diff options
-rw-r--r-- | nn/runtime/test/generated/spec_V1_3/pow_same_shape.example.cpp | 552 | ||||
-rw-r--r-- | nn/runtime/test/specs/V1_3/pow_same_shape.mod.py | 29 |
2 files changed, 581 insertions, 0 deletions
diff --git a/nn/runtime/test/generated/spec_V1_3/pow_same_shape.example.cpp b/nn/runtime/test/generated/spec_V1_3/pow_same_shape.example.cpp new file mode 100644 index 000000000..24521ac3c --- /dev/null +++ b/nn/runtime/test/generated/spec_V1_3/pow_same_shape.example.cpp @@ -0,0 +1,552 @@ +// Generated from pow_same_shape.mod.py +// DO NOT EDIT +// clang-format off +#include "TestHarness.h" +using namespace test_helper; + +namespace generated_tests::pow_same_shape { + +const TestModel& get_test_model() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {0, 1}, + .operands = {{ // base + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // exponent + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({4.0f, 3.0f, 2.0f, 1.0f, 0.5f, 0.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // output + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({1.0f, 8.0f, 9.0f, 4.0f, 2.23606797749979f, 1.0f}), + .dimensions = {3, 2, 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::POW + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_2, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model = TestModelManager::get().add("pow_same_shape", get_test_model()); + +} // namespace generated_tests::pow_same_shape + +namespace generated_tests::pow_same_shape { + +const TestModel& get_test_model_all_inputs_as_internal() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {3, 6}, + .operands = {{ // base + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // exponent + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // output + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({1.0f, 8.0f, 9.0f, 4.0f, 2.23606797749979f, 1.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // base_new + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // dummy + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({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<int32_t>({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // exponent_new + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({4.0f, 3.0f, 2.0f, 1.0f, 0.5f, 0.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // dummy1 + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({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<int32_t>({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 = {6, 7, 8}, + .outputs = {1}, + .type = TestOperationType::ADD + }, { + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::POW + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_2, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_all_inputs_as_internal = TestModelManager::get().add("pow_same_shape_all_inputs_as_internal", get_test_model_all_inputs_as_internal()); + +} // namespace generated_tests::pow_same_shape + +namespace generated_tests::pow_same_shape { + +const TestModel& get_test_model_relaxed() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = true, + .main = { + .inputIndexes = {0, 1}, + .operands = {{ // base + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // exponent + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({4.0f, 3.0f, 2.0f, 1.0f, 0.5f, 0.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // output + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({1.0f, 8.0f, 9.0f, 4.0f, 2.23606797749979f, 1.0f}), + .dimensions = {3, 2, 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::POW + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::UNKNOWN, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_relaxed = TestModelManager::get().add("pow_same_shape_relaxed", get_test_model_relaxed()); + +} // namespace generated_tests::pow_same_shape + +namespace generated_tests::pow_same_shape { + +const TestModel& get_test_model_relaxed_all_inputs_as_internal() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = true, + .main = { + .inputIndexes = {3, 6}, + .operands = {{ // base + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // exponent + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // output + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({1.0f, 8.0f, 9.0f, 4.0f, 2.23606797749979f, 1.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // base_new + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // dummy2 + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({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<int32_t>({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // exponent_new + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({4.0f, 3.0f, 2.0f, 1.0f, 0.5f, 0.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // dummy3 + .channelQuant = {}, + .data = TestBuffer::createFromVector<float>({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT32, + .zeroPoint = 0 + }, { // param3 + .channelQuant = {}, + .data = TestBuffer::createFromVector<int32_t>({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 = {6, 7, 8}, + .outputs = {1}, + .type = TestOperationType::ADD + }, { + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::POW + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::UNKNOWN, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_relaxed_all_inputs_as_internal = TestModelManager::get().add("pow_same_shape_relaxed_all_inputs_as_internal", get_test_model_relaxed_all_inputs_as_internal()); + +} // namespace generated_tests::pow_same_shape + +namespace generated_tests::pow_same_shape { + +const TestModel& get_test_model_float16() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {0, 1}, + .operands = {{ // base + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }, { // exponent + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({4.0f, 3.0f, 2.0f, 1.0f, 0.5f, 0.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }, { // output + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({1.0f, 8.0f, 9.0f, 4.0f, 2.2360680103302f, 1.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }}, + .operations = {{ + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::POW + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_2, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_float16 = TestModelManager::get().add("pow_same_shape_float16", get_test_model_float16()); + +} // namespace generated_tests::pow_same_shape + +namespace generated_tests::pow_same_shape { + +const TestModel& get_test_model_float16_all_inputs_as_internal() { + static TestModel model = { + .expectFailure = false, + .expectedMultinomialDistributionTolerance = 0, + .isRelaxed = false, + .main = { + .inputIndexes = {3, 6}, + .operands = {{ // base + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }, { // exponent + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }, { // output + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({1.0f, 8.0f, 9.0f, 4.0f, 2.2360680103302f, 1.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT, + .numberOfConsumers = 0, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }, { // base_new + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }, { // dummy4 + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }, { // param4 + .channelQuant = {}, + .data = TestBuffer::createFromVector<int32_t>({0}), + .dimensions = {}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::INT32, + .zeroPoint = 0 + }, { // exponent_new + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({4.0f, 3.0f, 2.0f, 1.0f, 0.5f, 0.0f}), + .dimensions = {3, 2, 1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }, { // dummy5 + .channelQuant = {}, + .data = TestBuffer::createFromVector<_Float16>({0.0f}), + .dimensions = {1}, + .isIgnored = false, + .lifetime = TestOperandLifeTime::CONSTANT_COPY, + .numberOfConsumers = 1, + .scale = 0.0f, + .type = TestOperandType::TENSOR_FLOAT16, + .zeroPoint = 0 + }, { // param5 + .channelQuant = {}, + .data = TestBuffer::createFromVector<int32_t>({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 = {6, 7, 8}, + .outputs = {1}, + .type = TestOperationType::ADD + }, { + .inputs = {0, 1}, + .outputs = {2}, + .type = TestOperationType::POW + }}, + .outputIndexes = {2} + }, + .minSupportedVersion = TestHalVersion::V1_2, + .referenced = {} + }; + return model; +} + +const auto dummy_test_model_float16_all_inputs_as_internal = TestModelManager::get().add("pow_same_shape_float16_all_inputs_as_internal", get_test_model_float16_all_inputs_as_internal()); + +} // namespace generated_tests::pow_same_shape + diff --git a/nn/runtime/test/specs/V1_3/pow_same_shape.mod.py b/nn/runtime/test/specs/V1_3/pow_same_shape.mod.py new file mode 100644 index 000000000..f44f167ce --- /dev/null +++ b/nn/runtime/test/specs/V1_3/pow_same_shape.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. +# +base = Input("base", "TENSOR_FLOAT32", "{3, 2, 1}") +exponent = Input("exponent", "TENSOR_FLOAT32", "{3, 2, 1}") +output = Output("output", "TENSOR_FLOAT32", "{3, 2, 1}") + +base_data = [1, 2, 3, 4, 5, 6] +exponent_data = [4, 3, 2, 1, 0.5, 0] +output_data = [base_data[i]**exponent_data[i] for i in range(len(base_data))] + +model = Model().Operation("POW", base, exponent).To(output).IntroducedIn("V1_2") +Example({ + base: base_data, + exponent: exponent_data, + output: output_data +}, model=model).AddVariations("relaxed", "float16") |