| 52 | } |
| 53 | |
| 54 | Status ResourceHandle::FromProto(const ResourceHandleProto& proto) { |
| 55 | set_device(proto.device()); |
| 56 | set_container(proto.container()); |
| 57 | set_name(proto.name()); |
| 58 | set_hash_code(proto.hash_code()); |
| 59 | set_maybe_type_name(proto.maybe_type_name()); |
| 60 | std::vector<DtypeAndPartialTensorShape> dtypes_and_shapes; |
| 61 | for (const auto& dtype_and_shape : proto.dtypes_and_shapes()) { |
| 62 | DataType dtype = dtype_and_shape.dtype(); |
| 63 | PartialTensorShape shape; |
| 64 | Status s = PartialTensorShape::BuildPartialTensorShape( |
| 65 | dtype_and_shape.shape(), &shape); |
| 66 | if (!s.ok()) { |
| 67 | return s; |
| 68 | } |
| 69 | dtypes_and_shapes.push_back(DtypeAndPartialTensorShape{dtype, shape}); |
| 70 | } |
| 71 | dtypes_and_shapes_ = std::move(dtypes_and_shapes); |
| 72 | return Status::OK(); |
| 73 | } |
| 74 | |
| 75 | string ResourceHandle::SerializeAsString() const { |
| 76 | ResourceHandleProto proto; |
no test coverage detected