MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / TEST_F

Function TEST_F

tests/test_tensor_basic.cpp:74–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72// ============= Tensor Creation Tests =============
73
74TEST_F(TensorBasicTest, EmptyTensorCreation) {
75 // Create empty tensors
76 auto tensor_custom = Tensor::empty({2, 3, 4}, Device::CUDA);
77 auto tensor_torch = torch::empty({2, 3, 4},
78 torch::TensorOptions().dtype(torch::kFloat32).device(torch::kCUDA));
79
80 // Check properties match PyTorch
81 EXPECT_EQ(tensor_custom.shape().rank(), tensor_torch.dim());
82 EXPECT_EQ(tensor_custom.shape()[0], tensor_torch.size(0));
83 EXPECT_EQ(tensor_custom.shape()[1], tensor_torch.size(1));
84 EXPECT_EQ(tensor_custom.shape()[2], tensor_torch.size(2));
85 EXPECT_EQ(tensor_custom.numel(), tensor_torch.numel());
86 EXPECT_TRUE(tensor_custom.is_valid());
87 EXPECT_FALSE(tensor_custom.is_empty());
88
89 // Both should be contiguous
90 EXPECT_TRUE(tensor_custom.is_contiguous());
91 EXPECT_TRUE(tensor_torch.is_contiguous());
92}
93
94TEST_F(TensorBasicTest, ZerosTensorCreation) {
95 // Create zeros tensors

Callers

nothing calls this directly

Calls 15

TensorOptionsClass · 0.85
fullFunction · 0.85
from_vectorFunction · 0.85
from_blobFunction · 0.85
moveFunction · 0.85
allcloseFunction · 0.85
dtype_sizeFunction · 0.85
shapeMethod · 0.80
numelMethod · 0.80
is_emptyMethod · 0.80
is_contiguousMethod · 0.80
is_cudaMethod · 0.80

Tested by

no test coverage detected