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

Method AddTfOp

tensorflow/lite/delegates/flex/test_util.cc:117–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117void FlexModelTest::AddTfOp(TfOpType op, const std::vector<int>& inputs,
118 const std::vector<int>& outputs) {
119 tf_ops_.push_back(next_op_index_);
120 ++next_op_index_;
121
122 auto attr = [](const string& key, const string& value) {
123 return " attr{ key: '" + key + "' value {" + value + "}}";
124 };
125
126 string type_attribute;
127 switch (interpreter_->tensor(inputs[0])->type) {
128 case kTfLiteInt32:
129 type_attribute = attr("T", "type: DT_INT32");
130 break;
131 case kTfLiteFloat32:
132 type_attribute = attr("T", "type: DT_FLOAT");
133 break;
134 case kTfLiteString:
135 type_attribute = attr("T", "type: DT_STRING");
136 break;
137 default:
138 // TODO(b/113613439): Use nodedef string utilities to properly handle all
139 // types.
140 LOG(FATAL) << "Type not supported";
141 break;
142 }
143
144 if (op == kUnpack) {
145 string attributes =
146 type_attribute + attr("num", "i: 2") + attr("axis", "i: 0");
147 AddTfOp("FlexUnpack", "Unpack", attributes, inputs, outputs);
148 } else if (op == kIdentity) {
149 string attributes = type_attribute;
150 AddTfOp("FlexIdentity", "Identity", attributes, inputs, outputs);
151 } else if (op == kAdd) {
152 string attributes = type_attribute;
153 AddTfOp("FlexAdd", "Add", attributes, inputs, outputs);
154 } else if (op == kMul) {
155 string attributes = type_attribute;
156 AddTfOp("FlexMul", "Mul", attributes, inputs, outputs);
157 } else if (op == kNonExistent) {
158 AddTfOp("NonExistentOp", "NonExistentOp", "", inputs, outputs);
159 } else if (op == kIncompatibleNodeDef) {
160 // "Cast" op is created without attributes - making it incompatible.
161 AddTfOp("FlexCast", "Cast", "", inputs, outputs);
162 }
163}
164
165void FlexModelTest::AddTfOp(const char* tflite_name, const string& tf_name,
166 const string& nodedef_str,

Callers

nothing calls this directly

Calls 12

VectorMethod · 0.80
push_backMethod · 0.45
tensorMethod · 0.45
SerializeToStringMethod · 0.45
StringMethod · 0.45
opMethod · 0.45
FinishMethod · 0.45
GetBufferMethod · 0.45
backMethod · 0.45
AddNodeWithParametersMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected