From 4a9c8972e3a671e9908d14fd46486ea5dc584a84 Mon Sep 17 00:00:00 2001 From: Lev Proleev Date: Tue, 5 May 2020 17:26:26 +0100 Subject: Fix null ptr dereference in cpu implementation of operations Operations fixed: * MEAN * ARGMIN/ARGMAX * STRIDED_SLICE The operations would crash when provided with inputs that resulted in an empty output shape. The change fixes the bug by making the operations output a tensor of size [1] in this case. Also, update the documentation to clarify this behaviour and move squeeze operation test to appropriate spec directory. Bug: 155508675 Bug: 155660285 Bug: 155508675 Bug: 155238914 Test: NNTest_static Change-Id: Ia865c26021dd4d781659957049dd567beeaeae99 --- nn/runtime/include/NeuralNetworks.h | 8 + .../spec_V1_1/mean_b155508675.example.cpp | 174 +++++++ .../spec_V1_1/squeeze_b155238914.example.cpp | 154 +++++++ .../spec_V1_1/strided_slice_b155662254.example.cpp | 254 +++++++++++ .../spec_V1_2/argmax_b155660285.example.cpp | 154 +++++++ .../spec_V1_2/argmin_b155660285.example.cpp | 154 +++++++ .../spec_V1_2/squeeze_b155238914.example.cpp | 87 ---- .../strided_slice_invalid_output_dims.example.cpp | 502 --------------------- nn/runtime/test/specs/V1_1/mean_b155508675.mod.py | 29 ++ .../test/specs/V1_1/squeeze_b155238914.mod.py | 29 ++ .../specs/V1_1/strided_slice_b155662254.mod.py | 29 ++ .../test/specs/V1_2/argmax_b155660285.mod.py | 29 ++ .../test/specs/V1_2/argmin_b155660285.mod.py | 29 ++ .../test/specs/V1_2/squeeze_b155238914.mod.py | 32 -- 14 files changed, 1043 insertions(+), 621 deletions(-) create mode 100644 nn/runtime/test/generated/spec_V1_1/mean_b155508675.example.cpp create mode 100644 nn/runtime/test/generated/spec_V1_1/squeeze_b155238914.example.cpp create mode 100644 nn/runtime/test/generated/spec_V1_1/strided_slice_b155662254.example.cpp create mode 100644 nn/runtime/test/generated/spec_V1_2/argmax_b155660285.example.cpp create mode 100644 nn/runtime/test/generated/spec_V1_2/argmin_b155660285.example.cpp delete mode 100644 nn/runtime/test/generated/spec_V1_2/squeeze_b155238914.example.cpp delete mode 100644 nn/runtime/test/generated/spec_V1_2/strided_slice_invalid_output_dims.example.cpp create mode 100644 nn/runtime/test/specs/V1_1/mean_b155508675.mod.py create mode 100644 nn/runtime/test/specs/V1_1/squeeze_b155238914.mod.py create mode 100644 nn/runtime/test/specs/V1_1/strided_slice_b155662254.mod.py create mode 100644 nn/runtime/test/specs/V1_2/argmax_b155660285.mod.py create mode 100644 nn/runtime/test/specs/V1_2/argmin_b155660285.mod.py delete mode 100644 nn/runtime/test/specs/V1_2/squeeze_b155238914.mod.py (limited to 'nn/runtime') diff --git a/nn/runtime/include/NeuralNetworks.h b/nn/runtime/include/NeuralNetworks.h index 82c668371..239cb6185 100644 --- a/nn/runtime/include/NeuralNetworks.h +++ b/nn/runtime/include/NeuralNetworks.h @@ -2201,6 +2201,8 @@ typedef enum { * For a {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} and * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM_SIGNED} tensor, * the scale and zeroPoint must be the same as input0. + * If all dimensions are reduced and keep_dims is false, the output + * shape is [1]. * * Available since API level 28. */ @@ -2336,6 +2338,8 @@ typedef enum { * For a {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} and * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM_SIGNED} tensor, * the scale and zeroPoint must be the same as input0. + * If all input dimensions are equal to 1 and are to be squeezed, the + * output shape is [1]. * * Available since API level 28. */ @@ -2387,6 +2391,8 @@ typedef enum { * For a {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM} and * {@link ANEURALNETWORKS_TENSOR_QUANT8_ASYMM_SIGNED} tensor, * the scale and zeroPoint must be the same as input0. + * If shrink_axis_mask is true for all input dimensions, the output + * shape is [1]. * * Available since API level 28. */ @@ -2520,6 +2526,7 @@ typedef enum { * * Outputs: * * 0: An (n - 1)-D {@link ANEURALNETWORKS_TENSOR_INT32} tensor. + * If input is 1-dimensional, the output shape is [1]. * * Available since API level 29. */ @@ -2547,6 +2554,7 @@ typedef enum { * * Outputs: * * 0: An (n - 1)-D {@link ANEURALNETWORKS_TENSOR_INT32} tensor. + * If input is 1-dimensional, the output shape is [1]. * * Available since API level 29. */ diff --git a/nn/runtime/test/generated/spec_V1_1/mean_b155508675.example.cpp b/nn/runtime/test/generated/spec_V1_1/mean_b155508675.example.cpp new file mode 100644 index 000000000..4cd5424b8 --- /dev/null +++ b/nn/runtime/test/generated/spec_V1_1/mean_b155508675.example.cpp @@ -0,0 +1,174 @@ +// Generated from mean_b155508675.mod.py +// DO NOT EDIT +// clang-format off +#include "TestHarness.h" +using namespace test_helper; + +namespace generated_tests::mean_b155508675 { + +const TestModel& get_test_model() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {0}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({2.0f, 3.0f, 3.0f, 4.0f}), + .dimensions = {2, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param + .channelQuant = {}, + .data = TestBuffer::createFromVector({0, 1, 2}), + .dimensions = {3}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // param1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({3.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {0, 1, 2}, + .outputs = {3}, + .type = TestOperationType::MEAN + }}, + .outputIndexes = {3} + }, + .minSupportedVersion = TestHalVersion::V1_1, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model = TestModelManager::get().add("mean_b155508675", get_test_model()); + +} // namespace generated_tests::mean_b155508675 + +namespace generated_tests::mean_b155508675 { + +const TestModel& get_test_model_all_inputs_as_internal() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {4}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({}), + .dimensions = {2, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param + .channelQuant = {}, + .data = TestBuffer::createFromVector({0, 1, 2}), + .dimensions = {3}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // param1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({3.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // op1_new + .channelQuant = {}, + .data = TestBuffer::createFromVector({2.0f, 3.0f, 3.0f, 4.0f}), + .dimensions = {2, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // dummy + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {4, 5, 6}, + .outputs = {0}, + .type = TestOperationType::ADD + }, { + .inputs = {0, 1, 2}, + .outputs = {3}, + .type = TestOperationType::MEAN + }}, + .outputIndexes = {3} + }, + .minSupportedVersion = TestHalVersion::V1_1, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_all_inputs_as_internal = TestModelManager::get().add("mean_b155508675_all_inputs_as_internal", get_test_model_all_inputs_as_internal()); + +} // namespace generated_tests::mean_b155508675 + diff --git a/nn/runtime/test/generated/spec_V1_1/squeeze_b155238914.example.cpp b/nn/runtime/test/generated/spec_V1_1/squeeze_b155238914.example.cpp new file mode 100644 index 000000000..1dec0599e --- /dev/null +++ b/nn/runtime/test/generated/spec_V1_1/squeeze_b155238914.example.cpp @@ -0,0 +1,154 @@ +// Generated from squeeze_b155238914.mod.py +// DO NOT EDIT +// clang-format off +#include "TestHarness.h" +using namespace test_helper; + +namespace generated_tests::squeeze_b155238914 { + +const TestModel& get_test_model() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {0}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1, 1, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({}), + .dimensions = {0}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::NO_VALUE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // op3 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::SQUEEZE + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_1, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model = TestModelManager::get().add("squeeze_b155238914", get_test_model()); + +} // namespace generated_tests::squeeze_b155238914 + +namespace generated_tests::squeeze_b155238914 { + +const TestModel& get_test_model_all_inputs_as_internal() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {3}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({}), + .dimensions = {1, 1, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({}), + .dimensions = {0}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::NO_VALUE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // op3 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // op1_new + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1, 1, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // dummy + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {3, 4, 5}, + .outputs = {0}, + .type = TestOperationType::ADD + }, { + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::SQUEEZE + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_1, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_all_inputs_as_internal = TestModelManager::get().add("squeeze_b155238914_all_inputs_as_internal", get_test_model_all_inputs_as_internal()); + +} // namespace generated_tests::squeeze_b155238914 + diff --git a/nn/runtime/test/generated/spec_V1_1/strided_slice_b155662254.example.cpp b/nn/runtime/test/generated/spec_V1_1/strided_slice_b155662254.example.cpp new file mode 100644 index 000000000..2923cbe9f --- /dev/null +++ b/nn/runtime/test/generated/spec_V1_1/strided_slice_b155662254.example.cpp @@ -0,0 +1,254 @@ +// Generated from strided_slice_b155662254.mod.py +// DO NOT EDIT +// clang-format off +#include "TestHarness.h" +using namespace test_helper; + +namespace generated_tests::strided_slice_b155662254 { + +const TestModel& get_test_model() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {0}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f, 1.0f, 2.0f, 3.0f}), + .dimensions = {4}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // param1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({1}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // param2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({1}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // param3 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // param4 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // param5 + .channelQuant = {}, + .data = TestBuffer::createFromVector({1}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {0, 1, 2, 3, 4, 5, 6}, + .outputs = {7}, + .type = TestOperationType::STRIDED_SLICE + }}, + .outputIndexes = {7} + }, + .minSupportedVersion = TestHalVersion::V1_1, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model = TestModelManager::get().add("strided_slice_b155662254", get_test_model()); + +} // namespace generated_tests::strided_slice_b155662254 + +namespace generated_tests::strided_slice_b155662254 { + +const TestModel& get_test_model_all_inputs_as_internal() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {8}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({}), + .dimensions = {4}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // param1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({1}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // param2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({1}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // param3 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // param4 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // param5 + .channelQuant = {}, + .data = TestBuffer::createFromVector({1}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // op1_new + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f, 1.0f, 2.0f, 3.0f}), + .dimensions = {4}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // dummy + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param6 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {8, 9, 10}, + .outputs = {0}, + .type = TestOperationType::ADD + }, { + .inputs = {0, 1, 2, 3, 4, 5, 6}, + .outputs = {7}, + .type = TestOperationType::STRIDED_SLICE + }}, + .outputIndexes = {7} + }, + .minSupportedVersion = TestHalVersion::V1_1, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_all_inputs_as_internal = TestModelManager::get().add("strided_slice_b155662254_all_inputs_as_internal", get_test_model_all_inputs_as_internal()); + +} // namespace generated_tests::strided_slice_b155662254 + diff --git a/nn/runtime/test/generated/spec_V1_2/argmax_b155660285.example.cpp b/nn/runtime/test/generated/spec_V1_2/argmax_b155660285.example.cpp new file mode 100644 index 000000000..1ebca7225 --- /dev/null +++ b/nn/runtime/test/generated/spec_V1_2/argmax_b155660285.example.cpp @@ -0,0 +1,154 @@ +// Generated from argmax_b155660285.mod.py +// DO NOT EDIT +// clang-format off +#include "TestHarness.h" +using namespace test_helper; + +namespace generated_tests::argmax_b155660285 { + +const TestModel& get_test_model() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {0}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({1.0f, 2.0f, 4.0f}), + .dimensions = {3}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({2}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::ARGMAX + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_2, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model = TestModelManager::get().add("argmax_b155660285", get_test_model()); + +} // namespace generated_tests::argmax_b155660285 + +namespace generated_tests::argmax_b155660285 { + +const TestModel& get_test_model_all_inputs_as_internal() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {3}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({}), + .dimensions = {3}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({2}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // op1_new + .channelQuant = {}, + .data = TestBuffer::createFromVector({1.0f, 2.0f, 4.0f}), + .dimensions = {3}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // dummy + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {3, 4, 5}, + .outputs = {0}, + .type = TestOperationType::ADD + }, { + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::ARGMAX + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_2, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_all_inputs_as_internal = TestModelManager::get().add("argmax_b155660285_all_inputs_as_internal", get_test_model_all_inputs_as_internal()); + +} // namespace generated_tests::argmax_b155660285 + diff --git a/nn/runtime/test/generated/spec_V1_2/argmin_b155660285.example.cpp b/nn/runtime/test/generated/spec_V1_2/argmin_b155660285.example.cpp new file mode 100644 index 000000000..cfa50c640 --- /dev/null +++ b/nn/runtime/test/generated/spec_V1_2/argmin_b155660285.example.cpp @@ -0,0 +1,154 @@ +// Generated from argmin_b155660285.mod.py +// DO NOT EDIT +// clang-format off +#include "TestHarness.h" +using namespace test_helper; + +namespace generated_tests::argmin_b155660285 { + +const TestModel& get_test_model() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {0}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({4.0f, 2.0f, 1.0f}), + .dimensions = {3}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({2}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::ARGMIN + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_2, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model = TestModelManager::get().add("argmin_b155660285", get_test_model()); + +} // namespace generated_tests::argmin_b155660285 + +namespace generated_tests::argmin_b155660285 { + +const TestModel& get_test_model_all_inputs_as_internal() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {3}, + .operands = {{ // op1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({}), + .dimensions = {3}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // op2 + .channelQuant = {}, + .data = TestBuffer::createFromVector({2}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_INT32, + .zeroPoint = 0 + }, { // op1_new + .channelQuant = {}, + .data = TestBuffer::createFromVector({4.0f, 2.0f, 1.0f}), + .dimensions = {3}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // dummy + .channelQuant = {}, + .data = TestBuffer::createFromVector({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param1 + .channelQuant = {}, + .data = TestBuffer::createFromVector({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {3, 4, 5}, + .outputs = {0}, + .type = TestOperationType::ADD + }, { + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::ARGMIN + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_2, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_all_inputs_as_internal = TestModelManager::get().add("argmin_b155660285_all_inputs_as_internal", get_test_model_all_inputs_as_internal()); + +} // namespace generated_tests::argmin_b155660285 + diff --git a/nn/runtime/test/generated/spec_V1_2/squeeze_b155238914.example.cpp b/nn/runtime/test/generated/spec_V1_2/squeeze_b155238914.example.cpp deleted file mode 100644 index c2fad450f..000000000 --- a/nn/runtime/test/generated/spec_V1_2/squeeze_b155238914.example.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Generated from squeeze_b155238914.mod.py -// DO NOT EDIT -// clang-format off -#include "TestHarness.h" -using namespace test_helper; - -namespace generated_tests::squeeze_b155238914 { - -const TestModel& get_test_model() { - static TestModel model = { - .expectFailure = false, - .expectedMultinomialDistributionTolerance = 0, - .isRelaxed = false, - .main = { - .inputIndexes = {0}, - .operands = {{ // op0 - .channelQuant = {}, - .data = TestBuffer::createFromVector({0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}), - .dimensions = {9, 1, 1}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // op1 - .channelQuant = {}, - .data = TestBuffer::createFromVector({0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}), - .dimensions = {9, 1, 1}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, - .numberOfConsumers = 0, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // op5 - .channelQuant = {}, - .data = TestBuffer::createFromVector({0.0f}), - .dimensions = {1, 1, 1}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // op7 - .channelQuant = {}, - .data = TestBuffer::createFromVector({}), - .dimensions = {0}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::NO_VALUE, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // op8 - .channelQuant = {}, - .data = TestBuffer::createFromVector({}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, - .numberOfConsumers = 0, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }}, - .operations = {{ - .inputs = {0}, - .outputs = {1}, - .type = TestOperationType::FLOOR - }, { - .inputs = {2, 3}, - .outputs = {4}, - .type = TestOperationType::SQUEEZE - }}, - .outputIndexes = {1} - }, - .minSupportedVersion = TestHalVersion::V1_2, - .referenced = {} - }; - return model; -} - -const auto dummy_test_model = TestModelManager::get().add("squeeze_b155238914", get_test_model()); - -} // namespace generated_tests::squeeze_b155238914 - diff --git a/nn/runtime/test/generated/spec_V1_2/strided_slice_invalid_output_dims.example.cpp b/nn/runtime/test/generated/spec_V1_2/strided_slice_invalid_output_dims.example.cpp deleted file mode 100644 index f164c190a..000000000 --- a/nn/runtime/test/generated/spec_V1_2/strided_slice_invalid_output_dims.example.cpp +++ /dev/null @@ -1,502 +0,0 @@ -// Generated from strided_slice_invalid_output_dims.mod.py -// DO NOT EDIT -// clang-format off -#include "TestHarness.h" -using namespace test_helper; - -namespace generated_tests::strided_slice_invalid_output_dims { - -const TestModel& get_test_model() { - static TestModel model = { - .expectFailure = true, - .expectedMultinomialDistributionTolerance = 0, - .isRelaxed = false, - .main = { - .inputIndexes = {0}, - .operands = {{ // input - .channelQuant = {}, - .data = TestBuffer::createFromVector({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), - .dimensions = {2, 3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // begins - .channelQuant = {}, - .data = TestBuffer::createFromVector({0, 0}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // ends - .channelQuant = {}, - .data = TestBuffer::createFromVector({2, 3}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // strides - .channelQuant = {}, - .data = TestBuffer::createFromVector({1, 1}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // beginMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // endMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // shrinkAxisMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({1}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // output - .channelQuant = {}, - .data = TestBuffer::createFromVector({1.0f, 2.0f, 3.0f}), - .dimensions = {3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, - .numberOfConsumers = 0, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }}, - .operations = {{ - .inputs = {0, 1, 2, 3, 4, 5, 6}, - .outputs = {7}, - .type = TestOperationType::STRIDED_SLICE - }}, - .outputIndexes = {7} - }, - .minSupportedVersion = TestHalVersion::V1_2, - .referenced = {} - }; - return model; -} - -const auto dummy_test_model = TestModelManager::get().add("strided_slice_invalid_output_dims", get_test_model()); - -} // namespace generated_tests::strided_slice_invalid_output_dims - -namespace generated_tests::strided_slice_invalid_output_dims { - -const TestModel& get_test_model_all_inputs_as_internal() { - static TestModel model = { - .expectFailure = true, - .expectedMultinomialDistributionTolerance = 0, - .isRelaxed = false, - .main = { - .inputIndexes = {8}, - .operands = {{ // input - .channelQuant = {}, - .data = TestBuffer::createFromVector({}), - .dimensions = {2, 3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // begins - .channelQuant = {}, - .data = TestBuffer::createFromVector({0, 0}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // ends - .channelQuant = {}, - .data = TestBuffer::createFromVector({2, 3}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // strides - .channelQuant = {}, - .data = TestBuffer::createFromVector({1, 1}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // beginMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // endMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // shrinkAxisMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({1}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // output - .channelQuant = {}, - .data = TestBuffer::createFromVector({1.0f, 2.0f, 3.0f}), - .dimensions = {3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, - .numberOfConsumers = 0, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // input_new - .channelQuant = {}, - .data = TestBuffer::createFromVector({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), - .dimensions = {2, 3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // dummy - .channelQuant = {}, - .data = TestBuffer::createFromVector({0.0f}), - .dimensions = {1}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // param - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }}, - .operations = {{ - .inputs = {8, 9, 10}, - .outputs = {0}, - .type = TestOperationType::ADD - }, { - .inputs = {0, 1, 2, 3, 4, 5, 6}, - .outputs = {7}, - .type = TestOperationType::STRIDED_SLICE - }}, - .outputIndexes = {7} - }, - .minSupportedVersion = TestHalVersion::V1_2, - .referenced = {} - }; - return model; -} - -const auto dummy_test_model_all_inputs_as_internal = TestModelManager::get().add("strided_slice_invalid_output_dims_all_inputs_as_internal", get_test_model_all_inputs_as_internal()); - -} // namespace generated_tests::strided_slice_invalid_output_dims - -namespace generated_tests::strided_slice_invalid_output_dims { - -const TestModel& get_test_model_all_tensors_as_inputs() { - static TestModel model = { - .expectFailure = true, - .expectedMultinomialDistributionTolerance = 0, - .isRelaxed = false, - .main = { - .inputIndexes = {0, 1, 2, 3}, - .operands = {{ // input - .channelQuant = {}, - .data = TestBuffer::createFromVector({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), - .dimensions = {2, 3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // begins - .channelQuant = {}, - .data = TestBuffer::createFromVector({0, 0}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // ends - .channelQuant = {}, - .data = TestBuffer::createFromVector({2, 3}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // strides - .channelQuant = {}, - .data = TestBuffer::createFromVector({1, 1}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // beginMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // endMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // shrinkAxisMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({1}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // output - .channelQuant = {}, - .data = TestBuffer::createFromVector({1.0f, 2.0f, 3.0f}), - .dimensions = {3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, - .numberOfConsumers = 0, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }}, - .operations = {{ - .inputs = {0, 1, 2, 3, 4, 5, 6}, - .outputs = {7}, - .type = TestOperationType::STRIDED_SLICE - }}, - .outputIndexes = {7} - }, - .minSupportedVersion = TestHalVersion::V1_2, - .referenced = {} - }; - return model; -} - -const auto dummy_test_model_all_tensors_as_inputs = TestModelManager::get().add("strided_slice_invalid_output_dims_all_tensors_as_inputs", get_test_model_all_tensors_as_inputs()); - -} // namespace generated_tests::strided_slice_invalid_output_dims - -namespace generated_tests::strided_slice_invalid_output_dims { - -const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() { - static TestModel model = { - .expectFailure = true, - .expectedMultinomialDistributionTolerance = 0, - .isRelaxed = false, - .main = { - .inputIndexes = {1, 2, 3, 8}, - .operands = {{ // input - .channelQuant = {}, - .data = TestBuffer::createFromVector({}), - .dimensions = {2, 3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // begins - .channelQuant = {}, - .data = TestBuffer::createFromVector({0, 0}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // ends - .channelQuant = {}, - .data = TestBuffer::createFromVector({2, 3}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // strides - .channelQuant = {}, - .data = TestBuffer::createFromVector({1, 1}), - .dimensions = {2}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_INT32, - .zeroPoint = 0 - }, { // beginMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // endMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // shrinkAxisMask - .channelQuant = {}, - .data = TestBuffer::createFromVector({1}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }, { // output - .channelQuant = {}, - .data = TestBuffer::createFromVector({1.0f, 2.0f, 3.0f}), - .dimensions = {3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, - .numberOfConsumers = 0, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // input_new - .channelQuant = {}, - .data = TestBuffer::createFromVector({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), - .dimensions = {2, 3}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // dummy1 - .channelQuant = {}, - .data = TestBuffer::createFromVector({0.0f}), - .dimensions = {1}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::TENSOR_FLOAT32, - .zeroPoint = 0 - }, { // param1 - .channelQuant = {}, - .data = TestBuffer::createFromVector({0}), - .dimensions = {}, - .isIgnored = false, - .lifetime = TestOperandLifeTime::CONSTANT_COPY, - .numberOfConsumers = 1, - .scale = 0.0f, - .type = TestOperandType::INT32, - .zeroPoint = 0 - }}, - .operations = {{ - .inputs = {8, 9, 10}, - .outputs = {0}, - .type = TestOperationType::ADD - }, { - .inputs = {0, 1, 2, 3, 4, 5, 6}, - .outputs = {7}, - .type = TestOperationType::STRIDED_SLICE - }}, - .outputIndexes = {7} - }, - .minSupportedVersion = TestHalVersion::V1_2, - .referenced = {} - }; - return model; -} - -const auto dummy_test_model_all_tensors_as_inputs_all_inputs_as_internal = TestModelManager::get().add("strided_slice_invalid_output_dims_all_tensors_as_inputs_all_inputs_as_internal", get_test_model_all_tensors_as_inputs_all_inputs_as_internal()); - -} // namespace generated_tests::strided_slice_invalid_output_dims - diff --git a/nn/runtime/test/specs/V1_1/mean_b155508675.mod.py b/nn/runtime/test/specs/V1_1/mean_b155508675.mod.py new file mode 100644 index 000000000..99bfbe63d --- /dev/null +++ b/nn/runtime/test/specs/V1_1/mean_b155508675.mod.py @@ -0,0 +1,29 @@ +# +# Copyright (C) 2020 The Android Open Source Project +# +# 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. +# + +# Model operands +op1 = Input("op1", ["TENSOR_FLOAT32", [2, 2, 1]]) +op2 = Output("op2", ["TENSOR_FLOAT32", [1]]) + +# Model operations +model = Model() +model.Operation("MEAN", op1, [0, 1, 2], 0).To(op2) + +# Example +Example({ + op1: [2.0, 3.0, 3.0, 4.0], + op2: [3.0], +}, model=model) diff --git a/nn/runtime/test/specs/V1_1/squeeze_b155238914.mod.py b/nn/runtime/test/specs/V1_1/squeeze_b155238914.mod.py new file mode 100644 index 000000000..75ac4381f --- /dev/null +++ b/nn/runtime/test/specs/V1_1/squeeze_b155238914.mod.py @@ -0,0 +1,29 @@ +# +# Copyright (C) 2020 The Android Open Source Project +# +# 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. +# +# Model operands +op1 = Input("op1", ["TENSOR_FLOAT32", [1, 1, 1]], [0]) +op2 = Parameter("op2", ["TENSOR_INT32", [0]], value=None) # omitted +op3 = Output("op3", ["TENSOR_FLOAT32", [1]]) + +# Model operations +model = Model() +model.Operation("SQUEEZE", op1, op2).To(op3) + +# Example +Example({ + op1: [0], + op3: [0] +}, model=model) diff --git a/nn/runtime/test/specs/V1_1/strided_slice_b155662254.mod.py b/nn/runtime/test/specs/V1_1/strided_slice_b155662254.mod.py new file mode 100644 index 000000000..908f8563d --- /dev/null +++ b/nn/runtime/test/specs/V1_1/strided_slice_b155662254.mod.py @@ -0,0 +1,29 @@ +# +# Copyright (C) 2020 The Android Open Source Project +# +# 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. +# + +# Model operands +op1 = Input("op1", ["TENSOR_FLOAT32", [4]]) +op2 = Output("op2", ["TENSOR_FLOAT32", [1]]) + +# Model operations +model = Model() +model.Operation("STRIDED_SLICE", op1, [0], [1], [1], 0, 0, 1).To(op2) + +# Example +Example({ + op1: [0.0, 1.0, 2.0, 3.0], + op2: [0.0], +}, model=model) diff --git a/nn/runtime/test/specs/V1_2/argmax_b155660285.mod.py b/nn/runtime/test/specs/V1_2/argmax_b155660285.mod.py new file mode 100644 index 000000000..6247e1519 --- /dev/null +++ b/nn/runtime/test/specs/V1_2/argmax_b155660285.mod.py @@ -0,0 +1,29 @@ +# +# Copyright (C) 2020 The Android Open Source Project +# +# 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. +# + +# Model operands +op1 = Input("op1", ["TENSOR_FLOAT32", [3]]) +op2 = Output("op2", ["TENSOR_INT32", [1]]) + +# Model operations +model = Model() +model.Operation("ARGMAX", op1, 0).To(op2) + +# Example +Example({ + op1: [1.0, 2.0, 4.0], + op2: [2], +}, model=model) diff --git a/nn/runtime/test/specs/V1_2/argmin_b155660285.mod.py b/nn/runtime/test/specs/V1_2/argmin_b155660285.mod.py new file mode 100644 index 000000000..a59500a6a --- /dev/null +++ b/nn/runtime/test/specs/V1_2/argmin_b155660285.mod.py @@ -0,0 +1,29 @@ +# +# Copyright (C) 2020 The Android Open Source Project +# +# 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. +# + +# Model operands +op1 = Input("op1", ["TENSOR_FLOAT32", [3]]) +op2 = Output("op2", ["TENSOR_INT32", [1]]) + +# Model operations +model = Model() +model.Operation("ARGMIN", op1, 0).To(op2) + +# Example +Example({ + op1: [4.0, 2.0, 1.0], + op2: [2], +}, model=model) diff --git a/nn/runtime/test/specs/V1_2/squeeze_b155238914.mod.py b/nn/runtime/test/specs/V1_2/squeeze_b155238914.mod.py deleted file mode 100644 index 70e41c6d3..000000000 --- a/nn/runtime/test/specs/V1_2/squeeze_b155238914.mod.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (C) 2020 The Android Open Source Project -# -# 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. -# -# Model operands -op0 = Input("op0", ["TENSOR_FLOAT32", [9, 1, 1]]) -op1 = Output("op1", ["TENSOR_FLOAT32", [9, 1, 1]]) -op5 = Parameter("op5", ["TENSOR_FLOAT32", [1, 1, 1]], [0]) -op7 = Parameter("op7", ["TENSOR_INT32", [0]], value=None) # omitted -op8 = Internal("op8", ["TENSOR_FLOAT32", []]) - -# Model operations -model = Model() -model.Operation("FLOOR", op0).To(op1) -model.Operation("SQUEEZE", op5, op7).To(op8) - -# Example -Example({ - op0: [0, 0, 0, 0, 0, 0, 0, 0, 0], - op1: [0, 0, 0, 0, 0, 0, 0, 0, 0], -}, model=model).DisableLifeTimeVariation() -- cgit v1.2.3