mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
C++ API parity: at::Tensor::data
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/26008 Test Plan: Imported from OSS Differential Revision: D17343488 Pulled By: pbelevich fbshipit-source-id: b9ba5e26cad621a428a14292446d7fb5a6e5535d
This commit is contained in:
committed by
Facebook Github Bot
parent
5e2d25af34
commit
33221b19ac
@ -311,3 +311,11 @@ TEST(TensorTest, DataPtr) {
|
||||
ASSERT_EQ(tensor_not_copy.data_ptr<float>(), tensor.data_ptr<float>());
|
||||
ASSERT_EQ(tensor_not_copy.data_ptr(), tensor.data_ptr());
|
||||
}
|
||||
|
||||
TEST(TensorTest, Data) {
|
||||
const auto tensor = torch::empty({3, 3});
|
||||
ASSERT_TRUE(torch::equal(tensor, tensor.data()));
|
||||
|
||||
const auto tensor2 = at::empty({3, 3});
|
||||
ASSERT_THROW(tensor2.data(), c10::Error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user