MCPcopy Create free account
hub / github.com/3DAnimals/3DAnimals / frostbite_fwd

Function frostbite_fwd

model/render/renderutils/c_src/torch_bindings.cpp:295–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293// frostbite diffuse
294
295torch::Tensor frostbite_fwd(torch::Tensor nrm, torch::Tensor wi, torch::Tensor wo, torch::Tensor linearRoughness, bool fp16)
296{
297 CHECK_TENSOR(nrm, 4, 3);
298 CHECK_TENSOR(wi, 4, 3);
299 CHECK_TENSOR(wo, 4, 3);
300 CHECK_TENSOR(linearRoughness, 4, 1);
301
302 cudaStream_t stream = at::cuda::getCurrentCUDAStream();
303
304 // Extract input parameters.
305 FrostbiteDiffuseKernelParams p;
306 p.out.fp16 = fp16;
307 update_grid(p.gridSize, nrm, wi, wo, linearRoughness);
308
309 // Allocate output tensors.
310 torch::TensorOptions opts = torch::TensorOptions().dtype(p.out.fp16 ? torch::kBFloat16 : torch::kFloat32).device(torch::kCUDA);
311 torch::Tensor out = torch::empty({ p.gridSize.z, p.gridSize.y, p.gridSize.x, 1 }, opts);
312
313 // Choose launch parameters.
314 dim3 blockSize = getLaunchBlockSize(BLOCK_X, BLOCK_Y, p.gridSize);
315 dim3 gridSize = getLaunchGridSize(blockSize, p.gridSize);
316
317 p.nrm = make_cuda_tensor(nrm, p.gridSize);
318 p.wi = make_cuda_tensor(wi, p.gridSize);
319 p.wo = make_cuda_tensor(wo, p.gridSize);
320 p.linearRoughness = make_cuda_tensor(linearRoughness, p.gridSize);
321 p.out = make_cuda_tensor(out, p.gridSize);
322
323 // Launch CUDA kernel.
324 void* args[] = { &p };
325 NVDR_CHECK_CUDA_ERROR(cudaLaunchKernel((const void*)FrostbiteDiffuseFwdKernel, gridSize, blockSize, args, 0, stream));
326
327 return out;
328}
329
330std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor> frostbite_bwd(torch::Tensor nrm, torch::Tensor wi, torch::Tensor wo, torch::Tensor linearRoughness, torch::Tensor grad)
331{

Callers

nothing calls this directly

Calls 4

update_gridFunction · 0.85
getLaunchBlockSizeFunction · 0.85
getLaunchGridSizeFunction · 0.85
make_cuda_tensorFunction · 0.85

Tested by

no test coverage detected