13 #ifndef MLIR_DIALECT_TOSA_UTILS_SHAPEUTILS_H
14 #define MLIR_DIALECT_TOSA_UTILS_SHAPEUTILS_H
19 #include "llvm/ADT/Sequence.h"
20 #include "llvm/ADT/SmallVector.h"
37 sizes.reserve(newSizes.size());
38 for (
auto size : newSizes)
39 sizes.push_back(size);
47 if (
auto shapedType = dyn_cast<ShapedType>(type)) {
48 if (shapedType.hasRank()) {
50 result.
sizes.reserve(shapedType.getRank());
51 for (
auto dim : shapedType.getShape())
52 result.
sizes.push_back(dim);
54 result.
dtype = shapedType.getElementType();
114 result.
sizes.resize(lhs.
sizes.size(), ShapedType::kDynamic);
115 for (
auto i : llvm::seq<unsigned>(0, result.
sizes.size())) {
116 int64_t lhsSize = lhs.
sizes[i];
117 int64_t rhsSize = rhs.
sizes[i];
118 int64_t &resultSize = result.
sizes[i];
119 if (lhsSize == ShapedType::kDynamic) {
120 resultSize = rhsSize;
121 }
else if (rhsSize == ShapedType::kDynamic) {
122 resultSize = lhsSize;
123 }
else if (lhsSize == rhsSize) {
124 resultSize = lhsSize;
158 result.
sizes.resize(lhs.
sizes.size(), ShapedType::kDynamic);
159 for (
int i = 0, e = lhs.
sizes.size(); i < e; i++) {
ShapedTypeComponents that represents the components of a ShapedType.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
Statically known information for a particular Value.
static ValueKnowledge join(const ValueKnowledge &lhs, const ValueKnowledge &rhs)
bool operator==(const ValueKnowledge &rhs) const
static ValueKnowledge getPessimisticValueState()
static ValueKnowledge meet(const ValueKnowledge &lhs, const ValueKnowledge &rhs)
ShapedTypeComponents getShapedTypeComponents() const
ValueKnowledge(bool hasRank, llvm::ArrayRef< int64_t > newSizes, Type dtype)
static ValueKnowledge getKnowledgeFromType(Type type)
llvm::SmallVector< int64_t > sizes