diff options
author | Przemysław Szczepaniak <pszczepaniak@google.com> | 2020-04-29 19:47:05 +0100 |
---|---|---|
committer | Przemysław Szczepaniak <pszczepaniak@google.com> | 2020-04-30 13:25:41 +0100 |
commit | 7264d519af881284e23193d3a6f2ca4186779f48 (patch) | |
tree | 364f3dfd4be6f4c92ad8290c7bd488208eca54dc /nn/runtime/test/specs | |
parent | d62e2398c3497375fdaf2d554aa479d18d30f7b6 (diff) | |
download | ml-7264d519af881284e23193d3a6f2ca4186779f48.tar.gz |
Fix null ptr dereference in squeeze cpu implementation.
Squeeze, when used on a single-value tensor with 1s in
each dimension, will result in zero-sized tensor without dimensions.
This change fixes it, by making its output a tensor of size [1].
Bug: 155238914
Test: squeeze_b155238914.mod.py run on coral.
Change-Id: Ia5bf655c647084d9fa094ae8a2048917a8237b81
Diffstat (limited to 'nn/runtime/test/specs')
-rw-r--r-- | nn/runtime/test/specs/V1_2/squeeze_b155238914.mod.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/nn/runtime/test/specs/V1_2/squeeze_b155238914.mod.py b/nn/runtime/test/specs/V1_2/squeeze_b155238914.mod.py new file mode 100644 index 000000000..70e41c6d3 --- /dev/null +++ b/nn/runtime/test/specs/V1_2/squeeze_b155238914.mod.py @@ -0,0 +1,32 @@ +# +# 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() |