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

#include <CircleUnpack.h>

Collaboration diagram for luci::CircleUnpackGraphBuilder:

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 CircleUnpack.h.

Member Function Documentation

◆ validate()

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

Implements luci::GraphBuilderBase.

Definition at line 31 of file CircleUnpack.cpp.

32{
33 LOGGER(l);
34
35 auto settings = luci::UserSettings::settings();
36
37 const auto &inputs = args.op.inputs;
38 const auto &outputs = args.op.outputs;
39 const auto *options = args.op.builtin_options.AsUnpackOptions();
40
41 if (inputs.size() != 1)
42 return false;
43
44 // NOTE real models may have mismatch
45 if (static_cast<int32_t>(outputs.size()) != options->num)
46 {
48 {
49 const auto tensors = args.reader.tensors();
50 const auto output_tensor = tensors[outputs[0]];
51 auto name = tensor_name(output_tensor);
52 WARN(l) << "Warning: import Unpack(" << name << ") 'num' is not same as outputs used";
53 }
54 else
55 return false;
56 }
57
58 if (options->num < 0)
59 return false;
60
61 const auto tensors = args.reader.tensors();
62 const auto tensor = tensors.at(inputs.at(0));
63 assert(tensor != nullptr);
64 const auto shape = wrap(tensor->shape());
65 auto shape_size = static_cast<int32_t>(shape.size());
66 if (shape_size > 0)
67 {
68 // NOTE for unknown shape, shape_size is 0
69 if (options->axis < -shape_size || options->axis >= shape_size)
70 return false;
71 }
72
73 return true;
74}
#define LOGGER(name)
Definition Log.h:65
#define WARN(name)
Definition Log.h:70
args
Definition infer.py:21
const char * tensor_name(const circle::Tensor *tensor)
VectorWrapper< T > wrap(const flatbuffers::Vector< T > *vec)
static UserSettings * settings()

References luci::UserSettings::DisableValidation, LOGGER, luci::UserSettings::settings(), luci::tensor_name(), WARN, and luci::wrap().


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