aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatWai Chong <tatwai.chong@arm.com>2022-06-28 17:11:13 -0700
committerTatWai Chong <tatwai.chong@arm.com>2022-08-04 11:12:01 -0700
commitd13f5e6e8b964e2b10b5f4133043e59e45f11aaa (patch)
tree2c3df0448185e6cb05553ba38fb8b25d52fe1f64
parent9e3bea5045e25bade95e3d5fec3f43e72217a77a (diff)
downloadtosa_mlir_translator-d13f5e6e8b964e2b10b5f4133043e59e45f11aaa.tar.gz
Update TOSA resize to match specification
Attribute stride and shift are removed, and has new scale and border. Signed-off-by: TatWai Chong <tatwai.chong@arm.com> Change-Id: Id34072deb46ffce642530cc7499eb777cf9b82fc
-rw-r--r--src/TosaSerialize.cpp47
m---------third_party/serialization_lib0
2 files changed, 14 insertions, 33 deletions
diff --git a/src/TosaSerialize.cpp b/src/TosaSerialize.cpp
index a6ea5ff..7256385 100644
--- a/src/TosaSerialize.cpp
+++ b/src/TosaSerialize.cpp
@@ -968,23 +968,15 @@ TosaSerializationOperatorBuilder::build<mlir::tosa::ResizeOp>(
std::string input_name = GetTensorName(op.getOperand(0));
std::string output_name = GetTensorName(op.getResult(0));
- std::vector<int> output_size;
- auto output_size_attr =
- op.getAttr("output_size").dyn_cast<mlir::ArrayAttr>().getValue();
- for (auto &int_attr : output_size_attr) {
- output_size.push_back(int_attr.dyn_cast<mlir::IntegerAttr>().getInt());
+ std::vector<int16_t> scale;
+ auto scale_attr =
+ op.getAttr("scale").dyn_cast<mlir::ArrayAttr>().getValue();
+ for (auto &int_attr : scale_attr) {
+ scale.push_back(int_attr.dyn_cast<mlir::IntegerAttr>().getInt());
}
- ASSERT_VECTOR_LENGTH(output_size, 2);
+ ASSERT_VECTOR_LENGTH(scale, 4);
- std::vector<int> stride;
- auto stride_attr =
- op.getAttr("stride").dyn_cast<mlir::ArrayAttr>().getValue();
- for (auto &int_attr : stride_attr) {
- stride.push_back(int_attr.dyn_cast<mlir::IntegerAttr>().getInt());
- }
- ASSERT_VECTOR_LENGTH(stride, 2);
-
- std::vector<int> offset;
+ std::vector<int16_t> offset;
auto offset_attr =
op.getAttr("offset").dyn_cast<mlir::ArrayAttr>().getValue();
for (auto &int_attr : offset_attr) {
@@ -992,30 +984,19 @@ TosaSerializationOperatorBuilder::build<mlir::tosa::ResizeOp>(
}
ASSERT_VECTOR_LENGTH(offset, 2);
- int32_t shift = op.getAttr("shift").dyn_cast<mlir::IntegerAttr>().getInt();
-
- std::vector<float> stride_fp;
- auto stride_fp_attr =
- op.getAttr("stride_fp").dyn_cast<mlir::ArrayAttr>().getValue();
- for (auto &fp_attr : stride_fp_attr) {
- stride_fp.push_back(fp_attr.dyn_cast<mlir::FloatAttr>().getValueAsDouble());
- }
- ASSERT_VECTOR_LENGTH(stride_fp, 2);
-
- std::vector<float> offset_fp;
- auto offset_fp_attr =
- op.getAttr("offset_fp").dyn_cast<mlir::ArrayAttr>().getValue();
- for (auto &fp_attr : offset_fp_attr) {
- offset_fp.push_back(fp_attr.dyn_cast<mlir::FloatAttr>().getValueAsDouble());
+ std::vector<int16_t> border;
+ auto border_attr =
+ op.getAttr("border").dyn_cast<mlir::ArrayAttr>().getValue();
+ for (auto &int_attr : border_attr) {
+ border.push_back(int_attr.dyn_cast<mlir::IntegerAttr>().getInt());
}
- ASSERT_VECTOR_LENGTH(offset_fp, 2);
+ ASSERT_VECTOR_LENGTH(border, 2);
auto mode_str =
op.getAttr("mode").dyn_cast<mlir::StringAttr>().getValue().str();
ResizeMode mode = ResizeModeStr2Enum(mode_str);
- TosaResizeAttribute attribute(output_size, stride, offset, shift, stride_fp,
- offset_fp, mode);
+ TosaResizeAttribute attribute(scale, offset, border, mode);
TosaSerializationOperator *tyop = new TosaSerializationOperator(
Op_RESIZE, Attribute_ResizeAttribute, &attribute,
diff --git a/third_party/serialization_lib b/third_party/serialization_lib
-Subproject 343d6a703c3a270a01102ec468b59ef2967b595
+Subproject 49b1ca63975d4f1865ca312ed9c9b5e0008e13e