pytorch
84a7ab25 - Optimize constructing tensors from external data (#55705)

Commit
3 years ago
Optimize constructing tensors from external data (#55705) Summary: This PR optimizes the way tensors are constructed from external data. It avoids allocating an empty tensor beforehand and directly constructs the target tensor by passing the newly-initialized `DataPtr`. Running some Facebook-internal benchmarks showed that combined with https://github.com/pytorch/pytorch/issues/54530 this PR achieves performance parity with Caffe2 tensor construction. (Overall ~2x speed improvement over the original `at::from_blob()` implementation.) Testing is done with the existing unit and integration tests as there is no user-observable API change. Pull Request resolved: https://github.com/pytorch/pytorch/pull/55705 Reviewed By: ezyang Differential Revision: D27686043 Pulled By: cbalioglu fbshipit-source-id: b365c614476bcf0567797dfaf2add1b76fb6c272
Author
Parents
Loading