mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Templatize Tensor.data_ptr() (#24847)
Summary: This PR templatizes `Tensor.data_ptr()`, to prepare for the deprecation of `Tensor.data<T>()` and introduction of `Tensor.data()` that has the same semantics as `Variable.data()`. Pull Request resolved: https://github.com/pytorch/pytorch/pull/24847 Differential Revision: D16906061 Pulled By: yf225 fbshipit-source-id: 8f9db9fd105b146598a9d759aa4b4332011da8ea
This commit is contained in:
committed by
Facebook Github Bot
parent
bf978e7890
commit
eb7b39e02f
@ -304,3 +304,10 @@ TEST(TensorTest, Item_CUDA) {
|
||||
ASSERT_EQ(scalar.to<int>(), 123);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(TensorTest, DataPtr) {
|
||||
auto tensor = at::empty({3, 4}, at::kFloat);
|
||||
auto tensor_not_copy = tensor.to(tensor.options());
|
||||
ASSERT_EQ(tensor_not_copy.data_ptr<float>(), tensor.data_ptr<float>());
|
||||
ASSERT_EQ(tensor_not_copy.data_ptr(), tensor.data_ptr());
|
||||
}
|
||||
|
Reference in New Issue
Block a user