14#ifndef MLIR_INTERFACES_INFERTYPEOPINTERFACE_H_
15#define MLIR_INTERFACES_INFERTYPEOPINTERFACE_H_
23#include "llvm/ADT/PointerUnion.h"
24#include "llvm/ADT/SmallVector.h"
36FailureOr<SmallVector<OpFoldResult>>
39 int resultIndex,
int dim);
46 if (
auto st = dyn_cast<ShapedType>(t))
50 if (
auto da = dyn_cast<DenseIntElementsAttr>(t))
92 explicit operator bool()
const {
return !val.isNull(); }
119 : elementType(elementType), attr(
nullptr), ranked(
false) {}
121 ranked = shapedType.hasRank();
122 elementType = shapedType.getElementType();
124 dims = llvm::to_vector<4>(shapedType.getShape());
132 template <
typename Arg,
typename = std::enable_if_t<
133 std::is_constructible<ShapeStorageT, Arg>::value>>
136 : dims(std::forward<Arg>(arg)), elementType(elementType), attr(attr),
140 : dims(vec.begin(), vec.end()), elementType(elementType), attr(attr),
146 assert(ranked &&
"requires ranked shape");
180 : RangeBaseT(values), operandShape(operandShape),
181 valueToShape(valueToShape) {}
246 SmallVectorImpl<Type> &inferredReturnTypes);
258template <
typename ConcreteType>
264#include "mlir/Interfaces/InferTypeOpInterface.h.inc"
269template <
typename ConcreteType>
273template <
typename ConcreteType>
275 :
public TraitBase<ConcreteType, InferShapedTypeOpAdaptor> {};
284template <
typename ConcreteType>
true
Given two iterators into the same block, return "true" if a is before `b.
false
Parses a map_entries map type from a string format back into its numeric value.
Attributes are known-constant values of operations.
This class helps build Operations.
Tensor type inference trait that constructs a tensor from the inferred shape and elemental types.
Helper class for implementing traits.
Operation is the basic unit of execution within MLIR.
Adaptor class to abstract the differences between whether value is from a ShapedType or ShapedTypeCom...
bool isDynamicDim(int index) const
Returns whether the index'th dimension is dynamic.
int64_t getDimSize(int index) const
Returns the size of the index'th dimension.
void dump() const
Dumps textual repesentation to stderr.
Type getElementType() const
Returns the element type.
ShapeAdaptor(Attribute t)
int64_t getRank() const
Returns the rank of the shape.
bool hasStaticShape() const
Returns whether the shape is fully static.
ShapeAdaptor(ShapedTypeComponents &components)
ShapeAdaptor(ShapedTypeComponents *components)
int64_t getNumElements() const
Returns the number of elements in the shape.
void getDims(SmallVectorImpl< int64_t > &res) const
Populates the dimensions from shape referenced.
bool hasRank() const
Returns whether the shape has a rank.
ShapedTypeComponents that represents the components of a ShapedType.
ShapedTypeComponents()
Default construction is an unranked shape.
ShapedTypeComponents(Arg &&arg, Type elementType=nullptr, Attribute attr=nullptr)
ShapedTypeComponents(ShapedType shapedType)
friend class ShapeAdaptor
ShapedTypeComponents(Type elementType)
ShapedTypeComponents(ArrayRef< int64_t > vec, Type elementType=nullptr, Attribute attr=nullptr)
ShapedTypeComponents(ShapeAdaptor adaptor)
bool hasRank() const
Return whether the shape has a rank.
Type getElementType() const
Return the element type component.
ArrayRef< int64_t > getDims() const
Return the dimensions of the shape.
Attribute getAttribute() const
Return the raw attribute component.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides an abstraction over the different types of ranges over Values.
ValueTypeIterator< iterator > type_iterator
Returns the types of the values within this range.
ValueShapeRange & setOperandShapeMapping(ValueShapeMapFn fn)
ValueTypeRange< ValueRange > type_range
ValueShapeRange & setValueToShapeMapping(ValueShapeMapFn fn)
Sets the Value to ShapeAdaptor mapping function and returns this.
ValueShapeMapFn getOperandShapeMapping() const
ValueShapeMapFn getValueToShapeMapping() const
Returns the set Value to ShapeAdaptor mapping function.
ValueShapeRange(const ValueShapeRange &)=default
ShapeAdaptor getValueAsShape(int index)
Returns an argument as shape.
type_range getTypes() const
ValueShapeRange(ValueRange values, ValueShapeMapFn operandShape=nullptr, ValueShapeMapFn valueToShape=nullptr)
ValueShapeRange(const std::initializer_list< Value > &values)
ShapeAdaptor getShape(int index) const
Returns the shape of index'th operand.
function_ref< ShapeAdaptor(Value)> ValueShapeMapFn
ValueRange getValues() const
Returns the Values in the ValueRange.
This class implements iteration on the types of a given range of values.
This class implements iteration on the types of a given range of values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
LogicalResult inferReturnTensorTypes(ArrayRef< ShapedTypeComponents > retComponents, SmallVectorImpl< Type > &inferredReturnTypes)
void reportFatalInferReturnTypesError(OperationState &state)
Report a fatal error indicating that the result types could not be inferred.
LogicalResult verifyInferredResultTypes(Operation *op)
Verifies that the inferred result types match the actual result types for the op.
Include the generated interface declarations.
LogicalResult reifyResultShapes(OpBuilder &b, Operation *op, ReifiedRankedShapedTypeDims &reifiedReturnShapes)
Reify the shape of the result of an operation (typically in terms of the shape of its operands).
FailureOr< OpFoldResult > reifyDimOfResult(OpBuilder &b, Operation *op, int resultIndex, int dim)
SmallVector< SmallVector< OpFoldResult > > ReifiedRankedShapedTypeDims
llvm::function_ref< Fn > function_ref
FailureOr< SmallVector< OpFoldResult > > reifyShapeOfResult(OpBuilder &b, Operation *op, int resultIndex)