pytorch
11172c19 - codemod at::ArrayRef and torch::IntArrayRef to std::vector in C++ API tests (#27884)

Commit
5 years ago
codemod at::ArrayRef and torch::IntArrayRef to std::vector in C++ API tests (#27884) Summary: `at::ArrayRef` / `torch::IntArrayRef` should be discouraged in user code, because users might not be aware of the fact that it doesn't own the underlying data, which already leads to memory access bugs when they try to write the following: ```cpp auto expected_sizes = torch::IntArrayRef({2, 16, 6}); // The memory that represents `{2, 16, 6}` is released after this line ASSERT_EQ(output.sizes(), expected_sizes); // `expected_sizes` is pointing to invalid memory region ``` This PR changes all usage of `at::ArrayRef` and `torch::IntArrayRef` to the corresponding `std::vector` version, so that users won't pick up the habit of using `ArrayRef` by looking at the test code. Pull Request resolved: https://github.com/pytorch/pytorch/pull/27884 Differential Revision: D17921646 Pulled By: yf225 fbshipit-source-id: 461e79fc22b598aac230d36cc028085ce6cbe937
Author
Will Feng
Parents
Loading