MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / TEST

Function TEST

test/cpp/compat/ATen_basic_test.cc:40–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38COMMON_DECLARE_bool(use_stride_kernel);
39
40TEST(TensorBaseTest, DataPtrAPIs) {
41 // Test data_ptr() and const_data_ptr() APIs
42 at::TensorBase tensor = at::ones({2, 3}, at::kFloat);
43
44 // Test void* data_ptr()
45 void* void_ptr = tensor.data_ptr();
46 ASSERT_NE(void_ptr, nullptr);
47
48 // Test typed data_ptr<T>()
49 float* float_ptr = tensor.data_ptr<float>();
50 ASSERT_NE(float_ptr, nullptr);
51 ASSERT_EQ(float_ptr, void_ptr);
52
53 // Test const_data_ptr()
54 const float* const_float_ptr = tensor.const_data_ptr<float>();
55 ASSERT_NE(const_float_ptr, nullptr);
56 ASSERT_EQ(const_float_ptr, float_ptr);
57
58 // Test mutable_data_ptr()
59 void* mutable_ptr = tensor.mutable_data_ptr();
60 ASSERT_NE(mutable_ptr, nullptr);
61 ASSERT_EQ(mutable_ptr, void_ptr);
62}
63TEST(TensorBaseTest, TypeDeviceAPIs) {
64 // Test type and device related APIs
65 at::TensorBase cpu_tensor = at::ones({2, 3}, at::kFloat);

Callers

nothing calls this directly

Calls 15

TensorOptionsFunction · 0.85
empty_cudaFunction · 0.85
elementSizeFunction · 0.85
multiply_integersFunction · 0.85
sum_integersFunction · 0.85
stream_synchronizeFunction · 0.85
mutable_data_ptrMethod · 0.80
is_cudaMethod · 0.80
copy_Method · 0.80
viewMethod · 0.80
permuteMethod · 0.80
as_stridedMethod · 0.80

Tested by

no test coverage detected