9 #ifndef MLIR_DIALECT_LINALG_LINALGTRAITS_H_ 10 #define MLIR_DIALECT_LINALG_LINALGTRAITS_H_ 29 template <
typename ConcreteType>
43 template <
typename ConcreteType>
57 template <
typename ConcreteType>
67 return cast<ConcreteType>(this->
getOperation()).getNumOutputs();
73 assert(i < nInputs());
79 auto it = llvm::find(getInputs(), value);
80 if (it != getInputs().end())
81 return it - getInputs().begin();
86 return getInput(i)->getType().template cast<ShapedType>();
91 return {
range.begin(),
range.begin() + nInputs()};
100 auto it = llvm::find(getOutputs(), value);
101 if (it != getOutputs().end())
102 return it - getOutputs().begin();
107 return getOutput(i)->getType().template cast<ShapedType>();
112 llvm::all_of(getInputsAndOutputs(),
118 for (
Type type : getInputs().getTypes())
119 if (
auto t = type.template dyn_cast<RankedTensorType>())
126 for (
Type type : getOutputs().getTypes())
127 if (
auto t = type.template dyn_cast<RankedTensorType>())
134 return {
range.begin() + nInputs(),
135 range.begin() + getNumInputsAndOutputs()};
141 return (i < nInputs()) ? getInputShapedType(i)
142 : getOutputShapedType(i - nInputs());
147 return {
range.begin(),
range.begin() + getNumInputsAndOutputs()};
151 getParallelIteratorTypeName(),
152 cast<ConcreteType>(this->
getOperation()).iterator_types());
156 getReductionIteratorTypeName(),
157 cast<ConcreteType>(this->
getOperation()).iterator_types());
161 getWindowIteratorTypeName(),
162 cast<ConcreteType>(this->
getOperation()).iterator_types());
166 cast<ConcreteType>(this->
getOperation()).iterator_types());
169 auto nOperands = cast<ConcreteType>(op).getNumInputsAndOutputs();
180 #endif // MLIR_DIALECT_LINALG_LINALGTRAITS_H_ Definition: InferTypeOpInterface.cpp:20
Operation::operand_range getInputs()
Return the range over inputs.
Definition: LinalgTraits.h:89
ShapedType getInputShapedType(unsigned i)
Return the i-th input buffer type.
Definition: LinalgTraits.h:85
Definition: Operation.h:27
bool hasBufferSemantics()
Query whether the op has only MemRef input and outputs.
Definition: LinalgTraits.h:110
ShapedType getShapedType(unsigned i)
Return the i-th buffer type.
Definition: LinalgTraits.h:140
operand_range getOperands()
Returns an iterator on the underlying Value's (Value ).
Definition: Operation.h:220
Value getOperand(unsigned idx)
Definition: Operation.h:207
bool failed(LogicalResult result)
Definition: LogicalResult.h:45
Definition: LinalgTraits.h:58
static LogicalResult verifyTrait(Operation *op)
Definition: LinalgTraits.h:168
unsigned getNumReductionLoops()
Definition: LinalgTraits.h:154
Definition: LinalgTraits.h:41
Definition: StandardTypes.h:178
Value getOutput(unsigned i)
Return the i-th output.
Definition: LinalgTraits.h:94
Operation::operand_range getOutputs()
Return the range over outputs.
Definition: LinalgTraits.h:132
unsigned getNumResults()
Return the number of results held by this operation.
Definition: Operation.cpp:548
LogicalResult success(bool isSuccess=true)
Definition: LogicalResult.h:25
unsigned getNumLoops()
Definition: LinalgTraits.h:164
Definition: LogicalResult.h:18
LogicalResult failure(bool isFailure=true)
Definition: LogicalResult.h:32
unsigned getNumIterators(StringRef name, ArrayAttr iteratorTypes)
Returns the iterator of a certain type.
Definition: StructuredOpsUtils.h:87
Type getType() const
Return the type of this value.
Definition: Value.cpp:34
static unsigned getNumOutputs()
Definition: LinalgTraits.h:46
Operation::operand_range getInputsAndOutputs()
Return the range over inputs and outputs.
Definition: LinalgTraits.h:145
Definition: StandardTypes.h:390
SmallVector< RankedTensorType, 4 > getInputTensorTypes()
Query the subset of input operands that are of ranked tensor type.
Definition: LinalgTraits.h:116
Value getInput(unsigned i)
Return the i-th input value.
Definition: LinalgTraits.h:72
ShapedType getOutputShapedType(unsigned i)
Return the i-th output buffer type.
Definition: LinalgTraits.h:106
LogicalResult verifyAtLeastNOperands(Operation *op, unsigned numOperands)
Definition: Operation.cpp:768
Definition: OpDefinition.h:386
Definition: LinalgTraits.h:44
Optional< unsigned > getIndexOfOutput(Value value)
Definition: LinalgTraits.h:99
Optional< unsigned > getIndexOfInput(Value value)
Definition: LinalgTraits.h:78
This class implements the operand iterators for the Operation class.
Definition: OperationSupport.h:559
unsigned getNumParallelLoops()
Definition: LinalgTraits.h:149
Definition: StandardTypes.h:63
mlir::edsc::intrinsics::ValueBuilder< RangeOp > range
Definition: Intrinsics.h:23
unsigned getNumInputsAndOutputs()
Return the number of inputs and outputs.
Definition: LinalgTraits.h:138
SmallVector< RankedTensorType, 4 > getOutputTensorTypes()
Query the subset of output operands that are of ranked tensor type.
Definition: LinalgTraits.h:124
bool isa() const
Definition: Types.h:254
unsigned getNumWindowLoops()
Definition: LinalgTraits.h:159
Operation * getOperation()
Return the ultimate Operation being worked on.
Definition: OpDefinition.h:389