ONE - On-device Neural Engine
Loading...
Searching...
No Matches
moco::ModelSignature Struct Reference

Class to store information to run a model. Normally this info comes from users via CLI params or configuration file. More...

#include <ModelSignature.h>

Public Member Functions

void add_input (const TensorName &input)
 
void add_input (const TensorName &&input)
 
void add_output (const TensorName &output)
 
void add_output (const TensorName &&output)
 
const std::vector< TensorName > & inputs () const
 
const std::vector< TensorName > & outputs () const
 
void add_customop (const std::string &op)
 Adds customop op type (not name of node) provided from user.
 
const std::vector< std::string > & customops () const
 
void shape (const std::string &node_name, const angkor::TensorShape &shape)
 Adds node name and its shape provided from user.
 
const angkor::TensorShapeshape (const std::string &node_name) const
 
void dtype (const std::string &node_name, loco::DataType dtype)
 Adds node name and its dtype provided from user.
 
loco::DataType dtype (const std::string &node_name) const
 

Detailed Description

Class to store information to run a model. Normally this info comes from users via CLI params or configuration file.

Definition at line 35 of file ModelSignature.h.

Member Function Documentation

◆ add_customop()

void moco::ModelSignature::add_customop ( const std::string &  op)

Adds customop op type (not name of node) provided from user.

Definition at line 24 of file ModelSignature.cpp.

25{
26 if (std::find(_customops.begin(), _customops.end(), op) == _customops.end())
27 _customops.emplace_back(op);
28 else
29 throw oops::UserExn("Duplicate custom operator", op);
30}
Exception to user.
Definition UserExn.h:42

◆ add_input() [1/2]

void moco::ModelSignature::add_input ( const TensorName &&  input)
inline

Definition at line 39 of file ModelSignature.h.

39{ _inputs.push_back(input); }

◆ add_input() [2/2]

void moco::ModelSignature::add_input ( const TensorName input)
inline

Definition at line 38 of file ModelSignature.h.

38{ _inputs.push_back(input); }

Referenced by nnkit::support::moco::tf::Backend::Backend(), and main().

◆ add_output() [1/2]

void moco::ModelSignature::add_output ( const TensorName &&  output)
inline

Definition at line 41 of file ModelSignature.h.

41{ _outputs.push_back(output); }

◆ add_output() [2/2]

void moco::ModelSignature::add_output ( const TensorName output)
inline

Definition at line 40 of file ModelSignature.h.

40{ _outputs.push_back(output); }

Referenced by nnkit::support::moco::tf::Backend::Backend(), and main().

◆ customops()

const std::vector< std::string > & moco::ModelSignature::customops ( ) const
inline

Definition at line 50 of file ModelSignature.h.

50{ return _customops; }

◆ dtype() [1/2]

loco::DataType moco::ModelSignature::dtype ( const std::string &  node_name) const

Definition at line 57 of file ModelSignature.cpp.

58{
59 auto res = _dtypes.find(node_name);
60 if (res == _dtypes.end())
61 return loco::DataType::Unknown;
62 else
63 return res->second;
64}

◆ dtype() [2/2]

void moco::ModelSignature::dtype ( const std::string &  node_name,
loco::DataType  dtype 
)

Adds node name and its dtype provided from user.

Definition at line 49 of file ModelSignature.cpp.

50{
51 if (_dtypes.find(node_name) != _dtypes.end())
52 throw oops::UserExn("Duplicate node name", node_name);
53
54 _dtypes[node_name] = dtype;
55}
void dtype(const std::string &node_name, loco::DataType dtype)
Adds node name and its dtype provided from user.

References dtype().

Referenced by moco::tf::COpCallGraphBuilder::build(), and dtype().

◆ inputs()

const std::vector< TensorName > & moco::ModelSignature::inputs ( ) const
inline

Definition at line 43 of file ModelSignature.h.

43{ return _inputs; }

Referenced by validate_onnx2circle.OnnxRunner::feed_random_inputs(), and package.infer.session::set_inputs().

◆ outputs()

const std::vector< TensorName > & moco::ModelSignature::outputs ( ) const
inline

◆ shape() [1/2]

const angkor::TensorShape * moco::ModelSignature::shape ( const std::string &  node_name) const

Definition at line 40 of file ModelSignature.cpp.

41{
42 auto res = _shapes.find(node_name);
43 if (res == _shapes.end())
44 return nullptr;
45 else
46 return &res->second;
47}

Referenced by RandomDataGenerator.RandomDataGenerator::_gen_float32(), RandomDataGenerator.RandomDataGenerator::_gen_int16(), and RandomDataGenerator.RandomDataGenerator::_gen_uint8().

◆ shape() [2/2]

void moco::ModelSignature::shape ( const std::string &  node_name,
const angkor::TensorShape shape 
)

Adds node name and its shape provided from user.

Definition at line 32 of file ModelSignature.cpp.

33{
34 if (_shapes.find(node_name) != _shapes.end())
35 throw oops::UserExn("Duplicate node name", node_name);
36
37 _shapes[node_name] = shape;
38}
void shape(const std::string &node_name, const angkor::TensorShape &shape)
Adds node name and its shape provided from user.

References shape().

Referenced by RandomDataGenerator.RandomDataGenerator::_gen_float32(), RandomDataGenerator.RandomDataGenerator::_gen_int16(), RandomDataGenerator.RandomDataGenerator::_gen_uint8(), nnkit::support::moco::tf::Backend::Backend(), moco::tf::COpCallGraphBuilder::build(), main(), and shape().


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