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

Function ConvertIntTensorConst

tensorflow/lite/toco/export_tensorflow.cc:241–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241void ConvertIntTensorConst(const Model& model, const string& name,
242 GraphDef* tensorflow_graph) {
243 if (HasAlreadyExportedConst(name, *tensorflow_graph)) {
244 return;
245 }
246 CHECK(model.HasArray(name));
247 const auto& array = model.GetArray(name);
248 tensorflow::NodeDef* const_op = tensorflow_graph->add_node();
249 const_op->set_op("Const");
250 const_op->set_name(name);
251 (*const_op->mutable_attr())["dtype"].set_type(DT_INT32);
252 auto* tensor = (*const_op->mutable_attr())["value"].mutable_tensor();
253 tensor->set_dtype(DT_INT32);
254 const auto& data = array.GetBuffer<ArrayDataType::kInt32>().data;
255 for (auto index : data) {
256 tensor->add_int_val(index);
257 }
258 const auto& array_shape = array.shape();
259 auto* shape = tensor->mutable_tensor_shape();
260 for (int i = 0; i < array_shape.dimensions_count(); i++) {
261 shape->add_dim()->set_size(array_shape.dims(i));
262 }
263}
264
265void CreateIntTensorConst(const string& name, const std::vector<int32>& data,
266 const std::vector<int32>& shape,

Callers 2

ConvertSplitVOperatorFunction · 0.85

Calls 9

HasAlreadyExportedConstFunction · 0.85
HasArrayMethod · 0.80
set_opMethod · 0.80
dimensions_countMethod · 0.80
set_nameMethod · 0.45
set_dtypeMethod · 0.45
shapeMethod · 0.45
set_sizeMethod · 0.45
dimsMethod · 0.45

Tested by

no test coverage detected