| 235 | // lambert |
| 236 | |
| 237 | torch::Tensor lambert_fwd(torch::Tensor nrm, torch::Tensor wi, bool fp16) |
| 238 | { |
| 239 | CHECK_TENSOR(nrm, 4, 3); |
| 240 | CHECK_TENSOR(wi, 4, 3); |
| 241 | |
| 242 | cudaStream_t stream = at::cuda::getCurrentCUDAStream(); |
| 243 | |
| 244 | // Extract input parameters. |
| 245 | LambertKernelParams p; |
| 246 | p.out.fp16 = fp16; |
| 247 | update_grid(p.gridSize, nrm, wi); |
| 248 | |
| 249 | // Allocate output tensors. |
| 250 | torch::TensorOptions opts = torch::TensorOptions().dtype(p.out.fp16 ? torch::kBFloat16 : torch::kFloat32).device(torch::kCUDA); |
| 251 | torch::Tensor out = torch::empty({ p.gridSize.z, p.gridSize.y, p.gridSize.x, 1 }, opts); |
| 252 | |
| 253 | // Choose launch parameters. |
| 254 | dim3 blockSize = getLaunchBlockSize(BLOCK_X, BLOCK_Y, p.gridSize); |
| 255 | dim3 gridSize = getLaunchGridSize(blockSize, p.gridSize); |
| 256 | |
| 257 | p.nrm = make_cuda_tensor(nrm, p.gridSize); |
| 258 | p.wi = make_cuda_tensor(wi, p.gridSize); |
| 259 | p.out = make_cuda_tensor(out, p.gridSize); |
| 260 | |
| 261 | // Launch CUDA kernel. |
| 262 | void* args[] = { &p }; |
| 263 | NVDR_CHECK_CUDA_ERROR(cudaLaunchKernel((const void*)LambertFwdKernel, gridSize, blockSize, args, 0, stream)); |
| 264 | |
| 265 | return out; |
| 266 | } |
| 267 | |
| 268 | std::tuple<torch::Tensor, torch::Tensor> lambert_bwd(torch::Tensor nrm, torch::Tensor wi, torch::Tensor grad) |
| 269 | { |
nothing calls this directly
no test coverage detected