33 return circle::ActivationFunctionType_NONE;
35 return circle::ActivationFunctionType_RELU;
37 return circle::ActivationFunctionType_RELU_N1_TO_1;
39 return circle::ActivationFunctionType_RELU6;
41 return circle::ActivationFunctionType_TANH;
43 return circle::ActivationFunctionType_SIGN_BIT;
53 case loco::DataType::U4:
54 return circle::TensorType_UINT4;
55 case loco::DataType::U8:
56 return circle::TensorType_UINT8;
58 case loco::DataType::S4:
59 return circle::TensorType_INT4;
60 case loco::DataType::S8:
61 return circle::TensorType_INT8;
62 case loco::DataType::S16:
63 return circle::TensorType_INT16;
64 case loco::DataType::S32:
65 return circle::TensorType_INT32;
66 case loco::DataType::S64:
67 return circle::TensorType_INT64;
69 case loco::DataType::FLOAT16:
70 return circle::TensorType_FLOAT16;
71 case loco::DataType::FLOAT32:
72 return circle::TensorType_FLOAT32;
74 case loco::DataType::BOOL:
75 return circle::TensorType_BOOL;
77 case loco::DataType::STRING:
78 return circle::TensorType_STRING;
80 case loco::DataType::MXFP4:
81 return circle::TensorType_MXFP4;
82 case loco::DataType::MXINT8:
83 return circle::TensorType_MXINT8;
95 return circle::MirrorPadMode::MirrorPadMode_REFLECT;
97 return circle::MirrorPadMode::MirrorPadMode_SYMMETRIC;
108 return circle::RoPEMode::RoPEMode_GPT_NEOX;
110 return circle::RoPEMode::RoPEMode_GPT_J;
116circle::FullyConnectedOptionsWeightsFormat
122 return circle::FullyConnectedOptionsWeightsFormat_DEFAULT;
124 return circle::FullyConnectedOptionsWeightsFormat_SHUFFLED4x16INT8;
126 return circle::FullyConnectedOptionsWeightsFormat_SHUFFLED16x1FLOAT32;
137 return circle::DimensionType_DENSE;
139 return circle::DimensionType_SPARSE_CSR;
148 auto type = sparse_idx_vec.
type();
155 return circle::CreateInt32VectorDirect(fb, sparse_idx_vec.
as_int32_vector()).Union();
159 return circle::CreateUint16VectorDirect(fb, sparse_idx_vec.
as_uint16_vector()).Union();
163 return circle::CreateUint8VectorDirect(fb, sparse_idx_vec.
as_uint8_vector()).Union();
166 INTERNAL_EXN_V(
"trying to convert unsupported luci::SparseIndexVectorType",
176 return circle::SparseIndexVector_NONE;
178 return circle::SparseIndexVector_Int32Vector;
180 return circle::SparseIndexVector_Uint16Vector;
182 return circle::SparseIndexVector_Uint8Vector;
184 INTERNAL_EXN_V(
"trying to convert unsupported luci::SparseIndexVectorType",
198 return (cast->out_data_type() == loco::DataType::Unknown) ? circle::BuiltinOptions_NONE
199 : circle::BuiltinOptions_CastOptions;
209 return custom_node->custom_code();
220 std::vector<uint8_t> custom_options_vec{custom_node->custom_options().begin(),
221 custom_node->custom_options().end()};
234 const std::string &custom_code,
235 const int32_t op_version)
237 assert(op_version > 0);
254 return circle::Padding_VALID;
263 bool same_padding_criterion_1 =
264 (
static_cast<uint32_t
>(ofm.
_dims[1]) == (ifm.
_dims[1] - 1) / stride->vertical() + 1) &&
265 (
static_cast<uint32_t
>(ofm.
_dims[2]) == (ifm.
_dims[2] - 1) / stride->horizontal() + 1);
268 bool same_padding_criterion_2 =
272 if (same_padding_criterion_1 && same_padding_criterion_2)
273 return circle::Padding_SAME;
281 return circle::Padding_VALID;
283 return circle::Padding_SAME;
310 assert(node->
annot<CircleTensorIndexAnnotation>() ==
nullptr);
311 node->
annot(std::make_unique<CircleTensorIndexAnnotation>(tensor_id));
316 if (node->
annot<CircleTensorIndexAnnotation>() !=
nullptr)
317 node->
annot<CircleTensorIndexAnnotation>(
nullptr);
322 assert(node->
annot<CircleTensorIndexAnnotation>() !=
nullptr);
323 return node->
annot<CircleTensorIndexAnnotation>()->index();
#define INTERNAL_EXN(msg)
@ brief throw internal exception with message
#define INTERNAL_EXN_V(msg, val)
@ brief throw internal exception with message and value
Helper class to hold data needed in creation of a FlatBuffer. To serialize data, you typically call o...
Offset< Vector< T > > CreateVector(const T *v, size_t len)
Serialize an array into a FlatBuffer vector.
const T * annot(void) const
Retrieve a stored annotation of type T.
Logical unit of computation.
uint32_t left(void) const
uint32_t bottom(void) const
uint32_t right(void) const
Stride configuration for N-dimensional spatial operations.
static BuiltinOperatorMappingRule & get()
static BuiltinOptionsMappingRule & get()
const std::vector< uint8_t > * as_uint8_vector(void) const
SparseIndexVectorType type(void) const
const std::vector< uint16_t > * as_uint16_vector(void) const
const std::vector< int32_t > * as_int32_vector(void) const
DataType
"scalar" value type
flatbuffers::Offset< void > to_circle_sparse_index_vector(flatbuffers::FlatBufferBuilder &fb, const SparseIndexVector &sparse_idx_vec)
circle::BuiltinOptions circle_builtin_options(const luci::CircleNode *node)
void set_tensor_index(loco::Node *node, const CircleTensorIndex &tensor_id)
flatbuffers::Offset< flatbuffers::Vector< uint8_t > > circle_custom_options(flatbuffers::FlatBufferBuilder &fb, const luci::CircleNode *node)
circle::Padding getOpPadding(const loco::Padding2D *pad, const loco::Stride< 2 > *stride, const ShapeDescription &ifm, const ShapeDescription &ofm)
circle::DimensionType to_circle_dimensiontype(luci::DimensionType type)
circle::FullyConnectedOptionsWeightsFormat to_circle_weightsformat(luci::CircleFullyConnected::WeightsFormat format)
circle::SparseIndexVector to_circle_sparse_index_vector_type(luci::SparseIndexVectorType type)
circle::RoPEMode to_circle_rope(luci::RoPEMode mode)
circle::ActivationFunctionType to_circle_actfunc(luci::FusedActFunc func)
int32_t CircleTensorIndex
circle::TensorType to_circle_tensortype(loco::DataType type)
void clear_tensor_index(loco::Node *node)
CircleTensorIndex get_tensor_index(loco::Node *node)
circle::BuiltinOperator circle_builtin_operator(const luci::CircleNode *node)
circle::MirrorPadMode to_circle_mirrorpadmode(luci::MirrorPadMode mode)
std::string circle_custom_code(const luci::CircleNode *node)
loco::GraphInputIndex index(const TFPlaceholder *node)
Extensible Node Metadata.
T accept(CircleNodeVisitorBase< T > *) const
std::unordered_map< OpCode, uint32_t > _operator_codes
uint32_t registerBuiltinOpcode(circle::BuiltinOperator builtin_code, const std::string &custom_code, const int32_t op_version)
if opcode is not registered in table of opcodes add it
std::vector< int32_t > _dims