mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
[caffe2] Don't copy Tensor dims during deserialization (#79471)
We can just make an IntArrayRef. Differential Revision: [D37124427](https://our.internmc.facebook.com/intern/diff/D37124427/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D37124427/)! Pull Request resolved: https://github.com/pytorch/pytorch/pull/79471 Approved by: https://github.com/ezyang
This commit is contained in:
parent
85144e63a9
commit
80a700bd1b
2 changed files with 3 additions and 8 deletions
|
|
@ -785,13 +785,8 @@ void DeserializeBlob(const BlobProto& blob_proto, Blob* result) {
|
|||
|
||||
// === Local helper functions ===
|
||||
// Get dimensions from Tensor proto
|
||||
std::vector<int64_t> DimsFromTensorProto(const TensorProto& proto) {
|
||||
std::vector<int64_t> dims;
|
||||
dims.reserve(proto.dims().size());
|
||||
for (const int64_t d : proto.dims()) {
|
||||
dims.push_back(d);
|
||||
}
|
||||
return dims;
|
||||
c10::IntArrayRef DimsFromTensorProto(const TensorProto& proto) {
|
||||
return c10::IntArrayRef(proto.dims().data(), proto.dims().size());
|
||||
}
|
||||
|
||||
// Get number of elements from Tensor proto
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ inline std::string SerializeBlobProtoAsString_EnforceCheck(
|
|||
|
||||
int64_t NumelFromTensorProto(const TensorProto& tensor_proto);
|
||||
|
||||
std::vector<int64_t> DimsFromTensorProto(const TensorProto& proto);
|
||||
c10::IntArrayRef DimsFromTensorProto(const TensorProto& proto);
|
||||
|
||||
TypeMeta GetDataType(const TensorProto& tensor_proto);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue