| 215 | } |
| 216 | |
| 217 | void 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 | |
| 241 | void ConvertIntTensorConst(const Model& model, const string& name, |
| 242 | GraphDef* tensorflow_graph) { |
no test coverage detected