2 # Copyright (C) 2018 The Android Open Source Project
3 # Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # refer to tanh_v1_dynamic.mod.py about the structore
20 # This adds reshape as the first op in a model and
21 # returns output of reshape, which is dynamic tensor
24 Testing Neg op when the input is dynamic.
25 input [1, 2, 3] shape [3] (value of shape will be [1, 2, 3])
29 Reshape (added by DynamicInputGenerator since it generates its output to be dynamic)
31 | dynamic tensor at compilation time but the shape will be [1, 2, 3] at execution time
35 output (dynamic tensor, [1, 2, 3] at execution time)
42 model_input_shape = [1, 2, 3]
44 dynamic_layer = dynamic_tensor.DynamicInputGenerator(model, model_input_shape, "TENSOR_FLOAT32")
46 test_node_input = dynamic_layer.getTestNodeInput()
48 # write Neg test. input is `test_input`
50 # note output shape is used by expected output's shape
51 model_output = Output("output", "TENSOR_FLOAT32", "{1, 2, 3}")
53 model.Operation("NEG", test_node_input).To(model_output)
55 model_input_data = [-10, 1, 0.5, -1, 30, 20]
56 model_output_data = [10, -1, -0.5, 1, -30, -20]
59 # use these two as input
60 dynamic_layer.getModelInput(): model_input_data,
61 dynamic_layer.getShapeInput() : model_input_shape,
63 model_output: model_output_data,