From 150bc9bcdea84f8c24a17d5f2fcb38128afe50ab Mon Sep 17 00:00:00 2001 From: Tai Ly Date: Thu, 22 Feb 2024 22:22:24 +0000 Subject: [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 Change-Id: I04750e25f4b01067418eb6123201e845c00ce8d8 --- src/TosaDeserialize.cpp | 11 ++++------- 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 TosaMlirOperatorBuilder::build(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(TosaSerializationOperator *op) const { TosaResizeAttribute *attr = static_cast(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( - 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_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::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(op.getAttr("scale")); - ASSERT_VECTOR_LENGTH(scale, 4); - - auto offset = getDenseI64ArrayAttr(op.getAttr("offset")); - ASSERT_VECTOR_LENGTH(offset, 2); - - auto border = getDenseI64ArrayAttr(op.getAttr("border")); - ASSERT_VECTOR_LENGTH(border, 2); - auto mode_str = op.getAttr("mode").dyn_cast().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{input_name}, + std::vector{input_name, scale_name, offset_name, + border_name}, std::vector{output_name}); return tyop; -- cgit v1.2.1