ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci::CircleIfGraphBuilder Class Reference

#include <CircleIf.h>

Collaboration diagram for luci::CircleIfGraphBuilder:

Public Member Functions

bool validate (const ValidateArgs &args) const final
 
- Public Member Functions inherited from luci::GraphBuilderMultiOutput
virtual ~GraphBuilderMultiOutput ()=default
 
CircleNodebuild (const circle::OperatorT &op, GraphBuilderContext *context) const final
 
- Public Member Functions inherited from luci::GraphBuilderBase
virtual ~GraphBuilderBase ()=default
 

Detailed Description

Definition at line 25 of file CircleIf.h.

Member Function Documentation

◆ validate()

bool luci::CircleIfGraphBuilder::validate ( const ValidateArgs args) const
finalvirtual

Implements luci::GraphBuilderBase.

Definition at line 28 of file CircleIf.cpp.

29{
30 const auto &inputs = args.op.inputs;
31 const auto *options = args.op.builtin_options.AsIfOptions();
32
33 if (inputs.size() < 2) // cond + input
34 return false;
35 if (args.op.outputs.size() < 1) // output
36 return false;
37
38 auto num_graphs = static_cast<int32_t>(args.reader.num_subgraph());
39 if (options->then_subgraph_index >= num_graphs)
40 return false;
41 if (options->else_subgraph_index >= num_graphs)
42 return false;
43
44 // input 0 should be BOOL type
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)
49 return false;
50
51 const auto shape = wrap(tensor->shape());
52 if (shape.size() != 1 && shape.size() != 0)
53 return false;
54
55 return true;
56}
args
Definition infer.py:21
VectorWrapper< T > wrap(const flatbuffers::Vector< T > *vec)

References luci::wrap().


The documentation for this class was generated from the following files: