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

Function ConvertGatherOperator

tensorflow/lite/toco/export_tensorflow.cc:1223–1250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1221}
1222
1223void ConvertGatherOperator(const Model& model, const GatherOperator& src_op,
1224 GraphDef* tensorflow_graph) {
1225 tensorflow::NodeDef* gather_op = tensorflow_graph->add_node();
1226 gather_op->set_op("GatherV2");
1227 gather_op->set_name(src_op.outputs[0]);
1228 *gather_op->add_input() = src_op.inputs[0];
1229 *gather_op->add_input() = src_op.inputs[1];
1230
1231 if (!src_op.axis) {
1232 // Dynamic axis.
1233 CHECK_EQ(src_op.inputs.size(), 3);
1234 *gather_op->add_input() = src_op.inputs[2];
1235 } else {
1236 // Constant axis.
1237 CHECK_EQ(src_op.inputs.size(), 2);
1238 const string gather_axis =
1239 AvailableArrayName(model, gather_op->name() + "/axis");
1240 CreateIntTensorConst(gather_axis, {src_op.axis.value()}, {},
1241 tensorflow_graph);
1242 *gather_op->add_input() = gather_axis;
1243 }
1244
1245 (*gather_op->mutable_attr())["Tindices"].set_type(DT_INT32);
1246 (*gather_op->mutable_attr())["Taxis"].set_type(DT_INT32);
1247 const tensorflow::DataType params_type =
1248 GetTensorFlowDataType(model, src_op.inputs[0]);
1249 (*gather_op->mutable_attr())["Tparams"].set_type(params_type);
1250}
1251
1252void ConvertArgMaxOperator(const Model& model, const ArgMaxOperator& src_op,
1253 GraphDef* tensorflow_graph) {

Callers 1

ConvertOperatorFunction · 0.70

Calls 9

AvailableArrayNameFunction · 0.85
CreateIntTensorConstFunction · 0.85
set_opMethod · 0.80
GetTensorFlowDataTypeFunction · 0.70
nameMethod · 0.65
set_nameMethod · 0.45
add_inputMethod · 0.45
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected