summaryrefslogtreecommitdiff
path: root/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8
diff options
context:
space:
mode:
Diffstat (limited to 'tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8')
-rw-r--r--tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/conv_quant8.mod.py35
-rw-r--r--tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/stderr.txt.expect2
-rw-r--r--tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/stdout.txt.expect142
3 files changed, 179 insertions, 0 deletions
diff --git a/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/conv_quant8.mod.py b/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/conv_quant8.mod.py
new file mode 100644
index 000000000..f6b3e89ca
--- /dev/null
+++ b/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/conv_quant8.mod.py
@@ -0,0 +1,35 @@
+# Copyright 2018, 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 = Model()
+i1 = Input("op1", "TENSOR_FLOAT32", "{1, 3, 3, 1}")
+f1 = Parameter("op2", "TENSOR_FLOAT32", "{1, 2, 2, 1}", [.25, .25, .25, .25])
+b1 = Parameter("op3", "TENSOR_FLOAT32", "{1}", [0])
+pad0 = Int32Scalar("pad0", 0)
+act = Int32Scalar("act", 0)
+stride = Int32Scalar("stride", 1)
+output = Output("op4", "TENSOR_FLOAT32", "{1, 2, 2, 1}")
+
+model = model.Operation("CONV_2D", i1, f1, b1, pad0, pad0, pad0, pad0, stride, stride, act).To(output)
+model = model.RelaxedExecution(True)
+
+# Example 1. Input in operand 0,
+input0 = {i1: # input 0
+ [1.0, 1.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0]}
+
+output0 = {output: # output 0
+ [.875, .875, .875, .875]}
+
+# Instantiate an example
+Example((input0, output0))
diff --git a/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/stderr.txt.expect b/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/stderr.txt.expect
new file mode 100644
index 000000000..3decb4c1c
--- /dev/null
+++ b/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/stderr.txt.expect
@@ -0,0 +1,2 @@
+Output VTS model: -
+Output example:-
diff --git a/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/stdout.txt.expect b/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/stdout.txt.expect
new file mode 100644
index 000000000..0df371ba0
--- /dev/null
+++ b/tests/nnapi/nnapi_test_generator/android-q-beta/tests/P_vts_quant8/stdout.txt.expect
@@ -0,0 +1,142 @@
+// clang-format off
+// Generated file (from: conv_quant8.mod.py). Do not edit
+// clang-format off
+// Generated file (from: conv_quant8.mod.py). Do not edit
+// Generated from: conv_quant8.mod.py.
+namespace conv_quant8 {
+// Generated conv_quant8 test
+#include "-"
+// Generated model constructor
+#include "-"
+} // namespace conv_quant8
+
+// Create the model
+Model createTestModel() {
+ const std::vector<Operand> operands = {
+ {
+ .type = OperandType::TENSOR_FLOAT32,
+ .dimensions = {1, 3, 3, 1},
+ .numberOfConsumers = 1,
+ .scale = 0.0f,
+ .zeroPoint = 0,
+ .lifetime = OperandLifeTime::MODEL_INPUT,
+ .location = {.poolIndex = 0, .offset = 0, .length = 0},
+ },
+ {
+ .type = OperandType::TENSOR_FLOAT32,
+ .dimensions = {1, 2, 2, 1},
+ .numberOfConsumers = 1,
+ .scale = 0.0f,
+ .zeroPoint = 0,
+ .lifetime = OperandLifeTime::CONSTANT_COPY,
+ .location = {.poolIndex = 0, .offset = 0, .length = 16},
+ },
+ {
+ .type = OperandType::TENSOR_FLOAT32,
+ .dimensions = {1},
+ .numberOfConsumers = 1,
+ .scale = 0.0f,
+ .zeroPoint = 0,
+ .lifetime = OperandLifeTime::CONSTANT_COPY,
+ .location = {.poolIndex = 0, .offset = 16, .length = 4},
+ },
+ {
+ .type = OperandType::INT32,
+ .dimensions = {},
+ .numberOfConsumers = 4,
+ .scale = 0.0f,
+ .zeroPoint = 0,
+ .lifetime = OperandLifeTime::CONSTANT_COPY,
+ .location = {.poolIndex = 0, .offset = 20, .length = 4},
+ },
+ {
+ .type = OperandType::INT32,
+ .dimensions = {},
+ .numberOfConsumers = 2,
+ .scale = 0.0f,
+ .zeroPoint = 0,
+ .lifetime = OperandLifeTime::CONSTANT_COPY,
+ .location = {.poolIndex = 0, .offset = 24, .length = 4},
+ },
+ {
+ .type = OperandType::INT32,
+ .dimensions = {},
+ .numberOfConsumers = 1,
+ .scale = 0.0f,
+ .zeroPoint = 0,
+ .lifetime = OperandLifeTime::CONSTANT_COPY,
+ .location = {.poolIndex = 0, .offset = 28, .length = 4},
+ },
+ {
+ .type = OperandType::TENSOR_FLOAT32,
+ .dimensions = {1, 2, 2, 1},
+ .numberOfConsumers = 0,
+ .scale = 0.0f,
+ .zeroPoint = 0,
+ .lifetime = OperandLifeTime::MODEL_OUTPUT,
+ .location = {.poolIndex = 0, .offset = 0, .length = 0},
+ }
+ };
+
+ const std::vector<Operation> operations = {
+ {
+ .type = OperationType::CONV_2D,
+ .inputs = {0, 1, 2, 3, 3, 3, 3, 4, 4, 5},
+ .outputs = {6},
+ }
+ };
+
+ const std::vector<uint32_t> inputIndexes = {0};
+ const std::vector<uint32_t> outputIndexes = {6};
+ std::vector<uint8_t> operandValues = {
+ 0, 0, 128, 62, 0, 0, 128, 62, 0, 0, 128, 62, 0, 0, 128, 62, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0
+ };
+ const std::vector<hidl_memory> pools = {};
+
+ return {
+ .operands = operands,
+ .operations = operations,
+ .inputIndexes = inputIndexes,
+ .outputIndexes = outputIndexes,
+ .operandValues = operandValues,
+ .pools = pools,
+ .relaxComputationFloat32toFloat16 = true,
+ };
+}
+
+bool is_ignored(int i) {
+ static std::set<int> ignore = {};
+ return ignore.find(i) != ignore.end();
+}
+
+std::vector<MixedTypedExample> examples = {
+// Begin of an example
+{
+//Input(s)
+{ // See tools/test_generator/include/TestHarness.h:MixedTyped
+ // int -> FLOAT32 map
+ {{0, {1.0f, 1.0f, 1.0f, 1.0f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f}}},
+ // int -> INT32 map
+ {},
+ // int -> QUANT8_ASYMM map
+ {}
+},
+//Output(s)
+{ // See tools/test_generator/include/TestHarness.h:MixedTyped
+ // int -> FLOAT32 map
+ {{0, {0.875f, 0.875f, 0.875f, 0.875f}}},
+ // int -> INT32 map
+ {},
+ // int -> QUANT8_ASYMM map
+ {}
+}
+}, // End of an example
+};
+
+TEST_F(NeuralnetworksHidlTest, conv_quant8) {
+ generated_tests::Execute(device,
+ conv_quant8::createTestModel,
+ conv_quant8::is_ignored,
+ conv_quant8::examples);
+}
+