...
1#include "main"
2
3#ifndef SHOULD_DEF
4#define SHOULD_DEF
5def ConstantOp : Toy_Op<"constant", [NoSideEffect]> {
6 // Provide a summary and description for this operation. This can be used to
7 // auto-generate documenatation of the operations within our dialect.
8 let summary = "constant operation";
9 let description = [{
10 Constant operation turns a literal into an SSA value. The data is attached
11 to the operation as an attribute. For example:
12
13 %0 = "toy.constant"()
14 { value = dense<[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]> : tensor<2x3xf64> }
15 : () -> tensor<2x3xf64>
16 }];
17
18 // The constant operation takes an attribute as the only input.
19 // `F64ElementsAttr` corresponds to a 64-bit floating-point ElementsAttr.
20 let arguments = (ins F64ElementsAttr:$value);
21
22 // The generic call operation returns a single value of TensorType.
23 // F64Tensor corresponds to a 64-bit floating-point TensorType.
24 let results = (outs F64Tensor<10>);
25
26 // Add additional verification logic to the constant operation.
27 let verifier = [{ return ::verify(*this); }];
28}
29#endif // SHOULD_DEF
View as plain text