30 const auto &inputs = args.op.inputs;
31 const auto *options = args.op.builtin_options.AsIfOptions();
33 if (inputs.size() < 2)
35 if (args.op.outputs.size() < 1)
38 auto num_graphs =
static_cast<int32_t
>(args.reader.num_subgraph());
39 if (options->then_subgraph_index >= num_graphs)
41 if (options->else_subgraph_index >= num_graphs)
45 const auto tensors = args.reader.tensors();
46 const auto tensor = tensors.at(inputs.at(0));
47 assert(tensor !=
nullptr);
48 if (tensor->type() != circle::TensorType_BOOL)
51 const auto shape =
wrap(tensor->shape());
52 if (shape.size() != 1 && shape.size() != 0)
74CircleNode *CircleIfGraphBuilder::build_node(
const BuildNodeArgs &bna)
const
76 uint32_t input_count = bna.op.inputs.size() - 1;
77 uint32_t output_count = bna.op.outputs.size();
81 node->
cond(bna.input_nodes[0]);
82 for (uint32_t idx = 0; idx < input_count; ++idx)
84 node->input(idx, bna.input_nodes[idx + 1]);
87 const auto *options = bna.op.builtin_options.AsIfOptions();
88 node->then_branch(options->then_subgraph_index);
89 node->else_branch(options->else_subgraph_index);
94CircleNode *CircleIfGraphBuilder::build_out(
const BuildOutArgs &boa)
const
96 auto *nodeout = boa.node->graph()->nodes()->create<CircleIfOut>();
98 nodeout->input(boa.node);
99 nodeout->index(boa.index);
NodeContext * nodes(void)
Derived * create(Args &&...args)
bool validate(const ValidateArgs &args) const final
VectorWrapper< T > wrap(const flatbuffers::Vector< T > *vec)