MCPcopy Create free account
hub / github.com/NVIDIA/MinkowskiEngine / test_maxpool

Method test_maxpool

tests/python/tensor_field.py:71–96  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

69 )
70
71 def test_maxpool(self):
72 coords = torch.IntTensor(
73 [[0, 1], [0, 1], [0, 2], [0, 2], [1, 0], [1, 0], [1, 1]]
74 )
75 feats = torch.FloatTensor([[0, 1, 2, 3, 5, 6, 7]]).T
76 sfield = TensorField(feats, coords)
77
78 # Convert to a sparse tensor
79 stensor = sfield.sparse(quantization_mode=SparseTensorQuantizationMode.MAX_POOL)
80 print(stensor)
81 self.assertTrue(
82 {1, 3, 6, 7} == {a for a in stensor.F.squeeze().detach().numpy()}
83 )
84
85 # device cuda
86 if not torch.cuda.is_available():
87 return
88
89 sfield = TensorField(feats, coords, device="cuda")
90
91 # Convert to a sparse tensor
92 stensor = sfield.sparse(quantization_mode=SparseTensorQuantizationMode.MAX_POOL)
93 print(stensor)
94 self.assertTrue(
95 {1, 3, 6, 7} == {a for a in stensor.F.squeeze().detach().cpu().numpy()}
96 )
97
98 def test_pcd(self):
99 coords, colors, pcd = load_file("1.ply")

Callers

nothing calls this directly

Calls 3

sparseMethod · 0.95
TensorFieldClass · 0.90
detachMethod · 0.80

Tested by

no test coverage detected