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

Function TEST_F

tests/test_expanded_tensor_ops.cpp:33–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31// ===== Stack dim=2 correctness (the root cause bug) =====
32
33TEST_F(ExpandedTensorOpsTest, StackDim2_Correctness) {
34 const size_t H = 4, W = 3;
35 auto r = Tensor::full({H, W}, 0.25f, Device::CUDA);
36 auto g = Tensor::full({H, W}, 0.50f, Device::CUDA);
37 auto b = Tensor::full({H, W}, 0.75f, Device::CUDA);
38
39 auto stacked = Tensor::stack({r, g, b}, 2);
40 assert_cuda_ok("stack dim=2");
41
42 ASSERT_EQ(stacked.size(0), static_cast<int>(H));
43 ASSERT_EQ(stacked.size(1), static_cast<int>(W));
44 ASSERT_EQ(stacked.size(2), 3);
45
46 auto cpu = stacked.cpu();
47 auto* p = cpu.ptr<float>();
48 for (size_t row = 0; row < H; ++row) {
49 for (size_t col = 0; col < W; ++col) {
50 size_t base = (row * W + col) * 3;
51 EXPECT_FLOAT_EQ(p[base + 0], 0.25f)
52 << "R at [" << row << "," << col << "]";
53 EXPECT_FLOAT_EQ(p[base + 1], 0.50f)
54 << "G at [" << row << "," << col << "]";
55 EXPECT_FLOAT_EQ(p[base + 2], 0.75f)
56 << "B at [" << row << "," << col << "]";
57 }
58 }
59}
60
61TEST_F(ExpandedTensorOpsTest, StackDim2_256x256) {
62 auto r = Tensor::full({256, 256}, 0.1f, Device::CUDA);

Callers

nothing calls this directly

Calls 12

fullFunction · 0.85
assert_cuda_okFunction · 0.85
ndimMethod · 0.80
sinMethod · 0.80
emptyFunction · 0.50
sizeMethod · 0.45
cpuMethod · 0.45
expandMethod · 0.45
reshapeMethod · 0.45
sliceMethod · 0.45
toMethod · 0.45
clampMethod · 0.45

Tested by

no test coverage detected