From 3621cb96a5fce800fc18a48e63edb136e3e8ab54 Mon Sep 17 00:00:00 2001 From: Hyeongseok Oh Date: Wed, 7 May 2025 19:25:31 +0900 Subject: [PATCH] [onert] Remove MatrixBandPart support This commit removes MatrixBandPart support in onert and tests. MatrixBandPart is split into many other builtin ops. ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh --- .../include/cker/operation/MatrixBandPart.h | 78 ------------------ runtime/onert/backend/cpu/KernelGenerator.cc | 19 ----- runtime/onert/backend/cpu/KernelGenerator.h | 1 - .../backend/cpu/ops/MatrixBandPartLayer.cc | 81 ------------------- .../backend/cpu/ops/MatrixBandPartLayer.h | 51 ------------ .../include/compiler/StaticShapeInferer.h | 1 - .../core/include/exec/DynamicShapeInferer.h | 1 - .../core/include/ir/Operations.Include.h | 1 - runtime/onert/core/include/ir/Operations.lst | 1 - .../include/ir/operation/MatrixBandPart.h | 47 ----------- .../onert/core/src/compiler/ShapeValidator.cc | 19 ----- .../onert/core/src/compiler/ShapeValidator.h | 1 - .../core/src/compiler/StaticShapeInferer.cc | 5 -- .../core/src/exec/DynamicShapeInferer.cc | 5 -- .../core/src/ir/operation/MatrixBandPart.cc | 31 ------- .../operation/UntrainableOperation.test.cc | 14 ---- runtime/onert/core/src/loader/BaseLoader.h | 5 -- .../nnapi/bridge/include/NeuralNetworksEx.h | 16 +--- .../nnapi/bridge/wrapper/OperationFactory.cc | 15 ---- .../nnapi_gtest.skip.aarch64-android.acl_cl | 2 - .../nnapi_gtest.skip.aarch64-android.acl_neon | 2 - .../nnapi_gtest.skip.aarch64-linux.acl_cl | 2 - .../nnapi_gtest.skip.aarch64-linux.acl_neon | 2 - .../nnapi_gtest.skip.armv7l-linux.acl_cl | 2 - .../nnapi_gtest.skip.armv7l-linux.acl_neon | 2 - .../Ex/matrix_band_part_ex_4D_float.mod.py | 38 --------- .../matrix_band_part_ex_dynamic_nnfw.mod.py | 27 ------- 27 files changed, 2 insertions(+), 467 deletions(-) delete mode 100644 runtime/compute/cker/include/cker/operation/MatrixBandPart.h delete mode 100644 runtime/onert/backend/cpu/ops/MatrixBandPartLayer.cc delete mode 100644 runtime/onert/backend/cpu/ops/MatrixBandPartLayer.h delete mode 100644 runtime/onert/core/include/ir/operation/MatrixBandPart.h delete mode 100644 runtime/onert/core/src/ir/operation/MatrixBandPart.cc delete mode 100644 runtime/tests/nnapi/specs/Ex/matrix_band_part_ex_4D_float.mod.py delete mode 100644 runtime/tests/nnapi/specs/Ex/matrix_band_part_ex_dynamic_nnfw.mod.py diff --git a/runtime/compute/cker/include/cker/operation/MatrixBandPart.h b/runtime/compute/cker/include/cker/operation/MatrixBandPart.h deleted file mode 100644 index ef2868455cf..00000000000 --- a/runtime/compute/cker/include/cker/operation/MatrixBandPart.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * Copyright 2017 The TensorFlow Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __NNFW_CKER_MATRIX_BAND_PART_H__ -#define __NNFW_CKER_MATRIX_BAND_PART_H__ - -#include "cker/Shape.h" - -#include - -namespace nnfw -{ -namespace cker -{ -template -void MatrixBandPart(const T num_lower_diags, const T num_upper_diags, const Shape &input_shape, - const float *input_data, const Shape &output_shape, float *output_data) -{ - auto last_dim = input_shape.DimensionsCount() - 1; - - T batch_num = 1; - for (int dim = 0; dim < input_shape.DimensionsCount() - 2; dim++) - { - batch_num *= input_shape.Dims(dim); - } - - const T row_num = input_shape.Dims(last_dim - 1); - const T col_num = input_shape.Dims(last_dim); - - if (!(num_lower_diags <= row_num)) - throw std::runtime_error( - "MatrixBandPart : num_lower must be negative or less or equal to number of rows"); - - if (!(num_upper_diags <= col_num)) - throw std::runtime_error( - "MatrixBandPart : num_upper must be negative or less or equal to number of columns"); - - std::fill(output_data, output_data + output_shape.FlatSize(), 0); // output matrix init - - // reference code, without multithreading - for (T batch = 0; batch < batch_num; ++batch) - { - for (T row = 0; row < row_num; ++row) - { - auto output = output_data + (batch * row_num * col_num + row * col_num); - auto input = input_data + (batch * row_num * col_num + row * col_num); - - const T band_start = - num_lower_diags < 0 ? 0 : std::min(col_num, std::max(T{0}, row - num_lower_diags)); - const T band_end = num_upper_diags < 0 - ? col_num - : std::min(static_cast(col_num), row + num_upper_diags + 1); - - for (T band_idx = band_start; band_idx < band_end; band_idx++) - { - output[band_idx] = input[band_idx]; - } - } - } -} -} // namespace cker -} // namespace nnfw - -#endif // __NNFW_CKER_MATRIX_BAND_PART_H__ diff --git a/runtime/onert/backend/cpu/KernelGenerator.cc b/runtime/onert/backend/cpu/KernelGenerator.cc index 7030c759a2a..fc11ed88ec6 100644 --- a/runtime/onert/backend/cpu/KernelGenerator.cc +++ b/runtime/onert/backend/cpu/KernelGenerator.cc @@ -63,7 +63,6 @@ #include "ops/UnpackLayer.h" #include "ops/SquaredDiffLayer.h" #include "ops/L2NormLayer.h" -#include "ops/MatrixBandPartLayer.h" #include "ops/BatchMatMulLayer.h" #include "ops/BroadcastToLayer.h" #include "ops/FusedBatchNormLayer.h" @@ -1132,24 +1131,6 @@ void KernelGenerator::visit(const ir::operation::Tile &node) _return_fn = std::move(fn); } -void KernelGenerator::visit(const ir::operation::MatrixBandPart &node) -{ - const auto output_index{node.getOutputs().at(0)}; - const auto input_index{node.getInputs().at(ir::operation::MatrixBandPart::INPUT)}; - const auto num_lower_index{node.getInputs().at(ir::operation::MatrixBandPart::NUM_LOWER_DIAG)}; - const auto num_upper_index{node.getInputs().at(ir::operation::MatrixBandPart::NUM_UPPER_DIAG)}; - - auto output_tensor = _tensor_reg->getPortableTensor(output_index); - auto input_tensor = _tensor_reg->getPortableTensor(input_index); - auto num_lower_tensor = _tensor_reg->getPortableTensor(num_lower_index); - auto num_upper_tensor = _tensor_reg->getPortableTensor(num_upper_index); - - auto fn = std::make_unique(); - - fn->configure(input_tensor, num_lower_tensor, num_upper_tensor, output_tensor); - _return_fn = std::move(fn); -} - void KernelGenerator::visit(const ir::operation::DetectionPostProcess &node) { using NMS = ir::operation::DetectionPostProcess; diff --git a/runtime/onert/backend/cpu/KernelGenerator.h b/runtime/onert/backend/cpu/KernelGenerator.h index 5ead87e61f6..7a4837637d5 100644 --- a/runtime/onert/backend/cpu/KernelGenerator.h +++ b/runtime/onert/backend/cpu/KernelGenerator.h @@ -63,7 +63,6 @@ class KernelGenerator : public basic::KernelGeneratorBase void visit(const ir::operation::L2Normalization &) override; void visit(const ir::operation::LogSoftmax &) override; void visit(const ir::operation::LSTM &) override; - void visit(const ir::operation::MatrixBandPart &) override; void visit(const ir::operation::DetectionPostProcess &) override; void visit(const ir::operation::OneHot &) override; void visit(const ir::operation::Pack &) override; diff --git a/runtime/onert/backend/cpu/ops/MatrixBandPartLayer.cc b/runtime/onert/backend/cpu/ops/MatrixBandPartLayer.cc deleted file mode 100644 index f42b8cdeaab..00000000000 --- a/runtime/onert/backend/cpu/ops/MatrixBandPartLayer.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "MatrixBandPartLayer.h" - -#include "OperationUtils.h" - -#include - -namespace onert::backend::cpu::ops -{ - -MatrixBandPartLayer::MatrixBandPartLayer() - : _input(nullptr), _num_lower_diag(nullptr), _num_upper_diag(nullptr), _output(nullptr) -{ - // DO NOTHING -} - -void MatrixBandPartLayer::matrixBandPartFloat32() -{ - if (_num_lower_diag->data_type() == OperandType::INT64) - { - nnfw::cker::MatrixBandPart( - *getBuffer(_num_lower_diag), *getBuffer(_num_upper_diag), getShape(_input), - getBuffer(_input), getShape(_output), getBuffer(_output)); - } - else - { - nnfw::cker::MatrixBandPart( - *getBuffer(_num_lower_diag), *getBuffer(_num_upper_diag), getShape(_input), - getBuffer(_input), getShape(_output), getBuffer(_output)); - } -} - -void MatrixBandPartLayer::matrixBandPartQuant8() { throw std::runtime_error{"NYI"}; } - -void MatrixBandPartLayer::configure(const IPortableTensor *input, - const IPortableTensor *num_lower_diag, - const IPortableTensor *num_upper_diag, IPortableTensor *output) -{ - _input = input; - _num_lower_diag = num_lower_diag; - _num_upper_diag = num_upper_diag; - _output = output; -} - -void MatrixBandPartLayer::run() -{ - if (_num_lower_diag->data_type() != _num_upper_diag->data_type()) - { - throw std::runtime_error{"MatrixBandpart: num_lower and num_upper must have the same type"}; - } - - if (_input->data_type() == OperandType::FLOAT32) - { - matrixBandPartFloat32(); - } - else if (_input->data_type() == OperandType::QUANT_UINT8_ASYMM) - { - matrixBandPartQuant8(); - } - else - { - throw std::runtime_error{"MatrixBandpart: unsupported data type"}; - } -} - -} // namespace onert::backend::cpu::ops diff --git a/runtime/onert/backend/cpu/ops/MatrixBandPartLayer.h b/runtime/onert/backend/cpu/ops/MatrixBandPartLayer.h deleted file mode 100644 index 992e04093a8..00000000000 --- a/runtime/onert/backend/cpu/ops/MatrixBandPartLayer.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in riting, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __ONERT_BACKEND_CPU_OPS_MATRIXBANDPARTLAYER_H__ -#define __ONERT_BACKEND_CPU_OPS_MATRIXBANDPARTLAYER_H__ - -#include - -#include - -namespace onert::backend::cpu::ops -{ - -class MatrixBandPartLayer : public ::onert::exec::IFunction -{ -public: - MatrixBandPartLayer(); - -public: - void matrixBandPartFloat32(); - - void matrixBandPartQuant8(); - - void configure(const IPortableTensor *input, const IPortableTensor *num_lower_diag, - const IPortableTensor *num_upper_diag, IPortableTensor *output); - - void run() override; - -private: - const IPortableTensor *_input; - const IPortableTensor *_num_lower_diag; - const IPortableTensor *_num_upper_diag; - IPortableTensor *_output; -}; - -} // namespace onert::backend::cpu::ops - -#endif // __ONERT_BACKEND_CPU_OPS_MATRIXBANDPARTLAYER_H__ diff --git a/runtime/onert/core/include/compiler/StaticShapeInferer.h b/runtime/onert/core/include/compiler/StaticShapeInferer.h index 8619467e979..c9fe7541a2e 100644 --- a/runtime/onert/core/include/compiler/StaticShapeInferer.h +++ b/runtime/onert/core/include/compiler/StaticShapeInferer.h @@ -137,7 +137,6 @@ class StaticShapeInferer : public ir::OperationVisitor void visit(const ir::operation::L2Normalization &op) override; void visit(const ir::operation::Loss &op) override; void visit(const ir::operation::LSTM &op) override; - void visit(const ir::operation::MatrixBandPart &op) override; void visit(const ir::operation::OneHot &op) override; void visit(const ir::operation::Pack &op) override; void visit(const ir::operation::Pad &op) override; diff --git a/runtime/onert/core/include/exec/DynamicShapeInferer.h b/runtime/onert/core/include/exec/DynamicShapeInferer.h index 65b623cc564..14a09e8a0af 100644 --- a/runtime/onert/core/include/exec/DynamicShapeInferer.h +++ b/runtime/onert/core/include/exec/DynamicShapeInferer.h @@ -62,7 +62,6 @@ class DynamicShapeInferer : public ir::OperationVisitor void visit(const ir::operation::Gather &op) override; void visit(const ir::operation::L2Normalization &op) override; void visit(const ir::operation::LSTM &op) override; - void visit(const ir::operation::MatrixBandPart &op) override; void visit(const ir::operation::DetectionPostProcess &op) override; void visit(const ir::operation::OneHot &op) override; void visit(const ir::operation::Pack &op) override; diff --git a/runtime/onert/core/include/ir/Operations.Include.h b/runtime/onert/core/include/ir/Operations.Include.h index 82024217027..b1dc5cb0e51 100644 --- a/runtime/onert/core/include/ir/Operations.Include.h +++ b/runtime/onert/core/include/ir/Operations.Include.h @@ -50,7 +50,6 @@ #include "ir/operation/LogSoftmax.h" #include "ir/operation/Loss.h" #include "ir/operation/LSTM.h" -#include "ir/operation/MatrixBandPart.h" #include "ir/operation/DetectionPostProcess.h" #include "ir/operation/OneHot.h" #include "ir/operation/Pack.h" diff --git a/runtime/onert/core/include/ir/Operations.lst b/runtime/onert/core/include/ir/Operations.lst index 0b87d2c76b9..03e9de8fae0 100644 --- a/runtime/onert/core/include/ir/Operations.lst +++ b/runtime/onert/core/include/ir/Operations.lst @@ -52,7 +52,6 @@ OP(L2Normalization) OP(LocalResponseNormalization) OP(LogSoftmax) OP(LSTM) -OP(MatrixBandPart) OP(DetectionPostProcess) OP(OneHot) OP(Pack) diff --git a/runtime/onert/core/include/ir/operation/MatrixBandPart.h b/runtime/onert/core/include/ir/operation/MatrixBandPart.h deleted file mode 100644 index 68363f5d681..00000000000 --- a/runtime/onert/core/include/ir/operation/MatrixBandPart.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __ONERT_IR_OPERATION_MATRIX_BAND_PART_H__ -#define __ONERT_IR_OPERATION_MATRIX_BAND_PART_H__ - -#include - -#include "ir/Operation.h" - -namespace onert::ir::operation -{ - -class MatrixBandPart : public Operation -{ -public: - enum Input - { - INPUT = 0, - NUM_LOWER_DIAG, - NUM_UPPER_DIAG, - }; - -public: - MatrixBandPart(const OperandIndexSequence &inputs, const OperandIndexSequence &outputs); - -public: - void accept(OperationVisitor &v) const override; - OpCode opcode() const final { return OpCode::MatrixBandPart; } -}; - -} // namespace onert::ir::operation - -#endif // __ONERT_IR_OPERATION_MATRIX_BAND_PART_H__ diff --git a/runtime/onert/core/src/compiler/ShapeValidator.cc b/runtime/onert/core/src/compiler/ShapeValidator.cc index fec3b10afa2..f49a133ac05 100644 --- a/runtime/onert/core/src/compiler/ShapeValidator.cc +++ b/runtime/onert/core/src/compiler/ShapeValidator.cc @@ -1111,25 +1111,6 @@ void ShapeValidator::visit(const ir::operation::Range &node) OP_REQUIRES(operands.at(delta_index).shape().rank() == 0); } -void ShapeValidator::visit(const ir::operation::MatrixBandPart &node) -{ - const auto &operands = _graph.operands(); - const auto output_index{node.getOutputs().at(0)}; - const auto input_index{node.getInputs().at(ir::operation::MatrixBandPart::Input::INPUT)}; - const auto num_lower_index{ - node.getInputs().at(ir::operation::MatrixBandPart::Input::NUM_LOWER_DIAG)}; - const auto num_upper_index{ - node.getInputs().at(ir::operation::MatrixBandPart::Input::NUM_UPPER_DIAG)}; - - // Check for dimension constraints - if (operands.at(output_index).info().isDynamic()) - return; - - OP_REQUIRES(operands.at(input_index).shape().rank() >= 2); // input must be more than 2 dim matrix - OP_REQUIRES(operands.at(num_upper_index).shape().rank() == 0); // num_lower must be scalar - OP_REQUIRES(operands.at(num_lower_index).shape().rank() == 0); // num_upper must be scalar -} - void ShapeValidator::visit(const ir::operation::LogSoftmax &node) { const auto &operands = _graph.operands(); diff --git a/runtime/onert/core/src/compiler/ShapeValidator.h b/runtime/onert/core/src/compiler/ShapeValidator.h index 725e589e440..b002b01be42 100644 --- a/runtime/onert/core/src/compiler/ShapeValidator.h +++ b/runtime/onert/core/src/compiler/ShapeValidator.h @@ -87,7 +87,6 @@ class ShapeValidator : public ir::OperationVisitor void visit(const ir::operation::SquaredDifference &node) override; void visit(const ir::operation::Tile &node) override; void visit(const ir::operation::Range &node) override; - void visit(const ir::operation::MatrixBandPart &node) override; void visit(const ir::operation::LogSoftmax &node) override; void visit(const ir::operation::RmsNorm &node) override; void visit(const ir::operation::RoPE &node) override; diff --git a/runtime/onert/core/src/compiler/StaticShapeInferer.cc b/runtime/onert/core/src/compiler/StaticShapeInferer.cc index d86ca4724cd..c0166303dc5 100644 --- a/runtime/onert/core/src/compiler/StaticShapeInferer.cc +++ b/runtime/onert/core/src/compiler/StaticShapeInferer.cc @@ -745,11 +745,6 @@ void StaticShapeInferer::visit(const ir::operation::LSTM &op) } } -void StaticShapeInferer::visit(const ir::operation::MatrixBandPart &op) -{ - handleSimpleUnaryOp(op, op.getInputs().at(ir::operation::MatrixBandPart::Input::INPUT)); -} - void StaticShapeInferer::visit(const ir::operation::OneHot &op) { auto &operands = _lowered_subg->graph().operands(); diff --git a/runtime/onert/core/src/exec/DynamicShapeInferer.cc b/runtime/onert/core/src/exec/DynamicShapeInferer.cc index a3901e629fd..50ead4979e1 100644 --- a/runtime/onert/core/src/exec/DynamicShapeInferer.cc +++ b/runtime/onert/core/src/exec/DynamicShapeInferer.cc @@ -594,11 +594,6 @@ void DynamicShapeInferer::visit(const ir::operation::LSTM &op) } } -void DynamicShapeInferer::visit(const ir::operation::MatrixBandPart &op) -{ - handleSimpleUnaryOp(op, op.getInputs().at(ir::operation::MatrixBandPart::INPUT)); -} - void DynamicShapeInferer::visit(const ir::operation::DetectionPostProcess & /* op */) { // NOTE DetectionPostProcess's undefined outputs' shape are decided on compile time diff --git a/runtime/onert/core/src/ir/operation/MatrixBandPart.cc b/runtime/onert/core/src/ir/operation/MatrixBandPart.cc deleted file mode 100644 index 43a28707d73..00000000000 --- a/runtime/onert/core/src/ir/operation/MatrixBandPart.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ir/operation/MatrixBandPart.h" -#include "ir/OperationVisitor.h" - -namespace onert::ir::operation -{ - -void MatrixBandPart::accept(OperationVisitor &v) const { v.visit(*this); } - -MatrixBandPart::MatrixBandPart(const OperandIndexSequence &inputs, - const OperandIndexSequence &outputs) - : Operation{OperandConstraint::createExact(3u), inputs, outputs} -{ -} - -} // namespace onert::ir::operation diff --git a/runtime/onert/core/src/ir/train/operation/UntrainableOperation.test.cc b/runtime/onert/core/src/ir/train/operation/UntrainableOperation.test.cc index a0eb5d4afdb..961f8a917b2 100644 --- a/runtime/onert/core/src/ir/train/operation/UntrainableOperation.test.cc +++ b/runtime/onert/core/src/ir/train/operation/UntrainableOperation.test.cc @@ -295,11 +295,6 @@ operation::LSTM generateLSTM() OperandIndexSequence{0}, param}; } -operation::MatrixBandPart generateMatrixBandPart() -{ - return operation::MatrixBandPart{OperandIndexSequence{1, 2, 3}, OperandIndexSequence{0}}; -} - operation::OneHot generateOneHot() { operation::OneHot::Param param; @@ -702,9 +697,6 @@ TEST(UntrainableOperation, testAllOps) const auto lstm = generateLSTM(); verifyOp(lstm); - const auto maxrix_band_part = generateMatrixBandPart(); - verifyOp(maxrix_band_part); - const auto one_hot = generateOneHot(); verifyOp(one_hot); @@ -1027,12 +1019,6 @@ TEST(UntrainableOperation, neg_TrainableOperationVisitor) EXPECT_ANY_THROW(visitor.invoke(*untrainable)); } - { - const auto matrix_band_part = generateMatrixBandPart(); - auto untrainable = generateUntrainableOperation(matrix_band_part); - EXPECT_ANY_THROW(visitor.invoke(*untrainable)); - } - { const auto one_hot = generateOneHot(); auto untrainable = generateUntrainableOperation(one_hot); diff --git a/runtime/onert/core/src/loader/BaseLoader.h b/runtime/onert/core/src/loader/BaseLoader.h index 5fb65319f14..874860e45be 100644 --- a/runtime/onert/core/src/loader/BaseLoader.h +++ b/runtime/onert/core/src/loader/BaseLoader.h @@ -1039,7 +1039,6 @@ void BaseLoader::loadCustom(const Operator *op, ir::Graph &subg) enum class BuiltinOP { - MatrixBandPart, FusedBatchNorm, StatelessRandomUniform, Erf, @@ -1048,7 +1047,6 @@ void BaseLoader::loadCustom(const Operator *op, ir::Graph &subg) // Mapping from custom op name string to BuiltinOP enum std::map builtin_map = { - {"MatrixBandPart", BuiltinOP::MatrixBandPart}, {"FusedBatchNormV3", BuiltinOP::FusedBatchNorm}, {"StatelessRandomUniform", BuiltinOP::StatelessRandomUniform}, {"Erf", BuiltinOP::Erf}, @@ -1061,9 +1059,6 @@ void BaseLoader::loadCustom(const Operator *op, ir::Graph &subg) auto custom_op_id = builtin_map.at(custom_op_name); switch (custom_op_id) { - case BuiltinOP::MatrixBandPart: - loadOperationTo(op, subg); - break; case BuiltinOP::FusedBatchNorm: loadFusedBatchNorm(op, subg); break; diff --git a/runtime/tests/nnapi/bridge/include/NeuralNetworksEx.h b/runtime/tests/nnapi/bridge/include/NeuralNetworksEx.h index 368e989ee89..0c8b6761fb8 100644 --- a/runtime/tests/nnapi/bridge/include/NeuralNetworksEx.h +++ b/runtime/tests/nnapi/bridge/include/NeuralNetworksEx.h @@ -486,22 +486,10 @@ typedef enum ANEURALNETWORKS_BATCH_MATMUL_EX = 50035, /** - * Copy a tensor setting everything outside a central band in each innermost matrix. * - * Supported tensor {@link OperandCode}: - * * {@link ANEURALNETWORKS_TENSOR_FLOAT32} - * - * Supported tensor rank: up to 4 - * - * Inputs: - * * 0: A tensor. - * * 1: An {@link ANEURALNETWORKS_INT32} scalar. Number of subdiagonals to keep. If negative, keep - * entire lower triangle. - * * 2: An {@link ANEURALNETWORKS_INT32} scalar. Number of superdiagonals to keep. If negative, - * keep entire upper triangle. + * IMPORTANT NOTICE: + * ANEURALNETWORKS_MATRIX_BAND_PART_EX operation is DEPRECATED * - * Outputs: - * * 0: An output tensor. The extracted banded tensor with the same shape as input. */ ANEURALNETWORKS_MATRIX_BAND_PART_EX = 50036, diff --git a/runtime/tests/nnapi/bridge/wrapper/OperationFactory.cc b/runtime/tests/nnapi/bridge/wrapper/OperationFactory.cc index 0b12d376889..9dcfa4a24dd 100644 --- a/runtime/tests/nnapi/bridge/wrapper/OperationFactory.cc +++ b/runtime/tests/nnapi/bridge/wrapper/OperationFactory.cc @@ -1527,21 +1527,6 @@ OperationFactory::OperationFactory() // 1 -> Multiple Tensor Index _map[ANEURALNETWORKS_TILE] = createSimpleBinaryOp; - _map[ANEURALNETWORKS_MATRIX_BAND_PART_EX] = [](const OperationFactory::Param &init_param, - Operands &) { - assert(init_param.input_count == 3); - assert(init_param.output_count == 1); - // Each input should be interpreted as follows: - // - // 0 -> A tensor, input - // 1 -> A 0-D tensor, number of lower diagnonals to keep - // 2 -> A 0-D tensor, number of upper diagnonals to keep - OperandIndexSequence inputs{init_param.inputs[0], init_param.inputs[1], init_param.inputs[2]}; - OperandIndexSequence outputs{init_param.outputs[0]}; - - return new operation::MatrixBandPart{inputs, outputs}; - }; - _map[ANEURALNETWORKS_BATCH_MATMUL_EX] = [](const OperationFactory::Param &init_param, Operands &operands) { assert(init_param.input_count == 4 && init_param.output_count == 1); diff --git a/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-android.acl_cl b/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-android.acl_cl index 5fa03711e44..ab58fac3ccc 100644 --- a/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-android.acl_cl +++ b/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-android.acl_cl @@ -113,8 +113,6 @@ GeneratedTests.lstm3_state2 GeneratedTests.lstm3_state3 GeneratedTests.lstm_state GeneratedTests.lstm_state2 -GeneratedTests.matrix_band_part_ex_4D_float -GeneratedTests.matrix_band_part_ex_dynamic_nnfw GeneratedTests.maximum_dynamic_nnfw GeneratedTests.minimum_dynamic_nnfw GeneratedTests.minimum_int32 diff --git a/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-android.acl_neon b/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-android.acl_neon index 042e8f71ced..f19f495346f 100644 --- a/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-android.acl_neon +++ b/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-android.acl_neon @@ -118,8 +118,6 @@ GeneratedTests.lstm3_state2 GeneratedTests.lstm3_state3 GeneratedTests.lstm_state GeneratedTests.lstm_state2 -GeneratedTests.matrix_band_part_ex_4D_float -GeneratedTests.matrix_band_part_ex_dynamic_nnfw GeneratedTests.maximum_dynamic_nnfw GeneratedTests.minimum_dynamic_nnfw GeneratedTests.mul_dynamic_nnfw diff --git a/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-linux.acl_cl b/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-linux.acl_cl index 5fa03711e44..ab58fac3ccc 100644 --- a/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-linux.acl_cl +++ b/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-linux.acl_cl @@ -113,8 +113,6 @@ GeneratedTests.lstm3_state2 GeneratedTests.lstm3_state3 GeneratedTests.lstm_state GeneratedTests.lstm_state2 -GeneratedTests.matrix_band_part_ex_4D_float -GeneratedTests.matrix_band_part_ex_dynamic_nnfw GeneratedTests.maximum_dynamic_nnfw GeneratedTests.minimum_dynamic_nnfw GeneratedTests.minimum_int32 diff --git a/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-linux.acl_neon b/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-linux.acl_neon index 042e8f71ced..f19f495346f 100644 --- a/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-linux.acl_neon +++ b/runtime/tests/nnapi/nnapi_gtest.skip.aarch64-linux.acl_neon @@ -118,8 +118,6 @@ GeneratedTests.lstm3_state2 GeneratedTests.lstm3_state3 GeneratedTests.lstm_state GeneratedTests.lstm_state2 -GeneratedTests.matrix_band_part_ex_4D_float -GeneratedTests.matrix_band_part_ex_dynamic_nnfw GeneratedTests.maximum_dynamic_nnfw GeneratedTests.minimum_dynamic_nnfw GeneratedTests.mul_dynamic_nnfw diff --git a/runtime/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_cl b/runtime/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_cl index 59725bcd3b8..066b0727524 100644 --- a/runtime/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_cl +++ b/runtime/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_cl @@ -109,8 +109,6 @@ GeneratedTests.lstm3_state2 GeneratedTests.lstm3_state3 GeneratedTests.lstm_state GeneratedTests.lstm_state2 -GeneratedTests.matrix_band_part_ex_4D_float -GeneratedTests.matrix_band_part_ex_dynamic_nnfw GeneratedTests.maximum_dynamic_nnfw GeneratedTests.minimum_dynamic_nnfw GeneratedTests.minimum_int32 diff --git a/runtime/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon b/runtime/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon index 3eeff768ad4..4c22bf4f96b 100644 --- a/runtime/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon +++ b/runtime/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon @@ -114,8 +114,6 @@ GeneratedTests.lstm3_state2 GeneratedTests.lstm3_state3 GeneratedTests.lstm_state GeneratedTests.lstm_state2 -GeneratedTests.matrix_band_part_ex_4D_float -GeneratedTests.matrix_band_part_ex_dynamic_nnfw GeneratedTests.maximum_dynamic_nnfw GeneratedTests.minimum_dynamic_nnfw GeneratedTests.mul_dynamic_nnfw diff --git a/runtime/tests/nnapi/specs/Ex/matrix_band_part_ex_4D_float.mod.py b/runtime/tests/nnapi/specs/Ex/matrix_band_part_ex_4D_float.mod.py deleted file mode 100644 index cb6834a2c82..00000000000 --- a/runtime/tests/nnapi/specs/Ex/matrix_band_part_ex_4D_float.mod.py +++ /dev/null @@ -1,38 +0,0 @@ -# model -model = Model() - -i1 = Input("op1", "TENSOR_FLOAT32", "{1, 1, 4, 4}") -i2 = Input("op2", "TENSOR_INT32", "{}") -i3 = Input("op3", "TENSOR_INT32", "{}") -i4 = Output("op4", "TENSOR_FLOAT32", "{1, 1, 4, 4}") -model = model.Operation("MATRIX_BAND_PART_EX", i1, i2, i3).To(i4) - -# Example 1. Input in operand 0, -input0 = {i1: # input 0 - [0, 1, 2, 3, -1, 0, 1, 2, -2, -1, 0, 1, -3, -2, -1, 0], - i2: # input 1 - [1], - i3: # input 2 - [-1]} - - -output0 = {i4: # output 0 - [0, 1, 2, 3, -1, 0, 1, 2, 0, -1, 0, 1, 0, 0, -1, 0]} - -# Instantiate an example -Example((input0, output0)) - - -# Example 2. Input in operand 0, -input1 = {i1: # input 0 - [0, 1, 2, 3, -1, 0, 1, 2, -2, -1, 0, 1, -3, -2, -1, 0], - i2: # input 1 - [2], - i3: # input 2 - [1]} - - -output1 = {i4: # output 0 - [0, 1, 0, 0, -1, 0, 1, 0, -2, -1, 0, 1, 0, -2, -1, 0]} - -Example((input1, output1)) diff --git a/runtime/tests/nnapi/specs/Ex/matrix_band_part_ex_dynamic_nnfw.mod.py b/runtime/tests/nnapi/specs/Ex/matrix_band_part_ex_dynamic_nnfw.mod.py deleted file mode 100644 index 3b9c7290376..00000000000 --- a/runtime/tests/nnapi/specs/Ex/matrix_band_part_ex_dynamic_nnfw.mod.py +++ /dev/null @@ -1,27 +0,0 @@ -import dynamic_tensor - -# model -model = Model() - -model_input_shape = [1, 1, 4, 4] -dynamic_layer = dynamic_tensor.DynamicInputGenerator(model, model_input_shape, "TENSOR_FLOAT32") -test_node_input = dynamic_layer.getTestNodeInput() - -i2 = Input("op2", "TENSOR_INT32", "{1}") -i3 = Input("op3", "TENSOR_INT32", "{1}") -i4 = Output("op4", "TENSOR_FLOAT32", "{1, 1, 4, 4}") -model = model.Operation("MATRIX_BAND_PART_EX", test_node_input, i2, i3).To(i4) - -input0 = {dynamic_layer.getModelInput(): - [0, 1, 2, 3, -1, 0, 1, 2, -2, -1, 0, 1, -3, -2, -1, 0], - dynamic_layer.getShapeInput() : model_input_shape, - i2: # input 1 - [1], - i3: # input 2 - [-1]} - -output0 = {i4: # output 0 - [0, 1, 2, 3, -1, 0, 1, 2, 0, -1, 0, 1, 0, 0, -1, 0]} - -# Instantiate an example -Example((input0, output0))