| 448 | } |
| 449 | |
| 450 | tensorflow::Status ImportBoolArray(const TensorProto& input_tensor, |
| 451 | Array* output_array) { |
| 452 | CHECK_EQ(input_tensor.dtype(), DT_BOOL); |
| 453 | const auto& input_shape = input_tensor.tensor_shape(); |
| 454 | CHECK_LE(input_shape.dim_size(), 6); |
| 455 | int input_flat_size; |
| 456 | auto status = ImportShape(input_shape.dim(), &input_flat_size, |
| 457 | output_array->mutable_shape()); |
| 458 | if (!status.ok()) return status; |
| 459 | |
| 460 | auto& output_bool_data = |
| 461 | output_array->GetMutableBuffer<ArrayDataType::kBool>().data; |
| 462 | output_bool_data.resize(RequiredBufferSizeForShape(output_array->shape()), |
| 463 | false); |
| 464 | status = |
| 465 | ImportTensorData<bool>(input_tensor, input_flat_size, &output_bool_data); |
| 466 | if (!status.ok() && output_bool_data.size() == 1) { |
| 467 | // Some graphs have bool const nodes without actual value... |
| 468 | // assuming that 'false' is implied. |
| 469 | // So far only encountered that in an array with 1 entry, let's |
| 470 | // require that until we encounter a graph where that's not the case. |
| 471 | output_bool_data[0] = false; |
| 472 | return tensorflow::Status::OK(); |
| 473 | } |
| 474 | return status; |
| 475 | } |
| 476 | |
| 477 | tensorflow::Status ImportStringArray(const TensorProto& input_tensor, |
| 478 | Array* output_array) { |
no test coverage detected