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();
72 return UnrankedTensorType::get(
dtype);
89 if (!lhs || !rhs || lhs.dtype != rhs.dtype)
95 if (!lhs.hasRank && !rhs.hasRank)
110 if (lhs.sizes.size() != rhs.sizes.size())
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];
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;
141 if (!lhs || !rhs || lhs.dtype != rhs.dtype)
147 if (!lhs.hasRank || !rhs.hasRank) {
152 if (lhs.sizes.size() != rhs.sizes.size()) {
158 result.sizes.resize(lhs.sizes.size(), ShapedType::kDynamic);
159 for (
int i = 0, e = lhs.sizes.size(); i < e; i++) {
160 if (lhs.sizes[i] == rhs.sizes[i]) {
161 result.sizes[i] = lhs.sizes[i];
false
Parses a map_entries map type from a string format back into its numeric value.
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.
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