ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleGreater.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
18
20
21#include <luci/UserSettings.h>
22#include <luci/Log.h>
23
24#include <loco.h>
25
26namespace luci
27{
28
30{
31 LOGGER(l);
32
33 if (!GraphBuilder::validate(args, 2))
34 return false;
35
36 auto settings = luci::UserSettings::settings();
37
38 const auto &inputs = args.op.inputs;
39 const auto &outputs = args.op.outputs;
40 const auto tensors = args.reader.tensors();
41
42 assert(tensors[inputs.at(0)] != nullptr && tensors[inputs.at(1)] != nullptr);
43 if (tensors[inputs.at(0)]->type() != tensors[inputs.at(1)]->type())
44 return false;
45
46 // NOTE: real models do have output dtype NOT BOOL
47 assert(tensors[outputs[0]] != nullptr);
48 if (tensors[outputs[0]]->type() != circle::TensorType_BOOL)
49 {
51 {
52 const auto output_tensor = tensors[outputs[0]];
53 auto name = tensor_name(output_tensor);
54 WARN(l) << "Warning: import Greater(" << name << ") output dtype is not boolean";
55 }
56 else
57 return false;
58 }
59
60 return true;
61}
62
63CircleNode *CircleGreaterGraphBuilder::build_node(const circle::OperatorT &,
64 const std::vector<CircleNode *> &inputs,
65 loco::Graph *graph) const
66{
67 auto *node = graph->nodes()->create<CircleGreater>();
68 node->x(inputs.at(0));
69 node->y(inputs.at(1));
70
71 return node;
72}
73
74} // namespace luci
#define LOGGER(name)
Definition Log.h:65
A neural network graph.
Definition Graph.h:161
bool validate(const ValidateArgs &args) const final
Greater in Circle.
loco::Node * x(void) const
bool validate(const ValidateArgs &args, size_t input_cnt) const
#define WARN(name)
Definition Log.h:70
const char * tensor_name(const circle::Tensor *tensor)
static UserSettings * settings()