MCPcopy
hub / github.com/junshutang/Make-It-3D / forward

Method forward

raymarching/raymarching.py:144–165  ·  view source on GitHub ↗

packbits, CUDA implementation Pack up the density grid into a bit field to accelerate ray marching. Args: grid: float, [C, H * H * H], assume H % 2 == 0 thresh: float, threshold Returns: bitfield: uint8, [C, H * H * H / 8]

(ctx, grid, thresh, bitfield=None)

Source from the content-addressed store, hash-verified

142 @staticmethod
143 @custom_fwd(cast_inputs=torch.float32)
144 def forward(ctx, grid, thresh, bitfield=None):
145 ''' packbits, CUDA implementation
146 Pack up the density grid into a bit field to accelerate ray marching.
147 Args:
148 grid: float, [C, H * H * H], assume H % 2 == 0
149 thresh: float, threshold
150 Returns:
151 bitfield: uint8, [C, H * H * H / 8]
152 '''
153 if not grid.is_cuda: grid = grid.cuda()
154 grid = grid.contiguous()
155
156 C = grid.shape[0]
157 H3 = grid.shape[1]
158 N = C * H3 // 8
159
160 if bitfield is None:
161 bitfield = torch.empty(N, dtype=torch.uint8, device=grid.device)
162
163 get_backend().packbits(grid, N, thresh, bitfield)
164
165 return bitfield
166
167packbits = _packbits.apply
168

Callers

nothing calls this directly

Calls 2

get_backendFunction · 0.85
cudaMethod · 0.45

Tested by

no test coverage detected