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

Function ConvertBoolTensorConst

tensorflow/lite/toco/export_tensorflow.cc:217–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217void ConvertBoolTensorConst(const Model& model, const string& name,
218 GraphDef* tensorflow_graph) {
219 if (HasAlreadyExportedConst(name, *tensorflow_graph)) {
220 return;
221 }
222 CHECK(model.HasArray(name));
223 const auto& array = model.GetArray(name);
224 tensorflow::NodeDef* const_op = tensorflow_graph->add_node();
225 const_op->set_op("Const");
226 const_op->set_name(name);
227 (*const_op->mutable_attr())["dtype"].set_type(DT_BOOL);
228 auto* tensor = (*const_op->mutable_attr())["value"].mutable_tensor();
229 tensor->set_dtype(DT_BOOL);
230 const auto& data = array.GetBuffer<ArrayDataType::kBool>().data;
231 for (auto index : data) {
232 tensor->add_bool_val(index);
233 }
234 const auto& array_shape = array.shape();
235 auto* shape = tensor->mutable_tensor_shape();
236 for (int i = 0; i < array_shape.dimensions_count(); i++) {
237 shape->add_dim()->set_size(array_shape.dims(i));
238 }
239}
240
241void ConvertIntTensorConst(const Model& model, const string& name,
242 GraphDef* tensorflow_graph) {

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