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

Function CreateIntTensorConst

tensorflow/lite/toco/export_tensorflow.cc:265–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265void CreateIntTensorConst(const string& name, const std::vector<int32>& data,
266 const std::vector<int32>& shape,
267 GraphDef* tensorflow_graph) {
268 if (HasAlreadyExportedConst(name, *tensorflow_graph)) {
269 return;
270 }
271 tensorflow::NodeDef* const_op = tensorflow_graph->add_node();
272 const_op->set_op("Const");
273 const_op->set_name(name);
274 (*const_op->mutable_attr())["dtype"].set_type(DT_INT32);
275 auto* tensor = (*const_op->mutable_attr())["value"].mutable_tensor();
276 tensor->set_dtype(DT_INT32);
277 for (auto index : data) {
278 tensor->add_int_val(index);
279 }
280 auto* tensor_shape = tensor->mutable_tensor_shape();
281 int num_elements = 1;
282 for (int size : shape) {
283 tensor_shape->add_dim()->set_size(size);
284 num_elements *= size;
285 }
286 CHECK_EQ(num_elements, data.size());
287}
288
289void ConvertComplex64TensorConst(const Model& model, const string& name,
290 GraphDef* tensorflow_graph) {

Callers 2

ConvertGatherOperatorFunction · 0.85

Calls 6

HasAlreadyExportedConstFunction · 0.85
set_opMethod · 0.80
set_nameMethod · 0.45
set_dtypeMethod · 0.45
set_sizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected