2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "ValidateHelpers.h"
22 bool validate_batch_space_nd(const GraphBuilderBase::ValidateArgs &args)
24 const auto &inputs = args.op.inputs;
25 if (inputs.size() != 3)
28 // input 1 and 2 should have INT32/INT64 type
29 const auto &tensors = args.reader.tensors();
30 const auto &tensor_1 = tensors.at(inputs.at(1));
31 switch (tensor_1->type)
33 case circle::TensorType_INT32:
34 case circle::TensorType_INT64:
39 const auto &tensor_2 = tensors.at(inputs.at(2));
40 switch (tensor_2->type)
42 case circle::TensorType_INT32:
43 case circle::TensorType_INT64:
49 // Only support input shape dimension 3 and 4 only
50 const auto &tensor_0 = tensors.at(inputs.at(0));
51 const auto t_0_s = tensor_0->shape.size();
52 if (t_0_s != 3 && t_0_s != 4)
55 // TODO check input shape
60 bool validate_minmax(const GraphBuilderBase::ValidateArgs &args)
62 const auto &inputs = args.op.inputs;
63 const auto &outputs = args.op.outputs;
65 if (inputs.size() != 2)
68 if (outputs.size() != 1)
71 const auto &tensors = args.reader.tensors();
72 const auto &tensor = tensors.at(inputs.at(0));
76 case circle::TensorType_FLOAT16:
77 case circle::TensorType_FLOAT32:
78 case circle::TensorType_FLOAT64:
79 case circle::TensorType_INT32:
80 case circle::TensorType_INT64:
86 if (tensors[inputs.at(1)]->type != tensor->type)
89 if (tensors[outputs[0]]->type != tensor->type)
95 bool validate_reduce_minmax(const GraphBuilderBase::ValidateArgs &args)
97 const auto &inputs = args.op.inputs;
98 const auto &outputs = args.op.outputs;
100 if (inputs.size() != 2)
103 if (outputs.size() != 1)
106 const auto &tensors = args.reader.tensors();
107 const auto &tensor_axis = tensors.at(inputs.at(1));
109 switch (tensor_axis->type)
111 case circle::TensorType_INT32:
112 case circle::TensorType_INT64: