diff options
author | Tai Ly <tai.ly@arm.com> | 2024-02-22 22:22:24 +0000 |
---|---|---|
committer | Tai Ly <tai.ly@arm.com> | 2024-02-23 14:56:11 -0800 |
commit | 150bc9bcdea84f8c24a17d5f2fcb38128afe50ab (patch) | |
tree | f25ca6459504eee81c7a3b3a9022a846f481138b | |
parent | 3bdc1904e7fef906f030ca61f81b1371ba528c0d (diff) | |
download | tosa_mlir_translator-150bc9bcdea84f8c24a17d5f2fcb38128afe50ab.tar.gz |
[tosa_mlir_translator] Change resize attrs to inputs
This patch changes tosa resize op's scale/offset/border
from attributes to inputs of tosa.shape type
Signed-off-by: Tai Ly <tai.ly@arm.com>
Change-Id: I04750e25f4b01067418eb6123201e845c00ce8d8
-rw-r--r-- | src/TosaDeserialize.cpp | 11 | ||||
-rw-r--r-- | src/TosaSerialize.cpp | 17 |
2 files changed, 10 insertions, 18 deletions
diff --git a/src/TosaDeserialize.cpp b/src/TosaDeserialize.cpp index 1dcd88d..1f24f71 100644 --- a/src/TosaDeserialize.cpp +++ b/src/TosaDeserialize.cpp @@ -1202,6 +1202,9 @@ template <> std::vector<mlir::Value> TosaMlirOperatorBuilder::build<Op_RESIZE>(TosaSerializationOperator *op) const { mlir::Value input_val = tensor_map->at(op->GetInputTensorNames()[0]); + mlir::Value scale_val = tensor_map->at(op->GetInputTensorNames()[1]); + mlir::Value offset_val = tensor_map->at(op->GetInputTensorNames()[2]); + mlir::Value border_val = tensor_map->at(op->GetInputTensorNames()[3]); mlir::RankedTensorType output_type = tensor_type_map->at(op->GetOutputTensorNames()[0]); @@ -1210,16 +1213,10 @@ TosaMlirOperatorBuilder::build<Op_RESIZE>(TosaSerializationOperator *op) const { TosaResizeAttribute *attr = static_cast<TosaResizeAttribute *>(op->GetAttribute()); - mlir::DenseI64ArrayAttr scale = - BuildDenseI64ArrayAttr(op_builder, attr->scale()); - mlir::DenseI64ArrayAttr offset = - BuildDenseI64ArrayAttr(op_builder, attr->offset()); - mlir::DenseI64ArrayAttr border = - BuildDenseI64ArrayAttr(op_builder, attr->border()); auto mode = op_builder->getStringAttr(ResizeEnum2Str(attr->mode())); mlir::Operation *mlir_op = op_builder->create<mlir::tosa::ResizeOp>( - loc, output_type, input_val, scale, offset, border, mode); + loc, output_type, input_val, scale_val, offset_val, border_val, mode); block->push_back(mlir_op); return std::vector<mlir::Value>({mlir_op->getResult(0)}); } diff --git a/src/TosaSerialize.cpp b/src/TosaSerialize.cpp index 3569893..9a6cf84 100644 --- a/src/TosaSerialize.cpp +++ b/src/TosaSerialize.cpp @@ -1238,26 +1238,21 @@ TosaSerializationOperator * TosaSerializationOperatorBuilder::build<mlir::tosa::ResizeOp>( mlir::Operation &op) const { std::string input_name = GetTensorName(op.getOperand(0)); + std::string scale_name = GetTensorName(op.getOperand(1)); + std::string offset_name = GetTensorName(op.getOperand(2)); + std::string border_name = GetTensorName(op.getOperand(3)); std::string output_name = GetTensorName(op.getResult(0)); - auto scale = getDenseI64ArrayAttr<int16_t>(op.getAttr("scale")); - ASSERT_VECTOR_LENGTH(scale, 4); - - auto offset = getDenseI64ArrayAttr<int16_t>(op.getAttr("offset")); - ASSERT_VECTOR_LENGTH(offset, 2); - - auto border = getDenseI64ArrayAttr<int16_t>(op.getAttr("border")); - ASSERT_VECTOR_LENGTH(border, 2); - auto mode_str = op.getAttr("mode").dyn_cast<mlir::StringAttr>().getValue().str(); ResizeMode mode = ResizeModeStr2Enum(mode_str); - TosaResizeAttribute attribute(scale, offset, border, mode); + TosaResizeAttribute attribute({}, {}, {}, mode); TosaSerializationOperator *tyop = new TosaSerializationOperator( Op_RESIZE, Attribute_ResizeAttribute, &attribute, - std::vector<std::string>{input_name}, + std::vector<std::string>{input_name, scale_name, offset_name, + border_name}, std::vector<std::string>{output_name}); return tyop; |