MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / OperatorKey

Class OperatorKey

tensorflow/lite/toco/tflite/export.h:90–164  ·  view source on GitHub ↗

A key to identify an operator. Only when `type` is `kUnsupported`, `custom_code` is filled to identify which operation is used.

Source from the content-addressed store, hash-verified

88// Only when `type` is `kUnsupported`, `custom_code` is filled to
89// identify which operation is used.
90class OperatorKey {
91 public:
92 OperatorKey() {}
93
94 // Construct OperatorKey by Toco op.
95 OperatorKey(
96 const ::toco::OperatorSignature& op_signature,
97 const std::map<OperatorType, std::unique_ptr<BaseOperator>>& ops_by_type,
98 bool enable_select_tf_ops);
99
100 // Construct OperatorKey by type, custom code and version.
101 // Note that this construct doesn't set the additional information including
102 // `is_custom_op`, `is_flex_op`, `is_unsupported_flex_op`.
103 OperatorKey(::tflite::BuiltinOperator type, const std::string& custom_code,
104 int version)
105 : type_(type), custom_code_(custom_code), version_(version) {}
106
107 // Only `type`, `custom_code` and `version` is used to compute hash and
108 // identity.
109 ::tflite::BuiltinOperator type() const { return type_; }
110 const std::string& custom_code() const { return custom_code_; }
111 int version() const { return version_; }
112
113 // The attributes below are not used to compute hash and identity.
114 //
115 // Return true if the op is a custom op. Note it will return false for Flex
116 // ops.
117 bool is_custom_op() const { return is_custom_op_; }
118 // Return true if the op is a Flex op.
119 bool is_flex_op() const { return is_flex_op_; }
120 // Return true if the op is a Flex op but it's knwon that the op is not
121 // supported by Flex runtime.
122 bool is_unsupported_flex_op() const { return is_unsupported_flex_op_; }
123 // Return the original TensorFlow op name for a Flex op.
124 const std::string& flex_tensorflow_op() const { return flex_tensorflow_op_; }
125
126 bool operator<(const OperatorKey& other) const {
127 if (type_ < other.type_)
128 return true;
129 else if (type_ > other.type_)
130 return false;
131 else if (custom_code_ < other.custom_code_)
132 return true;
133 else if (custom_code_ > other.custom_code_)
134 return false;
135 else
136 return version_ < other.version_;
137 }
138
139 bool operator==(const OperatorKey& other) const {
140 return type_ == other.type_ && custom_code_ == other.custom_code_ &&
141 version_ == other.version_;
142 }
143
144 struct Hash {
145 size_t operator()(const OperatorKey& key) const {
146 return ::tflite::CombineHashes(
147 {std::hash<size_t>()(static_cast<size_t>(key.type())),

Callers 5

LoadOperatorsMapFunction · 0.85
ExportOperatorCodesFunction · 0.85
ExportOperatorsFunction · 0.85
TEST_FFunction · 0.85
TESTFunction · 0.85

Calls

no outgoing calls

Tested by 2

TEST_FFunction · 0.68
TESTFunction · 0.68