From b39e5752c9aacecca0c285a90a981cfb8bf9b00c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=B5=9C=EC=84=B1=EC=A7=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Principal=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 31 May 2018 14:59:32 +0900 Subject: [PATCH] [Gather Op] add other operation types (#1329) * [Gather Op] add uint8 operation types This commit adds other operation types. -uint8 Signed-off-by: SungJin Choi * [Gather Op] add int32 operation types This commit adds other operation types. -int32 Signed-off-by: SungJin Choi * [Gather Op] add an comment that explains gather operation This commit adds comments. - Gather of NN Runtime supports TENSOR_FLOAT32, TENSOR_QUANT8_ASYMM, TENSOR_INT32 other than TFLite.(TFLite additionaly supports kTfLiteString.) Signed-off-by: SungJin Choi --- runtimes/nn/common/OperationsUtils.cpp | 1 + runtimes/nn/common/operations/Gather.cpp | 19 ++++- .../operations/internal/optimized/optimized_ops.h | 2 + .../generated/all_generated_tests.cpp | 84 ++++++++++++++++++---- .../generated/examples/gather_1D_int32.example.cpp | 22 ++++++ .../generated/examples/gather_1D_uint8.example.cpp | 22 ++++++ .../generated/examples/gather_2D_int32.example.cpp | 22 ++++++ .../generated/examples/gather_2D_uint8.example.cpp | 22 ++++++ .../generated/models/gather_1D_int32.model.cpp | 21 ++++++ .../generated/models/gather_1D_uint8.model.cpp | 22 ++++++ .../generated/models/gather_2D_int32.model.cpp | 22 ++++++ .../generated/models/gather_2D_uint8.model.cpp | 22 ++++++ .../generated/models/strided_slice.model.cpp | 5 +- .../models/strided_slice_float_1.model.cpp | 5 +- .../models/strided_slice_float_10.model.cpp | 5 +- .../models/strided_slice_float_2.model.cpp | 5 +- .../models/strided_slice_float_3.model.cpp | 5 +- .../models/strided_slice_float_4.model.cpp | 5 +- .../models/strided_slice_float_5.model.cpp | 5 +- .../models/strided_slice_float_6.model.cpp | 5 +- .../models/strided_slice_float_7.model.cpp | 5 +- .../models/strided_slice_float_8.model.cpp | 5 +- .../models/strided_slice_float_9.model.cpp | 5 +- .../specs/Ex/gather_1D_int32.mod.py | 18 +++++ .../specs/Ex/gather_1D_uint8.mod.py | 18 +++++ .../specs/Ex/gather_2D_int32.mod.py | 21 ++++++ .../specs/Ex/gather_2D_uint8.mod.py | 21 ++++++ 27 files changed, 355 insertions(+), 59 deletions(-) create mode 100644 runtimes/tests/neural_networks_test/generated/examples/gather_1D_int32.example.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/examples/gather_1D_uint8.example.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/examples/gather_2D_int32.example.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/examples/gather_2D_uint8.example.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/models/gather_1D_int32.model.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/models/gather_1D_uint8.model.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/models/gather_2D_int32.model.cpp create mode 100644 runtimes/tests/neural_networks_test/generated/models/gather_2D_uint8.model.cpp create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/gather_1D_int32.mod.py create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/gather_1D_uint8.mod.py create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/gather_2D_int32.mod.py create mode 100644 runtimes/tests/neural_networks_test/specs/Ex/gather_2D_uint8.mod.py diff --git a/runtimes/nn/common/OperationsUtils.cpp b/runtimes/nn/common/OperationsUtils.cpp index ae6eb3a..6b6ddd1 100644 --- a/runtimes/nn/common/OperationsUtils.cpp +++ b/runtimes/nn/common/OperationsUtils.cpp @@ -627,6 +627,7 @@ bool gatherPrepare(const Shape &inputShape, const Shape &coordsShape, Shape *out switch (inputShape.type) { case OperandType::TENSOR_FLOAT32: + case OperandType::TENSOR_QUANT8_ASYMM: case OperandType::TENSOR_INT32: { // Fully supported by reference_ops::Gather. diff --git a/runtimes/nn/common/operations/Gather.cpp b/runtimes/nn/common/operations/Gather.cpp index 1160682..1381c9f 100644 --- a/runtimes/nn/common/operations/Gather.cpp +++ b/runtimes/nn/common/operations/Gather.cpp @@ -32,7 +32,8 @@ namespace rt bool gatherGeneric(const uint8_t *inputData, const Shape &inputShape, const int32_t *coordsData, const Shape &coordsShape, uint8_t *outputData, const Shape &outputShape) { - // TODO: other types + // NN Runtime supports TENSOR_FLOAT32, TENSOR_QUANT8_ASYMM, TENSOR_INT32. + // While TFlite supports kTfLiteFloat32, kTfLiteUInt8, kTfLiteInt32, as well as kTfLiteString. if (inputShape.type == OperandType::TENSOR_FLOAT32) { optimized_ops::Gather(reinterpret_cast(inputData), @@ -41,6 +42,22 @@ bool gatherGeneric(const uint8_t *inputData, const Shape &inputShape, const int3 convertShapeToDims(coordsShape), reinterpret_cast(outputData), convertShapeToDims(outputShape)); } + else if (inputShape.type == OperandType::TENSOR_QUANT8_ASYMM) + { + optimized_ops::Gather(reinterpret_cast(inputData), + convertShapeToDims(inputShape), getNumberOfDimensions(inputShape), + reinterpret_cast(coordsData), + convertShapeToDims(coordsShape), reinterpret_cast(outputData), + convertShapeToDims(outputShape)); + } + else if (inputShape.type == OperandType::TENSOR_INT32) + { + optimized_ops::Gather(reinterpret_cast(inputData), + convertShapeToDims(inputShape), getNumberOfDimensions(inputShape), + reinterpret_cast(coordsData), + convertShapeToDims(coordsShape), reinterpret_cast(outputData), + convertShapeToDims(outputShape)); + } else { LOG(ERROR) << "Unsupported data type"; diff --git a/runtimes/nn/common/operations/internal/optimized/optimized_ops.h b/runtimes/nn/common/operations/internal/optimized/optimized_ops.h index a234c50..fd12f71 100644 --- a/runtimes/nn/common/operations/internal/optimized/optimized_ops.h +++ b/runtimes/nn/common/operations/internal/optimized/optimized_ops.h @@ -2875,6 +2875,8 @@ inline void Floor(const float *input_data, const Dims<4> &input_dims, float *out // Gather is implemented and modified while referring to Gather fuction in TFLite optimized_ops.h // file. +// Gather of NN Runtime supports TENSOR_FLOAT32, TENSOR_QUANT8_ASYMM, TENSOR_INT32 other than +// TFLite.(TFLite additionaly supports kTfLiteString.) template inline void Gather(const T *input_data, const Dims<4> &input_dims, uint32_t input_rank, const int32 *coords_data, const Dims<4> &coords_dims, T *output_data, diff --git a/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp b/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp index 9b1bc60..c5a72f8 100644 --- a/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp +++ b/runtimes/tests/neural_networks_test/generated/all_generated_tests.cpp @@ -2059,20 +2059,6 @@ TEST_F(GeneratedTests, div_) { div_::examples); } -namespace gather_1D_float { -std::vector examples = { -// Generated gather_1D_float test -#include "generated/examples/gather_1D_float.example.cpp" -}; -// Generated model constructor -#include "generated/models/gather_1D_float.model.cpp" -} // namespace gather_1D_float -TEST_F(GeneratedTests, gather_1D_float) { - execute(gather_1D_float::CreateModel, - gather_1D_float::is_ignored, - gather_1D_float::examples); -} - namespace strided_slice_float_10 { std::vector examples = { // Generated strided_slice_float_10 test @@ -2269,6 +2255,48 @@ TEST_F(GeneratedTests, cast_ex_int32_to_float32) { cast_ex_int32_to_float32::examples); } +namespace gather_1D_float { +std::vector examples = { +// Generated gather_1D_float test +#include "generated/examples/gather_1D_float.example.cpp" +}; +// Generated model constructor +#include "generated/models/gather_1D_float.model.cpp" +} // namespace gather_1D_float +TEST_F(GeneratedTests, gather_1D_float) { + execute(gather_1D_float::CreateModel, + gather_1D_float::is_ignored, + gather_1D_float::examples); +} + +namespace gather_1D_int32 { +std::vector examples = { +// Generated gather_1D_int32 test +#include "generated/examples/gather_1D_int32.example.cpp" +}; +// Generated model constructor +#include "generated/models/gather_1D_int32.model.cpp" +} // namespace gather_1D_int32 +TEST_F(GeneratedTests, gather_1D_int32) { + execute(gather_1D_int32::CreateModel, + gather_1D_int32::is_ignored, + gather_1D_int32::examples); +} + +namespace gather_1D_uint8 { +std::vector examples = { +// Generated gather_1D_uint8 test +#include "generated/examples/gather_1D_uint8.example.cpp" +}; +// Generated model constructor +#include "generated/models/gather_1D_uint8.model.cpp" +} // namespace gather_1D_uint8 +TEST_F(GeneratedTests, gather_1D_uint8) { + execute(gather_1D_uint8::CreateModel, + gather_1D_uint8::is_ignored, + gather_1D_uint8::examples); +} + namespace topk_v2_1D_int32 { std::vector examples = { // Generated topk_v2_1D_int32 test @@ -2339,6 +2367,34 @@ TEST_F(GeneratedTests, gather_2D_float) { gather_2D_float::examples); } +namespace gather_2D_int32 { +std::vector examples = { +// Generated gather_2D_int32 test +#include "generated/examples/gather_2D_int32.example.cpp" +}; +// Generated model constructor +#include "generated/models/gather_2D_int32.model.cpp" +} // namespace gather_2D_int32 +TEST_F(GeneratedTests, gather_2D_int32) { + execute(gather_2D_int32::CreateModel, + gather_2D_int32::is_ignored, + gather_2D_int32::examples); +} + +namespace gather_2D_uint8 { +std::vector examples = { +// Generated gather_2D_uint8 test +#include "generated/examples/gather_2D_uint8.example.cpp" +}; +// Generated model constructor +#include "generated/models/gather_2D_uint8.model.cpp" +} // namespace gather_2D_uint8 +TEST_F(GeneratedTests, gather_2D_uint8) { + execute(gather_2D_uint8::CreateModel, + gather_2D_uint8::is_ignored, + gather_2D_uint8::examples); +} + namespace strided_slice_ex_float_1 { std::vector examples = { // Generated strided_slice_ex_float_1 test diff --git a/runtimes/tests/neural_networks_test/generated/examples/gather_1D_int32.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/gather_1D_int32.example.cpp new file mode 100644 index 0000000..305018a --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/gather_1D_int32.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: gather_1D_int32.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {{0, {40000, 41000, 50000, 60000}}, {1, {2, 0}}}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {{0, {50000, 40000}}}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/examples/gather_1D_uint8.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/gather_1D_uint8.example.cpp new file mode 100644 index 0000000..398a672 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/gather_1D_uint8.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: gather_1D_uint8.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {{1, {2, 0}}}, + // int -> QUANT8_ASYMM map + {{0, {3, 4, 5, 6}}} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {{0, {5, 3}}} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/examples/gather_2D_int32.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/gather_2D_int32.example.cpp new file mode 100644 index 0000000..052eff5 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/gather_2D_int32.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: gather_2D_int32.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {{0, {40000, 41000, 50000, 60000, 70000, 80000, 90000, 79000, 170000, 180000, 190000, 110000}}, {1, {2, 0}}}, + // int -> QUANT8_ASYMM map + {} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {{0, {170000, 180000, 190000, 110000, 40000, 41000, 50000, 60000}}}, + // int -> QUANT8_ASYMM map + {} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/examples/gather_2D_uint8.example.cpp b/runtimes/tests/neural_networks_test/generated/examples/gather_2D_uint8.example.cpp new file mode 100644 index 0000000..f9b9af7 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/examples/gather_2D_uint8.example.cpp @@ -0,0 +1,22 @@ +// Generated file (from: gather_2D_uint8.mod.py). Do not edit +// Begin of an example +{ +//Input(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {{1, {2, 0}}}, + // int -> QUANT8_ASYMM map + {{0, {3, 4, 5, 6, 7, 8, 9, 1, 2, 18, 19, 11}}} +}, +//Output(s) +{ // See tools/test_generator/include/TestHarness.h:MixedTyped + // int -> FLOAT32 map + {}, + // int -> INT32 map + {}, + // int -> QUANT8_ASYMM map + {{0, {2, 18, 19, 11, 3, 4, 5, 6}}} +} +}, // End of an example diff --git a/runtimes/tests/neural_networks_test/generated/models/gather_1D_int32.model.cpp b/runtimes/tests/neural_networks_test/generated/models/gather_1D_int32.model.cpp new file mode 100644 index 0000000..bebe4d6 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/gather_1D_int32.model.cpp @@ -0,0 +1,21 @@ +// Generated file (from: gather_1D_int32.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type1(Type::TENSOR_INT32, {2}); + OperandType type0(Type::TENSOR_INT32, {4}); + // Phase 1, operands + auto op1 = model->addOperand(&type0); + auto op2 = model->addOperand(&type1); + auto op3 = model->addOperand(&type1); + // Phase 2, operations + model->addOperationEx(ANEURALNETWORKS_GATHER_EX, {op1, op2}, {op3}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {op1, op2}, + {op3}); + assert(model->isValid()); +} + +bool is_ignored(int i) { + static std::set ignore = {}; + return ignore.find(i) != ignore.end(); +} diff --git a/runtimes/tests/neural_networks_test/generated/models/gather_1D_uint8.model.cpp b/runtimes/tests/neural_networks_test/generated/models/gather_1D_uint8.model.cpp new file mode 100644 index 0000000..478314c --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/gather_1D_uint8.model.cpp @@ -0,0 +1,22 @@ +// Generated file (from: gather_1D_uint8.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type1(Type::TENSOR_INT32, {2}); + OperandType type2(Type::TENSOR_QUANT8_ASYMM, {2}); + OperandType type0(Type::TENSOR_QUANT8_ASYMM, {4}); + // Phase 1, operands + auto op1 = model->addOperand(&type0); + auto op2 = model->addOperand(&type1); + auto op3 = model->addOperand(&type2); + // Phase 2, operations + model->addOperationEx(ANEURALNETWORKS_GATHER_EX, {op1, op2}, {op3}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {op1, op2}, + {op3}); + assert(model->isValid()); +} + +bool is_ignored(int i) { + static std::set ignore = {}; + return ignore.find(i) != ignore.end(); +} diff --git a/runtimes/tests/neural_networks_test/generated/models/gather_2D_int32.model.cpp b/runtimes/tests/neural_networks_test/generated/models/gather_2D_int32.model.cpp new file mode 100644 index 0000000..6483b69 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/gather_2D_int32.model.cpp @@ -0,0 +1,22 @@ +// Generated file (from: gather_2D_int32.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type2(Type::TENSOR_INT32, {2,4}); + OperandType type1(Type::TENSOR_INT32, {2}); + OperandType type0(Type::TENSOR_INT32, {3,4}); + // Phase 1, operands + auto op1 = model->addOperand(&type0); + auto op2 = model->addOperand(&type1); + auto op3 = model->addOperand(&type2); + // Phase 2, operations + model->addOperationEx(ANEURALNETWORKS_GATHER_EX, {op1, op2}, {op3}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {op1, op2}, + {op3}); + assert(model->isValid()); +} + +bool is_ignored(int i) { + static std::set ignore = {}; + return ignore.find(i) != ignore.end(); +} diff --git a/runtimes/tests/neural_networks_test/generated/models/gather_2D_uint8.model.cpp b/runtimes/tests/neural_networks_test/generated/models/gather_2D_uint8.model.cpp new file mode 100644 index 0000000..0281963 --- /dev/null +++ b/runtimes/tests/neural_networks_test/generated/models/gather_2D_uint8.model.cpp @@ -0,0 +1,22 @@ +// Generated file (from: gather_2D_uint8.mod.py). Do not edit +void CreateModel(Model *model) { + OperandType type1(Type::TENSOR_INT32, {2}); + OperandType type2(Type::TENSOR_QUANT8_ASYMM, {2,4}); + OperandType type0(Type::TENSOR_QUANT8_ASYMM, {3,4}); + // Phase 1, operands + auto op1 = model->addOperand(&type0); + auto op2 = model->addOperand(&type1); + auto op3 = model->addOperand(&type2); + // Phase 2, operations + model->addOperationEx(ANEURALNETWORKS_GATHER_EX, {op1, op2}, {op3}); + // Phase 3, inputs and outputs + model->identifyInputsAndOutputs( + {op1, op2}, + {op3}); + assert(model->isValid()); +} + +bool is_ignored(int i) { + static std::set ignore = {}; + return ignore.find(i) != ignore.end(); +} diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice.model.cpp index 5f1b875..371d084 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {0, 0}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_1.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_1.model.cpp index fcd2f6d..d37e8e6 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_1.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_1.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {1}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_10.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_10.model.cpp index 1463f13..6fecfd3 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_10.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_10.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {1, 0}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {2}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_2.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_2.model.cpp index 47179ca..81e8796 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_2.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_2.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {-3}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_3.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_3.model.cpp index 113c775..343455a 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_3.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_3.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {-5}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_4.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_4.model.cpp index af5ffa8..b7524de 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_4.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_4.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {1}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_5.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_5.model.cpp index a0280d3..a590fc5 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_5.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_5.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {1}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_6.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_6.model.cpp index cb40c85..db1de2b 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_6.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_6.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {1}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {1}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_7.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_7.model.cpp index 1580128..d4d12e9 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_7.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_7.model.cpp @@ -10,7 +10,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type0); // Phase 2, operations static int32_t begins_init[] = {-1}; @@ -23,9 +22,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_8.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_8.model.cpp index 0dd3884..30c96b5 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_8.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_8.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {1, -1}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_9.model.cpp b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_9.model.cpp index 22e0e70..a93a1f8 100644 --- a/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_9.model.cpp +++ b/runtimes/tests/neural_networks_test/generated/models/strided_slice_float_9.model.cpp @@ -11,7 +11,6 @@ void CreateModel(Model *model) { auto strides = model->addOperand(&type1); auto beginMask = model->addOperand(&type2); auto endMask = model->addOperand(&type2); - auto shrinkAxisMask = model->addOperand(&type2); auto output = model->addOperand(&type3); // Phase 2, operations static int32_t begins_init[] = {1, 0}; @@ -24,9 +23,7 @@ void CreateModel(Model *model) { model->setOperandValue(beginMask, beginMask_init, sizeof(int32_t) * 1); static int32_t endMask_init[] = {0}; model->setOperandValue(endMask, endMask_init, sizeof(int32_t) * 1); - static int32_t shrinkAxisMask_init[] = {0}; - model->setOperandValue(shrinkAxisMask, shrinkAxisMask_init, sizeof(int32_t) * 1); - model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask, shrinkAxisMask}, {output}); + model->addOperation(ANEURALNETWORKS_STRIDED_SLICE, {input, begins, ends, strides, beginMask, endMask}, {output}); // Phase 3, inputs and outputs model->identifyInputsAndOutputs( {input}, diff --git a/runtimes/tests/neural_networks_test/specs/Ex/gather_1D_int32.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/gather_1D_int32.mod.py new file mode 100644 index 0000000..5c81dce --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/gather_1D_int32.mod.py @@ -0,0 +1,18 @@ +# model +model = Model() +i1 = Input("op1", "TENSOR_INT32", "{4}") # a vector of 2 float32s +i2 = Input("op2", "TENSOR_INT32", "{2}") # another vector of 2 int32s +i3 = Output("op3", "TENSOR_INT32", "{2}") +model = model.Operation("GATHER_EX", i1, i2).To(i3) + +# Example 1. Input in operand 0, +input0 = {i1: # input 0 + [40000, 41000, 50000, 60000], + i2: # input 1 + [2, 0]} + +output0 = {i3: # output 0 + [50000, 40000]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/gather_1D_uint8.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/gather_1D_uint8.mod.py new file mode 100644 index 0000000..d849e8a --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/gather_1D_uint8.mod.py @@ -0,0 +1,18 @@ +# model +model = Model() +i1 = Input("op1", "TENSOR_QUANT8_ASYMM", "{4}") # a vector of 2 float32s +i2 = Input("op2", "TENSOR_INT32", "{2}") # another vector of 2 int32s +i3 = Output("op3", "TENSOR_QUANT8_ASYMM", "{2}") +model = model.Operation("GATHER_EX", i1, i2).To(i3) + +# Example 1. Input in operand 0, +input0 = {i1: # input 0 + [3, 4, 5, 6], + i2: # input 1 + [2, 0]} + +output0 = {i3: # output 0 + [5, 3]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/gather_2D_int32.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/gather_2D_int32.mod.py new file mode 100644 index 0000000..178f5eb --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/gather_2D_int32.mod.py @@ -0,0 +1,21 @@ +# model +model = Model() +i1 = Input("op1", "TENSOR_INT32", "{3,4}") # a vector of 2 float32s +i2 = Input("op2", "TENSOR_INT32", "{2}") # another vector of 2 int32s +i3 = Output("op3", "TENSOR_INT32", "{2,4}") +model = model.Operation("GATHER_EX", i1, i2).To(i3) + +# Example 1. Input in operand 0, +input0 = {i1: # input 0 + [40000, 41000, 50000, 60000, + 70000, 80000, 90000, 79000, + 170000, 180000, 190000, 110000], + i2: # input 1 + [2, 0]} + +output0 = {i3: # output 0 + [170000, 180000, 190000, 110000, + 40000, 41000, 50000, 60000]} + +# Instantiate an example +Example((input0, output0)) diff --git a/runtimes/tests/neural_networks_test/specs/Ex/gather_2D_uint8.mod.py b/runtimes/tests/neural_networks_test/specs/Ex/gather_2D_uint8.mod.py new file mode 100644 index 0000000..405f6e6 --- /dev/null +++ b/runtimes/tests/neural_networks_test/specs/Ex/gather_2D_uint8.mod.py @@ -0,0 +1,21 @@ +# model +model = Model() +i1 = Input("op1", "TENSOR_QUANT8_ASYMM", "{3,4}") # a vector of 2 float32s +i2 = Input("op2", "TENSOR_INT32", "{2}") # another vector of 2 int32s +i3 = Output("op3", "TENSOR_QUANT8_ASYMM", "{2,4}") +model = model.Operation("GATHER_EX", i1, i2).To(i3) + +# Example 1. Input in operand 0, +input0 = {i1: # input 0 + [3, 4, 5, 6, + 7, 8, 9, 1, + 2, 18, 19, 11], + i2: # input 1 + [2, 0]} + +output0 = {i3: # output 0 + [2, 18, 19, 11, + 3, 4, 5, 6]} + +# Instantiate an example +Example((input0, output0)) -- 2.7.4