summaryrefslogtreecommitdiff
path: root/nn
diff options
context:
space:
mode:
Diffstat (limited to 'nn')
-rw-r--r--nn/common/Utils.cpp22
-rw-r--r--nn/runtime/ExecutionBuilder.cpp6
-rw-r--r--nn/runtime/test/fuzzing/TestRandomGraph.cpp2
-rw-r--r--nn/runtime/test/fuzzing/operation_signatures/Elementwise.cpp68
-rw-r--r--nn/runtime/test/generated/spec_V1_1/lsh_projection_2_relaxed.example.cpp111
-rw-r--r--nn/runtime/test/generated/spec_V1_1/lsh_projection_relaxed.example.cpp44
-rw-r--r--nn/runtime/test/generated/spec_V1_2/lsh_projection_3_relaxed.example.cpp111
-rw-r--r--nn/runtime/test/generated/spec_V1_2/lsh_projection_4_relaxed.example.cpp111
-rw-r--r--nn/runtime/test/generated/spec_V1_2/lsh_projection_deprecated.example.cpp111
-rw-r--r--nn/runtime/test/generated/spec_V1_2/lsh_projection_float16.example.cpp410
-rw-r--r--nn/runtime/test/generated/spec_V1_3_cts_only/cast_mismatching_shapes.example.cpp53
-rw-r--r--nn/runtime/test/specs/V1_1/lsh_projection_2_relaxed.mod.py5
-rw-r--r--nn/runtime/test/specs/V1_1/lsh_projection_relaxed.mod.py6
-rw-r--r--nn/runtime/test/specs/V1_2/lsh_projection_3_relaxed.mod.py5
-rw-r--r--nn/runtime/test/specs/V1_2/lsh_projection_4_relaxed.mod.py5
-rw-r--r--nn/runtime/test/specs/V1_2/lsh_projection_deprecated.mod.py5
-rw-r--r--nn/runtime/test/specs/V1_2/lsh_projection_float16.mod.py2
-rw-r--r--nn/runtime/test/specs/V1_3_cts_only/cast_mismatching_shapes.mod.py25
-rw-r--r--nn/tools/test_generator/README.md8
-rwxr-xr-xnn/tools/test_generator/test_generator.py10
20 files changed, 181 insertions, 939 deletions
diff --git a/nn/common/Utils.cpp b/nn/common/Utils.cpp
index fedc8cb30..4e4d0e06a 100644
--- a/nn/common/Utils.cpp
+++ b/nn/common/Utils.cpp
@@ -26,7 +26,10 @@
#include <sys/system_properties.h>
#include <algorithm>
+#include <functional>
+#include <iostream>
#include <limits>
+#include <numeric>
#include <set>
#include <string>
#include <tuple>
@@ -1509,8 +1512,10 @@ int validateOperation(ANeuralNetworksOperationType opType, uint32_t inputCount,
logInvalidInOutNumber(1, 1);
return ANEURALNETWORKS_BAD_DATA;
}
- auto inputType = operands[inputIndexes[0]].type;
- auto outputType = operands[outputIndexes[0]].type;
+ auto inputOperand = operands[inputIndexes[0]];
+ auto outputOperand = operands[outputIndexes[0]];
+ auto inputType = inputOperand.type;
+ auto outputType = outputOperand.type;
std::vector<OperandType> inExpectedTypes;
std::vector<OperandType> outExpectedTypes;
if ((inputType == OperandType::TENSOR_FLOAT16 ||
@@ -1536,6 +1541,19 @@ int validateOperation(ANeuralNetworksOperationType opType, uint32_t inputCount,
LOG(ERROR) << "Unsupported data type for operation " << getOperationName(opType);
return ANEURALNETWORKS_BAD_DATA;
}
+ // Validate that output shape is equal to input shape if dimensions
+ // are already known.
+ auto getNumberOfElements = [](const hardware::hidl_vec<uint32_t>& dims) {
+ if (dims.size() == 0) {
+ return 0;
+ }
+ return std::accumulate(dims.begin(), dims.end(), 1, std::multiplies<>());
+ };
+ if (inputOperand.dimensions.size() != 0 && outputOperand.dimensions.size() != 0 &&
+ getNumberOfElements(outputOperand.dimensions) != 0 &&
+ inputOperand.dimensions != outputOperand.dimensions) {
+ return ANEURALNETWORKS_BAD_DATA;
+ }
return validateOperationOperandTypes(operands, inputCount, inputIndexes,
inExpectedTypes, outputCount, outputIndexes,
outExpectedTypes);
diff --git a/nn/runtime/ExecutionBuilder.cpp b/nn/runtime/ExecutionBuilder.cpp
index 61e320f9a..d65d96446 100644
--- a/nn/runtime/ExecutionBuilder.cpp
+++ b/nn/runtime/ExecutionBuilder.cpp
@@ -876,7 +876,11 @@ std::vector<OutputShape> ExecutionBuilder::getInitialOutputShapes() const {
std::vector<OutputShape> outputShapes(mOutputs.size());
std::transform(mOutputs.begin(), mOutputs.end(), outputShapes.begin(),
[](const auto& x) -> OutputShape {
- return {.dimensions = x.dimensions(), .isSufficient = true};
+ hidl_vec<uint32_t> dimensions;
+ if (x.state() != ModelArgumentInfo::HAS_NO_VALUE) {
+ dimensions = x.dimensions();
+ }
+ return {.dimensions = std::move(dimensions), .isSufficient = true};
});
return outputShapes;
}
diff --git a/nn/runtime/test/fuzzing/TestRandomGraph.cpp b/nn/runtime/test/fuzzing/TestRandomGraph.cpp
index 55c6542f1..2c8024a22 100644
--- a/nn/runtime/test/fuzzing/TestRandomGraph.cpp
+++ b/nn/runtime/test/fuzzing/TestRandomGraph.cpp
@@ -485,7 +485,7 @@ const AccuracyCriteria kStrictCriteria = {
// broadcast or elementwise, e.g ADD, FLOOR.
const AccuracyCriteria kMediumCriteria = {
.float32 = {.bias = 1e-6f, .mse = 1e-8f, .atol = 1e-5f, .rtol = 1e-5f},
- .float16 = {.bias = 1e-3f, .mse = 1e-6f, .atol = 1e-2f, .rtol = 1e-2f},
+ .float16 = {.bias = 1e-3f, .mse = 1e-5f, .atol = 1e-2f, .rtol = 1e-2f},
.int32 = {.atol = 1},
.quant8Asymm = {.bias = 1.2, .mse = 1.2, .atol = 2},
.quant8AsymmSigned = {.bias = 1.2, .mse = 1.2, .atol = 2},
diff --git a/nn/runtime/test/fuzzing/operation_signatures/Elementwise.cpp b/nn/runtime/test/fuzzing/operation_signatures/Elementwise.cpp
index 567ff0581..d84727d95 100644
--- a/nn/runtime/test/fuzzing/operation_signatures/Elementwise.cpp
+++ b/nn/runtime/test/fuzzing/operation_signatures/Elementwise.cpp
@@ -131,41 +131,51 @@ DEFINE_ELEMENTWISE_WITH_QUANT_OUTPUT_SIGNATURE(LOGISTIC, V1_3, /*scale=*/1.f / 2
DEFINE_ELEMENTWISE_WITH_QUANT_OUTPUT_SIGNATURE(TANH, V1_3, /*scale=*/1.f / 128, /*zeroPoint=*/0,
TestOperandType::TENSOR_QUANT8_ASYMM_SIGNED);
+static void castingOpConstructor(TestOperandType dataType, uint32_t rank, RandomOperation* op) {
+ sameDimensionOpConstructor(dataType, rank, op);
+
+ // If it is casting to/from a FP16 data type, the source/destination should have a scale
+ // representable in FP16 to avoid precision loss.
+ if (op->inputs[0]->dataType == TestOperandType::TENSOR_FLOAT16) {
+ op->outputs[0]->scale = static_cast<_Float16>(op->outputs[0]->scale);
+ } else if (op->outputs[0]->dataType == TestOperandType::TENSOR_FLOAT16) {
+ op->inputs[0]->scale = static_cast<_Float16>(op->inputs[0]->scale);
+ }
+}
+
// Operations with output data type different from input.
-#define DEFINE_ELEMENTWISE_WITH_TYPED_OUTPUT_SIGNATURE(op, ver, outType, ...) \
- DEFINE_OPERATION_SIGNATURE(op##_##outType##_##ver){ \
- .opType = TestOperationType::op, \
- .supportedDataTypes = {__VA_ARGS__}, \
- .supportedRanks = {1, 2, 3, 4}, \
- .version = TestHalVersion::ver, \
- .inputs = {INPUT_DEFAULT}, \
- .outputs = {OUTPUT_TYPED(TestOperandType::outType)}, \
- .constructor = sameDimensionOpConstructor};
-
-DEFINE_ELEMENTWISE_WITH_TYPED_OUTPUT_SIGNATURE(DEQUANTIZE, V1_0, /*outType=*/TENSOR_FLOAT32,
- TestOperandType::TENSOR_QUANT8_ASYMM);
+#define DEFINE_QUANTIZATION_OP_SIGNATURE(op, ver, outType, ...) \
+ DEFINE_OPERATION_SIGNATURE(op##_##outType##_##ver){ \
+ .opType = TestOperationType::op, \
+ .supportedDataTypes = {__VA_ARGS__}, \
+ .supportedRanks = {1, 2, 3, 4}, \
+ .version = TestHalVersion::ver, \
+ .inputs = {INPUT_DEFAULT}, \
+ .outputs = {OUTPUT_TYPED(TestOperandType::outType)}, \
+ .constructor = castingOpConstructor};
-DEFINE_ELEMENTWISE_WITH_TYPED_OUTPUT_SIGNATURE(DEQUANTIZE, V1_2, /*outType=*/TENSOR_FLOAT32,
- TestOperandType::TENSOR_QUANT8_SYMM);
+DEFINE_QUANTIZATION_OP_SIGNATURE(DEQUANTIZE, V1_0, /*outType=*/TENSOR_FLOAT32,
+ TestOperandType::TENSOR_QUANT8_ASYMM);
-DEFINE_ELEMENTWISE_WITH_TYPED_OUTPUT_SIGNATURE(DEQUANTIZE, V1_2, /*outType=*/TENSOR_FLOAT16,
- TestOperandType::TENSOR_QUANT8_ASYMM,
- TestOperandType::TENSOR_QUANT8_SYMM);
+DEFINE_QUANTIZATION_OP_SIGNATURE(DEQUANTIZE, V1_2, /*outType=*/TENSOR_FLOAT32,
+ TestOperandType::TENSOR_QUANT8_SYMM);
-DEFINE_ELEMENTWISE_WITH_TYPED_OUTPUT_SIGNATURE(DEQUANTIZE, V1_3, /*outType=*/TENSOR_FLOAT32,
- TestOperandType::TENSOR_QUANT8_ASYMM_SIGNED);
+DEFINE_QUANTIZATION_OP_SIGNATURE(DEQUANTIZE, V1_2, /*outType=*/TENSOR_FLOAT16,
+ TestOperandType::TENSOR_QUANT8_ASYMM,
+ TestOperandType::TENSOR_QUANT8_SYMM);
-DEFINE_ELEMENTWISE_WITH_TYPED_OUTPUT_SIGNATURE(DEQUANTIZE, V1_3, /*outType=*/TENSOR_FLOAT16,
- TestOperandType::TENSOR_QUANT8_ASYMM_SIGNED);
+DEFINE_QUANTIZATION_OP_SIGNATURE(DEQUANTIZE, V1_3, /*outType=*/TENSOR_FLOAT32,
+ TestOperandType::TENSOR_QUANT8_ASYMM_SIGNED);
-DEFINE_ELEMENTWISE_WITH_TYPED_OUTPUT_SIGNATURE(QUANTIZE, V1_2, /*outType=*/TENSOR_QUANT8_ASYMM,
- TestOperandType::TENSOR_FLOAT32,
- TestOperandType::TENSOR_FLOAT16);
+DEFINE_QUANTIZATION_OP_SIGNATURE(DEQUANTIZE, V1_3, /*outType=*/TENSOR_FLOAT16,
+ TestOperandType::TENSOR_QUANT8_ASYMM_SIGNED);
-DEFINE_ELEMENTWISE_WITH_TYPED_OUTPUT_SIGNATURE(QUANTIZE, V1_3,
- /*outType=*/TENSOR_QUANT8_ASYMM_SIGNED,
- TestOperandType::TENSOR_FLOAT32,
- TestOperandType::TENSOR_FLOAT16);
+DEFINE_QUANTIZATION_OP_SIGNATURE(QUANTIZE, V1_2, /*outType=*/TENSOR_QUANT8_ASYMM,
+ TestOperandType::TENSOR_FLOAT32, TestOperandType::TENSOR_FLOAT16);
+
+DEFINE_QUANTIZATION_OP_SIGNATURE(QUANTIZE, V1_3,
+ /*outType=*/TENSOR_QUANT8_ASYMM_SIGNED,
+ TestOperandType::TENSOR_FLOAT32, TestOperandType::TENSOR_FLOAT16);
#define DEFINE_CAST_SIGNATURE(ver, outType, ...) \
DEFINE_OPERATION_SIGNATURE(CAST_##outType##_##ver){ \
@@ -175,7 +185,7 @@ DEFINE_ELEMENTWISE_WITH_TYPED_OUTPUT_SIGNATURE(QUANTIZE, V1_3,
.version = TestHalVersion::ver, \
.inputs = {INPUT_DEFAULT}, \
.outputs = {OUTPUT_TYPED(TestOperandType::outType)}, \
- .constructor = sameDimensionOpConstructor};
+ .constructor = castingOpConstructor};
DEFINE_CAST_SIGNATURE(V1_2, /*outType=*/TENSOR_FLOAT32, TestOperandType::TENSOR_FLOAT32,
TestOperandType::TENSOR_FLOAT16, TestOperandType::TENSOR_QUANT8_ASYMM,
diff --git a/nn/runtime/test/generated/spec_V1_1/lsh_projection_2_relaxed.example.cpp b/nn/runtime/test/generated/spec_V1_1/lsh_projection_2_relaxed.example.cpp
index 6fcbb81ec..23dbd2795 100644
--- a/nn/runtime/test/generated/spec_V1_1/lsh_projection_2_relaxed.example.cpp
+++ b/nn/runtime/test/generated/spec_V1_1/lsh_projection_2_relaxed.example.cpp
@@ -158,114 +158,3 @@ const auto dummy_test_model_all_tensors_as_inputs = TestModelManager::get().add(
} // namespace generated_tests::lsh_projection_2_relaxed
-namespace generated_tests::lsh_projection_2_relaxed {
-
-const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() {
- static TestModel model = {
- .expectFailure = false,
- .expectedMultinomialDistributionTolerance = 0,
- .isRelaxed = true,
- .main = {
- .inputIndexes = {1, 2, 5},
- .operands = {{ // hash
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({}),
- .dimensions = {4, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT32,
- .zeroPoint = 0
- }, { // lookup
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({12345, 54321, 67890, 9876, -12345678, -87654321}),
- .dimensions = {3, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // weight
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({}),
- .dimensions = {3},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT32,
- .zeroPoint = 0
- }, { // type_param
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1}),
- .dimensions = {},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::INT32,
- .zeroPoint = 0
- }, { // output
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1, 2, 2, 0}),
- .dimensions = {4},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT,
- .numberOfConsumers = 0,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // hash_new
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
- .dimensions = {4, 2},
- .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
- }},
- .operations = {{
- .inputs = {5, 6, 7},
- .outputs = {0},
- .type = TestOperationType::ADD
- }, {
- .inputs = {0, 1, 2, 3},
- .outputs = {4},
- .type = TestOperationType::LSH_PROJECTION
- }},
- .outputIndexes = {4}
- },
- .minSupportedVersion = TestHalVersion::UNKNOWN,
- .referenced = {}
- };
- return model;
-}
-
-const auto dummy_test_model_all_tensors_as_inputs_all_inputs_as_internal = TestModelManager::get().add("lsh_projection_2_relaxed_all_tensors_as_inputs_all_inputs_as_internal", get_test_model_all_tensors_as_inputs_all_inputs_as_internal());
-
-} // namespace generated_tests::lsh_projection_2_relaxed
-
diff --git a/nn/runtime/test/generated/spec_V1_1/lsh_projection_relaxed.example.cpp b/nn/runtime/test/generated/spec_V1_1/lsh_projection_relaxed.example.cpp
index 68782659b..aa7ccfb24 100644
--- a/nn/runtime/test/generated/spec_V1_1/lsh_projection_relaxed.example.cpp
+++ b/nn/runtime/test/generated/spec_V1_1/lsh_projection_relaxed.example.cpp
@@ -277,13 +277,13 @@ const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() {
.expectedMultinomialDistributionTolerance = 0,
.isRelaxed = true,
.main = {
- .inputIndexes = {1, 5, 8},
+ .inputIndexes = {0, 1, 5},
.operands = {{ // hash
.channelQuant = {},
- .data = TestBuffer::createFromVector<float>({}),
+ .data = TestBuffer::createFromVector<float>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
.dimensions = {4, 2},
.isIgnored = false,
- .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE,
+ .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
.numberOfConsumers = 1,
.scale = 0.0f,
.type = TestOperandType::TENSOR_FLOAT32,
@@ -328,36 +328,6 @@ const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() {
.scale = 0.0f,
.type = TestOperandType::TENSOR_INT32,
.zeroPoint = 0
- }, { // hash_new
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
- .dimensions = {4, 2},
- .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
}, { // weight_new
.channelQuant = {},
.data = TestBuffer::createFromVector<float>({0.12f, 0.34f, 0.56f}),
@@ -368,7 +338,7 @@ const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() {
.scale = 0.0f,
.type = TestOperandType::TENSOR_FLOAT32,
.zeroPoint = 0
- }, { // dummy2
+ }, { // dummy1
.channelQuant = {},
.data = TestBuffer::createFromVector<float>({0.0f}),
.dimensions = {1},
@@ -378,7 +348,7 @@ const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() {
.scale = 0.0f,
.type = TestOperandType::TENSOR_FLOAT32,
.zeroPoint = 0
- }, { // param2
+ }, { // param1
.channelQuant = {},
.data = TestBuffer::createFromVector<int32_t>({0}),
.dimensions = {},
@@ -391,10 +361,6 @@ const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() {
}},
.operations = {{
.inputs = {5, 6, 7},
- .outputs = {0},
- .type = TestOperationType::ADD
- }, {
- .inputs = {8, 9, 10},
.outputs = {2},
.type = TestOperationType::ADD
}, {
diff --git a/nn/runtime/test/generated/spec_V1_2/lsh_projection_3_relaxed.example.cpp b/nn/runtime/test/generated/spec_V1_2/lsh_projection_3_relaxed.example.cpp
index 0b964f97c..f44967963 100644
--- a/nn/runtime/test/generated/spec_V1_2/lsh_projection_3_relaxed.example.cpp
+++ b/nn/runtime/test/generated/spec_V1_2/lsh_projection_3_relaxed.example.cpp
@@ -158,114 +158,3 @@ const auto dummy_test_model_all_tensors_as_inputs = TestModelManager::get().add(
} // namespace generated_tests::lsh_projection_3_relaxed
-namespace generated_tests::lsh_projection_3_relaxed {
-
-const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() {
- static TestModel model = {
- .expectFailure = false,
- .expectedMultinomialDistributionTolerance = 0,
- .isRelaxed = true,
- .main = {
- .inputIndexes = {1, 2, 5},
- .operands = {{ // hash
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({}),
- .dimensions = {4, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT32,
- .zeroPoint = 0
- }, { // lookup
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({12345, 54321, 67890, 9876, -12345678, -87654321}),
- .dimensions = {3, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // weight
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({}),
- .dimensions = {3},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT32,
- .zeroPoint = 0
- }, { // type_param
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({3}),
- .dimensions = {},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::INT32,
- .zeroPoint = 0
- }, { // output
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1, 6, 10, 12}),
- .dimensions = {4},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT,
- .numberOfConsumers = 0,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // hash_new
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
- .dimensions = {4, 2},
- .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
- }},
- .operations = {{
- .inputs = {5, 6, 7},
- .outputs = {0},
- .type = TestOperationType::ADD
- }, {
- .inputs = {0, 1, 2, 3},
- .outputs = {4},
- .type = TestOperationType::LSH_PROJECTION
- }},
- .outputIndexes = {4}
- },
- .minSupportedVersion = TestHalVersion::UNKNOWN,
- .referenced = {}
- };
- return model;
-}
-
-const auto dummy_test_model_all_tensors_as_inputs_all_inputs_as_internal = TestModelManager::get().add("lsh_projection_3_relaxed_all_tensors_as_inputs_all_inputs_as_internal", get_test_model_all_tensors_as_inputs_all_inputs_as_internal());
-
-} // namespace generated_tests::lsh_projection_3_relaxed
-
diff --git a/nn/runtime/test/generated/spec_V1_2/lsh_projection_4_relaxed.example.cpp b/nn/runtime/test/generated/spec_V1_2/lsh_projection_4_relaxed.example.cpp
index 2329565ae..09e165d52 100644
--- a/nn/runtime/test/generated/spec_V1_2/lsh_projection_4_relaxed.example.cpp
+++ b/nn/runtime/test/generated/spec_V1_2/lsh_projection_4_relaxed.example.cpp
@@ -158,114 +158,3 @@ const auto dummy_test_model_all_tensors_as_inputs = TestModelManager::get().add(
} // namespace generated_tests::lsh_projection_4_relaxed
-namespace generated_tests::lsh_projection_4_relaxed {
-
-const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() {
- static TestModel model = {
- .expectFailure = false,
- .expectedMultinomialDistributionTolerance = 0,
- .isRelaxed = true,
- .main = {
- .inputIndexes = {1, 2, 5},
- .operands = {{ // hash
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({}),
- .dimensions = {4, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT32,
- .zeroPoint = 0
- }, { // lookup
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({12345, 54321, 67890, 9876, -12345678, -87654321}),
- .dimensions = {3, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // weight
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({}),
- .dimensions = {3},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT32,
- .zeroPoint = 0
- }, { // type_param
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1}),
- .dimensions = {},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::INT32,
- .zeroPoint = 0
- }, { // output
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1, 2, 2, 0}),
- .dimensions = {4},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT,
- .numberOfConsumers = 0,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // hash_new
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
- .dimensions = {4, 2},
- .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
- }},
- .operations = {{
- .inputs = {5, 6, 7},
- .outputs = {0},
- .type = TestOperationType::ADD
- }, {
- .inputs = {0, 1, 2, 3},
- .outputs = {4},
- .type = TestOperationType::LSH_PROJECTION
- }},
- .outputIndexes = {4}
- },
- .minSupportedVersion = TestHalVersion::UNKNOWN,
- .referenced = {}
- };
- return model;
-}
-
-const auto dummy_test_model_all_tensors_as_inputs_all_inputs_as_internal = TestModelManager::get().add("lsh_projection_4_relaxed_all_tensors_as_inputs_all_inputs_as_internal", get_test_model_all_tensors_as_inputs_all_inputs_as_internal());
-
-} // namespace generated_tests::lsh_projection_4_relaxed
-
diff --git a/nn/runtime/test/generated/spec_V1_2/lsh_projection_deprecated.example.cpp b/nn/runtime/test/generated/spec_V1_2/lsh_projection_deprecated.example.cpp
index e225e5500..e87591ee9 100644
--- a/nn/runtime/test/generated/spec_V1_2/lsh_projection_deprecated.example.cpp
+++ b/nn/runtime/test/generated/spec_V1_2/lsh_projection_deprecated.example.cpp
@@ -158,114 +158,3 @@ const auto dummy_test_model_all_tensors_as_inputs = TestModelManager::get().add(
} // namespace generated_tests::lsh_projection_deprecated
-namespace generated_tests::lsh_projection_deprecated {
-
-const TestModel& get_test_model_all_tensors_as_inputs_all_inputs_as_internal() {
- static TestModel model = {
- .expectFailure = false,
- .expectedMultinomialDistributionTolerance = 0,
- .isRelaxed = true,
- .main = {
- .inputIndexes = {1, 2, 5},
- .operands = {{ // hash
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({}),
- .dimensions = {4, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT32,
- .zeroPoint = 0
- }, { // lookup
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({12345, 54321, 67890, 9876, -12345678, -87654321}),
- .dimensions = {3, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // weight
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({}),
- .dimensions = {3},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT32,
- .zeroPoint = 0
- }, { // type_param
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1}),
- .dimensions = {},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::INT32,
- .zeroPoint = 0
- }, { // output
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1, 2, 2, 0}),
- .dimensions = {4},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT,
- .numberOfConsumers = 0,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // hash_new
- .channelQuant = {},
- .data = TestBuffer::createFromVector<float>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
- .dimensions = {4, 2},
- .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
- }},
- .operations = {{
- .inputs = {5, 6, 7},
- .outputs = {0},
- .type = TestOperationType::ADD
- }, {
- .inputs = {0, 1, 2, 3},
- .outputs = {4},
- .type = TestOperationType::LSH_PROJECTION
- }},
- .outputIndexes = {4}
- },
- .minSupportedVersion = TestHalVersion::UNKNOWN,
- .referenced = {}
- };
- return model;
-}
-
-const auto dummy_test_model_all_tensors_as_inputs_all_inputs_as_internal = TestModelManager::get().add("lsh_projection_deprecated_all_tensors_as_inputs_all_inputs_as_internal", get_test_model_all_tensors_as_inputs_all_inputs_as_internal());
-
-} // namespace generated_tests::lsh_projection_deprecated
-
diff --git a/nn/runtime/test/generated/spec_V1_2/lsh_projection_float16.example.cpp b/nn/runtime/test/generated/spec_V1_2/lsh_projection_float16.example.cpp
index c69b0c1e3..4a57101db 100644
--- a/nn/runtime/test/generated/spec_V1_2/lsh_projection_float16.example.cpp
+++ b/nn/runtime/test/generated/spec_V1_2/lsh_projection_float16.example.cpp
@@ -414,413 +414,3 @@ const auto dummy_test_model_all_tensors_as_inputs_all_inputs_as_internal = TestM
} // namespace generated_tests::lsh_projection_float16
-namespace generated_tests::lsh_projection_float16 {
-
-const TestModel& get_test_model_float16() {
- static TestModel model = {
- .expectFailure = false,
- .expectedMultinomialDistributionTolerance = 0,
- .isRelaxed = false,
- .main = {
- .inputIndexes = {1, 2},
- .operands = {{ // hash
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
- .dimensions = {4, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT16,
- .zeroPoint = 0
- }, { // lookup
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({12345, 54321, 67890, 9876, -12345678, -87654321}),
- .dimensions = {3, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // weight
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({0.12f, 0.34f, 0.56f}),
- .dimensions = {3},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT16,
- .zeroPoint = 0
- }, { // type_param
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({2}),
- .dimensions = {},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::INT32,
- .zeroPoint = 0
- }, { // output
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1, 1, 1, 1, 1, 0, 0, 0}),
- .dimensions = {8},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT,
- .numberOfConsumers = 0,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }},
- .operations = {{
- .inputs = {0, 1, 2, 3},
- .outputs = {4},
- .type = TestOperationType::LSH_PROJECTION
- }},
- .outputIndexes = {4}
- },
- .minSupportedVersion = TestHalVersion::V1_2,
- .referenced = {}
- };
- return model;
-}
-
-const auto dummy_test_model_float16 = TestModelManager::get().add("lsh_projection_float16_float16", get_test_model_float16());
-
-} // namespace generated_tests::lsh_projection_float16
-
-namespace generated_tests::lsh_projection_float16 {
-
-const TestModel& get_test_model_float16_all_inputs_as_internal() {
- static TestModel model = {
- .expectFailure = false,
- .expectedMultinomialDistributionTolerance = 0,
- .isRelaxed = false,
- .main = {
- .inputIndexes = {1, 5},
- .operands = {{ // hash
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
- .dimensions = {4, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT16,
- .zeroPoint = 0
- }, { // lookup
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({12345, 54321, 67890, 9876, -12345678, -87654321}),
- .dimensions = {3, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // weight
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({}),
- .dimensions = {3},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT16,
- .zeroPoint = 0
- }, { // type_param
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({2}),
- .dimensions = {},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::INT32,
- .zeroPoint = 0
- }, { // output
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1, 1, 1, 1, 1, 0, 0, 0}),
- .dimensions = {8},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT,
- .numberOfConsumers = 0,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // weight_new
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({0.12f, 0.34f, 0.56f}),
- .dimensions = {3},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT16,
- .zeroPoint = 0
- }, { // dummy3
- .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
- }, { // 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 = {5, 6, 7},
- .outputs = {2},
- .type = TestOperationType::ADD
- }, {
- .inputs = {0, 1, 2, 3},
- .outputs = {4},
- .type = TestOperationType::LSH_PROJECTION
- }},
- .outputIndexes = {4}
- },
- .minSupportedVersion = TestHalVersion::V1_2,
- .referenced = {}
- };
- return model;
-}
-
-const auto dummy_test_model_float16_all_inputs_as_internal = TestModelManager::get().add("lsh_projection_float16_float16_all_inputs_as_internal", get_test_model_float16_all_inputs_as_internal());
-
-} // namespace generated_tests::lsh_projection_float16
-
-namespace generated_tests::lsh_projection_float16 {
-
-const TestModel& get_test_model_float16_all_tensors_as_inputs() {
- static TestModel model = {
- .expectFailure = false,
- .expectedMultinomialDistributionTolerance = 0,
- .isRelaxed = false,
- .main = {
- .inputIndexes = {0, 1, 2},
- .operands = {{ // hash
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
- .dimensions = {4, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT16,
- .zeroPoint = 0
- }, { // lookup
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({12345, 54321, 67890, 9876, -12345678, -87654321}),
- .dimensions = {3, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // weight
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({0.12f, 0.34f, 0.56f}),
- .dimensions = {3},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT16,
- .zeroPoint = 0
- }, { // type_param
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({2}),
- .dimensions = {},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::INT32,
- .zeroPoint = 0
- }, { // output
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1, 1, 1, 1, 1, 0, 0, 0}),
- .dimensions = {8},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT,
- .numberOfConsumers = 0,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }},
- .operations = {{
- .inputs = {0, 1, 2, 3},
- .outputs = {4},
- .type = TestOperationType::LSH_PROJECTION
- }},
- .outputIndexes = {4}
- },
- .minSupportedVersion = TestHalVersion::V1_2,
- .referenced = {}
- };
- return model;
-}
-
-const auto dummy_test_model_float16_all_tensors_as_inputs = TestModelManager::get().add("lsh_projection_float16_float16_all_tensors_as_inputs", get_test_model_float16_all_tensors_as_inputs());
-
-} // namespace generated_tests::lsh_projection_float16
-
-namespace generated_tests::lsh_projection_float16 {
-
-const TestModel& get_test_model_float16_all_tensors_as_inputs_all_inputs_as_internal() {
- static TestModel model = {
- .expectFailure = false,
- .expectedMultinomialDistributionTolerance = 0,
- .isRelaxed = false,
- .main = {
- .inputIndexes = {1, 5, 8},
- .operands = {{ // hash
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({}),
- .dimensions = {4, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT16,
- .zeroPoint = 0
- }, { // lookup
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({12345, 54321, 67890, 9876, -12345678, -87654321}),
- .dimensions = {3, 2},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // weight
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({}),
- .dimensions = {3},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::TEMPORARY_VARIABLE,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_FLOAT16,
- .zeroPoint = 0
- }, { // type_param
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({2}),
- .dimensions = {},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::CONSTANT_COPY,
- .numberOfConsumers = 1,
- .scale = 0.0f,
- .type = TestOperandType::INT32,
- .zeroPoint = 0
- }, { // output
- .channelQuant = {},
- .data = TestBuffer::createFromVector<int32_t>({1, 1, 1, 1, 1, 0, 0, 0}),
- .dimensions = {8},
- .isIgnored = false,
- .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT,
- .numberOfConsumers = 0,
- .scale = 0.0f,
- .type = TestOperandType::TENSOR_INT32,
- .zeroPoint = 0
- }, { // hash_new
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({0.123f, 0.456f, -0.321f, -0.654f, 1.234f, 5.678f, -4.321f, -8.765f}),
- .dimensions = {4, 2},
- .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
- }, { // weight_new
- .channelQuant = {},
- .data = TestBuffer::createFromVector<_Float16>({0.12f, 0.34f, 0.56f}),
- .dimensions = {3},
- .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 = {5, 6, 7},
- .outputs = {0},
- .type = TestOperationType::ADD
- }, {
- .inputs = {8, 9, 10},
- .outputs = {2},
- .type = TestOperationType::ADD
- }, {
- .inputs = {0, 1, 2, 3},
- .outputs = {4},
- .type = TestOperationType::LSH_PROJECTION
- }},
- .outputIndexes = {4}
- },
- .minSupportedVersion = TestHalVersion::V1_2,
- .referenced = {}
- };
- return model;
-}
-
-const auto dummy_test_model_float16_all_tensors_as_inputs_all_inputs_as_internal = TestModelManager::get().add("lsh_projection_float16_float16_all_tensors_as_inputs_all_inputs_as_internal", get_test_model_float16_all_tensors_as_inputs_all_inputs_as_internal());
-
-} // namespace generated_tests::lsh_projection_float16
-
diff --git a/nn/runtime/test/generated/spec_V1_3_cts_only/cast_mismatching_shapes.example.cpp b/nn/runtime/test/generated/spec_V1_3_cts_only/cast_mismatching_shapes.example.cpp
new file mode 100644
index 000000000..24ba83438
--- /dev/null
+++ b/nn/runtime/test/generated/spec_V1_3_cts_only/cast_mismatching_shapes.example.cpp
@@ -0,0 +1,53 @@
+// Generated from cast_mismatching_shapes.mod.py
+// DO NOT EDIT
+// clang-format off
+#include "TestHarness.h"
+using namespace test_helper;
+
+namespace generated_tests::cast_mismatching_shapes {
+
+const TestModel& get_test_model() {
+ static TestModel model = {
+ .expectFailure = true,
+ .expectedMultinomialDistributionTolerance = 0,
+ .isRelaxed = false,
+ .main = {
+ .inputIndexes = {0},
+ .operands = {{ // input0
+ .channelQuant = {},
+ .data = TestBuffer::createFromVector<int32_t>({1, 2, 3, 4, 5, 6}),
+ .dimensions = {2, 3},
+ .isIgnored = false,
+ .lifetime = TestOperandLifeTime::SUBGRAPH_INPUT,
+ .numberOfConsumers = 1,
+ .scale = 0.0f,
+ .type = TestOperandType::TENSOR_INT32,
+ .zeroPoint = 0
+ }, { // output0
+ .channelQuant = {},
+ .data = TestBuffer::createFromVector<int32_t>({1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
+ .dimensions = {100},
+ .isIgnored = false,
+ .lifetime = TestOperandLifeTime::SUBGRAPH_OUTPUT,
+ .numberOfConsumers = 0,
+ .scale = 0.0f,
+ .type = TestOperandType::TENSOR_INT32,
+ .zeroPoint = 0
+ }},
+ .operations = {{
+ .inputs = {0},
+ .outputs = {1},
+ .type = TestOperationType::CAST
+ }},
+ .outputIndexes = {1}
+ },
+ .minSupportedVersion = TestHalVersion::UNKNOWN,
+ .referenced = {}
+ };
+ return model;
+}
+
+const auto dummy_test_model = TestModelManager::get().add("cast_mismatching_shapes", get_test_model());
+
+} // namespace generated_tests::cast_mismatching_shapes
+
diff --git a/nn/runtime/test/specs/V1_1/lsh_projection_2_relaxed.mod.py b/nn/runtime/test/specs/V1_1/lsh_projection_2_relaxed.mod.py
index 6608b0666..1904f0490 100644
--- a/nn/runtime/test/specs/V1_1/lsh_projection_2_relaxed.mod.py
+++ b/nn/runtime/test/specs/V1_1/lsh_projection_2_relaxed.mod.py
@@ -20,8 +20,9 @@ num_bits = 2
model = Model()
-hhash = Parameter("hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
- [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765])
+hhash = Parameter(
+ "hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
+ [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765]).ShouldNeverBeInternal()
lookup = Input("lookup", "TENSOR_INT32", "{%d, %d}" % (num_input, num_bits))
weight = Input("weight", "TENSOR_FLOAT32", "{%d}" % (num_input))
type_param = Int32Scalar("type_param", 1) # SPARSE
diff --git a/nn/runtime/test/specs/V1_1/lsh_projection_relaxed.mod.py b/nn/runtime/test/specs/V1_1/lsh_projection_relaxed.mod.py
index 9a1bfaca2..c8ac42bdc 100644
--- a/nn/runtime/test/specs/V1_1/lsh_projection_relaxed.mod.py
+++ b/nn/runtime/test/specs/V1_1/lsh_projection_relaxed.mod.py
@@ -20,8 +20,9 @@ num_bits = 2
model = Model()
-hhash = Parameter("hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
- [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765])
+hhash = Parameter(
+ "hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
+ [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765]).ShouldNeverBeInternal()
lookup = Input("lookup", "TENSOR_INT32", "{%d, %d}" % (num_input, num_bits))
weight = Input("weight", "TENSOR_FLOAT32", "{%d}" % (num_input))
type_param = Int32Scalar("type_param", 2) # DENSE
@@ -38,4 +39,3 @@ input0 = {
output0 = {output: [1, 1, 1, 0, 1, 1, 1, 0]}
Example((input0, output0))
-
diff --git a/nn/runtime/test/specs/V1_2/lsh_projection_3_relaxed.mod.py b/nn/runtime/test/specs/V1_2/lsh_projection_3_relaxed.mod.py
index de7cec111..443fe6956 100644
--- a/nn/runtime/test/specs/V1_2/lsh_projection_3_relaxed.mod.py
+++ b/nn/runtime/test/specs/V1_2/lsh_projection_3_relaxed.mod.py
@@ -20,8 +20,9 @@ num_bits = 2
model = Model()
-hhash = Parameter("hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
- [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765])
+hhash = Parameter(
+ "hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
+ [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765]).ShouldNeverBeInternal()
lookup = Input("lookup", "TENSOR_INT32", "{%d, %d}" % (num_input, num_bits))
weight = Input("weight", "TENSOR_FLOAT32", "{%d}" % (num_input))
type_param = Int32Scalar("type_param", 3) # SPARSE
diff --git a/nn/runtime/test/specs/V1_2/lsh_projection_4_relaxed.mod.py b/nn/runtime/test/specs/V1_2/lsh_projection_4_relaxed.mod.py
index 2b3b33a1e..a8af8940d 100644
--- a/nn/runtime/test/specs/V1_2/lsh_projection_4_relaxed.mod.py
+++ b/nn/runtime/test/specs/V1_2/lsh_projection_4_relaxed.mod.py
@@ -20,8 +20,9 @@ num_bits = 2
model = Model()
-hhash = Parameter("hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
- [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765])
+hhash = Parameter(
+ "hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
+ [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765]).ShouldNeverBeInternal()
lookup = Input("lookup", "TENSOR_INT32", "{%d, %d}" % (num_input, num_bits))
weight = Input("weight", "TENSOR_FLOAT32", "{%d}" % (num_input))
type_param = Int32Scalar("type_param", 1) # SPARSE DEPRECATED
diff --git a/nn/runtime/test/specs/V1_2/lsh_projection_deprecated.mod.py b/nn/runtime/test/specs/V1_2/lsh_projection_deprecated.mod.py
index 2b3b33a1e..a8af8940d 100644
--- a/nn/runtime/test/specs/V1_2/lsh_projection_deprecated.mod.py
+++ b/nn/runtime/test/specs/V1_2/lsh_projection_deprecated.mod.py
@@ -20,8 +20,9 @@ num_bits = 2
model = Model()
-hhash = Parameter("hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
- [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765])
+hhash = Parameter(
+ "hash", "TENSOR_FLOAT32", "{%d, %d}" % (num_hash, num_bits),
+ [0.123, 0.456, -0.321, -0.654, 1.234, 5.678, -4.321, -8.765]).ShouldNeverBeInternal()
lookup = Input("lookup", "TENSOR_INT32", "{%d, %d}" % (num_input, num_bits))
weight = Input("weight", "TENSOR_FLOAT32", "{%d}" % (num_input))
type_param = Int32Scalar("type_param", 1) # SPARSE DEPRECATED
diff --git a/nn/runtime/test/specs/V1_2/lsh_projection_float16.mod.py b/nn/runtime/test/specs/V1_2/lsh_projection_float16.mod.py
index ed19b17f7..4b22ad190 100644
--- a/nn/runtime/test/specs/V1_2/lsh_projection_float16.mod.py
+++ b/nn/runtime/test/specs/V1_2/lsh_projection_float16.mod.py
@@ -36,4 +36,4 @@ input0 = {
}
output0 = {output: [1, 1, 1, 1, 1, 0, 0, 0]}
-Example((input0, output0)).AddVariations("float16");
+Example((input0, output0))
diff --git a/nn/runtime/test/specs/V1_3_cts_only/cast_mismatching_shapes.mod.py b/nn/runtime/test/specs/V1_3_cts_only/cast_mismatching_shapes.mod.py
new file mode 100644
index 000000000..c718e5cc2
--- /dev/null
+++ b/nn/runtime/test/specs/V1_3_cts_only/cast_mismatching_shapes.mod.py
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+
+input0 = Input("input0", "TENSOR_INT32", "{2, 3}")
+output0 = Output("output0", "TENSOR_INT32", "{100}")
+
+model = Model().Operation("CAST", input0).To(output0)
+
+example = Example({
+ input0: [1, 2, 3, 4, 5, 6],
+ output0: [1, 2, 3, 4, 5, 6] + [0] * 94,
+}, model=model).ExpectFailure()
diff --git a/nn/tools/test_generator/README.md b/nn/tools/test_generator/README.md
index 29c1155d2..e781771ce 100644
--- a/nn/tools/test_generator/README.md
+++ b/nn/tools/test_generator/README.md
@@ -244,6 +244,14 @@ example.DisableLifeTimeVariation()
example.DisableDynamicOutputShapeVariation()
```
+You may also specify a certain operand to be input/const-only that `AllInputsAsInternalCoverter` will skip converting this operand.
+
+```Python
+# "hash" will be converted to a model input when applying AllTensorsAsInputsConverter,
+# but will be skipped when further applying AllInputsAsInternalCoverter.
+hash = Parameter("hash", "TENSOR_FLOAT32", "{1, 1}", [0.123]).ShouldNeverBeInternal()
+```
+
#### Some helper functions
The test generator provides several helper functions or shorthands to add commonly used group of variations.
diff --git a/nn/tools/test_generator/test_generator.py b/nn/tools/test_generator/test_generator.py
index e1b10a7ad..92dfad756 100755
--- a/nn/tools/test_generator/test_generator.py
+++ b/nn/tools/test_generator/test_generator.py
@@ -295,6 +295,7 @@ class Operand(NamedVariable):
self.model_index = None
self.ins = []
self.outs = []
+ self.mayBeInternal = True
def SetValue(self, value):
self.value = value if type(value) is list or type(value) is tuple or value is None \
@@ -330,8 +331,15 @@ class Operand(NamedVariable):
extraParams=self.type.extraParams)
if not issubclass(DerivedClass, Internal):
newop.SetValue(self.value)
+ if not self.mayBeInternal:
+ assert not issubclass(DerivedClass, Internal)
+ newop.ShouldNeverBeInternal()
return newop
+ def ShouldNeverBeInternal(self):
+ self.mayBeInternal = False
+ return self
+
# Base class of user-defined input/output operand
class InOut(Operand):
@@ -1031,7 +1039,7 @@ class AllInputsAsInternalCoverter(ModelVariation):
raise SkipVariation
# Find all input tensors that can be an output of the ADD operation.
- modelInputs = [i for i in model.GetInputs() if CompatibleWithADD(i)]
+ modelInputs = [i for i in model.GetInputs() if CompatibleWithADD(i) and i.mayBeInternal]
if not modelInputs:
raise SkipVariation