From d517e96dba4d6528382a770d38882e4610e2ff1b Mon Sep 17 00:00:00 2001 From: Lev Proleev Date: Wed, 20 May 2020 21:16:27 +0100 Subject: Add shape check to CAST validation The generated test is added only to CTS since VTS would fail on some 1.2 drivers. Fix: 156284111 Test: NeuralNetworksTest_static Change-Id: I4f3c6cdb9f546501e4ca375d7900431c384d6885 --- .../cast_mismatching_shapes.example.cpp | 53 ++++++++++++++++++++++ .../V1_3_cts_only/cast_mismatching_shapes.mod.py | 25 ++++++++++ 2 files changed, 78 insertions(+) create mode 100644 nn/runtime/test/generated/spec_V1_3_cts_only/cast_mismatching_shapes.example.cpp create mode 100644 nn/runtime/test/specs/V1_3_cts_only/cast_mismatching_shapes.mod.py (limited to 'nn/runtime') 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({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({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_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() -- cgit v1.2.3