| 1011 | } |
| 1012 | |
| 1013 | void Tensor::AsProtoTensorContent(TensorProto* proto) const { |
| 1014 | proto->Clear(); |
| 1015 | proto->set_dtype(dtype()); |
| 1016 | shape_.AsProto(proto->mutable_tensor_shape()); |
| 1017 | if (buf_) { |
| 1018 | CASES(dtype(), Helper<T>::Encode(buf_, shape_.num_elements(), |
| 1019 | proto->mutable_tensor_content())); |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | size_t Tensor::TotalBytes() const { |
| 1024 | if (shape_.num_elements() == 0) return 0; |