17#include "mio_circle/Helper.h"
35 assert(opcode !=
nullptr);
36 if (opcode->deprecated_builtin_code() == 127)
38 assert(opcode->builtin_code() >= 127);
39 return opcode->builtin_code();
42 assert(opcode->deprecated_builtin_code() != -1);
43 return static_cast<::circle::BuiltinOperator
>(opcode->deprecated_builtin_code());
46bool is_valid(const ::circle::OperatorCode *opcode)
49 const int8_t deprecated_builtin_code = opcode->deprecated_builtin_code();
50 if (deprecated_builtin_code < ::circle::BuiltinOperator_MIN)
53 if (deprecated_builtin_code == -1)
56 const ::circle::BuiltinOperator builtin_code = opcode->builtin_code();
57 if (!(::circle::BuiltinOperator_MIN <= builtin_code &&
58 builtin_code <= ::circle::BuiltinOperator_MAX))
64bool is_custom(const ::circle::OperatorCode *opcode)
67 return (code == ::circle::BuiltinOperator_CUSTOM);
70std::string
opcode_name(const ::circle::OperatorCode *opcode)
76 std::ostringstream oss;
83 if (!opcode->custom_code())
84 return "(invalid custom)";
86 std::string custom_op =
"CUSTOM(";
87 custom_op += opcode->custom_code()->c_str();
93 return ::circle::EnumNameBuiltinOperator(code);
96const char *
tensor_type(const ::circle::Tensor *tensor)
98 return ::circle::EnumNameTensorType(
tensor->type());
101const char *
tensor_name(const ::circle::Tensor *tensor)
103 if (
tensor->name() ==
nullptr || std::string(
tensor->name()->c_str()).empty())
106 return tensor->name()->c_str();
Code * code(const SessionID &sess)
const char * tensor_name(const ::circle::Tensor *tensor)
std::string opcode_name(const ::circle::OperatorCode *opcode)
const char * tensor_type(const ::circle::Tensor *tensor)
bool is_custom(const ::circle::OperatorCode *opcode)
bool is_valid(const ::circle::OperatorCode *opcode)
::circle::BuiltinOperator builtin_code_neutral(const ::circle::OperatorCode *opcode)