diff --git a/CLAUDE.md b/CLAUDE.md index edc5da02..4ab404b2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,5 +2,9 @@ This project's instructions live in [AGENTS.md](AGENTS.md). Read that file. +If you are an agent writing code here, the one section you are most likely to +get wrong is **[Comments](AGENTS.md#comments--write-fewer-and-shorter)**. Read it before +you write your first comment, not after the review. + (A real file rather than a symlink, so Windows checkouts without `core.symlinks` still get usable content.) diff --git a/cmake/SsBackendCuda.cmake b/cmake/SsBackendCuda.cmake index 9a4370b9..9e12ecb8 100644 --- a/cmake/SsBackendCuda.cmake +++ b/cmake/SsBackendCuda.cmake @@ -51,9 +51,15 @@ list(REMOVE_DUPLICATES TORCH_CUDA_ARCH_LIST) message(STATUS "CUDA architecture(s): ${TORCH_CUDA_ARCH_LIST}") +# "-real" emits cubin only; the bare form also emits PTX. See +# SS_CUDA_EMBED_PTX in SsOptions.cmake for why the default drops it. set(CMAKE_CUDA_ARCHITECTURES "") foreach(arch ${TORCH_CUDA_ARCH_LIST}) - list(APPEND CMAKE_CUDA_ARCHITECTURES "${arch}") + if(SS_CUDA_EMBED_PTX) + list(APPEND CMAKE_CUDA_ARCHITECTURES "${arch}") + else() + list(APPEND CMAKE_CUDA_ARCHITECTURES "${arch}-real") + endif() endforeach() # --------------------------------------------------------------------------- @@ -101,10 +107,7 @@ if(SS_DEBUG_SYMBOLS) list(APPEND SPLAT_NVCC_FLAGS "-lineinfo" "--generate-line-info" "--source-in-ptx") endif() -# Add gencode flags -foreach(arch ${TORCH_CUDA_ARCH_LIST}) - list(APPEND SPLAT_NVCC_FLAGS "-gencode" "arch=compute_${arch},code=sm_${arch}") -endforeach() + # Host side optimizations if(NOT WIN32) diff --git a/cmake/SsOptions.cmake b/cmake/SsOptions.cmake index b11f0b50..55dec642 100644 --- a/cmake/SsOptions.cmake +++ b/cmake/SsOptions.cmake @@ -91,6 +91,14 @@ option(SS_SEPARATE_TOOLS "Also build spirula-sfm / spirula-sam standalone" OFF) # in the embedded SPIR-V). Turn on for profiling/debugging builds. option(SS_DEBUG_SYMBOLS "Emit debug symbols / line info (host -g, CUDA cubin lineinfo, SPIR-V -g2)" OFF) +# Embed PTX alongside the cubin in the CUDA fatbin. PTX is only useful for +# JIT onto an architecture the binary was NOT built for, and the CUDA build +# detects the local GPU's compute capability from nvidia-smi, so a dev build +# carries it for nothing -- it is a third of every object file, and the +# per-(camera model, distortion tier) kernel instantiations make that a third +# of a large binary. Turn it on for a redistributable build. +option(SS_CUDA_EMBED_PTX "Embed PTX in the CUDA fatbin for forward-compatible JIT" OFF) + # --------------------------------------------------------------------------- # Compute backend selection # diff --git a/docs/build.md b/docs/build.md index 56ea0f2f..de4427ff 100644 --- a/docs/build.md +++ b/docs/build.md @@ -69,6 +69,7 @@ without reconfiguring, e.g. `-B build_cuda` and `-B build`. | `SS_SEPARATE_TOOLS` | `OFF` | *also* build `spirula-sfm` and `spirula-sam` standalone — same code, but neither links the engine (24 MB vs the combined 61 MB) | | `SS_BUILD_BACKEND_TESTS` | `OFF` | build `backend/tests/*` (CUDA branch; Vulkan always builds them) | | `SS_DEBUG_SYMBOLS` | `OFF` | host `-g`, CUDA cubin lineinfo, `slangc -g2`. Bloats binaries substantially — profiling/debugging only. | +| `SS_CUDA_EMBED_PTX` | `OFF` | embed PTX beside the cubin in the CUDA fatbin. Only buys JIT onto an architecture the binary was not built for, and costs about a third of every object; the build already detects the local GPU. Turn on for a redistributable binary. | | `SS_SLANGC` | *(empty)* | path to a `slangc` to use; empty means find on PATH and fetch the pinned release on miss/mismatch | | `SS_BUILD_SFM` | `ON` for `vulkan`, `OFF` for `cuda` | `ss_sfm` + `spirula sfm` + `sfm_*_test`. Vulkan-only; a CUDA build can opt in if the Vulkan SDK is present. | | `SS_BUILD_SAM` | `ON` for `vulkan`, `OFF` for `cuda` | `ss_nn` + `ss_sam` + `spirula sam` + `nn_ops_test` / `sam_pipeline_test`, and the GUI's in-process masking. Same rule as SfM. | diff --git a/docs/datasets.md b/docs/datasets.md index 77d9fe97..6e23f8ef 100644 --- a/docs/datasets.md +++ b/docs/datasets.md @@ -26,18 +26,97 @@ cameras), and equirectangular/spherical. See `src/core/CameraModel.h` — it is plain C++17 with no CUDA dependency, which is why the WASM viewer can reuse it. -COLMAP writes 18 camera models; `ColmapParser.cpp` knows every id (it has to, -to advance the `cameras.bin` read cursor) but maps only the ones the engine can -project. `EQUIRECTANGULAR` (id 17) is the spherical one: its params are `(w, h)` +COLMAP writes 18 camera models and `ColmapParser.cpp` accepts every one. +`EQUIRECTANGULAR` (id 17) is the spherical one: its params are `(w, h)` rather than a calibration, because the image *is* the calibration. It reaches the same `CameraModelType::EQUIRECTANGULAR` as a Metashape `spherical` sensor, with the same convention — +Z forward at the image centre, azimuth wrapping at the left/right edge — so the two formats describe an identical camera and `bake_post_split` treats them identically. Note the engine's canonical panorama intrinsics assume a 2:1 (360°×180°) image; the parser warns when one is not. -`RAD_TAN_THIN_PRISM_FISHEYE`, `SIMPLE_DIVISION`, `DIVISION`, `EUCM` and `FOV` -are recognised but rejected with a named error — there is no undistortion for -them on the engine side. + +## Lens distortion tiers + +Distortion is a separate axis from the camera model, and a COMPILE-TIME one: +a template argument in CUDA, a `kDistortion` specialization constant on Vulkan. +The four tiers, cheapest first, are `None`, `OpenCV` (`k1 k2 p1 p2`), +`ThinPrism` (`k1 k2 k3 k4 p1 p2 sx1 sy1`, COLMAP's `THIN_PRISM_FISHEYE`) and +`Rational` (`k1..k6 p1 p2`, COLMAP's `FULL_OPENCV`, where `k4..k6` divide). +A slot index does NOT mean the same thing across tiers. `core/CameraModel.h` +is the one definition; `shaders/projection_utils.slang` is the one +implementation, generic over an `ICameraDistortion`. + +The parser picks the CHEAPEST tier that represents the source camera exactly, +so a PINHOLE dataset costs no distortion registers at all and a `FULL_OPENCV` +camera whose `k4..k6` are zero demotes to `ThinPrism` +(`camera_distortion_demote`). Only eleven (model, tier) pairs are compiled — +no COLMAP fisheye model is rational, and EQUIRECTANGULAR carries no distortion. +`camera_distortion_is_compiled()` is that list, and it must stay in step with +`kCameraVariants` in `tools/codegen/generate_kernel_instantiation.py` and the +export list in `shaders/primitive_3dgs.slang`. + +A `transforms.json` is ambiguous about what `k4` means -- OpenCV's first +rational DENOMINATOR term, or Kannala-Brandt's / Metashape's fourth RADIAL one. +An explicit `camera_distortion` key settles it (`MetashapeParser` always writes +one); failing that, a fisheye camera is Kannala-Brandt, `k5`/`k6` mean rational +on their own, and the mere PRESENCE of `b1`/`b2`/`sx1`/`sy1` -- keys a rational +camera never carries -- makes `k4` radial. That last rule is what a +Metashape-converted `transforms.json` needs: reading its `k4` as a denominator +is a different lens, not a small error. + +`FOV`, `SIMPLE_DIVISION`, `DIVISION`, `EUCM` and `RAD_TAN_THIN_PRISM_FISHEYE` +have no exact tier, and neither does a Metashape sensor skew (`b2`), which is +an off-diagonal pixel term where every tier's pixel map is diagonal. They are +fitted onto a (model, `ThinPrism`) pair by near-minimax regression +(`data/DistortionFit.h`). + +`fit_camera_auto` chooses the camera model from the source's MEASURED field of +view, not from its name: a COLMAP `FOV` lens is perspective at omega 0.3 and a +180-degree fisheye at omega 0.87, and forcing the second onto a pinhole target +puts `tan(85 deg) = 11.4` into a degree-8 polynomial and fails. It then walks a +coefficient ladder (all eight, no thin prism, no `k3`/`k4`, ..., none) until the +fitted distortion is invertible everywhere sampled. **It never fails**: a +dataset that took hours to reconstruct must not refuse to load over a lens +model, so the worst case is a plain fisheye and a warning, not an exception. + +A fit closer than `dsfit::kExactFitPx` (0.1 px) is left alone -- the fitted +camera already reproduces the source to better than bilinear resampling can +resolve, so re-distorting would only cost VRAM and blur. In practice that +covers `FOV`, both division models and `EUCM`; `RAD_TAN_THIN_PRISM_FISHEYE` and +a real `b2` do not reach it. When it is not reached, the source model goes into +`ParsedDataset::redistort`, which makes `bake_post_split` set `any_warp` even at +K = 1 so the images route through the warp path's staging and get resampled. + +The resampling reads the TRUE source projection (`shaders/camera_source.slang`, +the one place those models live on device; `data/SourceCamera.h` is the host +mirror, and the two must agree exactly) rather than the fit -- going through the +fit would be a no-op. Source model ids 0..17 are COLMAP's own `CameraModelId` +values with COLMAP's parameter array verbatim; ours start at 1000 so COLMAP can +keep appending to its enum. + +A source model is sampled only where its image still grows outward as the ray +tilts off axis. Past that it has folded -- at the lens border for a polynomial +fisheye, well inside the frame for the division and unified models -- and two +directions share a pixel, so a warped face would be ringed by a mirrored copy +of the image instead of ending at the lens. Those rays are dropped, and the +synthesized FOV mask drops them by the same test. The fit domain stops earlier +still, where the radial rate falls below a quarter of its on-axis value: at the +fold itself no fitted distortion is invertible, so the coefficient ladder would +degrade a camera the tier otherwise reproduces to a fraction of a pixel. + +Two paths, both gathering per destination pixel: + +- **K = 1** (`kernels/pixelwise/ImageRedistort.cu`): destination pixel -> + ray through the fitted camera -> source pixel. The fit leaves the pose alone, + so a destination pixel and its source pixel are the SAME ray: depth (linear or + ray) and camera-frame normals transfer unchanged and only the sampling + coordinate moves. None of GtDepthNormalWarp.cu's point-space handling applies. +- **K > 1** (warp_to_pinhole): the cubemap face ray projects STRAIGHT through + the source camera, so the fitted camera is never materialized and the two + passes cost one kernel and no intermediate image. `RayToPixel` + is the seam; `kFromSource` is a template argument (a specialization constant + on Vulkan) so an ordinary dataset pays neither the branch nor the 16 registers + the source parameters occupy. ## Two-stage parse diff --git a/docs/notes/sfm-design.md b/docs/notes/sfm-design.md index 8204c5f8..171b2c31 100644 --- a/docs/notes/sfm-design.md +++ b/docs/notes/sfm-design.md @@ -48,7 +48,7 @@ be re-derived or re-attempted: D25, D26, D27, D11, D16, D47, D50, D45, D46. | D31 | Geometry core on unit bearings (D29 phase B) | | D32 | Kannala-Brandt fisheye model (COLMAP OPENCV_FISHEYE); per-real atan by Newton | | D33 | Wide-FOV cheirality + physical fisheye focal init (D29 phase D) | -| D34 | THIN_PRISM_FISHEYE + reduced FULL_OPENCV models | +| D34 | THIN_PRISM_FISHEYE + FULL_OPENCV models | | D35 | GPU pair selection instead of exhaustive pairing (or a vocab tree) | | D36 | Mapper robustness: refined+gated registration, iterated refinement with retriangulation, and undo | | D37 | Mapper time: incremental next-image scoring + retuned BA cadence | diff --git a/docs/notes/sfm-port-plan.md b/docs/notes/sfm-port-plan.md index 9b4fbfe8..18e5c769 100644 --- a/docs/notes/sfm-port-plan.md +++ b/docs/notes/sfm-port-plan.md @@ -450,7 +450,7 @@ setup carried in `matches.bin`; BA solver (dense Cholesky, implicit-Schur PCG, `float`/`double`/`df`, Huber/Cauchy, dof-tiered Schur kernels). **Camera models.** SIMPLE_PINHOLE, PINHOLE, SIMPLE_RADIAL, RADIAL, OPENCV, -FULL_OPENCV (reduced), OPENCV_FISHEYE (Kannala-Brandt, past 180°), +FULL_OPENCV, OPENCV_FISHEYE (Kannala-Brandt, past 180°), THIN_PRISM_FISHEYE, EQUIRECTANGULAR — with the principal point held constant by default and one principal-point-free global BA at the end for a single camera group. diff --git a/src/app/TrainerCore.cpp b/src/app/TrainerCore.cpp index 0eb66361..0a9b8d11 100644 --- a/src/app/TrainerCore.cpp +++ b/src/app/TrainerCore.cpp @@ -693,7 +693,7 @@ void TrainerSession::setup_engine() { dm.mask_boundary_offset = cfg.mask_boundary_offset; dm.warp_to_pinhole = cfg.warp_to_pinhole; engine_setup_data_manager( - dm, ds.camera_models, + dm, ds.camera_models, ds.camera_distortions, ds.image_filenames, ds.mask_filenames, has_depth ? ds.depth_filenames : std::vector{}, has_normal ? ds.normal_filenames : std::vector{}, @@ -702,6 +702,7 @@ void TrainerSession::setup_engine() { post.any_warp ? post.post_offsets : std::vector{}, post.viewmats, post.intrins, post.dist_coeffs, post.input_intrins, post.input_dist_coeffs, + post.redistort_models, post.redistort_params, ds.train_indices, ds.val_indices); // ---- Bilagrid / PPISP init ----------------------------------------- @@ -1039,13 +1040,14 @@ void TrainerSession::eval() { { std::lock_guard lk(engine_mutex); engine_setup_data_manager( - dm, eds.camera_models, + dm, eds.camera_models, eds.camera_distortions, eds.image_filenames, eds.mask_filenames, {}, {}, eds.widths, eds.heights, epost.any_warp ? epost.K_per_camera : std::vector{}, epost.any_warp ? epost.post_offsets : std::vector{}, epost.viewmats, epost.intrins, epost.dist_coeffs, epost.input_intrins, epost.input_dist_coeffs, + epost.redistort_models, epost.redistort_params, all_idx, {}); } diff --git a/src/app/gui/PreviewRenderer.cpp b/src/app/gui/PreviewRenderer.cpp index 3f933a57..0e6b4103 100644 --- a/src/app/gui/PreviewRenderer.cpp +++ b/src/app/gui/PreviewRenderer.cpp @@ -277,39 +277,56 @@ constexpr double kPi = 3.14159265358979323846; // MSVC has no M_PI by default struct P3 { float x, y, z; }; -bool has_distortion(const float* d) { - for (int i = 0; i < 10; i++) if (d[i] != 0.0f) return true; +bool has_distortion(int tier, const float* d) { + if (tier == (int)CameraDistortionType::None) return false; + for (int i = 0; i < kCameraDistortionParams; i++) if (d[i] != 0.0f) return true; return false; } -// dist = [k1 k2 k3 k4 p1 p2 s1 s2 b1 b2] (projection_utils.cuh:1166) -void distort_pt(double u, double v, const float* d, double out[2]) { +// Host mirror of the tier structs in shaders/projection_utils.slang; the slot +// order differs per tier, which is why the tier travels with the coefficients. +void distort_pt(double u, double v, int tier, const float* d, double out[2]) { double r2 = u*u + v*v; + if (tier == (int)CameraDistortionType::None) { + out[0] = u; out[1] = v; + return; + } + if (tier == (int)CameraDistortionType::OpenCV) { + double radial = 1 + r2*(d[0] + r2*d[1]); + out[0] = u*radial + 2*d[2]*u*v + d[3]*(r2 + 2*u*u); + out[1] = v*radial + 2*d[3]*u*v + d[2]*(r2 + 2*v*v); + return; + } + if (tier == (int)CameraDistortionType::Rational) { + double radial = (1 + r2*(d[0] + r2*(d[1] + r2*d[2]))) + / (1 + r2*(d[3] + r2*(d[4] + r2*d[5]))); + out[0] = u*radial + 2*d[6]*u*v + d[7]*(r2 + 2*u*u); + out[1] = v*radial + 2*d[7]*u*v + d[6]*(r2 + 2*v*v); + return; + } double radial = 1 + r2*(d[0] + r2*(d[1] + r2*(d[2] + r2*d[3]))); - double xd = u*radial + 2*d[4]*u*v + d[5]*(r2 + 2*u*u) + d[6]*r2; - double yd = v*radial + 2*d[5]*u*v + d[4]*(r2 + 2*v*v) + d[7]*r2; - out[0] = xd + d[8]*xd + d[9]*yd; // b1/b2 mix into x - out[1] = yd; + out[0] = u*radial + 2*d[4]*u*v + d[5]*(r2 + 2*u*u) + d[6]*r2; + out[1] = v*radial + 2*d[5]*u*v + d[4]*(r2 + 2*v*v) + d[7]*r2; } -void distort_jac(double qx, double qy, const float* d, double J[4]) { +void distort_jac(double qx, double qy, int tier, const float* d, double J[4]) { const double e = 1e-5; double f[2], fx[2], fy[2]; - distort_pt(qx, qy, d, f); - distort_pt(qx + e, qy, d, fx); - distort_pt(qx, qy + e, d, fy); + distort_pt(qx, qy, tier, d, f); + distort_pt(qx + e, qy, tier, d, fx); + distort_pt(qx, qy + e, tier, d, fy); J[0] = (fx[0]-f[0])/e; J[1] = (fx[1]-f[1])/e; // j00 j10 J[2] = (fy[0]-f[0])/e; J[3] = (fy[1]-f[1])/e; // j01 j11 } // Newton solve distort(q) = (u,v), with undistort_point_0's failure // conditions (well-posed forward Jacobian + re-distorts within 0.01). -bool undistort_pt(double u, double v, const float* d, double out[2]) { +bool undistort_pt(double u, double v, int tier, const float* d, double out[2]) { double qx = u, qy = v; for (int it = 0; it < 8; it++) { double f[2], J[4]; - distort_pt(qx, qy, d, f); - distort_jac(qx, qy, d, J); + distort_pt(qx, qy, tier, d, f); + distort_jac(qx, qy, tier, d, J); double det = J[0]*J[3] - J[2]*J[1]; if (std::fabs(det) < 1e-12) break; double rx = f[0] - u, ry = f[1] - v, inv = 1/det; @@ -318,10 +335,10 @@ bool undistort_pt(double u, double v, const float* d, double out[2]) { } if (!std::isfinite(qx) || !std::isfinite(qy)) return false; double J[4], f[2]; - distort_jac(qx, qy, d, J); + distort_jac(qx, qy, tier, d, J); double det = J[0]*J[3] - J[2]*J[1]; if (std::min(det, std::min(J[0], J[3])) <= 0) return false; // folded - distort_pt(qx, qy, d, f); + distort_pt(qx, qy, tier, d, f); if (std::hypot(f[0]-u, f[1]-v) >= 0.01) return false; out[0] = qx; out[1] = qy; return true; @@ -337,7 +354,7 @@ bool norm3(double x, double y, double z, double out[3]) { // Unproject a normalized image point to a unit ray in CV camera space // (+Z forward, +Y down); false when outside the valid domain. Mirrors // generate_ray (projection_utils.cuh:1368). -bool generate_ray(double u, double v, int model, const float* d, double out[3]) { +bool generate_ray(double u, double v, int model, int tier, const float* d, double out[3]) { if (model == M_EQUIRECT) { if (std::fabs(u) > kPi || std::fabs(v) > kPi/2) return false; double cl = std::cos(v); @@ -345,9 +362,9 @@ bool generate_ray(double u, double v, int model, const float* d, double out[3]) return true; } double uu = u, vv = v; - if (has_distortion(d)) { + if (has_distortion(tier, d)) { double q[2]; - if (!undistort_pt(u, v, d, q)) return false; + if (!undistort_pt(u, v, tier, d, q)) return false; uu = q[0]; vv = q[1]; } double r = std::hypot(uu, vv); @@ -372,7 +389,7 @@ struct FrustumTemplate { std::vector lines; std::vector anchors // interior gridlines (wire dome); equirectangular gets a lat/long wire // globe over the pixel grid. See viewer/js/dataset.js frustumTemplate for // the full rationale. -FrustumTemplate frustum_template(int model, int w, int h, float fx, float fy, +FrustumTemplate frustum_template(int model, int tier, int w, int h, float fx, float fy, float cx, float cy, const float* dist) { FrustumTemplate out; if (w < 1) w = std::max(1, (int)std::lround(2*cx)); @@ -392,12 +409,12 @@ FrustumTemplate frustum_template(int model, int w, int h, float fx, float fy, // Unproject; outside the valid domain, shrink uv toward the principal // point until it re-enters (Visualizer.cu:146-157). auto ray = [&](double u, double v, double dir[3]) { - if (generate_ray(u, v, model, dist, dir)) return; + if (generate_ray(u, v, model, tier, dist, dir)) return; double t0 = 0, t1 = 1, best[3] = {0, 0, 1}; bool have = false; for (int k = 0; k < 12; k++) { double s = 0.5*(t0+t1), rr[3]; - if (generate_ray(u*s, v*s, model, dist, rr)) { + if (generate_ray(u*s, v*s, model, tier, dist, rr)) { t0 = s; best[0]=rr[0]; best[1]=rr[1]; best[2]=rr[2]; have = true; } else t1 = s; } @@ -862,22 +879,24 @@ bool PreviewRenderer::build(const ParsedDataset& ds, const PostSplitCameras& pos map_dir(dx, X); map_dir(dy, Y); map_dir(dz, Z); int model = ds.camera_models.empty() ? M_PINHOLE : (int)ds.camera_models[i]; + int tier = ds.camera_distortions.empty() + ? (int)CameraDistortionType::None : ds.camera_distortions[i]; float fx = ds.intrins[i*4 + 0], fy = ds.intrins[i*4 + 1]; float cx = ds.intrins[i*4 + 2], cy = ds.intrins[i*4 + 3]; - static const float kZeroDist[10] = {}; + static const float kZeroDist[kCameraDistortionParams] = {}; const float* dist = ds.dist_coeffs.empty() ? kZeroDist - : &ds.dist_coeffs[i*10]; + : &ds.dist_coeffs[i*kCameraDistortionParams]; char key[256]; - std::snprintf(key, sizeof key, "%d|%d|%d|%.3f|%.3f|%.3f|%.3f", model, - ds.widths[i], ds.heights[i], fx, fy, cx, cy); + std::snprintf(key, sizeof key, "%d|%d|%d|%d|%.3f|%.3f|%.3f|%.3f", + model, tier, ds.widths[i], ds.heights[i], fx, fy, cx, cy); std::string k = key; - for (int j = 0; j < 10; j++) { + for (int j = 0; j < kCameraDistortionParams; j++) { std::snprintf(key, sizeof key, "|%g", dist[j]); k += key; } auto it = templates.find(k); if (it == templates.end()) - it = templates.emplace(k, frustum_template(model, ds.widths[i], + it = templates.emplace(k, frustum_template(model, tier, ds.widths[i], ds.heights[i], fx, fy, cx, cy, dist)).first; const FrustumTemplate& tmpl = it->second; diff --git a/src/app/gui/SplatViewer.cpp b/src/app/gui/SplatViewer.cpp index 01cc7dfc..3b19166f 100644 --- a/src/app/gui/SplatViewer.cpp +++ b/src/app/gui/SplatViewer.cpp @@ -357,7 +357,7 @@ void SplatViewer::run(std::string path) { // control, because there are none to show. What the call is // really for is the state the axes/grid overlay lives in. std::vector intrins{32, 32, 32, 32}; - std::vector dist((size_t)10, 0.0f); + std::vector dist((size_t)kCameraDistortionParams, 0.0f); std::vector c2w{1, 0, 0, center[0], 0, 1, 0, center[1], 0, 0, 1, center[2]}; @@ -367,7 +367,7 @@ void SplatViewer::run(std::string path) { (uint32_t)sizeof(int32_t), std::move(shape)}; }; engine_viewer_init(tvi(models_i, {1}), tv(intrins, {1, 4}), - tv(dist, {1, 10}), tv(c2w, {1, 3, 4}), + tv(dist, {1, kCameraDistortionParams}), tv(c2w, {1, 3, 4}), tvi(w_i, {1}), tvi(h_i, {1}), /*camera_size=*/radius * 1e-3f); // A file has no grid extent of its own; the model's does, and it diff --git a/src/app/webviewer/RenderWorker.cpp b/src/app/webviewer/RenderWorker.cpp index e8abf659..3b4a59ee 100644 --- a/src/app/webviewer/RenderWorker.cpp +++ b/src/app/webviewer/RenderWorker.cpp @@ -244,7 +244,7 @@ struct RenderWorker::Impl { vm[15] = 1.f; float intr[4] = {q.fx, q.fy, q.cx, q.cy}; - float dist0[10] = {0}; + float dist0[8] = {0}; // Distortion images are FULL render resolution (never-freed pool // slots) -- emit them only when the user is actually LOOKING at a // distortion buffer, and only offer those buffers when a distortion @@ -272,10 +272,10 @@ struct RenderWorker::Impl { // Trainer.render's "post-processor + D->H inside the lock". std::lock_guard lk(*hooks.engine_mutex); - set_camera_params(W, H, q.model, + set_camera_params(W, H, q.model, "NONE", tvp(vm, 4, {1, 4, 4}), tvp(intr, 4, {1, 4}), - tvp(dist0, 4, {1, 10})); + tvp(dist0, 4, {1, 8})); forward_3dgs(primitive, sh_deg, cfg.packed, want_median, want_dist ? 2 : 0); engine_copy_render_to_host( @@ -355,7 +355,7 @@ struct RenderWorker::Impl { float* di = (float*)d_intr.upload(intr, sizeof intr); float* dc = (float*)d_dist.upload(dist0, sizeof dist0); depth_to_normal_forward_tv( - q.model, tvp(di, 4, {1, 4}), tvp(dc, 4, {1, 10}), + q.model, "NONE", tvp(di, 4, {1, 4}), tvp(dc, 4, {1, 8}), /*is_ray_depth=*/true, tvp(dd, 4, {1, H, W, 1}), tvp(dn, 4, {1, H, W, 3})); std::vector n_host(npx * 3); @@ -447,7 +447,7 @@ struct RenderWorker::Impl { tvp(db, 4, {H, W, C}), tvp(dz, 4, {H, W, 1}), tvp(da, 4, {H, W, 3}), - (int)camera_model_from_name(q.model), + (int)camera_model_from_name(q.model), "NONE", tvp(di, 4, {1, 4}), tvp(dv, 4, {4, 4}), tvp(dc, 4, {1, 10}), @@ -532,7 +532,7 @@ float viewer_upload_cameras(const PostSplitCameras& post) { engine_viewer_init( tvp(post.post_models.data(), 4, {post.n_post}), tvp(post.intrins.data(), 4, {post.n_post, 4}), - tvp(post.dist_coeffs.data(), 4, {post.n_post, 10}), + tvp(post.dist_coeffs.data(), 4, {post.n_post, kCameraDistortionParams}), tvp(post.c2w_flip.data(), 4, {post.n_post, 3, 4}), tvp(post.post_widths.data(), 4, {post.n_post}), tvp(post.post_heights.data(), 4, {post.n_post}), diff --git a/src/backend/tests/DistortionFixture.h b/src/backend/tests/DistortionFixture.h new file mode 100644 index 00000000..78359289 --- /dev/null +++ b/src/backend/tests/DistortionFixture.h @@ -0,0 +1,59 @@ +#pragma once + +// Camera-distortion inputs shared by the backend parity tools: the compiled +// (camera model, tier) set and one coefficient row per (tier, camera). + +#include + +#include +#include + +namespace dist_fixture { + +inline const char* const kTierNames[4] = {"NONE", "OPENCV", "THIN_PRISM", + "RATIONAL"}; + +// Tiers compiled for each camera model, in CameraModelType order; see +// camera_distortion_is_compiled in core/CameraModel.h. Rows are padded with +// tier 0 so a fixed-width table indexes cleanly -- read only kNumTiers[m]. +inline constexpr int kNumTiers[4] = {4, 3, 3, 1}; +inline constexpr int kTiers[4][4] = { + {0, 1, 2, 3}, // PINHOLE + {0, 1, 2, 0}, // FISHEYE + {0, 1, 2, 0}, // EQUISOLID + {0, 0, 0, 0}, // EQUIRECTANGULAR +}; + +// [tier][camera][kCameraDistortionParams], each row written in ITS OWN tier's +// coefficient order (core/CameraModel.h) -- a row is only meaningful under the +// tier it was built for. Every tier fills the terms the cheaper tiers cannot +// express (tangential p1/p2, thin-prism sx1/sy1, the rational denominator +// k4..k6), so sweeping the tiers sweeps the distortion math and not just the +// dispatch. Magnitudes stay mild: a strong lens flips borderline culls, which +// rewrite whole rows of the comparison. +inline std::vector distortion_rows(int64_t C) { + static const float row[4][kCameraDistortionParams] = { + {}, + {0.05f, -0.01f, 0.0012f, -0.0020f}, + {0.05f, -0.01f, 0.0020f, -0.0005f, + 0.0012f, -0.0020f, 0.0015f, -0.0008f}, + {0.05f, -0.01f, 0.0020f, 0.0300f, -0.0040f, 0.0010f, + 0.0012f, -0.0020f}, + }; + std::vector out((size_t)4 * C * kCameraDistortionParams, 0.0f); + for (int t = 0; t < 4; t++) + for (int64_t c = 0; c < C; c++) { + const float s = 1.0f - 0.3f * (float)(c % 3); + for (int k = 0; k < kCameraDistortionParams; k++) + out[((size_t)t * C + c) * kCameraDistortionParams + k] = + s * row[t][k]; + } + return out; +} + +// Offset in floats of camera `c`'s row under `tier`, into distortion_rows(C). +inline int64_t row_offset(int tier, int64_t C, int64_t c = 0) { + return ((int64_t)tier * C + c) * kCameraDistortionParams; +} + +} // namespace dist_fixture diff --git a/src/backend/tests/engine/engine_render_parity.cpp b/src/backend/tests/engine/engine_render_parity.cpp index c0d8ba97..16d680f3 100644 --- a/src/backend/tests/engine/engine_render_parity.cpp +++ b/src/backend/tests/engine/engine_render_parity.cpp @@ -12,6 +12,7 @@ // pixels). The blit's uint8 output allows |d| <= 2 per byte (fp rounding at // the byte quantization boundary) with the same violation cap. +#include #include #include #include @@ -89,13 +90,13 @@ int main(int argc, char** argv) { cy_, 0, sy_, 0.2f, 0, 1, 0, -0.1f, -sy_, 0, cy_, 4.2f, 0, 0, 0, 1, }; std::vector intr = {180, 182, 120, 90, 175, 177, 118, 92}; - std::vector dist(C * 10, 0.f); - dist[0] = 0.04f; dist[1] = -0.008f; dist[10] = -0.02f; dist[11] = 0.003f; + std::vector dist = dist_fixture::distortion_rows(C); - auto set_cams = [&](const char* model) { - set_camera_params(W, H, model, ttv(vm.data(), {C, 4, 4}), - ttv(intr.data(), {C, 4}), - ttv(dist.data(), {C, 10})); + auto set_cams = [&](const char* model, int tier) { + set_camera_params(W, H, model, dist_fixture::kTierNames[tier], + ttv(vm.data(), {C, 4, 4}), ttv(intr.data(), {C, 4}), + ttv(dist.data() + dist_fixture::row_offset(tier, C), + {C, kCameraDistortionParams})); }; // --- background: SH skybox with deterministic coefficients --- @@ -149,18 +150,22 @@ int main(int argc, char** argv) { struct Cfg { const char* prim; const char* cam; + int tier; // distortion tier, index into dist_fixture::kTierNames bool packed; bool median; int dist_type; // 0 None, 2 RGB_D }; + // Rows 1 and 2 differ only in the tier, so the NONE fast path is read + // against a distorted neighbour. const Cfg cfgs[] = { - {"3dgs", "PINHOLE", false, true, 0}, - {"mip", "FISHEYE", false, false, 2}, - {"3dgut", "PINHOLE", false, false, 0}, - {"3dgs", "EQUIRECTANGULAR", true, false, 0}, + {"3dgs", "PINHOLE", 0, false, true, 0}, + {"3dgs", "PINHOLE", 1, false, true, 0}, + {"mip", "FISHEYE", 2, false, false, 2}, + {"3dgut", "PINHOLE", 3, false, false, 0}, + {"3dgs", "EQUIRECTANGULAR", 0, true, false, 0}, }; for (const Cfg& c : cfgs) { - set_cams(c.cam); + set_cams(c.cam, c.tier); forward_3dgs(c.prim, 3, c.packed, c.median, c.dist_type); backend::device_synchronize(); if (const char* err = backend::last_error()) { @@ -173,7 +178,7 @@ int main(int argc, char** argv) { // --- noise background mode --- engine_init_background_noise(/*linear=*/false); - set_cams("PINHOLE"); + set_cams("PINHOLE", 1); forward_3dgs("3dgs", 3, false, false, 0); backend::device_synchronize(); pull(0, 0); @@ -184,9 +189,10 @@ int main(int argc, char** argv) { float* d_normals = (float*)backend::device_malloc((size_t)C * H * W * 3 * 4); depth_to_normal_forward_tv( - "PINHOLE", + "PINHOLE", "OPENCV", ttv(engine().camera.intrins.data_ptr(), {C, 4}), - ttv(engine().camera.dist_coeffs.data_ptr(), {C, 10}), + ttv(engine().camera.dist_coeffs.data_ptr(), + {C, kCameraDistortionParams}), /*is_ray_depth=*/true, ttv(depth_t.data_ptr(), {C, H, W, 1}), ttv(d_normals, {C, H, W, 3})); @@ -199,8 +205,8 @@ int main(int argc, char** argv) { // --- viewer blit: synthetic 6-camera dataset + grid overlay --- { - std::vector v_intr(N_CAM * 4), v_dist(N_CAM * 10, 0.f), - v_c2w(N_CAM * 12); + std::vector v_intr(N_CAM * 4), + v_dist(N_CAM * kCameraDistortionParams, 0.f), v_c2w(N_CAM * 12); std::vector v_w(N_CAM, 320), v_h(N_CAM, 240), v_model(N_CAM, 0); for (int i = 0; i < N_CAM; i++) { @@ -229,7 +235,7 @@ int main(int argc, char** argv) { v_model[2] = 1; // one fisheye frustum engine_viewer_init(ttv(v_model.data(), {N_CAM}), ttv(v_intr.data(), {N_CAM, 4}), - ttv(v_dist.data(), {N_CAM, 10}), + ttv(v_dist.data(), {N_CAM, kCameraDistortionParams}), ttv(v_c2w.data(), {N_CAM, 3, 4}), ttv(v_w.data(), {N_CAM}), ttv(v_h.data(), {N_CAM}), 0.25f); @@ -238,7 +244,12 @@ int main(int argc, char** argv) { // view camera = render camera 0 (device copies) std::vector view_vm(vm.begin(), vm.begin() + 16); std::vector view_intr(intr.begin(), intr.begin() + 4); - std::vector view_dist(10, 0.f); + // Visualization camera: OpenCV, so the blit's own projection runs a + // distorted tier rather than only the fast path. + std::vector view_dist( + dist.begin() + dist_fixture::row_offset(1, C), + dist.begin() + dist_fixture::row_offset(1, C) + + kCameraDistortionParams); float* d_vm = upload(view_vm); float* d_vi = upload(view_intr); float* d_vd = upload(view_dist); @@ -253,7 +264,8 @@ int main(int argc, char** argv) { engine_blit_view( "rgb", ttv(rgb_t.data_ptr(), {H, W, 3}), ttv(depth_t.data_ptr(), {H, W, 1}), ttv(d_Ts, {H, W, 1}), 0, - ttv(d_vi, {1, 4}), ttv(d_vm, {4, 4}), ttv(d_vd, {1, 10}), + "OPENCV", ttv(d_vi, {1, 4}), ttv(d_vm, {4, 4}), + ttv(d_vd, {1, kCameraDistortionParams}), /*show_training_cameras=*/cams, /*show_overlay=*/true, /*grid_dist=*/3.0f, 0.2f, -0.1f, 0.0f, ttv(d_out, {H, W, 3})); diff --git a/src/backend/tests/engine/engine_train_parity.cpp b/src/backend/tests/engine/engine_train_parity.cpp index 582797f8..37dc17ed 100644 --- a/src/backend/tests/engine/engine_train_parity.cpp +++ b/src/backend/tests/engine/engine_train_parity.cpp @@ -20,6 +20,7 @@ // all optimizer steps (fed by atomically accumulated gradients). // Densification is disabled so the splat count stays fixed. +#include #include #include #include @@ -181,7 +182,7 @@ int main(int argc, char** argv) { 0, 0, 0, 1, }; std::vector intr = {70, 71, 48, 36, 69, 70, 47, 37}; - std::vector dist(C * 10, 0.f); + std::vector dist = dist_fixture::distortion_rows(C); auto gt_rgb = r.bytes((int64_t)C * H * W * 3); auto gt_depth = r.words((int64_t)C * H * W, 12); @@ -189,11 +190,15 @@ int main(int argc, char** argv) { auto gt_alpha = r.bytes((int64_t)C * H * W); for (auto& v : gt_alpha) v = v < 220 ? 1 : 0; + // One step per tier: PINHOLE compiles all four, and the tier is + // orthogonal to everything the step does with the GT. for (int s = 0; s < 4; s++, step++) { auto losses = engine_train_step( step, max_steps, "3dgs", 3, /*packed=*/false, W, H, - "PINHOLE", ttv(vm.data(), 4, {C, 4, 4}), - ttv(intr.data(), 4, {C, 4}), ttv(dist.data(), 4, {C, 10}), + "PINHOLE", dist_fixture::kTierNames[s], + ttv(vm.data(), 4, {C, 4, 4}), ttv(intr.data(), 4, {C, 4}), + ttv(dist.data() + dist_fixture::row_offset(s, C), 4, + {C, kCameraDistortionParams}), ttv(gt_rgb.data(), 1, {C, H, W, 3}), ttv(gt_depth.data(), 2, {C, H, W, 1}), ttv(gt_normal.data(), 1, {C, H, W, 3}), @@ -222,21 +227,26 @@ int main(int argc, char** argv) { post_intr.push_back(0.5f * out_W); post_intr.push_back(0.5f * out_H); } - std::vector post_dist(B_post * 10, 0.f); + // engine_train_step_warped always sets the post-split table to + // PINHOLE / NONE. + std::vector post_dist(B_post * kCameraDistortionParams, 0.f); struct WarpCase { const char* model; + int tier; // distortion tier, index into dist_fixture::kTierNames int in_H, in_W; float fx, fy; }; const WarpCase wcases[2] = { - {"FISHEYE", 48, 64, 20.0f, 20.5f}, - {"EQUIRECTANGULAR", 32, 64, 10.2f, 10.2f}, + {"FISHEYE", 2, 48, 64, 20.0f, 20.5f}, + {"EQUIRECTANGULAR", 0, 32, 64, 10.2f, 10.2f}, }; + const std::vector warp_dist = dist_fixture::distortion_rows(1); for (const WarpCase& wc : wcases) { std::vector in_intr = {wc.fx, wc.fy, 0.5f * wc.in_W, 0.5f * wc.in_H}; - std::vector in_dist(10, 0.005f); + const float* in_dist = + warp_dist.data() + dist_fixture::row_offset(wc.tier, 1); auto gt_rgb = r.bytes((int64_t)wc.in_H * wc.in_W * 3); auto gt_alpha = r.bytes((int64_t)wc.in_H * wc.in_W); @@ -249,10 +259,12 @@ int main(int argc, char** argv) { step, max_steps, "3dgs", 3, /*packed=*/false, out_W, out_H, ttv(post_vm.data(), 4, {B_post, 4, 4}), ttv(post_intr.data(), 4, {B_post, 4}), - ttv(post_dist.data(), 4, {B_post, 10}), wc.model, + ttv(post_dist.data(), 4, {B_post, kCameraDistortionParams}), + wc.model, dist_fixture::kTierNames[wc.tier], /*B_in=*/1, wc.in_H, wc.in_W, K, ttv(in_intr.data(), 4, {1, 4}), - ttv(in_dist.data(), 4, {1, 10}), + ttv(in_dist, 4, {1, kCameraDistortionParams}), + ttv_null(), ttv_null(), ttv(gt_rgb.data(), 1, {1, wc.in_H, wc.in_W, 3}), ttv(gt_alpha.data(), 1, {1, wc.in_H, wc.in_W, 1}), wc.in_H, wc.in_W, diff --git a/src/backend/tests/fpbo_parity.cpp b/src/backend/tests/fpbo_parity.cpp index c5318ff2..21a446f4 100644 --- a/src/backend/tests/fpbo_parity.cpp +++ b/src/backend/tests/fpbo_parity.cpp @@ -12,6 +12,7 @@ // N is a multiple of the 256-thread block (see projqgrad_parity note on the // CUDA kernel's tail-thread reads). +#include #include #include #include @@ -125,9 +126,7 @@ int main(int argc, char** argv) { cy_, 0, sy_, 0.3f, 0, 1, 0, -0.2f, -sy_, 0, cy_, 5.f, 0, 0, 0, 1, }; std::vector intr = {150, 152, 100, 75, 145, 146, 97, 78}; - std::vector dist(C * 10, 0.f); - dist[0] = 0.05f; dist[1] = -0.01f; - dist[10] = -0.03f; + std::vector dist = dist_fixture::distortion_rows(C); float* d_vm = upload(vm); float* d_intr = upload(intr); @@ -140,11 +139,16 @@ int main(int argc, char** argv) { const char* cams[4] = {"PINHOLE", "FISHEYE", "EQUISOLID", "EQUIRECTANGULAR"}; + auto dist_tv = [&](int tier) { + return ttv(d_dist + dist_fixture::row_offset(tier, C), + {C, kCameraDistortionParams}); + }; struct Cfg { int prim; // 0 = 3dgs, 1 = mip, 2 = 3dgut bool packed; int cam; + int dist; // distortion tier, index into dist_fixture::kTierNames int max_deg; int level; // 0 fp32, 1 quantized SH bool non_sh; // non-SH quant (level 1 only) @@ -154,16 +158,19 @@ int main(int argc, char** argv) { bool per_splat_steps; bool densify; }; + // Rows 1 and 2 differ only in the tier, so the NONE fast path is read + // against a distorted neighbour. const Cfg cfgs[] = { - {0, false, 0, 3, 0, false, false, false, 31, false, true}, - {1, false, 1, 2, 0, false, true, false, 0, true, false}, - {2, false, 0, 3, 0, false, false, true, 7, false, true}, + {0, false, 0, 0, 3, 0, false, false, false, 31, false, true}, + {0, false, 0, 1, 3, 0, false, false, false, 31, false, true}, + {1, false, 1, 2, 2, 0, false, true, false, 0, true, false}, + {2, false, 0, 3, 3, 0, false, false, true, 7, false, true}, // NOTE: scale-agnostic means x non-SH quant is excluded: the mixed // g1/g2 units make u = g1/sqrt(g2) unbounded for edge splats // (radii 0 with nonzero grad), so +-1 quantum decode differences // amplify chaotically -- inherent to the lossy codec, on CUDA too. - {0, true, 2, 3, 1, true, false, false, 31, false, false}, - {2, true, 3, 1, 1, false, false, true, 7, false, false}, + {0, true, 2, 1, 3, 1, true, false, false, 31, false, false}, + {2, true, 3, 0, 1, 1, false, false, true, 7, false, false}, }; for (const Cfg& cfg : cfgs) { @@ -234,7 +241,8 @@ int main(int argc, char** argv) { : projection_3dgut_packed_forward; auto out = fn(N, cfg.max_deg, splats_fwd, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {C, 10}), radii, q_val_packed, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, q_val_packed, q_val_bounds, (uint32_t)NUM_SH, level1 ? 16 : 32, level1 ? 0 : 256); cam_ids = std::get<0>(out); @@ -247,7 +255,8 @@ int main(int argc, char** argv) { : projection_3dgut_forward; auto out = fn(N, cfg.max_deg, splats_fwd, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {C, 10}), radii, q_val_packed, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, q_val_packed, q_val_bounds, (uint32_t)NUM_SH, level1 ? 16 : 32, level1 ? 0 : 256); aabb_nd = DeviceTensorFloatND(std::get<0>(out)); @@ -375,7 +384,8 @@ int main(int argc, char** argv) { n_isect * 4, MemcpyKind::HostToDevice); fn(N, cfg.max_deg, splats, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {C, 10}), cam_ids, gauss_ids, aabb_nd, v_world, + dist_fixture::kTierNames[cfg.dist], dist_tv(cfg.dist), + cam_ids, gauss_ids, aabb_nd, v_world, v_screen, g1_world, g2_world, shq_tv, shq_b_tv, shv_tv, shv_b_tv, non_sh, radii, densify_score, /*lr_means=*/1.6e-4f, /*lr_quats=*/1e-3f, /*lr_scales=*/5e-3f, diff --git a/src/backend/tests/meshing_parity.cpp b/src/backend/tests/meshing_parity.cpp index 4f65109b..b1b484e7 100644 --- a/src/backend/tests/meshing_parity.cpp +++ b/src/backend/tests/meshing_parity.cpp @@ -30,6 +30,7 @@ // visibility) compare as exact CODES, also with a cap: a last-ulp Morton // difference reorders one leaf and rewrites a whole subtree's links. +#include #include #include @@ -398,7 +399,10 @@ int main(int argc, char** argv) { } // === 4. rasterize_moments_3dgut_fwd over a real projection === - std::vector vm(16 * NCAM), intr(4 * NCAM), dist(10 * NCAM, 0.0f); + std::vector vm(16 * NCAM), intr(4 * NCAM); + // One coefficient row per (tier, camera): the samplers below give each + // camera a different tier; the projection and the cull pick one block. + std::vector dist = dist_fixture::distortion_rows(NCAM); for (int c = 0; c < NCAM; ++c) { // identity rotation, camera pushed back along -z float* m = &vm[16 * c]; @@ -411,7 +415,6 @@ int main(int argc, char** argv) { in[1] = 120.0f; in[2] = 0.5f * (float)W; in[3] = 0.5f * (float)H; - dist[10 * c + 0] = 0.02f; // mild radial distortion } float* d_vm = upload(vm); float* d_intr = upload(intr); @@ -436,9 +439,10 @@ int main(int argc, char** argv) { backend::memset_sync(d_radii, 0, N * sizeof(float)); auto [aabb_2d, depths_2d, splats_s] = projection_3dgut_forward( (int64_t)N, 0, in_splats, ttv(d_vm + 16 * cam, {1, 4, 4}), - ttv(d_intr + 4 * cam, {1, 4}), W, H, "PINHOLE", - ttv(d_dist + 10 * cam, {1, 10}), radii, std::nullopt, std::nullopt, - 0, 32, 0); + ttv(d_intr + 4 * cam, {1, 4}), W, H, "PINHOLE", "THIN_PRISM", + ttv(d_dist + dist_fixture::row_offset(2, NCAM, cam), + {1, kCameraDistortionParams}), + radii, std::nullopt, std::nullopt, 0, 32, 0); DeviceTensorFloatND aabb_nd(aabb_2d), depths_nd(depths_2d); DeviceTensorFloatND proj_conic = splats_s[0]; DeviceTensorFloatND proj_opac = splats_s[1]; @@ -452,8 +456,10 @@ int main(int argc, char** argv) { rasterize_moments_3dgut_fwd( (int64_t)N, in_splats, splats_s, DeviceVector(), ttv(d_vm + 16 * cam, {1, 4, 4}), ttv(d_intr + 4 * cam, {1, 4}), - "PINHOLE", ttv(d_dist + 10 * cam, {1, 10}), aabb_2d, W, H, - tile_offsets, flatten_ids, d_moments, nullptr); + "PINHOLE", "THIN_PRISM", + ttv(d_dist + dist_fixture::row_offset(2, NCAM, cam), + {1, kCameraDistortionParams}), + aabb_2d, W, H, tile_offsets, flatten_ids, d_moments, nullptr); backend::device_synchronize(); if (check_error()) return 1; readback(lacc, (const float*)d_moments, (int64_t)npix * 3); @@ -461,8 +467,10 @@ int main(int argc, char** argv) { rasterize_moments_3dgut_fwd( (int64_t)N, in_splats, splats_s, DeviceVector(), ttv(d_vm + 16 * cam, {1, 4, 4}), ttv(d_intr + 4 * cam, {1, 4}), - "PINHOLE", ttv(d_dist + 10 * cam, {1, 10}), aabb_2d, W, H, - tile_offsets, flatten_ids, d_moments, d_rgbimg); + "PINHOLE", "THIN_PRISM", + ttv(d_dist + dist_fixture::row_offset(2, NCAM, cam), + {1, kCameraDistortionParams}), + aabb_2d, W, H, tile_offsets, flatten_ids, d_moments, d_rgbimg); backend::device_synchronize(); if (check_error()) return 1; readback(lacc, (const float*)d_rgbimg, (int64_t)npix * 3); @@ -504,14 +512,18 @@ int main(int argc, char** argv) { for (int c = 0; c < NCAM; ++c) { const int cm = 0; // PINHOLE + // Thin prism is covered by the projection and the cull. + const int td = c == 0 ? 0 : c == 1 ? 1 : 3; + const float* d_dc = + d_dist + dist_fixture::row_offset(td, NCAM, c); meshing::launch_sample_occ(d_q, NQ, d_vm + 16 * c, d_intr + 4 * c, - d_dist + 10 * c, cm, d_mom_s, W, H, k, + d_dc, cm, td, d_mom_s, W, H, k, d_kmin, d_cnt); meshing::launch_sample_color(d_q, NQ, d_vm + 16 * c, - d_intr + 4 * c, d_dist + 10 * c, cm, + d_intr + 4 * c, d_dc, cm, td, d_mom_s, d_rgb_s, W, H, d_num, d_den); meshing::launch_sample_view_density( - d_q, NQ, d_vm + 16 * c, d_intr + 4 * c, d_dist + 10 * c, cm, + d_q, NQ, d_vm + 16 * c, d_intr + 4 * c, d_dc, cm, td, d_mom_s, W, H, d_dens); } meshing::launch_finalize_occ(NQ, d_kmin, d_cnt, k, d_occ_k); @@ -606,9 +618,11 @@ int main(int argc, char** argv) { int32_t* d_W = upload(ws); int32_t* d_H = upload(hs); uint32_t* d_vis = alloc(NV); - meshing::launch_cull(d_verts, NV, d_faces, NF, d_vm, d_intr, d_dist, - d_W, d_H, /*camera_model=*/0, NCAM, t_leafMin, - t_leafMax, t_internal, t_nodeAABB, d_vis); + meshing::launch_cull( + d_verts, NV, d_faces, NF, d_vm, d_intr, + d_dist + dist_fixture::row_offset(2, NCAM), + d_W, d_H, /*camera_model=*/0, /*distortion=*/2, NCAM, t_leafMin, + t_leafMax, t_internal, t_nodeAABB, d_vis); backend::device_synchronize(); if (check_error()) return 1; readback_i32(codes, (const int32_t*)d_vis, NV); diff --git a/src/backend/tests/proj_bwd_parity.cpp b/src/backend/tests/proj_bwd_parity.cpp index aab6a0ba..4838b186 100644 --- a/src/backend/tests/proj_bwd_parity.cpp +++ b/src/backend/tests/proj_bwd_parity.cpp @@ -11,6 +11,7 @@ // whose order differs between backends, so the comparison is tolerance-based // with a small violation-fraction cap. +#include #include #include #include @@ -98,9 +99,7 @@ int main(int argc, char** argv) { cy_, 0, sy_, 0.3f, 0, 1, 0, -0.2f, -sy_, 0, cy_, 5.f, 0, 0, 0, 1, }; std::vector intr = {150, 152, 100, 75, 145, 146, 97, 78}; - std::vector dist(C * 10, 0.f); - dist[0] = 0.05f; dist[1] = -0.01f; - dist[10] = -0.03f; + std::vector dist = dist_fixture::distortion_rows(C); float* d_means = upload(means); float* d_quats = upload(quats); @@ -152,24 +151,32 @@ int main(int argc, char** argv) { const char* cams[4] = {"PINHOLE", "FISHEYE", "EQUISOLID", "EQUIRECTANGULAR"}; + auto dist_tv = [&](int tier) { + return ttv(d_dist + dist_fixture::row_offset(tier, C), + {C, kCameraDistortionParams}); + }; struct Cfg { int prim; // 0 = 3dgs, 1 = mip, 2 = 3dgut bool packed; int cam; + int dist; // distortion tier, index into dist_fixture::kTierNames int max_deg; // max_sh_degree passed to fwd + bwd int qbits; // 0 = fp32 SH, 8/16 = value-quant bool q_fpbo; // bounds layout when qbits != 0 bool vmg; // viewmat grad }; + // Rows 1 and 2 are the same config on NONE and on OpenCV, so the tier's + // fast path is read against a distorted neighbour. const Cfg cfgs[] = { - {0, false, 0, 3, 0, false, true}, - {1, false, 1, 2, 0, false, false}, - {0, true, 2, 3, 0, false, false}, - {2, false, 0, 3, 0, false, true}, - {2, true, 1, 1, 0, false, false}, - {0, false, 0, 3, 8, false, false}, - {2, false, 3, 3, 16, true, false}, + {0, false, 0, 0, 3, 0, false, true}, + {0, false, 0, 1, 3, 0, false, true}, + {1, false, 1, 2, 2, 0, false, false}, + {0, true, 2, 1, 3, 0, false, false}, + {2, false, 0, 3, 3, 0, false, true}, + {2, true, 1, 0, 1, 0, false, false}, + {0, false, 0, 2, 3, 8, false, false}, + {2, false, 3, 0, 3, 16, true, false}, }; for (const Cfg& cfg : cfgs) { @@ -200,7 +207,8 @@ int main(int argc, char** argv) { : projection_3dgut_packed_forward; auto out = fn(N, cfg.max_deg, splats_in, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {C, 10}), radii, q_packed, q_bounds, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, q_packed, q_bounds, (uint32_t)NUM_SH, quant ? cfg.qbits : 32, q_stride); cam_ids = std::get<0>(out); gauss_ids = std::get<1>(out); @@ -213,7 +221,8 @@ int main(int argc, char** argv) { : projection_3dgut_forward; auto out = fn(N, cfg.max_deg, splats_in, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {C, 10}), radii, q_packed, q_bounds, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, q_packed, q_bounds, (uint32_t)NUM_SH, quant ? cfg.qbits : 32, q_stride); aabb_2d = std::get<0>(out); } @@ -269,7 +278,8 @@ int main(int argc, char** argv) { : cfg.prim == 1 ? projection_mip_backward : projection_3dgut_backward; bwd(N, cfg.max_deg, splats_in, ttv(d_vm, {C, 16}), - ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], ttv(d_dist, {C, 10}), + ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], + dist_fixture::kTierNames[cfg.dist], dist_tv(cfg.dist), cam_ids, gauss_ids, aabb_2d, v_screen, v_world, cfg.vmg ? &v_viewmats : nullptr, q_packed, q_bounds, (uint32_t)NUM_SH, quant ? cfg.qbits : 32, q_stride); diff --git a/src/backend/tests/projection_parity.cpp b/src/backend/tests/projection_parity.cpp index 534227aa..69dc8a86 100644 --- a/src/backend/tests/projection_parity.cpp +++ b/src/backend/tests/projection_parity.cpp @@ -5,11 +5,13 @@ // CUDA build: ./projection_parity dump ref.bin // Vulkan build: ./projection_parity compare ref.bin (per device) // -// Deterministic inputs; 16 configs = {3DGS, MIP} x 4 camera models x -// SH degree {0, 3} (+ one no-distortion config). Comparison is tolerance- -// based (fast-math exp/sqrt chains differ across compilers) with a small -// allowance for borderline-cull flips, which change entire rows. +// Deterministic inputs; the configs are {3DGS, MIP, 3DGUT} x 4 camera models +// x SH degree {0, 3} x the distortion tiers compiled for that model. +// Comparison is tolerance-based (fast-math exp/sqrt chains differ across +// compilers) with a small allowance for borderline-cull flips, which change +// entire rows. +#include #include #include @@ -83,9 +85,7 @@ int main(int argc, char** argv) { cy_, 0, sy_, 0.3f, 0, 1, 0, -0.2f, -sy_, 0, cy_, 5.f, 0, 0, 0, 1, }; std::vector intr = {600, 610, 400, 300, 580, 585, 390, 310}; - std::vector dist(C * 10, 0.f); - dist[0] = 0.05f; dist[1] = -0.01f; dist[2] = 0.001f; dist[3] = -0.002f; - dist[10] = -0.03f; dist[11] = 0.004f; + std::vector dist = dist_fixture::distortion_rows(C); float* d_means = upload(means); float* d_quats = upload(quats); @@ -112,12 +112,21 @@ int main(int argc, char** argv) { const char* cams[4] = {"PINHOLE", "FISHEYE", "EQUISOLID", "EQUIRECTANGULAR"}; + auto dist_tv = [&](int tier) { + return ttv(d_dist + dist_fixture::row_offset(tier, C), + {C, kCameraDistortionParams}); + }; + std::vector acc; for (int prim = 0; prim < 3; prim++) for (int ci = 0; ci < 4; ci++) for (int shd = 0; shd <= 3; shd += 3) - for (int use_dist = 0; use_dist < 2; use_dist++) { - if (use_dist == 0 && ci != 0) continue; // one nodist cfg + // The tier is orthogonal to SH degree: sweep the compiled + // tiers at degree 3 and keep degree 0 on the NONE fast path, + // which also runs with a null coefficient tensor. + for (int t = 0; t < (shd ? dist_fixture::kNumTiers[ci] : 1); + t++) { + const int tier = dist_fixture::kTiers[ci][t]; backend::memset_sync(d_radii, 0, N * sizeof(float)); auto fn = prim == 0 ? projection_3dgs_forward : prim == 1 ? projection_mip_forward @@ -125,8 +134,9 @@ int main(int argc, char** argv) { auto out = fn( N, shd, in_splats, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[ci], - use_dist ? ttv(d_dist, {C, 10}) - : ttv(nullptr, {C, 10}), + dist_fixture::kTierNames[tier], + shd ? dist_tv(tier) + : ttv(nullptr, {C, kCameraDistortionParams}), radii, std::nullopt, std::nullopt, 0, 32, 0); backend::device_synchronize(); if (const char* err = backend::last_error()) { @@ -186,9 +196,14 @@ int main(int argc, char** argv) { return std::make_pair(packed_tv, bounds_tv); }; + int qcfg = 0; for (int prim = 0; prim < 3; prim++) for (int bits = 8; bits <= 16; bits += 8) - for (int fpbo = 0; fpbo < 2; fpbo++) { + for (int fpbo = 0; fpbo < 2; fpbo++, qcfg++) { + // Value-quant and distortion are independent axes, so rotate + // the tier through the codec configs instead of crossing them. + const int tier = dist_fixture::kTiers[prim] + [qcfg % dist_fixture::kNumTiers[prim]]; backend::memset_sync(d_radii, 0, N * sizeof(float)); auto fn = prim == 0 ? projection_3dgs_forward : prim == 1 ? projection_mip_forward @@ -197,7 +212,8 @@ int main(int argc, char** argv) { auto out = fn( N, 3, in_splats_q, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[prim], - ttv(d_dist, {C, 10}), radii, packed_tv, bounds_tv, + dist_fixture::kTierNames[tier], dist_tv(tier), radii, + packed_tv, bounds_tv, (uint32_t)NUM_SH, bits, fpbo ? 0 : 256); backend::device_synchronize(); if (const char* err = backend::last_error()) { @@ -220,14 +236,17 @@ int main(int argc, char** argv) { // --- packed projection: nnz-compacted outputs (ids exact via float) --- for (int prim = 0; prim < 3; prim++) for (int ci = 0; ci < 4; ci += 3) { // PINHOLE + EQUIRECTANGULAR + // PINHOLE walks the three distorted tiers across the primitives; + // EQUIRECTANGULAR has no lens distortion. + const int tier = ci == 0 ? 1 + prim : 0; backend::memset_sync(d_radii, 0, N * sizeof(float)); auto fn = prim == 0 ? projection_3dgs_packed_forward : prim == 1 ? projection_mip_packed_forward : projection_3dgut_packed_forward; auto out = fn(N, 3, in_splats, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[ci], - ttv(d_dist, {C, 10}), radii, std::nullopt, - std::nullopt, 0, 32, 0); + dist_fixture::kTierNames[tier], dist_tv(tier), + radii, std::nullopt, std::nullopt, 0, 32, 0); backend::device_synchronize(); if (const char* err = backend::last_error()) { std::fprintf(stderr, "backend error: %s\n", err); @@ -261,13 +280,16 @@ int main(int argc, char** argv) { const int prim = k == 0 ? 0 : 2; const int bits = k == 0 ? 8 : 16; const int fpbo = k; + // PINHOLE rational, then FISHEYE thin-prism. + const int tier = k == 0 ? 3 : 2; backend::memset_sync(d_radii, 0, N * sizeof(float)); auto fn = prim == 0 ? projection_3dgs_packed_forward : projection_3dgut_packed_forward; auto [packed_tv, bounds_tv] = quant_args(bits, fpbo); auto out = fn(N, 3, in_splats_q, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[k], - ttv(d_dist, {C, 10}), radii, packed_tv, bounds_tv, + dist_fixture::kTierNames[tier], dist_tv(tier), radii, + packed_tv, bounds_tv, (uint32_t)NUM_SH, bits, fpbo ? 0 : 256); backend::device_synchronize(); if (const char* err = backend::last_error()) { diff --git a/src/backend/tests/projqgrad_parity.cpp b/src/backend/tests/projqgrad_parity.cpp index 60c97331..1e0f1016 100644 --- a/src/backend/tests/projqgrad_parity.cpp +++ b/src/backend/tests/projqgrad_parity.cpp @@ -13,6 +13,7 @@ // The register camera-loop accumulation is deterministic; codes compare with // a +-1 quantum tolerance (codec rounding + last-ulp bound differences). +#include #include #include #include @@ -120,9 +121,7 @@ int main(int argc, char** argv) { cy_, 0, sy_, 0.3f, 0, 1, 0, -0.2f, -sy_, 0, cy_, 5.f, 0, 0, 0, 1, }; std::vector intr = {150, 152, 100, 75, 145, 146, 97, 78}; - std::vector dist(C * 10, 0.f); - dist[0] = 0.05f; dist[1] = -0.01f; - dist[10] = -0.03f; + std::vector dist = dist_fixture::distortion_rows(C); float* d_means = upload(means); float* d_quats = upload(quats); @@ -164,21 +163,26 @@ int main(int argc, char** argv) { const char* cams[4] = {"PINHOLE", "FISHEYE", "EQUISOLID", "EQUIRECTANGULAR"}; + auto dist_tv = [&](int tier) { + return ttv(d_dist + dist_fixture::row_offset(tier, C), + {C, kCameraDistortionParams}); + }; struct Cfg { int prim; // 0 = 3dgs, 1 = mip, 2 = 3dgut bool packed; int cam; + int dist; // distortion tier, index into dist_fixture::kTierNames int max_deg; bool geom_quant; // quantize means/quats/scales (off for 3dgut) bool qsrc; // q8 SH value source }; const Cfg cfgs[] = { - {0, false, 0, 3, true, false}, - {2, false, 1, 3, false, false}, - {0, true, 2, 2, true, false}, - {2, true, 0, 1, false, true}, - {1, false, 0, 3, true, false}, + {0, false, 0, 1, 3, true, false}, + {2, false, 1, 2, 3, false, false}, + {0, true, 2, 1, 2, true, false}, + {2, true, 0, 3, 1, false, true}, + {1, false, 0, 0, 3, true, false}, }; for (const Cfg& cfg : cfgs) { @@ -203,7 +207,8 @@ int main(int argc, char** argv) { : projection_3dgut_packed_forward; auto out = fn(N, cfg.max_deg, splats_in, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {C, 10}), radii, q_packed, q_bounds, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, q_packed, q_bounds, (uint32_t)NUM_SH, quant_src ? 8 : 32, 256); cam_ids = std::get<0>(out); gauss_ids = std::get<1>(out); @@ -216,7 +221,8 @@ int main(int argc, char** argv) { : projection_3dgut_forward; auto out = fn(N, cfg.max_deg, splats_in, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {C, 10}), radii, q_packed, q_bounds, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, q_packed, q_bounds, (uint32_t)NUM_SH, quant_src ? 8 : 32, 256); aabb_2d = std::get<0>(out); } @@ -332,7 +338,8 @@ int main(int argc, char** argv) { n_isect * 4, MemcpyKind::HostToDevice); bwd(N, cfg.max_deg, splats_in, ttv(d_vm, {C, 16}), ttv(d_intr, {C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {C, 10}), cam_ids, gauss_ids, aabb_2d, v_screen, + dist_fixture::kTierNames[cfg.dist], dist_tv(cfg.dist), + cam_ids, gauss_ids, aabb_2d, v_screen, v_world, gq, q_packed, q_bounds, (uint32_t)NUM_SH, quant_src ? 8 : 32, 256); backend::device_synchronize(); diff --git a/src/backend/tests/pwtrain_parity.cpp b/src/backend/tests/pwtrain_parity.cpp index fcf660b5..faeeddb4 100644 --- a/src/backend/tests/pwtrain_parity.cpp +++ b/src/backend/tests/pwtrain_parity.cpp @@ -11,6 +11,7 @@ // contributions in a different order than CUDA's block-atomic scheme, so // comparison uses the usual tolerance + small violation-fraction cap. +#include #include #include #include @@ -136,35 +137,40 @@ int main(int argc, char** argv) { // ---- cameras for depth kernels ---- std::vector intrins = {50.f, 50.f, 32.f, 24.f, 55.f, 52.f, 30.f, 25.f}; // [B,4] - std::vector dist(B * 10, 0.f); - dist[0] = 0.05f; // mild k1 on batch 0 - dist[10 + 0] = -0.03f; + std::vector dist = dist_fixture::distortion_rows(B); float* d_intr = upload(intrins); float* d_dist = upload(dist); + auto dist_tv = [&](int tier) { + return ttv(d_dist + dist_fixture::row_offset(tier, B), + {B, kCameraDistortionParams}); + }; std::vector depths(PIX); fill(depths, 0.5f, 6.f); float* d_depths = upload(depths); - // ---- depth_to_normal_backward (pinhole w/ dist; ray + linear depth) ---- - for (int rd = 0; rd < 2; rd++) { - std::vector vn(PIX * 3); - fill(vn, -1.f, 1.f); - float* d_vn = upload(vn); - float* d_vd = fresh1(); - depth_to_normal_backward("PINHOLE", ttv(d_intr, {B, 4}), - ttv(d_dist, {B, 10}), rd != 0, t1(d_depths), - t3(d_vn), t1(d_vd)); - backend::device_synchronize(); - readback_f(acc, d_vd, PIX); - } + // ---- depth_to_normal_backward (pinhole; every tier x ray/linear) ---- + for (int tier = 0; tier < 4; tier++) + for (int rd = 0; rd < 2; rd++) { + std::vector vn(PIX * 3); + fill(vn, -1.f, 1.f); + float* d_vn = upload(vn); + float* d_vd = fresh1(); + depth_to_normal_backward("PINHOLE", + dist_fixture::kTierNames[tier], + ttv(d_intr, {B, 4}), dist_tv(tier), + rd != 0, t1(d_depths), t3(d_vn), + t1(d_vd)); + backend::device_synchronize(); + readback_f(acc, d_vd, PIX); + } - // ---- linear_depth_to_ray_depth_inplace (fisheye, no dist view) ---- + // ---- linear_depth_to_ray_depth_inplace (fisheye, thin prism) ---- { std::vector dcopy = depths; float* d_d = upload(dcopy); - linear_depth_to_ray_depth_inplace("FISHEYE", ttv(d_intr, {B, 4}), - ttv(d_dist, {B, 10}), (int)W * 2, - (int)H * 2, t1(d_d)); + linear_depth_to_ray_depth_inplace("FISHEYE", "THIN_PRISM", + ttv(d_intr, {B, 4}), dist_tv(2), + (int)W * 2, (int)H * 2, t1(d_d)); backend::device_synchronize(); readback_f(acc, d_d, PIX); } @@ -198,6 +204,7 @@ int main(int argc, char** argv) { cy_, 0, sy_, 0, 0, 1, 0, 0, -sy_, 0, cy_, 1.f, 0, 0, 0, 1}; float* d_vm = upload(vm); for (int deg : {1, 3}) { + const int tier = deg == 1 ? 1 : 2; // OpenCV, then thin prism const int K = (deg + 1) * (deg + 1); std::vector sh(K * 3); fill(sh, -0.4f, 0.4f); @@ -205,16 +212,18 @@ int main(int argc, char** argv) { float* d_sh = upload(sh); float* d_out = fresh3(); render_background_sh_forward( - (int)W, (int)H, "PINHOLE", deg, ttv(d_vm, {B, 4, 4}), - ttv(d_intr, {B, 4}), ttv(d_dist, {B, 10}), + (int)W, (int)H, "PINHOLE", dist_fixture::kTierNames[tier], + deg, ttv(d_vm, {B, 4, 4}), + ttv(d_intr, {B, 4}), dist_tv(tier), ttv(d_sh, {K, 3}), ttv(d_out, {B, H, W, 3})); std::vector vout2(PIX * 3); fill(vout2, -1.f, 1.f); float* d_vout2 = upload(vout2); float* d_vsh = upload(std::vector(K * 3, 0.f)); render_background_sh_backward( - (int)W, (int)H, "PINHOLE", deg, ttv(d_vm, {B, 4, 4}), - ttv(d_intr, {B, 4}), ttv(d_dist, {B, 10}), + (int)W, (int)H, "PINHOLE", dist_fixture::kTierNames[tier], + deg, ttv(d_vm, {B, 4, 4}), + ttv(d_intr, {B, 4}), dist_tv(tier), ttv(d_sh, {K, 3}), ttv(d_out, {B, H, W, 3}), ttv(d_vout2, {B, H, W, 3}), ttv(d_vsh, {K, 3})); backend::device_synchronize(); diff --git a/src/backend/tests/raster_bwd_parity.cpp b/src/backend/tests/raster_bwd_parity.cpp index 8d8ba05f..4931892e 100644 --- a/src/backend/tests/raster_bwd_parity.cpp +++ b/src/backend/tests/raster_bwd_parity.cpp @@ -11,6 +11,7 @@ // whose order differs between backends (and between runs on CUDA), so the // comparison is tolerance-based with a small violation-fraction cap. +#include #include #include #include @@ -102,9 +103,7 @@ int main(int argc, char** argv) { cy_, 0, sy_, 0.3f, 0, 1, 0, -0.2f, -sy_, 0, cy_, 5.f, 0, 0, 0, 1, }; std::vector intr = {150, 152, 100, 75, 145, 146, 97, 78}; - std::vector dist(C * 10, 0.f); - dist[0] = 0.05f; dist[1] = -0.01f; - dist[10] = -0.03f; + std::vector dist = dist_fixture::distortion_rows(C); float* d_means = upload(means); float* d_quats = upload(quats); @@ -163,20 +162,29 @@ int main(int argc, char** argv) { int prim; // 0 = 3dgs, 2 = 3dgut bool packed; int cam; + int dist; // distortion tier, index into dist_fixture::kTierNames DistortionType dt; bool median; bool aw; bool vmg; // 3dgut viewmat grad }; + // The 3dgs backward never sees the camera, so the tier sweep lives on the + // 3dgut rows; the 3dgs rows carry it through the projection only. const Cfg cfgs[] = { - {0, false, 0, DistortionType::None, false, false, false}, - {0, false, 0, DistortionType::RGB_D, true, true, false}, - {0, true, 1, DistortionType::D, false, false, false}, - {2, false, 0, DistortionType::None, false, false, true}, - {2, false, 1, DistortionType::D, true, true, false}, + {0, false, 0, 0, DistortionType::None, false, false, false}, + {0, false, 0, 1, DistortionType::RGB_D, true, true, false}, + {0, true, 1, 2, DistortionType::D, false, false, false}, + {2, false, 0, 0, DistortionType::None, false, false, true}, + {2, false, 1, 2, DistortionType::D, true, true, false}, + {2, false, 0, 1, DistortionType::RGB_D, false, false, false}, + {2, true, 0, 3, DistortionType::D, false, false, false}, }; const char* cams[4] = {"PINHOLE", "FISHEYE", "EQUISOLID", "EQUIRECTANGULAR"}; + auto dist_tv = [&](int tier) { + return ttv(d_dist + dist_fixture::row_offset(tier, C), + {(int64_t)C, kCameraDistortionParams}); + }; for (const Cfg& cfg : cfgs) { backend::memset_sync(d_radii, 0, N * sizeof(float)); @@ -192,7 +200,8 @@ int main(int argc, char** argv) { : projection_3dgut_packed_forward; auto out = fn(N, 3, in_splats, ttv(d_vm, {(int64_t)C, 16}), ttv(d_intr, {(int64_t)C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {(int64_t)C, 10}), radii, std::nullopt, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, std::nullopt, std::nullopt, 0, 32, 0); cam_ids = std::get<0>(out); gauss_ids = std::get<1>(out); @@ -207,7 +216,8 @@ int main(int argc, char** argv) { : projection_3dgut_forward; auto out = fn(N, 3, in_splats, ttv(d_vm, {(int64_t)C, 16}), ttv(d_intr, {(int64_t)C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {(int64_t)C, 10}), radii, std::nullopt, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, std::nullopt, std::nullopt, 0, 32, 0); aabb_2d = std::get<0>(out); auto depths_2d = std::get<1>(out); @@ -248,7 +258,8 @@ int main(int argc, char** argv) { rout = rasterize_to_pixels_3dgut_fwd( N, in_splats, splats_s, gauss_ids, ttv(d_vm, {(int64_t)C, 16}), ttv(d_intr, {(int64_t)C, 4}), - cams[cfg.cam], ttv(d_dist, {(int64_t)C, 10}), aabb_2d, W, H, + cams[cfg.cam], dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), aabb_2d, W, H, tile_offsets, flatten_ids, cfg.dt, cfg.median); } else { rout = rasterize_to_pixels_3dgs_fwd(N, in_splats, splats_s, @@ -281,7 +292,8 @@ int main(int argc, char** argv) { N, in_splats, splats_s, gauss_ids, ttv(d_vm, {(int64_t)C, 16}), ttv(d_intr, {(int64_t)C, 4}), cams[cfg.cam], - ttv(d_dist, {(int64_t)C, 10}), aabb_2d, W, H, + dist_fixture::kTierNames[cfg.dist], dist_tv(cfg.dist), + aabb_2d, W, H, tile_offsets, flatten_ids, render_Ts, last_ids, renders, dist_fwd_opt, cfg.dt, DeviceTensor3D{}, awmap_t, v_renders, t3f1(d_v_T), v_med_t, v_dist_opt, diff --git a/src/backend/tests/render_parity.cpp b/src/backend/tests/render_parity.cpp index 66516806..d44e54dc 100644 --- a/src/backend/tests/render_parity.cpp +++ b/src/backend/tests/render_parity.cpp @@ -6,13 +6,14 @@ // Vulkan build: ./render_parity compare ref.bin (per device) // // Sections: -// 1. Background SH forward: SH degree x camera model image parity. +// 1. Background SH forward: SH degree x (camera model, distortion tier). // 2. Full pipeline (projection -> intersect -> rasterize), fused + packed, -// per primitive, with distortion / median variants. Rendered images, +// per primitive, with dist-loss / median variants. Rendered images, // transmittances, and tile offsets are compared with tolerance; near-tie // depth keys may sort differently across backends (last-ulp projection // divergence), so a small violation fraction is allowed. +#include #include #include #include @@ -115,9 +116,7 @@ int main(int argc, char** argv) { cy_, 0, sy_, 0.3f, 0, 1, 0, -0.2f, -sy_, 0, cy_, 5.f, 0, 0, 0, 1, }; std::vector intr = {150, 152, 100, 75, 145, 146, 97, 78}; - std::vector dist(C * 10, 0.f); - dist[0] = 0.05f; dist[1] = -0.01f; dist[2] = 0.001f; dist[3] = -0.002f; - dist[10] = -0.03f; dist[11] = 0.004f; + std::vector dist = dist_fixture::distortion_rows(C); float* d_means = upload(means); float* d_quats = upload(quats); @@ -142,6 +141,10 @@ int main(int argc, char** argv) { const char* cams[4] = {"PINHOLE", "FISHEYE", "EQUISOLID", "EQUIRECTANGULAR"}; + auto dist_tv = [&](int tier) { + return ttv(d_dist + dist_fixture::row_offset(tier, C), + {(int64_t)C, kCameraDistortionParams}); + }; std::vector acc; @@ -152,12 +155,19 @@ int main(int argc, char** argv) { float* d_bg_sh = upload(bg_sh); float* d_bg_out = (float*)backend::device_malloc((size_t)C * H * W * 3 * 4); - for (int shd = 0; shd <= 4; shd += 2) // degrees 0, 2, 4 + for (int si = 0; si < 3; si++) // degrees 0, 2, 4 for (int ci = 0; ci < 4; ci++) { + const int shd = 2 * si; + // PINHOLE has four compiled tiers and only three slots here, + // so start it at OpenCV; the NONE path is covered by the + // other models. + const int tier = + dist_fixture::kTiers[ci][(ci == 0 ? si + 1 : si) % + dist_fixture::kNumTiers[ci]]; render_background_sh_forward( - W, H, cams[ci], shd, ttv(d_vm, {(int64_t)C, 16}), - ttv(d_intr, {(int64_t)C, 4}), - ttv(d_dist, {(int64_t)C, 10}), + W, H, cams[ci], dist_fixture::kTierNames[tier], shd, + ttv(d_vm, {(int64_t)C, 16}), + ttv(d_intr, {(int64_t)C, 4}), dist_tv(tier), ttv(d_bg_sh, {(shd + 1) * (shd + 1), 3}), ttv(d_bg_out, {(int64_t)C, H, W, 3})); backend::device_synchronize(); @@ -173,18 +183,22 @@ int main(int argc, char** argv) { int prim; // 0 = 3dgs, 1 = mip, 2 = 3dgut bool packed; int cam; + int dist; // distortion tier, index into dist_fixture::kTierNames DistortionType dt; bool median; }; + // Only the 3dgut rasterizer reads the camera, so its rows carry the tier + // sweep; for 3dgs/mip the tier reaches the projection alone. const Cfg cfgs[] = { - {0, false, 0, DistortionType::RGB_D, true}, - {1, false, 0, DistortionType::RGB_D, true}, - {2, false, 0, DistortionType::RGB_D, true}, - {0, false, 1, DistortionType::D, false}, - {2, false, 3, DistortionType::None, true}, - {0, true, 3, DistortionType::None, false}, - {1, true, 0, DistortionType::D, false}, - {2, true, 0, DistortionType::None, false}, + {0, false, 0, 1, DistortionType::RGB_D, true}, + {1, false, 0, 0, DistortionType::RGB_D, true}, + {2, false, 0, 1, DistortionType::RGB_D, true}, + {2, false, 0, 2, DistortionType::D, false}, + {0, false, 1, 2, DistortionType::D, false}, + {2, false, 3, 0, DistortionType::None, true}, + {0, true, 3, 0, DistortionType::None, false}, + {1, true, 0, 3, DistortionType::D, false}, + {2, true, 0, 3, DistortionType::None, false}, }; for (const Cfg& cfg : cfgs) { @@ -203,7 +217,8 @@ int main(int argc, char** argv) { : projection_3dgut_packed_forward; auto out = fn(N, 3, in_splats, ttv(d_vm, {(int64_t)C, 16}), ttv(d_intr, {(int64_t)C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {(int64_t)C, 10}), radii, std::nullopt, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, std::nullopt, std::nullopt, 0, 32, 0); cam_ids = std::get<0>(out); gauss_ids = std::get<1>(out); @@ -220,7 +235,8 @@ int main(int argc, char** argv) { : projection_3dgut_forward; auto out = fn(N, 3, in_splats, ttv(d_vm, {(int64_t)C, 16}), ttv(d_intr, {(int64_t)C, 4}), W, H, cams[cfg.cam], - ttv(d_dist, {(int64_t)C, 10}), radii, std::nullopt, + dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), radii, std::nullopt, std::nullopt, 0, 32, 0); aabb_2d = std::get<0>(out); auto depths_2d = std::get<1>(out); @@ -266,7 +282,8 @@ int main(int argc, char** argv) { rout = rasterize_to_pixels_3dgut_fwd( N, in_splats, splats_s, gauss_ids, ttv(d_vm, {(int64_t)C, 16}), ttv(d_intr, {(int64_t)C, 4}), - cams[cfg.cam], ttv(d_dist, {(int64_t)C, 10}), aabb_2d, W, H, + cams[cfg.cam], dist_fixture::kTierNames[cfg.dist], + dist_tv(cfg.dist), aabb_2d, W, H, tile_offsets, flatten_ids, cfg.dt, cfg.median); } else { auto fn = cfg.prim == 0 ? rasterize_to_pixels_3dgs_fwd diff --git a/src/backend/tests/warp_parity.cpp b/src/backend/tests/warp_parity.cpp index 39a8883e..cc1c5b4f 100644 --- a/src/backend/tests/warp_parity.cpp +++ b/src/backend/tests/warp_parity.cpp @@ -17,13 +17,17 @@ // through the same channel; a flipped boundary texel counts as one // violation. // -// Coverage: all three wide camera models (PINHOLE with null dist_coeffs -> -// zeros-fallback path), u8/u16 image, u8 mask, u16-ray + f32-linear depth +// Coverage: all three wide camera models across the distortion tiers +// (the NONE row also passes null dist_coeffs, the zeros-fallback path), +// u8/u16 image, u8 mask, u16-ray + f32-linear depth // (GT at a different resolution than the intrinsics reference, exercising // the sx/sy rescale), u8/f32 normal (with all-zero "no data" sentinel -// pixels), the equirectangular variants (x-wrap sampling), and the four +// pixels), the equirectangular variants (x-wrap sampling), the re-distort +// family at two modality resolutions, both branches of the skewed source +// model and its fold rejection (shaders/camera_source.slang), and the four // raw byte->float converters with odd element counts (word-tail handling). +#include #include #include #include @@ -167,13 +171,22 @@ int main(int argc, char** argv) { struct Cam { const char* model; float fx, fy; - bool null_dist; + int dist; // tier; NONE also drives the null dist_coeffs path + int source; // COLMAP model id for the fused re-distort, 0 = none }; - const Cam cams[3] = { - {"FISHEYE", 20.0f, 20.5f, false}, - {"EQUISOLID", 24.0f, 24.0f, false}, - {"PINHOLE", 30.0f, 31.0f, true}, + const Cam cams[6] = { + {"FISHEYE", 20.0f, 20.5f, 2, 0}, + {"EQUISOLID", 24.0f, 24.0f, 1, 0}, + {"PINHOLE", 30.0f, 31.0f, 0, 0}, + {"PINHOLE", 30.0f, 31.0f, 3, 0}, + // EUCM source: the warp projects through it instead of the fitted + // camera, which is the fused re-distort + warp-to-pinhole path. + {"FISHEYE", 20.0f, 20.5f, 2, 16}, + // The skewed source, its other branch (Metashape b2). + {"FISHEYE", 20.0f, 20.5f, 2, 1000}, }; + std::vector dist_rows = dist_fixture::distortion_rows(B); + const float* d_dist_all = upload(dist_rows); for (const Cam& cam : cams) { std::vector intr; for (int b = 0; b < B; b++) { @@ -183,10 +196,40 @@ int main(int argc, char** argv) { intr.push_back(0.5f * Hin - 0.2f * b); } float* d_intr = upload(intr); - float* d_dist = nullptr; - if (!cam.null_dist) { - std::vector dist = r.vec(B * 10, -0.02f, 0.02f); - d_dist = upload(dist); + const float* d_dist = + cam.dist ? d_dist_all + dist_fixture::row_offset(cam.dist, B) + : nullptr; + const char* d_tier = dist_fixture::kTierNames[cam.dist]; + + const int* d_src_models = nullptr; + const float* d_src_params = nullptr; + std::vector src_models; + std::vector src_params; + if (cam.source) { + src_models.assign(B, cam.source); + src_params.assign((size_t)B * 16, 0.0f); + for (int b = 0; b < B; b++) { + float* p = &src_params[(size_t)b * 16]; + p[0] = intr[b*4 + 0]; p[1] = intr[b*4 + 1]; + p[2] = intr[b*4 + 2]; p[3] = intr[b*4 + 3]; + if (cam.source == 1000) { + p[4] = 0.35f; // skew, pixels + p[5] = 0.02f; p[6] = -0.003f; // k1 k2 + // k4 folds this lens at 110 deg, inside the 135 deg + // the widest face ray reaches, so source_unfolded runs + // both ways here. + p[7] = 0.001f; p[8] = -8e-4f; // k3 k4 + p[9] = 7e-4f; p[10] = -4e-4f; // p1 p2 + p[11] = 3e-4f; p[12] = -2e-4f; // sx1 sy1 + p[13] = 1.0f; // equidistant fisheye base + p[14] = 0.0f; // polynomial radial + } else { + p[4] = 0.6f; // EUCM alpha + p[5] = 1.1f; // EUCM beta + } + } + d_src_models = (const int*)upload(src_models); + d_src_params = upload(src_params); } const int64_t n_out = (int64_t)B * K * Hout * Wout; @@ -195,16 +238,16 @@ int main(int argc, char** argv) { auto img = r.bytes((int64_t)B * Hin * Win * 3); float* out = alloc_out(n_out * 3); launch_warp_byte_to_float_wide( - cam.model, d_intr, d_dist, upload(img), false, B, Hin, - Win, 3, out, K, Hout, Wout, d_axes); + cam.model, d_tier, d_intr, d_dist, d_src_models, d_src_params, upload(img), false, + B, Hin, Win, 3, out, K, Hout, Wout, d_axes); readback_f(out, n_out * 3); } if (cam.model[0] == 'F') { auto img = r.words((int64_t)B * Hin * Win * 3, 65535); float* out = alloc_out(n_out * 3); launch_warp_byte_to_float_wide( - cam.model, d_intr, d_dist, upload(img), true, B, Hin, - Win, 3, out, K, Hout, Wout, d_axes); + cam.model, d_tier, d_intr, d_dist, d_src_models, d_src_params, upload(img), true, + B, Hin, Win, 3, out, K, Hout, Wout, d_axes); readback_f(out, n_out * 3); } @@ -213,9 +256,9 @@ int main(int argc, char** argv) { auto m = r.bytes((int64_t)B * Hin * Win); for (auto& v : m) v = v < 200 ? 1 : 0; uint8_t* out = alloc_out(n_out); - launch_warp_mask_wide(cam.model, d_intr, d_dist, upload(m), - B, Hin, Win, out, K, Hout, Wout, - d_axes); + launch_warp_mask_wide(cam.model, d_tier, d_intr, d_dist, d_src_models, d_src_params, + upload(m), B, Hin, Win, out, K, Hout, + Wout, d_axes); readback_b(out, n_out); } @@ -224,7 +267,7 @@ int main(int argc, char** argv) { auto dep = r.words((int64_t)B * Hd * Wd, 5000); for (size_t i = 0; i < dep.size(); i += 53) dep[i] = 0; float* out = alloc_out(n_out); - launch_warp_depth_wide(cam.model, d_intr, d_dist, + launch_warp_depth_wide(cam.model, d_tier, d_intr, d_dist, d_src_models, d_src_params, upload(dep), 2, B, Hd, Wd, Hin, Win, out, K, Hout, Wout, d_axes, true); readback_f(out, n_out); @@ -233,7 +276,7 @@ int main(int argc, char** argv) { auto dep = r.vec((int64_t)B * Hd * Wd, 0.5f, 8.0f); for (size_t i = 0; i < dep.size(); i += 41) dep[i] = -0.5f; float* out = alloc_out(n_out); - launch_warp_depth_wide(cam.model, d_intr, d_dist, + launch_warp_depth_wide(cam.model, d_tier, d_intr, d_dist, d_src_models, d_src_params, upload(dep), 4, B, Hd, Wd, Hin, Win, out, K, Hout, Wout, d_axes, false); readback_f(out, n_out); @@ -246,7 +289,7 @@ int main(int argc, char** argv) { for (size_t i = 0; i + 2 < nrm.size(); i += 87) nrm[i] = nrm[i + 1] = nrm[i + 2] = 0; float* out = alloc_out(n_out * 3); - launch_warp_normal_wide(cam.model, d_intr, d_dist, + launch_warp_normal_wide(cam.model, d_tier, d_intr, d_dist, d_src_models, d_src_params, upload(nrm), 1, B, Hd, Wd, Hin, Win, out, K, Hout, Wout, d_axes); readback_f(out, n_out * 3); @@ -254,7 +297,7 @@ int main(int argc, char** argv) { if (cam.model[0] == 'F') { auto nrm = r.vec((int64_t)B * Hd * Wd * 3, -1.0f, 1.0f); float* out = alloc_out(n_out * 3); - launch_warp_normal_wide(cam.model, d_intr, d_dist, + launch_warp_normal_wide(cam.model, d_tier, d_intr, d_dist, d_src_models, d_src_params, upload(nrm), 4, B, Hd, Wd, Hin, Win, out, K, Hout, Wout, d_axes); readback_f(out, n_out * 3); @@ -262,6 +305,117 @@ int main(int argc, char** argv) { } } + // ---- re-distort (K == 1): a camera whose lens model no tier represents, + // resampled from the true source projection onto the fitted tier. The + // modality grids deliberately DIFFER from the intrinsics reference: an + // equal-resolution case cannot tell scale_in from scale_out, so it would + // pass with the source scale applied to the destination step. + { + const int B = 2, refW = 42, refH = 58; + struct Grid { int in_w, in_h, out_w, out_h; }; + const Grid grids[2] = { + {refW, refH, refW, refH}, // same resolution + {21, 29, 31, 43}, // half-res source, odd-size destination + }; + std::vector intr; + for (int b = 0; b < B; b++) { + intr.push_back(30.0f + 0.5f * b); + intr.push_back(31.0f + 0.3f * b); + intr.push_back(0.5f * refW + 0.4f * b); + intr.push_back(0.5f * refH - 0.2f * b); + } + float* d_intr = upload(intr); + std::vector dist_rows = dist_fixture::distortion_rows(B); + const float* d_dist = + upload(dist_rows) + dist_fixture::row_offset(2, B); // ThinPrism + + // EUCM (COLMAP model 16), the wide-angle case the fitter targets. + std::vector src_models(B, 16); + std::vector src_params((size_t)B * 16, 0.0f); + for (int b = 0; b < B; b++) { + float* p = &src_params[(size_t)b * 16]; + p[0] = intr[b*4 + 0]; p[1] = intr[b*4 + 1]; + p[2] = intr[b*4 + 2]; p[3] = intr[b*4 + 3]; + p[4] = 0.6f; p[5] = 1.1f; + } + const int* d_src_m = (const int*)upload(src_models); + const float* d_src_p = upload(src_params); + + for (const Grid& g : grids) { + const int64_t n_in = (int64_t)B * g.in_h * g.in_w; + const int64_t n_out = (int64_t)B * g.out_h * g.out_w; + + auto img = r.bytes(n_in * 3); + float* o_img = alloc_out(n_out * 3); + launch_redistort_byte_to_float( + "FISHEYE", "THIN_PRISM", d_intr, d_dist, d_src_m, d_src_p, + upload(img), false, B, g.in_h, g.in_w, 3, + o_img, g.out_h, g.out_w, refH, refW, 0.5f); + readback_f(o_img, n_out * 3); + + auto msk = r.bytes(n_in); + for (size_t i = 0; i < msk.size(); i++) msk[i] = (msk[i] > 40) ? 1 : 0; + uint8_t* o_msk = alloc_out(n_out); + launch_redistort_mask( + "FISHEYE", "THIN_PRISM", d_intr, d_dist, d_src_m, d_src_p, + upload(msk), B, g.in_h, g.in_w, + o_msk, g.out_h, g.out_w, refH, refW); + readback_b(o_msk, n_out); + + // A smooth ramp, not noise: neighbouring taps thousands of counts + // apart amplify a last-ULP difference in uv_src into a visible + // depth error that is data range, not geometry. + std::vector dep((size_t)n_in); + for (int64_t i = 0; i < n_in; i++) + dep[i] = (uint16_t)(1000 + (i % 997)); + float* o_dep = alloc_out(n_out); + launch_redistort_depth( + "FISHEYE", "THIN_PRISM", d_intr, d_dist, d_src_m, d_src_p, + upload(dep), 2, B, g.in_h, g.in_w, 1, + o_dep, g.out_h, g.out_w, refH, refW, 0.0f); + readback_f(o_dep, n_out); + + auto nrm = r.bytes(n_in * 3); + for (size_t i = 0; i + 2 < nrm.size(); i += 87) + nrm[i] = nrm[i + 1] = nrm[i + 2] = 0; // "no data" sentinel + float* o_nrm = alloc_out(n_out * 3); + launch_redistort_normal( + "FISHEYE", "THIN_PRISM", d_intr, d_dist, d_src_m, d_src_p, + upload(nrm), false, B, g.in_h, g.in_w, + o_nrm, g.out_h, g.out_w, refH, refW); + readback_f(o_nrm, n_out * 3); + } + + // The skewed source's rational branch on a perspective base -- the one + // combination the wide config above does not reach. + { + std::vector sm(B, 1000); + std::vector sp((size_t)B * 16, 0.0f); + for (int b = 0; b < B; b++) { + float* p = &sp[(size_t)b * 16]; + p[0] = intr[b*4 + 0]; p[1] = intr[b*4 + 1]; + p[2] = intr[b*4 + 2]; p[3] = intr[b*4 + 3]; + p[4] = 0.35f; // skew + p[5] = -0.28f; p[6] = 0.11f; p[7] = -0.02f; // k1 k2 k3 + p[8] = 0.9f; p[9] = 0.05f; p[10] = -0.004f; // k4 k5 k6 + p[11] = 7e-4f; p[12] = -4e-4f; // p1 p2 + p[13] = 0.0f; // perspective base + p[14] = 1.0f; // rational radial + } + const int64_t n_in = (int64_t)B * refH * refW; + const int64_t n_out = n_in; + auto img = r.bytes(n_in * 3); + float* out = alloc_out(n_out * 3); + launch_redistort_byte_to_float( + "PINHOLE", "RATIONAL", d_intr, + upload(dist_rows) + dist_fixture::row_offset(3, B), + (const int*)upload(sm), upload(sp), + upload(img), false, B, refH, refW, 3, + out, refH, refW, refH, refW, 0.5f); + readback_f(out, n_out * 3); + } + } + // ---- equirectangular warps ------------------------------------------- { const int B = 1, Hin = 32, Win = 64, K = 4, Hout = 16, Wout = 16; diff --git a/src/backend/vulkan/README.md b/src/backend/vulkan/README.md index 54a3dfca..7b7841bc 100644 --- a/src/backend/vulkan/README.md +++ b/src/backend/vulkan/README.md @@ -155,10 +155,37 @@ Variant axes follow the CUDA instantiation structure - **Primitive** (Vanilla3DGS / MipSplatting / Vanilla3DGUT) is a type parameter → separate entry point (buffer layouts differ). -- **Camera model, SH degree, DistortionType, output_median, VALUE_BITS** - are value parameters → specialization constants on ONE SPIR-V module, - folded at pipeline creation. Pipelines are created lazily and cached by - (entry point, spec-constant tuple, device capability set). +- **Camera model, lens-distortion tier, SH degree, DistortionType, + output_median, VALUE_BITS** are value parameters → specialization + constants on ONE SPIR-V module, folded at pipeline creation. Pipelines are + created lazily and cached by (entry point, spec-constant tuple, device + capability set). + +### The lens-distortion tier (`kDistortion`) + +`CameraDistortionType` (0 None / 1 OpenCV / 2 ThinPrism / 3 Rational, see +`core/CameraModel.h`) is a Slang generic `D : ICameraDistortion` in +`shaders/projection_utils.slang`. `backend/vulkan/shaders/dist_spec.slang` +carries the glue: `load_dist_coeffs` (a camera's prefix of the 8-float +storage row), `pixel_ray`, and the `SS_DISPATCH_DIST` / +`SS_DISPATCH_CAM_DIST` macros that fold the constant — the latter covering +only the eleven compiled (model, tier) pairs, with the rest falling through +to the nearest compiled tier. Launchers reject an uncompiled pair up front +(`vkk::cam_dist_spec`), so the fallthrough is never reached. + +**`kDistortion` is declared LAST in every module, and its value appended last +in every `SpecList`.** Spec-constant IDs are assigned by declaration order +within a module and the host passes `SpecList` by index, so a constant +inserted mid-module silently renumbers every axis after it (the class of bug +the densify copy kernel hit — see "Spec IDs follow declaration order" below). +The resulting IDs: warp 0; background_sh / pixel_wise_{render,train} / +meshing_raster / visualizer 1; rasterize_moments 3; projection_fwd / +rasterize_fwd 4; projection_bwd / rasterize_bwd 6; projection_qgrad 8; +fpbo 11 (12 axes, still under `SpecList::kMax` = 16). + +The one axis declared after `kDistortion` is warp's `kFromSource` (ID 1), +which selects the source-camera projection in the wide warps: it trails so the +launches that never re-distort keep passing their one-element `SpecList`. ## Shaders: build and shipping @@ -378,7 +405,9 @@ the engine level. field a shader may load through is NEVER null — launchers substitute `vkk::or_fallback()` (a 4 KB zeroed allocation in KernelCommon.h); "null means zeros" inputs (dist_coeffs and friends) just read the - fallback; "null selects a mode" moved to specialization constants + fallback (the identity distortion tier reads nothing at all: a large + camera index would run past the 4 KB fallback); + "null selects a mode" moved to specialization constants (intersect_tile kEllipse/kHasXy/kPacked, rasterize_fwd kRasterPacked — spec-folding removes the dead load entirely) or explicit flag fields (blit has_lss/has_tri, thumbnails has_alpha, optimizer has_steps/ @@ -671,11 +700,12 @@ the engine level. under bilinear-resampled GT, and the Pearson-depth chain fed by atomic-order-dependent sums); validation clean. - **Dataset warp/conversion + end-to-end training (phase 5, eighth and - final slice)**: `kernels/Warp.cpp` implements the 12 remaining launch + final slice)**: `kernels/Warp.cpp` implements the 16 remaining launch APIs — the fused byte->float GT warps of GtDepthNormalWarp.cu - (`launch_warp_{byte_to_float,mask,depth,normal}_{wide,equi}`) plus the - raw converters (`uint8/16_{image,depth,normal}_to_float_raw` and the - DeviceTensor3D wrappers). Device work in `warp.slang`: + (`launch_warp_{byte_to_float,mask,depth,normal}_{wide,equi}`), the + ImageRedistort.cu family (`launch_redistort_*`) and the raw converters + (`uint8/16_{image,depth,normal}_to_float_raw` and the DeviceTensor3D + wrappers). Device work in `warp.slang`: - The wide warps project each pinhole-face ray through the CANONICAL `projection_utils.slang` `*_proj_nav` exports (same functions the CUDA kernels call), with the camera model as a runtime params field @@ -694,6 +724,14 @@ the engine level. by accident of the `valid` guard. - One `bytes_to_float` entry (elem_kind + scale + offset) covers all four raw converters. + - **Re-distort** (`launch_redistort_{byte_to_float,float,mask,normal}`, + mirroring ImageRedistort.cu): a COLMAP camera with no exact distortion + tier is fitted onto one, and the GT is resampled from the TRUE source + projection (`shaders/camera_source.slang`, shared with CUDA) instead of + from the fit. `redistort_{img,mask,normal}` cover the four launchers — + byte->float and float->float differ only in `elem_kind`. The fused + fisheye case never materializes the fitted camera: the wide warps take + the source projection directly under the `kFromSource` axis. - Parity: `warp_parity` (170K floats, one tight channel — everything here is deterministic per-pixel math; <= 0.0012% violations, isolated proj_nav valid-flip / nearest-rounding boundary pixels) and diff --git a/src/backend/vulkan/kernels/BackgroundShFwd.cpp b/src/backend/vulkan/kernels/BackgroundShFwd.cpp index 5ea5b7ec..42040140 100644 --- a/src/backend/vulkan/kernels/BackgroundShFwd.cpp +++ b/src/backend/vulkan/kernels/BackgroundShFwd.cpp @@ -44,14 +44,6 @@ int64_t _batch_count(const TorchTensorView& t, int64_t per_item) { return n / per_item; } -int _camera_model_int(const std::string& camera_model) { - auto cm = cmt(camera_model); - if (cm == (CameraModelType)-1) - throw std::runtime_error("Camera model " + camera_model + - " is not supported for skybox"); - return (int)cm; -} - } // namespace /* API definitions matching kernels/background/BackgroundSphericalHarmonics.cuh */ @@ -60,6 +52,7 @@ void render_background_sh_forward( int w, int h, std::string camera_model, + std::string distortion, int sh_degree, TorchTensorView viewmats, TorchTensorView intrins, @@ -71,10 +64,7 @@ void render_background_sh_forward( throw std::runtime_error( "render_background_sh_forward: sh_degree must be in [0, 4]"); - CameraModelType cam = cmt(camera_model); - if ((int)cam < 0 || (int)cam > 3) - throw std::runtime_error("Camera model " + camera_model + - " is not supported for skybox"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); int64_t b = _batch_count(out_color, (int64_t)h * w * 3); if (b * h * w == 0) return; @@ -91,9 +81,9 @@ void render_background_sh_forward( p.width = (uint32_t)w; p.height = (uint32_t)h; p.B = (uint32_t)b; - p.camera_model = (int32_t)cam; + p.camera_model = (int32_t)cd.cam; - backend::vk::SpecList spec{(uint32_t)sh_degree}; + backend::vk::SpecList spec{(uint32_t)sh_degree, cd.dist}; vkk::dispatch("background_sh.background_sh_fwd", spec, (uint32_t)((w + 127) / 128), (uint32_t)h, (uint32_t)b, &p, sizeof(p)); @@ -106,6 +96,7 @@ void render_background_sh_backward( int w, int h, std::string camera_model, + std::string distortion, int sh_degree, TorchTensorView viewmats, TorchTensorView intrins, @@ -118,6 +109,7 @@ void render_background_sh_backward( if (sh_degree < 0 || sh_degree > 4) throw std::runtime_error( "render_background_sh_backward: sh_degree must be in [0, 4]"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); int64_t b = _batch_count(out_color, (int64_t)h * w * 3); if (b * h * w == 0) return; if (_batch_count(viewmats, 16) != b || _batch_count(intrins, 4) != b) @@ -143,10 +135,10 @@ void render_background_sh_backward( p.width = (uint32_t)w; p.height = (uint32_t)h; p.B = (uint32_t)b; - p.camera_model = _camera_model_int(camera_model); + p.camera_model = (int32_t)cd.cam; vkk::dispatch("background_sh.background_sh_bwd", - backend::vk::SpecList{(uint32_t)sh_degree}, kBgBwdWgs, 1, 1, - &p, sizeof(p)); + backend::vk::SpecList{(uint32_t)sh_degree, cd.dist}, + kBgBwdWgs, 1, 1, &p, sizeof(p)); BackgroundShBwdReduceParams r{}; r.scratch = (uint64_t)scratch; diff --git a/src/backend/vulkan/kernels/FusedProjectionBwdOptim.cpp b/src/backend/vulkan/kernels/FusedProjectionBwdOptim.cpp index 651699b5..93ea15fe 100644 --- a/src/backend/vulkan/kernels/FusedProjectionBwdOptim.cpp +++ b/src/backend/vulkan/kernels/FusedProjectionBwdOptim.cpp @@ -53,7 +53,8 @@ void launch_fpbo_vk( std::vector& splats_world, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string& camera_model, const TorchTensorView& dist_coeffs, + const std::string& camera_model, const std::string& distortion, + const TorchTensorView& dist_coeffs, const DeviceVector& camera_ids, const DeviceVector& gaussian_ids, DeviceTensorFloatND& aabb, @@ -84,9 +85,7 @@ void launch_fpbo_vk( "fused_projection_bwd_optimizer: quantization_level must be " "0 or 1; got " + std::to_string(quantization_level)); - CameraModelType cam = cmt(camera_model); - if ((int)cam < 0 || (int)cam > 3) - throw std::runtime_error("Unsupported camera model"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); Vanilla3DGS<0>::WorldBuffer wb(splats_world); Vanilla3DGS<0>::WorldBuffer vwb( @@ -234,7 +233,7 @@ void launch_fpbo_vk( vkk::Fold f = vkk::fold_1d(N, 256); p.wgs_per_row = f.per_row; backend::vk::SpecList spec{ - (uint32_t)cam, + cd.cam, (uint32_t)sh_degree, antialiased ? 1u : 0u, level1 ? 16u : 0u, // kShValueBits: level 1 reads SH via the codec @@ -244,7 +243,8 @@ void launch_fpbo_vk( color_trust_linear ? 1u : 0u, level1 ? 1u : 0u, (level1 && non_sh.enabled) ? 1u : 0u, - vw_mask}; + vw_mask, + cd.dist}; vkk::dispatch_ring("fpbo.fpbo", spec, f.per_row, f.rows, 1, &p, sizeof(p)); } @@ -255,7 +255,8 @@ void launch_fpbo_vk( #define _FPBO_ARGS \ num_splats, max_sh_degree, splats_world, viewmats, intrins, \ - image_width, image_height, camera_model, dist_coeffs, camera_ids, \ + image_width, image_height, camera_model, distortion, dist_coeffs, \ + camera_ids, \ gaussian_ids, aabb, v_splats_world, v_splats_screen, \ g1_splats_world, g2_splats_world, sh_packed, sh_quant_bounds, \ sh_value_packed, sh_value_bounds, non_sh, radii, densify_score, \ @@ -271,7 +272,8 @@ void launch_fpbo_vk( std::vector splats_world, \ TorchTensorView viewmats, TorchTensorView intrins, \ const uint32_t image_width, const uint32_t image_height, \ - const std::string camera_model, const TorchTensorView dist_coeffs, \ + const std::string camera_model, const std::string distortion, \ + const TorchTensorView dist_coeffs, \ const DeviceVector camera_ids, \ const DeviceVector gaussian_ids, DeviceTensorFloatND aabb, \ const std::vector v_splats_world, \ @@ -298,7 +300,8 @@ void launch_fpbo_vk( static void _fpbo_call(bool eval3d, bool antialiased, _FPBO_PARAMS) { launch_fpbo_vk(eval3d, antialiased, num_splats, max_sh_degree, splats_world, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, + gaussian_ids, aabb, v_splats_world, v_splats_screen, g1_splats_world, g2_splats_world, sh_packed, sh_quant_bounds, sh_value_packed, sh_value_bounds, non_sh, radii, diff --git a/src/backend/vulkan/kernels/KernelCommon.h b/src/backend/vulkan/kernels/KernelCommon.h index ef36ab0e..5e10ea63 100644 --- a/src/backend/vulkan/kernels/KernelCommon.h +++ b/src/backend/vulkan/kernels/KernelCommon.h @@ -11,6 +11,7 @@ #include "backend/vulkan/VulkanPipelines.h" #include "backend/common/SortScan.h" +#include #include #include @@ -130,6 +131,42 @@ inline uint64_t or_fallback(const void* p) { return or_fallback((uint64_t)p); } +// The kCameraModel / kDistortion specialization values for a launch. Pairs +// outside the compiled set (camera_distortion_is_compiled in +// core/CameraModel.h) are rejected here rather than dispatched: the shaders' +// SS_DISPATCH_CAM_DIST folds them onto a neighbouring tier instead of carrying +// a dead arm, so an unchecked pair would silently project with the wrong +// distortion. +struct CamDistSpec { + uint32_t cam, dist; +}; + +inline CamDistSpec cam_dist_spec(const std::string& camera_model, + const std::string& distortion) { + const CameraModelType m = cmt(camera_model); + const CameraDistortionType d = cdt(distortion); + bool ok = (int)m >= 0 && (int)m <= 3 && (int)d >= 0 && (int)d <= 3; + if (ok) { + if (m == CameraModelType::FISHEYE || m == CameraModelType::EQUISOLID) + ok = d != CameraDistortionType::Rational; + else if (m == CameraModelType::EQUIRECTANGULAR) + ok = d == CameraDistortionType::None; + } + if (!ok) + throw std::runtime_error("Unsupported camera model / distortion tier"); + return {(uint32_t)m, (uint32_t)d}; +} + +// kDistortion alone, for launches whose camera model stays a runtime value and +// may differ from the one the coefficients were written for (the visualizer +// blits the dataset cameras through a free-navigation view camera). +inline uint32_t distortion_spec(const std::string& distortion) { + const CameraDistortionType d = cdt(distortion); + if ((int)d < 0 || (int)d > 3) + throw std::runtime_error("Unsupported camera distortion tier"); + return (uint32_t)d; +} + // Validation + resolution of the SH value-quant launch args shared by the // projection launchers (fwd, packed fwd; bwd reuses it in the training // phase). Returns the kShValueBits spec value (0 = fp32). Mirrors the CUDA diff --git a/src/backend/vulkan/kernels/Meshing.cpp b/src/backend/vulkan/kernels/Meshing.cpp index a2cd6ade..f395ad96 100644 --- a/src/backend/vulkan/kernels/Meshing.cpp +++ b/src/backend/vulkan/kernels/Meshing.cpp @@ -194,11 +194,13 @@ void fill_scene(P& p, const meshing::GpuScene& s) { p.sc_iso = s.iso; } -// Spec IDs for meshing_raster.slang: 0 = camera model. -backend::vk::SpecList camera_spec(int camera_model) { - if (camera_model < 0 || camera_model > 3) - throw std::runtime_error("meshing: unsupported camera model"); - return backend::vk::SpecList{(uint32_t)camera_model}; +// Spec IDs for meshing_raster.slang: 0 = camera model, 1 = distortion tier. +backend::vk::SpecList camera_spec(int camera_model, int distortion) { + if (camera_model < 0 || camera_model > 3 || distortion < 0 || + distortion > 3) + throw std::runtime_error( + "meshing: unsupported camera model / distortion tier"); + return backend::vk::SpecList{(uint32_t)camera_model, (uint32_t)distortion}; } // Ring dispatch of a flat 1D range (the params structs above the push floor). @@ -434,7 +436,8 @@ void launch_occ_combine(int n, float* occ, const float* occ_static) { void launch_sample_occ( const float* xyz, int n, const float* viewmat, const float* intrin, const float* dist, - int camera_model, const float3* moments, int W, int H, int k, + int camera_model, int distortion, + const float3* moments, int W, int H, int k, float* occ_kmin, int* cnt ) { if (n <= 0) return; @@ -451,8 +454,8 @@ void launch_sample_occ( p.H = (uint32_t)H; p.k = (uint32_t)k; vkk::dispatch_flat("meshing_raster.mesh_sample_occ", - camera_spec(camera_model), n, 256, &p, sizeof(p), - &p.wgs_per_row); + camera_spec(camera_model, distortion), n, 256, &p, + sizeof(p), &p.wgs_per_row); } void launch_finalize_occ(int n, const float* occ_kmin, const int* cnt, int k, @@ -464,14 +467,15 @@ void launch_finalize_occ(int n, const float* occ_kmin, const int* cnt, int k, p.occ = (uint64_t)occ; p.n = (uint32_t)n; p.k = (uint32_t)k; - vkk::dispatch_flat("meshing_raster.mesh_finalize_occ", camera_spec(0), n, + vkk::dispatch_flat("meshing_raster.mesh_finalize_occ", camera_spec(0, 0), n, 256, &p, sizeof(p), &p.wgs_per_row); } void launch_sample_color( const float* xyz, int n, const float* viewmat, const float* intrin, const float* dist, - int camera_model, const float3* moments, const float3* rgb_img, + int camera_model, int distortion, + const float3* moments, const float3* rgb_img, int W, int H, float3* num, float* den ) { if (n <= 0) return; @@ -488,8 +492,8 @@ void launch_sample_color( p.W = (uint32_t)W; p.H = (uint32_t)H; vkk::dispatch_flat("meshing_raster.mesh_sample_color", - camera_spec(camera_model), n, 256, &p, sizeof(p), - &p.wgs_per_row); + camera_spec(camera_model, distortion), n, 256, &p, + sizeof(p), &p.wgs_per_row); } void launch_finalize_color(int n, const float3* num, const float* den, @@ -500,14 +504,16 @@ void launch_finalize_color(int n, const float3* num, const float* den, p.den = (uint64_t)den; p.rgb = (uint64_t)rgb; p.n = (uint32_t)n; - vkk::dispatch_flat("meshing_raster.mesh_finalize_color", camera_spec(0), n, - 256, &p, sizeof(p), &p.wgs_per_row); + vkk::dispatch_flat("meshing_raster.mesh_finalize_color", + camera_spec(0, 0), n, 256, &p, sizeof(p), + &p.wgs_per_row); } void launch_sample_view_density( const float* xyz, int n, const float* viewmat, const float* intrin, const float* dist, - int camera_model, const float3* moments, int W, int H, float* dens + int camera_model, int distortion, + const float3* moments, int W, int H, float* dens ) { if (n <= 0) return; MeshViewDensityParams p{}; @@ -521,8 +527,8 @@ void launch_sample_view_density( p.W = (uint32_t)W; p.H = (uint32_t)H; vkk::dispatch_flat("meshing_raster.mesh_sample_view_density", - camera_spec(camera_model), n, 256, &p, sizeof(p), - &p.wgs_per_row); + camera_spec(camera_model, distortion), n, 256, &p, + sizeof(p), &p.wgs_per_row); } void launch_tri_prep( @@ -545,14 +551,14 @@ void launch_tri_prep( p.ext_y = inv_ext.y; p.ext_z = inv_ext.z; p.nf = (uint32_t)nf; - vkk::dispatch_flat("meshing_raster.mesh_tri_prep", camera_spec(0), nf, 256, - &p, sizeof(p), &p.wgs_per_row); + vkk::dispatch_flat("meshing_raster.mesh_tri_prep", camera_spec(0, 0), nf, + 256, &p, sizeof(p), &p.wgs_per_row); } void launch_cull( const float* verts, int nv, const int* faces, int nf, const float* viewmats, const float* intrins, const float* dist, - const int* Ws, const int* Hs, int camera_model, int C, + const int* Ws, const int* Hs, int camera_model, int distortion, int C, const float3* leafMin, const float3* leafMax, const int2* internal, const float3* nodeAABB, uint32_t* visible @@ -576,7 +582,8 @@ void launch_cull( p.nv = (uint32_t)nv; p.nf = (uint32_t)nf; p.C = (uint32_t)C; - dispatch_flat_ring("meshing_raster.mesh_cull", camera_spec(camera_model), + dispatch_flat_ring("meshing_raster.mesh_cull", + camera_spec(camera_model, distortion), nv, 256, &p, sizeof(p), &p.wgs_per_row); } diff --git a/src/backend/vulkan/kernels/PixelWiseRender.cpp b/src/backend/vulkan/kernels/PixelWiseRender.cpp index b488093f..3b5152f9 100644 --- a/src/backend/vulkan/kernels/PixelWiseRender.cpp +++ b/src/backend/vulkan/kernels/PixelWiseRender.cpp @@ -107,6 +107,7 @@ void rgb_to_srgb_forward( void depth_to_normal_forward( std::string camera_model, + std::string distortion, TorchTensorView intrins, TorchTensorView dist_coeffs, bool is_ray_depth, @@ -126,21 +127,24 @@ void depth_to_normal_forward( p.H = H; p.B = B; p.is_ray_depth = is_ray_depth ? 1u : 0u; - p.camera_model = (int32_t)cmt(camera_model); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); + p.camera_model = (int32_t)cd.cam; vkk::dispatch("pixel_wise_render.depth_to_normal_fwd", - backend::vk::SpecList{}, (W + 15) / 16, (H + 15) / 16, B, - &p, sizeof(p)); + backend::vk::SpecList{0u, cd.dist}, (W + 15) / 16, + (H + 15) / 16, B, &p, sizeof(p)); } void depth_to_normal_forward_tv( std::string camera_model, + std::string distortion, TorchTensorView intrins, TorchTensorView dist_coeffs, bool is_ray_depth, TorchTensorView depths, TorchTensorView normals ) { - depth_to_normal_forward(camera_model, intrins, dist_coeffs, is_ray_depth, + depth_to_normal_forward(camera_model, distortion, intrins, dist_coeffs, + is_ray_depth, DeviceTensor3D(depths), DeviceTensor3D(normals)); } diff --git a/src/backend/vulkan/kernels/PixelWiseTrain.cpp b/src/backend/vulkan/kernels/PixelWiseTrain.cpp index 6e832cf3..d96a9233 100644 --- a/src/backend/vulkan/kernels/PixelWiseTrain.cpp +++ b/src/backend/vulkan/kernels/PixelWiseTrain.cpp @@ -175,6 +175,7 @@ void overexposure_grad_add( void depth_to_normal_backward( std::string camera_model, + std::string distortion, TorchTensorView intrins, TorchTensorView dist_coeffs, bool is_ray_depth, @@ -196,13 +197,16 @@ void depth_to_normal_backward( p.H = H; p.B = B; p.is_ray_depth = is_ray_depth ? 1u : 0u; - p.camera_model = (int32_t)cmt(camera_model); - vkk::dispatch("pixel_wise_train.d2n_bwd", backend::vk::SpecList{}, - (W + 15) / 16, (H + 15) / 16, B, &p, sizeof(p)); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); + p.camera_model = (int32_t)cd.cam; + vkk::dispatch("pixel_wise_train.d2n_bwd", + backend::vk::SpecList{0u, cd.dist}, (W + 15) / 16, + (H + 15) / 16, B, &p, sizeof(p)); } void depth_to_normal_backward_tv( std::string camera_model, + std::string distortion, TorchTensorView intrins, TorchTensorView dist_coeffs, bool is_ray_depth, @@ -210,7 +214,8 @@ void depth_to_normal_backward_tv( TorchTensorView v_normals, TorchTensorView v_depths ) { - depth_to_normal_backward(camera_model, intrins, dist_coeffs, is_ray_depth, + depth_to_normal_backward(camera_model, distortion, intrins, dist_coeffs, + is_ray_depth, DeviceTensor3D(depths), DeviceTensor3D(v_normals), DeviceTensor3D(v_depths)); @@ -218,6 +223,7 @@ void depth_to_normal_backward_tv( void linear_depth_to_ray_depth_inplace( std::string camera_model, + std::string distortion, TorchTensorView intrins, TorchTensorView dist_coeffs, int image_width, int image_height, @@ -234,8 +240,10 @@ void linear_depth_to_ray_depth_inplace( p.W = (uint32_t)w; p.H = (uint32_t)h; p.B = (uint32_t)b; - p.camera_model = (int32_t)cmt(camera_model); - vkk::dispatch("pixel_wise_train.lin_to_ray_depth", backend::vk::SpecList{}, + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); + p.camera_model = (int32_t)cd.cam; + vkk::dispatch("pixel_wise_train.lin_to_ray_depth", + backend::vk::SpecList{0u, cd.dist}, (uint32_t)((w + 127) / 128), (uint32_t)h, (uint32_t)b, &p, sizeof(p)); } diff --git a/src/backend/vulkan/kernels/ProjectionBwd.cpp b/src/backend/vulkan/kernels/ProjectionBwd.cpp index 93bd5400..b6efd360 100644 --- a/src/backend/vulkan/kernels/ProjectionBwd.cpp +++ b/src/backend/vulkan/kernels/ProjectionBwd.cpp @@ -64,7 +64,8 @@ void launch_projection_bwd_vk( const int max_sh_degree, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string& camera_model, const TorchTensorView& dist_coeffs, + const std::string& camera_model, const std::string& distortion, + const TorchTensorView& dist_coeffs, const DeviceVector& camera_ids, const DeviceVector& gaussian_ids, const DeviceTensor2D& aabb, @@ -83,9 +84,7 @@ void launch_projection_bwd_vk( sh_value_bits, sh_bounds_stride, &q_packed, &q_bounds, &q_stride); - CameraModelType cam = cmt(camera_model); - if ((int)cam < 0 || (int)cam > 3) - throw std::runtime_error("Unsupported camera model"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); // WorldBuffer layout is identical for 3DGS/Mip/3DGUT (TensorArray<6>). Vanilla3DGS<0>::WorldBuffer wb( @@ -113,9 +112,10 @@ void launch_projection_bwd_vk( const uint64_t total = (uint64_t)C * (uint64_t)N; vkk::Fold f = vkk::fold_1d(total, 128); - backend::vk::SpecList spec{(uint32_t)cam, (uint32_t)sh_degree, + backend::vk::SpecList spec{cd.cam, (uint32_t)sh_degree, antialiased ? 1u : 0u, spec_bits, - packed ? 1u : 0u, viewmat_grad ? 1u : 0u}; + packed ? 1u : 0u, viewmat_grad ? 1u : 0u, + cd.dist}; if (!eval3d) { Vanilla3DGS<0>::ScreenBuffer vsb( @@ -215,6 +215,7 @@ void projection_3dgs_backward( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -231,7 +232,7 @@ void projection_3dgs_backward( launch_projection_bwd_vk( /*eval3d=*/false, /*antialiased=*/false, num_splats, splats_world, max_sh_degree, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, v_viewmats, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_bounds_stride); } @@ -245,6 +246,7 @@ void projection_mip_backward( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -261,7 +263,7 @@ void projection_mip_backward( launch_projection_bwd_vk( /*eval3d=*/false, /*antialiased=*/true, num_splats, splats_world, max_sh_degree, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, v_viewmats, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_bounds_stride); } @@ -275,6 +277,7 @@ void projection_3dgut_backward( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -291,7 +294,7 @@ void projection_3dgut_backward( launch_projection_bwd_vk( /*eval3d=*/true, /*antialiased=*/false, num_splats, splats_world, max_sh_degree, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, v_viewmats, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_bounds_stride); } diff --git a/src/backend/vulkan/kernels/ProjectionBwdQuantGrad.cpp b/src/backend/vulkan/kernels/ProjectionBwdQuantGrad.cpp index 3f40bfcf..e234ffde 100644 --- a/src/backend/vulkan/kernels/ProjectionBwdQuantGrad.cpp +++ b/src/backend/vulkan/kernels/ProjectionBwdQuantGrad.cpp @@ -52,7 +52,8 @@ void launch_projection_qgrad_vk( const std::vector& splats_world, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string& camera_model, const TorchTensorView& dist_coeffs, + const std::string& camera_model, const std::string& distortion, + const TorchTensorView& dist_coeffs, const DeviceVector& camera_ids, const DeviceVector& gaussian_ids, const DeviceTensor2D& aabb, @@ -71,9 +72,7 @@ void launch_projection_qgrad_vk( sh_value_bits, sh_value_bounds_stride, &q_packed, &q_bounds, &q_stride); - CameraModelType cam = cmt(camera_model); - if ((int)cam < 0 || (int)cam > 3) - throw std::runtime_error("Unsupported camera model"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); Vanilla3DGS<0>::WorldBuffer wb( const_cast&>(splats_world)); @@ -168,10 +167,11 @@ void launch_projection_qgrad_vk( vkk::Fold f = vkk::fold_1d(N, 256); p.wgs_per_row = f.per_row; - backend::vk::SpecList spec{(uint32_t)cam, (uint32_t)sh_degree, + backend::vk::SpecList spec{cd.cam, (uint32_t)sh_degree, antialiased ? 1u : 0u, spec_bits, packed ? 1u : 0u, eval3d ? 1u : 0u, - gq_mask, world_grad_add ? 1u : 0u}; + gq_mask, world_grad_add ? 1u : 0u, + cd.dist}; vkk::dispatch_ring("projection_qgrad.projection_qgrad", spec, f.per_row, f.rows, 1, &p, sizeof(p)); } @@ -189,6 +189,7 @@ void projection_3dgs_backward_quantgrad( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -205,7 +206,7 @@ void projection_3dgs_backward_quantgrad( launch_projection_qgrad_vk( /*eval3d=*/false, /*antialiased=*/false, num_splats, max_sh_degree, splats_world, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, gq, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_value_bounds_stride); @@ -220,6 +221,7 @@ void projection_mip_backward_quantgrad( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -236,7 +238,7 @@ void projection_mip_backward_quantgrad( launch_projection_qgrad_vk( /*eval3d=*/false, /*antialiased=*/true, num_splats, max_sh_degree, splats_world, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, gq, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_value_bounds_stride); @@ -251,6 +253,7 @@ void projection_3dgut_backward_quantgrad( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -267,7 +270,7 @@ void projection_3dgut_backward_quantgrad( launch_projection_qgrad_vk( /*eval3d=*/true, /*antialiased=*/false, num_splats, max_sh_degree, splats_world, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, gq, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_value_bounds_stride); diff --git a/src/backend/vulkan/kernels/ProjectionFwd.cpp b/src/backend/vulkan/kernels/ProjectionFwd.cpp index 3fd9196d..85aa8c1f 100644 --- a/src/backend/vulkan/kernels/ProjectionFwd.cpp +++ b/src/backend/vulkan/kernels/ProjectionFwd.cpp @@ -1,7 +1,7 @@ // Vulkan implementation of the projection-forward launch API // (kernels/projection/ProjectionFwd.cuh). Mirrors ProjectionFwd.cu's launcher logic; the // device work runs shaders/projection_fwd.slang with camera model / -// SH degree / antialiased as specialization constants. +// distortion tier / SH degree / antialiased as specialization constants. #include @@ -56,7 +56,8 @@ launch_projection_fwd_vk( const int max_sh_degree, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string& camera_model, const TorchTensorView& dist_coeffs, + const std::string& camera_model, const std::string& distortion, + const TorchTensorView& dist_coeffs, DeviceVector& radii, const std::optional& sh_value_packed, const std::optional& sh_value_bounds, @@ -70,9 +71,7 @@ launch_projection_fwd_vk( sh_value_bits, sh_bounds_stride, &q_packed, &q_bounds, &q_stride); - CameraModelType cam = cmt(camera_model); - if ((int)cam < 0 || (int)cam > 3) - throw std::runtime_error("Unsupported camera model"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); Vanilla3DGS<0>::WorldBuffer wb(in_splats); int sh_degree = wb.sh_degree(); @@ -123,8 +122,8 @@ launch_projection_fwd_vk( p.height = image_height; p.wgs_per_row = per_row; - backend::vk::SpecList spec{(uint32_t)cam, (uint32_t)sh_degree, - antialiased ? 1u : 0u, spec_bits}; + backend::vk::SpecList spec{cd.cam, (uint32_t)sh_degree, + antialiased ? 1u : 0u, spec_bits, 0u, cd.dist}; vkk::dispatch_ring("projection_fwd.projection_fwd_3dgs", spec, per_row, rows, 1, &p, sizeof(p)); @@ -142,7 +141,8 @@ std::tuple< const std::vector &in_splats, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string camera_model, const TorchTensorView dist_coeffs, + const std::string camera_model, const std::string distortion, + const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, const std::optional sh_value_bounds, @@ -153,7 +153,7 @@ std::tuple< return launch_projection_fwd_vk( /*antialiased=*/false, num_splats, in_splats, max_sh_degree, viewmats, intrins, image_width, image_height, camera_model, - dist_coeffs, radii, sh_value_packed, sh_value_bounds, + distortion, dist_coeffs, radii, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_bounds_stride); } @@ -164,7 +164,8 @@ std::tuple< const std::vector &in_splats, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string camera_model, const TorchTensorView dist_coeffs, + const std::string camera_model, const std::string distortion, + const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, const std::optional sh_value_bounds, @@ -175,7 +176,7 @@ std::tuple< return launch_projection_fwd_vk( /*antialiased=*/true, num_splats, in_splats, max_sh_degree, viewmats, intrins, image_width, image_height, camera_model, - dist_coeffs, radii, sh_value_packed, sh_value_bounds, + distortion, dist_coeffs, radii, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_bounds_stride); } @@ -186,7 +187,8 @@ std::tuple< const std::vector &in_splats, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string camera_model, const TorchTensorView dist_coeffs, + const std::string camera_model, const std::string distortion, + const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, const std::optional sh_value_bounds, @@ -201,9 +203,7 @@ std::tuple< sh_value_bits, sh_bounds_stride, &q_packed, &q_bounds, &q_stride); - CameraModelType cam = cmt(camera_model); - if ((int)cam < 0 || (int)cam > 3) - throw std::runtime_error("Unsupported camera model"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); const int64_t N = num_splats; Vanilla3DGUT<0>::WorldBuffer wb(in_splats); @@ -253,8 +253,8 @@ std::tuple< p.height = image_height; p.wgs_per_row = per_row; - backend::vk::SpecList spec{(uint32_t)cam, (uint32_t)sh_degree, 0u, - spec_bits}; + backend::vk::SpecList spec{cd.cam, (uint32_t)sh_degree, 0u, spec_bits, 0u, + cd.dist}; vkk::dispatch_ring("projection_fwd.projection_fwd_3dgut", spec, per_row, rows, 1, &p, sizeof(p)); diff --git a/src/backend/vulkan/kernels/ProjectionPackedFwd.cpp b/src/backend/vulkan/kernels/ProjectionPackedFwd.cpp index 3e484114..baedf1dc 100644 --- a/src/backend/vulkan/kernels/ProjectionPackedFwd.cpp +++ b/src/backend/vulkan/kernels/ProjectionPackedFwd.cpp @@ -51,7 +51,8 @@ launch_projection_packed_vk( const int max_sh_degree, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string& camera_model, const TorchTensorView& dist_coeffs, + const std::string& camera_model, const std::string& distortion, + const TorchTensorView& dist_coeffs, DeviceVector& radii, const std::optional& sh_value_packed, const std::optional& sh_value_bounds, @@ -65,9 +66,7 @@ launch_projection_packed_vk( sh_value_bits, sh_bounds_stride, &q_packed, &q_bounds, &q_stride); - CameraModelType cam = cmt(camera_model); - if ((int)cam < 0 || (int)cam > 3) - throw std::runtime_error("Unsupported camera model"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); Vanilla3DGS<0>::WorldBuffer wb(in_splats); int sh_degree = wb.sh_degree(); @@ -101,10 +100,11 @@ launch_projection_packed_vk( mp.wgs_per_row = per_row; // Spec IDs: 0 = camera model, 1 = SH degree (unused by the mask), - // 2 = antialiased, 3 = SH value bits (unused by the mask), 4 = eval3d. - backend::vk::SpecList spec{(uint32_t)cam, (uint32_t)sh_degree, + // 2 = antialiased, 3 = SH value bits (unused by the mask), 4 = eval3d, + // 5 = distortion tier. + backend::vk::SpecList spec{cd.cam, (uint32_t)sh_degree, antialiased ? 1u : 0u, spec_bits, - eval3d ? 1u : 0u}; + eval3d ? 1u : 0u, cd.dist}; vkk::dispatch("projection_fwd.projection_packed_mask", spec, per_row, rows, 1, &mp, sizeof(mp)); @@ -197,6 +197,7 @@ std::tuple< \ const uint32_t image_width, \ const uint32_t image_height, \ const std::string camera_model, \ + const std::string distortion, \ const TorchTensorView dist_coeffs, \ DeviceVector radii, \ const std::optional sh_value_packed, \ @@ -208,7 +209,7 @@ std::tuple< \ return launch_projection_packed_vk( \ eval3d, antialiased, num_splats, in_splats, max_sh_degree, \ viewmats, intrins, image_width, image_height, camera_model, \ - dist_coeffs, radii, sh_value_packed, sh_value_bounds, \ + distortion, dist_coeffs, radii, sh_value_packed, sh_value_bounds, \ num_sh_buffer, sh_value_bits, sh_bounds_stride); \ } diff --git a/src/backend/vulkan/kernels/RasterizeBwd.cpp b/src/backend/vulkan/kernels/RasterizeBwd.cpp index 448fba2d..15cb9099 100644 --- a/src/backend/vulkan/kernels/RasterizeBwd.cpp +++ b/src/backend/vulkan/kernels/RasterizeBwd.cpp @@ -190,6 +190,7 @@ std::tuple< TorchTensorView viewmats, TorchTensorView intrins, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, const uint32_t image_width, @@ -212,9 +213,7 @@ std::tuple< bool need_viewmat_grad ) { (void)loss_map; // declared but unused by the CUDA kernel as well - CameraModelType cam = cmt(camera_model); - if ((int)cam < 0 || (int)cam > 3) - throw std::runtime_error("Unsupported camera model"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); const uint32_t spec_dist = dist_spec_bwd(dist_type); const bool aw = accum_weight_map.data_ptr() != nullptr; const bool md = v_median.data_ptr() != nullptr; @@ -308,11 +307,12 @@ std::tuple< p.tile_height = tile_height; // Spec IDs: cam(0), dist(1), median(2), accum(3), viewmat(4), - // packed(5). + // packed(5), distortion tier(6). backend::vk::SpecList spec{ - (uint32_t)cam, spec_dist, + cd.cam, spec_dist, md ? 1u : 0u, aw ? 1u : 0u, - need_viewmat_grad ? 1u : 0u, packed ? 1u : 0u}; + need_viewmat_grad ? 1u : 0u, packed ? 1u : 0u, + cd.dist}; vkk::dispatch_ring("rasterize_bwd.rasterize_bwd_3dgut", spec, I, tile_height * 2, tile_width * 2, &p, sizeof(p)); } diff --git a/src/backend/vulkan/kernels/RasterizeFwd.cpp b/src/backend/vulkan/kernels/RasterizeFwd.cpp index 1441b246..fa0358e8 100644 --- a/src/backend/vulkan/kernels/RasterizeFwd.cpp +++ b/src/backend/vulkan/kernels/RasterizeFwd.cpp @@ -206,6 +206,7 @@ std::tuple< TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB const uint32_t image_width, @@ -215,9 +216,7 @@ std::tuple< DistortionType dist_type, bool output_median ) { - CameraModelType cam = cmt(camera_model); - if ((int)cam < 0 || (int)cam > 3) - throw std::runtime_error("Unsupported camera model"); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); const int64_t batch = tile_offsets.size<0>(); const uint32_t tile_height = (uint32_t)tile_offsets.size<1>(); @@ -261,10 +260,10 @@ std::tuple< p.tile_height = tile_height; // Spec IDs: 0 = camera model, 1 = dist type, 2 = median, - // 3 = kRasterPacked (gaussian_ids present). - backend::vk::SpecList spec{(uint32_t)cam, dist_spec(dist_type), + // 3 = kRasterPacked (gaussian_ids present), 4 = distortion tier. + backend::vk::SpecList spec{cd.cam, dist_spec(dist_type), output_median ? 1u : 0u, - gaussian_ids.data_ptr() ? 1u : 0u}; + gaussian_ids.data_ptr() ? 1u : 0u, cd.dist}; dispatch_raster("rasterize_fwd.rasterize_fwd_3dgut", spec, (uint32_t)batch, tile_width, tile_height, &p, sizeof(p)); diff --git a/src/backend/vulkan/kernels/RasterizeMomentsFwd.cpp b/src/backend/vulkan/kernels/RasterizeMomentsFwd.cpp index fdeb47ee..49e5003b 100644 --- a/src/backend/vulkan/kernels/RasterizeMomentsFwd.cpp +++ b/src/backend/vulkan/kernels/RasterizeMomentsFwd.cpp @@ -38,6 +38,7 @@ void rasterize_moments_3dgut_fwd( TorchTensorView viewmats, TorchTensorView intrins, const std::string& camera_model, + const std::string& distortion, TorchTensorView dist_coeffs, DeviceTensor2D aabb, uint32_t image_width, @@ -47,9 +48,8 @@ void rasterize_moments_3dgut_fwd( float3* render_moments, float3* render_rgb ) { - CameraModelType cam = cmt(camera_model); - if (cam != CameraModelType::PINHOLE && cam != CameraModelType::FISHEYE && - cam != CameraModelType::EQUISOLID) + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); + if (cd.cam == (uint32_t)CameraModelType::EQUIRECTANGULAR) throw std::runtime_error( "rasterize_moments_3dgut_fwd: unsupported camera model"); @@ -86,10 +86,11 @@ void rasterize_moments_3dgut_fwd( p.tile_width = tile_width; p.tile_height = tile_height; - // Spec IDs: 0 = camera model, 1 = kRasterPacked, 2 = kOutputRgb. - backend::vk::SpecList spec{(uint32_t)cam, + // Spec IDs: 0 = camera model, 1 = kRasterPacked, 2 = kOutputRgb, + // 3 = distortion tier. + backend::vk::SpecList spec{cd.cam, gaussian_ids.data_ptr() ? 1u : 0u, - render_rgb ? 1u : 0u}; + render_rgb ? 1u : 0u, cd.dist}; vkk::dispatch_ring("rasterize_moments.rasterize_moments_3dgut", spec, I, tile_height * MACRO_TILE_SIZE_Y, tile_width * MACRO_TILE_SIZE_X, &p, sizeof(p)); diff --git a/src/backend/vulkan/kernels/Visualizer.cpp b/src/backend/vulkan/kernels/Visualizer.cpp index e04cea9e..63704b5e 100644 --- a/src/backend/vulkan/kernels/Visualizer.cpp +++ b/src/backend/vulkan/kernels/Visualizer.cpp @@ -283,8 +283,9 @@ RootBox compute_root_box(const void* root_aabb_dev) { void fill_frustums(int64_t n, const void* intrins, const void* widths, const void* heights, const void* camera_models, - const void* dist_coeffs, const void* c2w, float size, - void* lss_buffer, void* tri_buffer) { + const void* dist_coeffs, uint32_t dist_spec, + const void* c2w, float size, void* lss_buffer, + void* tri_buffer) { VisFrustumParams p{}; p.intrins = (uint64_t)intrins; p.widths = (uint64_t)widths; @@ -296,8 +297,9 @@ void fill_frustums(int64_t n, const void* intrins, const void* widths, p.tri_buffer = (uint64_t)tri_buffer; p.size = size; p.N = (uint32_t)n; - vkk::dispatch("visualizer.vis_fill_frustum", backend::vk::SpecList{}, - (uint32_t)n, 1, 1, &p, sizeof(p)); + vkk::dispatch("visualizer.vis_fill_frustum", + backend::vk::SpecList{0u, dist_spec}, (uint32_t)n, 1, 1, &p, + sizeof(p)); } // root_aabb: u32[6] mapped; min words init 0xffffffff, max words 0. @@ -347,7 +349,7 @@ struct BlitGeom { void run_blit(const TorchTensorView& render_rgbs, const TorchTensorView& render_depths, const TorchTensorView& render_alphas, int view_camera_model, - const TorchTensorView& view_intrins, + uint32_t dist_spec, const TorchTensorView& view_intrins, const TorchTensorView& view_viewmat, const TorchTensorView& view_dist_coeffs, const BlitGeom& geom, const void* thumbnails, int thumb_w, int thumb_h, @@ -396,7 +398,7 @@ void run_blit(const TorchTensorView& render_rgbs, if (!backend::vk::params_alloc(sizeof(p), ¶ms_addr, ¶ms_mapped)) throw std::runtime_error("Vulkan backend: params ring failed"); std::memcpy(params_mapped, &p, sizeof(p)); - vkk::dispatch("visualizer.vis_blit", backend::vk::SpecList{}, + vkk::dispatch("visualizer.vis_blit", backend::vk::SpecList{0u, dist_spec}, (uint32_t)((w + 7) / 8), (uint32_t)((h + 3) / 4), 1, ¶ms_addr, sizeof(params_addr)); @@ -411,7 +413,7 @@ void run_blit(const TorchTensorView& render_rgbs, /* ---- engine-cached BVH build (mirrors _viewer_build_bvh) ---- */ -void _viewer_build_bvh() { +void _viewer_build_bvh(uint32_t dist_spec) { auto& v = engine().viewer; int64_t n = v.N_post; @@ -426,8 +428,9 @@ void _viewer_build_bvh() { fill_frustums(n, v.d_intrins.data_ptr(), v.d_widths.data_ptr(), v.d_heights.data_ptr(), v.d_camera_models.data_ptr(), - v.d_dist_coeffs.data_ptr(), v.d_camera_to_worlds.data_ptr(), - v.camera_size, lss_buffer, tri_buffer); + v.d_dist_coeffs.data_ptr(), dist_spec, + v.d_camera_to_worlds.data_ptr(), v.camera_size, lss_buffer, + tri_buffer); if (v.num_overlay > 0) backend::memcpy_sync(lss_buffer + (size_t)num_cam_lss * 2, @@ -557,7 +560,8 @@ void engine_viewer_init( _hv_to_dv(PoolSlot::ViewerCmodels, camera_models); v.d_dist_coeffs = _hv_to_dv( PoolSlot::ViewerDist, - TorchTensorView(std::get<0>(dist_coeffs), 4, {N * 10LL})); + TorchTensorView(std::get<0>(dist_coeffs), 4, + {N * (int64_t)kCameraDistortionParams})); v.d_camera_to_worlds = _hv_to_dv( PoolSlot::ViewerC2w, TorchTensorView(std::get<0>(camera_to_worlds), 4, {N * 12LL})); @@ -677,6 +681,7 @@ void engine_blit_view( TorchTensorView render_depth, TorchTensorView render_alpha, int view_camera_model, + std::string distortion, TorchTensorView view_intrins, TorchTensorView view_viewmat, TorchTensorView view_dist_coeffs, @@ -688,6 +693,7 @@ void engine_blit_view( float grid_target_z, TorchTensorView out_rgb) { + const uint32_t dist_spec = vkk::distortion_spec(distortion); std::lock_guard _vlock(viewer_mutex()); auto& v = engine().viewer; if (!v.initialized) { @@ -715,7 +721,7 @@ void engine_blit_view( BlitGeom geom; if (show_training_cameras || show_overlay) { if (!v.bvh_built || v.bvh_camera_size != v.camera_size) - _viewer_build_bvh(); + _viewer_build_bvh(dist_spec); geom.lss_buffer = DevicePool::global().acquire( PoolSlot::ViewerLss, (size_t)v.bvh_num_lss * 2); geom.lss_nodes = v.bvh_lss_nodes_ptr; @@ -733,7 +739,7 @@ void engine_blit_view( } run_blit(render_buffer, render_depth, render_alpha, view_camera_model, - view_intrins, view_viewmat, view_dist_coeffs, geom, + dist_spec, view_intrins, view_viewmat, view_dist_coeffs, geom, v.thumbnails.data_ptr(), VIEWER_THUMBNAIL_SIZE, VIEWER_THUMBNAIL_SIZE, min_max, out_rgb); } @@ -744,6 +750,7 @@ void blit_train_cameras_tensor( TorchTensorView render_depths, TorchTensorView render_alphas, const int view_camera_model, + std::string distortion, TorchTensorView view_intrins, TorchTensorView view_viewmat, TorchTensorView view_dist_coeffs, @@ -758,6 +765,7 @@ void blit_train_cameras_tensor( bool show_training_cameras, TorchTensorView out_rgb ) { + const uint32_t dist_spec = vkk::distortion_spec(distortion); auto& rgb_shape = std::get<2>(render_rgbs); int64_t h = rgb_shape[0], w = rgb_shape[1], c = rgb_shape[2]; int64_t n = std::get<2>(intrins)[0]; @@ -773,7 +781,7 @@ void blit_train_cameras_tensor( if (!show_training_cameras) { BlitGeom geom; // no frusta, no overlay run_blit(render_rgbs, render_depths, render_alphas, - view_camera_model, view_intrins, view_viewmat, + view_camera_model, dist_spec, view_intrins, view_viewmat, view_dist_coeffs, geom, (void*)std::get<0>(thumbnails), thumb_w, thumb_h, min_max, out_rgb); return; @@ -789,7 +797,7 @@ void blit_train_cameras_tensor( (const void*)std::get<0>(widths), (const void*)std::get<0>(heights), (const void*)std::get<0>(camera_models), - (const void*)std::get<0>(dist_coeffs), + (const void*)std::get<0>(dist_coeffs), dist_spec, (const void*)std::get<0>(camera_to_worlds), camera_size, lss_buffer, tri_buffer); @@ -815,7 +823,7 @@ void blit_train_cameras_tensor( geom.show_cams = true; geom.show_overlay = false; run_blit(render_rgbs, render_depths, render_alphas, view_camera_model, - view_intrins, view_viewmat, view_dist_coeffs, geom, + dist_spec, view_intrins, view_viewmat, view_dist_coeffs, geom, (void*)std::get<0>(thumbnails), thumb_w, thumb_h, min_max, out_rgb); } diff --git a/src/backend/vulkan/kernels/Warp.cpp b/src/backend/vulkan/kernels/Warp.cpp index f8ac4e76..159feb09 100644 --- a/src/backend/vulkan/kernels/Warp.cpp +++ b/src/backend/vulkan/kernels/Warp.cpp @@ -1,7 +1,8 @@ -// Vulkan implementation of the dataset GT warp + byte->float conversion -// launch APIs (the launch_warp_* section of kernels/pixelwise/PixelWise.cuh and the -// uint8/16_*_to_float_raw converters of EngineInternal.h). Mirrors the -// CUDA launchers in kernels/pixelwise/ImageWarp.cu; the device work runs +// Vulkan implementation of the dataset GT warp / re-distort + byte->float +// conversion launch APIs (the launch_warp_* and launch_redistort_* sections of +// kernels/pixelwise/PixelWise.cuh and the uint8/16_*_to_float_raw converters of +// EngineInternal.h). Mirrors the CUDA launchers in +// kernels/pixelwise/ImageWarp.cu + ImageRedistort.cu; the device work runs // shaders/warp.slang. // // All launchers take raw device pointers (the engine's DataManager path @@ -24,26 +25,30 @@ constexpr int kElemF32 = 2; // Mirrors WarpParams in shaders/warp.slang. struct WarpParams { - uint64_t intrins, dist_coeffs, src, dst, axes; + uint64_t intrins, dist_coeffs, source_models, source_params; + uint64_t src, dst, axes; int32_t B, Hin, Win, C; int32_t K, Hout, Wout; int32_t elem_kind, camera_model; - int32_t in_H, in_W; + int32_t ref_H, ref_W; int32_t ray_depth; - float norm_inv, decode_off; + float norm_inv, decode_off, invalid; + int32_t _pad0; }; -static_assert(sizeof(WarpParams) == 5 * 8 + 14 * 4, +static_assert(sizeof(WarpParams) == 7 * 8 + 16 * 4, "params layout must match the slang struct"); // Mirrors WarpMaskParams in shaders/warp.slang. struct WarpMaskParams { - uint64_t intrins, dist_coeffs, src, dst, axes; + uint64_t intrins, dist_coeffs, source_models, source_params; + uint64_t src, dst, axes; int32_t B, Hin, Win; int32_t K, Hout, Wout; int32_t camera_model; + int32_t ref_H, ref_W; uint32_t wgs_per_row; }; -static_assert(sizeof(WarpMaskParams) == 5 * 8 + 8 * 4, +static_assert(sizeof(WarpMaskParams) == 7 * 8 + 10 * 4, "params layout must match the slang struct"); // Mirrors BytesToFloatParams in shaders/warp.slang. @@ -58,17 +63,25 @@ struct BytesToFloatParams { static_assert(sizeof(BytesToFloatParams) == 2 * 8 + 6 * 4, "params layout must match the slang struct"); +// Source pointers, which the ordinary (non-re-distorting) path leaves null. +struct SourceCam { + const int* models = nullptr; + const float* params = nullptr; +}; + // Common WarpParams assembly for the image / depth / normal warps. WarpParams make_warp_params(const float* d_intrins, const float* d_dist, - const void* d_src, float* d_dst, + SourceCam src_cam, const void* d_src, float* d_dst, const float* d_axes, int B, int Hin, int Win, int C, int K, int Hout, int Wout, int elem_kind, - CameraModelType cm, int in_H, int in_W, + CameraModelType cm, int ref_H, int ref_W, bool ray_depth, float norm_inv, float decode_off) { WarpParams p{}; p.intrins = vkk::or_fallback(d_intrins); p.dist_coeffs = vkk::or_fallback(d_dist); + p.source_models = vkk::or_fallback(src_cam.models); + p.source_params = vkk::or_fallback(src_cam.params); p.src = vkk::or_fallback(d_src); p.dst = (uint64_t)d_dst; p.axes = vkk::or_fallback(d_axes); @@ -76,7 +89,7 @@ WarpParams make_warp_params(const float* d_intrins, const float* d_dist, p.K = K; p.Hout = Hout; p.Wout = Wout; p.elem_kind = elem_kind; p.camera_model = (int)cm; - p.in_H = in_H; p.in_W = in_W; + p.ref_H = ref_H; p.ref_W = ref_W; p.ray_depth = ray_depth ? 1 : 0; p.norm_inv = norm_inv; p.decode_off = decode_off; @@ -85,15 +98,33 @@ WarpParams make_warp_params(const float* d_intrins, const float* d_dist, // (ceil(Wout/16), ceil(Hout/16), B) grid of flat-256 workgroups (16x16 // logical tiles), mirroring the CUDA _LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1). -void dispatch_warp(const char* entry, const WarpParams& p) { +void dispatch_warp(const char* entry, const WarpParams& p, + const backend::vk::SpecList& spec) { if ((int64_t)p.B * p.K * p.Hout * p.Wout <= 0) return; if (p.B > 65535) throw std::runtime_error("warp: batch exceeds grid limit"); - vkk::dispatch(entry, {}, (uint32_t)((p.Wout + 15) / 16), + vkk::dispatch(entry, spec, (uint32_t)((p.Wout + 15) / 16), (uint32_t)((p.Hout + 15) / 16), (uint32_t)p.B, &p, sizeof(p)); } +// Re-distort of one modality, whose input and output grids are independent of +// each other and of the (ref_H, ref_W) intrinsics reference. +WarpParams make_redistort_params(const float* d_intrins, const float* d_dist, + SourceCam src_cam, const void* d_src, + float* d_dst, int B, int in_H, int in_W, + int C, int out_H, int out_W, int elem_kind, + CameraModelType cm, int ref_H, int ref_W, + float norm_inv, float decode_off, + float invalid) { + WarpParams p = make_warp_params(d_intrins, d_dist, src_cam, d_src, d_dst, + nullptr, B, in_H, in_W, C, 1, out_H, out_W, + elem_kind, cm, ref_H, ref_W, false, + norm_inv, decode_off); + p.invalid = invalid; + return p; +} + void run_bytes_to_float(const void* d_in, float* d_out, int64_t total, int elem_kind, float scale, float offset) { BytesToFloatParams p{}; @@ -107,6 +138,11 @@ void run_bytes_to_float(const void* d_in, float* d_out, int64_t total, &p.wgs_per_row); } +// kFromSource: the CUDA _SS_DISPATCH_SOURCE predicate. +uint32_t from_source_spec(const int* d_source_models) { + return d_source_models != nullptr ? 1u : 0u; +} + int resolve_depth_kind(uint32_t elem_size, const char* who) { if (elem_size == 2) return kElemU16; if (elem_size == 4) return kElemF32; @@ -162,20 +198,27 @@ void uint16_image_to_float_tensor(DeviceTensor3D img_in, void launch_warp_byte_to_float_wide( std::string camera_model, + std::string distortion, const float* d_intrins, const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, const void* d_byte, bool input_is_u16, int B, int Hin, int Win, int C, float* d_float_out, int K, int Hout, int Wout, const float* d_axes) { + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); dispatch_warp("warp.warp_img_wide", make_warp_params( - d_intrins, d_dist_coeffs, d_byte, d_float_out, d_axes, + d_intrins, d_dist_coeffs, + {d_source_models, d_source_params}, + d_byte, d_float_out, d_axes, B, Hin, Win, C, K, Hout, Wout, - input_is_u16 ? kElemU16 : kElemU8, cmt(camera_model), - Hin, Win, false, - input_is_u16 ? 1.0f / 65535.0f : 1.0f / 255.0f, 0.0f)); + input_is_u16 ? kElemU16 : kElemU8, + (CameraModelType)cd.cam, Hin, Win, false, + input_is_u16 ? 1.0f / 65535.0f : 1.0f / 255.0f, 0.0f), + {cd.dist, from_source_spec(d_source_models)}); } void launch_warp_byte_to_float_equi( @@ -186,17 +229,21 @@ void launch_warp_byte_to_float_equi( { dispatch_warp("warp.warp_img_equi", make_warp_params( - nullptr, nullptr, d_byte, d_float_out, d_axes, + nullptr, nullptr, {}, d_byte, d_float_out, d_axes, B, Hin, Win, C, K, Hout, Wout, input_is_u16 ? kElemU16 : kElemU8, CameraModelType::EQUIRECTANGULAR, Hin, Win, false, - input_is_u16 ? 1.0f / 65535.0f : 1.0f / 255.0f, 0.0f)); + input_is_u16 ? 1.0f / 65535.0f : 1.0f / 255.0f, 0.0f), + {}); } void launch_warp_mask_wide( std::string camera_model, + std::string distortion, const float* d_intrins, const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, const uint8_t* d_byte_mask, int B, int Hin, int Win, uint8_t* d_byte_out, int K, int Hout, int Wout, @@ -205,15 +252,19 @@ void launch_warp_mask_wide( WarpMaskParams p{}; p.intrins = vkk::or_fallback(d_intrins); p.dist_coeffs = vkk::or_fallback(d_dist_coeffs); + p.source_models = vkk::or_fallback(d_source_models); + p.source_params = vkk::or_fallback(d_source_params); p.src = vkk::or_fallback(d_byte_mask); p.dst = (uint64_t)d_byte_out; p.axes = vkk::or_fallback(d_axes); p.B = B; p.Hin = Hin; p.Win = Win; p.K = K; p.Hout = Hout; p.Wout = Wout; - p.camera_model = (int)cmt(camera_model); + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); + p.camera_model = (int)cd.cam; int64_t words = ((int64_t)B * K * Hout * Wout + 3) / 4; - vkk::dispatch_flat("warp.warp_mask_wide", {}, words, 256, &p, sizeof(p), - &p.wgs_per_row); + vkk::dispatch_flat("warp.warp_mask_wide", + {cd.dist, from_source_spec(d_source_models)}, words, + 256, &p, sizeof(p), &p.wgs_per_row); } void launch_warp_mask_equi( @@ -225,6 +276,8 @@ void launch_warp_mask_equi( WarpMaskParams p{}; p.intrins = vkk::or_fallback(nullptr); p.dist_coeffs = vkk::or_fallback(nullptr); + p.source_models = vkk::or_fallback(nullptr); + p.source_params = vkk::or_fallback(nullptr); p.src = vkk::or_fallback(d_byte_mask); p.dst = (uint64_t)d_byte_out; p.axes = vkk::or_fallback(d_axes); @@ -238,21 +291,28 @@ void launch_warp_mask_equi( void launch_warp_depth_wide( std::string camera_model, + std::string distortion, const float* d_intrins, const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, const void* d_depth, uint32_t elem_size, int B, int Hin, int Win, int in_H, int in_W, float* d_float_out, int K, int Hout, int Wout, const float* d_axes, bool input_is_ray_depth) { + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); dispatch_warp("warp.warp_depth_wide", make_warp_params( - d_intrins, d_dist_coeffs, d_depth, d_float_out, d_axes, + d_intrins, d_dist_coeffs, + {d_source_models, d_source_params}, + d_depth, d_float_out, d_axes, B, Hin, Win, 1, K, Hout, Wout, resolve_depth_kind(elem_size, "launch_warp_depth_wide"), - cmt(camera_model), in_H, in_W, input_is_ray_depth, - 1.0f, 0.0f)); + (CameraModelType)cd.cam, in_H, in_W, input_is_ray_depth, + 1.0f, 0.0f), + {cd.dist, from_source_spec(d_source_models)}); } void launch_warp_depth_equi( @@ -263,17 +323,21 @@ void launch_warp_depth_equi( { dispatch_warp("warp.warp_depth_equi", make_warp_params( - nullptr, nullptr, d_depth, d_float_out, d_axes, + nullptr, nullptr, {}, d_depth, d_float_out, d_axes, B, Hin, Win, 1, K, Hout, Wout, resolve_depth_kind(elem_size, "launch_warp_depth_equi"), CameraModelType::EQUIRECTANGULAR, Hin, Win, - input_is_ray_depth, 1.0f, 0.0f)); + input_is_ray_depth, 1.0f, 0.0f), + {}); } void launch_warp_normal_wide( std::string camera_model, + std::string distortion, const float* d_intrins, const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, const void* d_normal, uint32_t elem_size, int B, int Hin, int Win, int in_H, int in_W, @@ -284,12 +348,17 @@ void launch_warp_normal_wide( throw std::runtime_error( "launch_warp_normal_wide: normal must be uint8 or float32"); bool u8 = elem_size == 1; + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); dispatch_warp("warp.warp_normal_wide", make_warp_params( - d_intrins, d_dist_coeffs, d_normal, d_float_out, d_axes, + d_intrins, d_dist_coeffs, + {d_source_models, d_source_params}, + d_normal, d_float_out, d_axes, B, Hin, Win, 3, K, Hout, Wout, - u8 ? kElemU8 : kElemF32, cmt(camera_model), in_H, in_W, - false, u8 ? 1.0f / 127.5f : 1.0f, u8 ? -1.0f : 0.0f)); + u8 ? kElemU8 : kElemF32, (CameraModelType)cd.cam, in_H, + in_W, false, u8 ? 1.0f / 127.5f : 1.0f, + u8 ? -1.0f : 0.0f), + {cd.dist, from_source_spec(d_source_models)}); } void launch_warp_normal_equi( @@ -304,9 +373,121 @@ void launch_warp_normal_equi( bool u8 = elem_size == 1; dispatch_warp("warp.warp_normal_equi", make_warp_params( - nullptr, nullptr, d_normal, d_float_out, d_axes, + nullptr, nullptr, {}, d_normal, d_float_out, d_axes, B, Hin, Win, 3, K, Hout, Wout, u8 ? kElemU8 : kElemF32, CameraModelType::EQUIRECTANGULAR, Hin, Win, false, - u8 ? 1.0f / 127.5f : 1.0f, u8 ? -1.0f : 0.0f)); + u8 ? 1.0f / 127.5f : 1.0f, u8 ? -1.0f : 0.0f), + {}); +} + + +// ---- Re-distort onto the fitted tier (PixelWise.cuh) ------------------------ + +void launch_redistort_byte_to_float( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const void* d_byte, bool input_is_u16, + int B, int in_H, int in_W, int C, + float* d_float_out, int out_H, int out_W, + int ref_H, int ref_W, + float invalid) +{ + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); + dispatch_warp("warp.redistort_img", + make_redistort_params( + d_intrins, d_dist_coeffs, + {d_source_models, d_source_params}, + d_byte, d_float_out, B, in_H, in_W, C, out_H, out_W, + input_is_u16 ? kElemU16 : kElemU8, + (CameraModelType)cd.cam, ref_H, ref_W, + input_is_u16 ? 1.0f / 65535.0f : 1.0f / 255.0f, 0.0f, + invalid), + {cd.dist}); +} + +// Depth is raw counts either way, so norm_inv stays 1 -- same convention as +// the wide warp. +void launch_redistort_depth( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const void* d_in, uint32_t elem_size, + int B, int in_H, int in_W, int C, + float* d_float_out, int out_H, int out_W, + int ref_H, int ref_W, + float invalid) +{ + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); + dispatch_warp("warp.redistort_img", + make_redistort_params( + d_intrins, d_dist_coeffs, + {d_source_models, d_source_params}, + d_in, d_float_out, B, in_H, in_W, C, out_H, out_W, + elem_size == 2 ? kElemU16 : kElemF32, + (CameraModelType)cd.cam, ref_H, ref_W, 1.0f, 0.0f, + invalid), + {cd.dist}); +} + +void launch_redistort_mask( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const uint8_t* d_byte_mask, + int B, int in_H, int in_W, + uint8_t* d_byte_out, int out_H, int out_W, + int ref_H, int ref_W) +{ + WarpMaskParams p{}; + p.intrins = vkk::or_fallback(d_intrins); + p.dist_coeffs = vkk::or_fallback(d_dist_coeffs); + p.source_models = vkk::or_fallback(d_source_models); + p.source_params = vkk::or_fallback(d_source_params); + p.src = vkk::or_fallback(d_byte_mask); + p.dst = (uint64_t)d_byte_out; + p.axes = vkk::or_fallback(nullptr); + p.B = B; p.Hin = in_H; p.Win = in_W; + p.K = 1; p.Hout = out_H; p.Wout = out_W; + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); + p.camera_model = (int)cd.cam; + p.ref_H = ref_H; p.ref_W = ref_W; + int64_t words = ((int64_t)B * out_H * out_W + 3) / 4; + vkk::dispatch_flat("warp.redistort_mask", {cd.dist}, words, 256, &p, + sizeof(p), &p.wgs_per_row); +} + +void launch_redistort_normal( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const void* d_in, bool input_is_float, + int B, int in_H, int in_W, + float* d_float_out, int out_H, int out_W, + int ref_H, int ref_W) +{ + const vkk::CamDistSpec cd = vkk::cam_dist_spec(camera_model, distortion); + dispatch_warp("warp.redistort_normal", + make_redistort_params( + d_intrins, d_dist_coeffs, + {d_source_models, d_source_params}, + d_in, d_float_out, B, in_H, in_W, 3, out_H, out_W, + input_is_float ? kElemF32 : kElemU8, + (CameraModelType)cd.cam, ref_H, ref_W, + input_is_float ? 1.0f : 1.0f / 127.5f, + input_is_float ? 0.0f : -1.0f, 0.0f), + {cd.dist}); } diff --git a/src/backend/vulkan/shaders/background_sh.slang b/src/backend/vulkan/shaders/background_sh.slang index 625a1bea..22079f8a 100644 --- a/src/backend/vulkan/shaders/background_sh.slang +++ b/src/backend/vulkan/shaders/background_sh.slang @@ -4,9 +4,9 @@ // the camera-to-world rotation use the same projection_utils.slang exports // the CUDA kernel wraps (generate_ray + transform_ray_d). // -// kShDegree is a specialization constant (the CUDA kernel's template -// parameter); the camera model is a plain runtime value, exactly like the -// CUDA kernel's `int camera_model` argument. +// kShDegree and kDistortion (declared last) are specialization constants (the +// CUDA kernel's template parameters); the camera model is a plain runtime +// value, exactly like the CUDA kernel's `int camera_model` argument. // // Backward: CUDA's 512-thread block-atomic SH reduction // (sh_block_atomic_add_f3_512) hardcodes warp==32 and needs float atomics, @@ -20,6 +20,7 @@ #include "shaders/projection_utils.slang" #include "shaders/harmonics.slang" #undef CudaDeviceExport +#include "dist_spec.slang" [SpecializationConstant] const int kShDegree = 0; @@ -27,7 +28,7 @@ const int kShDegree = 0; struct BackgroundShFwdParams { // 56 bytes: pushed directly float* viewmats; // [B,16] row-major world->camera float4* intrins; // [B] fx, fy, cx, cy - float* dist_coeffs; // [B,10] or null + float* dist_coeffs; // [B,8] or null float* sh_coeffs; // [(kShDegree+1)^2, 3] float* out_img; // [B,H,W,3] uint32_t width; @@ -39,6 +40,9 @@ struct BackgroundShFwdParams { // 56 bytes: pushed directly // Workgroups are a flat 128x1 pixel-row segment (not the CUDA kernel's // 16x16): REQUIRE_FULL_SUBGROUPS demands the X dimension be a multiple of // the pinned subgroup size (README subgroup rules). Grid (ceil(W/128), H, B). +#define _bg_ray(D) \ + ray_ok = pixel_ray(p.dist_coeffs, bi, p.camera_model, uv, raydir) + [shader("compute")] [numthreads(128, 1, 1)] void background_sh_fwd(uint3 gtid: SV_DispatchThreadID, @@ -55,18 +59,15 @@ void background_sh_fwd(uint3 gtid: SV_DispatchThreadID, for (int r = 0; r < 3; r++) R[r] = float3(vm[4 * r + 0], vm[4 * r + 1], vm[4 * r + 2]); float4 intrin = p.intrins[bi]; - float dist[10]; - [ForceUnroll] - for (int i = 0; i < 10; i++) - dist[i] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * bi + i]; float2 uv = float2((float(px) + 0.5f - intrin.z) / intrin.x, (float(py) + 0.5f - intrin.w) / intrin.y); float3 color = float3(0.0f); - float3 raydir; - if (generate_ray(uv, p.camera_model, dist, raydir)) { + float3 raydir = float3(0.0f); + bool ray_ok = false; + SS_DISPATCH_DIST(_bg_ray) + if (ray_ok) { float3 dir = transform_ray_d(R, raydir); float3 dc = float3(p.sh_coeffs[0], p.sh_coeffs[1], p.sh_coeffs[2]); float3* coeffs_l1 = (float3*)p.sh_coeffs + 1; @@ -94,7 +95,7 @@ static const uint kBgBwdSlices = kBgBwdWgs * 256; struct BackgroundShBwdParams { // 80 bytes: pushed directly float* viewmats; // [B,16] float4* intrins; // [B] - float* dist_coeffs; // [B,10] (fallback-backed) + float* dist_coeffs; // [B,8] (fallback-backed) float* sh_coeffs; // [K,3], K = (kShDegree+1)^2 float* out_color; // [B,H,W,3] forward output (clamp mask) float* v_out_color; // [B,H,W,3] @@ -146,15 +147,12 @@ void background_sh_bwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, for (int r = 0; r < 3; r++) R[r] = float3(vm[4 * r + 0], vm[4 * r + 1], vm[4 * r + 2]); float4 intrin = p.intrins[bi]; - float dist[10]; - [ForceUnroll] - for (int k = 0; k < 10; k++) - dist[k] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * bi + k]; float2 uv = float2((float(px) + 0.5f - intrin.z) / intrin.x, (float(py) + 0.5f - intrin.w) / intrin.y); - float3 raydir; - if (!generate_ray(uv, p.camera_model, dist, raydir)) continue; + float3 raydir = float3(0.0f); + bool ray_ok = false; + SS_DISPATCH_DIST(_bg_ray) + if (!ray_ok) continue; float3 dir = transform_ray_d(R, raydir); // v_dir is discarded (engine holds cameras fixed, as in CUDA). @@ -211,3 +209,9 @@ void background_sh_bwd_reduce(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, } if (tid == 0) p.v_sh_coeffs[col] += _bgsh_red[0]; } + +#undef _bg_ray + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/dist_spec.slang b/src/backend/vulkan/shaders/dist_spec.slang new file mode 100644 index 00000000..9b0f4d2d --- /dev/null +++ b/src/backend/vulkan/shaders/dist_spec.slang @@ -0,0 +1,86 @@ +#pragma once + +// Distortion tier as a specialization constant: the coefficient loader and the +// dispatch macros that fold `kDistortion` (and, where the camera model is also +// a spec constant, the pair) into the Slang generics of +// shaders/projection_utils.slang. +// +// `kDistortion` itself is NOT declared here. Specialization-constant IDs are +// assigned by declaration order within a module and the host passes SpecList by +// index, so a constant declared mid-module renumbers everything after it: every +// module declares `kDistortion` LAST and appends its value last in SpecList. +// +// Include after shaders/projection_utils.slang (directly or transitively) and +// after int64_compat.slang. + +// Storage width of one camera's coefficient row; must match +// kCameraDistortionParams in core/CameraModel.h. Each tier reads a prefix. +static const int kDistCoeffRow = 8; + +// The identity tier reads nothing: its one slot is unused (Slang has no +// zero-length array), and an undistorted launch passes the 4 KB zeroed +// fallback, which a large `cid` would index past. +[ForceInline] +void load_dist_coeffs( + float* dist_coeffs, uint cid, out float dist[D.kNumParams] +) { + [ForceUnroll] + for (int i = 0; i < D.kNumParams; i++) + dist[i] = (D.kIsIdentity || is_null(dist_coeffs)) + ? 0.0f + : dist_coeffs[kDistCoeffRow * cid + i]; +} + +// Ray through a pixel for the kernels that take the camera model as a runtime +// value (rasterization, background, pixel-wise): loads the tier's row and calls +// generate_ray, so callers dispatch on kDistortion alone. +[ForceInline] +bool pixel_ray(float* dist_coeffs, uint cid, + int camera_model, float2 uv, + out float3 raydir) { + float dist[D.kNumParams]; + load_dist_coeffs(dist_coeffs, cid, dist); + return generate_ray(uv, camera_model, dist, raydir); +} + +// CALL(D) once per tier, folded on kDistortion. +#define SS_DISPATCH_DIST(CALL) \ + switch (kDistortion) { \ + case 0: CALL(DistNone); break; \ + case 1: CALL(DistOpenCV); break; \ + case 2: CALL(DistThinPrism); break; \ + default: CALL(DistRational); break; \ + } + +// CALL(camera model, D) over the ELEVEN compiled (model, tier) combos +// (camera_distortion_is_compiled in core/CameraModel.h). Combos outside that +// set fall through to the nearest compiled tier rather than duplicating an +// arm -- no launcher dispatches them. +#define SS_DISPATCH_CAM_DIST(CALL) \ + switch (kCameraModel) { \ + case 1: \ + switch (kDistortion) { \ + case 0: CALL(CameraModelType::FISHEYE, DistNone); break; \ + case 1: CALL(CameraModelType::FISHEYE, DistOpenCV); break; \ + default: CALL(CameraModelType::FISHEYE, DistThinPrism); break; \ + } \ + break; \ + case 2: \ + switch (kDistortion) { \ + case 0: CALL(CameraModelType::EQUISOLID, DistNone); break; \ + case 1: CALL(CameraModelType::EQUISOLID, DistOpenCV); break; \ + default: CALL(CameraModelType::EQUISOLID, DistThinPrism); break;\ + } \ + break; \ + case 3: \ + CALL(CameraModelType::EQUIRECTANGULAR, DistNone); \ + break; \ + default: \ + switch (kDistortion) { \ + case 0: CALL(CameraModelType::PINHOLE, DistNone); break; \ + case 1: CALL(CameraModelType::PINHOLE, DistOpenCV); break; \ + case 2: CALL(CameraModelType::PINHOLE, DistThinPrism); break; \ + default: CALL(CameraModelType::PINHOLE, DistRational); break; \ + } \ + break; \ + } diff --git a/src/backend/vulkan/shaders/fpbo.slang b/src/backend/vulkan/shaders/fpbo.slang index 09c74f59..58cd757b 100644 --- a/src/backend/vulkan/shaders/fpbo.slang +++ b/src/backend/vulkan/shaders/fpbo.slang @@ -18,6 +18,7 @@ // attributes); only ever set with kLevel == 1 // kVwMask = which v_splats_world tensors exist (1 means, 2 quats, // 4 scales, 8 opac, 16 dc) -- folded loads +// kDistortion = CameraDistortionType (0..3), declared last // // Barriers only exist in the kLevel/kNonShQuant reduces and the staged SH // writeback, which every thread reaches (`inside` masks work, never control @@ -158,6 +159,51 @@ float _fp_sigmoid(float x) { return 1.0f / (1.0f + exp(-x)); } // optim_quant.slang (oq_state_read / oq_accum_us / oq_state_encode / // oq_sqrt3 / oq_sqrt4), shared with optim_geometry.slang. +// The per-splat camera loop, generic over the two projection spec axes so the +// entry point folds them once (its block reduces stay outside). +[ForceInline] +void _fpbo_camera_loop( + FpboParams p, PbSplat s, uint gid, int cid_0, int cid_1, gindex_t qbase, + gindex_t vstride, inout PbGrads g) { + for (int cid_t = cid_0; cid_t < cid_1; ++cid_t) { + int idx = (kPacked != 0) ? p.perm[cid_t] + : cid_t * int(p.N) + int(gid); + int cid = (kPacked != 0) ? p.camera_ids[idx] : cid_t; + float4 bb = p.aabb[idx]; + if (bb.z <= bb.x || bb.w <= bb.y) + continue; + PbCamera c = pb_load_camera(p.viewmats, p.intrins, + p.dist_coeffs, uint(cid)); + if (kEval3d != 0) { + float3 v_ss = float3(p.vs0[3 * idx], p.vs0[3 * idx + 1], + p.vs0[3 * idx + 2]); + float v_so = p.vs1[idx]; + float3 v_rgb = float3(p.vs2[3 * idx], p.vs2[3 * idx + 1], + p.vs2[3 * idx + 2]); + pb_vjp_3dgut(s, c, p.width, p.height, v_ss, v_so, g); + pb_sh_vjp(s, c, p.features_sh + gid * 3 * p.num_sh_buffer, + p.sh_value_packed, p.sh_value_bounds, qbase, + vstride, v_rgb, g); + } else { + float2 v_xy = float2(p.vs0[2 * idx], p.vs0[2 * idx + 1]); + float v_depth = p.vs1[idx]; + float3 v_conic = float3(p.vs2[3 * idx], p.vs2[3 * idx + 1], + p.vs2[3 * idx + 2]); + float v_opac = p.vs3[idx]; + float3 v_rgb = float3(p.vs4[3 * idx], p.vs4[3 * idx + 1], + p.vs4[3 * idx + 2]); + pb_vjp_2d(s, c, p.width, p.height, v_xy, v_depth, v_conic, + v_opac, g); + pb_sh_vjp(s, c, p.features_sh + gid * 3 * p.num_sh_buffer, + p.sh_value_packed, p.sh_value_bounds, qbase, + vstride, v_rgb, g); + } + } +} + +#define _fpbo_call(M, D) \ + _fpbo_camera_loop(p, s, gid, cid_0, cid_1, qbase, vstride, g) + [shader("compute")] [numthreads(256, 1, 1)] void fpbo(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -209,40 +255,7 @@ void fpbo(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, // all 3*K cells; the host passes kShValueBits = 16 and the FPBO // stride below). gindex_t vstride = (gindex_t)256 * 3 * (gindex_t)p.num_sh_buffer; - for (int cid_t = cid_0; cid_t < cid_1; ++cid_t) { - int idx = (kPacked != 0) ? p.perm[cid_t] - : cid_t * int(p.N) + int(gid); - int cid = (kPacked != 0) ? p.camera_ids[idx] : cid_t; - float4 bb = p.aabb[idx]; - if (bb.z <= bb.x || bb.w <= bb.y) - continue; - PbCamera cam = pb_load_camera(p.viewmats, p.intrins, - p.dist_coeffs, uint(cid)); - if (kEval3d != 0) { - float3 v_ss = float3(p.vs0[3 * idx], p.vs0[3 * idx + 1], - p.vs0[3 * idx + 2]); - float v_so = p.vs1[idx]; - float3 v_rgb = float3(p.vs2[3 * idx], p.vs2[3 * idx + 1], - p.vs2[3 * idx + 2]); - pb_vjp_3dgut(s, cam, p.width, p.height, v_ss, v_so, g); - pb_sh_vjp(s, cam, p.features_sh + gid * 3 * p.num_sh_buffer, - p.sh_value_packed, p.sh_value_bounds, qbase, - vstride, v_rgb, g); - } else { - float2 v_xy = float2(p.vs0[2 * idx], p.vs0[2 * idx + 1]); - float v_depth = p.vs1[idx]; - float3 v_conic = float3(p.vs2[3 * idx], p.vs2[3 * idx + 1], - p.vs2[3 * idx + 2]); - float v_opac = p.vs3[idx]; - float3 v_rgb = float3(p.vs4[3 * idx], p.vs4[3 * idx + 1], - p.vs4[3 * idx + 2]); - pb_vjp_2d(s, cam, p.width, p.height, v_xy, v_depth, v_conic, - v_opac, g); - pb_sh_vjp(s, cam, p.features_sh + gid * 3 * p.num_sh_buffer, - p.sh_value_packed, p.sh_value_bounds, qbase, - vstride, v_rgb, g); - } - } + SS_DISPATCH_CAM_DIST(_fpbo_call) // per-splat regularizers -> gradient float v_losses[5] = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; @@ -744,3 +757,9 @@ void fpbo(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, } } } + +#undef _fpbo_call + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/meshing_raster.slang b/src/backend/vulkan/shaders/meshing_raster.slang index 79347d42..40ab0033 100644 --- a/src/backend/vulkan/shaders/meshing_raster.slang +++ b/src/backend/vulkan/shaders/meshing_raster.slang @@ -15,9 +15,11 @@ #include "int64_compat.slang" #include "shaders/projection_utils.slang" #undef CudaDeviceExport +#include "dist_spec.slang" // Camera model of the images being sampled. Value parameter on the CUDA side; -// a specialization constant here, like every other camera-model axis. +// a specialization constant here, like every other camera-model axis +// (kDistortion follows at the end of the file). [SpecializationConstant] const int kCameraModel = 0; @@ -58,8 +60,9 @@ float3 bilinear3(float* img, int W, int H, float u, float v) { // Project p (world) into the camera. Returns false if behind the camera or out // of frame; else fills pixel (u,v) and the along-ray depth z = |p_cam|. [ForceInline] -bool project_point(float* viewmat, float* intrin, float* dist, int W, int H, - float3 pw, out float u, out float v, out float z) { +bool project_point( + float* viewmat, float* intrin, float* dist, int W, int H, float3 pw, + out float u, out float v, out float z) { u = 0.0f; v = 0.0f; z = 0.0f; float3 p_cam; [ForceUnroll] @@ -68,17 +71,18 @@ bool project_point(float* viewmat, float* intrin, float* dist, int W, int H, viewmat[4 * r + 2] * pw.z + viewmat[4 * r + 3]; float4 intr = float4(intrin[0], intrin[1], intrin[2], intrin[3]); - float dc[10]; + float dc[D.kNumParams]; [ForceUnroll] - for (int t = 0; t < 10; ++t) dc[t] = dist[t]; + for (int t = 0; t < D.kNumParams; ++t) dc[t] = dist[t]; - // proj_nav handles the behind-camera / invalid-distortion cases and returns - // pixel-space uv (already scaled by fx,fy and offset by cx,cy). + // The projections handle the behind-camera / invalid-distortion cases and + // return pixel-space uv (already scaled by fx,fy and offset by cx,cy). float2 uv; bool valid = - (kCameraModel == 1) ? fisheye_proj_nav(p_cam, intr, dc, uv) : - (kCameraModel == 2) ? equisolid_proj_nav(p_cam, intr, dc, uv) : - persp_proj_nav(p_cam, intr, dc, uv); + (kCameraModel == 1) ? fisheye_proj(p_cam, intr, dc, uv) : + (kCameraModel == 2) ? equisolid_proj(p_cam, intr, dc, uv) : + (kCameraModel == 3) ? equirect_proj(p_cam, intr, uv) : + persp_proj(p_cam, intr, dc, uv); if (!valid) return false; u = uv.x; v = uv.y; if (u < 0.0f || u >= float(W) || v < 0.0f || v >= float(H)) return false; @@ -148,16 +152,11 @@ struct MeshSampleOccParams { // 56 bytes: pushed directly uint32_t _pad0; }; -[shader("compute")] -[numthreads(256, 1, 1)] -void mesh_sample_occ(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, - uniform MeshSampleOccParams p) { - uint gid = (wg.y * p.wgs_per_row + wg.x) * 256 + tid; - if (gid >= p.n) return; - int i = int(gid); +[ForceInline] +void _ms_occ(MeshSampleOccParams p, int i) { float u, v, z; - if (!project_point(p.viewmat, p.intrin, p.dist, int(p.W), int(p.H), - ld3(p.xyz, i), u, v, z)) + if (!project_point(p.viewmat, p.intrin, p.dist, int(p.W), int(p.H), + ld3(p.xyz, i), u, v, z)) return; float occ; if (!occ_bilinear(p.moments, int(p.W), int(p.H), u, v, z, occ)) @@ -173,6 +172,18 @@ void mesh_sample_occ(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, p.cnt[i] += 1; } +#define _ms_occ_call(D) _ms_occ(p, int(gid)) + +[shader("compute")] +[numthreads(256, 1, 1)] +void mesh_sample_occ(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, + uniform MeshSampleOccParams p) { + uint gid = (wg.y * p.wgs_per_row + wg.x) * 256 + tid; + if (gid >= p.n) return; + SS_DISPATCH_DIST(_ms_occ_call) +} +#undef _ms_occ_call + struct MeshFinalizeOccParams { // 32 bytes: pushed directly float* occ_kmin; int* cnt; @@ -215,16 +226,11 @@ struct MeshSampleColorParams { // 72 bytes: pushed directly uint32_t wgs_per_row; }; -[shader("compute")] -[numthreads(256, 1, 1)] -void mesh_sample_color(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, - uniform MeshSampleColorParams p) { - uint gid = (wg.y * p.wgs_per_row + wg.x) * 256 + tid; - if (gid >= p.n) return; - int i = int(gid); +[ForceInline] +void _ms_color(MeshSampleColorParams p, int i) { float u, v, z; - if (!project_point(p.viewmat, p.intrin, p.dist, int(p.W), int(p.H), - ld3(p.xyz, i), u, v, z)) + if (!project_point(p.viewmat, p.intrin, p.dist, int(p.W), int(p.H), + ld3(p.xyz, i), u, v, z)) return; float occ; // Sample the occlusion slightly IN FRONT of the point (2% of depth): @@ -246,6 +252,18 @@ void mesh_sample_color(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, p.den[i] += w4; } +#define _ms_color_call(D) _ms_color(p, int(gid)) + +[shader("compute")] +[numthreads(256, 1, 1)] +void mesh_sample_color(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, + uniform MeshSampleColorParams p) { + uint gid = (wg.y * p.wgs_per_row + wg.x) * 256 + tid; + if (gid >= p.n) return; + SS_DISPATCH_DIST(_ms_color_call) +} +#undef _ms_color_call + struct MeshFinalizeColorParams { // 32 bytes: pushed directly float* num; float* den; @@ -286,16 +304,11 @@ struct MeshViewDensityParams { // 56 bytes: pushed directly uint32_t wgs_per_row; }; -[shader("compute")] -[numthreads(256, 1, 1)] -void mesh_sample_view_density(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, - uniform MeshViewDensityParams p) { - uint gid = (wg.y * p.wgs_per_row + wg.x) * 256 + tid; - if (gid >= p.n) return; - int i = int(gid); +[ForceInline] +void _ms_density(MeshViewDensityParams p, int i) { float u, v, z; - if (!project_point(p.viewmat, p.intrin, p.dist, int(p.W), int(p.H), - ld3(p.xyz, i), u, v, z)) + if (!project_point(p.viewmat, p.intrin, p.dist, int(p.W), int(p.H), + ld3(p.xyz, i), u, v, z)) return; float occ; // same front-shifted sample as the color path: tolerate surface fuzz @@ -307,6 +320,18 @@ void mesh_sample_view_density(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, if (nu > p.dens[i]) p.dens[i] = nu; } +#define _ms_density_call(D) _ms_density(p, int(gid)) + +[shader("compute")] +[numthreads(256, 1, 1)] +void mesh_sample_view_density(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, + uniform MeshViewDensityParams p) { + uint gid = (wg.y * p.wgs_per_row + wg.x) * 256 + tid; + if (gid >= p.n) return; + SS_DISPATCH_DIST(_ms_density_call) +} +#undef _ms_density_call + // =========================================================================== // Visibility cull // =========================================================================== @@ -487,20 +512,14 @@ struct MeshCullParams { uint32_t wgs_per_row; }; -[shader("compute")] -[numthreads(256, 1, 1)] -void mesh_cull(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, - uniform MeshCullParams* pp) { - MeshCullParams p = *pp; - uint gid = (wg.y * p.wgs_per_row + wg.x) * 256 + tid; - if (gid >= p.nv) return; - int i = int(gid); +[ForceInline] +void _ms_cull(MeshCullParams p, int i) { float3 pt = ld3(p.verts, i); for (uint c = 0; c < p.C; ++c) { float* vm = p.viewmats + c * 16; float u, v, z; - if (!project_point(vm, p.intrins + c * 4, p.dist + c * 10, - p.Ws[c], p.Hs[c], pt, u, v, z)) + if (!project_point(vm, p.intrins + c * 4, p.dist + c * kDistCoeffRow, + p.Ws[c], p.Hs[c], pt, u, v, z)) continue; // out of frame / behind camera // camera center in world: C = -R^T t (viewmat row-major world->cam) float3 cam = float3( @@ -515,3 +534,20 @@ void mesh_cull(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, } p.visible[i] = 0u; // seen by no camera } + +#define _ms_cull_call(D) _ms_cull(p, int(gid)) + +[shader("compute")] +[numthreads(256, 1, 1)] +void mesh_cull(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, + uniform MeshCullParams* pp) { + MeshCullParams p = *pp; + uint gid = (wg.y * p.wgs_per_row + wg.x) * 256 + tid; + if (gid >= p.nv) return; + SS_DISPATCH_DIST(_ms_cull_call) +} +#undef _ms_cull_call + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/pixel_wise_render.slang b/src/backend/vulkan/shaders/pixel_wise_render.slang index 96802bde..aa23ea81 100644 --- a/src/backend/vulkan/shaders/pixel_wise_render.slang +++ b/src/backend/vulkan/shaders/pixel_wise_render.slang @@ -14,6 +14,7 @@ #include "int64_compat.slang" #include "shaders/pixel_wise.slang" #undef CudaDeviceExport +#include "dist_spec.slang" // Single boolean variant flag shared by the entries that need one // (noise blend: is_linear; srgb: is_input_linear). @@ -158,7 +159,7 @@ static const int D2N_TILE = 16; struct DepthToNormalParams { // 52 bytes: pushed directly float4* intrins; // [B] - float* dist_coeffs; // [B,10] or null + float* dist_coeffs; // [B,8] or null float* depths; // [B,H,W,1] float* normals; // [B,H,W,3] uint32_t W; @@ -170,6 +171,33 @@ struct DepthToNormalParams { // 52 bytes: pushed directly groupshared float3 _d2n_points[(D2N_TILE + 2) * (D2N_TILE + 2)]; +// Apron fill, generic over the tier so the entry folds kDistortion once +// instead of switching inside the loop. +[ForceInline] +void _d2n_fill_apron(DepthToNormalParams p, uint bid, + uint2 tile0, uint tid, + float4 intrin) { + float dist[D.kNumParams]; + load_dist_coeffs(p.dist_coeffs, bid, dist); + for (uint k = tid; k < uint((D2N_TILE + 2) * (D2N_TILE + 2)); k += 256) { + int it = int(k % (D2N_TILE + 2)), jt = int(k / (D2N_TILE + 2)); + int ig = int(tile0.x) + it - 1; + int jg = int(tile0.y) + jt - 1; + float depth = + (ig >= 0 && ig < int(p.W) && jg >= 0 && jg < int(p.H)) + ? p.depths[(bid * p.H + uint(jg)) * p.W + uint(ig)] + : 0.0f; + float3 ray = generate_ray_d2n( + float2(float(ig) + 0.5f, float(jg) + 0.5f), intrin, dist, + p.camera_model, p.is_ray_depth != 0); + _d2n_points[k] = ray * depth; + } +} + +#define _d2n_call(D) \ + _d2n_fill_apron(p, bid, uint2(wg.x * D2N_TILE, wg.y * D2N_TILE), tid, \ + intrin) + [shader("compute")] [numthreads(256, 1, 1)] void depth_to_normal_fwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -189,27 +217,10 @@ void depth_to_normal_fwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, } float4 intrin = p.intrins[bid]; - float dist[10]; - [ForceUnroll] - for (int k = 0; k < 10; k++) - dist[k] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * bid + k]; // Shared apron of unprojected points (ray * depth), same layout as the // CUDA kernel's shared_points[TILE+2][TILE+2]. - for (uint k = tid; k < uint((D2N_TILE + 2) * (D2N_TILE + 2)); k += 256) { - int it = int(k % (D2N_TILE + 2)), jt = int(k / (D2N_TILE + 2)); - int ig = int(wg.x * D2N_TILE) + it - 1; - int jg = int(wg.y * D2N_TILE) + jt - 1; - float depth = - (ig >= 0 && ig < int(p.W) && jg >= 0 && jg < int(p.H)) - ? p.depths[(bid * p.H + uint(jg)) * p.W + uint(ig)] - : 0.0f; - float3 ray = generate_ray_d2n( - float2(float(ig) + 0.5f, float(jg) + 0.5f), intrin, dist, - p.camera_model, p.is_ray_depth != 0); - _d2n_points[k] = ray * depth; - } + SS_DISPATCH_DIST(_d2n_call) GroupMemoryBarrierWithGroupSync(); if (!inside) return; @@ -226,3 +237,9 @@ void depth_to_normal_fwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, p.normals[3 * o + 1] = normal.y; p.normals[3 * o + 2] = normal.z; } + +#undef _d2n_call + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/pixel_wise_train.slang b/src/backend/vulkan/shaders/pixel_wise_train.slang index fbe36e5e..02bd9a53 100644 --- a/src/backend/vulkan/shaders/pixel_wise_train.slang +++ b/src/backend/vulkan/shaders/pixel_wise_train.slang @@ -13,6 +13,7 @@ #undef CudaDeviceExport #include "atomic_float.slang" +#include "dist_spec.slang" // Shared boolean variant flag (noise blend: is_linear; srgb: // is_input_linear), same convention as pixel_wise_render.slang. @@ -208,7 +209,7 @@ static const int D2NB_TILE = 16; struct DepthToNormalBwdParams { // 60 bytes: pushed directly float4* intrins; // [B] - float* dist_coeffs; // [B,10] (fallback-backed) + float* dist_coeffs; // [B,8] (fallback-backed) float* depths; // [B,H,W,1] float* v_normals; // [B,H,W,3] float* v_depths; // [B,H,W,1] accumulated in place @@ -221,6 +222,33 @@ struct DepthToNormalBwdParams { // 60 bytes: pushed directly groupshared float4 _d2nb_points[(D2NB_TILE + 2) * (D2NB_TILE + 2)]; +// Apron fill, generic over the tier so the entry folds kDistortion once +// instead of switching inside the loop. +[ForceInline] +void _d2nb_fill_apron(DepthToNormalBwdParams p, + uint bid, uint2 tile0, uint tid, + float4 intrin) { + float dist[D.kNumParams]; + load_dist_coeffs(p.dist_coeffs, bid, dist); + for (uint k = tid; k < uint((D2NB_TILE + 2) * (D2NB_TILE + 2)); k += 256) { + int it = int(k % (D2NB_TILE + 2)), jt = int(k / (D2NB_TILE + 2)); + int ig = int(tile0.x) + it - 1; + int jg = int(tile0.y) + jt - 1; + float depth = + (ig >= 0 && ig < int(p.W) && jg >= 0 && jg < int(p.H)) + ? p.depths[(bid * p.H + uint(jg)) * p.W + uint(ig)] + : 0.0f; + float3 ray = generate_ray_d2n( + float2(float(ig) + 0.5f, float(jg) + 0.5f), intrin, dist, + p.camera_model, p.is_ray_depth != 0); + _d2nb_points[k] = float4(ray, depth); + } +} + +#define _d2nb_call(D) \ + _d2nb_fill_apron(p, bid, uint2(wg.x * D2NB_TILE, wg.y * D2NB_TILE), \ + tid, intrin) + [shader("compute")] [numthreads(256, 1, 1)] void d2n_bwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -234,25 +262,8 @@ void d2n_bwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, if (i == 0 || i == p.W - 1 || j == 0 || j == p.H - 1) inside = false; float4 intrin = p.intrins[bid]; - float dist[10]; - [ForceUnroll] - for (int k = 0; k < 10; k++) - dist[k] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * bid + k]; - for (uint k = tid; k < uint((D2NB_TILE + 2) * (D2NB_TILE + 2)); k += 256) { - int it = int(k % (D2NB_TILE + 2)), jt = int(k / (D2NB_TILE + 2)); - int ig = int(wg.x * D2NB_TILE) + it - 1; - int jg = int(wg.y * D2NB_TILE) + jt - 1; - float depth = - (ig >= 0 && ig < int(p.W) && jg >= 0 && jg < int(p.H)) - ? p.depths[(bid * p.H + uint(jg)) * p.W + uint(ig)] - : 0.0f; - float3 ray = generate_ray_d2n( - float2(float(ig) + 0.5f, float(jg) + 0.5f), intrin, dist, - p.camera_model, p.is_ray_depth != 0); - _d2nb_points[k] = float4(ray, depth); - } + SS_DISPATCH_DIST(_d2nb_call) GroupMemoryBarrierWithGroupSync(); if (!inside) return; @@ -289,7 +300,7 @@ void d2n_bwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, struct LinToRayDepthParams { // 48 bytes: pushed directly float4* intrins; // [B] at IMAGE resolution - float* dist_coeffs; // [B,10] (fallback-backed) + float* dist_coeffs; // [B,8] (fallback-backed) float* depths; // [B,Hd,Wd,1] in/out float sx, sy; // depth_res / image_res uint32_t W, H, B; @@ -297,6 +308,19 @@ struct LinToRayDepthParams { // 48 bytes: pushed directly uint32_t _pad0; }; +[ForceInline] +float _l2r_factor(LinToRayDepthParams p, uint bid, + float4 scaled, float2 pix) { + float dist[D.kNumParams]; + load_dist_coeffs(p.dist_coeffs, bid, dist); + return ray_depth_to_linear_depth_factor(pix, scaled, dist, + p.camera_model); +} + +#define _l2r_call(D) \ + factor = _l2r_factor(p, bid, scaled, \ + float2(float(i) + 0.5f, float(j) + 0.5f)) + [shader("compute")] [numthreads(128, 1, 1)] void lin_to_ray_depth(uint3 gtid: SV_DispatchThreadID, @@ -307,17 +331,11 @@ void lin_to_ray_depth(uint3 gtid: SV_DispatchThreadID, float4 intrin = p.intrins[bid]; float4 scaled = float4(intrin.x * p.sx, intrin.y * p.sy, intrin.z * p.sx, intrin.w * p.sy); - float dist[10]; - [ForceUnroll] - for (int k = 0; k < 10; k++) - dist[k] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * bid + k]; uint o = (bid * p.H + j) * p.W + i; float in_depth = p.depths[o]; - float factor = ray_depth_to_linear_depth_factor( - float2(float(i) + 0.5f, float(j) + 0.5f), scaled, dist, - p.camera_model); + float factor = 0.0f; + SS_DISPATCH_DIST(_l2r_call) p.depths[o] = (factor > 0.0f) ? (in_depth / factor) : 0.0f; } @@ -391,3 +409,10 @@ void color_shift_update(uint tid: SV_GroupThreadID, p.batch_sum[tid] = 0.0f; } } + +#undef _d2nb_call +#undef _l2r_call + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/proj_bwd_common.slang b/src/backend/vulkan/shaders/proj_bwd_common.slang index 53a763bd..e74722b3 100644 --- a/src/backend/vulkan/shaders/proj_bwd_common.slang +++ b/src/backend/vulkan/shaders/proj_bwd_common.slang @@ -7,12 +7,14 @@ // Declares the spec constants shared by every kernel in the family -- // includers must list their extra spec constants AFTER this include so the // auto-assigned constant IDs stay 0..4 here and 5.. in the includer, -// matching the host-side SpecList order. +// matching the host-side SpecList order. kDistortion is the one exception: +// every includer declares it LAST, after its own constants. // // Include AFTER primitive_3dgs.slang / harmonics.slang / sh_quant.slang / // sh_vjp.slang / atomic_float.slang. #include "int64_compat.slang" +#include "dist_spec.slang" [SpecializationConstant] const int kCameraModel = 0; @@ -48,17 +50,17 @@ PbSplat pb_load_splat(float* means, float* quats, float* scales, return s; } -struct PbCamera { +struct PbCamera { float3x3 R; float3 t; float4 intrin; - float dist[10]; + float dist[D.kNumParams]; }; [ForceInline] -PbCamera pb_load_camera(float* viewmats, float4* intrins, float* dist_coeffs, - uint cid) { - PbCamera c; +PbCamera pb_load_camera( + float* viewmats, float4* intrins, float* dist_coeffs, uint cid) { + PbCamera c; float* vm = viewmats + cid * 16; [ForceUnroll] for (int r = 0; r < 3; r++) { @@ -66,9 +68,7 @@ PbCamera pb_load_camera(float* viewmats, float4* intrins, float* dist_coeffs, c.t[r] = vm[4 * r + 3]; } c.intrin = intrins[cid]; - [ForceUnroll] - for (int i = 0; i < 10; i++) - c.dist[i] = is_null(dist_coeffs) ? 0.0f : dist_coeffs[10 * cid + i]; + load_dist_coeffs(dist_coeffs, cid, c.dist); return c; } @@ -99,101 +99,55 @@ PbGrads pb_grads_zero() { return g; } +// primitive_3dgs.slang exports one VJP per (camera model, tier); this generic +// conformance is the same body, reached with both axes still symbolic so the +// callers can stay generic and fold once at the entry point. +struct PbProj : _DiffProjection3DGS { + [ForceInline] + [Differentiable] + static void projection(_projection_3dgs_ARGS(D.kNumParams)) { + return projection_3dgs( + antialiased, mean, quat, scale, in_opacity, R, t, + fx, fy, cx, cy, dist_coeffs, image_width, image_height, + aabb_xyxy, sorting_depth, radius, mean2d, depth, conic, opacity); + } +}; + // One intersection's projection VJP, 2D (3DGS / Mip) screen layout // {xy, depth, conic, opac}. kAntialiased selects Mip. [ForceInline] -void pb_vjp_2d(PbSplat s, PbCamera c, uint width, uint height, float2 v_xy, - float v_depth, float3 v_conic, float v_opac, - inout PbGrads g) { - const bool aa = kAntialiased != 0; - switch (kCameraModel) { - case 0: - projection_3dgs_persp_vjp(aa, s.mean, s.quat, s.scale, s.in_opacity, - c.R, c.t, c.intrin.x, c.intrin.y, - c.intrin.z, c.intrin.w, c.dist, width, - height, v_xy, v_depth, v_conic, v_opac, - g.v_mean, g.v_quat, g.v_scale, g.v_opacity, - g.v_R, g.v_t); - break; - case 1: - projection_3dgs_fisheye_vjp(aa, s.mean, s.quat, s.scale, - s.in_opacity, c.R, c.t, c.intrin.x, - c.intrin.y, c.intrin.z, c.intrin.w, - c.dist, width, height, v_xy, v_depth, - v_conic, v_opac, g.v_mean, g.v_quat, - g.v_scale, g.v_opacity, g.v_R, g.v_t); - break; - case 2: - projection_3dgs_equisolid_vjp(aa, s.mean, s.quat, s.scale, - s.in_opacity, c.R, c.t, c.intrin.x, - c.intrin.y, c.intrin.z, c.intrin.w, - c.dist, width, height, v_xy, v_depth, - v_conic, v_opac, g.v_mean, g.v_quat, - g.v_scale, g.v_opacity, g.v_R, g.v_t); - break; - default: - projection_3dgs_equirect_vjp(aa, s.mean, s.quat, s.scale, - s.in_opacity, c.R, c.t, c.intrin.x, - c.intrin.y, c.intrin.z, c.intrin.w, - c.dist, width, height, v_xy, v_depth, - v_conic, v_opac, g.v_mean, g.v_quat, - g.v_scale, g.v_opacity, g.v_R, g.v_t); - break; - } +void pb_vjp_2d( + PbSplat s, PbCamera c, uint width, uint height, float2 v_xy, + float v_depth, float3 v_conic, float v_opac, inout PbGrads g) { + _projection_3dgs_vjp >( + kAntialiased != 0, s.mean, s.quat, s.scale, s.in_opacity, c.R, c.t, + c.intrin.x, c.intrin.y, c.intrin.z, c.intrin.w, c.dist, width, height, + v_xy, v_depth, v_conic, v_opac, g.v_mean, g.v_quat, g.v_scale, + g.v_opacity, g.v_R, g.v_t); } // One intersection's projection VJP, 3DGUT screen layout {scale, opac}: the // screen-scale grad feeds the conic slot with v_mean2d = 0, v_depth = 0 // (mirrors Primitive3DGUT::project_vjp), antialiased always false. [ForceInline] -void pb_vjp_3dgut(PbSplat s, PbCamera c, uint width, uint height, - float3 v_sscale, float v_sopac, inout PbGrads g) { - switch (kCameraModel) { - case 0: - projection_3dgut_persp_vjp(false, s.mean, s.quat, s.scale, - s.in_opacity, c.R, c.t, c.intrin.x, - c.intrin.y, c.intrin.z, c.intrin.w, - c.dist, width, height, float2(0.0f), 0.0f, - v_sscale, v_sopac, g.v_mean, g.v_quat, - g.v_scale, g.v_opacity, g.v_R, g.v_t); - break; - case 1: - projection_3dgut_fisheye_vjp(false, s.mean, s.quat, s.scale, - s.in_opacity, c.R, c.t, c.intrin.x, - c.intrin.y, c.intrin.z, c.intrin.w, - c.dist, width, height, float2(0.0f), - 0.0f, v_sscale, v_sopac, g.v_mean, - g.v_quat, g.v_scale, g.v_opacity, g.v_R, - g.v_t); - break; - case 2: - projection_3dgut_equisolid_vjp(false, s.mean, s.quat, s.scale, - s.in_opacity, c.R, c.t, c.intrin.x, - c.intrin.y, c.intrin.z, c.intrin.w, - c.dist, width, height, float2(0.0f), - 0.0f, v_sscale, v_sopac, g.v_mean, - g.v_quat, g.v_scale, g.v_opacity, - g.v_R, g.v_t); - break; - default: - projection_3dgut_equirect_vjp(false, s.mean, s.quat, s.scale, - s.in_opacity, c.R, c.t, c.intrin.x, - c.intrin.y, c.intrin.z, c.intrin.w, - c.dist, width, height, float2(0.0f), - 0.0f, v_sscale, v_sopac, g.v_mean, - g.v_quat, g.v_scale, g.v_opacity, - g.v_R, g.v_t); - break; - } +void pb_vjp_3dgut( + PbSplat s, PbCamera c, uint width, uint height, float3 v_sscale, + float v_sopac, inout PbGrads g) { + _projection_3dgs_vjp >( + false, s.mean, s.quat, s.scale, s.in_opacity, c.R, c.t, c.intrin.x, + c.intrin.y, c.intrin.z, c.intrin.w, c.dist, width, height, + float2(0.0f), 0.0f, v_sscale, v_sopac, g.v_mean, g.v_quat, g.v_scale, + g.v_opacity, g.v_R, g.v_t); } // SH color VJP with the value-quant bit depth folded from kShValueBits // (generic args must be parse-time constants; the branch folds away). // `coeffs` is the splat's fp32 SH pointer (unused when kShValueBits != 0). [ForceInline] -void pb_sh_vjp(PbSplat s, PbCamera c, float* coeffs, uint* qpacked, - float2* qbounds, gindex_t qbase, gindex_t qstride, float3 v_rgb, - inout PbGrads g) { +void pb_sh_vjp( + PbSplat s, PbCamera c, float* coeffs, uint* qpacked, float2* qbounds, + gindex_t qbase, gindex_t qstride, float3 v_rgb, inout PbGrads g) { if (kShValueBits == 8) sh_color_vjp<8>(kShDegree, s.mean, c.R, c.t, s.dc, coeffs, qpacked, qbounds, qbase, qstride, v_rgb, g.v_dc, g.v_sh, diff --git a/src/backend/vulkan/shaders/projection_bwd.slang b/src/backend/vulkan/shaders/projection_bwd.slang index 01b82d41..862f7c89 100644 --- a/src/backend/vulkan/shaders/projection_bwd.slang +++ b/src/backend/vulkan/shaders/projection_bwd.slang @@ -14,6 +14,7 @@ // kViewmatGrad = 1: accumulate v_R / v_t into v_viewmats (per-thread CAS // adds -- CUDA's labeled-partition warp reduce is a perf // shortcut with identical, order-nondeterministic sums) +// kDistortion = CameraDistortionType (0..3), declared last #define CudaDeviceExport ForceInline #include "int64_compat.slang" @@ -43,7 +44,7 @@ struct ProjectionBwd3dgsParams { // cameras float* viewmats; // [C,16] row-major float4* intrins; // [C] - float* dist_coeffs; // [C,10] or fallback zeros + float* dist_coeffs; // [C,8] or fallback zeros // packed intersection ids (kPacked; fallback otherwise) int* camera_ids; // [nnz] int* gaussian_ids; // [nnz] @@ -76,7 +77,8 @@ struct ProjectionBwd3dgsParams { uint32_t num_sh_buffer; }; -void _pb_run_3dgs(ProjectionBwd3dgsParams p, uint idx) { +void _pb_run_3dgs( + ProjectionBwd3dgsParams p, uint idx) { uint cid, gid; if (kPacked != 0) { cid = uint(p.camera_ids[idx]); @@ -89,7 +91,8 @@ void _pb_run_3dgs(ProjectionBwd3dgsParams p, uint idx) { gid = idx % p.N; } - PbCamera cam = pb_load_camera(p.viewmats, p.intrins, p.dist_coeffs, cid); + PbCamera c = pb_load_camera(p.viewmats, p.intrins, p.dist_coeffs, + cid); PbSplat s = pb_load_splat(p.means, p.quats, p.scales, p.opacities, p.features_dc, gid); @@ -102,10 +105,11 @@ void _pb_run_3dgs(ProjectionBwd3dgsParams p, uint idx) { p.vs_rgb[3 * idx + 2]); PbGrads g = pb_grads_zero(); - pb_vjp_2d(s, cam, p.width, p.height, v_xy, v_depth, v_conic, v_opac, g); + pb_vjp_2d(s, c, p.width, p.height, v_xy, v_depth, v_conic, v_opac, + g); gindex_t qbase = (gindex_t)3 * (gindex_t)p.num_sh_buffer * (gindex_t)gid; - pb_sh_vjp(s, cam, p.features_sh + gid * p.sh_stride_src, p.sh_packed, - p.sh_bounds, qbase, i64mem_get(p.sh_bounds_stride), v_rgb, g); + pb_sh_vjp(s, c, p.features_sh + gid * p.sh_stride_src, p.sh_packed, + p.sh_bounds, qbase, i64mem_get(p.sh_bounds_stride), v_rgb, g); pb_add3(p.vw_means + 3 * gid, g.v_mean); pb_add4(p.vw_quats + 4 * gid, g.v_quat); @@ -118,6 +122,8 @@ void _pb_run_3dgs(ProjectionBwd3dgsParams p, uint idx) { pb_scatter_viewmat(p.v_viewmats, cid, g.v_R, g.v_t); } +#define _pb_call_2d(M, D) _pb_run_3dgs(p, idx) + [shader("compute")] [numthreads(128, 1, 1)] void projection_bwd_3dgs(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -126,8 +132,9 @@ void projection_bwd_3dgs(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, uint idx = (wg.y * p.wgs_per_row + wg.x) * 128 + tid; uint total = (kPacked != 0) ? p.N : p.C * p.N; if (idx >= total) return; - _pb_run_3dgs(p, idx); + SS_DISPATCH_CAM_DIST(_pb_call_2d) } +#undef _pb_call_2d // --------------------------------------------------------------------------- // 3DGUT: ScreenBuffer grads {scale, opacity, rgb}. @@ -171,7 +178,8 @@ struct ProjectionBwd3dgutParams { uint32_t num_sh_buffer; }; -void _pb_run_3dgut(ProjectionBwd3dgutParams p, uint idx) { +void _pb_run_3dgut( + ProjectionBwd3dgutParams p, uint idx) { uint cid, gid; if (kPacked != 0) { cid = uint(p.camera_ids[idx]); @@ -184,7 +192,8 @@ void _pb_run_3dgut(ProjectionBwd3dgutParams p, uint idx) { gid = idx % p.N; } - PbCamera cam = pb_load_camera(p.viewmats, p.intrins, p.dist_coeffs, cid); + PbCamera c = pb_load_camera(p.viewmats, p.intrins, p.dist_coeffs, + cid); PbSplat s = pb_load_splat(p.means, p.quats, p.scales, p.opacities, p.features_dc, gid); @@ -195,10 +204,10 @@ void _pb_run_3dgut(ProjectionBwd3dgutParams p, uint idx) { p.vs_rgb[3 * idx + 2]); PbGrads g = pb_grads_zero(); - pb_vjp_3dgut(s, cam, p.width, p.height, v_sscale, v_sopac, g); + pb_vjp_3dgut(s, c, p.width, p.height, v_sscale, v_sopac, g); gindex_t qbase = (gindex_t)3 * (gindex_t)p.num_sh_buffer * (gindex_t)gid; - pb_sh_vjp(s, cam, p.features_sh + gid * p.sh_stride_src, p.sh_packed, - p.sh_bounds, qbase, i64mem_get(p.sh_bounds_stride), v_rgb, g); + pb_sh_vjp(s, c, p.features_sh + gid * p.sh_stride_src, p.sh_packed, + p.sh_bounds, qbase, i64mem_get(p.sh_bounds_stride), v_rgb, g); pb_add3(p.vw_means + 3 * gid, g.v_mean); pb_add4(p.vw_quats + 4 * gid, g.v_quat); @@ -211,6 +220,8 @@ void _pb_run_3dgut(ProjectionBwd3dgutParams p, uint idx) { pb_scatter_viewmat(p.v_viewmats, cid, g.v_R, g.v_t); } +#define _pb_call_3d(M, D) _pb_run_3dgut(p, idx) + [shader("compute")] [numthreads(128, 1, 1)] void projection_bwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -219,5 +230,10 @@ void projection_bwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, uint idx = (wg.y * p.wgs_per_row + wg.x) * 128 + tid; uint total = (kPacked != 0) ? p.N : p.C * p.N; if (idx >= total) return; - _pb_run_3dgut(p, idx); + SS_DISPATCH_CAM_DIST(_pb_call_3d) } +#undef _pb_call_3d + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/projection_fwd.slang b/src/backend/vulkan/shaders/projection_fwd.slang index 42cc0342..d10f39fa 100644 --- a/src/backend/vulkan/shaders/projection_fwd.slang +++ b/src/backend/vulkan/shaders/projection_fwd.slang @@ -8,6 +8,7 @@ // kAntialiased = 0 (Vanilla3DGS) | 1 (MipSplatting) // kShValueBits = 0 (fp32) | 8 | 16 (the CUDA VALUE_BITS template axis; // decode via sh_quant.slang's word-based q8/q16 loads) +// kDistortion = CameraDistortionType (0..3), declared last (dist_spec.slang) // // Params exceed the 128-byte push floor -> delivered via the params ring // (push constant = one device address). @@ -18,6 +19,7 @@ #include "shaders/harmonics.slang" #undef CudaDeviceExport #include "sh_quant.slang" +#include "dist_spec.slang" [SpecializationConstant] const int kCameraModel = 0; @@ -68,7 +70,7 @@ struct ProjectionFwdParams { // cameras float* viewmats; // [C,16] row-major float4* intrins; // [C] - float* dist_coeffs; // [C,10] or null + float* dist_coeffs; // [C,8] or null // outputs float4* out_aabb; // [C,N] float* out_depths; // [C,N] @@ -93,8 +95,8 @@ struct ProjectionFwdParams { uint32_t _pad0; }; -void run_projection(ProjectionFwdParams p, - uint idx) { +void run_projection( + ProjectionFwdParams p, uint idx) { uint cid = (idx / p.N) % p.C; uint gid = idx % p.N; @@ -108,11 +110,8 @@ void run_projection(ProjectionFwdParams p, t[r] = vm[4 * r + 3]; } float4 intrin = p.intrins[cid]; - float dist[10]; - [ForceUnroll] - for (int i = 0; i < 10; i++) - dist[i] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * cid + i]; + float dist[D.kNumParams]; + load_dist_coeffs(p.dist_coeffs, cid, dist); // splat float3 mean = float3(p.means[3 * gid], p.means[3 * gid + 1], @@ -131,7 +130,7 @@ void run_projection(ProjectionFwdParams p, float s_depth; float3 s_conic; float s_opac; - projection_3dgs( + projection_3dgs( kAntialiased != 0, mean, quat, scale, in_opacity, R, t, intrin.x, intrin.y, intrin.z, intrin.w, dist, @@ -177,6 +176,8 @@ void run_projection(ProjectionFwdParams p, } } +#define _pf_call(M, D) run_projection(p, idx) + [shader("compute")] [numthreads(128, 1, 1)] void projection_fwd_3dgs(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -184,16 +185,12 @@ void projection_fwd_3dgs(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, ProjectionFwdParams p = *pp; uint idx = (wg.y * p.wgs_per_row + wg.x) * 128 + tid; if (idx >= p.C * p.N) return; - switch (kCameraModel) { - case 0: run_projection(p, idx); break; - case 1: run_projection(p, idx); break; - case 2: run_projection(p, idx); break; - case 3: run_projection(p, idx); break; - } + SS_DISPATCH_CAM_DIST(_pf_call) } +#undef _pf_call // --------------------------------------------------------------------------- -// 3DGUT (eval3d): projection_3dgs, antialiased always +// 3DGUT (eval3d): projection_3dgs, antialiased always // false; the ScreenBuffer is TensorArray<3> {scale, opacity, rgb} where the // "conic" output lands in the scale slot (the eval3d rasterizer culls with // the projected 2D conic). Mirrors Primitive3DGUT.cuh project(). @@ -228,8 +225,8 @@ struct Projection3dgutParams { uint32_t _pad0; }; -void run_projection_3dgut(Projection3dgutParams p, - uint idx) { +void run_projection_3dgut( + Projection3dgutParams p, uint idx) { uint cid = (idx / p.N) % p.C; uint gid = idx % p.N; @@ -242,11 +239,8 @@ void run_projection_3dgut(Projection3dgutParams p, t[r] = vm[4 * r + 3]; } float4 intrin = p.intrins[cid]; - float dist[10]; - [ForceUnroll] - for (int i = 0; i < 10; i++) - dist[i] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * cid + i]; + float dist[D.kNumParams]; + load_dist_coeffs(p.dist_coeffs, cid, dist); float3 mean = float3(p.means[3 * gid], p.means[3 * gid + 1], p.means[3 * gid + 2]); @@ -264,7 +258,7 @@ void run_projection_3dgut(Projection3dgutParams p, float depth; float3 s_scale; float s_opac; - projection_3dgs( + projection_3dgs( false, // antialiased: always false for 3DGUT mean, quat, scale, in_opacity, R, t, intrin.x, intrin.y, intrin.z, intrin.w, dist, @@ -302,6 +296,8 @@ void run_projection_3dgut(Projection3dgutParams p, } } +#define _pg_call(M, D) run_projection_3dgut(p, idx) + [shader("compute")] [numthreads(128, 1, 1)] void projection_fwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -309,14 +305,9 @@ void projection_fwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, Projection3dgutParams p = *pp; uint idx = (wg.y * p.wgs_per_row + wg.x) * 128 + tid; if (idx >= p.C * p.N) return; - switch (kCameraModel) { - case 0: run_projection_3dgut(p, idx); break; - case 1: run_projection_3dgut(p, idx); break; - case 2: run_projection_3dgut(p, idx); break; - case 3: run_projection_3dgut(p, idx); - break; - } + SS_DISPATCH_CAM_DIST(_pg_call) } +#undef _pg_call // --------------------------------------------------------------------------- // Packed projection (two-pass compaction, ProjectionPackedFwd_kernel.cuh). @@ -345,8 +336,8 @@ struct PackedMaskParams { // fits in the 128-byte push floor: pushed direct uint32_t wgs_per_row; }; -void run_packed_mask( - PackedMaskParams p, uint idx) { +void run_packed_mask(PackedMaskParams p, uint idx) { uint cid = (idx / p.N) % p.C; uint gid = idx % p.N; @@ -359,11 +350,8 @@ void run_packed_mask( t[r] = vm[4 * r + 3]; } float4 intrin = p.intrins[cid]; - float dist[10]; - [ForceUnroll] - for (int i = 0; i < 10; i++) - dist[i] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * cid + i]; + float dist[D.kNumParams]; + load_dist_coeffs(p.dist_coeffs, cid, dist); float3 mean = float3(p.means[3 * gid], p.means[3 * gid + 1], p.means[3 * gid + 2]); @@ -381,7 +369,7 @@ void run_packed_mask( float opac; // The mask only consumes the AABB; SH evaluation is skipped (the CUDA // mask kernel computes and discards it). - projection_3dgs( + projection_3dgs( !eval3d && kAntialiased != 0, mean, quat, scale, in_opacity, R, t, intrin.x, intrin.y, intrin.z, intrin.w, dist, @@ -396,6 +384,9 @@ void run_packed_mask( (aabb.z - aabb.x > 1e-3f && aabb.w - aabb.y > 1e-3f) ? 1 : 0; } +#define _pm_call_3d(M, D) run_packed_mask(p, idx) +#define _pm_call_2d(M, D) run_packed_mask(p, idx) + [shader("compute")] [numthreads(128, 1, 1)] void projection_packed_mask(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -403,21 +394,13 @@ void projection_packed_mask(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, uint idx = (wg.y * p.wgs_per_row + wg.x) * 128 + tid; if (idx >= p.C * p.N) return; if (kEval3d != 0) { - switch (kCameraModel) { - case 0: run_packed_mask(p, idx); break; - case 1: run_packed_mask(p, idx); break; - case 2: run_packed_mask(p, idx); break; - case 3: run_packed_mask(p, idx); break; - } + SS_DISPATCH_CAM_DIST(_pm_call_3d) } else { - switch (kCameraModel) { - case 0: run_packed_mask(p, idx); break; - case 1: run_packed_mask(p, idx); break; - case 2: run_packed_mask(p, idx); break; - case 3: run_packed_mask(p, idx); break; - } + SS_DISPATCH_CAM_DIST(_pm_call_2d) } } +#undef _pm_call_3d +#undef _pm_call_2d struct PackedFwdParams { float* means; @@ -453,8 +436,8 @@ struct PackedFwdParams { uint32_t _pad0; }; -void run_packed_fwd( - PackedFwdParams p, uint idx) { +void run_packed_fwd(PackedFwdParams p, uint idx) { int out_idx = idx == 0 ? 0 : p.mask_scan[idx - 1]; if (p.mask_scan[idx] == out_idx) return; @@ -470,11 +453,8 @@ void run_packed_fwd( t[r] = vm[4 * r + 3]; } float4 intrin = p.intrins[cid]; - float dist[10]; - [ForceUnroll] - for (int i = 0; i < 10; i++) - dist[i] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * cid + i]; + float dist[D.kNumParams]; + load_dist_coeffs(p.dist_coeffs, cid, dist); float3 mean = float3(p.means[3 * gid], p.means[3 * gid + 1], p.means[3 * gid + 2]); @@ -492,7 +472,7 @@ void run_packed_fwd( float depth; float3 conic; // eval3d: carries the culling scale (see 3DGUT notes) float opac; - projection_3dgs( + projection_3dgs( !eval3d && kAntialiased != 0, mean, quat, scale, in_opacity, R, t, intrin.x, intrin.y, intrin.z, intrin.w, dist, @@ -546,6 +526,9 @@ void run_packed_fwd( InterlockedMax(p.out_radii[gid], asuint(radius)); } +#define _pk_call_3d(M, D) run_packed_fwd(p, idx) +#define _pk_call_2d(M, D) run_packed_fwd(p, idx) + [shader("compute")] [numthreads(128, 1, 1)] void projection_packed_fwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -554,18 +537,14 @@ void projection_packed_fwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, uint idx = (wg.y * p.wgs_per_row + wg.x) * 128 + tid; if (idx >= p.C * p.N) return; if (kEval3d != 0) { - switch (kCameraModel) { - case 0: run_packed_fwd(p, idx); break; - case 1: run_packed_fwd(p, idx); break; - case 2: run_packed_fwd(p, idx); break; - case 3: run_packed_fwd(p, idx); break; - } + SS_DISPATCH_CAM_DIST(_pk_call_3d) } else { - switch (kCameraModel) { - case 0: run_packed_fwd(p, idx); break; - case 1: run_packed_fwd(p, idx); break; - case 2: run_packed_fwd(p, idx); break; - case 3: run_packed_fwd(p, idx); break; - } + SS_DISPATCH_CAM_DIST(_pk_call_2d) } } +#undef _pk_call_3d +#undef _pk_call_2d + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/projection_qgrad.slang b/src/backend/vulkan/shaders/projection_qgrad.slang index c6fa9fcd..c96e37b1 100644 --- a/src/backend/vulkan/shaders/projection_qgrad.slang +++ b/src/backend/vulkan/shaders/projection_qgrad.slang @@ -13,6 +13,7 @@ // loads never exist (llvmpipe speculated-load rule) // kWorldGradAdd = 1: add mean/quat/scale register grads onto the fp32 // world-grad buffer (3DGUT; one owner thread -> plain add) +// kDistortion = CameraDistortionType (0..3), declared last // // One thread per splat also for !inside tail threads: the camera loop is // fully skipped for them (CUDA reads out-of-bounds aabb entries harmlessly @@ -133,6 +134,55 @@ void _qg_nonsh(bool active, uint* packed, float2* bounds, } } +// The per-splat camera loop, generic over the two projection spec axes so the +// entry point folds them once (its block reduces stay outside). +[ForceInline] +void _qg_camera_loop( + ProjectionQgradParams p, uint gid, bool inside, int cid_0, int cid_1, + inout PbGrads g) { + if (!inside) + return; + PbSplat s = pb_load_splat(p.means, p.quats, p.scales, p.opacities, + p.features_dc, gid); + gindex_t qbase = (gindex_t)3 * (gindex_t)p.num_sh_buffer * (gindex_t)gid; + for (int cid_t = cid_0; cid_t < cid_1; ++cid_t) { + int idx = (kPacked != 0) ? p.perm[cid_t] + : cid_t * int(p.N) + int(gid); + int cid = (kPacked != 0) ? p.camera_ids[idx] : cid_t; + float4 bb = p.aabb[idx]; + if (bb.z <= bb.x || bb.w <= bb.y) + continue; + PbCamera c = pb_load_camera(p.viewmats, p.intrins, + p.dist_coeffs, uint(cid)); + if (kEval3d != 0) { + float3 v_ss = float3(p.vs0[3 * idx], p.vs0[3 * idx + 1], + p.vs0[3 * idx + 2]); + float v_so = p.vs1[idx]; + float3 v_rgb = float3(p.vs2[3 * idx], p.vs2[3 * idx + 1], + p.vs2[3 * idx + 2]); + pb_vjp_3dgut(s, c, p.width, p.height, v_ss, v_so, g); + pb_sh_vjp(s, c, p.features_sh + gid * p.sh_stride_src, + p.sh_value_packed, p.sh_value_bounds, qbase, + i64mem_get(p.sh_value_bounds_stride), v_rgb, g); + } else { + float2 v_xy = float2(p.vs0[2 * idx], p.vs0[2 * idx + 1]); + float v_depth = p.vs1[idx]; + float3 v_conic = float3(p.vs2[3 * idx], p.vs2[3 * idx + 1], + p.vs2[3 * idx + 2]); + float v_opac = p.vs3[idx]; + float3 v_rgb = float3(p.vs4[3 * idx], p.vs4[3 * idx + 1], + p.vs4[3 * idx + 2]); + pb_vjp_2d(s, c, p.width, p.height, v_xy, v_depth, v_conic, + v_opac, g); + pb_sh_vjp(s, c, p.features_sh + gid * p.sh_stride_src, + p.sh_value_packed, p.sh_value_bounds, qbase, + i64mem_get(p.sh_value_bounds_stride), v_rgb, g); + } + } +} + +#define _qg_call(M, D) _qg_camera_loop(p, gid, inside, cid_0, cid_1, g) + [shader("compute")] [numthreads(256, 1, 1)] void projection_qgrad(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -152,46 +202,7 @@ void projection_qgrad(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, } PbGrads g = pb_grads_zero(); - if (inside) { - PbSplat s = pb_load_splat(p.means, p.quats, p.scales, p.opacities, - p.features_dc, gid); - gindex_t qbase = - (gindex_t)3 * (gindex_t)p.num_sh_buffer * (gindex_t)gid; - for (int cid_t = cid_0; cid_t < cid_1; ++cid_t) { - int idx = (kPacked != 0) ? p.perm[cid_t] - : cid_t * int(p.N) + int(gid); - int cid = (kPacked != 0) ? p.camera_ids[idx] : cid_t; - float4 bb = p.aabb[idx]; - if (bb.z <= bb.x || bb.w <= bb.y) - continue; - PbCamera cam = pb_load_camera(p.viewmats, p.intrins, - p.dist_coeffs, uint(cid)); - if (kEval3d != 0) { - float3 v_ss = float3(p.vs0[3 * idx], p.vs0[3 * idx + 1], - p.vs0[3 * idx + 2]); - float v_so = p.vs1[idx]; - float3 v_rgb = float3(p.vs2[3 * idx], p.vs2[3 * idx + 1], - p.vs2[3 * idx + 2]); - pb_vjp_3dgut(s, cam, p.width, p.height, v_ss, v_so, g); - pb_sh_vjp(s, cam, p.features_sh + gid * p.sh_stride_src, - p.sh_value_packed, p.sh_value_bounds, qbase, - i64mem_get(p.sh_value_bounds_stride), v_rgb, g); - } else { - float2 v_xy = float2(p.vs0[2 * idx], p.vs0[2 * idx + 1]); - float v_depth = p.vs1[idx]; - float3 v_conic = float3(p.vs2[3 * idx], p.vs2[3 * idx + 1], - p.vs2[3 * idx + 2]); - float v_opac = p.vs3[idx]; - float3 v_rgb = float3(p.vs4[3 * idx], p.vs4[3 * idx + 1], - p.vs4[3 * idx + 2]); - pb_vjp_2d(s, cam, p.width, p.height, v_xy, v_depth, v_conic, - v_opac, g); - pb_sh_vjp(s, cam, p.features_sh + gid * p.sh_stride_src, - p.sh_value_packed, p.sh_value_bounds, qbase, - i64mem_get(p.sh_value_bounds_stride), v_rgb, g); - } - } - } + SS_DISPATCH_CAM_DIST(_qg_call) // fp32 geometry writeback (3DGUT: add proj contribution onto the // raster-bwd world grads; one owner thread per gid -> race-free adds). @@ -265,6 +276,8 @@ void projection_qgrad(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, } } +#undef _qg_call + // --------------------------------------------------------------------------- // Packed-mode preprocessing helpers (mirror the FPBO/qgrad iota + // camera_id_bounds kernels; the sort itself runs via backend::sort_pairs). @@ -306,3 +319,7 @@ void qgrad_camera_id_bounds(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, for (int k = lo; k <= hi; ++k) p.camera_id_bounds[k] = int(i); } + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/rasterize_bwd.slang b/src/backend/vulkan/shaders/rasterize_bwd.slang index 3ba42b43..6c6803d2 100644 --- a/src/backend/vulkan/shaders/rasterize_bwd.slang +++ b/src/backend/vulkan/shaders/rasterize_bwd.slang @@ -31,6 +31,7 @@ // kAccumWeight = 0 | 1 (o_accum_weight + accum_weight_map wired) // kViewmatGrad = 0 | 1 (3dgut entry only) // kPacked = 0 | 1 (gaussian_ids present) +// kDistortion = CameraDistortionType 0..3 (3dgut entry only), last #define CudaDeviceExport ForceInline #include "int64_compat.slang" @@ -39,6 +40,7 @@ #include "raster_common.slang" #include "atomic_float.slang" +#include "dist_spec.slang" [SpecializationConstant] const int kCameraModel = 0; @@ -491,7 +493,7 @@ struct Raster3dgutBwdParams { // via params ring int* gaussian_ids; float* viewmats; // [I,16] float4* intrins; // [I] - float* dist_coeffs; // [I,10] (fallback-backed) + float* dist_coeffs; // [I,8] (fallback-backed) float4* aabb; int* tile_offsets; int* flatten_ids; @@ -610,6 +612,11 @@ void _rb3_reduce_add(float* dst, float val, uint tid) { } } +#define _rb_ray(D) \ + ray_ok = pixel_ray(p.dist_coeffs, image_id, kCameraModel, \ + float2((px - intrin.z) / intrin.x, \ + (py - intrin.w) / intrin.y), raydir) + [shader("compute")] [numthreads(32, 1, 1)] void rasterize_bwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -629,11 +636,6 @@ void rasterize_bwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, R[r] = float3(vm[4 * r + 0], vm[4 * r + 1], vm[4 * r + 2]); float3 tvec = float3(vm[3], vm[7], vm[11]); float4 intrin = p.intrins[image_id]; - float dist[10]; - [ForceUnroll] - for (int k = 0; k < 10; k++) - dist[k] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * image_id + k]; float3 ray_o = transform_ray_o(R, tvec); float3 total_v_ray_o = float3(0.0f); @@ -647,10 +649,9 @@ void rasterize_bwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, int bin_final = inside ? p.last_ids[img_off + gpix] : -1; float px = float(gx) + 0.5f; float py = float(gy) + 0.5f; - float3 raydir; - bool ray_ok = generate_ray( - float2((px - intrin.z) / intrin.x, (py - intrin.w) / intrin.y), - kCameraModel, dist, raydir); + float3 raydir = float3(0.0f); + bool ray_ok = false; + SS_DISPATCH_DIST(_rb_ray) inside = inside && ray_ok; float3 ray_d = transform_ray_d(R, raydir); _rb_raybin[pix] = float4(ray_d, asfloat(bin_final)); @@ -826,3 +827,9 @@ void rasterize_bwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, _rb3_reduce_add(v_viewmat + 11, v_t.z, tid); } } + +#undef _rb_ray + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/rasterize_fwd.slang b/src/backend/vulkan/shaders/rasterize_fwd.slang index 70e9da66..dd68b3ef 100644 --- a/src/backend/vulkan/shaders/rasterize_fwd.slang +++ b/src/backend/vulkan/shaders/rasterize_fwd.slang @@ -10,6 +10,7 @@ // kCameraModel = CameraModelType 0..3 (eval3d entry only) // kDistType = 0 None | 1 D | 2 RGB_D (the instantiated subset) // kOutputMedian = 0 | 1 +// kDistortion = CameraDistortionType 0..3 (eval3d entry only), last // The primitive pixel type is RGB_D for all current primitives, so the // render output channels are hard-wired to rgb + depth. // @@ -27,6 +28,7 @@ #undef CudaDeviceExport #include "raster_common.slang" +#include "dist_spec.slang" [SpecializationConstant] const int kCameraModel = 0; @@ -306,7 +308,7 @@ struct RasterFwd3dgutParams { // cameras float* viewmats; // [I, 16] row-major float4* intrins; // [I] - float* dist_coeffs; // [I, 10] or null + float* dist_coeffs; // [I, 8] or null float4* aabb; // [..] projected 2D AABB (xmin,ymin,xmax,ymax) int* tile_offsets; // [I, tile_height, tile_width] int* flatten_ids; // [n_isects] @@ -327,6 +329,11 @@ struct RasterFwd3dgutParams { uint32_t tile_height; }; +#define _rf_ray(D) \ + ray_ok = pixel_ray(p.dist_coeffs, image_id, kCameraModel, \ + float2((px - intrin.z) / intrin.x, \ + (py - intrin.w) / intrin.y), raydir) + [shader("compute")] [numthreads(64, 1, 1)] void rasterize_fwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -351,11 +358,6 @@ void rasterize_fwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, ct[r] = vm[4 * r + 3]; } float4 intrin = p.intrins[image_id]; - float dist[10]; - [ForceUnroll] - for (int k = 0; k < 10; k++) - dist[k] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * image_id + k]; float3 ray_o = transform_ray_o(R, ct); @@ -366,11 +368,10 @@ void rasterize_fwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, bool inside = (i < p.height && j < p.width); - float3 raydir; - inside = inside && - generate_ray(float2((px - intrin.z) / intrin.x, - (py - intrin.w) / intrin.y), - kCameraModel, dist, raydir); + float3 raydir = float3(0.0f); + bool ray_ok = false; + SS_DISPATCH_DIST(_rf_ray) + inside = inside && ray_ok; float3 ray_d = transform_ray_d(R, raydir); bool done = !inside; @@ -538,3 +539,9 @@ void rasterize_fwd_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, p.out_last_ids[pix_id_global] = int(cur_idx); } } + +#undef _rf_ray + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/rasterize_moments.slang b/src/backend/vulkan/shaders/rasterize_moments.slang index 74d81f3d..cdeae350 100644 --- a/src/backend/vulkan/shaders/rasterize_moments.slang +++ b/src/backend/vulkan/shaders/rasterize_moments.slang @@ -7,7 +7,8 @@ // occ_from_moment) -- plus the optional full-ray DC color image. // // Only 3DGUT with the three supported camera models is instantiated, matching -// the CUDA side; the camera model is a specialization constant. +// the CUDA side; the camera model and distortion tier are specialization +// constants (kDistortion declared last -- see dist_spec.slang). #define CudaDeviceExport ForceInline #include "int64_compat.slang" @@ -15,6 +16,7 @@ #undef CudaDeviceExport #include "raster_common.slang" +#include "dist_spec.slang" [SpecializationConstant] const int kCameraModel = 0; @@ -51,7 +53,7 @@ struct RasterMomentsParams { // cameras float* viewmats; // [I, 16] row-major float4* intrins; // [I] - float* dist_coeffs; // [I, 10] (never null: zeroed fallback) + float* dist_coeffs; // [I, 8] (never null: zeroed fallback) float4* aabb; // [..] projected 2D AABB (xmin,ymin,xmax,ymax) int* tile_offsets; // [I, tile_height, tile_width] int* flatten_ids; // [n_isects] @@ -68,6 +70,11 @@ struct RasterMomentsParams { uint32_t _pad0; }; +#define _rm_ray(D) \ + ray_ok = pixel_ray(p.dist_coeffs, image_id, kCameraModel, \ + float2((px - intrin.z) / intrin.x, \ + (py - intrin.w) / intrin.y), raydir) + [shader("compute")] [numthreads(64, 1, 1)] void rasterize_moments_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -92,10 +99,6 @@ void rasterize_moments_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, ct[r] = vm[4 * r + 3]; } float4 intrin = p.intrins[image_id]; - float dist[10]; - [ForceUnroll] - for (int k = 0; k < 10; k++) - dist[k] = p.dist_coeffs[10 * image_id + k]; float3 ray_o = transform_ray_o(R, ct); @@ -106,11 +109,10 @@ void rasterize_moments_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, bool inside = (i < p.height && j < p.width); - float3 raydir; - inside = inside && - generate_ray(float2((px - intrin.z) / intrin.x, - (py - intrin.w) / intrin.y), - kCameraModel, dist, raydir); + float3 raydir = float3(0.0f); + bool ray_ok = false; + SS_DISPATCH_DIST(_rm_ray) + inside = inside && ray_ok; float3 ray_d = transform_ray_d(R, raydir); bool done = !inside; @@ -243,3 +245,9 @@ void rasterize_moments_3dgut(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, } } } + +#undef _rm_ray + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/visualizer.slang b/src/backend/vulkan/shaders/visualizer.slang index 0be29de0..ae508fe1 100644 --- a/src/backend/vulkan/shaders/visualizer.slang +++ b/src/backend/vulkan/shaders/visualizer.slang @@ -28,6 +28,31 @@ #include "int64_compat.slang" #include "int8_compat.slang" +#include "dist_spec.slang" + +// generate_ray with the tier folded from kDistortion, taking the full 8-float +// storage row: the callers keep their groupshared barriers at top level. +[ForceInline] +bool _vis_ray(float2 uv, int camera_model, + float row[kDistCoeffRow], + out float3 raydir) { + float dc[D.kNumParams]; + [ForceUnroll] + for (int k = 0; k < D.kNumParams; k++) dc[k] = row[k]; + return generate_ray(uv, camera_model, dc, raydir); +} + +#define _vis_ray_call(D) ok = _vis_ray(uv, camera_model, row, raydir) + +[ForceInline] +bool vis_ray(float2 uv, int camera_model, float row[kDistCoeffRow], + out float3 raydir) { + bool ok = false; + raydir = float3(0.0f); + SS_DISPATCH_DIST(_vis_ray_call) + return ok; +} +#undef _vis_ray_call static const int kNumFrustumSegments = 16; static const int kNumFrustumFaces = 8; @@ -64,7 +89,7 @@ struct VisFrustumParams { // 76 -> 80 bytes: pushed directly int* widths; // [N] int* heights; // [N] int* camera_models; // [N] - float* dist_coeffs; // [N,10] or null + float* dist_coeffs; // [N,8] or null float* camera_to_worlds; // [N,3,4] float4* lss_buffer; // [N, 8*kNumFrustumSegments, 2] float4* tri_buffer; // [N, 4*kNumFrustumFaces^2, 4] @@ -76,15 +101,15 @@ struct VisFrustumParams { // 76 -> 80 bytes: pushed directly groupshared float3 _vis_polylines[4 * kNumFrustumSegments]; [ForceInline] -float3 frustum_ray(float2 uv, int camera_model, float dist[10]) { +float3 frustum_ray(float2 uv, int camera_model, float dist[kDistCoeffRow]) { float3 raydir = float3(asfloat(0x7fc00000u)); // NaN - if (!generate_ray(uv, camera_model, dist, raydir)) { + if (!vis_ray(uv, camera_model, dist, raydir)) { // binary search for the last valid uv toward the center float t0 = 0.0f, t1 = 1.0f; for (int iter = 0; iter < 12; ++iter) { float t = 0.5f * (t0 + t1); float3 temp; - if (generate_ray(uv * t, camera_model, dist, temp)) { + if (vis_ray(uv * t, camera_model, dist, temp)) { t0 = t; raydir = temp; } else { @@ -107,11 +132,12 @@ void vis_fill_frustum(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, float width = float(p.widths[bid]); float height = float(p.heights[bid]); int camera_model = p.camera_models[bid]; - float dist[10]; + float dist[kDistCoeffRow]; [ForceUnroll] - for (int k = 0; k < 10; k++) - dist[k] = is_null(p.dist_coeffs) ? 0.0f - : p.dist_coeffs[10 * bid + k]; + for (int k = 0; k < kDistCoeffRow; k++) + dist[k] = is_null(p.dist_coeffs) + ? 0.0f + : p.dist_coeffs[kDistCoeffRow * bid + k]; float2 corners[4] = { float2(-cx / fx, -cy / fy), float2((width - cx) / fx, -cy / fy), @@ -812,7 +838,7 @@ struct VisBlitParams { // 16 ptrs + 11 scalars: via params ring float* render_alphas; // [H,W,1] float4* view_intrins; // [4] (one camera) float* view_viewmat; // [4,4] - float* view_dist; // [10] or null + float* view_dist; // [8] or null float4* lss_buffer; // or null int2* lss_nodes; float3* lss_aabb; @@ -922,9 +948,9 @@ void vis_blit(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, p.view_viewmat[4 * r + 2]); float3 t = float3(p.view_viewmat[3], p.view_viewmat[7], p.view_viewmat[11]); - float dist[10]; + float dist[kDistCoeffRow]; [ForceUnroll] - for (int k = 0; k < 10; k++) + for (int k = 0; k < kDistCoeffRow; k++) dist[k] = is_null(p.view_dist) ? 0.0f : p.view_dist[k]; float alpha_final = 0.0f; @@ -938,8 +964,7 @@ void vis_blit(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, float3 ray_o = transform_ray_o(R, t); float3 ray_d; float2 uv = float2((px - cx) / fx, (py - cy) / fy); - bool inside = - generate_ray(uv, p.view_camera_model, dist, ray_d); + bool inside = vis_ray(uv, p.view_camera_model, dist, ray_d); if (p.view_camera_model == 1 /*FISHEYE*/) inside = inside && length(uv) < 3.14159265358979323846f; if (p.view_camera_model == 2 /*EQUISOLID*/) @@ -1197,3 +1222,7 @@ void vis_update_thumbnails(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, if (tid == 0) u8_store(p.done_mask, post_idx, 0xffu); } + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +[SpecializationConstant] +const int kDistortion = 0; diff --git a/src/backend/vulkan/shaders/warp.slang b/src/backend/vulkan/shaders/warp.slang index 5e9c286b..4d06ead0 100644 --- a/src/backend/vulkan/shaders/warp.slang +++ b/src/backend/vulkan/shaders/warp.slang @@ -1,6 +1,7 @@ -// Dataset GT warp + byte->float conversion kernels (Vulkan backend), -// mirroring kernels/pixelwise/ImageWarp.cu + GtDepthNormalWarp.cu (launch_warp_*) and -// the raw converters (uint8/16_*_to_float_raw). The wide warps project each +// Dataset GT warp + re-distort + byte->float conversion kernels (Vulkan +// backend), mirroring kernels/pixelwise/ImageWarp.cu + GtDepthNormalWarp.cu +// (launch_warp_*) + ImageRedistort.cu (launch_redistort_*) and the raw +// converters (uint8/16_*_to_float_raw). The wide warps project each // pinhole-face ray through the same canonical projection_utils.slang // *_proj_nav exports the CUDA kernels call, so per-pixel outputs differ only // by fast-math rounding (plus isolated valid-flip / nearest-rounding pixels @@ -21,7 +22,9 @@ #include "int64_compat.slang" #include "int8_compat.slang" #include "shaders/projection_utils.slang" +#include "shaders/camera_source.slang" #undef CudaDeviceExport +#include "dist_spec.slang" // Input element kinds (the CUDA T_in template axis / elem_size dispatch). static const int kElemU8 = 0; @@ -92,14 +95,6 @@ float4 _wp_intrin(float* intrins, int bid) { intrins[bid * 4 + 2], intrins[bid * 4 + 3]); } -[ForceInline] -float[10] _wp_dist(float* dist_coeffs, int bid) { - float[10] dc; - [ForceUnroll] - for (int k = 0; k < 10; k++) dc[k] = dist_coeffs[bid * 10 + k]; - return dc; -} - [ForceInline] void _wp_axes(float* axes, int ki, out float3 ax, out float3 ay, out float3 az) { @@ -109,15 +104,44 @@ void _wp_axes(float* axes, int ki, out float3 ax, out float3 ay, az = float3(axes[b + 6], axes[b + 7], axes[b + 8]); } -// Camera-model dispatch matching the CUDA kernels' ternary chain. +// Camera-model dispatch matching the CUDA kernels' ternary chain; the +// distortion tier comes from kDistortion. [ForceInline] -bool _wp_proj(int camera_model, float3 raydir, float4 intrin, - float[10] dist_coeffs, out float2 uv) { +bool _wp_proj(int camera_model, float3 raydir, + float4 intrin, float* dist_coeffs, + int bid, out float2 uv) { + float dc[D.kNumParams]; + load_dist_coeffs(dist_coeffs, uint(bid), dc); if (camera_model == int(CameraModelType::FISHEYE)) - return fisheye_proj_nav(raydir, intrin, dist_coeffs, uv); + return fisheye_proj(raydir, intrin, dc, uv); if (camera_model == int(CameraModelType::EQUISOLID)) - return equisolid_proj_nav(raydir, intrin, dist_coeffs, uv); - return persp_proj_nav(raydir, intrin, dist_coeffs, uv); + return equisolid_proj(raydir, intrin, dc, uv); + return persp_proj(raydir, intrin, dc, uv); +} + +// Ray -> pixel of image `bid` through its TRUE COLMAP lens model, for cameras +// the parser could only fit onto a tier (see shaders/camera_source.slang). +[ForceInline] +bool _wp_source_proj(int* source_models, float* source_params, int bid, + float3 raydir, out float2 uv) { + float sp[kSourceMaxParams]; + [ForceUnroll] + for (int k = 0; k < kSourceMaxParams; k++) + sp[k] = source_params[kSourceMaxParams * bid + k]; + return source_project(source_models[bid], sp, raydir, uv); +} + +// RayToPixel mirror: kFromSource resamples from the source projection instead +// of the fitted one. +[ForceInline] +bool _wp_to_pixel(int camera_model, float3 raydir, + float4 intrin, float* dist_coeffs, + int* source_models, + float* source_params, int bid, + out float2 uv) { + if (kFromSource != 0) + return _wp_source_proj(source_models, source_params, bid, raydir, uv); + return _wp_proj(camera_model, raydir, intrin, dist_coeffs, bid, uv); } // Equirectangular sample position for a face ray (see ImageWarp.cu; f is @@ -164,15 +188,17 @@ float3 _wp_one_normal(uint* src, int kind, gindex_t plane, int H, int W, return r / rl; } -// Shared params for the image / depth / normal warp entries. 96 bytes: -// pushed directly (by value). Pointer fields are never null (zeros +// Shared params for the image / depth / normal warp and re-distort entries. +// 120 bytes: pushed directly (by value). Pointer fields are never null (zeros // fallback); the *_equi entries statically ignore intrins / dist_coeffs. struct WarpParams { - float* intrins; // [B, 4] - float* dist_coeffs; // [B, 10] - uint* src; // [B, Hin, Win, C] u8 / u16 / f32 elements - float* dst; // [B, K, Hout, Wout, C] float - float* axes; // [K, 3, 3] face axes + float* intrins; // [B, 4] + float* dist_coeffs; // [B, 8] + int* source_models; // [B] COLMAP model id (kFromSource / redistort) + float* source_params; // [B, 16] that model's parameters + uint* src; // [B, Hin, Win, C] u8 / u16 / f32 elements + float* dst; // [B, K, Hout, Wout, C] float + float* axes; // [K, 3, 3] face axes int B; int Hin; int Win; @@ -182,11 +208,13 @@ struct WarpParams { int Wout; int elem_kind; // kElemU8 / kElemU16 / kElemF32 int camera_model; // CameraModelType (wide entries) - int in_H; // intrinsics reference resolution (the projected uv is - int in_W; // in this pixel space; depth/normal rescale to Hin/Win) + int ref_H; // intrinsics reference resolution (the projected uv is + int ref_W; // in this pixel space; every grid rescales from it) int ray_depth; // depth entries: input already stores ray depth float norm_inv; float decode_off; // normal entries: post-normalization offset + float invalid; // redistort entries: out-of-frame fill + int _pad0; }; // 16x16 logical tile decode: flat 256-wide workgroups (the pinned 32-wide @@ -202,22 +230,19 @@ bool _wp_tile(WarpParams p, uint3 wg, uint tid, out int i, out int j, return i < p.Wout && j < p.Hout; } -[shader("compute")] -[numthreads(256, 1, 1)] -void warp_img_wide(uniform WarpParams p, uint3 wg: SV_GroupID, - uint tid: SV_GroupIndex) { - int i, j, bid; - float tx, ty; - if (!_wp_tile(p, wg, tid, i, j, bid, tx, ty)) return; +[ForceInline] +void _wp_img_wide(WarpParams p, int i, int j, int bid, + float tx, float ty) { float4 intrin = _wp_intrin(p.intrins, bid); - float[10] dc = _wp_dist(p.dist_coeffs, bid); gindex_t plane = gindex_t(bid) * p.Hin * p.Win; for (int ki = 0; ki < p.K; ki++) { float3 ax, ay, az; _wp_axes(p.axes, ki, ax, ay, az); float3 raydir = az + tx * ax + ty * ay; float2 uv; - bool valid = _wp_proj(p.camera_model, raydir, intrin, dc, uv); + bool valid = _wp_to_pixel(p.camera_model, raydir, intrin, + p.dist_coeffs, p.source_models, + p.source_params, bid, uv); gindex_t base = (((gindex_t(bid) * p.K + ki) * p.Hout + j) * p.Wout + i) * p.C; for (int c = 0; c < p.C; c++) { float v = 0.5f; @@ -229,6 +254,19 @@ void warp_img_wide(uniform WarpParams p, uint3 wg: SV_GroupID, } } +#define _wp_img_call(D) _wp_img_wide(p, i, j, bid, tx, ty) + +[shader("compute")] +[numthreads(256, 1, 1)] +void warp_img_wide(uniform WarpParams p, uint3 wg: SV_GroupID, + uint tid: SV_GroupIndex) { + int i, j, bid; + float tx, ty; + if (!_wp_tile(p, wg, tid, i, j, bid, tx, ty)) return; + SS_DISPATCH_DIST(_wp_img_call) +} +#undef _wp_img_call + [shader("compute")] [numthreads(256, 1, 1)] void warp_img_equi(uniform WarpParams p, uint3 wg: SV_GroupID, @@ -250,25 +288,22 @@ void warp_img_equi(uniform WarpParams p, uint3 wg: SV_GroupID, } } -[shader("compute")] -[numthreads(256, 1, 1)] -void warp_depth_wide(uniform WarpParams p, uint3 wg: SV_GroupID, - uint tid: SV_GroupIndex) { - int i, j, bid; - float tx, ty; - if (!_wp_tile(p, wg, tid, i, j, bid, tx, ty)) return; +[ForceInline] +void _wp_depth_wide(WarpParams p, int i, int j, + int bid, float tx, float ty) { float4 intrin = _wp_intrin(p.intrins, bid); - float[10] dc = _wp_dist(p.dist_coeffs, bid); gindex_t plane = gindex_t(bid) * p.Hin * p.Win; // Projected uv is in intrinsics-reference (RGB input) pixel space; // rescale to the GT depth map's own resolution. - float sx = float(p.Win) / float(p.in_W), sy = float(p.Hin) / float(p.in_H); + float sx = float(p.Win) / float(p.ref_W), sy = float(p.Hin) / float(p.ref_H); for (int ki = 0; ki < p.K; ki++) { float3 ax, ay, az; _wp_axes(p.axes, ki, ax, ay, az); float3 raydir = az + tx * ax + ty * ay; float2 uv; - bool valid = _wp_proj(p.camera_model, raydir, intrin, dc, uv); + bool valid = _wp_to_pixel(p.camera_model, raydir, intrin, + p.dist_coeffs, p.source_models, + p.source_params, bid, uv); float outv = 0.0f; if (valid) { float d = _wp_bilinear(p.src, p.elem_kind, plane, p.Hin, p.Win, 1, @@ -280,6 +315,19 @@ void warp_depth_wide(uniform WarpParams p, uint3 wg: SV_GroupID, } } +#define _wp_depth_call(D) _wp_depth_wide(p, i, j, bid, tx, ty) + +[shader("compute")] +[numthreads(256, 1, 1)] +void warp_depth_wide(uniform WarpParams p, uint3 wg: SV_GroupID, + uint tid: SV_GroupIndex) { + int i, j, bid; + float tx, ty; + if (!_wp_tile(p, wg, tid, i, j, bid, tx, ty)) return; + SS_DISPATCH_DIST(_wp_depth_call) +} +#undef _wp_depth_call + [shader("compute")] [numthreads(256, 1, 1)] void warp_depth_equi(uniform WarpParams p, uint3 wg: SV_GroupID, @@ -300,23 +348,20 @@ void warp_depth_equi(uniform WarpParams p, uint3 wg: SV_GroupID, } } -[shader("compute")] -[numthreads(256, 1, 1)] -void warp_normal_wide(uniform WarpParams p, uint3 wg: SV_GroupID, - uint tid: SV_GroupIndex) { - int i, j, bid; - float tx, ty; - if (!_wp_tile(p, wg, tid, i, j, bid, tx, ty)) return; +[ForceInline] +void _wp_normal_wide(WarpParams p, int i, int j, + int bid, float tx, float ty) { float4 intrin = _wp_intrin(p.intrins, bid); - float[10] dc = _wp_dist(p.dist_coeffs, bid); gindex_t plane = gindex_t(bid) * p.Hin * p.Win; - float sx = float(p.Win) / float(p.in_W), sy = float(p.Hin) / float(p.in_H); + float sx = float(p.Win) / float(p.ref_W), sy = float(p.Hin) / float(p.ref_H); for (int ki = 0; ki < p.K; ki++) { float3 ax, ay, az; _wp_axes(p.axes, ki, ax, ay, az); float3 raydir = az + tx * ax + ty * ay; float2 uv; - bool valid = _wp_proj(p.camera_model, raydir, intrin, dc, uv); + bool valid = _wp_to_pixel(p.camera_model, raydir, intrin, + p.dist_coeffs, p.source_models, + p.source_params, bid, uv); float3 nf = float3(-1.0f); if (valid) nf = _wp_one_normal(p.src, p.elem_kind, plane, p.Hin, p.Win, @@ -329,6 +374,19 @@ void warp_normal_wide(uniform WarpParams p, uint3 wg: SV_GroupID, } } +#define _wp_normal_call(D) _wp_normal_wide(p, i, j, bid, tx, ty) + +[shader("compute")] +[numthreads(256, 1, 1)] +void warp_normal_wide(uniform WarpParams p, uint3 wg: SV_GroupID, + uint tid: SV_GroupIndex) { + int i, j, bid; + float tx, ty; + if (!_wp_tile(p, wg, tid, i, j, bid, tx, ty)) return; + SS_DISPATCH_DIST(_wp_normal_call) +} +#undef _wp_normal_call + [shader("compute")] [numthreads(256, 1, 1)] void warp_normal_equi(uniform WarpParams p, uint3 wg: SV_GroupID, @@ -356,12 +414,14 @@ void warp_normal_equi(uniform WarpParams p, uint3 wg: SV_GroupID, // map to whole u32 OUTPUT words in the flat [B, K, Hout, Wout] byte space: // each thread decodes its 4 byte positions independently and stores one // word, so there is exactly one writer per word and no atomics. -struct WarpMaskParams { // 72 bytes: pushed directly - float* intrins; // [B, 4] - float* dist_coeffs; // [B, 10] - uint* src; // [B, Hin, Win] uint8 - uint* dst; // [B, K, Hout, Wout] uint8 (word writes) - float* axes; // [K, 3, 3] +struct WarpMaskParams { // 96 bytes: pushed directly + float* intrins; // [B, 4] + float* dist_coeffs; // [B, 8] + int* source_models; // [B] + float* source_params; // [B, 16] + uint* src; // [B, Hin, Win] uint8 + uint* dst; // [B, K, Hout, Wout] uint8 (word writes) + float* axes; // [K, 3, 3] int B; int Hin; int Win; @@ -369,11 +429,14 @@ struct WarpMaskParams { // 72 bytes: pushed directly int Hout; int Wout; int camera_model; + int ref_H; // intrinsics reference resolution (redistort entry) + int ref_W; uint wgs_per_row; }; [ForceInline] -uint _wp_mask_byte(WarpMaskParams p, uint n, bool equi) { +uint _wp_mask_byte(WarpMaskParams p, uint n, + bool equi) { uint i = n % uint(p.Wout); uint t = n / uint(p.Wout); uint j = t % uint(p.Hout); @@ -395,9 +458,10 @@ uint _wp_mask_byte(WarpMaskParams p, uint n, bool equi) { ys = clamp(ys, 0, p.Hin - 1); } else { float4 intrin = _wp_intrin(p.intrins, int(bid)); - float[10] dc = _wp_dist(p.dist_coeffs, int(bid)); float2 uv; - if (!_wp_proj(p.camera_model, raydir, intrin, dc, uv)) return 0u; + if (!_wp_to_pixel(p.camera_model, raydir, intrin, p.dist_coeffs, + p.source_models, p.source_params, int(bid), uv)) + return 0u; xs = int(floor(clamp(uv.x + 0.5f, -8.0f, float(p.Win) + 8.0f))); ys = int(floor(clamp(uv.y + 0.5f, -8.0f, float(p.Hin) + 8.0f))); if (xs < 0 || xs >= p.Win || ys < 0 || ys >= p.Hin) return 0u; @@ -407,7 +471,8 @@ uint _wp_mask_byte(WarpMaskParams p, uint n, bool equi) { } [ForceInline] -void _wp_mask_main(WarpMaskParams p, uint3 wg, uint tid, bool equi) { +void _wp_mask_main(WarpMaskParams p, uint3 wg, + uint tid, bool equi) { uint word = (wg.y * p.wgs_per_row + wg.x) * 256u + tid; uint total = uint(p.B * p.K) * uint(p.Hout) * uint(p.Wout); if (word >= (total + 3u) / 4u) return; @@ -415,25 +480,179 @@ void _wp_mask_main(WarpMaskParams p, uint3 wg, uint tid, bool equi) { for (uint b = 0; b < 4u; b++) { uint n = word * 4u + b; if (n < total) - outw |= _wp_mask_byte(p, n, equi) << (b * 8u); + outw |= _wp_mask_byte(p, n, equi) << (b * 8u); } p.dst[word] = outw; } +#define _wp_mask_call(D) _wp_mask_main(p, wg, tid, false) + [shader("compute")] [numthreads(256, 1, 1)] void warp_mask_wide(uniform WarpMaskParams p, uint3 wg: SV_GroupID, uint tid: SV_GroupIndex) { - _wp_mask_main(p, wg, tid, false); + SS_DISPATCH_DIST(_wp_mask_call) } +#undef _wp_mask_call [shader("compute")] [numthreads(256, 1, 1)] void warp_mask_equi(uniform WarpMaskParams p, uint3 wg: SV_GroupID, uint tid: SV_GroupIndex) { - _wp_mask_main(p, wg, tid, true); + _wp_mask_main(p, wg, tid, true); } +// Re-distort: resample a GT image from a camera whose lens model no distortion +// tier represents onto the tier the parser fitted for it (mirrors +// kernels/pixelwise/ImageRedistort.cu). The fit keeps the pose, so a +// destination pixel and its source pixel are the same ray. Both grids are +// expressed relative to the intrinsics reference (ref_H/ref_W, the RGB +// resolution) and need not match: a depth or normal map carries its own size, +// so scale_out (destination step) and scale_in (source lookup) differ. +[ForceInline] +bool _rd_lookup(float* intrins, float* dist_coeffs, + int* source_models, + float* source_params, int camera_model, + int bid, int i, int j, float2 scale_out, + float2 scale_in, out float2 uv_src) { + uv_src = float2(0.0f); + float4 intrin = _wp_intrin(intrins, bid); + float2 uv = float2(((float(i) + 0.5f) / scale_out.x - intrin.z) / intrin.x, + ((float(j) + 0.5f) / scale_out.y - intrin.w) / intrin.y); + float dc[D.kNumParams]; + load_dist_coeffs(dist_coeffs, uint(bid), dc); + float3 raydir; + if (!unproject_point(uv, camera_model, dc, raydir)) + return false; + if (!_wp_source_proj(source_models, source_params, bid, raydir, uv_src)) + return false; + uv_src *= scale_in; + return true; +} + +[ForceInline] +float2 _rd_scale(int W, int H, int ref_W, int ref_H) { + return float2(float(W) / float(ref_W), float(H) / float(ref_H)); +} + +[ForceInline] +void _rd_img(WarpParams p, int i, int j, int bid) { + float2 uv_src; + bool valid = _rd_lookup(p.intrins, p.dist_coeffs, p.source_models, + p.source_params, p.camera_model, bid, i, j, + _rd_scale(p.Wout, p.Hout, p.ref_W, p.ref_H), + _rd_scale(p.Win, p.Hin, p.ref_W, p.ref_H), + uv_src); + gindex_t plane = gindex_t(bid) * p.Hin * p.Win; + gindex_t base = ((gindex_t(bid) * p.Hout + j) * p.Wout + i) * p.C; + for (int c = 0; c < p.C; c++) { + float v = p.invalid; + if (valid) + v = _wp_bilinear(p.src, p.elem_kind, plane, p.Hin, p.Win, p.C, c, + uv_src.x, uv_src.y, p.norm_inv, p.invalid, false); + p.dst[base + c] = v; + } +} + +#define _rd_img_call(D) _rd_img(p, i, j, bid) + +[shader("compute")] +[numthreads(256, 1, 1)] +void redistort_img(uniform WarpParams p, uint3 wg: SV_GroupID, + uint tid: SV_GroupIndex) { + int i, j, bid; + float tx, ty; + if (!_wp_tile(p, wg, tid, i, j, bid, tx, ty)) return; + SS_DISPATCH_DIST(_rd_img_call) +} +#undef _rd_img_call + +[ForceInline] +void _rd_normal(WarpParams p, int i, int j, int bid) { + float2 uv_src; + float3 n = float3(-1.0f); + if (_rd_lookup(p.intrins, p.dist_coeffs, p.source_models, + p.source_params, p.camera_model, bid, i, j, + _rd_scale(p.Wout, p.Hout, p.ref_W, p.ref_H), + _rd_scale(p.Win, p.Hin, p.ref_W, p.ref_H), uv_src)) { + gindex_t plane = gindex_t(bid) * p.Hin * p.Win; + float3 s; + s.x = _wp_bilinear(p.src, p.elem_kind, plane, p.Hin, p.Win, 3, 0, + uv_src.x, uv_src.y, p.norm_inv, 0.0f, false) + p.decode_off; + s.y = _wp_bilinear(p.src, p.elem_kind, plane, p.Hin, p.Win, 3, 1, + uv_src.x, uv_src.y, p.norm_inv, 0.0f, false) + p.decode_off; + s.z = _wp_bilinear(p.src, p.elem_kind, plane, p.Hin, p.Win, 3, 2, + uv_src.x, uv_src.y, p.norm_inv, 0.0f, false) + p.decode_off; + float sl = length(s); + // The pose is unchanged, so a camera-frame normal needs no rotation. + if (s.x + s.y + s.z > -2.366f && sl > 1e-8f) + n = s / sl; + } + gindex_t base = ((gindex_t(bid) * p.Hout + j) * p.Wout + i) * 3; + p.dst[base + 0] = n.x; + p.dst[base + 1] = n.y; + p.dst[base + 2] = n.z; +} + +#define _rd_normal_call(D) _rd_normal(p, i, j, bid) + +[shader("compute")] +[numthreads(256, 1, 1)] +void redistort_normal(uniform WarpParams p, uint3 wg: SV_GroupID, + uint tid: SV_GroupIndex) { + int i, j, bid; + float tx, ty; + if (!_wp_tile(p, wg, tid, i, j, bid, tx, ty)) return; + SS_DISPATCH_DIST(_rd_normal_call) +} +#undef _rd_normal_call + +// Out-of-frame is masked OUT rather than padded: the fitted camera can see a +// little past the source image. Word-per-thread output, as warp_mask_wide. +[ForceInline] +uint _rd_mask_byte(WarpMaskParams p, uint n) { + uint i = n % uint(p.Wout); + uint t = n / uint(p.Wout); + uint j = t % uint(p.Hout); + uint bid = t / uint(p.Hout); + float2 uv; + if (!_rd_lookup(p.intrins, p.dist_coeffs, p.source_models, + p.source_params, p.camera_model, int(bid), int(i), + int(j), _rd_scale(p.Wout, p.Hout, p.ref_W, p.ref_H), + _rd_scale(p.Win, p.Hin, p.ref_W, p.ref_H), uv)) + return 0u; + int xs = int(floor(clamp(uv.x + 0.5f, -8.0f, float(p.Win) + 8.0f))); + int ys = int(floor(clamp(uv.y + 0.5f, -8.0f, float(p.Hin) + 8.0f))); + if (xs < 0 || xs >= p.Win || ys < 0 || ys >= p.Hin) return 0u; + gindex_t idx = gindex_t(bid) * p.Hin * p.Win + gindex_t(ys) * p.Win + xs; + return _wp_load(p.src, idx, kElemU8) != 0.0f ? 1u : 0u; +} + +[ForceInline] +void _rd_mask_main(WarpMaskParams p, uint3 wg, + uint tid) { + uint word = (wg.y * p.wgs_per_row + wg.x) * 256u + tid; + uint total = uint(p.B) * uint(p.Hout) * uint(p.Wout); + if (word >= (total + 3u) / 4u) return; + uint outw = 0u; + for (uint b = 0; b < 4u; b++) { + uint n = word * 4u + b; + if (n < total) + outw |= _rd_mask_byte(p, n) << (b * 8u); + } + p.dst[word] = outw; +} + +#define _rd_mask_call(D) _rd_mask_main(p, wg, tid) + +[shader("compute")] +[numthreads(256, 1, 1)] +void redistort_mask(uniform WarpMaskParams p, uint3 wg: SV_GroupID, + uint tid: SV_GroupIndex) { + SS_DISPATCH_DIST(_rd_mask_call) +} +#undef _rd_mask_call + // Flat byte/u16 -> float conversion: out[i] = elem(i) * scale + offset. // Covers uint8/16_image_to_float (1/255, 1/65535), uint8_normal_to_float // (1/127.5, -1) and uint16_depth_to_float (1, 0). @@ -456,3 +675,11 @@ void bytes_to_float(uniform BytesToFloatParams p, uint3 wg: SV_GroupID, if (idx >= p.total) return; p.dst[idx] = _wp_load(p.src, gindex_t(idx), p.elem_kind) * p.scale + p.offset; } + +// Declared last: spec IDs follow declaration order (see dist_spec.slang). +// kFromSource trails kDistortion so the launches that never re-distort keep +// passing a one-element SpecList. +[SpecializationConstant] +const int kDistortion = 0; +[SpecializationConstant] +const int kFromSource = 0; diff --git a/src/core/Camera.h b/src/core/Camera.h index cdcc66f8..075681cf 100644 --- a/src/core/Camera.h +++ b/src/core/Camera.h @@ -8,9 +8,9 @@ // // Two constraints are not visible from the declarations: // -// - The model is ONE enum for the whole batch, not per camera, because that -// is how the projection / rasterization kernels dispatch. Mixed models in -// one batch have to be split into separate tables. +// - The model AND the distortion tier are ONE enum each for the whole batch, +// not per camera, because that is how the projection / rasterization +// kernels dispatch. Mixed cameras have to be split into separate tables. // // - Width / height live host-side. Only host code reads them (launch // dimensions, image-size bookkeeping), so keeping them off device avoids @@ -26,17 +26,6 @@ #include -// Distortion parameter layout per camera. MUST match the projection/raster -// kernels. -// -// index 0..3 : k1, k2, p1, p2 (radial + tangential) -// index 4..7 : k3, k4, k5, k6 (extended radial — OpenCV fisheye etc.) -// index 8..9 : sx1, sy1 (thin-prism) -// -// Cameras with fewer parameters pad the tail with zero. -inline constexpr int kCameraDistortionParams = 10; - - // COLMAP / NerfStudio camera-model string -> CameraModelType. // Returns CameraModelType(-1) for unknown / unsupported models; callers // validate and raise. @@ -57,6 +46,16 @@ inline CameraModelType camera_model_from_name(const std::string& name) { return (CameraModelType)-1; } +inline const char* camera_distortion_to_string(CameraDistortionType d) { + switch (d) { + case CameraDistortionType::None: return "NONE"; + case CameraDistortionType::OpenCV: return "OPENCV"; + case CameraDistortionType::ThinPrism: return "THIN_PRISM"; + case CameraDistortionType::Rational: return "RATIONAL"; + default: return "UNKNOWN"; + } +} + inline const char* camera_model_to_string(CameraModelType m) { switch (m) { case CameraModelType::PINHOLE: return "PINHOLE"; @@ -82,10 +81,11 @@ public: int32_t width, int32_t height, CameraModelType model, + CameraDistortionType distortion, const TorchTensorView& viewmats, // host or device, [N, 4, 4] const TorchTensorView& intrins, // host or device, [N, 4] - const TorchTensorView& dist_coeffs) // host or device, [N, 10] - : _num(num), _model(model) + const TorchTensorView& dist_coeffs) // host or device, [N, 8] + : _num(num), _model(model), _distortion(distortion) { _validate_shape("viewmats", viewmats, {num, 4, 4}); _validate_shape("intrins", intrins, {num, 4}); @@ -104,12 +104,13 @@ public: Cameras(const std::string& key_prefix, int64_t num, CameraModelType model, + CameraDistortionType distortion, const TorchTensorView& viewmats, const TorchTensorView& intrins, const TorchTensorView& dist_coeffs, std::vector widths, std::vector heights) - : _num(num), _model(model), + : _num(num), _model(model), _distortion(distortion), _widths(std::move(widths)), _heights(std::move(heights)) { _validate_shape("viewmats", viewmats, {num, 4, 4}); @@ -130,12 +131,13 @@ public: // is the caller's responsibility. Cameras(int64_t num, CameraModelType model, + CameraDistortionType distortion, DeviceTensor2D viewmats, DeviceVector intrins, DeviceTensor2D dist_coeffs, std::vector widths, std::vector heights) - : _num(num), _model(model), + : _num(num), _model(model), _distortion(distortion), _viewmats(viewmats), _intrins(intrins), _dist_coeffs(dist_coeffs), _widths(std::move(widths)), _heights(std::move(heights)) { @@ -153,9 +155,10 @@ public: // ---- Read-only accessors ---------------------------------------------- - int64_t num() const { return _num; } - CameraModelType model() const { return _model; } - bool empty() const { return _num == 0; } + int64_t num() const { return _num; } + CameraModelType model() const { return _model; } + CameraDistortionType distortion() const { return _distortion; } + bool empty() const { return _num == 0; } const DeviceTensor2D& viewmats() const { return _viewmats; } const DeviceVector& intrins() const { return _intrins; } @@ -174,12 +177,13 @@ public: private: - int64_t _num = 0; - CameraModelType _model = (CameraModelType)-1; + int64_t _num = 0; + CameraModelType _model = (CameraModelType)-1; + CameraDistortionType _distortion = CameraDistortionType::None; DeviceTensor2D _viewmats; // [N, 4] -- each row is a float4 DeviceVector _intrins; // [N] -- (fx, fy, cx, cy) - DeviceTensor2D _dist_coeffs; // [N, 10] + DeviceTensor2D _dist_coeffs; // [N, 8] std::vector _widths; // size N, host-side std::vector _heights; // size N, host-side diff --git a/src/core/CameraDistortion.cuh b/src/core/CameraDistortion.cuh new file mode 100644 index 00000000..22a28514 --- /dev/null +++ b/src/core/CameraDistortion.cuh @@ -0,0 +1,87 @@ +#pragma once + +// Compile-time selection of the per-tier Slang exports. +// +// slangc cannot export a generic, so shaders/projection_utils.slang emits one +// entry per distortion tier (`_none` / `_opencv` / `_prism` / `_rational`) and +// these traits pick one from a `CameraDistortionType` template argument. +// +// INCLUDE ORDER: this header names SlangProjectionUtils::* but does not open +// that namespace, because generated/projection_utils.cuh is `#pragma once` and +// would land in whichever namespace included it first. Include it after the +// TU's own `namespace SlangProjectionUtils { ... }` block. + +#include "core/Common.cuh" + +#ifdef __CUDACC__ + +template +struct SlangDistortion; + +#define _SS_DEF_SLANG_DISTORTION(TIER, SUFFIX) \ +template<> \ +struct SlangDistortion { \ + using Coeffs = CameraDistortionCoeffsT; \ + \ + static __device__ __forceinline__ \ + bool is_valid_distortion(float2 uv, const Coeffs& c) { \ + return SlangProjectionUtils::is_valid_distortion##SUFFIX(uv, c.v); \ + } \ + static __device__ __forceinline__ \ + bool persp_proj_nav(float3 p_view, float4 intrins, const Coeffs& c, float2* uv) { \ + return SlangProjectionUtils::persp_proj_nav##SUFFIX(p_view, intrins, c.v, uv); \ + } \ + static __device__ __forceinline__ \ + bool fisheye_proj_nav(float3 p_view, float4 intrins, const Coeffs& c, float2* uv) { \ + return SlangProjectionUtils::fisheye_proj_nav##SUFFIX(p_view, intrins, c.v, uv); \ + } \ + static __device__ __forceinline__ \ + bool equisolid_proj_nav(float3 p_view, float4 intrins, const Coeffs& c, float2* uv) { \ + return SlangProjectionUtils::equisolid_proj_nav##SUFFIX(p_view, intrins, c.v, uv); \ + } \ + static __device__ __forceinline__ \ + float2 distort_point(float2 uv, int camera_model, const Coeffs& c) { \ + return SlangProjectionUtils::distort_point##SUFFIX(uv, camera_model, c.v); \ + } \ + static __device__ __forceinline__ \ + bool undistort_point(float2 uv, int camera_model, const Coeffs& c, float2* out) { \ + return SlangProjectionUtils::undistort_point##SUFFIX(uv, camera_model, c.v, out); \ + } \ + static __device__ __forceinline__ \ + bool unproject_point(float2 uv, int camera_model, const Coeffs& c, float3* rd) { \ + return SlangProjectionUtils::unproject_point##SUFFIX(uv, camera_model, c.v, rd); \ + } \ + static __device__ __forceinline__ \ + bool generate_ray(float2 uv, int camera_model, const Coeffs& c, float3* rd) { \ + return SlangProjectionUtils::generate_ray##SUFFIX(uv, camera_model, c.v, rd); \ + } \ +}; + +_SS_DEF_SLANG_DISTORTION(None, _none) +_SS_DEF_SLANG_DISTORTION(OpenCV, _opencv) +_SS_DEF_SLANG_DISTORTION(ThinPrism, _prism) +_SS_DEF_SLANG_DISTORTION(Rational, _rational) + +#undef _SS_DEF_SLANG_DISTORTION + + +// Camera-model-aware `*_proj_nav`, for the kernels that take the model at run +// time (image warps, meshing raster). EQUIRECTANGULAR ignores the coefficients. +template +__device__ __forceinline__ bool camera_proj_nav( + CameraModelType model, float3 p_view, float4 intrins, + const typename SlangDistortion::Coeffs& c, float2* uv +) { + switch (model) { + case CameraModelType::FISHEYE: + return SlangDistortion::fisheye_proj_nav(p_view, intrins, c, uv); + case CameraModelType::EQUISOLID: + return SlangDistortion::equisolid_proj_nav(p_view, intrins, c, uv); + case CameraModelType::EQUIRECTANGULAR: + return SlangProjectionUtils::equirect_proj_nav(p_view, intrins, uv); + default: + return SlangDistortion::persp_proj_nav(p_view, intrins, c, uv); + } +} + +#endif // __CUDACC__ diff --git a/src/core/CameraModel.h b/src/core/CameraModel.h index 0edf413a..b9072754 100644 --- a/src/core/CameraModel.h +++ b/src/core/CameraModel.h @@ -25,6 +25,142 @@ enum class CameraModelType { EQUIRECTANGULAR = 3, }; +// Lens distortion, orthogonal to CameraModelType and chosen per camera group at +// load time: the parsers pick the cheapest tier that represents the source +// camera exactly, and fit + re-distort when none does. Values must match +// CameraDistortionType in shaders/projection_utils.slang and Common.cuh. +// +// Coefficient order is each tier's own -- a slot index does NOT mean the same +// thing across tiers: +// OpenCV k1 k2 p1 p2 (COLMAP OPENCV) +// ThinPrism k1 k2 k3 k4 p1 p2 sx1 sy1 (COLMAP THIN_PRISM_FISHEYE) +// Rational k1 k2 k3 k4 k5 k6 p1 p2 (COLMAP FULL_OPENCV; k4..k6 divide) +enum class CameraDistortionType { + None = 0, + OpenCV = 1, + ThinPrism = 2, + Rational = 3, +}; + +// Storage width of the per-camera coefficient row. Every tier reads a prefix of +// it; the tail is zero. MUST match kCameraDistortionParams in Common.cuh. +inline constexpr int kCameraDistortionParams = 8; + +inline constexpr int camera_distortion_num_params(CameraDistortionType d) { + return d == CameraDistortionType::None ? 0 : + d == CameraDistortionType::OpenCV ? 4 : 8; +} + +inline const char* camera_distortion_to_string(CameraDistortionType d) { + switch (d) { + case CameraDistortionType::None: return "NONE"; + case CameraDistortionType::OpenCV: return "OPENCV"; + case CameraDistortionType::ThinPrism: return "THIN_PRISM"; + case CameraDistortionType::Rational: return "RATIONAL"; + default: return "UNKNOWN"; + } +} + +inline CameraDistortionType camera_distortion_from_name(const std::string& name) { + if (name == "NONE") return CameraDistortionType::None; + if (name == "OPENCV") return CameraDistortionType::OpenCV; + if (name == "THIN_PRISM") return CameraDistortionType::ThinPrism; + if (name == "RATIONAL") return CameraDistortionType::Rational; + return (CameraDistortionType)-1; +} + +// Cheapest tier that still represents `coeffs` exactly, given the tier it was +// written in. Zero-extension OpenCV -> ThinPrism is exact, so a ThinPrism +// camera whose k3/k4/sx1/sy1 vanish demotes; a Rational camera whose +// denominator vanishes is a plain polynomial and demotes as well. +inline CameraDistortionType camera_distortion_demote( + CameraDistortionType tier, const float* coeffs, float* out) +{ + auto zero = [](float v) { return v == 0.0f; }; + if (tier == CameraDistortionType::Rational) { + // 1/(1 + 0) == 1, so an all-zero denominator is the polynomial form + // with k1..k3 and no k4 term. + if (zero(coeffs[3]) && zero(coeffs[4]) && zero(coeffs[5])) { + float k1 = coeffs[0], k2 = coeffs[1], k3 = coeffs[2]; + float p1 = coeffs[6], p2 = coeffs[7]; + if (zero(k3)) { + out[0] = k1; out[1] = k2; out[2] = p1; out[3] = p2; + for (int i = 4; i < kCameraDistortionParams; i++) out[i] = 0.0f; + return CameraDistortionType::OpenCV; + } + out[0] = k1; out[1] = k2; out[2] = k3; out[3] = 0.0f; + out[4] = p1; out[5] = p2; out[6] = 0.0f; out[7] = 0.0f; + return CameraDistortionType::ThinPrism; + } + } else if (tier == CameraDistortionType::ThinPrism) { + if (zero(coeffs[2]) && zero(coeffs[3]) && zero(coeffs[6]) && zero(coeffs[7])) { + float k1 = coeffs[0], k2 = coeffs[1], p1 = coeffs[4], p2 = coeffs[5]; + out[0] = k1; out[1] = k2; out[2] = p1; out[3] = p2; + for (int i = 4; i < kCameraDistortionParams; i++) out[i] = 0.0f; + return camera_distortion_demote(CameraDistortionType::OpenCV, out, out); + } + } else if (tier == CameraDistortionType::OpenCV) { + if (zero(coeffs[0]) && zero(coeffs[1]) && zero(coeffs[2]) && zero(coeffs[3])) { + for (int i = 0; i < kCameraDistortionParams; i++) out[i] = 0.0f; + return CameraDistortionType::None; + } + } else { + for (int i = 0; i < kCameraDistortionParams; i++) out[i] = 0.0f; + return CameraDistortionType::None; + } + if (out != coeffs) + for (int i = 0; i < kCameraDistortionParams; i++) out[i] = coeffs[i]; + return tier; +} + +// Rewrite `coeffs` from `from` into `to`, which must be a tier that contains it +// (see camera_distortion_kernel_tier). Returns false when it does not. +inline bool camera_distortion_promote(CameraDistortionType from, + CameraDistortionType to, + const float* coeffs, float* out) { + if (from == to) { + if (out != coeffs) + for (int i = 0; i < kCameraDistortionParams; i++) out[i] = coeffs[i]; + return true; + } + float in[kCameraDistortionParams]; + for (int i = 0; i < kCameraDistortionParams; i++) in[i] = coeffs[i]; + for (int i = 0; i < kCameraDistortionParams; i++) out[i] = 0.0f; + if (from == CameraDistortionType::None) + return true; // all-zero coefficients are the identity in every tier + if (from == CameraDistortionType::OpenCV && to == CameraDistortionType::ThinPrism) { + out[0] = in[0]; out[1] = in[1]; // k1 k2 + out[4] = in[2]; out[5] = in[3]; // p1 p2 + return true; + } + if (from == CameraDistortionType::OpenCV && to == CameraDistortionType::Rational) { + out[0] = in[0]; out[1] = in[1]; // k1 k2 (numerator) + out[6] = in[2]; out[7] = in[3]; // p1 p2 + return true; + } + // ThinPrism -> Rational would need a 4th numerator term and drop sx1/sy1; + // Rational -> ThinPrism cannot express the denominator at all. + return false; +} + +// Which (camera model, distortion tier) pairs the CUDA kernels are instantiated +// for. Every tier is available on Vulkan (a specialization constant costs no +// SPIR-V), so this bounds the CUDA binary only, and it must match +// kCameraVariants in tools/codegen/generate_kernel_instantiation.py and the +// export lists in shaders/primitive_3dgs.slang. +// +// The gaps are not arbitrary: no COLMAP fisheye model is rational, and +// EQUIRECTANGULAR has no lens distortion. +inline bool camera_distortion_is_compiled(CameraModelType m, CameraDistortionType d) { + switch (m) { + case CameraModelType::PINHOLE: return true; + case CameraModelType::FISHEYE: + case CameraModelType::EQUISOLID: return d != CameraDistortionType::Rational; + case CameraModelType::EQUIRECTANGULAR: return d == CameraDistortionType::None; + default: return false; + } +} + // COLMAP / NerfStudio camera-model string -> CameraModelType. // Returns CameraModelType(-1) for unknown / unsupported models; callers // should validate and raise. Mirrors Camera.h:90-105. diff --git a/src/core/Common.cuh b/src/core/Common.cuh index b47228b5..bffd90db 100644 --- a/src/core/Common.cuh +++ b/src/core/Common.cuh @@ -87,44 +87,8 @@ struct FixedArray #endif // #ifdef __CUDACC__ -#ifdef __CUDACC__ -// k1 k2 k3 k4 p1 p2 sx1 sy1 b1 b2 -typedef FixedArray CameraDistortionCoeffs; -#endif - #include -struct CameraDistortionCoeffsBuffer { - float* __restrict__ coeffs; - - CameraDistortionCoeffsBuffer(const TorchTensorView &tensor) { - if (std::get<2>(tensor).size() != 2 || std::get<2>(tensor)[1] != 10) - throw std::runtime_error("dist coeffs must have shape (C, 10)"); - if (std::get<1>(tensor) != sizeof(float)) - throw std::runtime_error("dist coeffs must be float"); - coeffs = (float*)std::get<0>(tensor); - } - - CameraDistortionCoeffsBuffer(float* ptr) : coeffs(ptr) {} - - #ifdef __CUDACC__ - __device__ CameraDistortionCoeffs load(long idx) const { - CameraDistortionCoeffs res; - if (coeffs == nullptr) { - #pragma unroll - for (int i = 0; i < 10; i++) - res[i] = 0.0f; - } else { - float* c = coeffs + 10 * idx; - #pragma unroll - for (int i = 0; i < 10; i++) - res[i] = c[i]; - } - return res; - } - #endif -}; - // Camera Types // This must match projection_utils.slang enum class CameraModelType { @@ -134,6 +98,71 @@ enum class CameraModelType { EQUIRECTANGULAR = 3, }; +// Lens distortion tier, orthogonal to CameraModelType and a COMPILE-TIME axis +// in every kernel that projects. Must match core/CameraModel.h and +// projection_utils.slang; the per-tier coefficient order is documented there. +enum class CameraDistortionType { + None = 0, + OpenCV = 1, + ThinPrism = 2, + Rational = 3, +}; + +// Storage width of one camera's coefficient row. Each tier reads a prefix. +inline constexpr int kCameraDistortionParams = 8; + +inline constexpr int camera_distortion_num_params(CameraDistortionType d) { + return d == CameraDistortionType::None ? 0 : + d == CameraDistortionType::OpenCV ? 4 : 8; +} + +#ifdef __CUDACC__ +// Per-tier coefficient pack. Sized to the tier, not to the storage row, so an +// undistorted camera costs no registers at all. DistNone in Slang carries one +// unread slot (Slang has no zero-length array), which the launchers mirror. +template +struct CameraDistortionCoeffsT { + static constexpr int kNum = camera_distortion_num_params(D); + FixedArray 0 ? kNum : 1)> v; +}; +#endif + +struct CameraDistortionCoeffsBuffer { + float* __restrict__ coeffs; + + CameraDistortionCoeffsBuffer(const TorchTensorView &tensor) { + if (std::get<2>(tensor).size() != 2 || + std::get<2>(tensor)[1] != kCameraDistortionParams) + throw std::runtime_error("dist coeffs must have shape (C, 8)"); + if (std::get<1>(tensor) != sizeof(float)) + throw std::runtime_error("dist coeffs must be float"); + coeffs = (float*)std::get<0>(tensor); + } + + CameraDistortionCoeffsBuffer(float* ptr) : coeffs(ptr) {} + + #ifdef __CUDACC__ + template + __device__ CameraDistortionCoeffsT load(long idx) const { + CameraDistortionCoeffsT res; + constexpr int kNum = CameraDistortionCoeffsT::kNum; + if constexpr (kNum == 0) { + res.v[0] = 0.0f; + } else if (coeffs == nullptr) { + #pragma unroll + for (int i = 0; i < kNum; i++) + res.v[i] = 0.0f; + } else { + const float* c = coeffs + kCameraDistortionParams * idx; + #pragma unroll + for (int i = 0; i < kNum; i++) + res.v[i] = c[i]; + } + return res; + } + #endif +}; + inline CameraModelType cmt(const std::string &s) { return (s == "PINHOLE") ? CameraModelType::PINHOLE : (s == "FISHEYE") ? CameraModelType::FISHEYE : @@ -142,6 +171,14 @@ inline CameraModelType cmt(const std::string &s) { (CameraModelType)-1; } +inline CameraDistortionType cdt(const std::string &s) { + return (s == "NONE") ? CameraDistortionType::None : + (s == "OPENCV") ? CameraDistortionType::OpenCV : + (s == "THIN_PRISM") ? CameraDistortionType::ThinPrism : + (s == "RATIONAL") ? CameraDistortionType::Rational : + (CameraDistortionType)-1; +} + // Kernel launcher diff --git a/src/core/PoolSlots.h b/src/core/PoolSlots.h index f2d8e87c..5746b241 100644 --- a/src/core/PoolSlots.h +++ b/src/core/PoolSlots.h @@ -288,6 +288,8 @@ enum class SaveClass : uint8_t { /* ---- warped-setup staging ---- */ \ X(WarpInputIntrins , "warp.input_intrins", Other , Never) \ X(WarpInputDistCoeffs , "warp.input_dist_coeffs", Other , Never) \ + X(WarpSourceModels , "warp.source_models", Other , Never) \ + X(WarpSourceParams , "warp.source_params", Other , Never) \ /* ---- data-manager scratch ---- */ \ X(DmAxesFisheye5 , "dm.axes.fisheye5", Other , Never) \ X(DmAxesEquirect6 , "dm.axes.equirect6", Other , Never) \ diff --git a/src/data/DataManager.cpp b/src/data/DataManager.cpp index 0b2ecd1b..9f8f9992 100644 --- a/src/data/DataManager.cpp +++ b/src/data/DataManager.cpp @@ -100,6 +100,12 @@ struct IndexGroup { int32_t width = 0; int32_t height = 0; CameraModelType model = (CameraModelType)-1; // uniform within a group + CameraDistortionType distortion = CameraDistortionType::None; // likewise + // Whether this group's images must be resampled from a fitted source + // camera. Part of the group key: the kernels take it as a compile-time + // axis, so a group that mixes fitted and exact cameras would project the + // exact ones through source model -1 and blank them. + bool redistort = false; int32_t mask_h = 0, mask_w = 0; int32_t depth_h = 0, depth_w = 0; int32_t normal_h = 0, normal_w = 0; @@ -495,14 +501,21 @@ void DecodedBatch::build_views() { int64_t B_post = num; viewmats_view = mk(viewmats.data(), 4, {B_post, 4LL, 4LL}); intrins_view = mk(intrins.data(), 4, {B_post, 4LL}); - dist_coeffs_view = mk(dist_coeffs.data(), 4, {B_post, 10LL}); + dist_coeffs_view = mk(dist_coeffs.data(), 4, + {B_post, (long long)kCameraDistortionParams}); // Per-INPUT intrins / dist_coeffs views (size B_in). Empty when the // warp kernel doesn't need them. int64_t B_in = input_num; if (!input_intrins.empty()) { input_intrins_view = mk(input_intrins.data(), 4, {B_in, 4LL}); - input_dist_coeffs_view = mk(input_dist_coeffs.data(), 4, {B_in, 10LL}); + input_dist_coeffs_view = mk(input_dist_coeffs.data(), 4, + {B_in, (long long)kCameraDistortionParams}); + if (!input_source_models.empty()) { + input_source_models_view = TorchTensorView( + (uint64_t)input_source_models.data(), 4, {B_in}); + input_source_params_view = mk(input_source_params.data(), 4, {B_in, 16LL}); + } } // Image / modality views stay at INPUT shape. The engine warps on the @@ -535,7 +548,8 @@ public: DataManagerImpl( DataManagerConfig config, - std::vector camera_models, // per-camera enum int + std::vector camera_models, // per-camera enum int + std::vector camera_distortions, // per-camera tier int std::vector image_filenames, std::vector mask_filenames, std::vector depth_filenames, @@ -548,7 +562,9 @@ public: std::vector intrins, // post-split std::vector dist_coeffs, // post-split std::vector input_intrins, // per-input - std::vector input_dist_coeffs, // per-input + std::vector input_dist_coeffs, + std::vector redistort_models, + std::vector redistort_params, // per-input std::vector train_indices, std::vector val_indices); @@ -591,6 +607,9 @@ private: // partitioned by this so a mixed pinhole + fisheye dataset just yields // two extra groups; batches stay homogeneous. std::vector _camera_models; + std::vector _camera_distortions; + std::vector _redistort_models; + std::vector _redistort_params; // Per-input K and post-split offset. Length N. K[i] is the split factor // for input camera i (1 / 5 / 6). post_offsets[i] is the starting index // in _viewmats / _intrins / _dist_coeffs (which are now POST-split). @@ -771,6 +790,7 @@ private: DataManagerImpl::DataManagerImpl( DataManagerConfig config, std::vector camera_models, + std::vector camera_distortions, std::vector image_filenames, std::vector mask_filenames, std::vector depth_filenames, @@ -784,10 +804,15 @@ DataManagerImpl::DataManagerImpl( std::vector dist_coeffs, std::vector input_intrins, std::vector input_dist_coeffs, + std::vector redistort_models, + std::vector redistort_params, std::vector train_indices, std::vector val_indices) : _cfg(config), _camera_models(std::move(camera_models)), + _camera_distortions(std::move(camera_distortions)), + _redistort_models(std::move(redistort_models)), + _redistort_params(std::move(redistort_params)), _K_per_camera(std::move(K_per_camera)), _post_offsets(std::move(post_offsets)), _image_filenames(std::move(image_filenames)), @@ -830,14 +855,14 @@ DataManagerImpl::DataManagerImpl( (int64_t)_heights.size() != N || (int64_t)_viewmats.size() != n_post * 16 || (int64_t)_intrins.size() != n_post * 4 || - (int64_t)_dist_coeffs.size() != n_post * 10) { + (int64_t)_dist_coeffs.size() != n_post * kCameraDistortionParams) { throw std::runtime_error( "DataManager: per-camera array length mismatch (expected widths/heights " "of length N and viewmats/intrins/dist_coeffs of length N_post = sum(K))"); } if (!_input_intrins.empty() && ((int64_t)_input_intrins.size() != N * 4 || - (int64_t)_input_dist_coeffs.size() != N * 10)) { + (int64_t)_input_dist_coeffs.size() != N * kCameraDistortionParams)) { throw std::runtime_error( "DataManager: input_intrins / input_dist_coeffs length mismatch " "(expected length 4*N / 10*N respectively, or both empty)"); @@ -1032,19 +1057,26 @@ std::vector DataManagerImpl::build_index_groups_member( // Group key: (W, H, camera_model). std::map handles tuple keys natively, // and group build happens once at construction, so we don't need an // unordered_map's hash machinery here. - std::map, IndexGroup> by_shape; + std::map, + IndexGroup> by_shape; // Track first per-modality mismatch for a one-shot warning. Mutable so // this const method can update them; semantically they're cache. static bool warned_mask = false, warned_depth = false, warned_normal = false; for (int32_t i : flat_indices) { - auto key = std::make_tuple(_widths[i], _heights[i], _camera_models[i]); + const bool redistort_i = + !_redistort_models.empty() && _redistort_models[i] >= 0; + auto key = std::make_tuple(_widths[i], _heights[i], _camera_models[i], + _camera_distortions[i], + (int32_t)redistort_i); auto& g = by_shape[key]; if (g.indices.empty()) { g.width = _widths[i]; g.height = _heights[i]; g.model = (CameraModelType)_camera_models[i]; + g.distortion = (CameraDistortionType)_camera_distortions[i]; + g.redistort = redistort_i; g.K = _K_per_camera[i]; // Pick the cubemap axes corresponding to this group's split factor. if (g.K == 5) g.axes_dev = _axes_fisheye5_dev; @@ -1252,6 +1284,7 @@ void DataManagerImpl::allocate_batch( b.height = g.out_h; b.num = B_post; b.model = (K > 1) ? CameraModelType::PINHOLE : g.model; + b.distortion = (K > 1) ? CameraDistortionType::None : g.distortion; b.indices = ds_indices; b.post_offsets.assign((size_t)B, 0); @@ -1262,18 +1295,26 @@ void DataManagerImpl::allocate_batch( b.input_num = B; b.K = K; b.input_model = g.model; + b.input_distortion = g.distortion; b.axes_dev = g.axes_dev; b.viewmats.assign((size_t)B_post * 16, 0.0f); b.intrins.assign((size_t)B_post * 4, 0.0f); - b.dist_coeffs.assign((size_t)B_post * 10, 0.0f); + b.dist_coeffs.assign((size_t)B_post * kCameraDistortionParams, 0.0f); // Per-INPUT intrins / dist_coeffs (needed by the wide warp kernel for // fisheye / equisolid). Allocate only when K > 1 and the source arrays // are present. - if (K > 1 && !_input_intrins.empty()) { + if ((K > 1 || g.redistort) && !_input_intrins.empty()) { b.input_intrins.assign((size_t)B * 4, 0.0f); - b.input_dist_coeffs.assign((size_t)B * 10, 0.0f); + b.input_dist_coeffs.assign((size_t)B * kCameraDistortionParams, 0.0f); + if (g.redistort) { + b.input_source_models.assign((size_t)B, -1); + b.input_source_params.assign((size_t)B * 16, 0.0f); + } else { + b.input_source_models.clear(); + b.input_source_params.clear(); + } } else { b.input_intrins.clear(); b.input_dist_coeffs.clear(); @@ -1338,16 +1379,22 @@ void DataManagerImpl::fill_camera_params(DecodedBatch& b) { std::memcpy(&b.intrins[(size_t)j * K * 4], &_intrins[(size_t)off * 4], (size_t)K * 4 * sizeof(float)); - std::memcpy(&b.dist_coeffs[(size_t)j * K * 10], - &_dist_coeffs[(size_t)off * 10], - (size_t)K * 10 * sizeof(float)); + std::memcpy(&b.dist_coeffs[(size_t)j * K * kCameraDistortionParams], + &_dist_coeffs[(size_t)off * kCameraDistortionParams], + (size_t)K * kCameraDistortionParams * sizeof(float)); if (have_in) { std::memcpy(&b.input_intrins[(size_t)j * 4], &_input_intrins[(size_t)i_in * 4], 4 * sizeof(float)); - std::memcpy(&b.input_dist_coeffs[(size_t)j * 10], - &_input_dist_coeffs[(size_t)i_in * 10], - 10 * sizeof(float)); + std::memcpy(&b.input_dist_coeffs[(size_t)j * kCameraDistortionParams], + &_input_dist_coeffs[(size_t)i_in * kCameraDistortionParams], + kCameraDistortionParams * sizeof(float)); + if (!b.input_source_models.empty()) { + b.input_source_models[j] = _redistort_models[i_in]; + std::memcpy(&b.input_source_params[(size_t)j * 16], + &_redistort_params[(size_t)i_in * 16], + 16 * sizeof(float)); + } } } } @@ -1957,6 +2004,7 @@ void DataManagerImpl::fetch_one(int32_t index, DecodedBatch& out) { DataManager::DataManager( DataManagerConfig config, std::vector camera_models, + std::vector camera_distortions, std::vector image_filenames, std::vector mask_filenames, std::vector depth_filenames, @@ -1970,17 +2018,21 @@ DataManager::DataManager( std::vector dist_coeffs, std::vector input_intrins, std::vector input_dist_coeffs, + std::vector redistort_models, + std::vector redistort_params, std::vector train_indices, std::vector val_indices) { _impl = std::make_unique( std::move(config), std::move(camera_models), + std::move(camera_distortions), std::move(image_filenames), std::move(mask_filenames), std::move(depth_filenames), std::move(normal_filenames), std::move(widths), std::move(heights), std::move(K_per_camera), std::move(post_offsets), std::move(viewmats), std::move(intrins), std::move(dist_coeffs), std::move(input_intrins), std::move(input_dist_coeffs), + std::move(redistort_models), std::move(redistort_params), std::move(train_indices), std::move(val_indices)); } diff --git a/src/data/DataManager.h b/src/data/DataManager.h index 82586f4d..4d4c9d83 100644 --- a/src/data/DataManager.h +++ b/src/data/DataManager.h @@ -125,12 +125,13 @@ struct DecodedBatch { int32_t height = 0; // post-split H int32_t num = 0; // post-split B (= input B * K) CameraModelType model = (CameraModelType)-1; // PINHOLE when K>1 + CameraDistortionType distortion = CameraDistortionType::None; // None when K>1 // Selected camera indices, in input batch order (length = input B). std::vector indices; // Camera parameters at POST-split resolution, host-contiguous. - // Length = 16 / 4 / 10 * num (= B*K). + // Length = 16 / 4 / 8 * num (= B*K). std::vector viewmats; std::vector intrins; std::vector dist_coeffs; @@ -179,15 +180,24 @@ struct DecodedBatch { int32_t input_num = 0; // = num / K int32_t K = 1; CameraModelType input_model = (CameraModelType)-1; + CameraDistortionType input_distortion = CameraDistortionType::None; const float* axes_dev = nullptr; // Per-INPUT intrins / dist_coeffs (length input_num). Populated when // K > 1 and the wide warp kernel (fisheye/equisolid) needs them. The // equirectangular path ignores these. std::vector input_intrins; // 4 * input_num - std::vector input_dist_coeffs; // 10 * input_num + std::vector input_dist_coeffs; // 8 * input_num + + // Per-INPUT source camera for the images that must be re-distorted. + // Empty when the dataset has none; see ParsedDataset::redistort. + std::vector input_source_models; // input_num + std::vector input_source_params; // 16 * input_num + TorchTensorView input_intrins_view{0, 0, {}}; TorchTensorView input_dist_coeffs_view{0, 0, {}}; + TorchTensorView input_source_models_view{0, 0, {}}; + TorchTensorView input_source_params_view{0, 0, {}}; // Engine-facing TorchTensorViews. Lazily filled by `build_views()` once // the buffers are populated. The Engine consumes these directly via @@ -250,6 +260,7 @@ public: DataManagerConfig config, // Per-INPUT-camera (length N) --------------------------------------- std::vector camera_models, + std::vector camera_distortions, std::vector image_filenames, std::vector mask_filenames, std::vector depth_filenames, @@ -272,13 +283,17 @@ public: // (bake_post_split in DatasetCommon.cpp). std::vector viewmats, // [N_post, 4, 4] std::vector intrins, // [N_post, 4] - std::vector dist_coeffs, // [N_post, 10] + std::vector dist_coeffs, // [N_post, 8] // Per-INPUT intrins/dist_coeffs (length N). Needed by the wide warp // kernel (fisheye/equisolid projection). Pass empty vectors when // no fisheye-warp camera is in the dataset -- the kernel only reads // them on the fisheye path. std::vector input_intrins, // [N, 4] - std::vector input_dist_coeffs, // [N, 10] + std::vector input_dist_coeffs, // [N, 8] + // Per-INPUT source camera for images that must be re-distorted; + // empty when the dataset has none. See PostSplitCameras. + std::vector redistort_models, // [N] + std::vector redistort_params, // [N, 16] std::vector train_indices, std::vector val_indices); diff --git a/src/data/DatasetParser.h b/src/data/DatasetParser.h index 28cf7462..eb34b042 100644 --- a/src/data/DatasetParser.h +++ b/src/data/DatasetParser.h @@ -77,6 +77,17 @@ ColmapPoints3D read_points3D_text(const std::string& recon_dir) ColmapPoints3D read_ply_points(const std::string& path); +// The exotic camera a fitted camera stands in for, so the re-distort kernel +// can evaluate the true source projection rather than an approximation of it. +// `source_model` and `params` are as data/SourceCamera.h defines them; ignored +// when `source_model < 0`. +struct RedistortSource { + int32_t source_model = -1; + float params[16]{}; + float fit_max_px = 0.0f; // reported near-minimax error of the fit +}; + + // =========================================================================== // Parser config + baked dataset // =========================================================================== @@ -150,9 +161,11 @@ struct DatasetParserConfig { struct ParsedDataset { int64_t num_cameras = 0; - // CameraModelType as int (Camera.h camera_model_from_name over the - // nerfstudio-normalized model name). + // CameraModelType / CameraDistortionType as int, per input camera. The + // distortion tier is the cheapest one that represents the source camera + // exactly; `redistort` says when that required resampling the images. std::vector camera_models; + std::vector camera_distortions; // Absolute file paths. mask/depth/normal are all-N with "" for images // that have no such auxiliary file, or empty vectors when no image has @@ -169,7 +182,14 @@ struct ParsedDataset { std::vector c2w; std::vector intrins; // [N, 4] (fx, fy, cx, cy) - std::vector dist_coeffs; // [N, 10] (k1 k2 k3 k4 p1 p2 sx1 sy1 b1 b2) + // [N, 8]; slot meaning is per-tier, see core/CameraModel.h + std::vector dist_coeffs; + + // Cameras whose source model no tier represents exactly (COLMAP FOV / + // DIVISION / EUCM / RAD_TAN_THIN_PRISM_FISHEYE, Metashape affinity-skew). + // Empty when every camera mapped exactly. Indexed like the arrays above; + // `source_model < 0` marks a camera that needs no resampling. + std::vector redistort; // Per-INPUT train/val partition (validation_fraction). std::vector train_indices; @@ -237,7 +257,8 @@ struct PostSplitCameras { // POST-split. std::vector viewmats; // [N_post, 4, 4] std::vector intrins; // [N_post, 4] - std::vector dist_coeffs; // [N_post, 10] + std::vector dist_coeffs; // [N_post, 8] + std::vector post_distortions; // [N_post] CameraDistortionType // Viewer (engine_viewer_init) arrays, POST-split: camera-to-world in the // y/z-flipped form the blit kernel expects, plus per-post W/H/model. @@ -248,7 +269,15 @@ struct PostSplitCameras { // Per-INPUT copies for the wide-warp kernel; empty when !any_warp. std::vector input_intrins; // [N, 4] - std::vector input_dist_coeffs; // [N, 10] + std::vector input_dist_coeffs; // [N, 8] + std::vector input_distortions; // [N] CameraDistortionType + + // Flattened ParsedDataset::redistort, per INPUT camera. Empty when no + // camera needs resampling; -1 in `redistort_models` marks one that does + // not. A dataset with any of these sets any_warp, because the re-distort + // shares the warp path's staging even at K == 1. + std::vector redistort_models; // [N] + std::vector redistort_params; // [N, 16] }; PostSplitCameras bake_post_split(const ParsedDataset& ds, diff --git a/src/data/DistortionFit.cpp b/src/data/DistortionFit.cpp new file mode 100644 index 00000000..f52139dd --- /dev/null +++ b/src/data/DistortionFit.cpp @@ -0,0 +1,643 @@ +#include "data/DistortionFit.h" + +#include +#include +#include + +// Method, in one place: +// +// 1. Scan the source's field of view by bisecting theta along 128 azimuths of +// the target's own axis, giving the valid domain as a star region. +// 2. Sample a tensor-product Chebyshev-Gauss grid over that region's bounding +// box in the TARGET's undistorted normalized coordinates -- theta-space for +// FISHEYE/EQUISOLID, tan-space for PINHOLE (projection_utils.slang). Equal +// weights at those nodes integrate against 1/sqrt(1-x^2), which is what +// makes the L2 solution track the L-infinity one. +// 3. The residual is bilinear -- linear in k1..k4/p1/p2/sx1/sy1 at fixed +// intrinsics, linear in fx/fy/cx/cy at fixed coefficients -- so a linear +// solve with c = 0 gives the intrinsics, then Levenberg-Marquardt over all +// 12 unknowns converges to machine precision. Alternating the two exact +// blocks instead looks tempting and is not: fx and k1..k4 are strongly +// coupled and it stalls near 2 px on a source the tier represents exactly. +// 4. A few Lawson rounds (w <- w * |r|) push that toward minimax; the best +// max-error iterate is kept. +// 5. If the fitted distortion turns out not to be invertible over the domain, +// the high-order coefficients are masked off and 1-4 repeated. A slightly +// worse camera the kernels accept beats an exact one they reject. + +namespace dsfit { +namespace { + +constexpr double kPi = 3.14159265358979323846; +constexpr int kNC = 8; // ThinPrism coefficients +constexpr int kNU = 12; // ... plus fx, cx, fy, cy + +struct Model { + double fx = 1.0, fy = 1.0, cx = 0.0, cy = 0.0; + double c[kNC] = {}; +}; + +struct Sample { + double u = 0.0, v = 0.0; // target undistorted normalized + double us = 0.0, vs = 0.0; // source pixel + double w = 1.0; + double gx[kNC] = {}, gy[kNC] = {}; +}; + +// Past 175 degrees a lens is not something this fits, and tan(85 deg) = 11.4 +// is already as far as a polynomial in tan-space can be pushed. +constexpr double kWidestTheta = 175.0 * kPi / 180.0; + +double theta_cap(CameraModelType m) { + return m == CameraModelType::PINHOLE ? 85.0 * kPi / 180.0 : kWidestTheta; +} + +double rho_of_theta(CameraModelType m, double th) { + switch (m) { + case CameraModelType::PINHOLE: return std::tan(th); + case CameraModelType::FISHEYE: return th; + case CameraModelType::EQUISOLID: return 2.0 * std::sin(0.5 * th); + default: return 0.0; + } +} + +bool unproject(CameraModelType m, double u, double v, double d[3]) { + if (m == CameraModelType::PINHOLE) { + d[0] = u; d[1] = v; d[2] = 1.0; + return true; + } + double r = std::sqrt(u * u + v * v), th; + if (m == CameraModelType::FISHEYE) { + th = r; + } else if (m == CameraModelType::EQUISOLID) { + if (r > 2.0) return false; + th = 2.0 * std::asin(0.5 * r); + } else { + return false; + } + if (th > kPi) return false; + double s = r > 1e-12 ? std::sin(th) / r : 1.0; + d[0] = u * s; d[1] = v * s; d[2] = std::cos(th); + return true; +} + +// Column basis of DistThinPrism::distort, matching the slot order +// k1 k2 k3 k4 p1 p2 sx1 sy1. +void distort_basis(double u, double v, double gx[kNC], double gy[kNC]) { + double r2 = u * u + v * v, r4 = r2 * r2, r6 = r4 * r2, r8 = r4 * r4; + gx[0] = u * r2; gx[1] = u * r4; gx[2] = u * r6; gx[3] = u * r8; + gx[4] = 2.0 * u * v; gx[5] = r2 + 2.0 * u * u; gx[6] = r2; gx[7] = 0.0; + gy[0] = v * r2; gy[1] = v * r4; gy[2] = v * r6; gy[3] = v * r8; + gy[4] = r2 + 2.0 * v * v; gy[5] = 2.0 * u * v; gy[6] = 0.0; gy[7] = r2; +} + +// Mirrors is_valid_distortion: the distortion must stay locally +// orientation-preserving or the kernels drop the primitive. +bool distortion_invertible(double u, double v, const double c[kNC]) { + double r2 = u * u + v * v, r4 = r2 * r2, r6 = r4 * r2; + double R = 1.0 + r2 * (c[0] + r2 * (c[1] + r2 * (c[2] + r2 * c[3]))); + double Rp = c[0] + 2.0 * c[1] * r2 + 3.0 * c[2] * r4 + 4.0 * c[3] * r6; + double p1 = c[4], p2 = c[5], sx = c[6], sy = c[7]; + double j00 = R + 2.0 * u * u * Rp + 2.0 * p1 * v + 6.0 * p2 * u + 2.0 * sx * u; + double j01 = 2.0 * u * v * Rp + 2.0 * p1 * u + 2.0 * p2 * v + 2.0 * sx * v; + double j10 = 2.0 * u * v * Rp + 2.0 * p2 * v + 2.0 * p1 * u + 2.0 * sy * u; + double j11 = R + 2.0 * v * v * Rp + 2.0 * p2 * u + 6.0 * p1 * v + 2.0 * sy * v; + return std::min(j00 * j11 - j01 * j10, std::min(j00, j11)) > 0.0; +} + +// Cholesky of the lower triangle of A (row major, n <= kNU), then solve into b. +bool solve_spd(int n, double* A, double* b) { + for (int i = 0; i < n; i++) { + for (int j = 0; j <= i; j++) { + double s = A[i * n + j]; + for (int k = 0; k < j; k++) s -= A[i * n + k] * A[j * n + k]; + if (i == j) { + if (!(s > 0.0)) return false; + A[i * n + i] = std::sqrt(s); + } else { + A[i * n + j] = s / A[j * n + j]; + } + } + } + for (int i = 0; i < n; i++) { + double s = b[i]; + for (int k = 0; k < i; k++) s -= A[i * n + k] * b[k]; + b[i] = s / A[i * n + i]; + } + for (int i = n - 1; i >= 0; i--) { + double s = b[i]; + for (int k = i + 1; k < n; k++) s -= A[k * n + i] * b[k]; + b[i] = s / A[i * n + i]; + } + return true; +} + +// Undistorted-then-distorted normalized point of `m` at sample `p`. +void distorted(const Model& m, const Sample& p, double* dx, double* dy) { + double x = p.u, y = p.v; + for (int j = 0; j < kNC; j++) { + x += m.c[j] * p.gx[j]; + y += m.c[j] * p.gy[j]; + } + *dx = x; + *dy = y; +} + +double cost(const std::vector& s, const Model& m) { + double f = 0.0; + for (const Sample& p : s) { + double dx, dy; + distorted(m, p, &dx, &dy); + double ru = m.fx * dx + m.cx - p.us; + double rv = m.fy * dy + m.cy - p.vs; + f += p.w * (ru * ru + rv * rv); + } + return f; +} + +// Levenberg-Marquardt on the weighted least squares. Unknown order: +// c[0..7], then fx, cx, fy, cy; `act` lists the ones that may move, so a +// masked-off coefficient keeps whatever it was initialized to (zero). +void optimize(const std::vector& s, Model& m, + const std::vector& act) { + const int nu = (int)act.size(); + if (nu == 0) return; + double lambda = 1e-6; + double f0 = cost(s, m); + for (int it = 0; it < 200 && lambda < 1e14; it++) { + double jtj[kNU * kNU] = {}, jtr[kNU] = {}; + for (const Sample& p : s) { + double dx, dy; + distorted(m, p, &dx, &dy); + double ru = m.fx * dx + m.cx - p.us; + double rv = m.fy * dy + m.cy - p.vs; + double ju[kNU] = {}, jv[kNU] = {}; + for (int j = 0; j < kNC; j++) { + ju[j] = m.fx * p.gx[j]; + jv[j] = m.fy * p.gy[j]; + } + ju[8] = dx; ju[9] = 1.0; + jv[10] = dy; jv[11] = 1.0; + for (int i = 0; i < nu; i++) { + const int ai = act[i]; + jtr[i] += p.w * (ju[ai] * ru + jv[ai] * rv); + for (int j = 0; j <= i; j++) { + const int aj = act[j]; + jtj[i * nu + j] += p.w * (ju[ai] * ju[aj] + jv[ai] * jv[aj]); + } + } + } + bool stepped = false; + for (int attempt = 0; attempt < 24 && !stepped && lambda < 1e14; attempt++) { + double A[kNU * kNU], b[kNU]; + std::copy(jtj, jtj + nu * nu, A); + for (int i = 0; i < nu; i++) { + // Marquardt scaling: fx ~ 1e3 and k1 ~ 1e-1 in one system. + A[i * nu + i] += lambda * std::max(jtj[i * nu + i], 1e-300); + b[i] = -jtr[i]; + } + if (!solve_spd(nu, A, b)) { lambda *= 10.0; continue; } + Model t = m; + for (int i = 0; i < nu; i++) { + switch (act[i]) { + case 8: t.fx += b[i]; break; + case 9: t.cx += b[i]; break; + case 10: t.fy += b[i]; break; + case 11: t.cy += b[i]; break; + default: t.c[act[i]] += b[i]; break; + } + } + double f1 = cost(s, t); + if (f1 < f0) { + bool done = f0 - f1 <= 1e-14 * f0; + m = t; + f0 = f1; + lambda = std::max(lambda * 0.1, 1e-12); + stepped = true; + if (done) return; + } else { + lambda *= 10.0; + } + } + if (!stepped) return; + } +} + +void solve_intrinsics(const std::vector& s, Model& m) { + double sw = 0.0; + double sxx = 0.0, sx = 0.0, sxu = 0.0, su = 0.0; + double syy = 0.0, sy = 0.0, syv = 0.0, sv = 0.0; + for (const Sample& p : s) { + double dx, dy; + distorted(m, p, &dx, &dy); + sw += p.w; + sxx += p.w * dx * dx; sx += p.w * dx; sxu += p.w * dx * p.us; su += p.w * p.us; + syy += p.w * dy * dy; sy += p.w * dy; syv += p.w * dy * p.vs; sv += p.w * p.vs; + } + double dx_det = sxx * sw - sx * sx; + if (std::fabs(dx_det) > 1e-30 * (sxx * sw + 1.0)) { + m.fx = (sxu * sw - sx * su) / dx_det; + m.cx = (sxx * su - sx * sxu) / dx_det; + } + double dy_det = syy * sw - sy * sy; + if (std::fabs(dy_det) > 1e-30 * (syy * sw + 1.0)) { + m.fy = (syv * sw - sy * sv) / dy_det; + m.cy = (syy * sv - sy * syv) / dy_det; + } +} + +void errors(const std::vector& s, const Model& m, + std::vector* e, double* rms, double* mx) { + if (e) e->resize(s.size()); + double sum2 = 0.0, worst = 0.0; + for (size_t i = 0; i < s.size(); i++) { + const Sample& p = s[i]; + double dx, dy; + distorted(m, p, &dx, &dy); + double ru = m.fx * dx + m.cx - p.us; + double rv = m.fy * dy + m.cy - p.vs; + double d = std::sqrt(ru * ru + rv * rv); + if (e) (*e)[i] = d; + sum2 += ru * ru + rv * rv; + worst = std::max(worst, d); + } + *rms = s.empty() ? 0.0 : std::sqrt(sum2 / (double)s.size()); + *mx = worst; +} + +// The source's valid domain as theta_max per azimuth: star-shaped about the +// target axis, which every lens model satisfies on its FIRST branch. Only the +// first branch counts -- EUCM and the unified models fold back and re-enter the +// image mirrored, and fitting both branches at once is meaningless. +struct Domain { + static constexpr int kAz = 128; + double theta[kAz] = {}; + + double limit(double phi) const { + double t = phi * (kAz / (2.0 * kPi)); + t -= std::floor(t / kAz) * kAz; + int i = (int)t; + double f = t - i; + return theta[i % kAz] * (1.0 - f) + theta[(i + 1) % kAz] * f; + } +}; + +void scan_domain(const SourceProject& src, double w, double h, double cap, + Domain* dom) { + // Where the optical axis lands, so "outward" can be measured. + double cu = 0.5 * w, cv = 0.5 * h; + src(0.0, 0.0, 1.0, &cu, &cv); + for (int a = 0; a < Domain::kAz; a++) { + double phi = 2.0 * kPi * a / Domain::kAz; + const double cp = std::cos(phi), sp = std::sin(phi); + auto radius = [&](double th, double* r) { + double st = std::sin(th), ct = std::cos(th), u, v; + if (!src(st * cp, st * sp, ct, &u, &v)) return false; + if (!(u >= 0.0 && u <= w && v >= 0.0 && v <= h)) return false; + *r = std::hypot(u - cu, v - cv); + return true; + }; + // The domain ends where the source leaves the image AND where its + // image radius stops growing fast enough. Without the second test a + // model that folds back INSIDE the frame -- r_d peaks and comes back, + // which the division and unified models do -- is fitted across the + // fold, and fitting a two-to-one map is meaningless. + // + // "Fast enough" is is_valid_distortion's Jdet > 0.25 read in + // theta-space: the derivative is zero AT the fold, so any coefficient + // error flips its sign and the ladder discards coefficients the source + // needs. The kernels drop those pixels either way. + const double back = cap * 1e-3; + double r_ax = 0.0; + const bool have_ax = radius(back, &r_ax); // radius(0) is 0 by + const double min_growth = 0.25 * r_ax; // construction + auto inside = [&](double th) { + double r1, r0; + if (!radius(th, &r1)) return false; + if (th <= back) return true; + if (!radius(th - back, &r0)) return false; + return have_ax ? (r1 - r0 > min_growth) : (r1 > r0); + }; + const int kSteps = 48; + double lo = -1.0, hi = -1.0; + for (int i = 0; i <= kSteps; i++) { + double th = cap * i / kSteps; + if (inside(th)) lo = th; + else if (lo >= 0.0) { hi = th; break; } + } + if (lo >= 0.0 && hi >= 0.0) { + for (int i = 0; i < 40; i++) { + double mid = 0.5 * (lo + hi); + if (inside(mid)) lo = mid; else hi = mid; + } + } + dom->theta[a] = std::max(lo, 0.0); + } +} + +double domain_max(const Domain& d) { + double m = 0.0; + for (double t : d.theta) m = std::max(m, t); + return m; +} + +std::vector build_samples(const SourceProject& src, CameraModelType m, + double w, double h, const double box[4], + const Domain& dom, int n, bool chebyshev) { + std::vector xs(n), ys(n); + for (int i = 0; i < n; i++) { + double t = chebyshev ? std::cos(kPi * (2 * i + 1) / (2.0 * n)) + : (n == 1 ? 0.0 : -1.0 + 2.0 * i / (n - 1)); + xs[i] = 0.5 * (box[0] + box[1]) + 0.5 * (box[1] - box[0]) * t; + ys[i] = 0.5 * (box[2] + box[3]) + 0.5 * (box[3] - box[2]) * t; + } + std::vector out; + out.reserve((size_t)n * n); + for (int j = 0; j < n; j++) { + for (int i = 0; i < n; i++) { + Sample p; + p.u = xs[i]; + p.v = ys[j]; + double d[3], us, vs; + if (!unproject(m, p.u, p.v, d)) continue; + double th = std::atan2(std::sqrt(d[0] * d[0] + d[1] * d[1]), d[2]); + if (th > dom.limit(std::atan2(p.v, p.u))) continue; + if (!src(d[0], d[1], d[2], &us, &vs)) continue; + if (!(us >= 0.0 && us <= w && vs >= 0.0 && vs <= h)) continue; + p.us = us; + p.vs = vs; + distort_basis(p.u, p.v, p.gx, p.gy); + out.push_back(p); + } + } + return out; +} + +// The rim of the valid domain falls between grid nodes, and a near-minimax +// residual peaks there, so the reported max is only honest with it sampled. +void append_rim(const SourceProject& src, CameraModelType m, double w, double h, + const Domain& dom, std::vector* out) { + const int kN = 4 * Domain::kAz; + for (int a = 0; a < kN; a++) { + double phi = 2.0 * kPi * a / kN; + double rho = rho_of_theta(m, dom.limit(phi) * 0.999); + Sample p; + p.u = rho * std::cos(phi); + p.v = rho * std::sin(phi); + double d[3], us, vs; + if (!unproject(m, p.u, p.v, d)) continue; + if (!src(d[0], d[1], d[2], &us, &vs)) continue; + if (!(us >= 0.0 && us <= w && vs >= 0.0 && vs <= h)) continue; + p.us = us; + p.vs = vs; + distort_basis(p.u, p.v, p.gx, p.gy); + out->push_back(p); + } +} + +// Coefficient sets tried in turn until the fitted distortion is invertible: +// everything, then no thin prism, then no k3/k4, then radial only, then k1 +// alone, then none. Each rung is a subset of the one above it. +constexpr unsigned kCoeffLadder[] = {0xFFu, 0x3Fu, 0x33u, 0x03u, 0x01u, 0x00u}; + +std::vector active_unknowns(unsigned mask, bool refine) { + std::vector act; + for (int j = 0; j < kNC; j++) + if (mask & (1u << j)) act.push_back(j); + if (refine) { act.push_back(8); act.push_back(9); act.push_back(10); act.push_back(11); } + return act; +} + +// One (model, coefficient mask) attempt over an already-scanned domain. +FitResult fit_one(const SourceProject& src, double w, double h, + CameraModelType model, const FitOptions& opt, unsigned mask, + const Domain& dom) { + FitResult res; + res.target.model = model; + res.target.distortion = CameraDistortionType::ThinPrism; + + double box[4] = {0.0, 0.0, 0.0, 0.0}; // xmin xmax ymin ymax + for (int a = 0; a < Domain::kAz; a++) { + double phi = 2.0 * kPi * a / Domain::kAz; + double rho = rho_of_theta(model, dom.theta[a]); + double x = rho * std::cos(phi), y = rho * std::sin(phi); + box[0] = std::min(box[0], x); box[1] = std::max(box[1], x); + box[2] = std::min(box[2], y); box[3] = std::max(box[3], y); + } + if (!(box[1] > box[0]) || !(box[3] > box[2])) + return res; + + const int n = std::min(512, std::max(8, opt.grid)); + std::vector fit = build_samples(src, model, w, h, box, dom, n, true); + if ((int)fit.size() < 4 * kNC) + return res; + + Model m; + solve_intrinsics(fit, m); + if (!(m.fx > 0.0) || !(m.fy > 0.0)) + return res; + + const std::vector act = active_unknowns(mask, opt.refine_intrinsics); + Model best = m; + double best_max = 1e300; + std::vector e; + const int lawson = std::max(0, opt.lawson_iters); + for (int round = 0; round <= lawson; round++) { + optimize(fit, m, act); + double rms, mx; + errors(fit, m, &e, &rms, &mx); + if (mx < best_max) { best_max = mx; best = m; } + if (round == lawson) break; + // Lawson: reweight by residual, floored so a node cannot be retired for + // good, then renormalized to keep the ridge scale meaningful. + double floor_e = 1e-3 * mx, sum = 0.0; + for (size_t i = 0; i < fit.size(); i++) { + fit[i].w *= e[i] + floor_e; + sum += fit[i].w; + } + if (!(sum > 0.0)) break; + double scale = (double)fit.size() / sum; + for (Sample& p : fit) p.w *= scale; + } + + std::vector check = build_samples(src, model, w, h, box, dom, + std::min(1024, 2 * n + 1), false); + append_rim(src, model, w, h, dom, &check); + if (check.empty()) check = fit; + double rms = 0.0, mx = 0.0; + errors(check, best, nullptr, &rms, &mx); + + bool invertible = true; + for (const Sample& p : check) + invertible = invertible && distortion_invertible(p.u, p.v, best.c); + + res.target.fx = (float)best.fx; + res.target.fy = (float)best.fy; + res.target.cx = (float)best.cx; + res.target.cy = (float)best.cy; + for (int j = 0; j < kNC; j++) res.target.coeffs[j] = (float)best.c[j]; + res.rms_px = rms; + res.max_px = mx; + res.samples = (int)check.size(); + res.invertible = invertible; + res.ok = invertible && rms <= opt.max_rms_px; + return res; +} + +// Walk the ladder until the distortion is invertible, keeping the best rung +// reached. `wide` is the domain scanned at the widest cap; it is narrowed to +// what `model` can address. +FitResult fit_model(const SourceProject& src, double w, double h, + CameraModelType model, const FitOptions& opt, + const Domain& wide) { + FitResult res; + res.target.model = model; + res.target.distortion = CameraDistortionType::ThinPrism; + if (!camera_distortion_is_compiled(model, CameraDistortionType::ThinPrism)) + return res; + + Domain dom = wide; + const double cap = theta_cap(model); + for (int a = 0; a < Domain::kAz; a++) dom.theta[a] = std::min(dom.theta[a], cap); + + unsigned prev = ~0u; + for (unsigned rung : kCoeffLadder) { + unsigned mask = rung & opt.coeff_mask; + if (mask == prev) continue; + prev = mask; + FitResult r = fit_one(src, w, h, model, opt, mask, dom); + // A rung that failed to solve at all says nothing about the next one. + if (r.samples > 0 && (r.invertible || res.samples == 0)) res = r; + if (r.invertible) break; + } + return res; +} + +} // namespace + +FitResult fit_camera(const SourceProject& src, int width, int height, + CameraModelType target_model, const FitOptions& opt) { + FitResult res; + res.target.model = target_model; + res.target.distortion = CameraDistortionType::ThinPrism; + if (!src || width <= 0 || height <= 0) + return res; + const double w = (double)width, h = (double)height; + Domain dom; + scan_domain(src, w, h, theta_cap(target_model), &dom); + res = fit_model(src, w, h, target_model, opt, dom); + res.fov_deg = 2.0 * domain_max(dom) * 180.0 / kPi; + return res; +} + +FitResult fit_camera_auto(const SourceProject& src, int width, int height, + const FitOptions& opt) { + FitResult res; + res.target.distortion = CameraDistortionType::ThinPrism; + if (!src || width <= 0 || height <= 0) + return res; + + const double w = (double)width, h = (double)height; + Domain dom; + scan_domain(src, w, h, kWidestTheta, &dom); + const double half_fov = domain_max(dom); + res.fov_deg = 2.0 * half_fov * 180.0 / kPi; + + // Preference order, widest usable model last. A perspective target keeps + // the straight lines straight but its tan() blows the polynomial up past + // ~60 degrees, and equisolid only earns its keep on a true ultra-wide. + CameraModelType cands[3]; + int nc = 0; + if (half_fov < 60.0 * kPi / 180.0) cands[nc++] = CameraModelType::PINHOLE; + cands[nc++] = CameraModelType::FISHEYE; + if (half_fov > 70.0 * kPi / 180.0) cands[nc++] = CameraModelType::EQUISOLID; + + // Sub-tenth-of-a-pixel is below what bilinear resampling can resolve, so + // the first candidate that reaches it wins outright. Past that, a later + // candidate has to be clearly better to displace the preferred one -- + // swapping a perspective camera for a fisheye to shave 10% off the + // residual is not worth the change of character. + constexpr double kGoodPx = 0.1; + bool have = false; + for (int i = 0; i < nc; i++) { + FitResult r = fit_model(src, w, h, cands[i], opt, dom); + if (r.samples == 0) continue; + bool better = !have || (r.invertible && !res.invertible) || + (r.invertible == res.invertible && + r.max_px < 0.5 * res.max_px); + if (better) { + double fov = res.fov_deg; + res = r; + res.fov_deg = fov; + have = true; + } + if (r.invertible && r.max_px <= kGoodPx) break; + } + if (have) + return res; + + // Nothing projected. Rather than fail the load, hand back a plain fisheye + // spanning the image; the caller warns and the dataset still opens. + res.target.model = CameraModelType::FISHEYE; + res.target.distortion = CameraDistortionType::None; + res.target.fx = res.target.fy = (float)(0.5 * std::max(w, h)); + res.target.cx = (float)(0.5 * w); + res.target.cy = (float)(0.5 * h); + for (int j = 0; j < kNC; j++) res.target.coeffs[j] = 0.0f; + res.invertible = true; + res.ok = false; + return res; +} + +} // namespace dsfit + +// Self-check against two lens models no tier represents exactly, at 1600x1200: +// g++ -std=c++17 -I src -DDSFIT_SELFTEST src/data/DistortionFit.cpp -o /tmp/dfit +#ifdef DSFIT_SELFTEST +#include + +int main() { + auto run = [](const char* name, const dsfit::SourceProject& s, CameraModelType m) { + dsfit::FitResult r = dsfit::fit_camera(s, 1600, 1200, m); + std::printf("%-22s -> %-9s rms %.3e px max %.3e px n %d inv %d ok %d\n", + name, camera_model_to_string(m), r.rms_px, r.max_px, + r.samples, (int)r.invertible, (int)r.ok); + std::printf(" f %.3f %.3f c %.3f %.3f k %.5g %.5g %.5g %.5g" + " p %.5g %.5g s %.5g %.5g\n", + r.target.fx, r.target.fy, r.target.cx, r.target.cy, + r.target.coeffs[0], r.target.coeffs[1], r.target.coeffs[2], + r.target.coeffs[3], r.target.coeffs[4], r.target.coeffs[5], + r.target.coeffs[6], r.target.coeffs[7]); + }; + + // COLMAP FOV: r_d = atan(2 r tan(omega/2)) / omega on the pinhole plane. + const double omega = 0.9; + dsfit::SourceProject fov = [&](double x, double y, double z, double* u, double* v) { + if (z <= 1e-9) return false; + double a = x / z, b = y / z, r = std::sqrt(a * a + b * b); + double f = r < 1e-9 ? 1.0 + : std::atan(2.0 * r * std::tan(0.5 * omega)) / (r * omega); + *u = 1000.0 * a * f + 800.0; + *v = 1000.0 * b * f + 600.0; + return true; + }; + run("COLMAP FOV w=0.9", fov, CameraModelType::PINHOLE); + run("COLMAP FOV w=0.9", fov, CameraModelType::FISHEYE); + + // EUCM: d = sqrt(beta*(x^2+y^2) + z^2), denom = alpha*d + (1-alpha)*z. + // Deliberately unguarded past its fold-back angle; Domain must find it. + const double alpha = 0.6, beta = 1.1; + dsfit::SourceProject eucm = [&](double x, double y, double z, double* u, double* v) { + double d = std::sqrt(beta * (x * x + y * y) + z * z); + double den = alpha * d + (1.0 - alpha) * z; + if (den <= 1e-9) return false; + *u = 600.0 * x / den + 800.0; + *v = 600.0 * y / den + 600.0; + return true; + }; + run("EUCM a=0.6 b=1.1", eucm, CameraModelType::FISHEYE); + run("EUCM a=0.6 b=1.1", eucm, CameraModelType::EQUISOLID); + run("EUCM a=0.6 b=1.1", eucm, CameraModelType::PINHOLE); + return 0; +} +#endif diff --git a/src/data/DistortionFit.h b/src/data/DistortionFit.h new file mode 100644 index 00000000..03936ee7 --- /dev/null +++ b/src/data/DistortionFit.h @@ -0,0 +1,76 @@ +#pragma once + +// Fit an arbitrary source camera onto a compiled (CameraModelType, +// CameraDistortionType) pair on the CPU. +// +// Used when a dataset carries a lens model no tier represents exactly (COLMAP +// FOV, Metashape affinity/skew, EUCM/UCM, ...). The fit is in PIXELS against +// the source's own pixel map over its whole valid domain, so the fitted camera +// keeps the source image size and the same solid angle -- no inscribed-rectangle +// crop. `fit_camera` is pure; cache the result per camera group. + +#include "core/CameraModel.h" + +#include + +namespace dsfit { + +// A fit closer than this reproduces the source camera to better than bilinear +// resampling can resolve, so a parser that reaches it can keep the images as +// they are instead of re-distorting them. +constexpr double kExactFitPx = 0.1; + +// Forward map of the SOURCE camera: a view-space direction (need not be +// normalized) -> pixel. false where the source has no image: behind the camera, +// or outside its valid domain. +using SourceProject = std::function; + +struct FitTarget { + CameraModelType model = CameraModelType::PINHOLE; + CameraDistortionType distortion = CameraDistortionType::ThinPrism; + float fx = 0.0f, fy = 0.0f, cx = 0.0f, cy = 0.0f; + float coeffs[kCameraDistortionParams] = {}; +}; + +struct FitOptions { + int grid = 64; // Chebyshev nodes per axis + bool refine_intrinsics = true; // false: fx/fy/cx/cy from the undistorted fit only + double max_rms_px = 0.5; // decides FitResult::ok, nothing else + int lawson_iters = 8; // 0 = plain Chebyshev-weighted least squares + // Which of the 8 ThinPrism slots the fit may use, low bit = k1, in the + // order k1 k2 k3 k4 p1 p2 sx1 sy1. Retrying with the high-order terms + // masked off is how a non-invertible fit is recovered. + unsigned coeff_mask = 0xFFu; +}; + +struct FitResult { + FitTarget target; + // Measured on an independent uniform grid twice as dense as the fit grid, + // not on the nodes the fit optimized. + double rms_px = 0.0; + double max_px = 0.0; // the near-minimax objective + int samples = 0; + double fov_deg = 0.0; // full angle the source images, 2x the largest theta + bool invertible = true; // fitted distortion passes is_valid_distortion everywhere sampled + bool ok = false; // solved, invertible, and rms_px <= max_rms_px +}; + +// Fit `target_model` + ThinPrism coefficients to `src` over a `width` x `height` +// image. Returns ok == false for EQUIRECTANGULAR (carries no distortion) and +// when the source has no image around the axis. +FitResult fit_camera(const SourceProject& src, int width, int height, + CameraModelType target_model, + const FitOptions& opt = FitOptions()); + +// Same, choosing the camera model from the source's measured field of view and +// degrading the coefficient set until the distortion is invertible. +// +// Always returns a camera the engine can train with -- a dataset that took +// hours to reconstruct must not fail to load over a lens model. Read `max_px` +// for how faithful the choice is; `ok` is false only when the source projects +// nothing at all, and even then the target is a usable (if arbitrary) camera. +FitResult fit_camera_auto(const SourceProject& src, int width, int height, + const FitOptions& opt = FitOptions()); + +} // namespace dsfit diff --git a/src/data/SourceCamera.cpp b/src/data/SourceCamera.cpp new file mode 100644 index 00000000..91ae8383 --- /dev/null +++ b/src/data/SourceCamera.cpp @@ -0,0 +1,185 @@ +#include "data/SourceCamera.h" + +#include + +// Transcribed from colmap/src/colmap/sensor/models.h (FOVCameraModel, +// SimpleDivisionCameraModel, DivisionCameraModel, EUCMCameraModel, +// RadTanThinPrismFisheyeModel::Distortion) and, for kSkewed, from +// shaders/camera_source.slang. Only the forward direction is needed: the +// fitter samples it and the re-distort kernel re-evaluates it. + +namespace srccam { + +namespace { + +bool project_fov(const float* prm, double X, double Y, double Z, + double* u, double* v) { + if (Z < 1e-12) return false; + double x = X / Z, y = Y / Z, omega = prm[4]; + double r2 = x*x + y*y, om2 = omega * omega; + constexpr double kEps = 1e-4; + double factor; + if (om2 < kEps) { + factor = (om2 * r2) / 3.0 - om2 / 12.0 + 1.0; + } else if (r2 < kEps) { + double t = std::tan(omega / 2.0); + factor = (-2.0 * t * (4.0 * r2 * t * t - 3.0)) / (3.0 * omega); + } else { + double r = std::sqrt(r2); + factor = std::atan(r * 2.0 * std::tan(omega / 2.0)) / (r * omega); + } + *u = prm[0] * x * factor + prm[2]; + *v = prm[1] * y * factor + prm[3]; + return true; +} + +bool project_division(const float* prm, bool simple, double X, double Y, double Z, + double* u, double* v) { + double fx = prm[0], fy = simple ? prm[0] : prm[1]; + double cx = simple ? prm[1] : prm[2], cy = simple ? prm[2] : prm[3]; + double k = simple ? prm[3] : prm[4]; + double rho2 = X*X + Y*Y; + double disc = Z*Z - 4.0 * rho2 * k; + if (disc < 0.0) return false; + double r = 2.0 / (Z + std::sqrt(disc)); + *u = fx * r * X + cx; + *v = fy * r * Y + cy; + return true; +} + +bool project_eucm(const float* prm, double X, double Y, double Z, + double* u, double* v) { + if (Z < 1e-12) return false; + double alpha = prm[4], beta = prm[5]; + double rho2 = beta * (X*X + Y*Y) + Z*Z; + if (rho2 < 0.0) return false; + double den = alpha * std::sqrt(rho2) + (1.0 - alpha) * Z; + if (den < 1e-12) return false; + *u = prm[0] * X / den + prm[2]; + *v = prm[1] * Y / den + prm[3]; + return true; +} + +// Aria Fisheye624. Unlike THIN_PRISM_FISHEYE, the tangential and thin-prism +// terms act on the ALREADY radially distorted point. +bool project_rad_tan_thin_prism(const float* prm, double X, double Y, double Z, + double* u, double* v) { + if (Z < 1e-12) return false; + double xn = X / Z, yn = Y / Z; + double r = std::sqrt(xn*xn + yn*yn); + double uu = xn, vv = yn; + if (r > 1e-12) { + double th = std::atan(r); + uu *= th / r; vv *= th / r; + } + double th2 = uu*uu + vv*vv, pw = 1.0, rad = 1.0; + for (int i = 0; i < 6; i++) { pw *= th2; rad += prm[4 + i] * pw; } + double x = rad * uu, y = rad * vv; + double p0 = prm[10], p1 = prm[11]; + double s0 = prm[12], s1 = prm[13], s2 = prm[14], s3 = prm[15]; + double x2 = x*x, y2 = y*y, xy = x*y, r2 = x2 + y2, r4 = r2*r2; + double xd = x + 2.0*p1*xy + p0*(r2 + 2.0*x2) + s0*r2 + s1*r4; + double yd = y + 2.0*p0*xy + p1*(r2 + 2.0*y2) + s2*r2 + s3*r4; + *u = prm[0] * xd + prm[2]; + *v = prm[1] * yd + prm[3]; + return true; +} + +bool project_skewed(const float* p, double X, double Y, double Z, + double* u, double* v) { + double qx, qy; + const int base = (int)p[13]; + if (base == (int)kSkewBasePerspective) { + if (Z < 1e-12) return false; + qx = X / Z; qy = Y / Z; + } else { + double r = std::sqrt(X*X + Y*Y); + double theta = std::atan2(r, Z), k; + if (base == (int)kSkewBaseFisheye) + k = theta < 1e-3 ? (1.0 - theta*theta/3.0) / Z : theta / r; + else + k = r < 1e-6 ? (1.0 - theta*theta/24.0) / Z + : (2.0 * std::sin(0.5 * theta)) / r; + qx = X * k; qy = Y * k; + } + double r2 = qx*qx + qy*qy, dx, dy; + if (p[14] != 0.0f) { + double radial = (1.0 + r2*(p[5] + r2*(p[6] + r2*p[7]))) + / (1.0 + r2*(p[8] + r2*(p[9] + r2*p[10]))); + dx = qx * radial + 2.0*p[11]*qx*qy + p[12]*(r2 + 2.0*qx*qx); + dy = qy * radial + 2.0*p[12]*qx*qy + p[11]*(r2 + 2.0*qy*qy); + } else { + double radial = 1.0 + r2*(p[5] + r2*(p[6] + r2*(p[7] + r2*p[8]))); + dx = qx * radial + 2.0*p[9]*qx*qy + p[10]*(r2 + 2.0*qx*qx) + p[11]*r2; + dy = qy * radial + 2.0*p[10]*qx*qy + p[9]*(r2 + 2.0*qy*qy) + p[12]*r2; + } + *u = p[0] * dx + p[4] * dy + p[2]; + *v = p[1] * dy + p[3]; + return true; +} + +// The model's own formula, with no check that it still describes a lens. +bool project_raw(int model_id, const float* params, + double X, double Y, double Z, double* u, double* v) { + switch (model_id) { + case kSkewed: + return project_skewed(params, X, Y, Z, u, v); + case kColmapFOV: + return project_fov(params, X, Y, Z, u, v); + case kColmapSimpleDivision: + return project_division(params, true, X, Y, Z, u, v); + case kColmapDivision: + return project_division(params, false, X, Y, Z, u, v); + case kColmapEUCM: + return project_eucm(params, X, Y, Z, u, v); + case kColmapRadTanThinPrismFisheye: + return project_rad_tan_thin_prism(params, X, Y, Z, u, v); + default: + return false; + } +} + +// source_unfolded mirror; camera_source.slang has the why. +bool unfolded(int model_id, const float* params, double X, double Y, double Z, + double u, double v) { + double l = std::sqrt(X*X + Y*Y + Z*Z); + if (!(l > 0.0)) return false; + double n[3] = {X / l, Y / l, Z / l}; + double t[3] = {1.0, 0.0, 0.0}; + if (!(std::abs(n[0]) < 0.9)) { t[0] = 0.0; t[1] = 1.0; } + double e1[3] = {t[1]*n[2] - t[2]*n[1], t[2]*n[0] - t[0]*n[2], + t[0]*n[1] - t[1]*n[0]}; + double e1l = std::sqrt(e1[0]*e1[0] + e1[1]*e1[1] + e1[2]*e1[2]); + for (double& c : e1) c /= e1l; + double e2[3] = {n[1]*e1[2] - n[2]*e1[1], n[2]*e1[0] - n[0]*e1[2], + n[0]*e1[1] - n[1]*e1[0]}; + constexpr double kStep = 1e-3; // radians + double au, av, bu, bv; + if (!project_raw(model_id, params, n[0] + kStep*e1[0], n[1] + kStep*e1[1], + n[2] + kStep*e1[2], &au, &av)) return false; + if (!project_raw(model_id, params, n[0] + kStep*e2[0], n[1] + kStep*e2[1], + n[2] + kStep*e2[2], &bu, &bv)) return false; + return (au - u) * (bv - v) - (av - v) * (bu - u) > 0.0; +} + +} // namespace + +void rescale(int model_id, float* params, double s) { + if (!(s > 0.0) || s == 1.0) return; + // Everything else is on the normalized plane and scale-free: FOV's omega, + // the division models' k, EUCM's alpha/beta, the radial and tangential + // coefficients. SIMPLE_DIVISION is the one model with a single focal + // length, which shifts its principal point down a slot. + int n = 4; + if (model_id == kColmapSimpleDivision) n = 3; + if (model_id == kSkewed) n = 5; // ... plus the skew + for (int i = 0; i < n; i++) params[i] = (float)(params[i] / s); +} + +bool project(int model_id, const float* params, + double X, double Y, double Z, double* u, double* v) { + return project_raw(model_id, params, X, Y, Z, u, v) && + unfolded(model_id, params, X, Y, Z, *u, *v); +} + +} // namespace srccam diff --git a/src/data/SourceCamera.h b/src/data/SourceCamera.h new file mode 100644 index 00000000..d3ade39a --- /dev/null +++ b/src/data/SourceCamera.h @@ -0,0 +1,48 @@ +#pragma once + +// Forward projection of the camera models no (CameraModelType, +// CameraDistortionType) pair represents, on the CPU. +// +// Host mirror of shaders/camera_source.slang. The fitter measures against this +// one and the re-distort kernel resamples through that one, so the two must +// agree exactly or the images land in a different camera than the one fitted. + +namespace srccam { + +// Model ids. 0..17 are COLMAP's own CameraModelId values (models.h), and their +// parameters are COLMAP's array verbatim. Ours are numbered from 1000, leaving +// COLMAP room to keep appending to its enum. +constexpr int kColmapFOV = 7; +constexpr int kColmapRadTanThinPrismFisheye = 11; +constexpr int kColmapSimpleDivision = 12; +constexpr int kColmapDivision = 13; +constexpr int kColmapEUCM = 16; + +// Any supported camera plus a sensor skew, which no tier carries: Agisoft +// Metashape's b2. Parameter layout in camera_source.slang. +constexpr int kSkewed = 1000; + +// kSkewed's base camera, params[13]. +constexpr float kSkewBasePerspective = 0.0f; +constexpr float kSkewBaseFisheye = 1.0f; +constexpr float kSkewBaseEquisolid = 2.0f; + +// kSkewed's radial form, params[14]. +constexpr float kSkewRadialPolynomial = 0.0f; // DistThinPrism slot order +constexpr float kSkewRadialRational = 1.0f; // DistRational slot order + +constexpr int kMaxParams = 16; + +// View-space direction (need not be normalized) -> source pixel. false where +// the source camera has no image for that direction, including past the angle +// where the model folds back over itself. +bool project(int model_id, const float* params, + double X, double Y, double Z, double* u, double* v); + +// Divide the pixel-valued parameters by `s`, for a parser that downscales the +// camera it fitted. The re-distort kernels take the source parameters in the +// same pixel space as the fitted intrinsics, so the two must be scaled +// together; which entries are pixels differs per model. +void rescale(int model_id, float* params, double s); + +} // namespace srccam diff --git a/src/data/parsers/ColmapParser.cpp b/src/data/parsers/ColmapParser.cpp index 63a2e420..9daab337 100644 --- a/src/data/parsers/ColmapParser.cpp +++ b/src/data/parsers/ColmapParser.cpp @@ -7,6 +7,8 @@ #include "data/FastFloat.h" #include "core/CameraModel.h" // camera_model_from_name (CUDA-free) +#include "data/DistortionFit.h" +#include "data/SourceCamera.h" #include #include @@ -90,6 +92,12 @@ const std::map& colmap_model_table() { return t; } +int colmap_model_id(const std::string& name) { + for (const auto& [id, info] : colmap_model_table()) + if (name == info.name) return id; + return -1; +} + } // namespace @@ -270,77 +278,223 @@ ColmapPoints3D read_points3D_text(const std::string& recon_dir) { // =========================================================================== -// Camera-param normalization + engine dist_coeffs layout -// (k1 k2 k3 k4 p1 p2 sx1 sy1 b1 b2). +// COLMAP camera model -> (CameraModelType, CameraDistortionType, coefficients) +// +// Every one of COLMAP's 18 models is accepted. Fourteen map exactly onto a +// tier; the remaining four (FOV, SIMPLE_DIVISION, DIVISION, EUCM) and +// RAD_TAN_THIN_PRISM_FISHEYE have no exact representation and are fitted, with +// the source model recorded so the images can be re-distorted to match. +// +// COLMAP's parameter ORDER is not ours: it interleaves p1,p2 between k2 and k3 +// (models.h FullOpenCVCameraModel / ThinPrismFisheyeCameraModel), and its +// FULL_OPENCV k4..k6 are DENOMINATOR terms, not further radial terms. // =========================================================================== namespace { struct BakedIntrins { float fx, fy, cx, cy; - std::array dist{}; // k1 k2 k3 k4 p1 p2 sx1 sy1 b1 b2 - std::string model_name; // nerfstudio-normalized: OPENCV / OPENCV_FISHEYE / ... + CameraModelType model = CameraModelType::PINHOLE; + CameraDistortionType distortion = CameraDistortionType::None; + std::array dist{}; + RedistortSource source; // source_model < 0 unless fitted }; BakedIntrins bake_colmap_intrins(const ColmapCamera& cam) { const auto& p = cam.params; auto P = [&](size_t i) { return (float)p[i]; }; + auto need = [&](size_t n) { + if (p.size() < n) + throw std::runtime_error( + "ColmapParser: camera model " + cam.model + " needs " + + std::to_string(n) + " parameters, got " + + std::to_string(p.size())); + }; BakedIntrins o; - if (cam.model == "SIMPLE_PINHOLE" || cam.model == "SIMPLE_RADIAL" || - cam.model == "RADIAL") { - o.fx = o.fy = P(0); o.cx = P(1); o.cy = P(2); - if (cam.model != "SIMPLE_PINHOLE") o.dist[0] = P(3); // k1 - if (cam.model == "RADIAL") o.dist[1] = P(4); // k2 - o.model_name = "OPENCV"; + // ---- one focal length, principal point, no distortion ---------------- + if (cam.model == "SIMPLE_PINHOLE") { + need(3); o.fx = o.fy = P(0); o.cx = P(1); o.cy = P(2); } else if (cam.model == "PINHOLE") { - o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); - o.model_name = "OPENCV"; - } else if (cam.model == "OPENCV") { - o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); - o.dist[0] = P(4); o.dist[1] = P(5); // k1 k2 - o.dist[4] = P(6); o.dist[5] = P(7); // p1 p2 - o.model_name = "OPENCV"; - } else if (cam.model == "FULL_OPENCV") { - o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); - o.dist[0] = P(4); o.dist[1] = P(5); // k1 k2 - o.dist[4] = P(6); o.dist[5] = P(7); // p1 p2 - o.dist[2] = P(8); o.dist[3] = P(9); // k3 k4 - // k5/k6 have no slot in the engine's 10-coeff layout; the Python - // dataparser drops them too (DISTORTION_KEYS has no k5/k6). - o.model_name = "FULL_OPENCV"; - } else if (cam.model == "OPENCV_FISHEYE" || cam.model == "THIN_PRISM_FISHEYE") { - o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); - o.dist[0] = P(4); o.dist[1] = P(5); // k1 k2 - if (cam.model == "OPENCV_FISHEYE") { - o.dist[2] = P(6); o.dist[3] = P(7); // k3 k4 - } else { - o.dist[4] = P(6); o.dist[5] = P(7); // p1 p2 - o.dist[2] = P(8); o.dist[3] = P(9); // k3 k4 - o.dist[6] = P(10); o.dist[7] = P(11); // sx1 sy1 - } - o.model_name = "OPENCV_FISHEYE"; - } else if (cam.model == "SIMPLE_RADIAL_FISHEYE" || cam.model == "RADIAL_FISHEYE") { + need(4); o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); + } else if (cam.model == "SIMPLE_FISHEYE") { + need(3); o.fx = o.fy = P(0); o.cx = P(1); o.cy = P(2); + o.model = CameraModelType::FISHEYE; + } else if (cam.model == "FISHEYE") { + need(4); o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); + o.model = CameraModelType::FISHEYE; + + // ---- radial-only, one focal length -> OpenCV tier with zero p1,p2 ---- + } else if (cam.model == "SIMPLE_RADIAL" || cam.model == "RADIAL" || + cam.model == "SIMPLE_RADIAL_FISHEYE" || cam.model == "RADIAL_FISHEYE") { + bool two = (cam.model == "RADIAL" || cam.model == "RADIAL_FISHEYE"); + need(two ? 5 : 4); o.fx = o.fy = P(0); o.cx = P(1); o.cy = P(2); - o.dist[0] = P(3); // k1 - if (cam.model == "RADIAL_FISHEYE") o.dist[1] = P(4); // k2 - o.model_name = "OPENCV_FISHEYE"; - } else if (cam.model == "SIMPLE_FISHEYE" || cam.model == "FISHEYE") { - if (cam.model == "SIMPLE_FISHEYE") { o.fx = o.fy = P(0); o.cx = P(1); o.cy = P(2); } - else { o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); } - o.model_name = "OPENCV_FISHEYE"; + o.distortion = CameraDistortionType::OpenCV; + o.dist[0] = P(3); // k1 + if (two) o.dist[1] = P(4); // k2 + if (cam.model == "SIMPLE_RADIAL_FISHEYE" || cam.model == "RADIAL_FISHEYE") + o.model = CameraModelType::FISHEYE; + + // ---- fx, fy, cx, cy + k1 k2 p1 p2 ------------------------------------ + } else if (cam.model == "OPENCV") { + need(8); + o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); + o.distortion = CameraDistortionType::OpenCV; + o.dist[0] = P(4); o.dist[1] = P(5); // k1 k2 + o.dist[2] = P(6); o.dist[3] = P(7); // p1 p2 + + // ---- the rational model ---------------------------------------------- + } else if (cam.model == "FULL_OPENCV") { + need(12); + o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); + o.distortion = CameraDistortionType::Rational; + o.dist[0] = P(4); o.dist[1] = P(5); // k1 k2 numerator + o.dist[2] = P(8); // k3 numerator + o.dist[3] = P(9); o.dist[4] = P(10); o.dist[5] = P(11); // k4 k5 k6 denominator + o.dist[6] = P(6); o.dist[7] = P(7); // p1 p2 + + // ---- fisheye radial in theta-space ----------------------------------- + } else if (cam.model == "OPENCV_FISHEYE") { + need(8); + o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); + o.model = CameraModelType::FISHEYE; + o.distortion = CameraDistortionType::ThinPrism; + o.dist[0] = P(4); o.dist[1] = P(5); o.dist[2] = P(6); o.dist[3] = P(7); + + } else if (cam.model == "THIN_PRISM_FISHEYE") { + need(12); + o.fx = P(0); o.fy = P(1); o.cx = P(2); o.cy = P(3); + o.model = CameraModelType::FISHEYE; + o.distortion = CameraDistortionType::ThinPrism; + o.dist[0] = P(4); o.dist[1] = P(5); // k1 k2 + o.dist[2] = P(8); o.dist[3] = P(9); // k3 k4 + o.dist[4] = P(6); o.dist[5] = P(7); // p1 p2 + o.dist[6] = P(10); o.dist[7] = P(11); // sx1 sy1 + } else if (cam.model == "EQUIRECTANGULAR") { + need(2); o.fx = (float)(p[0] / (2.0 * kPi)); o.fy = (float)(p[1] / kPi); o.cx = (float)(p[0] / 2.0); o.cy = (float)(p[1] / 2.0); - o.model_name = "EQUIRECTANGULAR"; + o.model = CameraModelType::EQUIRECTANGULAR; + + // ---- no exact tier: fit and re-distort -------------------------------- } else { - throw std::runtime_error("ColmapParser: unsupported camera model " + cam.model); + int id = colmap_model_id(cam.model); + if (id < 0) + throw std::runtime_error("ColmapParser: unknown camera model " + cam.model); + need((size_t)colmap_model_table().at(id).num_params); + o.source.source_model = id; + for (size_t i = 0; i < p.size() && i < 16; i++) + o.source.params[i] = (float)p[i]; + // Camera model, intrinsics and coefficients all come from the fit + // below. Which model suits depends on the parameters, not the name: + // a FOV lens is perspective at omega 0.3 and a full fisheye at 0.87. + return o; } + + // Drop to the cheapest tier the coefficients actually need. + o.distortion = camera_distortion_demote(o.distortion, o.dist.data(), o.dist.data()); return o; } +// One line per distinct outcome rather than per camera record: an image +// collection run through COLMAP without --ImageReader.single_camera has one +// camera record per photo, and the same sentence a thousand times is noise. +struct FitReport { + std::string source; // COLMAP model name + CameraModelType model; + CameraDistortionType distortion; + enum { Redistorted, Exact, Failed } kind; + double max_px = 0.0; // worst in the group + int count = 0; + + std::string key() const { + return source + "/" + camera_model_to_string(model) + "/" + + camera_distortion_to_string(distortion) + "/" + + std::to_string((int)kind); + } +}; + +// Replace an unrepresentable camera with the nearest supported one. The images +// are resampled to match later (DataManager's re-distort pass); what is chosen +// here is only the target camera. +void fit_colmap_source(const ColmapCamera& cam, BakedIntrins& bi, + std::map& reports) { + const RedistortSource src = bi.source; + dsfit::SourceProject project = + [&src](double x, double y, double z, double* u, double* v) { + return srccam::project(src.source_model, src.params, x, y, z, u, v); + }; + dsfit::FitResult fit = dsfit::fit_camera_auto( + project, (int)cam.width, (int)cam.height); + + bi.model = fit.target.model; + bi.fx = fit.target.fx; bi.fy = fit.target.fy; + bi.cx = fit.target.cx; bi.cy = fit.target.cy; + for (int i = 0; i < kCameraDistortionParams; i++) + bi.dist[i] = fit.target.coeffs[i]; + bi.distortion = camera_distortion_demote( + fit.target.distortion, bi.dist.data(), bi.dist.data()); + bi.source.fit_max_px = (float)fit.max_px; + + FitReport r; + r.source = cam.model; + r.model = bi.model; + r.distortion = bi.distortion; + r.max_px = fit.max_px; + if (!fit.ok && fit.samples == 0) { + // Only reachable when the source projected nothing anywhere -- a + // camera record this reader cannot interpret at all. Loading a wrong + // camera beats refusing to open a reconstruction that took hours. + r.kind = FitReport::Failed; + bi.source.source_model = -1; + } else if (fit.max_px < dsfit::kExactFitPx) { + // The fitted camera and the source agree to well under what bilinear + // resampling can resolve, so re-distorting would only cost VRAM and + // blur the images. + r.kind = FitReport::Exact; + bi.source.source_model = -1; + } else { + r.kind = FitReport::Redistorted; + } + + auto [it, fresh] = reports.emplace(r.key(), r); + it->second.count++; + if (!fresh) it->second.max_px = std::max(it->second.max_px, r.max_px); +} + +void print_fit_reports(const std::map& reports) { + namespace dm = spirula::i18n::msg::data; + for (const auto& [key, r] : reports) { + (void)key; + switch (r.kind) { + case FitReport::Failed: + std::printf("%s %s\n", dm::word_warning.get(), + spirula::i18n::format(dm::camera_model_fit_failed, + {r.source, r.count, + camera_model_to_string(r.model)}).c_str()); + break; + case FitReport::Exact: + std::printf("%s\n", spirula::i18n::format( + dm::camera_model_fitted_exact, + {r.source, r.count, camera_model_to_string(r.model), + camera_distortion_to_string(r.distortion), + dsfit::kExactFitPx}).c_str()); + break; + case FitReport::Redistorted: + std::printf("%s\n", spirula::i18n::format( + dm::camera_model_fitted, + {r.source, r.count, camera_model_to_string(r.model), + camera_distortion_to_string(r.distortion), + r.max_px}).c_str()); + break; + } + } +} + // colmap_utils.py qvec2rotmat (world->camera rotation from (w,x,y,z)). void qvec2rotmat(const std::array& q, double R[3][3]) { double w = q[0], x = q[1], y = q[2], z = q[3]; @@ -594,12 +748,30 @@ ParsedDataset parse_colmap_dataset(const std::string& dataset_dir, ds.train_frame_scale = train_frame_scale; for (int k = 0; k < 16; k++) ds.train_to_normalized[k] = (float)T_inv[k]; ds.camera_models.reserve(N); + ds.camera_distortions.reserve(N); ds.image_filenames.reserve(N); ds.widths.reserve(N); ds.heights.reserve(N); ds.c2w.resize(N * 12); ds.intrins.resize(N * 4); - ds.dist_coeffs.resize(N * 10); + ds.dist_coeffs.resize(N * kCameraDistortionParams); + + // One bake per COLMAP camera record, not per frame: a record is one + // physical camera, and a fitted one costs a least-squares solve. + std::map baked; + std::map fit_reports; + bool any_redistort = false; + for (const auto& [id, cam] : cameras) { + BakedIntrins bi = bake_colmap_intrins(cam); + if (bi.source.source_model >= 0) { + // May clear source_model again when the fit turned out exact. + fit_colmap_source(cam, bi, fit_reports); + any_redistort |= (bi.source.source_model >= 0); + } + baked.emplace(id, bi); + } + print_fit_reports(fit_reports); + if (any_redistort) ds.redistort.resize(N); std::vector mask_files(N), depth_files(N), normal_files(N); bool any_mask = false, any_depth = false, any_normal = false; @@ -620,11 +792,13 @@ ParsedDataset parse_colmap_dataset(const std::string& dataset_dir, " does not exist (set --image-dir if needed)"); ds.image_filenames.push_back(img_path.string()); - BakedIntrins bi = bake_colmap_intrins(cam); + BakedIntrins bi = baked.at(im.camera_id); float W = (float)cam.width, H = (float)cam.height; if (cfg.rescale_camera_to_fit > 0.0f) { float s = cfg.rescale_camera_to_fit; bi.fx /= s; bi.fy /= s; bi.cx /= s; bi.cy /= s; + if (bi.source.source_model >= 0) + srccam::rescale(bi.source.source_model, bi.source.params, s); auto round_dim = [&](float v) { if (cfg.downscale_rounding_mode == "ceil") return std::ceil(v / s); if (cfg.downscale_rounding_mode == "round") return std::round(v / s); @@ -638,12 +812,12 @@ ParsedDataset parse_colmap_dataset(const std::string& dataset_dir, ds.intrins[j*4 + 1] = bi.fy; ds.intrins[j*4 + 2] = bi.cx; ds.intrins[j*4 + 3] = bi.cy; - std::copy(bi.dist.begin(), bi.dist.end(), ds.dist_coeffs.begin() + j*10); + std::copy(bi.dist.begin(), bi.dist.end(), + ds.dist_coeffs.begin() + j*kCameraDistortionParams); - CameraModelType model = camera_model_from_name(bi.model_name); - if ((int)model < 0) - throw std::runtime_error("ColmapParser: unmapped camera model " + bi.model_name); - ds.camera_models.push_back((int32_t)model); + ds.camera_models.push_back((int32_t)bi.model); + ds.camera_distortions.push_back((int32_t)bi.distortion); + if (any_redistort) ds.redistort[j] = bi.source; std::copy(&c2w_all[i*12], &c2w_all[i*12] + 12, &ds.c2w[j*12]); diff --git a/src/data/parsers/DatasetCommon.cpp b/src/data/parsers/DatasetCommon.cpp index f3516600..ef196ebe 100644 --- a/src/data/parsers/DatasetCommon.cpp +++ b/src/data/parsers/DatasetCommon.cpp @@ -358,11 +358,14 @@ PostSplitCameras bake_post_split(const ParsedDataset& ds, out.viewmats.assign(n_post * 16, 0.f); out.intrins.assign(n_post * 4, 0.f); - out.dist_coeffs.assign(n_post * 10, 0.f); + out.dist_coeffs.assign(n_post * kCameraDistortionParams, 0.f); out.c2w_flip.assign(n_post * 12, 0.f); out.post_widths.assign(n_post, 0); out.post_heights.assign(n_post, 0); out.post_models.assign(n_post, PINHOLE_V); + // Cubemap faces are canonical pinhole with zero coefficients; only a K == 1 + // camera keeps the tier the parser chose. + out.post_distortions.assign(n_post, (int32_t)CameraDistortionType::None); // POST-split c2w staging (double). std::vector post_c2w(n_post * 12); @@ -393,8 +396,12 @@ PostSplitCameras bake_post_split(const ParsedDataset& ds, std::copy(&ds.intrins[i*4], &ds.intrins[i*4] + 4, &out.intrins[off*4]); } - std::copy(&ds.dist_coeffs[i*10], &ds.dist_coeffs[i*10] + 10, - &out.dist_coeffs[off*10]); + if (ds.camera_models[i] != EQUIRECT_V) { + std::copy(&ds.dist_coeffs[i*kCameraDistortionParams], + &ds.dist_coeffs[i*kCameraDistortionParams] + kCameraDistortionParams, + &out.dist_coeffs[off*kCameraDistortionParams]); + out.post_distortions[off] = ds.camera_distortions[i]; + } continue; } @@ -452,9 +459,26 @@ PostSplitCameras bake_post_split(const ParsedDataset& ds, vm[15] = 1.f; } + // A camera whose lens model had to be fitted needs its images resampled, + // which runs on the warp path's staging even when K == 1. + bool any_redistort = false; + for (const RedistortSource& r : ds.redistort) + any_redistort |= (r.source_model >= 0); + if (any_redistort) { + out.any_warp = true; + out.redistort_models.assign(N, -1); + out.redistort_params.assign((size_t)N * 16, 0.0f); + for (int64_t i = 0; i < N && i < (int64_t)ds.redistort.size(); i++) { + out.redistort_models[i] = ds.redistort[i].source_model; + for (int k = 0; k < 16; k++) + out.redistort_params[i*16 + k] = ds.redistort[i].params[k]; + } + } + if (out.any_warp) { out.input_intrins = ds.intrins; out.input_dist_coeffs = ds.dist_coeffs; + out.input_distortions = ds.camera_distortions; } return out; } diff --git a/src/data/parsers/MetashapeParser.cpp b/src/data/parsers/MetashapeParser.cpp index 55a195c3..ea77e9e2 100644 --- a/src/data/parsers/MetashapeParser.cpp +++ b/src/data/parsers/MetashapeParser.cpp @@ -385,6 +385,18 @@ ParsedDataset parse_metashape_dataset(const std::string& dataset_dir, jset(s, "p2", jnum(child_double(*calib, "p1"))); jset(s, "b1", jnum(child_double(*calib, "b1") / fl)); jset(s, "b2", jnum(child_double(*calib, "b2") / fl)); + // Metashape's k4 is the 4th RADIAL term, not OpenCV's first + // rational denominator, so say so rather than let the nerfstudio + // back end guess from which keys are present. + jset(s, "camera_distortion", jstr("THIN_PRISM")); + // PhotoScan <= 1.5 multiplied the tangential terms by + // (1 + P3 r^2 + P4 r^4); nothing here carries that. + if (child_double(*calib, "p3") != 0.0 || + child_double(*calib, "p4") != 0.0) + throw std::runtime_error( + "MetashapeParser: sensor " + *idp + " has nonzero p3/p4 " + "(the pre-1.6 tangential scaling), which no supported " + "distortion model carries"); } sensor_dict.emplace(*idp, std::move(s)); } diff --git a/src/data/parsers/NerfstudioParser.cpp b/src/data/parsers/NerfstudioParser.cpp index de1bfb4b..67383b0a 100644 --- a/src/data/parsers/NerfstudioParser.cpp +++ b/src/data/parsers/NerfstudioParser.cpp @@ -8,6 +8,8 @@ #include "data/Json.h" #include "core/CameraModel.h" // camera_model_from_name (CUDA-free) +#include "data/DistortionFit.h" +#include "data/SourceCamera.h" #include #include @@ -15,7 +17,9 @@ #include #include #include +#include #include +#include namespace dmsg = spirula::i18n::msg::data; @@ -259,9 +263,12 @@ ColmapPoints3D read_ply_points(const std::string& path) { namespace { -// Distortion keys, in engine dist_coeffs order. -const char* kDistortionKeys[10] = { - "k1", "k2", "k3", "k4", "p1", "p2", "sx1", "sy1", "b1", "b2"}; +// transforms.json distortion keys. k4..k6 mean different things either side of +// the fisheye divide: on a perspective camera they are OpenCV's RATIONAL +// denominator, on a fisheye they are further theta-space radial terms. +struct RawDistortion { + double k1, k2, k3, k4, k5, k6, p1, p2, sx1, sy1, b1, b2; +}; // frame-then-meta numeric lookup; throws when required and absent in both. double frame_or_meta(const JsonValue& frame, const JsonValue& meta, @@ -274,6 +281,73 @@ double frame_or_meta(const JsonValue& frame, const JsonValue& meta, return def; } +// A sensor skew (Metashape b2) is an off-diagonal pixel term, and every tier's +// pixel map is diagonal. So the camera is fitted without it and the images are +// resampled from the true skewed projection -- unless the skew turns out to be +// smaller than resampling can express, in which case it is simply dropped. +struct SkewFit { + CameraModelType model; + CameraDistortionType tier; + double fx, fy, cx, cy; + float coeffs[kCameraDistortionParams]; + RedistortSource source; // source_model < 0 when the skew was negligible +}; + +// Keyed on everything the fit depends on: a transforms.json repeats the same +// intrinsics on every frame and each fit is a least-squares solve. +using SkewCache = std::map; + +const SkewFit& fit_skewed_sensor(SkewCache& cache, CameraModelType model, + CameraDistortionType tier, + double fx, double fy, double cx, double cy, + double skew_px, const float* coeffs, + double W, double H, const std::string& label) { + RedistortSource src; + src.source_model = srccam::kSkewed; + src.params[0] = (float)fx; src.params[1] = (float)fy; + src.params[2] = (float)cx; src.params[3] = (float)cy; + src.params[4] = (float)skew_px; + for (int k = 0; k < kCameraDistortionParams; k++) + src.params[5 + k] = coeffs[k]; + src.params[13] = model == CameraModelType::FISHEYE ? srccam::kSkewBaseFisheye + : model == CameraModelType::EQUISOLID ? srccam::kSkewBaseEquisolid + : srccam::kSkewBasePerspective; + src.params[14] = tier == CameraDistortionType::Rational + ? srccam::kSkewRadialRational : srccam::kSkewRadialPolynomial; + + std::string key((const char*)src.params, sizeof(src.params)); + key += std::string((const char*)&W, sizeof(W)); + key += std::string((const char*)&H, sizeof(H)); + auto it = cache.find(key); + if (it != cache.end()) + return it->second; + + dsfit::SourceProject project = + [&src](double x, double y, double z, double* u, double* v) { + return srccam::project(src.source_model, src.params, x, y, z, u, v); + }; + // The same camera model reproduces everything but the skew, so try it + // before letting the fitter pick one it likes better. + dsfit::FitResult fit = dsfit::fit_camera(project, (int)W, (int)H, model); + if (!fit.invertible || fit.samples == 0) + fit = dsfit::fit_camera_auto(project, (int)W, (int)H); + + SkewFit f{}; + f.model = fit.target.model; + f.tier = fit.target.distortion; + f.fx = fit.target.fx; f.fy = fit.target.fy; + f.cx = fit.target.cx; f.cy = fit.target.cy; + for (int k = 0; k < kCameraDistortionParams; k++) f.coeffs[k] = fit.target.coeffs[k]; + if (fit.max_px >= dsfit::kExactFitPx) { + f.source = src; + f.source.fit_max_px = (float)fit.max_px; + std::printf("%s\n", spirula::i18n::format(dmsg::camera_sensor_skew, + {label, skew_px, camera_model_to_string(f.model), + camera_distortion_to_string(f.tier), fit.max_px}).c_str()); + } + return cache.emplace(std::move(key), f).first->second; +} + // 3x3 inverse (adjugate); used for applied_transform^-1. void invert3x3d(const double m[3][3], double out[3][3]) { double a = m[0][0], b = m[0][1], c = m[0][2], @@ -401,8 +475,9 @@ ParsedDataset parse_nerfstudio_meta(const JsonValue& meta, ds.train_frame_scale = (float)(scale_factor != 0.0 ? 1.0 / scale_factor : 1.0); ds.c2w.resize(N * 12); ds.intrins.resize(N * 4); - ds.dist_coeffs.resize(N * 10); + ds.dist_coeffs.resize(N * kCameraDistortionParams); ds.camera_models.reserve(N); + ds.camera_distortions.reserve(N); ds.image_filenames.reserve(N); ds.widths.reserve(N); ds.heights.reserve(N); @@ -410,6 +485,8 @@ ParsedDataset parse_nerfstudio_meta(const JsonValue& meta, std::vector mask_files(N), depth_files(N), normal_files(N); bool any_mask = false, any_depth = false, any_normal = false; const int EQUIRECT_V = (int)camera_model_from_name("EQUIRECTANGULAR"); + const int PINHOLE_V = (int)camera_model_from_name("PINHOLE"); + SkewCache skew_cache; for (int64_t j = 0; j < N; j++) { const Frame& F = frames[subset[j]]; @@ -431,13 +508,92 @@ ParsedDataset parse_nerfstudio_meta(const JsonValue& meta, throw std::runtime_error("NerfstudioParser: unsupported camera model " + model_name); - for (int k = 0; k < 10; k++) - ds.dist_coeffs[j*10 + k] = - (float)frame_or_meta(fr, meta, kDistortionKeys[k], false, 0.0); + RawDistortion rd{}; + auto get = [&](const char* key) { + return frame_or_meta(fr, meta, key, false, 0.0); + }; + rd.k1 = get("k1"); rd.k2 = get("k2"); rd.k3 = get("k3"); + rd.k4 = get("k4"); rd.k5 = get("k5"); rd.k6 = get("k6"); + rd.p1 = get("p1"); rd.p2 = get("p2"); + rd.sx1 = get("sx1"); rd.sy1 = get("sy1"); + rd.b1 = get("b1"); rd.b2 = get("b2"); + + // b1/b2 arrive already converted, NOT as Metashape writes them: + // metashape_utils.py (and MetashapeParser, which mirrors it) divides + // both by fl_x, and swaps p1/p2 into OpenCV order on the way. So here + // they are affinity and skew relative to fl_x. The affinity is an fx + // correction and folds in exactly; the skew is off-diagonal, so it is + // handled after the tier is known, below. + const double skew_px = rd.b2 * fx; + if (rd.b1 != 0.0) fx *= 1.0 + rd.b1; + + // An explicit "camera_distortion" resolves what k4 means; without one, + // a perspective camera follows OpenCV (k4..k6 are the rational + // denominator) and a fisheye follows Kannala-Brandt (k4 is radial). + // MetashapeParser always writes the key, because its 4th radial term + // would otherwise be read as a denominator. + CameraDistortionType hint = (CameraDistortionType)-1; + if (const JsonValue* v = fr.find("camera_distortion")) + hint = camera_distortion_from_name(v->as_string()); + else if (const JsonValue* v2 = meta.find("camera_distortion")) + hint = camera_distortion_from_name(v2->as_string()); + + // b1/b2 are Metashape's affinity and skew and sx1/sy1 are thin-prism + // terms; a rational camera has none of them, so their mere PRESENCE + // resolves what k4 means for a file that omits "camera_distortion" -- + // which is what a transforms.json converted from Metashape looks like. + // k5/k6 exist only in the rational model and decide on their own. + auto has = [&](const char* key) { + return fr.find(key) != nullptr || meta.find(key) != nullptr; + }; + bool thin_prism_shaped = + has("b1") || has("b2") || has("sx1") || has("sy1"); + + float* dst = &ds.dist_coeffs[j*kCameraDistortionParams]; + CameraDistortionType tier; + bool fisheye = ((int)model != PINHOLE_V); + bool rational = (hint == CameraDistortionType::Rational) || + ((int)hint < 0 && !fisheye && + (rd.k5 != 0.0 || rd.k6 != 0.0 || + (rd.k4 != 0.0 && !thin_prism_shaped))); + if (rational) { + tier = CameraDistortionType::Rational; + dst[0] = (float)rd.k1; dst[1] = (float)rd.k2; dst[2] = (float)rd.k3; + dst[3] = (float)rd.k4; dst[4] = (float)rd.k5; dst[5] = (float)rd.k6; + dst[6] = (float)rd.p1; dst[7] = (float)rd.p2; + } else { + tier = CameraDistortionType::ThinPrism; + dst[0] = (float)rd.k1; dst[1] = (float)rd.k2; + dst[2] = (float)rd.k3; dst[3] = (float)rd.k4; + dst[4] = (float)rd.p1; dst[5] = (float)rd.p2; + dst[6] = (float)rd.sx1; dst[7] = (float)rd.sy1; + } + if ((int)model == EQUIRECT_V) { + // A panorama has no lens, so it has no skew either; b2 on one is + // meaningless and ignored along with the rest of the coefficients. + tier = CameraDistortionType::None; + for (int k = 0; k < kCameraDistortionParams; k++) dst[k] = 0.0f; + } else if (skew_px != 0.0) { + const SkewFit& f = fit_skewed_sensor(skew_cache, model, tier, fx, fy, + cx, cy, skew_px, dst, W, H, F.abs); + model = f.model; + tier = f.tier; + fx = f.fx; fy = f.fy; cx = f.cx; cy = f.cy; + std::copy(f.coeffs, f.coeffs + kCameraDistortionParams, dst); + if (f.source.source_model >= 0) { + if (ds.redistort.empty()) ds.redistort.resize(N); + ds.redistort[j] = f.source; + } + } + ds.camera_distortions.push_back( + (int32_t)camera_distortion_demote(tier, dst, dst)); if (cfg.rescale_camera_to_fit > 0.0f) { double s = cfg.rescale_camera_to_fit; fx /= s; fy /= s; cx /= s; cy /= s; + if (!ds.redistort.empty() && ds.redistort[j].source_model >= 0) + srccam::rescale(ds.redistort[j].source_model, + ds.redistort[j].params, s); auto round_dim = [&](double v) { if (cfg.downscale_rounding_mode == "ceil") return std::ceil(v / s); if (cfg.downscale_rounding_mode == "round") return std::round(v / s); diff --git a/src/engine/Engine.h b/src/engine/Engine.h index 6265584d..d4af5c2a 100644 --- a/src/engine/Engine.h +++ b/src/engine/Engine.h @@ -60,6 +60,7 @@ void set_camera_params( int width, int height, std::string camera_model, + std::string distortion, TorchTensorView viewmats, TorchTensorView intrins, TorchTensorView dist_coeffs @@ -92,6 +93,7 @@ void set_training_data( // gt_depth / gt_normal to disable those. void set_training_data_warped( std::string input_model_name, // "FISHEYE" / "EQUISOLID" / "EQUIRECTANGULAR" + std::string input_distortion, int B_in, int in_H, int in_W, int K, int out_H, int out_W, TorchTensorView gt_rgb, // [B_in, in_H, in_W, 3] byte @@ -103,7 +105,9 @@ void set_training_data_warped( int normal_in_H, int normal_in_W, bool input_depth_is_ray_depth, // interpretation of the wide GT depth TorchTensorView input_intrins, // [B_in, 4] float - TorchTensorView input_dist_coeffs,// [B_in, 10] float + TorchTensorView input_dist_coeffs,// [B_in, 8] float + TorchTensorView input_source_models, // [B_in] int32 (nullable) + TorchTensorView input_source_params, // [B_in, 16] float uint64_t axes_dev // device float ptr [K, 3, 3] ); @@ -282,7 +286,7 @@ std::map engine_train_step( std::string primitive, int sh_degree, bool packed, - int width, int height, std::string camera_model, + int width, int height, std::string camera_model, std::string distortion, TorchTensorView viewmats, TorchTensorView intrins, TorchTensorView dist_coeffs, @@ -307,9 +311,12 @@ std::map engine_train_step_warped( TorchTensorView post_intrins, TorchTensorView post_dist_coeffs, std::string input_camera_model, + std::string input_distortion, int B_in, int in_H, int in_W, int K, TorchTensorView input_intrins, TorchTensorView input_dist_coeffs, + TorchTensorView input_source_models, + TorchTensorView input_source_params, TorchTensorView gt_rgb_byte, TorchTensorView gt_alpha_byte, int mask_in_H, int mask_in_W, @@ -332,6 +339,7 @@ struct HeteroSubBatch { int height = 0; int num = 0; // number of cameras in this sub-batch std::string camera_model; + std::string distortion; TorchTensorView viewmats{0, 0, {}}; TorchTensorView intrins{0, 0, {}}; TorchTensorView dist_coeffs{0, 0, {}}; @@ -377,6 +385,7 @@ void engine_setup_data_manager( // Per-camera model enum value (int; cast to CameraModelType internally). // Mixed pinhole + fisheye datasets just produce extra index groups. std::vector camera_models, + std::vector camera_distortions, std::vector image_filenames, std::vector mask_filenames, std::vector depth_filenames, @@ -397,6 +406,8 @@ void engine_setup_data_manager( // camera is in the dataset. std::vector input_intrins, std::vector input_dist_coeffs, + std::vector redistort_models, + std::vector redistort_params, std::vector train_indices, std::vector val_indices); @@ -555,6 +566,7 @@ void engine_blit_view( TorchTensorView render_depth, // [H,W,1] float, may be null when buffer_key=="alpha" TorchTensorView render_alpha, // [H,W,1] float int view_camera_model, + std::string distortion, TorchTensorView view_intrins, // [1,4] float TorchTensorView view_viewmat, // [4,4] float TorchTensorView view_dist_coeffs, diff --git a/src/engine/EngineBackground.cpp b/src/engine/EngineBackground.cpp index 62079c2b..de0d0923 100644 --- a/src/engine/EngineBackground.cpp +++ b/src/engine/EngineBackground.cpp @@ -174,7 +174,8 @@ void _engine_background_forward() { TorchTensorView bg_image_tv = _dt3d_tv(bg.fwd_background); BgShViews vs = _engine_bg_sh_views(C_batch); render_background_sh_forward( - W, H, engine().camera.model_str, bg.sh_degree, + W, H, engine().camera.model_str, + engine().camera.distortion_str, bg.sh_degree, vs.viewmats, vs.intrins, vs.dist_coeffs, vs.sh_coeffs, bg_image_tv); @@ -268,7 +269,8 @@ void _engine_background_backward_hook( BgShViews vs = _engine_bg_sh_views(C_batch); render_background_sh_backward( - W, H, engine().camera.model_str, bg.sh_degree, + W, H, engine().camera.model_str, + engine().camera.distortion_str, bg.sh_degree, vs.viewmats, vs.intrins, vs.dist_coeffs, vs.sh_coeffs, bg_image_tv, v_bg_tv2, diff --git a/src/engine/EngineDataManager.cpp b/src/engine/EngineDataManager.cpp index 414857ca..3d13929e 100644 --- a/src/engine/EngineDataManager.cpp +++ b/src/engine/EngineDataManager.cpp @@ -26,6 +26,7 @@ void engine_setup_data_manager( DataManagerConfig cfg, std::vector camera_models, + std::vector camera_distortions, std::vector image_filenames, std::vector mask_filenames, std::vector depth_filenames, @@ -39,6 +40,8 @@ void engine_setup_data_manager( std::vector dist_coeffs, std::vector input_intrins, std::vector input_dist_coeffs, + std::vector redistort_models, + std::vector redistort_params, std::vector train_indices, std::vector val_indices) { @@ -47,7 +50,7 @@ void engine_setup_data_manager( engine().dm.reset(); engine().dm = std::make_unique( - std::move(cfg), std::move(camera_models), + std::move(cfg), std::move(camera_models), std::move(camera_distortions), std::move(image_filenames), std::move(mask_filenames), std::move(depth_filenames), std::move(normal_filenames), std::move(widths), std::move(heights), @@ -55,6 +58,7 @@ void engine_setup_data_manager( std::move(viewmats), std::move(intrins), std::move(dist_coeffs), std::move(input_intrins), std::move(input_dist_coeffs), + std::move(redistort_models), std::move(redistort_params), std::move(train_indices), std::move(val_indices)); } @@ -148,13 +152,14 @@ std::map engine_train_step_managed( TorchTensorView bilagrid_cam_indices( (uint64_t)_bg_idx_buf.data(), 4, {(int64_t)b.num, 1LL}); - if (b.K <= 1) { + if (b.K <= 1 && b.input_source_models.empty()) { // Standard path: GT is already at engine shape, no warp needed. return engine_train_step( step, max_steps, std::move(primitive), sh_degree, packed, (int)b.width, (int)b.height, camera_model_to_string(b.model), + camera_distortion_to_string(b.distortion), b.viewmats_view, b.intrins_view, b.dist_coeffs_view, b.rgb_view, b.depth_view, b.normal_view, b.mask_view, bilagrid_cam_indices, @@ -170,8 +175,10 @@ std::map engine_train_step_managed( (int)b.width, (int)b.height, b.viewmats_view, b.intrins_view, b.dist_coeffs_view, camera_model_to_string(b.input_model), + camera_distortion_to_string(b.input_distortion), b.input_num, b.input_height, b.input_width, b.K, b.input_intrins_view, b.input_dist_coeffs_view, + b.input_source_models_view, b.input_source_params_view, b.rgb_view, b.mask_view, b.mask_height, b.mask_width, b.depth_view, b.depth_height, b.depth_width, @@ -232,19 +239,25 @@ static TorchTensorView _tv_null() { return {0, 0, {}}; } // mask and warp training used, and neither wants loss, backward or optim. static void _install_and_forward(const DecodedBatch& b, std::string primitive, int sh_degree, bool packed) { - if (b.K <= 1) { + if (b.K <= 1 && b.input_source_models.empty()) { set_camera_params((int)b.width, (int)b.height, camera_model_to_string(b.model), + camera_distortion_to_string(b.distortion), b.viewmats_view, b.intrins_view, b.dist_coeffs_view); // No depth/normal: both callers compare RGB only, and skipping them // avoids the linear->ray depth conversion pass. set_training_data(b.rgb_view, _tv_null(), _tv_null(), b.mask_view, true); } else { - set_camera_params((int)b.width, (int)b.height, "PINHOLE", + // b.model / b.distortion are already PINHOLE / NONE when K > 1; at + // K == 1 (re-distort) they are the camera the parser fitted. + set_camera_params((int)b.width, (int)b.height, + camera_model_to_string(b.model), + camera_distortion_to_string(b.distortion), b.viewmats_view, b.intrins_view, b.dist_coeffs_view); set_training_data_warped( camera_model_to_string(b.input_model), + camera_distortion_to_string(b.input_distortion), b.input_num, (int)b.input_height, (int)b.input_width, b.K, (int)b.height, (int)b.width, b.rgb_view, b.mask_view, (int)b.mask_height, (int)b.mask_width, @@ -252,6 +265,7 @@ static void _install_and_forward(const DecodedBatch& b, std::string primitive, _tv_null(), 0, 0, true, b.input_intrins_view, b.input_dist_coeffs_view, + b.input_source_models_view, b.input_source_params_view, (uint64_t)b.axes_dev); } diff --git a/src/engine/EngineForward.cpp b/src/engine/EngineForward.cpp index e4290c07..c0478083 100644 --- a/src/engine/EngineForward.cpp +++ b/src/engine/EngineForward.cpp @@ -126,7 +126,8 @@ void forward_3dgs( engine().cur_num_splats, sh_degree, in_splats, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().optim.radii, sh_value_packed_opt, sh_value_bounds_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); cam_ids = a; gauss_ids = b; aabb_vec = c; depths_vec = d; @@ -136,7 +137,8 @@ void forward_3dgs( engine().cur_num_splats, sh_degree, in_splats, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().optim.radii, sh_value_packed_opt, sh_value_bounds_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); cam_ids = a; gauss_ids = b; aabb_vec = c; depths_vec = d; @@ -146,7 +148,8 @@ void forward_3dgs( engine().cur_num_splats, sh_degree, in_splats, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().optim.radii, sh_value_packed_opt, sh_value_bounds_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); cam_ids = a; gauss_ids = b; aabb_vec = c; depths_vec = d; @@ -169,7 +172,8 @@ void forward_3dgs( engine().cur_num_splats, sh_degree, in_splats, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().optim.radii, sh_value_packed_opt, sh_value_bounds_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); aabb_2d = a; depths_2d = b; @@ -179,7 +183,8 @@ void forward_3dgs( engine().cur_num_splats, sh_degree, in_splats, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().optim.radii, sh_value_packed_opt, sh_value_bounds_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); aabb_2d = a; depths_2d = b; @@ -189,7 +194,8 @@ void forward_3dgs( engine().cur_num_splats, sh_degree, in_splats, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().optim.radii, sh_value_packed_opt, sh_value_bounds_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); aabb_2d = a; depths_2d = b; @@ -267,7 +273,8 @@ void forward_3dgs( engine().cur_num_splats, in_splats, engine().fwd.splats_s, engine().fwd.gaussian_ids, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().fwd.aabb, (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, tile_offsets, flatten_ids, dist_type, output_median); diff --git a/src/engine/EngineLoss.cpp b/src/engine/EngineLoss.cpp index 8161c3af..cca744b8 100644 --- a/src/engine/EngineLoss.cpp +++ b/src/engine/EngineLoss.cpp @@ -248,6 +248,7 @@ static void _engine_raster_proj_backward( _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().fwd.aabb, (uint32_t)engine().camera.width, @@ -336,7 +337,8 @@ static void _engine_raster_proj_backward( fn(engine().cur_num_splats, engine().sh_degree, engine().fwd.splats_w, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().fwd.camera_ids, engine().fwd.gaussian_ids, engine().fwd.aabb, v_splats_s_out, v_splats_w_out, gq, vp_opt, vb_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); @@ -350,7 +352,8 @@ static void _engine_raster_proj_backward( engine().cur_num_splats, engine().sh_degree, engine().fwd.splats_w, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().fwd.camera_ids, engine().fwd.gaussian_ids, engine().fwd.aabb, v_splats_s_out, v_splats_w_out, nullptr, vp_opt, vb_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); @@ -359,7 +362,8 @@ static void _engine_raster_proj_backward( engine().cur_num_splats, engine().sh_degree, engine().fwd.splats_w, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().fwd.camera_ids, engine().fwd.gaussian_ids, engine().fwd.aabb, v_splats_s_out, v_splats_w_out, nullptr, vp_opt, vb_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); @@ -368,7 +372,8 @@ static void _engine_raster_proj_backward( engine().cur_num_splats, engine().sh_degree, engine().fwd.splats_w, _dt2d_tv(engine().camera.viewmats), _dv_tv(engine().camera.intrins), (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, - engine().camera.model_str, _dt2d_tv(engine().camera.dist_coeffs), + engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().fwd.camera_ids, engine().fwd.gaussian_ids, engine().fwd.aabb, v_splats_s_out, v_splats_w_out, nullptr, vp_opt, vb_opt, num_sh_buffer, sh_value_bits, sh_bounds_stride); @@ -526,6 +531,7 @@ std::map engine_compute_loss_backward( depth_normal = _pool_tv(PoolSlot::EngDepthNormal, C, H, W, 3); depth_to_normal_forward( engine().camera.model_str, + engine().camera.distortion_str, _dv_tv(engine().camera.intrins), _dt2d_tv(engine().camera.dist_coeffs), is_ray_depth, @@ -552,6 +558,7 @@ std::map engine_compute_loss_backward( median_normal = _pool_tv(PoolSlot::EngMedianNormal, C, H, W, 3); depth_to_normal_forward( engine().camera.model_str, + engine().camera.distortion_str, _dv_tv(engine().camera.intrins), _dt2d_tv(engine().camera.dist_coeffs), is_ray_depth, @@ -781,6 +788,7 @@ std::map engine_compute_loss_backward( if (compute_depth_normal) { depth_to_normal_backward( engine().camera.model_str, + engine().camera.distortion_str, _dv_tv(engine().camera.intrins), _dt2d_tv(engine().camera.dist_coeffs), is_ray_depth, @@ -795,6 +803,7 @@ std::map engine_compute_loss_backward( if (has_median && median_normal_active) { depth_to_normal_backward( engine().camera.model_str, + engine().camera.distortion_str, _dv_tv(engine().camera.intrins), _dt2d_tv(engine().camera.dist_coeffs), is_ray_depth, diff --git a/src/engine/EngineOptim.cpp b/src/engine/EngineOptim.cpp index dafae24a..e3e4250d 100644 --- a/src/engine/EngineOptim.cpp +++ b/src/engine/EngineOptim.cpp @@ -444,6 +444,7 @@ void engine_fused_proj_bwd_optim_step(int step, const OptimConfig& cfg) { (uint32_t)engine().camera.width, (uint32_t)engine().camera.height, engine().camera.model_str, + engine().camera.distortion_str, _dt2d_tv(engine().camera.dist_coeffs), engine().fwd.camera_ids, engine().fwd.gaussian_ids, diff --git a/src/engine/EngineSetup.cpp b/src/engine/EngineSetup.cpp index 9cbc0653..dc1905af 100644 --- a/src/engine/EngineSetup.cpp +++ b/src/engine/EngineSetup.cpp @@ -51,6 +51,7 @@ void set_camera_params( int width, int height, std::string camera_model, + std::string distortion, TorchTensorView viewmats, TorchTensorView intrins, TorchTensorView dist_coeffs @@ -59,6 +60,8 @@ void set_camera_params( engine().camera.height = height; engine().camera.model = cmt(camera_model); engine().camera.model_str = camera_model; + engine().camera.distortion = cdt(distortion); + engine().camera.distortion_str = distortion; engine().camera.num = std::get<2>(viewmats)[0]; if (std::get<2>(intrins)[0] != engine().camera.num || @@ -108,6 +111,7 @@ void set_training_data( if (!input_depth_is_ray_depth && engine().gt.depth.data_ptr() != nullptr) { linear_depth_to_ray_depth_inplace( engine().camera.model_str, + engine().camera.distortion_str, _dv_tv(engine().camera.intrins), _dt2d_tv(engine().camera.dist_coeffs), engine().camera.width, engine().camera.height, diff --git a/src/engine/EngineSetupWarped.cpp b/src/engine/EngineSetupWarped.cpp index 2c2df239..7a2194f4 100644 --- a/src/engine/EngineSetupWarped.cpp +++ b/src/engine/EngineSetupWarped.cpp @@ -54,6 +54,20 @@ static const void* _h2d_stage_byte( // views point at host std::vector memory (DecodedBatch hands out host // TorchTensorViews), so they must be copied to device first -- otherwise the // kernel faults on an illegal address. Zero-copy when already a device ptr. +static const int32_t* _h2d_stage_ints( + const TorchTensorView& src_tv, size_t numel, PoolSlot slot) +{ + uint64_t src_ptr = std::get<0>(src_tv); + if (src_ptr == 0 || numel == 0) return nullptr; + if (_is_device_ptr((void*)src_ptr)) { + return (const int32_t*)src_ptr; + } + int32_t* p = DevicePool::global().acquire(slot, numel); + backend::memcpy_sync(p, (void*)src_ptr, numel * sizeof(int32_t), + backend::MemcpyKind::HostToDevice); + return p; +} + static const float* _h2d_stage_floats( const TorchTensorView& src_tv, size_t numel, PoolSlot slot) { @@ -72,6 +86,7 @@ void set_training_data_warped( // Input-side camera model name (FISHEYE / EQUISOLID / EQUIRECTANGULAR). // The kernel dispatcher uses this to pick wide vs equirectangular warp. std::string input_model_name, + std::string input_distortion, int B_in, int in_H, int in_W, int K, int out_H, int out_W, // GT RGB at INPUT shape, byte (uint8 or uint16). The kernel fuses @@ -94,6 +109,14 @@ void set_training_data_warped( // be zero-copy when already on device. TorchTensorView input_intrins, TorchTensorView input_dist_coeffs, + // Per-INPUT source camera, for the cameras whose lens model no tier + // represents: [B_in] COLMAP model id and [B_in, 16] its own parameters. + // Null unless the dataset carries one. With K > 1 the wide warp projects + // straight through this instead of the fitted camera, so the two passes + // fuse and no intermediate image is allocated; with K == 1 it selects the + // re-distort kernels below. + TorchTensorView input_source_models, + TorchTensorView input_source_params, // Device pointer to the [K, 3, 3] cubemap axes table (lifetime managed // by DataManager). uint64_t axes_dev) @@ -136,10 +159,26 @@ void set_training_data_warped( const float* d_intrins = _h2d_stage_floats( input_intrins, (size_t)B_in * 4, PoolSlot::WarpInputIntrins); const float* d_dist = _h2d_stage_floats( - input_dist_coeffs, (size_t)B_in * 10, PoolSlot::WarpInputDistCoeffs); + input_dist_coeffs, (size_t)B_in * kCameraDistortionParams, + PoolSlot::WarpInputDistCoeffs); + + const int* d_src_models = nullptr; + const float* d_src_params = nullptr; + if (std::get<0>(input_source_models) != 0) { + d_src_models = (const int*)_h2d_stage_ints( + input_source_models, (size_t)B_in, PoolSlot::WarpSourceModels); + d_src_params = _h2d_stage_floats( + input_source_params, (size_t)B_in * 16, PoolSlot::WarpSourceParams); + } + const bool redistort_only = (K == 1 && d_src_models != nullptr); CameraModelType cm = cmt(input_model_name); - if (cm == CameraModelType::EQUIRECTANGULAR) { + if (redistort_only) { + launch_redistort_byte_to_float( + input_model_name, input_distortion, d_intrins, d_dist, + d_src_models, d_src_params, d_rgb_byte, rgb_u16, + B_in, in_H, in_W, 3, d_rgb_float, out_H, out_W, in_H, in_W, 0.5f); + } else if (cm == CameraModelType::EQUIRECTANGULAR) { launch_warp_byte_to_float_equi( d_rgb_byte, rgb_u16, B_in, in_H, in_W, 3, d_rgb_float, K, out_H, out_W, @@ -149,7 +188,8 @@ void set_training_data_warped( // projection dispatch internally on `cm`. (PINHOLE doesn't normally // hit this path -- K==1 there -- but the kernel handles it anyway.) launch_warp_byte_to_float_wide( - input_model_name, d_intrins, d_dist, + input_model_name, input_distortion, d_intrins, d_dist, + d_src_models, d_src_params, d_rgb_byte, rgb_u16, B_in, in_H, in_W, 3, d_rgb_float, K, out_H, out_W, (const float*)axes_dev); @@ -175,13 +215,20 @@ void set_training_data_warped( uint8_t* d_mask_out = DevicePool::global().acquire( PoolSlot::GtAlpha, (size_t)B_post * out_H * out_W); - if (cm == CameraModelType::EQUIRECTANGULAR) { + if (redistort_only) { + launch_redistort_mask( + input_model_name, input_distortion, d_intrins, d_dist, + d_src_models, d_src_params, + (const uint8_t*)d_mask_in, B_in, mask_in_H, mask_in_W, + d_mask_out, out_H, out_W, in_H, in_W); + } else if (cm == CameraModelType::EQUIRECTANGULAR) { launch_warp_mask_equi( (const uint8_t*)d_mask_in, B_in, mask_in_H, mask_in_W, d_mask_out, K, out_H, out_W, (const float*)axes_dev); } else { launch_warp_mask_wide( - input_model_name, d_intrins, d_dist, + input_model_name, input_distortion, d_intrins, d_dist, + d_src_models, d_src_params, (const uint8_t*)d_mask_in, B_in, mask_in_H, mask_in_W, d_mask_out, K, out_H, out_W, (const float*)axes_dev); } @@ -211,14 +258,21 @@ void set_training_data_warped( } float* d_depth_out = DevicePool::global().acquire( PoolSlot::GtDepth, (size_t)B_post * out_H * out_W); - if (cm == CameraModelType::EQUIRECTANGULAR) { + if (redistort_only) { + launch_redistort_depth( + input_model_name, input_distortion, d_intrins, d_dist, + d_src_models, d_src_params, d_depth_in, d_elem, + B_in, depth_in_H, depth_in_W, 1, + d_depth_out, out_H, out_W, in_H, in_W, 0.0f); + } else if (cm == CameraModelType::EQUIRECTANGULAR) { launch_warp_depth_equi( d_depth_in, d_elem, B_in, depth_in_H, depth_in_W, d_depth_out, K, out_H, out_W, (const float*)axes_dev, input_depth_is_ray_depth); } else { launch_warp_depth_wide( - input_model_name, d_intrins, d_dist, + input_model_name, input_distortion, d_intrins, d_dist, + d_src_models, d_src_params, d_depth_in, d_elem, B_in, depth_in_H, depth_in_W, in_H, in_W, d_depth_out, K, out_H, out_W, (const float*)axes_dev, input_depth_is_ray_depth); @@ -247,13 +301,20 @@ void set_training_data_warped( } float* d_normal_out = DevicePool::global().acquire( PoolSlot::GtNormal, (size_t)B_post * out_H * out_W * 3); - if (cm == CameraModelType::EQUIRECTANGULAR) { + if (redistort_only) { + launch_redistort_normal( + input_model_name, input_distortion, d_intrins, d_dist, + d_src_models, d_src_params, d_normal_in, n_elem == 4, + B_in, normal_in_H, normal_in_W, + d_normal_out, out_H, out_W, in_H, in_W); + } else if (cm == CameraModelType::EQUIRECTANGULAR) { launch_warp_normal_equi( d_normal_in, n_elem, B_in, normal_in_H, normal_in_W, d_normal_out, K, out_H, out_W, (const float*)axes_dev); } else { launch_warp_normal_wide( - input_model_name, d_intrins, d_dist, + input_model_name, input_distortion, d_intrins, d_dist, + d_src_models, d_src_params, d_normal_in, n_elem, B_in, normal_in_H, normal_in_W, in_H, in_W, d_normal_out, K, out_H, out_W, (const float*)axes_dev); diff --git a/src/engine/EngineState.h b/src/engine/EngineState.h index 338168f6..f3b8049f 100644 --- a/src/engine/EngineState.h +++ b/src/engine/EngineState.h @@ -115,10 +115,12 @@ struct CameraTable { int32_t width = 0; int32_t height = 0; CameraModelType model = (CameraModelType)-1; + CameraDistortionType distortion = CameraDistortionType::None; std::string model_str; + std::string distortion_str = "NONE"; DeviceTensor2D viewmats; // [C, 4] DeviceVector intrins; // [C] - DeviceTensor2D dist_coeffs; // [C, 10] + DeviceTensor2D dist_coeffs; // [C, 8] }; // Forward-pass intermediates retained for backward. @@ -450,7 +452,7 @@ struct EngineViewerState { DeviceVector d_widths; // [N_post] DeviceVector d_heights; // [N_post] DeviceVector d_camera_models; // [N_post] - DeviceVector d_dist_coeffs; // [N_post, 10] + DeviceVector d_dist_coeffs; // [N_post, 8] DeviceVector d_camera_to_worlds; // [N_post, 3, 4] (y/z-flipped form) float camera_size = 0.0f; // frustum render scale, from knn-dist diff --git a/src/engine/EngineTrainStep.cpp b/src/engine/EngineTrainStep.cpp index 2bd55a66..c272243d 100644 --- a/src/engine/EngineTrainStep.cpp +++ b/src/engine/EngineTrainStep.cpp @@ -216,7 +216,7 @@ static std::map _engine_train_step_split_one_per_camera( std::string primitive, int sh_degree, bool packed, - int width, int height, std::string camera_model, + int width, int height, std::string camera_model, std::string distortion, TorchTensorView viewmats, // [B, 4, 4] TorchTensorView intrins, // [B, 4] TorchTensorView dist_coeffs, // [B, K] @@ -244,7 +244,7 @@ static std::map _engine_train_step_split_one_per_camera( // Single-camera batch -> no point splitting; fall through to the // standard path with grad_scale = 1. if (B == 1) { - set_camera_params(width, height, camera_model, + set_camera_params(width, height, camera_model, distortion, viewmats, intrins, dist_coeffs); set_training_data(gt_rgb, gt_depth, gt_normal, gt_alpha, cfg.loss.input_depth_is_ray_depth); @@ -305,7 +305,7 @@ static std::map _engine_train_step_split_one_per_camera( TorchTensorView aph_k = _slice_tv_first_dim(gt_alpha, k); TorchTensorView bgi_k = _slice_tv_first_dim(bilagrid_cam_indices, k); - set_camera_params(width, height, camera_model, vmt_k, itr_k, dst_k); + set_camera_params(width, height, camera_model, distortion, vmt_k, itr_k, dst_k); set_training_data(rgb_k, dep_k, nrm_k, aph_k, cfg.loss.input_depth_is_ray_depth); @@ -443,7 +443,7 @@ std::map engine_train_step_hetero( TorchTensorView aph_c = _slice_tv_first_dim(s.gt_alpha, c); TorchTensorView bgi_c = _slice_tv_first_dim(s.bilagrid_cam_indices, c); - set_camera_params(s.width, s.height, s.camera_model, + set_camera_params(s.width, s.height, s.camera_model, s.distortion, vmt_c, itr_c, dst_c); set_training_data(rgb_c, dep_c, nrm_c, aph_c, cfg.loss.input_depth_is_ray_depth); @@ -495,7 +495,7 @@ std::map engine_train_step( std::string primitive, int sh_degree, bool packed, - int width, int height, std::string camera_model, + int width, int height, std::string camera_model, std::string distortion, TorchTensorView viewmats, TorchTensorView intrins, TorchTensorView dist_coeffs, @@ -509,12 +509,12 @@ std::map engine_train_step( if (cfg.optim.split_batch) { return _engine_train_step_split_one_per_camera( step, max_steps, std::move(primitive), sh_degree, packed, - width, height, std::move(camera_model), + width, height, std::move(camera_model), std::move(distortion), viewmats, intrins, dist_coeffs, gt_rgb, gt_depth, gt_normal, gt_alpha, bilagrid_cam_indices, cfg); } - set_camera_params(width, height, camera_model, viewmats, intrins, dist_coeffs); + set_camera_params(width, height, camera_model, distortion, viewmats, intrins, dist_coeffs); set_training_data(gt_rgb, gt_depth, gt_normal, gt_alpha, cfg.loss.input_depth_is_ray_depth); return _engine_train_step_after_setup( @@ -539,10 +539,13 @@ static std::map _engine_train_step_split_warped( TorchTensorView post_intrins, TorchTensorView post_dist_coeffs, std::string input_camera_model, + std::string input_distortion, int B_in, int in_H, int in_W, int K, TorchTensorView input_intrins, TorchTensorView input_dist_coeffs, + TorchTensorView input_source_models, + TorchTensorView input_source_params, TorchTensorView gt_rgb_byte, TorchTensorView gt_alpha_byte, int mask_in_H, int mask_in_W, @@ -564,20 +567,27 @@ static std::map _engine_train_step_split_warped( if (K <= 0) throw std::runtime_error("split_batch (warped): K must be positive"); + // Cubemap faces are canonical pinhole. K == 1 is the re-distort path, + // whose destination is the camera the parser fitted -- the input one. + const std::string post_model = K > 1 ? "PINHOLE" : input_camera_model; + const std::string post_dist = K > 1 ? "NONE" : input_distortion; + // Single input image (B_in == 1) -> nothing to split; route through the // standard warped path so K cams are processed in one shot. grad_scale // stays at 1.0 (the normal post-batch normalization is correct). if (B_in == 1) { - set_camera_params(out_W, out_H, "PINHOLE", + set_camera_params(out_W, out_H, post_model, post_dist, post_viewmats, post_intrins, post_dist_coeffs); - set_training_data_warped(input_camera_model, + set_training_data_warped(input_camera_model, input_distortion, B_in, in_H, in_W, K, out_H, out_W, gt_rgb_byte, gt_alpha_byte, mask_in_H, mask_in_W, gt_depth_byte, depth_in_H, depth_in_W, gt_normal_byte, normal_in_H, normal_in_W, cfg.loss.input_depth_is_ray_depth, - input_intrins, input_dist_coeffs, axes_dev); + input_intrins, input_dist_coeffs, + input_source_models, input_source_params, + axes_dev); return _engine_train_step_after_setup( step, max_steps, std::move(primitive), sh_degree, packed, bilagrid_cam_indices, cfg); @@ -613,6 +623,10 @@ static std::map _engine_train_step_split_warped( TorchTensorView nrm_k = _slice_tv_first_dim(gt_normal_byte, k); TorchTensorView i_itr_k = _slice_tv_first_dim(input_intrins, k); TorchTensorView i_dst_k = _slice_tv_first_dim(input_dist_coeffs, k); + TorchTensorView i_src_m_k = std::get<0>(input_source_models) == 0 + ? input_source_models : _slice_tv_first_dim(input_source_models, k); + TorchTensorView i_src_p_k = std::get<0>(input_source_params) == 0 + ? input_source_params : _slice_tv_first_dim(input_source_params, k); // Per-input-image POST-split slices (B_post axis, K consecutive rows // per input). @@ -621,15 +635,17 @@ static std::map _engine_train_step_split_warped( TorchTensorView p_dst_k = _slice_tv_range_first_dim(post_dist_coeffs, k * K, K); TorchTensorView bgi_k = _slice_tv_range_first_dim(bilagrid_cam_indices, k * K, K); - set_camera_params(out_W, out_H, "PINHOLE", p_vmt_k, p_itr_k, p_dst_k); - set_training_data_warped(input_camera_model, + set_camera_params(out_W, out_H, post_model, post_dist, + p_vmt_k, p_itr_k, p_dst_k); + set_training_data_warped(input_camera_model, input_distortion, /*B_in=*/1, in_H, in_W, K, out_H, out_W, rgb_k, mask_k, mask_in_H, mask_in_W, dep_k, depth_in_H, depth_in_W, nrm_k, normal_in_H, normal_in_W, cfg.loss.input_depth_is_ray_depth, - i_itr_k, i_dst_k, axes_dev); + i_itr_k, i_dst_k, i_src_m_k, i_src_p_k, + axes_dev); _set_cur_cam_indices(bgi_k); engine_viewer_capture_thumbnails(bgi_k); @@ -681,13 +697,16 @@ std::map engine_train_step_warped( int out_W, int out_H, TorchTensorView post_viewmats, // [B*K, 4, 4] TorchTensorView post_intrins, // [B*K, 4] - TorchTensorView post_dist_coeffs, // [B*K, 10] + TorchTensorView post_dist_coeffs, // [B*K, 8] // Warp inputs (operate on INPUT shape). std::string input_camera_model, // "FISHEYE" / "EQUISOLID" / "EQUIRECTANGULAR" + std::string input_distortion, int B_in, int in_H, int in_W, int K, TorchTensorView input_intrins, // [B_in, 4] - TorchTensorView input_dist_coeffs, // [B_in, 10] + TorchTensorView input_dist_coeffs, // [B_in, 8] + TorchTensorView input_source_models, // [B_in] int32 (nullable) + TorchTensorView input_source_params, // [B_in, 16] TorchTensorView gt_rgb_byte, // [B_in, in_H, in_W, 3] u8/u16 TorchTensorView gt_alpha_byte, // [B_in, mask_in_H, mask_in_W, 1] u8 (nullable) int mask_in_H, int mask_in_W, @@ -704,25 +723,31 @@ std::map engine_train_step_warped( return _engine_train_step_split_warped( step, max_steps, std::move(primitive), sh_degree, packed, out_W, out_H, post_viewmats, post_intrins, post_dist_coeffs, - std::move(input_camera_model), B_in, in_H, in_W, K, + std::move(input_camera_model), std::move(input_distortion), B_in, in_H, in_W, K, input_intrins, input_dist_coeffs, + input_source_models, input_source_params, gt_rgb_byte, gt_alpha_byte, mask_in_H, mask_in_W, gt_depth_byte, depth_in_H, depth_in_W, gt_normal_byte, normal_in_H, normal_in_W, axes_dev, bilagrid_cam_indices, cfg); } - // Camera table is set up at POST-split resolution + PINHOLE. - set_camera_params(out_W, out_H, "PINHOLE", + // Cubemap faces are canonical pinhole; K == 1 (re-distort) keeps the + // camera the parser fitted, which is the input one. + set_camera_params(out_W, out_H, + K > 1 ? "PINHOLE" : input_camera_model, + K > 1 ? "NONE" : input_distortion, post_viewmats, post_intrins, post_dist_coeffs); // GT is warped on the fly into a float [B*K, out_H, out_W, 3] buffer. - set_training_data_warped(input_camera_model, + set_training_data_warped(input_camera_model, input_distortion, B_in, in_H, in_W, K, out_H, out_W, gt_rgb_byte, gt_alpha_byte, mask_in_H, mask_in_W, gt_depth_byte, depth_in_H, depth_in_W, gt_normal_byte, normal_in_H, normal_in_W, cfg.loss.input_depth_is_ray_depth, - input_intrins, input_dist_coeffs, axes_dev); + input_intrins, input_dist_coeffs, + input_source_models, input_source_params, + axes_dev); return _engine_train_step_after_setup( step, max_steps, std::move(primitive), sh_degree, packed, bilagrid_cam_indices, cfg); diff --git a/src/generated/camera_source.cuh b/src/generated/camera_source.cuh new file mode 100644 index 00000000..abef8ccd --- /dev/null +++ b/src/generated/camera_source.cuh @@ -0,0 +1,850 @@ +#pragma once + +#include "generated/slang.cuh" + +inline __device__ float dot_0(float2 x_0, float2 y_0) +{ + int i_0 = int(0); + float result_0 = 0.0f; + for(;;) + { + if(i_0 < int(2)) + { + } + else + { + break; + } + float result_1 = result_0 + _slang_vector_get_element(x_0, i_0) * _slang_vector_get_element(y_0, i_0); + i_0 = i_0 + int(1); + result_0 = result_1; + } + return result_0; +} + +inline __device__ float dot_1(float3 x_1, float3 y_1) +{ + int i_1 = int(0); + float result_2 = 0.0f; + for(;;) + { + if(i_1 < int(3)) + { + } + else + { + break; + } + float result_3 = result_2 + _slang_vector_get_element(x_1, i_1) * _slang_vector_get_element(y_1, i_1); + i_1 = i_1 + int(1); + result_2 = result_3; + } + return result_2; +} + +inline __device__ float length_0(float2 x_2) +{ + return (F32_sqrt((dot_0(x_2, x_2)))); +} + +inline __device__ float length_1(float3 x_3) +{ + return (F32_sqrt((dot_1(x_3, x_3)))); +} + +inline __device__ float3 normalize_0(float3 x_4) +{ + return x_4 / make_float3 (length_1(x_4)); +} + +inline __device__ float3 cross_0(float3 left_0, float3 right_0) +{ + float _S1 = left_0.y; + float _S2 = right_0.z; + float _S3 = left_0.z; + float _S4 = right_0.y; + float _S5 = right_0.x; + float _S6 = left_0.x; + return make_float3 (_S1 * _S2 - _S3 * _S4, _S3 * _S5 - _S6 * _S2, _S6 * _S4 - _S1 * _S5); +} + +inline __device__ bool source_project(int model_id_0, FixedArray params_0, float3 ray_0, float2 * uv_0) +{ + float2 a_0; + bool _S7; + float dy_0; + float dx_0; + bool _S8; + bool _S9; + bool _S10; + bool _S11; + bool _S12; + bool _S13; + bool _S14; + for(;;) + { + bool _S15 = model_id_0 == int(1000); + _S8 = _S15; + if(_S15) + { + for(;;) + { + *uv_0 = make_float2 (0.0f); + int base_0 = int(params_0[int(13)]); + if(base_0 == int(0)) + { + float _S16 = ray_0.z; + if(_S16 < 9.999999960041972e-13f) + { + _S7 = false; + break; + } + a_0 = float2 {ray_0.x, ray_0.y} / make_float2 (_S16); + } + else + { + float2 _S17 = float2 {ray_0.x, ray_0.y}; + float r_0 = length_0(_S17); + float _S18 = ray_0.z; + float theta_0 = (F32_atan2((r_0), (_S18))); + if(base_0 == int(1)) + { + if(theta_0 < 0.00100000004749745f) + { + dx_0 = (1.0f - theta_0 * theta_0 / 3.0f) / _S18; + } + else + { + dx_0 = theta_0 / r_0; + } + } + else + { + if(r_0 < 9.99999997475242708e-07f) + { + dx_0 = (1.0f - theta_0 * theta_0 / 24.0f) / _S18; + } + else + { + dx_0 = 2.0f * (F32_sin((0.5f * theta_0))) / r_0; + } + } + a_0 = _S17 * make_float2 (dx_0); + } + float u_0 = a_0.x; + float v_0 = a_0.y; + float r2_0 = u_0 * u_0 + v_0 * v_0; + if((params_0[int(14)]) != 0.0f) + { + float radial_0 = (1.0f + r2_0 * (params_0[int(5)] + r2_0 * (params_0[int(6)] + r2_0 * params_0[int(7)]))) / (1.0f + r2_0 * (params_0[int(8)] + r2_0 * (params_0[int(9)] + r2_0 * params_0[int(10)]))); + float _S19 = v_0 * radial_0 + 2.0f * params_0[int(12)] * u_0 * v_0 + params_0[int(11)] * (r2_0 + 2.0f * v_0 * v_0); + dx_0 = u_0 * radial_0 + 2.0f * params_0[int(11)] * u_0 * v_0 + params_0[int(12)] * (r2_0 + 2.0f * u_0 * u_0); + dy_0 = _S19; + } + else + { + float radial_1 = 1.0f + r2_0 * (params_0[int(5)] + r2_0 * (params_0[int(6)] + r2_0 * (params_0[int(7)] + r2_0 * params_0[int(8)]))); + float _S20 = v_0 * radial_1 + 2.0f * params_0[int(10)] * u_0 * v_0 + params_0[int(9)] * (r2_0 + 2.0f * v_0 * v_0) + params_0[int(12)] * r2_0; + dx_0 = u_0 * radial_1 + 2.0f * params_0[int(9)] * u_0 * v_0 + params_0[int(10)] * (r2_0 + 2.0f * u_0 * u_0) + params_0[int(11)] * r2_0; + dy_0 = _S20; + } + *uv_0 = make_float2 (params_0[int(0)] * dx_0 + params_0[int(4)] * dy_0 + params_0[int(2)], params_0[int(1)] * dy_0 + params_0[int(3)]); + _S7 = true; + break; + } + break; + } + if(model_id_0 == int(7)) + { + for(;;) + { + *uv_0 = make_float2 (0.0f); + float _S21 = ray_0.z; + if(_S21 < 9.999999960041972e-13f) + { + _S7 = false; + break; + } + float x_5 = ray_0.x / _S21; + float y_2 = ray_0.y / _S21; + float r2_1 = x_5 * x_5 + y_2 * y_2; + float om2_0 = params_0[int(4)] * params_0[int(4)]; + if(om2_0 < 0.00009999999747379f) + { + dx_0 = om2_0 * r2_1 / 3.0f - om2_0 / 12.0f + 1.0f; + } + else + { + if(r2_1 < 0.00009999999747379f) + { + float t_0 = (F32_tan((params_0[int(4)] * 0.5f))); + dx_0 = -2.0f * t_0 * (4.0f * r2_1 * t_0 * t_0 - 3.0f) / (3.0f * params_0[int(4)]); + } + else + { + float r_1 = (F32_sqrt((r2_1))); + dx_0 = (F32_atan((r_1 * 2.0f * (F32_tan((params_0[int(4)] * 0.5f)))))) / (r_1 * params_0[int(4)]); + } + } + *uv_0 = make_float2 (params_0[int(0)] * x_5 * dx_0 + params_0[int(2)], params_0[int(1)] * y_2 * dx_0 + params_0[int(3)]); + _S7 = true; + break; + } + break; + } + if(model_id_0 == int(12)) + { + for(;;) + { + *uv_0 = make_float2 (0.0f); + float _S22 = ray_0.x; + float _S23 = ray_0.y; + float _S24 = ray_0.z; + float disc_0 = _S24 * _S24 - 4.0f * (_S22 * _S22 + _S23 * _S23) * params_0[int(3)]; + bool _S25 = disc_0 < 0.0f; + _S9 = _S25; + if(_S25) + { + break; + } + float _S26 = params_0[int(0)] * (2.0f / (_S24 + (F32_sqrt((disc_0))))); + *uv_0 = make_float2 (_S26 * _S22 + params_0[int(1)], _S26 * _S23 + params_0[int(2)]); + break; + } + _S7 = !_S9; + break; + } + if(model_id_0 == int(13)) + { + for(;;) + { + *uv_0 = make_float2 (0.0f); + float _S27 = ray_0.x; + float _S28 = ray_0.y; + float _S29 = ray_0.z; + float disc_1 = _S29 * _S29 - 4.0f * (_S27 * _S27 + _S28 * _S28) * params_0[int(4)]; + bool _S30 = disc_1 < 0.0f; + _S10 = _S30; + if(_S30) + { + break; + } + float r_2 = 2.0f / (_S29 + (F32_sqrt((disc_1)))); + *uv_0 = make_float2 (params_0[int(0)] * r_2 * _S27 + params_0[int(2)], params_0[int(1)] * r_2 * _S28 + params_0[int(3)]); + break; + } + _S7 = !_S10; + break; + } + if(model_id_0 == int(16)) + { + for(;;) + { + *uv_0 = make_float2 (0.0f); + float _S31 = ray_0.z; + if(_S31 < 9.999999960041972e-13f) + { + _S7 = false; + break; + } + float _S32 = ray_0.x; + float _S33 = ray_0.y; + float rho2_0 = params_0[int(5)] * (_S32 * _S32 + _S33 * _S33) + _S31 * _S31; + if(rho2_0 < 0.0f) + { + _S7 = false; + break; + } + float den_0 = params_0[int(4)] * (F32_sqrt((rho2_0))) + (1.0f - params_0[int(4)]) * _S31; + if(den_0 < 9.999999960041972e-13f) + { + _S7 = false; + break; + } + *uv_0 = make_float2 (params_0[int(0)] * _S32 / den_0 + params_0[int(2)], params_0[int(1)] * _S33 / den_0 + params_0[int(3)]); + _S7 = true; + break; + } + break; + } + if(model_id_0 == int(11)) + { + for(;;) + { + *uv_0 = make_float2 (0.0f); + float _S34 = ray_0.z; + if(_S34 < 9.999999960041972e-13f) + { + _S7 = false; + break; + } + float xn_0 = ray_0.x / _S34; + float yn_0 = ray_0.y / _S34; + float r_3 = (F32_sqrt((xn_0 * xn_0 + yn_0 * yn_0))); + if(r_3 > 9.999999960041972e-13f) + { + float th_0 = (F32_atan((r_3))); + float vv_0 = yn_0 * (th_0 / r_3); + dx_0 = xn_0 * (th_0 / r_3); + dy_0 = vv_0; + } + else + { + dx_0 = xn_0; + dy_0 = yn_0; + } + float _S35 = dx_0 * dx_0 + dy_0 * dy_0; + float pw_0 = _S35 * _S35; + float pw_1 = pw_0 * _S35; + float pw_2 = pw_1 * _S35; + float pw_3 = pw_2 * _S35; + float rad_0 = 1.0f + params_0[int(4)] * _S35 + params_0[int(5)] * pw_0 + params_0[int(6)] * pw_1 + params_0[int(7)] * pw_2 + params_0[int(8)] * pw_3 + params_0[int(9)] * (pw_3 * _S35); + float x_6 = rad_0 * dx_0; + float y_3 = rad_0 * dy_0; + float x2_0 = x_6 * x_6; + float y2_0 = y_3 * y_3; + float xy_0 = x_6 * y_3; + float r2_2 = x2_0 + y2_0; + float r4_0 = r2_2 * r2_2; + *uv_0 = make_float2 (params_0[int(0)] * (x_6 + 2.0f * params_0[int(11)] * xy_0 + params_0[int(10)] * (r2_2 + 2.0f * x2_0) + params_0[int(12)] * r2_2 + params_0[int(13)] * r4_0) + params_0[int(2)], params_0[int(1)] * (y_3 + 2.0f * params_0[int(10)] * xy_0 + params_0[int(11)] * (r2_2 + 2.0f * y2_0) + params_0[int(14)] * r2_2 + params_0[int(15)] * r4_0) + params_0[int(3)]); + _S7 = true; + break; + } + break; + } + *uv_0 = make_float2 (0.0f); + _S7 = false; + break; + } + if(!_S7) + { + return false; + } + float2 _S36 = *uv_0; + for(;;) + { + float3 n_0 = normalize_0(ray_0); + float3 t_1; + if((F32_abs((n_0.x))) < 0.89999997615814209f) + { + t_1 = make_float3 (1.0f, 0.0f, 0.0f); + } + else + { + t_1 = make_float3 (0.0f, 1.0f, 0.0f); + } + float3 e1_0 = normalize_0(cross_0(t_1, n_0)); + float3 e2_0 = cross_0(n_0, e1_0); + float3 _S37 = n_0 + make_float3 (0.00100000004749745f) * e1_0; + for(;;) + { + if(_S8) + { + for(;;) + { + float2 _S38 = make_float2 (0.0f); + int base_1 = int(params_0[int(13)]); + if(base_1 == int(0)) + { + float _S39 = _S37.z; + if(_S39 < 9.999999960041972e-13f) + { + _S7 = false; + a_0 = _S38; + break; + } + a_0 = float2 {_S37.x, _S37.y} / make_float2 (_S39); + } + else + { + float2 _S40 = float2 {_S37.x, _S37.y}; + float r_4 = length_0(_S40); + float _S41 = _S37.z; + float theta_1 = (F32_atan2((r_4), (_S41))); + if(base_1 == int(1)) + { + if(theta_1 < 0.00100000004749745f) + { + dx_0 = (1.0f - theta_1 * theta_1 / 3.0f) / _S41; + } + else + { + dx_0 = theta_1 / r_4; + } + } + else + { + if(r_4 < 9.99999997475242708e-07f) + { + dx_0 = (1.0f - theta_1 * theta_1 / 24.0f) / _S41; + } + else + { + dx_0 = 2.0f * (F32_sin((0.5f * theta_1))) / r_4; + } + } + a_0 = _S40 * make_float2 (dx_0); + } + float u_1 = a_0.x; + float v_1 = a_0.y; + float r2_3 = u_1 * u_1 + v_1 * v_1; + if((params_0[int(14)]) != 0.0f) + { + float radial_2 = (1.0f + r2_3 * (params_0[int(5)] + r2_3 * (params_0[int(6)] + r2_3 * params_0[int(7)]))) / (1.0f + r2_3 * (params_0[int(8)] + r2_3 * (params_0[int(9)] + r2_3 * params_0[int(10)]))); + float _S42 = v_1 * radial_2 + 2.0f * params_0[int(12)] * u_1 * v_1 + params_0[int(11)] * (r2_3 + 2.0f * v_1 * v_1); + dx_0 = u_1 * radial_2 + 2.0f * params_0[int(11)] * u_1 * v_1 + params_0[int(12)] * (r2_3 + 2.0f * u_1 * u_1); + dy_0 = _S42; + } + else + { + float radial_3 = 1.0f + r2_3 * (params_0[int(5)] + r2_3 * (params_0[int(6)] + r2_3 * (params_0[int(7)] + r2_3 * params_0[int(8)]))); + float _S43 = v_1 * radial_3 + 2.0f * params_0[int(10)] * u_1 * v_1 + params_0[int(9)] * (r2_3 + 2.0f * v_1 * v_1) + params_0[int(12)] * r2_3; + dx_0 = u_1 * radial_3 + 2.0f * params_0[int(9)] * u_1 * v_1 + params_0[int(10)] * (r2_3 + 2.0f * u_1 * u_1) + params_0[int(11)] * r2_3; + dy_0 = _S43; + } + float2 _S44 = make_float2 (params_0[int(0)] * dx_0 + params_0[int(4)] * dy_0 + params_0[int(2)], params_0[int(1)] * dy_0 + params_0[int(3)]); + _S7 = true; + a_0 = _S44; + break; + } + break; + } + if(model_id_0 == int(7)) + { + for(;;) + { + float2 _S45 = make_float2 (0.0f); + float _S46 = _S37.z; + if(_S46 < 9.999999960041972e-13f) + { + _S7 = false; + a_0 = _S45; + break; + } + float x_7 = _S37.x / _S46; + float y_4 = _S37.y / _S46; + float r2_4 = x_7 * x_7 + y_4 * y_4; + float om2_1 = params_0[int(4)] * params_0[int(4)]; + if(om2_1 < 0.00009999999747379f) + { + dx_0 = om2_1 * r2_4 / 3.0f - om2_1 / 12.0f + 1.0f; + } + else + { + if(r2_4 < 0.00009999999747379f) + { + float t_2 = (F32_tan((params_0[int(4)] * 0.5f))); + dx_0 = -2.0f * t_2 * (4.0f * r2_4 * t_2 * t_2 - 3.0f) / (3.0f * params_0[int(4)]); + } + else + { + float r_5 = (F32_sqrt((r2_4))); + dx_0 = (F32_atan((r_5 * 2.0f * (F32_tan((params_0[int(4)] * 0.5f)))))) / (r_5 * params_0[int(4)]); + } + } + float2 _S47 = make_float2 (params_0[int(0)] * x_7 * dx_0 + params_0[int(2)], params_0[int(1)] * y_4 * dx_0 + params_0[int(3)]); + _S7 = true; + a_0 = _S47; + break; + } + break; + } + if(model_id_0 == int(12)) + { + for(;;) + { + float2 _S48 = make_float2 (0.0f); + float _S49 = _S37.x; + float _S50 = _S37.y; + float _S51 = _S37.z; + float disc_2 = _S51 * _S51 - 4.0f * (_S49 * _S49 + _S50 * _S50) * params_0[int(3)]; + bool _S52 = disc_2 < 0.0f; + _S11 = _S52; + if(_S52) + { + a_0 = _S48; + break; + } + float _S53 = params_0[int(0)] * (2.0f / (_S51 + (F32_sqrt((disc_2))))); + a_0 = make_float2 (_S53 * _S49 + params_0[int(1)], _S53 * _S50 + params_0[int(2)]); + break; + } + _S7 = !_S11; + break; + } + if(model_id_0 == int(13)) + { + for(;;) + { + float2 _S54 = make_float2 (0.0f); + float _S55 = _S37.x; + float _S56 = _S37.y; + float _S57 = _S37.z; + float disc_3 = _S57 * _S57 - 4.0f * (_S55 * _S55 + _S56 * _S56) * params_0[int(4)]; + bool _S58 = disc_3 < 0.0f; + _S12 = _S58; + if(_S58) + { + a_0 = _S54; + break; + } + float r_6 = 2.0f / (_S57 + (F32_sqrt((disc_3)))); + a_0 = make_float2 (params_0[int(0)] * r_6 * _S55 + params_0[int(2)], params_0[int(1)] * r_6 * _S56 + params_0[int(3)]); + break; + } + _S7 = !_S12; + break; + } + if(model_id_0 == int(16)) + { + for(;;) + { + float2 _S59 = make_float2 (0.0f); + float _S60 = _S37.z; + if(_S60 < 9.999999960041972e-13f) + { + _S7 = false; + a_0 = _S59; + break; + } + float _S61 = _S37.x; + float _S62 = _S37.y; + float rho2_1 = params_0[int(5)] * (_S61 * _S61 + _S62 * _S62) + _S60 * _S60; + if(rho2_1 < 0.0f) + { + _S7 = false; + a_0 = _S59; + break; + } + float den_1 = params_0[int(4)] * (F32_sqrt((rho2_1))) + (1.0f - params_0[int(4)]) * _S60; + if(den_1 < 9.999999960041972e-13f) + { + _S7 = false; + a_0 = _S59; + break; + } + float2 _S63 = make_float2 (params_0[int(0)] * _S61 / den_1 + params_0[int(2)], params_0[int(1)] * _S62 / den_1 + params_0[int(3)]); + _S7 = true; + a_0 = _S63; + break; + } + break; + } + if(model_id_0 == int(11)) + { + for(;;) + { + float2 _S64 = make_float2 (0.0f); + float _S65 = _S37.z; + if(_S65 < 9.999999960041972e-13f) + { + _S7 = false; + a_0 = _S64; + break; + } + float xn_1 = _S37.x / _S65; + float yn_1 = _S37.y / _S65; + float r_7 = (F32_sqrt((xn_1 * xn_1 + yn_1 * yn_1))); + if(r_7 > 9.999999960041972e-13f) + { + float th_1 = (F32_atan((r_7))); + float vv_1 = yn_1 * (th_1 / r_7); + dx_0 = xn_1 * (th_1 / r_7); + dy_0 = vv_1; + } + else + { + dx_0 = xn_1; + dy_0 = yn_1; + } + float _S66 = dx_0 * dx_0 + dy_0 * dy_0; + float pw_4 = _S66 * _S66; + float pw_5 = pw_4 * _S66; + float pw_6 = pw_5 * _S66; + float pw_7 = pw_6 * _S66; + float rad_1 = 1.0f + params_0[int(4)] * _S66 + params_0[int(5)] * pw_4 + params_0[int(6)] * pw_5 + params_0[int(7)] * pw_6 + params_0[int(8)] * pw_7 + params_0[int(9)] * (pw_7 * _S66); + float x_8 = rad_1 * dx_0; + float y_5 = rad_1 * dy_0; + float x2_1 = x_8 * x_8; + float y2_1 = y_5 * y_5; + float xy_1 = x_8 * y_5; + float r2_5 = x2_1 + y2_1; + float r4_1 = r2_5 * r2_5; + float2 _S67 = make_float2 (params_0[int(0)] * (x_8 + 2.0f * params_0[int(11)] * xy_1 + params_0[int(10)] * (r2_5 + 2.0f * x2_1) + params_0[int(12)] * r2_5 + params_0[int(13)] * r4_1) + params_0[int(2)], params_0[int(1)] * (y_5 + 2.0f * params_0[int(10)] * xy_1 + params_0[int(11)] * (r2_5 + 2.0f * y2_1) + params_0[int(14)] * r2_5 + params_0[int(15)] * r4_1) + params_0[int(3)]); + _S7 = true; + a_0 = _S67; + break; + } + break; + } + float2 _S68 = make_float2 (0.0f); + _S7 = false; + a_0 = _S68; + break; + } + if(!_S7) + { + _S7 = false; + break; + } + float2 b_0; + float3 _S69 = n_0 + make_float3 (0.00100000004749745f) * e2_0; + for(;;) + { + if(_S8) + { + for(;;) + { + float2 _S70 = make_float2 (0.0f); + int base_2 = int(params_0[int(13)]); + if(base_2 == int(0)) + { + float _S71 = _S69.z; + if(_S71 < 9.999999960041972e-13f) + { + _S7 = false; + b_0 = _S70; + break; + } + b_0 = float2 {_S69.x, _S69.y} / make_float2 (_S71); + } + else + { + float2 _S72 = float2 {_S69.x, _S69.y}; + float r_8 = length_0(_S72); + float _S73 = _S69.z; + float theta_2 = (F32_atan2((r_8), (_S73))); + if(base_2 == int(1)) + { + if(theta_2 < 0.00100000004749745f) + { + dx_0 = (1.0f - theta_2 * theta_2 / 3.0f) / _S73; + } + else + { + dx_0 = theta_2 / r_8; + } + } + else + { + if(r_8 < 9.99999997475242708e-07f) + { + dx_0 = (1.0f - theta_2 * theta_2 / 24.0f) / _S73; + } + else + { + dx_0 = 2.0f * (F32_sin((0.5f * theta_2))) / r_8; + } + } + b_0 = _S72 * make_float2 (dx_0); + } + float u_2 = b_0.x; + float v_2 = b_0.y; + float r2_6 = u_2 * u_2 + v_2 * v_2; + if((params_0[int(14)]) != 0.0f) + { + float radial_4 = (1.0f + r2_6 * (params_0[int(5)] + r2_6 * (params_0[int(6)] + r2_6 * params_0[int(7)]))) / (1.0f + r2_6 * (params_0[int(8)] + r2_6 * (params_0[int(9)] + r2_6 * params_0[int(10)]))); + float _S74 = v_2 * radial_4 + 2.0f * params_0[int(12)] * u_2 * v_2 + params_0[int(11)] * (r2_6 + 2.0f * v_2 * v_2); + dx_0 = u_2 * radial_4 + 2.0f * params_0[int(11)] * u_2 * v_2 + params_0[int(12)] * (r2_6 + 2.0f * u_2 * u_2); + dy_0 = _S74; + } + else + { + float radial_5 = 1.0f + r2_6 * (params_0[int(5)] + r2_6 * (params_0[int(6)] + r2_6 * (params_0[int(7)] + r2_6 * params_0[int(8)]))); + float _S75 = v_2 * radial_5 + 2.0f * params_0[int(10)] * u_2 * v_2 + params_0[int(9)] * (r2_6 + 2.0f * v_2 * v_2) + params_0[int(12)] * r2_6; + dx_0 = u_2 * radial_5 + 2.0f * params_0[int(9)] * u_2 * v_2 + params_0[int(10)] * (r2_6 + 2.0f * u_2 * u_2) + params_0[int(11)] * r2_6; + dy_0 = _S75; + } + float2 _S76 = make_float2 (params_0[int(0)] * dx_0 + params_0[int(4)] * dy_0 + params_0[int(2)], params_0[int(1)] * dy_0 + params_0[int(3)]); + _S7 = true; + b_0 = _S76; + break; + } + break; + } + if(model_id_0 == int(7)) + { + for(;;) + { + float2 _S77 = make_float2 (0.0f); + float _S78 = _S69.z; + if(_S78 < 9.999999960041972e-13f) + { + _S7 = false; + b_0 = _S77; + break; + } + float x_9 = _S69.x / _S78; + float y_6 = _S69.y / _S78; + float r2_7 = x_9 * x_9 + y_6 * y_6; + float om2_2 = params_0[int(4)] * params_0[int(4)]; + if(om2_2 < 0.00009999999747379f) + { + dx_0 = om2_2 * r2_7 / 3.0f - om2_2 / 12.0f + 1.0f; + } + else + { + if(r2_7 < 0.00009999999747379f) + { + float t_3 = (F32_tan((params_0[int(4)] * 0.5f))); + dx_0 = -2.0f * t_3 * (4.0f * r2_7 * t_3 * t_3 - 3.0f) / (3.0f * params_0[int(4)]); + } + else + { + float r_9 = (F32_sqrt((r2_7))); + dx_0 = (F32_atan((r_9 * 2.0f * (F32_tan((params_0[int(4)] * 0.5f)))))) / (r_9 * params_0[int(4)]); + } + } + float2 _S79 = make_float2 (params_0[int(0)] * x_9 * dx_0 + params_0[int(2)], params_0[int(1)] * y_6 * dx_0 + params_0[int(3)]); + _S7 = true; + b_0 = _S79; + break; + } + break; + } + if(model_id_0 == int(12)) + { + for(;;) + { + float2 _S80 = make_float2 (0.0f); + float _S81 = _S69.x; + float _S82 = _S69.y; + float _S83 = _S69.z; + float disc_4 = _S83 * _S83 - 4.0f * (_S81 * _S81 + _S82 * _S82) * params_0[int(3)]; + bool _S84 = disc_4 < 0.0f; + _S13 = _S84; + if(_S84) + { + b_0 = _S80; + break; + } + float _S85 = params_0[int(0)] * (2.0f / (_S83 + (F32_sqrt((disc_4))))); + b_0 = make_float2 (_S85 * _S81 + params_0[int(1)], _S85 * _S82 + params_0[int(2)]); + break; + } + _S7 = !_S13; + break; + } + if(model_id_0 == int(13)) + { + for(;;) + { + float2 _S86 = make_float2 (0.0f); + float _S87 = _S69.x; + float _S88 = _S69.y; + float _S89 = _S69.z; + float disc_5 = _S89 * _S89 - 4.0f * (_S87 * _S87 + _S88 * _S88) * params_0[int(4)]; + bool _S90 = disc_5 < 0.0f; + _S14 = _S90; + if(_S90) + { + b_0 = _S86; + break; + } + float r_10 = 2.0f / (_S89 + (F32_sqrt((disc_5)))); + b_0 = make_float2 (params_0[int(0)] * r_10 * _S87 + params_0[int(2)], params_0[int(1)] * r_10 * _S88 + params_0[int(3)]); + break; + } + _S7 = !_S14; + break; + } + if(model_id_0 == int(16)) + { + for(;;) + { + float2 _S91 = make_float2 (0.0f); + float _S92 = _S69.z; + if(_S92 < 9.999999960041972e-13f) + { + _S7 = false; + b_0 = _S91; + break; + } + float _S93 = _S69.x; + float _S94 = _S69.y; + float rho2_2 = params_0[int(5)] * (_S93 * _S93 + _S94 * _S94) + _S92 * _S92; + if(rho2_2 < 0.0f) + { + _S7 = false; + b_0 = _S91; + break; + } + float den_2 = params_0[int(4)] * (F32_sqrt((rho2_2))) + (1.0f - params_0[int(4)]) * _S92; + if(den_2 < 9.999999960041972e-13f) + { + _S7 = false; + b_0 = _S91; + break; + } + float2 _S95 = make_float2 (params_0[int(0)] * _S93 / den_2 + params_0[int(2)], params_0[int(1)] * _S94 / den_2 + params_0[int(3)]); + _S7 = true; + b_0 = _S95; + break; + } + break; + } + if(model_id_0 == int(11)) + { + for(;;) + { + float2 _S96 = make_float2 (0.0f); + float _S97 = _S69.z; + if(_S97 < 9.999999960041972e-13f) + { + _S7 = false; + b_0 = _S96; + break; + } + float xn_2 = _S69.x / _S97; + float yn_2 = _S69.y / _S97; + float r_11 = (F32_sqrt((xn_2 * xn_2 + yn_2 * yn_2))); + if(r_11 > 9.999999960041972e-13f) + { + float th_2 = (F32_atan((r_11))); + float vv_2 = yn_2 * (th_2 / r_11); + dx_0 = xn_2 * (th_2 / r_11); + dy_0 = vv_2; + } + else + { + dx_0 = xn_2; + dy_0 = yn_2; + } + float _S98 = dx_0 * dx_0 + dy_0 * dy_0; + float pw_8 = _S98 * _S98; + float pw_9 = pw_8 * _S98; + float pw_10 = pw_9 * _S98; + float pw_11 = pw_10 * _S98; + float rad_2 = 1.0f + params_0[int(4)] * _S98 + params_0[int(5)] * pw_8 + params_0[int(6)] * pw_9 + params_0[int(7)] * pw_10 + params_0[int(8)] * pw_11 + params_0[int(9)] * (pw_11 * _S98); + float x_10 = rad_2 * dx_0; + float y_7 = rad_2 * dy_0; + float x2_2 = x_10 * x_10; + float y2_2 = y_7 * y_7; + float xy_2 = x_10 * y_7; + float r2_8 = x2_2 + y2_2; + float r4_2 = r2_8 * r2_8; + float2 _S99 = make_float2 (params_0[int(0)] * (x_10 + 2.0f * params_0[int(11)] * xy_2 + params_0[int(10)] * (r2_8 + 2.0f * x2_2) + params_0[int(12)] * r2_8 + params_0[int(13)] * r4_2) + params_0[int(2)], params_0[int(1)] * (y_7 + 2.0f * params_0[int(10)] * xy_2 + params_0[int(11)] * (r2_8 + 2.0f * y2_2) + params_0[int(14)] * r2_8 + params_0[int(15)] * r4_2) + params_0[int(3)]); + _S7 = true; + b_0 = _S99; + break; + } + break; + } + float2 _S100 = make_float2 (0.0f); + _S7 = false; + b_0 = _S100; + break; + } + if(!_S7) + { + _S7 = false; + break; + } + float2 j1_0 = a_0 - _S36; + float2 j2_0 = b_0 - _S36; + _S7 = (j1_0.x * j2_0.y - j1_0.y * j2_0.x) > 0.0f; + break; + } + return _S7; +} + diff --git a/src/generated/pixel_wise.cuh b/src/generated/pixel_wise.cuh index 0580673a..de262f26 100644 --- a/src/generated/pixel_wise.cuh +++ b/src/generated/pixel_wise.cuh @@ -249,7 +249,7 @@ inline __device__ float3 clamp_0(float3 x_2, float3 minBound_0, float3 maxBo inline __device__ float3 blend_background(float3 rgb_0, float transmittance_2, float3 background_0) { - return clamp_0(rgb_0 + make_float3 (transmittance_2) * background_0, make_float3 (0.0f), make_float3 (1.0f)); + return clamp_0(rgb_0 + make_float3 (transmittance_2, transmittance_2, transmittance_2) * background_0, make_float3 (0.0f), make_float3 (1.0f)); } inline __device__ void s_bwd_prop_clamp_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S20, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S21, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S22, float3 _S23) @@ -260,12 +260,12 @@ inline __device__ void s_bwd_prop_clamp_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S2 inline __device__ void s_bwd_prop_blend_background_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dprgb_0, DiffPair_float_0 * dptransmittance_1, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpbackground_0, float3 _s_dOut_1) { - float3 _S24 = make_float3 ((*dptransmittance_1).primal_0); + float3 _S24 = make_float3 ((*dptransmittance_1).primal_0, (*dptransmittance_1).primal_0, (*dptransmittance_1).primal_0); float3 _S25 = make_float3 (0.0f); float3 _S26 = make_float3 (1.0f); float3 _S27 = make_float3 (0.0f); DiffPair_vectorx3Cfloatx2C3x3E_0 _S28; - (&_S28)->primal_0 = (*dprgb_0).primal_0 + make_float3 ((*dptransmittance_1).primal_0) * (*dpbackground_0).primal_0; + (&_S28)->primal_0 = (*dprgb_0).primal_0 + _S24 * (*dpbackground_0).primal_0; (&_S28)->differential_0 = _S27; DiffPair_vectorx3Cfloatx2C3x3E_0 _S29; (&_S29)->primal_0 = _S25; @@ -890,9 +890,488 @@ inline __device__ float3 rgb_to_srgb_bwd(float3 rgb_5, Matrix co return p_rgb_2.differential_0; } -inline __device__ Matrix transpose_0(Matrix x_7) +inline __device__ void _d_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_5, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpy_4, float dOut_5) { - Matrix result_3; + float3 x_d_result_0; + *&((&x_d_result_0)->x) = (*dpy_4).primal_0.x * dOut_5; + float3 y_d_result_0; + *&((&y_d_result_0)->x) = (*dpx_5).primal_0.x * dOut_5; + *&((&x_d_result_0)->y) = (*dpy_4).primal_0.y * dOut_5; + *&((&y_d_result_0)->y) = (*dpx_5).primal_0.y * dOut_5; + *&((&x_d_result_0)->z) = (*dpy_4).primal_0.z * dOut_5; + *&((&y_d_result_0)->z) = (*dpx_5).primal_0.z * dOut_5; + dpx_5->primal_0 = (*dpx_5).primal_0; + dpx_5->differential_0 = x_d_result_0; + dpy_4->primal_0 = (*dpy_4).primal_0; + dpy_4->differential_0 = y_d_result_0; + return; +} + +inline __device__ float dot_0(float3 x_7, float3 y_2) +{ + int i_3 = int(0); + float result_3 = 0.0f; + for(;;) + { + if(i_3 < int(3)) + { + } + else + { + break; + } + float result_4 = result_3 + _slang_vector_get_element(x_7, i_3) * _slang_vector_get_element(y_2, i_3); + i_3 = i_3 + int(1); + result_3 = result_4; + } + return result_3; +} + +inline __device__ float dot_1(float2 x_8, float2 y_3) +{ + int i_4 = int(0); + float result_5 = 0.0f; + for(;;) + { + if(i_4 < int(2)) + { + } + else + { + break; + } + float result_6 = result_5 + _slang_vector_get_element(x_8, i_4) * _slang_vector_get_element(y_3, i_4); + i_4 = i_4 + int(1); + result_5 = result_6; + } + return result_5; +} + +inline __device__ void _d_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * a_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * b_0, float3 dOut_6) +{ + float _S152 = dOut_6.y; + float _S153 = dOut_6.z; + float _S154 = dOut_6.x; + float _S155 = (*a_0).primal_0.z * _S152 + - (*a_0).primal_0.y * _S153; + float _S156 = - (*a_0).primal_0.z * _S154 + (*a_0).primal_0.x * _S153; + float _S157 = (*a_0).primal_0.y * _S154 + - (*a_0).primal_0.x * _S152; + float3 _S158 = make_float3 (- (*b_0).primal_0.z * _S152 + (*b_0).primal_0.y * _S153, (*b_0).primal_0.z * _S154 + - (*b_0).primal_0.x * _S153, - (*b_0).primal_0.y * _S154 + (*b_0).primal_0.x * _S152); + a_0->primal_0 = (*a_0).primal_0; + a_0->differential_0 = _S158; + float3 _S159 = make_float3 (_S155, _S156, _S157); + b_0->primal_0 = (*b_0).primal_0; + b_0->differential_0 = _S159; + return; +} + +inline __device__ float3 cross_0(float3 left_2, float3 right_2) +{ + float _S160 = left_2.y; + float _S161 = right_2.z; + float _S162 = left_2.z; + float _S163 = right_2.y; + float _S164 = right_2.x; + float _S165 = left_2.x; + return make_float3 (_S160 * _S161 - _S162 * _S163, _S162 * _S164 - _S165 * _S161, _S165 * _S163 - _S160 * _S164); +} + +inline __device__ void _d_sqrt_0(DiffPair_float_0 * dpx_6, float dOut_7) +{ + float _S166 = 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), ((*dpx_6).primal_0)))))) * dOut_7; + dpx_6->primal_0 = (*dpx_6).primal_0; + dpx_6->differential_0 = _S166; + return; +} + +inline __device__ float length_0(float3 x_9) +{ + return (F32_sqrt((dot_0(x_9, x_9)))); +} + +inline __device__ float length_1(float2 x_10) +{ + return (F32_sqrt((dot_1(x_10, x_10)))); +} + +inline __device__ float3 points_to_normal(FixedArray points_0) +{ + float3 _S167 = points_0[int(0)]; + bool _S168; + if((dot_0(_S167, _S167)) == 0.0f) + { + _S168 = true; + } + else + { + float3 _S169 = points_0[int(1)]; + _S168 = (dot_0(_S169, _S169)) == 0.0f; + } + if(_S168) + { + _S168 = true; + } + else + { + float3 _S170 = points_0[int(2)]; + _S168 = (dot_0(_S170, _S170)) == 0.0f; + } + if(_S168) + { + _S168 = true; + } + else + { + float3 _S171 = points_0[int(3)]; + _S168 = (dot_0(_S171, _S171)) == 0.0f; + } + if(_S168) + { + return make_float3 (0.0f); + } + float3 normal_0 = cross_0(points_0[int(1)] - points_0[int(0)], - (points_0[int(3)] - points_0[int(2)])); + float3 normal_1; + if((dot_0(normal_0, normal_0)) != 0.0f) + { + normal_1 = normal_0 / make_float3 (length_0(normal_0)); + } + else + { + normal_1 = normal_0; + } + return normal_1; +} + +struct DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 +{ + FixedArray primal_0; + FixedArray differential_0; +}; + +inline __device__ float s_primal_ctx_dot_0(float3 _S172, float3 _S173) +{ + return dot_0(_S172, _S173); +} + +inline __device__ float3 s_primal_ctx_cross_0(float3 _S174, float3 _S175) +{ + return cross_0(_S174, _S175); +} + +inline __device__ void s_bwd_prop_sqrt_0(DiffPair_float_0 * _S176, float _S177) +{ + _d_sqrt_0(_S176, _S177); + return; +} + +inline __device__ void s_bwd_prop_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_7, float _s_dOut_4) +{ + float _S178 = (*dpx_7).primal_0.x; + float _S179 = (*dpx_7).primal_0.y; + float _S180 = (*dpx_7).primal_0.z; + DiffPair_float_0 _S181; + (&_S181)->primal_0 = _S178 * _S178 + _S179 * _S179 + _S180 * _S180; + (&_S181)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S181, _s_dOut_4); + float _S182 = (*dpx_7).primal_0.z * _S181.differential_0; + float _S183 = _S182 + _S182; + float _S184 = (*dpx_7).primal_0.y * _S181.differential_0; + float _S185 = _S184 + _S184; + float _S186 = (*dpx_7).primal_0.x * _S181.differential_0; + float _S187 = _S186 + _S186; + float3 _S188 = make_float3 (0.0f); + *&((&_S188)->z) = _S183; + *&((&_S188)->y) = _S185; + *&((&_S188)->x) = _S187; + dpx_7->primal_0 = (*dpx_7).primal_0; + dpx_7->differential_0 = _S188; + return; +} + +inline __device__ void s_bwd_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S189, float _S190) +{ + s_bwd_prop_length_impl_0(_S189, _S190); + return; +} + +inline __device__ void s_bwd_prop_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S191, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S192, float _S193) +{ + _d_dot_0(_S191, _S192, _S193); + return; +} + +inline __device__ void s_bwd_prop_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S194, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S195, float3 _S196) +{ + _d_cross_0(_S194, _S195, _S196); + return; +} + +inline __device__ void s_bwd_prop_points_to_normal_0(DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 * dppoints_0, float3 _s_dOut_5) +{ + FixedArray _S197 = dppoints_0->primal_0; + float3 _S198 = make_float3 (0.0f); + float3 _S199 = dppoints_0->primal_0[int(0)]; + bool _S200 = (s_primal_ctx_dot_0(_S199, _S199)) == 0.0f; + bool _S201; + float3 _S202; + if(_S200) + { + _S201 = true; + _S202 = _S198; + } + else + { + float3 _S203 = _S197[int(1)]; + _S201 = (s_primal_ctx_dot_0(_S203, _S203)) == 0.0f; + _S202 = _S197[int(1)]; + } + bool _S204; + float3 _S205; + if(_S201) + { + _S204 = true; + _S205 = _S198; + } + else + { + float3 _S206 = _S197[int(2)]; + _S204 = (s_primal_ctx_dot_0(_S206, _S206)) == 0.0f; + _S205 = _S197[int(2)]; + } + bool _S207; + float3 _S208; + if(_S204) + { + _S207 = true; + _S208 = _S198; + } + else + { + float3 _S209 = _S197[int(3)]; + _S207 = (s_primal_ctx_dot_0(_S209, _S209)) == 0.0f; + _S208 = _S197[int(3)]; + } + bool _S210 = !_S207; + float3 _S211; + float3 _S212; + float3 _S213; + float3 _S214; + float3 _S215; + if(_S210) + { + float3 dx_0 = _S197[int(1)] - _S197[int(0)]; + float3 _S216 = - (_S197[int(3)] - _S197[int(2)]); + float3 _S217 = s_primal_ctx_cross_0(dx_0, _S216); + bool _S218 = (s_primal_ctx_dot_0(_S217, _S217)) != 0.0f; + if(_S218) + { + float _S219 = length_0(_S217); + float3 _S220 = make_float3 (_S219); + _S211 = make_float3 (_S219 * _S219); + _S212 = _S220; + } + else + { + _S211 = _S198; + _S212 = _S198; + } + float3 _S221 = _S212; + _S207 = _S218; + _S212 = _S217; + _S213 = _S221; + _S214 = dx_0; + _S215 = _S216; + } + else + { + _S207 = false; + _S211 = _S198; + _S212 = _S198; + _S213 = _S198; + _S214 = _S198; + _S215 = _S198; + } + FixedArray _S222; + if(_S210) + { + if(_S207) + { + float3 _S223 = _s_dOut_5 / _S211; + float3 _S224 = _S212 * - _S223; + float3 _S225 = _S213 * _S223; + float _S226 = _S224.x + _S224.y + _S224.z; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S227; + (&_S227)->primal_0 = _S212; + (&_S227)->differential_0 = _S198; + s_bwd_length_impl_0(&_S227, _S226); + _S211 = _S225 + _S227.differential_0; + } + else + { + _S211 = _s_dOut_5; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S228; + (&_S228)->primal_0 = _S212; + (&_S228)->differential_0 = _S198; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S229; + (&_S229)->primal_0 = _S212; + (&_S229)->differential_0 = _S198; + s_bwd_prop_dot_0(&_S228, &_S229, 0.0f); + float3 _S230 = _S229.differential_0 + _S228.differential_0 + _S211; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S231; + (&_S231)->primal_0 = _S214; + (&_S231)->differential_0 = _S198; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S232; + (&_S232)->primal_0 = _S215; + (&_S232)->differential_0 = _S198; + s_bwd_prop_cross_0(&_S231, &_S232, _S230); + float3 s_diff_dy_T_0 = - _S232.differential_0; + float3 _S233 = - s_diff_dy_T_0; + float3 _S234 = - _S231.differential_0; + FixedArray _S235; + _S235[int(0)] = _S198; + _S235[int(1)] = _S198; + _S235[int(2)] = _S198; + _S235[int(3)] = _S198; + _S235[int(2)] = _S233; + _S235[int(3)] = s_diff_dy_T_0; + _S235[int(1)] = _S231.differential_0; + _S222[int(0)] = _S235[int(0)]; + _S222[int(1)] = _S235[int(1)]; + _S222[int(2)] = _S235[int(2)]; + _S222[int(3)] = _S235[int(3)]; + _S211 = _S234; + } + else + { + _S222[int(0)] = _S198; + _S222[int(1)] = _S198; + _S222[int(2)] = _S198; + _S222[int(3)] = _S198; + _S211 = _S198; + } + if(_S204) + { + } + else + { + DiffPair_vectorx3Cfloatx2C3x3E_0 _S236; + (&_S236)->primal_0 = _S208; + (&_S236)->differential_0 = _S198; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S237; + (&_S237)->primal_0 = _S208; + (&_S237)->differential_0 = _S198; + s_bwd_prop_dot_0(&_S236, &_S237, 0.0f); + float3 _S238 = _S237.differential_0 + _S236.differential_0; + FixedArray _S239; + _S239[int(0)] = _S198; + _S239[int(1)] = _S198; + _S239[int(2)] = _S198; + _S239[int(3)] = _S198; + _S239[int(3)] = _S238; + float3 _S240 = _S222[int(1)] + _S239[int(1)]; + float3 _S241 = _S222[int(2)] + _S239[int(2)]; + float3 _S242 = _S222[int(3)] + _S239[int(3)]; + _S222[int(0)] = _S222[int(0)] + _S239[int(0)]; + _S222[int(1)] = _S240; + _S222[int(2)] = _S241; + _S222[int(3)] = _S242; + } + if(_S201) + { + } + else + { + DiffPair_vectorx3Cfloatx2C3x3E_0 _S243; + (&_S243)->primal_0 = _S205; + (&_S243)->differential_0 = _S198; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S244; + (&_S244)->primal_0 = _S205; + (&_S244)->differential_0 = _S198; + s_bwd_prop_dot_0(&_S243, &_S244, 0.0f); + float3 _S245 = _S244.differential_0 + _S243.differential_0; + FixedArray _S246; + _S246[int(0)] = _S198; + _S246[int(1)] = _S198; + _S246[int(2)] = _S198; + _S246[int(3)] = _S198; + _S246[int(2)] = _S245; + float3 _S247 = _S222[int(1)] + _S246[int(1)]; + float3 _S248 = _S222[int(2)] + _S246[int(2)]; + float3 _S249 = _S222[int(3)] + _S246[int(3)]; + _S222[int(0)] = _S222[int(0)] + _S246[int(0)]; + _S222[int(1)] = _S247; + _S222[int(2)] = _S248; + _S222[int(3)] = _S249; + } + if(_S200) + { + } + else + { + DiffPair_vectorx3Cfloatx2C3x3E_0 _S250; + (&_S250)->primal_0 = _S202; + (&_S250)->differential_0 = _S198; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S251; + (&_S251)->primal_0 = _S202; + (&_S251)->differential_0 = _S198; + s_bwd_prop_dot_0(&_S250, &_S251, 0.0f); + float3 _S252 = _S251.differential_0 + _S250.differential_0; + FixedArray _S253; + _S253[int(0)] = _S198; + _S253[int(1)] = _S198; + _S253[int(2)] = _S198; + _S253[int(3)] = _S198; + _S253[int(1)] = _S252; + float3 _S254 = _S222[int(1)] + _S253[int(1)]; + float3 _S255 = _S222[int(2)] + _S253[int(2)]; + float3 _S256 = _S222[int(3)] + _S253[int(3)]; + _S222[int(0)] = _S222[int(0)] + _S253[int(0)]; + _S222[int(1)] = _S254; + _S222[int(2)] = _S255; + _S222[int(3)] = _S256; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S257; + (&_S257)->primal_0 = _S197[int(0)]; + (&_S257)->differential_0 = _S198; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S258; + (&_S258)->primal_0 = _S197[int(0)]; + (&_S258)->differential_0 = _S198; + s_bwd_prop_dot_0(&_S257, &_S258, 0.0f); + float3 _S259 = _S258.differential_0 + _S257.differential_0 + _S211; + FixedArray _S260; + _S260[int(0)] = _S198; + _S260[int(1)] = _S198; + _S260[int(2)] = _S198; + _S260[int(3)] = _S198; + _S260[int(0)] = _S259; + FixedArray _S261 = { + _S222[int(0)] + _S260[int(0)], _S222[int(1)] + _S260[int(1)], _S222[int(2)] + _S260[int(2)], _S222[int(3)] + _S260[int(3)] + }; + dppoints_0->primal_0 = dppoints_0->primal_0; + dppoints_0->differential_0 = _S261; + return; +} + +inline __device__ void s_bwd_points_to_normal_0(DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 * _S262, float3 _S263) +{ + s_bwd_prop_points_to_normal_0(_S262, _S263); + return; +} + +inline __device__ void points_to_normal_vjp(FixedArray points_1, float3 v_normal_0, FixedArray * v_points_0) +{ + FixedArray _S264 = { make_float3 (0.0f), make_float3 (0.0f), make_float3 (0.0f), make_float3 (0.0f) }; + DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 dp_points_0; + (&dp_points_0)->primal_0 = points_1; + (&dp_points_0)->differential_0 = _S264; + s_bwd_points_to_normal_0(&dp_points_0, v_normal_0); + *v_points_0 = (&dp_points_0)->differential_0; + return; +} + +inline __device__ Matrix transpose_0(Matrix x_11) +{ + Matrix result_7; int r_0 = int(0); for(;;) { @@ -913,12 +1392,12 @@ inline __device__ Matrix transpose_0(Matrix x_7) { break; } - *_slang_vector_get_element_ptr(((&result_3)->rows + (r_0)), c_0) = _slang_vector_get_element(x_7.rows[c_0], r_0); + *_slang_vector_get_element_ptr(((&result_7)->rows + (r_0)), c_0) = _slang_vector_get_element(x_11.rows[c_0], r_0); c_0 = c_0 + int(1); } r_0 = r_0 + int(1); } - return result_3; + return result_7; } inline __device__ float determinant_0(Matrix m_0) @@ -926,206 +1405,372 @@ inline __device__ float determinant_0(Matrix m_0) return m_0.rows[int(0)].x * m_0.rows[int(1)].y - m_0.rows[int(0)].y * m_0.rows[int(1)].x; } -inline __device__ void _d_sqrt_0(DiffPair_float_0 * dpx_5, float dOut_5) +inline __device__ bool undistort_point_0(float2 uv_0, FixedArray * dist_coeffs_0, int maxiter_0, float2 * uv_undist_0) { - float _S152 = 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), ((*dpx_5).primal_0)))))) * dOut_5; - dpx_5->primal_0 = (*dpx_5).primal_0; - dpx_5->differential_0 = _S152; - return; + *uv_undist_0 = uv_0; + return true; } -inline __device__ void _d_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_6, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpy_4, float dOut_6) +inline __device__ float2 DistOpenCV_distort_0(float2 uv_1, FixedArray * coeffs_0) { - float3 x_d_result_0; - *&((&x_d_result_0)->x) = (*dpy_4).primal_0.x * dOut_6; - float3 y_d_result_0; - *&((&y_d_result_0)->x) = (*dpx_6).primal_0.x * dOut_6; - *&((&x_d_result_0)->y) = (*dpy_4).primal_0.y * dOut_6; - *&((&y_d_result_0)->y) = (*dpx_6).primal_0.y * dOut_6; - *&((&x_d_result_0)->z) = (*dpy_4).primal_0.z * dOut_6; - *&((&y_d_result_0)->z) = (*dpx_6).primal_0.z * dOut_6; - dpx_6->primal_0 = (*dpx_6).primal_0; - dpx_6->differential_0 = x_d_result_0; - dpy_4->primal_0 = (*dpy_4).primal_0; - dpy_4->differential_0 = y_d_result_0; - return; + float u_0 = uv_1.x; + float v_0 = uv_1.y; + float r2_0 = u_0 * u_0 + v_0 * v_0; + return uv_1 * make_float2 (1.0f + r2_0 * ((*coeffs_0)[int(0)] + r2_0 * (*coeffs_0)[int(1)])) + make_float2 (2.0f * (*coeffs_0)[int(2)] * u_0 * v_0 + (*coeffs_0)[int(3)] * (r2_0 + 2.0f * u_0 * u_0), 2.0f * (*coeffs_0)[int(3)] * u_0 * v_0 + (*coeffs_0)[int(2)] * (r2_0 + 2.0f * v_0 * v_0)); } -inline __device__ float dot_0(float3 x_8, float3 y_2) +struct DiffPair_vectorx3Cfloatx2C2x3E_0 { - int i_3 = int(0); - float result_4 = 0.0f; - for(;;) - { - if(i_3 < int(3)) - { - } - else - { - break; - } - float result_5 = result_4 + _slang_vector_get_element(x_8, i_3) * _slang_vector_get_element(y_2, i_3); - i_3 = i_3 + int(1); - result_4 = result_5; - } - return result_4; + float2 primal_0; + float2 differential_0; +}; + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistOpenCV_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_0, FixedArray * coeffs_1) +{ + float u_1 = dpuv_0->primal_0.x; + float s_diff_u_0 = dpuv_0->differential_0.x; + float v_1 = dpuv_0->primal_0.y; + float s_diff_v_0 = dpuv_0->differential_0.y; + float _S265 = s_diff_u_0 * u_1; + float _S266 = s_diff_v_0 * v_1; + float r2_1 = u_1 * u_1 + v_1 * v_1; + float s_diff_r2_0 = _S265 + _S265 + (_S266 + _S266); + float _S267 = (*coeffs_1)[int(0)] + r2_1 * (*coeffs_1)[int(1)]; + float radial_0 = 1.0f + r2_1 * _S267; + float _S268 = 2.0f * (*coeffs_1)[int(2)]; + float _S269 = _S268 * u_1; + float _S270 = 2.0f * u_1; + float _S271 = 2.0f * (*coeffs_1)[int(3)]; + float _S272 = _S271 * u_1; + float _S273 = 2.0f * v_1; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S274 = { dpuv_0->primal_0 * make_float2 (radial_0) + make_float2 (_S269 * v_1 + (*coeffs_1)[int(3)] * (r2_1 + _S270 * u_1), _S272 * v_1 + (*coeffs_1)[int(2)] * (r2_1 + _S273 * v_1)), dpuv_0->differential_0 * make_float2 (radial_0) + make_float2 (s_diff_r2_0 * _S267 + s_diff_r2_0 * (*coeffs_1)[int(1)] * r2_1) * dpuv_0->primal_0 + make_float2 (s_diff_u_0 * _S268 * v_1 + s_diff_v_0 * _S269 + (s_diff_r2_0 + (s_diff_u_0 * 2.0f * u_1 + s_diff_u_0 * _S270)) * (*coeffs_1)[int(3)], s_diff_u_0 * _S271 * v_1 + s_diff_v_0 * _S272 + (s_diff_r2_0 + (s_diff_v_0 * 2.0f * v_1 + s_diff_v_0 * _S273)) * (*coeffs_1)[int(2)]) }; + return _S274; } -inline __device__ float dot_1(float2 x_9, float2 y_3) -{ - int i_4 = int(0); - float result_6 = 0.0f; - for(;;) - { - if(i_4 < int(2)) - { - } - else - { - break; - } - float result_7 = result_6 + _slang_vector_get_element(x_9, i_4) * _slang_vector_get_element(y_3, i_4); - i_4 = i_4 + int(1); - result_6 = result_7; - } - return result_6; -} - -inline __device__ float length_0(float2 x_10) -{ - return (F32_sqrt((dot_1(x_10, x_10)))); -} - -inline __device__ float length_1(float3 x_11) -{ - return (F32_sqrt((dot_0(x_11, x_11)))); -} - -inline __device__ bool undistort_point_0(float2 uv_0, FixedArray * dist_coeffs_0, int maxiter_0, float2 * uv_undist_0) +inline __device__ bool undistort_point_1(float2 uv_2, FixedArray * dist_coeffs_1, int maxiter_1, float2 * uv_undist_1) { int i_5 = int(0); - float2 q_0 = uv_0; + float2 q_0 = uv_2; for(;;) { - if(i_5 < maxiter_0) + if(i_5 < maxiter_1) { } else { break; } - float _S153 = (*dist_coeffs_0)[int(3)]; - float _S154 = (*dist_coeffs_0)[int(4)]; - float _S155 = (*dist_coeffs_0)[int(5)]; - float _S156 = (*dist_coeffs_0)[int(6)]; - float _S157 = (*dist_coeffs_0)[int(7)]; - float _S158 = (*dist_coeffs_0)[int(8)]; - float _S159 = (*dist_coeffs_0)[int(9)]; - float u_0 = q_0.x; - float v_0 = q_0.y; - float r2_0 = u_0 * u_0 + v_0 * v_0; - float _S160 = (*dist_coeffs_0)[int(2)] + r2_0 * (*dist_coeffs_0)[int(3)]; - float _S161 = (*dist_coeffs_0)[int(1)] + r2_0 * _S160; - float _S162 = (*dist_coeffs_0)[int(0)] + r2_0 * _S161; - float radial_0 = 1.0f + r2_0 * _S162; - float _S163 = 2.0f * (*dist_coeffs_0)[int(4)]; - float _S164 = _S163 * u_0; - float _S165 = 2.0f * u_0; - float _S166 = 2.0f * (*dist_coeffs_0)[int(5)]; - float _S167 = _S166 * u_0; - float _S168 = 2.0f * v_0; - float2 _S169 = q_0 * make_float2 (radial_0) + make_float2 (_S164 * v_0 + (*dist_coeffs_0)[int(5)] * (r2_0 + _S165 * u_0) + (*dist_coeffs_0)[int(6)] * r2_0, _S167 * v_0 + (*dist_coeffs_0)[int(4)] * (r2_0 + _S168 * v_0) + (*dist_coeffs_0)[int(7)] * r2_0); - float2 r_1 = _S169 + make_float2 ((*dist_coeffs_0)[int(8)] * _S169.x + (*dist_coeffs_0)[int(9)] * _S169.y, 0.0f) - uv_0; - float _S170 = 0.0f * v_0; - float s_diff_r2_0 = u_0 + u_0 + (_S170 + _S170); - float2 _S171 = make_float2 (1.0f, 0.0f) * make_float2 (radial_0) + make_float2 (s_diff_r2_0 * _S162 + (s_diff_r2_0 * _S161 + (s_diff_r2_0 * _S160 + s_diff_r2_0 * _S153 * r2_0) * r2_0) * r2_0) * q_0 + make_float2 (_S163 * v_0 + 0.0f * _S164 + (s_diff_r2_0 + (_S165 + _S165)) * _S155 + s_diff_r2_0 * _S156, _S166 * v_0 + 0.0f * _S167 + (s_diff_r2_0 + (_S170 + 0.0f * _S168)) * _S154 + s_diff_r2_0 * _S157); - float _S172 = 0.0f * u_0; - float s_diff_r2_1 = _S172 + _S172 + (v_0 + v_0); - float2 _S173 = make_float2 (0.0f, 1.0f) * make_float2 (radial_0) + make_float2 (s_diff_r2_1 * _S162 + (s_diff_r2_1 * _S161 + (s_diff_r2_1 * _S160 + s_diff_r2_1 * _S153 * r2_0) * r2_0) * r2_0) * q_0 + make_float2 (0.0f * _S163 * v_0 + _S164 + (s_diff_r2_1 + (_S172 + 0.0f * _S165)) * _S155 + s_diff_r2_1 * _S156, 0.0f * _S166 * v_0 + _S167 + (s_diff_r2_1 + (_S168 + _S168)) * _S154 + s_diff_r2_1 * _S157); - Matrix _S174 = transpose_0(makeMatrix (_S171 + make_float2 (_S171.x * _S158 + _S171.y * _S159, 0.0f), _S173 + make_float2 (_S173.x * _S158 + _S173.y * _S159, 0.0f))); - float inv_det_0 = 1.0f / (_S174.rows[int(0)].x * _S174.rows[int(1)].y - _S174.rows[int(0)].y * _S174.rows[int(1)].x); - float _S175 = r_1.x; - float _S176 = r_1.y; - float2 q_1 = q_0 - make_float2 ((_S175 * _S174.rows[int(1)].y - _S176 * _S174.rows[int(0)].y) * inv_det_0, (- _S175 * _S174.rows[int(1)].x + _S176 * _S174.rows[int(0)].x) * inv_det_0); + float2 _S275 = DistOpenCV_distort_0(q_0, dist_coeffs_1); + float2 r_1 = _S275 - uv_2; + float2 _S276 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S277; + (&_S277)->primal_0 = q_0; + (&_S277)->differential_0 = _S276; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S278 = s_fwd_DistOpenCV_distort_0(&_S277, dist_coeffs_1); + float2 _S279 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S280; + (&_S280)->primal_0 = q_0; + (&_S280)->differential_0 = _S279; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S281 = s_fwd_DistOpenCV_distort_0(&_S280, dist_coeffs_1); + Matrix _S282 = transpose_0(makeMatrix (_S278.differential_0, _S281.differential_0)); + float inv_det_0 = 1.0f / (_S282.rows[int(0)].x * _S282.rows[int(1)].y - _S282.rows[int(0)].y * _S282.rows[int(1)].x); + float _S283 = r_1.x; + float _S284 = r_1.y; + float2 q_1 = q_0 - make_float2 ((_S283 * _S282.rows[int(1)].y - _S284 * _S282.rows[int(0)].y) * inv_det_0, (- _S283 * _S282.rows[int(1)].x + _S284 * _S282.rows[int(0)].x) * inv_det_0); i_5 = i_5 + int(1); q_0 = q_1; } - *uv_undist_0 = q_0; - float _S177 = (*dist_coeffs_0)[int(0)]; - float _S178 = (*dist_coeffs_0)[int(1)]; - float _S179 = (*dist_coeffs_0)[int(2)]; - float _S180 = (*dist_coeffs_0)[int(3)]; - float _S181 = (*dist_coeffs_0)[int(4)]; - float _S182 = (*dist_coeffs_0)[int(5)]; - float _S183 = (*dist_coeffs_0)[int(6)]; - float _S184 = (*dist_coeffs_0)[int(7)]; - float _S185 = (*dist_coeffs_0)[int(8)]; - float _S186 = (*dist_coeffs_0)[int(9)]; - float u_1 = q_0.x; - float v_1 = q_0.y; - float _S187 = 0.0f * v_1; - float r2_1 = u_1 * u_1 + v_1 * v_1; - float s_diff_r2_2 = u_1 + u_1 + (_S187 + _S187); - float _S188 = (*dist_coeffs_0)[int(2)] + r2_1 * (*dist_coeffs_0)[int(3)]; - float _S189 = (*dist_coeffs_0)[int(1)] + r2_1 * _S188; - float _S190 = (*dist_coeffs_0)[int(0)] + r2_1 * _S189; - float radial_1 = 1.0f + r2_1 * _S190; - float _S191 = 2.0f * (*dist_coeffs_0)[int(4)]; - float _S192 = _S191 * u_1; - float _S193 = 2.0f * u_1; - float _S194 = 2.0f * (*dist_coeffs_0)[int(5)]; - float _S195 = _S194 * u_1; - float _S196 = 2.0f * v_1; - float2 _S197 = make_float2 (1.0f, 0.0f) * make_float2 (radial_1) + make_float2 (s_diff_r2_2 * _S190 + (s_diff_r2_2 * _S189 + (s_diff_r2_2 * _S188 + s_diff_r2_2 * (*dist_coeffs_0)[int(3)] * r2_1) * r2_1) * r2_1) * q_0 + make_float2 (_S191 * v_1 + 0.0f * _S192 + (s_diff_r2_2 + (_S193 + _S193)) * (*dist_coeffs_0)[int(5)] + s_diff_r2_2 * (*dist_coeffs_0)[int(6)], _S194 * v_1 + 0.0f * _S195 + (s_diff_r2_2 + (_S187 + 0.0f * _S196)) * (*dist_coeffs_0)[int(4)] + s_diff_r2_2 * (*dist_coeffs_0)[int(7)]); - float _S198 = 0.0f * u_1; - float s_diff_r2_3 = _S198 + _S198 + (v_1 + v_1); - float2 _S199 = make_float2 (0.0f, 1.0f) * make_float2 (radial_1) + make_float2 (s_diff_r2_3 * _S190 + (s_diff_r2_3 * _S189 + (s_diff_r2_3 * _S188 + s_diff_r2_3 * (*dist_coeffs_0)[int(3)] * r2_1) * r2_1) * r2_1) * q_0 + make_float2 (0.0f * _S191 * v_1 + _S192 + (s_diff_r2_3 + (_S198 + 0.0f * _S193)) * (*dist_coeffs_0)[int(5)] + s_diff_r2_3 * (*dist_coeffs_0)[int(6)], 0.0f * _S194 * v_1 + _S195 + (s_diff_r2_3 + (_S196 + _S196)) * (*dist_coeffs_0)[int(4)] + s_diff_r2_3 * (*dist_coeffs_0)[int(7)]); - Matrix _S200 = transpose_0(makeMatrix (_S197 + make_float2 (_S197.x * (*dist_coeffs_0)[int(8)] + _S197.y * (*dist_coeffs_0)[int(9)], 0.0f), _S199 + make_float2 (_S199.x * (*dist_coeffs_0)[int(8)] + _S199.y * (*dist_coeffs_0)[int(9)], 0.0f))); - bool _S201; - if((F32_min((determinant_0(_S200)), ((F32_min((_S200.rows[int(0)].x), (_S200.rows[int(1)].y)))))) > 0.0f) + *uv_undist_1 = q_0; + float2 _S285 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S286; + (&_S286)->primal_0 = q_0; + (&_S286)->differential_0 = _S285; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S287 = s_fwd_DistOpenCV_distort_0(&_S286, dist_coeffs_1); + float2 _S288 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S289; + (&_S289)->primal_0 = q_0; + (&_S289)->differential_0 = _S288; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S290 = s_fwd_DistOpenCV_distort_0(&_S289, dist_coeffs_1); + Matrix _S291 = transpose_0(makeMatrix (_S287.differential_0, _S290.differential_0)); + float _S292 = (F32_min((determinant_0(_S291)), ((F32_min((_S291.rows[int(0)].x), (_S291.rows[int(1)].y)))))); + bool _S293; + if(_S292 > 0.25f) { - float u_2 = (*uv_undist_0).x; - float v_2 = (*uv_undist_0).y; - float r2_2 = u_2 * u_2 + v_2 * v_2; - float2 _S202 = *uv_undist_0 * make_float2 (1.0f + r2_2 * (_S177 + r2_2 * (_S178 + r2_2 * (_S179 + r2_2 * _S180)))) + make_float2 (_S191 * u_2 * v_2 + _S182 * (r2_2 + 2.0f * u_2 * u_2) + _S183 * r2_2, _S194 * u_2 * v_2 + _S181 * (r2_2 + 2.0f * v_2 * v_2) + _S184 * r2_2); - _S201 = (length_0(_S202 + make_float2 (_S185 * _S202.x + _S186 * _S202.y, 0.0f) - uv_0)) < 0.00999999977648258f; + _S293 = _S292 < 4.0f; } else { - _S201 = false; + _S293 = false; } - return _S201; + if(_S293) + { + float2 _S294 = DistOpenCV_distort_0(q_0, dist_coeffs_1); + _S293 = (dot_1(q_0, _S294)) >= 0.0f; + } + else + { + _S293 = false; + } + if(_S293) + { + float2 _S295 = DistOpenCV_distort_0(*uv_undist_1, dist_coeffs_1); + _S293 = (length_1(_S295 - uv_2)) < 0.00999999977648258f; + } + else + { + _S293 = false; + } + return _S293; +} + +inline __device__ float2 DistThinPrism_distort_0(float2 uv_3, FixedArray * coeffs_2) +{ + float u_2 = uv_3.x; + float v_2 = uv_3.y; + float r2_2 = u_2 * u_2 + v_2 * v_2; + return uv_3 * make_float2 (1.0f + r2_2 * ((*coeffs_2)[int(0)] + r2_2 * ((*coeffs_2)[int(1)] + r2_2 * ((*coeffs_2)[int(2)] + r2_2 * (*coeffs_2)[int(3)])))) + make_float2 (2.0f * (*coeffs_2)[int(4)] * u_2 * v_2 + (*coeffs_2)[int(5)] * (r2_2 + 2.0f * u_2 * u_2) + (*coeffs_2)[int(6)] * r2_2, 2.0f * (*coeffs_2)[int(5)] * u_2 * v_2 + (*coeffs_2)[int(4)] * (r2_2 + 2.0f * v_2 * v_2) + (*coeffs_2)[int(7)] * r2_2); +} + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistThinPrism_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_1, FixedArray * coeffs_3) +{ + float u_3 = dpuv_1->primal_0.x; + float s_diff_u_1 = dpuv_1->differential_0.x; + float v_3 = dpuv_1->primal_0.y; + float s_diff_v_1 = dpuv_1->differential_0.y; + float _S296 = s_diff_u_1 * u_3; + float _S297 = s_diff_v_1 * v_3; + float r2_3 = u_3 * u_3 + v_3 * v_3; + float s_diff_r2_1 = _S296 + _S296 + (_S297 + _S297); + float _S298 = (*coeffs_3)[int(2)] + r2_3 * (*coeffs_3)[int(3)]; + float _S299 = (*coeffs_3)[int(1)] + r2_3 * _S298; + float _S300 = (*coeffs_3)[int(0)] + r2_3 * _S299; + float radial_1 = 1.0f + r2_3 * _S300; + float _S301 = 2.0f * (*coeffs_3)[int(4)]; + float _S302 = _S301 * u_3; + float _S303 = 2.0f * u_3; + float _S304 = 2.0f * (*coeffs_3)[int(5)]; + float _S305 = _S304 * u_3; + float _S306 = 2.0f * v_3; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S307 = { dpuv_1->primal_0 * make_float2 (radial_1) + make_float2 (_S302 * v_3 + (*coeffs_3)[int(5)] * (r2_3 + _S303 * u_3) + (*coeffs_3)[int(6)] * r2_3, _S305 * v_3 + (*coeffs_3)[int(4)] * (r2_3 + _S306 * v_3) + (*coeffs_3)[int(7)] * r2_3), dpuv_1->differential_0 * make_float2 (radial_1) + make_float2 (s_diff_r2_1 * _S300 + (s_diff_r2_1 * _S299 + (s_diff_r2_1 * _S298 + s_diff_r2_1 * (*coeffs_3)[int(3)] * r2_3) * r2_3) * r2_3) * dpuv_1->primal_0 + make_float2 (s_diff_u_1 * _S301 * v_3 + s_diff_v_1 * _S302 + (s_diff_r2_1 + (s_diff_u_1 * 2.0f * u_3 + s_diff_u_1 * _S303)) * (*coeffs_3)[int(5)] + s_diff_r2_1 * (*coeffs_3)[int(6)], s_diff_u_1 * _S304 * v_3 + s_diff_v_1 * _S305 + (s_diff_r2_1 + (s_diff_v_1 * 2.0f * v_3 + s_diff_v_1 * _S306)) * (*coeffs_3)[int(4)] + s_diff_r2_1 * (*coeffs_3)[int(7)]) }; + return _S307; +} + +inline __device__ bool undistort_point_2(float2 uv_4, FixedArray * dist_coeffs_2, int maxiter_2, float2 * uv_undist_2) +{ + int i_6 = int(0); + float2 q_2 = uv_4; + for(;;) + { + if(i_6 < maxiter_2) + { + } + else + { + break; + } + float2 _S308 = DistThinPrism_distort_0(q_2, dist_coeffs_2); + float2 r_2 = _S308 - uv_4; + float2 _S309 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S310; + (&_S310)->primal_0 = q_2; + (&_S310)->differential_0 = _S309; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S311 = s_fwd_DistThinPrism_distort_0(&_S310, dist_coeffs_2); + float2 _S312 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S313; + (&_S313)->primal_0 = q_2; + (&_S313)->differential_0 = _S312; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S314 = s_fwd_DistThinPrism_distort_0(&_S313, dist_coeffs_2); + Matrix _S315 = transpose_0(makeMatrix (_S311.differential_0, _S314.differential_0)); + float inv_det_1 = 1.0f / (_S315.rows[int(0)].x * _S315.rows[int(1)].y - _S315.rows[int(0)].y * _S315.rows[int(1)].x); + float _S316 = r_2.x; + float _S317 = r_2.y; + float2 q_3 = q_2 - make_float2 ((_S316 * _S315.rows[int(1)].y - _S317 * _S315.rows[int(0)].y) * inv_det_1, (- _S316 * _S315.rows[int(1)].x + _S317 * _S315.rows[int(0)].x) * inv_det_1); + i_6 = i_6 + int(1); + q_2 = q_3; + } + *uv_undist_2 = q_2; + float2 _S318 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S319; + (&_S319)->primal_0 = q_2; + (&_S319)->differential_0 = _S318; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S320 = s_fwd_DistThinPrism_distort_0(&_S319, dist_coeffs_2); + float2 _S321 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S322; + (&_S322)->primal_0 = q_2; + (&_S322)->differential_0 = _S321; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S323 = s_fwd_DistThinPrism_distort_0(&_S322, dist_coeffs_2); + Matrix _S324 = transpose_0(makeMatrix (_S320.differential_0, _S323.differential_0)); + float _S325 = (F32_min((determinant_0(_S324)), ((F32_min((_S324.rows[int(0)].x), (_S324.rows[int(1)].y)))))); + bool _S326; + if(_S325 > 0.25f) + { + _S326 = _S325 < 4.0f; + } + else + { + _S326 = false; + } + if(_S326) + { + float2 _S327 = DistThinPrism_distort_0(q_2, dist_coeffs_2); + _S326 = (dot_1(q_2, _S327)) >= 0.0f; + } + else + { + _S326 = false; + } + if(_S326) + { + float2 _S328 = DistThinPrism_distort_0(*uv_undist_2, dist_coeffs_2); + _S326 = (length_1(_S328 - uv_4)) < 0.00999999977648258f; + } + else + { + _S326 = false; + } + return _S326; +} + +inline __device__ float2 DistRational_distort_0(float2 uv_5, FixedArray * coeffs_4) +{ + float u_4 = uv_5.x; + float v_4 = uv_5.y; + float r2_4 = u_4 * u_4 + v_4 * v_4; + return uv_5 * make_float2 ((1.0f + r2_4 * ((*coeffs_4)[int(0)] + r2_4 * ((*coeffs_4)[int(1)] + r2_4 * (*coeffs_4)[int(2)]))) / (1.0f + r2_4 * ((*coeffs_4)[int(3)] + r2_4 * ((*coeffs_4)[int(4)] + r2_4 * (*coeffs_4)[int(5)])))) + make_float2 (2.0f * (*coeffs_4)[int(6)] * u_4 * v_4 + (*coeffs_4)[int(7)] * (r2_4 + 2.0f * u_4 * u_4), 2.0f * (*coeffs_4)[int(7)] * u_4 * v_4 + (*coeffs_4)[int(6)] * (r2_4 + 2.0f * v_4 * v_4)); +} + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistRational_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_2, FixedArray * coeffs_5) +{ + float u_5 = dpuv_2->primal_0.x; + float s_diff_u_2 = dpuv_2->differential_0.x; + float v_5 = dpuv_2->primal_0.y; + float s_diff_v_2 = dpuv_2->differential_0.y; + float _S329 = s_diff_u_2 * u_5; + float _S330 = s_diff_v_2 * v_5; + float r2_5 = u_5 * u_5 + v_5 * v_5; + float s_diff_r2_2 = _S329 + _S329 + (_S330 + _S330); + float _S331 = (*coeffs_5)[int(1)] + r2_5 * (*coeffs_5)[int(2)]; + float _S332 = (*coeffs_5)[int(0)] + r2_5 * _S331; + float _S333 = 1.0f + r2_5 * _S332; + float _S334 = (*coeffs_5)[int(4)] + r2_5 * (*coeffs_5)[int(5)]; + float _S335 = (*coeffs_5)[int(3)] + r2_5 * _S334; + float _S336 = 1.0f + r2_5 * _S335; + float radial_2 = _S333 / _S336; + float _S337 = 2.0f * (*coeffs_5)[int(6)]; + float _S338 = _S337 * u_5; + float _S339 = 2.0f * u_5; + float _S340 = 2.0f * (*coeffs_5)[int(7)]; + float _S341 = _S340 * u_5; + float _S342 = 2.0f * v_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S343 = { dpuv_2->primal_0 * make_float2 (radial_2) + make_float2 (_S338 * v_5 + (*coeffs_5)[int(7)] * (r2_5 + _S339 * u_5), _S341 * v_5 + (*coeffs_5)[int(6)] * (r2_5 + _S342 * v_5)), dpuv_2->differential_0 * make_float2 (radial_2) + make_float2 (((s_diff_r2_2 * _S332 + (s_diff_r2_2 * _S331 + s_diff_r2_2 * (*coeffs_5)[int(2)] * r2_5) * r2_5) * _S336 - _S333 * (s_diff_r2_2 * _S335 + (s_diff_r2_2 * _S334 + s_diff_r2_2 * (*coeffs_5)[int(5)] * r2_5) * r2_5)) / (_S336 * _S336)) * dpuv_2->primal_0 + make_float2 (s_diff_u_2 * _S337 * v_5 + s_diff_v_2 * _S338 + (s_diff_r2_2 + (s_diff_u_2 * 2.0f * u_5 + s_diff_u_2 * _S339)) * (*coeffs_5)[int(7)], s_diff_u_2 * _S340 * v_5 + s_diff_v_2 * _S341 + (s_diff_r2_2 + (s_diff_v_2 * 2.0f * v_5 + s_diff_v_2 * _S342)) * (*coeffs_5)[int(6)]) }; + return _S343; +} + +inline __device__ bool undistort_point_3(float2 uv_6, FixedArray * dist_coeffs_3, int maxiter_3, float2 * uv_undist_3) +{ + int i_7 = int(0); + float2 q_4 = uv_6; + for(;;) + { + if(i_7 < maxiter_3) + { + } + else + { + break; + } + float2 _S344 = DistRational_distort_0(q_4, dist_coeffs_3); + float2 r_3 = _S344 - uv_6; + float2 _S345 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S346; + (&_S346)->primal_0 = q_4; + (&_S346)->differential_0 = _S345; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S347 = s_fwd_DistRational_distort_0(&_S346, dist_coeffs_3); + float2 _S348 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S349; + (&_S349)->primal_0 = q_4; + (&_S349)->differential_0 = _S348; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S350 = s_fwd_DistRational_distort_0(&_S349, dist_coeffs_3); + Matrix _S351 = transpose_0(makeMatrix (_S347.differential_0, _S350.differential_0)); + float inv_det_2 = 1.0f / (_S351.rows[int(0)].x * _S351.rows[int(1)].y - _S351.rows[int(0)].y * _S351.rows[int(1)].x); + float _S352 = r_3.x; + float _S353 = r_3.y; + float2 q_5 = q_4 - make_float2 ((_S352 * _S351.rows[int(1)].y - _S353 * _S351.rows[int(0)].y) * inv_det_2, (- _S352 * _S351.rows[int(1)].x + _S353 * _S351.rows[int(0)].x) * inv_det_2); + i_7 = i_7 + int(1); + q_4 = q_5; + } + *uv_undist_3 = q_4; + float2 _S354 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S355; + (&_S355)->primal_0 = q_4; + (&_S355)->differential_0 = _S354; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S356 = s_fwd_DistRational_distort_0(&_S355, dist_coeffs_3); + float2 _S357 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S358; + (&_S358)->primal_0 = q_4; + (&_S358)->differential_0 = _S357; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S359 = s_fwd_DistRational_distort_0(&_S358, dist_coeffs_3); + Matrix _S360 = transpose_0(makeMatrix (_S356.differential_0, _S359.differential_0)); + float _S361 = (F32_min((determinant_0(_S360)), ((F32_min((_S360.rows[int(0)].x), (_S360.rows[int(1)].y)))))); + bool _S362; + if(_S361 > 0.25f) + { + _S362 = _S361 < 4.0f; + } + else + { + _S362 = false; + } + if(_S362) + { + float2 _S363 = DistRational_distort_0(q_4, dist_coeffs_3); + _S362 = (dot_1(q_4, _S363)) >= 0.0f; + } + else + { + _S362 = false; + } + if(_S362) + { + float2 _S364 = DistRational_distort_0(*uv_undist_3, dist_coeffs_3); + _S362 = (length_1(_S364 - uv_6)) < 0.00999999977648258f; + } + else + { + _S362 = false; + } + return _S362; } inline __device__ float3 normalize_0(float3 x_12) { - return x_12 / make_float3 (length_1(x_12)); + return x_12 / make_float3 (length_0(x_12)); } -inline __device__ float3 unproject_raydir_0(float2 uv_1, int camera_model_0, bool is_ray_depth_0) +inline __device__ float3 unproject_raydir_0(float2 uv_7, int camera_model_0, bool is_ray_depth_0) { float3 raydir_0; bool is_unit_0; if(camera_model_0 == int(1)) { - float theta_0 = length_0(uv_1); - float3 _S203 = make_float3 ((uv_1 / make_float2 ((F32_max((theta_0), (1.00000001168609742e-07f)))) * make_float2 ((F32_sin((theta_0))))).x, (uv_1 / make_float2 ((F32_max((theta_0), (1.00000001168609742e-07f)))) * make_float2 ((F32_sin((theta_0))))).y, (F32_cos((theta_0)))); + float theta_0 = length_1(uv_7); + float3 _S365 = make_float3 ((uv_7 / make_float2 ((F32_max((theta_0), (1.00000001168609742e-07f)))) * make_float2 ((F32_sin((theta_0))))).x, (uv_7 / make_float2 ((F32_max((theta_0), (1.00000001168609742e-07f)))) * make_float2 ((F32_sin((theta_0))))).y, (F32_cos((theta_0)))); is_unit_0 = true; - raydir_0 = _S203; + raydir_0 = _S365; } else { - bool _S204 = camera_model_0 == int(2); - if(_S204) + bool _S366 = camera_model_0 == int(2); + if(_S366) { - float r_2 = length_0(uv_1); - raydir_0 = make_float3 ((uv_1 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_2 * r_2)))))))).x, (uv_1 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_2 * r_2)))))))).y, 1.0f - 0.5f * r_2 * r_2); + float r_4 = length_1(uv_7); + raydir_0 = make_float3 ((uv_7 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_4 * r_4)))))))).x, (uv_7 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_4 * r_4)))))))).y, 1.0f - 0.5f * r_4 * r_4); } else { - raydir_0 = make_float3 (uv_1.x, uv_1.y, 1.0f); + raydir_0 = make_float3 (uv_7.x, uv_7.y, 1.0f); } - is_unit_0 = _S204; + is_unit_0 = _S366; } if(is_ray_depth_0) { @@ -1144,79 +1789,93 @@ inline __device__ float3 unproject_raydir_0(float2 uv_1, int camera_model_0, b return raydir_0; } -inline __device__ float3 generate_ray_d2n(float2 pix_pos_0, float4 intrins_0, FixedArray dist_coeffs_1, int camera_model_1, bool is_ray_depth_1) +inline __device__ float3 generate_ray_d2n_none(float2 pix_pos_0, float4 intrins_0, FixedArray dist_coeffs_4, int camera_model_1, bool is_ray_depth_1) { - float2 _S205 = (pix_pos_0 - float2 {intrins_0.z, intrins_0.w}) / float2 {intrins_0.x, intrins_0.y}; - float2 uv_2 = _S205; - FixedArray _S206 = dist_coeffs_1; - bool _S207 = undistort_point_0(_S205, &_S206, int(12), &uv_2); - if(!_S207) + float3 _S367; + for(;;) { - int3 _S208 = make_int3 (int(0)); - float3 _S209 = make_float3 ((float)_S208.x, (float)_S208.y, (float)_S208.z); - return _S209; + float2 uv_8 = (pix_pos_0 - float2 {intrins_0.z, intrins_0.w}) / float2 {intrins_0.x, intrins_0.y}; + FixedArray _S368 = dist_coeffs_4; + float2 uv_u_0; + bool _S369 = undistort_point_0(uv_8, &_S368, int(12), &uv_u_0); + if(!_S369) + { + int3 _S370 = make_int3 (int(0)); + float3 _S371 = make_float3 ((float)_S370.x, (float)_S370.y, (float)_S370.z); + _S367 = _S371; + break; + } + _S367 = unproject_raydir_0(uv_u_0, camera_model_1, is_ray_depth_1); + break; } - return unproject_raydir_0(uv_2, camera_model_1, is_ray_depth_1); + return _S367; } -inline __device__ float3 depth_to_point(float2 pix_pos_1, float4 intrins_1, FixedArray dist_coeffs_2, int camera_model_2, bool is_ray_depth_2, float depth_2) +inline __device__ float3 depth_to_point_none(float2 pix_pos_1, float4 intrins_1, FixedArray dist_coeffs_5, int camera_model_2, bool is_ray_depth_2, float depth_2) { - float2 _S210 = (pix_pos_1 - float2 {intrins_1.z, intrins_1.w}) / float2 {intrins_1.x, intrins_1.y}; - float2 uv_3 = _S210; - FixedArray _S211 = dist_coeffs_2; - bool _S212 = undistort_point_0(_S210, &_S211, int(12), &uv_3); - if(!_S212) + float3 _S372; + for(;;) { - return make_float3 (0.0f); + float2 uv_9 = (pix_pos_1 - float2 {intrins_1.z, intrins_1.w}) / float2 {intrins_1.x, intrins_1.y}; + FixedArray _S373 = dist_coeffs_5; + float2 uv_u_1; + bool _S374 = undistort_point_0(uv_9, &_S373, int(12), &uv_u_1); + if(!_S374) + { + _S372 = make_float3 (0.0f); + break; + } + _S372 = make_float3 (depth_2) * unproject_raydir_0(uv_u_1, camera_model_2, is_ray_depth_2); + break; } - return make_float3 (depth_2) * unproject_raydir_0(uv_3, camera_model_2, is_ray_depth_2); + return _S372; } struct s_bwd_prop_depth_to_point_Intermediates_0 { - float2 _S213; - bool _S214; + float2 _S375; + bool _S376; }; -inline __device__ float s_primal_ctx_sin_0(float _S215) +inline __device__ float s_primal_ctx_sin_0(float _S377) { - return (F32_sin((_S215))); + return (F32_sin((_S377))); } -inline __device__ float s_primal_ctx_cos_0(float _S216) +inline __device__ float s_primal_ctx_cos_0(float _S378) { - return (F32_cos((_S216))); + return (F32_cos((_S378))); } -inline __device__ float s_primal_ctx_sqrt_0(float _S217) +inline __device__ float s_primal_ctx_sqrt_0(float _S379) { - return (F32_sqrt((_S217))); + return (F32_sqrt((_S379))); } -inline __device__ float3 s_primal_ctx_unproject_raydir_0(float2 dpuv_0, int camera_model_3, bool is_ray_depth_3) +inline __device__ float3 s_primal_ctx_unproject_raydir_0(float2 dpuv_3, int camera_model_3, bool is_ray_depth_3) { float3 raydir_1; bool is_unit_1; if(camera_model_3 == int(1)) { - float _S218 = length_0(dpuv_0); - float3 _S219 = make_float3 ((dpuv_0 / make_float2 ((F32_max((_S218), (1.00000001168609742e-07f)))) * make_float2 (s_primal_ctx_sin_0(_S218))).x, (dpuv_0 / make_float2 ((F32_max((_S218), (1.00000001168609742e-07f)))) * make_float2 (s_primal_ctx_sin_0(_S218))).y, s_primal_ctx_cos_0(_S218)); + float _S380 = length_1(dpuv_3); + float3 _S381 = make_float3 ((dpuv_3 / make_float2 ((F32_max((_S380), (1.00000001168609742e-07f)))) * make_float2 (s_primal_ctx_sin_0(_S380))).x, (dpuv_3 / make_float2 ((F32_max((_S380), (1.00000001168609742e-07f)))) * make_float2 (s_primal_ctx_sin_0(_S380))).y, s_primal_ctx_cos_0(_S380)); is_unit_1 = true; - raydir_1 = _S219; + raydir_1 = _S381; } else { - bool _S220 = camera_model_3 == int(2); - if(_S220) + bool _S382 = camera_model_3 == int(2); + if(_S382) { - float _S221 = length_0(dpuv_0); - raydir_1 = make_float3 ((dpuv_0 * make_float2 (s_primal_ctx_sqrt_0((F32_max((0.0f), (1.0f - 0.25f * _S221 * _S221)))))).x, (dpuv_0 * make_float2 (s_primal_ctx_sqrt_0((F32_max((0.0f), (1.0f - 0.25f * _S221 * _S221)))))).y, 1.0f - 0.5f * _S221 * _S221); + float _S383 = length_1(dpuv_3); + raydir_1 = make_float3 ((dpuv_3 * make_float2 (s_primal_ctx_sqrt_0((F32_max((0.0f), (1.0f - 0.25f * _S383 * _S383)))))).x, (dpuv_3 * make_float2 (s_primal_ctx_sqrt_0((F32_max((0.0f), (1.0f - 0.25f * _S383 * _S383)))))).y, 1.0f - 0.5f * _S383 * _S383); } else { - raydir_1 = make_float3 (dpuv_0.x, dpuv_0.y, 1.0f); + raydir_1 = make_float3 (dpuv_3.x, dpuv_3.y, 1.0f); } - is_unit_1 = _S220; + is_unit_1 = _S382; } if(is_ray_depth_3) { @@ -1235,610 +1894,236 @@ inline __device__ float3 s_primal_ctx_unproject_raydir_0(float2 dpuv_0, int ca return raydir_1; } -inline __device__ float3 s_primal_ctx_depth_to_point_0(float2 pix_pos_2, float4 intrins_2, FixedArray * dist_coeffs_3, int camera_model_4, bool is_ray_depth_4, float dpdepth_1, s_bwd_prop_depth_to_point_Intermediates_0 * _s_diff_ctx_0) +inline __device__ float depth_to_point_vjp_none(float2 pix_pos_2, float4 intrins_2, FixedArray dist_coeffs_6, int camera_model_4, bool is_ray_depth_4, float depth_3, float3 v_point_0) { - _s_diff_ctx_0->_S213 = make_float2 (0.0f); - _s_diff_ctx_0->_S214 = false; - float2 _S222 = (pix_pos_2 - float2 {intrins_2.z, intrins_2.w}) / float2 {intrins_2.x, intrins_2.y}; - float2 _S223 = _S222; - bool _S224 = undistort_point_0(_S222, dist_coeffs_3, int(12), &_S223); - _s_diff_ctx_0->_S213 = _S223; - _s_diff_ctx_0->_S214 = _S224; - float2 uv_4 = _S223; - bool _S225 = !_S224; - float3 _S226; - if(_S225) + float2 _S384 = make_float2 (0.0f); + s_bwd_prop_depth_to_point_Intermediates_0 _S385; + (&_S385)->_S375 = _S384; + (&_S385)->_S376 = false; + float2 uv_10 = (pix_pos_2 - float2 {intrins_2.z, intrins_2.w}) / float2 {intrins_2.x, intrins_2.y}; + float2 _S386 = _S384; + FixedArray _S387 = dist_coeffs_6; + bool _S388 = undistort_point_0(uv_10, &_S387, int(12), &_S386); + (&_S385)->_S375 = _S386; + (&_S385)->_S376 = _S388; + s_bwd_prop_depth_to_point_Intermediates_0 _S389 = _S385; + float3 _S390 = make_float3 (0.0f); + bool _S391 = !!_S385._S376; + float3 _S392; + if(_S391) { - _S226 = make_float3 (0.0f); - } - bool _S227 = !_S225; - if(_S227) - { - _S226 = make_float3 (dpdepth_1) * s_primal_ctx_unproject_raydir_0(uv_4, camera_model_4, is_ray_depth_4); - } - return _S226; -} - -inline __device__ void s_bwd_prop_depth_to_point_0(float2 pix_pos_3, float4 intrins_3, FixedArray * dist_coeffs_4, int camera_model_5, bool is_ray_depth_5, DiffPair_float_0 * dpdepth_2, float3 _s_dOut_4, s_bwd_prop_depth_to_point_Intermediates_0 * _s_diff_ctx_1) -{ - float3 _S228 = make_float3 (0.0f); - float2 _S229 = _s_diff_ctx_1->_S213; - bool _S230 = !!_s_diff_ctx_1->_S214; - float3 _S231; - if(_S230) - { - _S231 = s_primal_ctx_unproject_raydir_0(_S229, camera_model_5, is_ray_depth_5); + _S392 = s_primal_ctx_unproject_raydir_0(_S389._S375, camera_model_4, is_ray_depth_4); } else { - _S231 = _S228; + _S392 = _S390; } - if(_S230) + if(_S391) { - _S231 = _S231 * _s_dOut_4; + _S392 = _S392 * v_point_0; } else { - _S231 = _S228; + _S392 = _S390; } - float _S232 = _S231.x + _S231.y + _S231.z; - dpdepth_2->primal_0 = (*dpdepth_2).primal_0; - dpdepth_2->differential_0 = _S232; - return; + return _S392.x + _S392.y + _S392.z; } -inline __device__ void s_bwd_depth_to_point_0(float2 _S233, float4 _S234, FixedArray * _S235, int _S236, bool _S237, DiffPair_float_0 * _S238, float3 _S239) +inline __device__ float3 depth_to_normal_none(float2 pix_center_0, float4 intrins_3, FixedArray dist_coeffs_7, int camera_model_5, bool is_ray_depth_5, float4 depths_0) { - s_bwd_prop_depth_to_point_Intermediates_0 _S240; - float3 _S241 = s_primal_ctx_depth_to_point_0(_S233, _S234, _S235, _S236, _S237, (*_S238).primal_0, &_S240); - s_bwd_prop_depth_to_point_Intermediates_0 _S242 = _S240; - s_bwd_prop_depth_to_point_0(_S233, _S234, _S235, _S236, _S237, _S238, _S239, &_S242); - return; -} - -inline __device__ float depth_to_point_vjp(float2 pix_pos_4, float4 intrins_4, FixedArray dist_coeffs_5, int camera_model_6, bool is_ray_depth_6, float depth_3, float3 v_point_0) -{ - DiffPair_float_0 dp_depth_0; - (&dp_depth_0)->primal_0 = depth_3; - (&dp_depth_0)->differential_0 = 0.0f; - FixedArray _S243 = dist_coeffs_5; - s_bwd_depth_to_point_0(pix_pos_4, intrins_4, &_S243, camera_model_6, is_ray_depth_6, &dp_depth_0, v_point_0); - return dp_depth_0.differential_0; -} - -inline __device__ void _d_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * a_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * b_0, float3 dOut_7) -{ - float _S244 = dOut_7.y; - float _S245 = dOut_7.z; - float _S246 = dOut_7.x; - float _S247 = (*a_0).primal_0.z * _S244 + - (*a_0).primal_0.y * _S245; - float _S248 = - (*a_0).primal_0.z * _S246 + (*a_0).primal_0.x * _S245; - float _S249 = (*a_0).primal_0.y * _S246 + - (*a_0).primal_0.x * _S244; - float3 _S250 = make_float3 (- (*b_0).primal_0.z * _S244 + (*b_0).primal_0.y * _S245, (*b_0).primal_0.z * _S246 + - (*b_0).primal_0.x * _S245, - (*b_0).primal_0.y * _S246 + (*b_0).primal_0.x * _S244); - a_0->primal_0 = (*a_0).primal_0; - a_0->differential_0 = _S250; - float3 _S251 = make_float3 (_S247, _S248, _S249); - b_0->primal_0 = (*b_0).primal_0; - b_0->differential_0 = _S251; - return; -} - -inline __device__ float3 cross_0(float3 left_2, float3 right_2) -{ - float _S252 = left_2.y; - float _S253 = right_2.z; - float _S254 = left_2.z; - float _S255 = right_2.y; - float _S256 = right_2.x; - float _S257 = left_2.x; - return make_float3 (_S252 * _S253 - _S254 * _S255, _S254 * _S256 - _S257 * _S253, _S257 * _S255 - _S252 * _S256); -} - -inline __device__ float3 points_to_normal(FixedArray points_0) -{ - float3 _S258 = points_0[int(0)]; - bool _S259; - if((dot_0(_S258, _S258)) == 0.0f) + float3 normal_2; + for(;;) { - _S259 = true; - } - else - { - float3 _S260 = points_0[int(1)]; - _S259 = (dot_0(_S260, _S260)) == 0.0f; - } - if(_S259) - { - _S259 = true; - } - else - { - float3 _S261 = points_0[int(2)]; - _S259 = (dot_0(_S261, _S261)) == 0.0f; - } - if(_S259) - { - _S259 = true; - } - else - { - float3 _S262 = points_0[int(3)]; - _S259 = (dot_0(_S262, _S262)) == 0.0f; - } - if(_S259) - { - return make_float3 (0.0f); - } - float3 normal_0 = cross_0(points_0[int(1)] - points_0[int(0)], - (points_0[int(3)] - points_0[int(2)])); - float3 normal_1; - if((dot_0(normal_0, normal_0)) != 0.0f) - { - normal_1 = normal_0 / make_float3 (length_1(normal_0)); - } - else - { - normal_1 = normal_0; - } - return normal_1; -} - -struct DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 -{ - FixedArray primal_0; - FixedArray differential_0; -}; - -inline __device__ float s_primal_ctx_dot_0(float3 _S263, float3 _S264) -{ - return dot_0(_S263, _S264); -} - -inline __device__ float3 s_primal_ctx_cross_0(float3 _S265, float3 _S266) -{ - return cross_0(_S265, _S266); -} - -inline __device__ void s_bwd_prop_sqrt_0(DiffPair_float_0 * _S267, float _S268) -{ - _d_sqrt_0(_S267, _S268); - return; -} - -inline __device__ void s_bwd_prop_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_7, float _s_dOut_5) -{ - float _S269 = (*dpx_7).primal_0.x; - float _S270 = (*dpx_7).primal_0.y; - float _S271 = (*dpx_7).primal_0.z; - DiffPair_float_0 _S272; - (&_S272)->primal_0 = _S269 * _S269 + _S270 * _S270 + _S271 * _S271; - (&_S272)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S272, _s_dOut_5); - float _S273 = (*dpx_7).primal_0.z * _S272.differential_0; - float _S274 = _S273 + _S273; - float _S275 = (*dpx_7).primal_0.y * _S272.differential_0; - float _S276 = _S275 + _S275; - float _S277 = (*dpx_7).primal_0.x * _S272.differential_0; - float _S278 = _S277 + _S277; - float3 _S279 = make_float3 (0.0f); - *&((&_S279)->z) = _S274; - *&((&_S279)->y) = _S276; - *&((&_S279)->x) = _S278; - dpx_7->primal_0 = (*dpx_7).primal_0; - dpx_7->differential_0 = _S279; - return; -} - -inline __device__ void s_bwd_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S280, float _S281) -{ - s_bwd_prop_length_impl_0(_S280, _S281); - return; -} - -inline __device__ void s_bwd_prop_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S282, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S283, float _S284) -{ - _d_dot_0(_S282, _S283, _S284); - return; -} - -inline __device__ void s_bwd_prop_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S285, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S286, float3 _S287) -{ - _d_cross_0(_S285, _S286, _S287); - return; -} - -inline __device__ void s_bwd_prop_points_to_normal_0(DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 * dppoints_0, float3 _s_dOut_6) -{ - FixedArray _S288 = dppoints_0->primal_0; - float3 _S289 = make_float3 (0.0f); - float3 _S290 = dppoints_0->primal_0[int(0)]; - bool _S291 = (s_primal_ctx_dot_0(_S290, _S290)) == 0.0f; - bool _S292; - float3 _S293; - if(_S291) - { - _S292 = true; - _S293 = _S289; - } - else - { - float3 _S294 = _S288[int(1)]; - _S292 = (s_primal_ctx_dot_0(_S294, _S294)) == 0.0f; - _S293 = _S288[int(1)]; - } - bool _S295; - float3 _S296; - if(_S292) - { - _S295 = true; - _S296 = _S289; - } - else - { - float3 _S297 = _S288[int(2)]; - _S295 = (s_primal_ctx_dot_0(_S297, _S297)) == 0.0f; - _S296 = _S288[int(2)]; - } - bool _S298; - float3 _S299; - if(_S295) - { - _S298 = true; - _S299 = _S289; - } - else - { - float3 _S300 = _S288[int(3)]; - _S298 = (s_primal_ctx_dot_0(_S300, _S300)) == 0.0f; - _S299 = _S288[int(3)]; - } - bool _S301 = !_S298; - float3 _S302; - float3 _S303; - float3 _S304; - float3 _S305; - float3 _S306; - if(_S301) - { - float3 dx_0 = _S288[int(1)] - _S288[int(0)]; - float3 _S307 = - (_S288[int(3)] - _S288[int(2)]); - float3 _S308 = s_primal_ctx_cross_0(dx_0, _S307); - bool _S309 = (s_primal_ctx_dot_0(_S308, _S308)) != 0.0f; - if(_S309) + bool _S393; + if((depths_0.x) == 0.0f) { - float _S310 = length_1(_S308); - float3 _S311 = make_float3 (_S310); - _S302 = make_float3 (_S310 * _S310); - _S303 = _S311; + _S393 = true; } else { - _S302 = _S289; - _S303 = _S289; + _S393 = (depths_0.y) == 0.0f; } - float3 _S312 = _S303; - _S298 = _S309; - _S303 = _S308; - _S304 = _S312; - _S305 = dx_0; - _S306 = _S307; - } - else - { - _S298 = false; - _S302 = _S289; - _S303 = _S289; - _S304 = _S289; - _S305 = _S289; - _S306 = _S289; - } - FixedArray _S313; - if(_S301) - { - if(_S298) + if(_S393) { - float3 _S314 = _s_dOut_6 / _S302; - float3 _S315 = _S303 * - _S314; - float3 _S316 = _S304 * _S314; - float _S317 = _S315.x + _S315.y + _S315.z; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S318; - (&_S318)->primal_0 = _S303; - (&_S318)->differential_0 = _S289; - s_bwd_length_impl_0(&_S318, _S317); - _S302 = _S316 + _S318.differential_0; + _S393 = true; } else { - _S302 = _s_dOut_6; + _S393 = (depths_0.z) == 0.0f; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S319; - (&_S319)->primal_0 = _S303; - (&_S319)->differential_0 = _S289; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S320; - (&_S320)->primal_0 = _S303; - (&_S320)->differential_0 = _S289; - s_bwd_prop_dot_0(&_S319, &_S320, 0.0f); - float3 _S321 = _S320.differential_0 + _S319.differential_0 + _S302; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S322; - (&_S322)->primal_0 = _S305; - (&_S322)->differential_0 = _S289; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S323; - (&_S323)->primal_0 = _S306; - (&_S323)->differential_0 = _S289; - s_bwd_prop_cross_0(&_S322, &_S323, _S321); - float3 s_diff_dy_T_0 = - _S323.differential_0; - float3 _S324 = - s_diff_dy_T_0; - float3 _S325 = - _S322.differential_0; - FixedArray _S326; - _S326[int(0)] = _S289; - _S326[int(1)] = _S289; - _S326[int(2)] = _S289; - _S326[int(3)] = _S289; - _S326[int(2)] = _S324; - _S326[int(3)] = s_diff_dy_T_0; - _S326[int(1)] = _S322.differential_0; - _S313[int(0)] = _S326[int(0)]; - _S313[int(1)] = _S326[int(1)]; - _S313[int(2)] = _S326[int(2)]; - _S313[int(3)] = _S326[int(3)]; - _S302 = _S325; + if(_S393) + { + _S393 = true; + } + else + { + _S393 = (depths_0.w) == 0.0f; + } + if(_S393) + { + normal_2 = make_float3 (0.0f); + break; + } + float3 * _S394; + float3 * _S395; + float3 * _S396; + float3 * _S397; + int _S398; + FixedArray points_2; + for(;;) + { + float2 _S399 = float2 {intrins_3.z, intrins_3.w}; + float2 _S400 = float2 {intrins_3.x, intrins_3.y}; + float2 uv_11 = (pix_center_0 + make_float2 (-1.0f, -0.0f) - _S399) / _S400; + FixedArray _S401 = dist_coeffs_7; + float2 uv_u_2; + bool _S402 = undistort_point_0(uv_11, &_S401, int(12), &uv_u_2); + if(!_S402) + { + float3 _S403 = make_float3 (0.0f); + _S398 = int(0); + _S397 = nullptr; + _S396 = nullptr; + _S395 = nullptr; + _S394 = nullptr; + normal_2 = _S403; + break; + } + points_2[int(0)] = make_float3 (depths_0.x) * unproject_raydir_0(uv_u_2, camera_model_5, is_ray_depth_5); + for(;;) + { + float2 uv_12 = (pix_center_0 + make_float2 (1.0f, -0.0f) - _S399) / _S400; + FixedArray _S404 = dist_coeffs_7; + float2 uv_u_3; + bool _S405 = undistort_point_0(uv_12, &_S404, int(12), &uv_u_3); + if(!_S405) + { + float3 _S406 = make_float3 (0.0f); + _S398 = int(0); + _S397 = nullptr; + normal_2 = _S406; + break; + } + points_2[int(1)] = make_float3 (depths_0.y) * unproject_raydir_0(uv_u_3, camera_model_5, is_ray_depth_5); + _S398 = int(2); + _S397 = &points_2[int(1)]; + break; + } + if(_S398 != int(2)) + { + _S396 = &points_2[int(0)]; + _S395 = nullptr; + _S394 = nullptr; + break; + } + float2 uv_13 = (pix_center_0 + make_float2 (0.0f, -1.0f) - _S399) / _S400; + FixedArray _S407 = dist_coeffs_7; + float2 uv_u_4; + bool _S408 = undistort_point_0(uv_13, &_S407, int(12), &uv_u_4); + if(!_S408) + { + float3 _S409 = make_float3 (0.0f); + _S398 = int(0); + _S396 = &points_2[int(0)]; + _S395 = nullptr; + _S394 = nullptr; + normal_2 = _S409; + break; + } + points_2[int(2)] = make_float3 (depths_0.z) * unproject_raydir_0(uv_u_4, camera_model_5, is_ray_depth_5); + for(;;) + { + float2 uv_14 = (pix_center_0 + make_float2 (0.0f, 1.0f) - _S399) / _S400; + FixedArray _S410 = dist_coeffs_7; + float2 uv_u_5; + bool _S411 = undistort_point_0(uv_14, &_S410, int(12), &uv_u_5); + if(!_S411) + { + float3 _S412 = make_float3 (0.0f); + _S398 = int(0); + _S396 = nullptr; + normal_2 = _S412; + break; + } + points_2[int(3)] = make_float3 (depths_0.w) * unproject_raydir_0(uv_u_5, camera_model_5, is_ray_depth_5); + _S398 = int(2); + _S396 = &points_2[int(3)]; + break; + } + if(_S398 != int(2)) + { + float3 * _S413 = _S396; + _S396 = &points_2[int(0)]; + _S395 = _S413; + _S394 = &points_2[int(2)]; + break; + } + float3 * _S414 = _S396; + _S398 = int(1); + _S396 = &points_2[int(0)]; + _S395 = _S414; + _S394 = &points_2[int(2)]; + break; + } + if(_S398 != int(1)) + { + break; + } + float3 normal_3 = cross_0(*_S397 - *_S396, - (*_S395 - *_S394)); + if((dot_0(normal_3, normal_3)) != 0.0f) + { + normal_2 = normal_3 / make_float3 (length_0(normal_3)); + } + else + { + normal_2 = normal_3; + } + break; } - else - { - _S313[int(0)] = _S289; - _S313[int(1)] = _S289; - _S313[int(2)] = _S289; - _S313[int(3)] = _S289; - _S302 = _S289; - } - if(_S295) - { - } - else - { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S327; - (&_S327)->primal_0 = _S299; - (&_S327)->differential_0 = _S289; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S328; - (&_S328)->primal_0 = _S299; - (&_S328)->differential_0 = _S289; - s_bwd_prop_dot_0(&_S327, &_S328, 0.0f); - float3 _S329 = _S328.differential_0 + _S327.differential_0; - FixedArray _S330; - _S330[int(0)] = _S289; - _S330[int(1)] = _S289; - _S330[int(2)] = _S289; - _S330[int(3)] = _S289; - _S330[int(3)] = _S329; - float3 _S331 = _S313[int(1)] + _S330[int(1)]; - float3 _S332 = _S313[int(2)] + _S330[int(2)]; - float3 _S333 = _S313[int(3)] + _S330[int(3)]; - _S313[int(0)] = _S313[int(0)] + _S330[int(0)]; - _S313[int(1)] = _S331; - _S313[int(2)] = _S332; - _S313[int(3)] = _S333; - } - if(_S292) - { - } - else - { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S334; - (&_S334)->primal_0 = _S296; - (&_S334)->differential_0 = _S289; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S335; - (&_S335)->primal_0 = _S296; - (&_S335)->differential_0 = _S289; - s_bwd_prop_dot_0(&_S334, &_S335, 0.0f); - float3 _S336 = _S335.differential_0 + _S334.differential_0; - FixedArray _S337; - _S337[int(0)] = _S289; - _S337[int(1)] = _S289; - _S337[int(2)] = _S289; - _S337[int(3)] = _S289; - _S337[int(2)] = _S336; - float3 _S338 = _S313[int(1)] + _S337[int(1)]; - float3 _S339 = _S313[int(2)] + _S337[int(2)]; - float3 _S340 = _S313[int(3)] + _S337[int(3)]; - _S313[int(0)] = _S313[int(0)] + _S337[int(0)]; - _S313[int(1)] = _S338; - _S313[int(2)] = _S339; - _S313[int(3)] = _S340; - } - if(_S291) - { - } - else - { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S341; - (&_S341)->primal_0 = _S293; - (&_S341)->differential_0 = _S289; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S342; - (&_S342)->primal_0 = _S293; - (&_S342)->differential_0 = _S289; - s_bwd_prop_dot_0(&_S341, &_S342, 0.0f); - float3 _S343 = _S342.differential_0 + _S341.differential_0; - FixedArray _S344; - _S344[int(0)] = _S289; - _S344[int(1)] = _S289; - _S344[int(2)] = _S289; - _S344[int(3)] = _S289; - _S344[int(1)] = _S343; - float3 _S345 = _S313[int(1)] + _S344[int(1)]; - float3 _S346 = _S313[int(2)] + _S344[int(2)]; - float3 _S347 = _S313[int(3)] + _S344[int(3)]; - _S313[int(0)] = _S313[int(0)] + _S344[int(0)]; - _S313[int(1)] = _S345; - _S313[int(2)] = _S346; - _S313[int(3)] = _S347; - } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S348; - (&_S348)->primal_0 = _S288[int(0)]; - (&_S348)->differential_0 = _S289; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S349; - (&_S349)->primal_0 = _S288[int(0)]; - (&_S349)->differential_0 = _S289; - s_bwd_prop_dot_0(&_S348, &_S349, 0.0f); - float3 _S350 = _S349.differential_0 + _S348.differential_0 + _S302; - FixedArray _S351; - _S351[int(0)] = _S289; - _S351[int(1)] = _S289; - _S351[int(2)] = _S289; - _S351[int(3)] = _S289; - _S351[int(0)] = _S350; - FixedArray _S352 = { - _S313[int(0)] + _S351[int(0)], _S313[int(1)] + _S351[int(1)], _S313[int(2)] + _S351[int(2)], _S313[int(3)] + _S351[int(3)] - }; - dppoints_0->primal_0 = dppoints_0->primal_0; - dppoints_0->differential_0 = _S352; - return; + return normal_2; } -inline __device__ void s_bwd_points_to_normal_0(DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 * _S353, float3 _S354) -{ - s_bwd_prop_points_to_normal_0(_S353, _S354); - return; -} - -inline __device__ void points_to_normal_vjp(FixedArray points_1, float3 v_normal_0, FixedArray * v_points_0) -{ - FixedArray _S355 = { make_float3 (0.0f), make_float3 (0.0f), make_float3 (0.0f), make_float3 (0.0f) }; - DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 dp_points_0; - (&dp_points_0)->primal_0 = points_1; - (&dp_points_0)->differential_0 = _S355; - s_bwd_points_to_normal_0(&dp_points_0, v_normal_0); - *v_points_0 = (&dp_points_0)->differential_0; - return; -} - -inline __device__ float3 depth_to_normal(float2 pix_center_0, float4 intrins_5, FixedArray dist_coeffs_6, int camera_model_7, bool is_ray_depth_7, float4 depths_0) -{ - bool _S356; - if((depths_0.x) == 0.0f) - { - _S356 = true; - } - else - { - _S356 = (depths_0.y) == 0.0f; - } - if(_S356) - { - _S356 = true; - } - else - { - _S356 = (depths_0.z) == 0.0f; - } - if(_S356) - { - _S356 = true; - } - else - { - _S356 = (depths_0.w) == 0.0f; - } - if(_S356) - { - return make_float3 (0.0f); - } - FixedArray points_2; - float2 _S357 = float2 {intrins_5.z, intrins_5.w}; - float2 _S358 = float2 {intrins_5.x, intrins_5.y}; - float2 _S359 = (pix_center_0 + make_float2 (-1.0f, -0.0f) - _S357) / _S358; - float2 uv_5 = _S359; - FixedArray _S360 = dist_coeffs_6; - bool _S361 = undistort_point_0(_S359, &_S360, int(12), &uv_5); - if(!_S361) - { - return make_float3 (0.0f); - } - points_2[int(0)] = make_float3 (depths_0.x) * unproject_raydir_0(uv_5, camera_model_7, is_ray_depth_7); - float2 _S362 = (pix_center_0 + make_float2 (1.0f, -0.0f) - _S357) / _S358; - float2 uv_6 = _S362; - FixedArray _S363 = dist_coeffs_6; - bool _S364 = undistort_point_0(_S362, &_S363, int(12), &uv_6); - if(!_S364) - { - return make_float3 (0.0f); - } - points_2[int(1)] = make_float3 (depths_0.y) * unproject_raydir_0(uv_6, camera_model_7, is_ray_depth_7); - float2 _S365 = (pix_center_0 + make_float2 (0.0f, -1.0f) - _S357) / _S358; - float2 uv_7 = _S365; - FixedArray _S366 = dist_coeffs_6; - bool _S367 = undistort_point_0(_S365, &_S366, int(12), &uv_7); - if(!_S367) - { - return make_float3 (0.0f); - } - points_2[int(2)] = make_float3 (depths_0.z) * unproject_raydir_0(uv_7, camera_model_7, is_ray_depth_7); - float2 _S368 = (pix_center_0 + make_float2 (0.0f, 1.0f) - _S357) / _S358; - float2 uv_8 = _S368; - FixedArray _S369 = dist_coeffs_6; - bool _S370 = undistort_point_0(_S368, &_S369, int(12), &uv_8); - if(!_S370) - { - return make_float3 (0.0f); - } - points_2[int(3)] = make_float3 (depths_0.w) * unproject_raydir_0(uv_8, camera_model_7, is_ray_depth_7); - float3 normal_2 = cross_0(points_2[int(1)] - points_2[int(0)], - (points_2[int(3)] - points_2[int(2)])); - float3 normal_3; - if((dot_0(normal_2, normal_2)) != 0.0f) - { - normal_3 = normal_2 / make_float3 (length_1(normal_2)); - } - else - { - normal_3 = normal_2; - } - return normal_3; -} - -struct DiffPair_vectorx3Cfloatx2C4x3E_0 -{ - float4 primal_0; - float4 differential_0; -}; - struct s_bwd_prop_depth_to_normal_Intermediates_0 { - float2 _S371; - bool _S372; - float2 _S373; - bool _S374; - float2 _S375; - bool _S376; - float2 _S377; - bool _S378; + float2 _S415; + bool _S416; + float2 _S417; + bool _S418; + float2 _S419; + bool _S420; + float2 _S421; + bool _S422; }; -inline __device__ float3 s_primal_ctx_depth_to_normal_0(float2 pix_center_1, float4 intrins_6, FixedArray * dist_coeffs_7, int camera_model_8, bool is_ray_depth_8, float4 dpdepths_0, s_bwd_prop_depth_to_normal_Intermediates_0 * _s_diff_ctx_2) +inline __device__ void depth_to_normal_vjp_none(float2 pix_center_1, float4 intrins_4, FixedArray dist_coeffs_8, int camera_model_6, bool is_ray_depth_6, float4 depths_1, float3 v_normal_1, float4 * v_depths_0) { - float2 _S379 = make_float2 (0.0f); - _s_diff_ctx_2->_S371 = _S379; - _s_diff_ctx_2->_S372 = false; - _s_diff_ctx_2->_S373 = _S379; - _s_diff_ctx_2->_S374 = false; - _s_diff_ctx_2->_S375 = _S379; - _s_diff_ctx_2->_S376 = false; - _s_diff_ctx_2->_S377 = _S379; - _s_diff_ctx_2->_S378 = false; - _s_diff_ctx_2->_S371 = _S379; - _s_diff_ctx_2->_S372 = false; - _s_diff_ctx_2->_S373 = _S379; - _s_diff_ctx_2->_S374 = false; - _s_diff_ctx_2->_S375 = _S379; - _s_diff_ctx_2->_S376 = false; - _s_diff_ctx_2->_S377 = _S379; - _s_diff_ctx_2->_S378 = false; - float3 _S380 = make_float3 (0.0f); + float2 _S423 = make_float2 (0.0f); + s_bwd_prop_depth_to_normal_Intermediates_0 _S424; + (&_S424)->_S415 = _S423; + (&_S424)->_S416 = false; + (&_S424)->_S417 = _S423; + (&_S424)->_S418 = false; + (&_S424)->_S419 = _S423; + (&_S424)->_S420 = false; + (&_S424)->_S421 = _S423; + (&_S424)->_S422 = false; + (&_S424)->_S415 = _S423; + (&_S424)->_S416 = false; + (&_S424)->_S417 = _S423; + (&_S424)->_S418 = false; + (&_S424)->_S419 = _S423; + (&_S424)->_S420 = false; + (&_S424)->_S421 = _S423; + (&_S424)->_S422 = false; + bool _S425 = (depths_1.x) == 0.0f; bool _runFlag_0; - if((dpdepths_0.x) == 0.0f) + if(_S425) { _runFlag_0 = true; } else { - _runFlag_0 = (dpdepths_0.y) == 0.0f; + _runFlag_0 = (depths_1.y) == 0.0f; } if(_runFlag_0) { @@ -1846,7 +2131,7 @@ inline __device__ float3 s_primal_ctx_depth_to_normal_0(float2 pix_center_1, f } else { - _runFlag_0 = (dpdepths_0.z) == 0.0f; + _runFlag_0 = (depths_1.z) == 0.0f; } if(_runFlag_0) { @@ -1854,1380 +2139,5553 @@ inline __device__ float3 s_primal_ctx_depth_to_normal_0(float2 pix_center_1, f } else { - _runFlag_0 = (dpdepths_0.w) == 0.0f; + _runFlag_0 = (depths_1.w) == 0.0f; } - float3 normal_4; - if(_runFlag_0) + int _S426; + if(!_runFlag_0) { - normal_4 = make_float3 (0.0f); - } - bool _S381 = !_runFlag_0; - if(_S381) - { - float2 _S382 = float2 {intrins_6.z, intrins_6.w}; - float2 _S383 = float2 {intrins_6.x, intrins_6.y}; - float2 _S384 = (pix_center_1 + make_float2 (-1.0f, -0.0f) - _S382) / _S383; - float2 _S385 = _S384; - bool _S386 = undistort_point_0(_S384, dist_coeffs_7, int(12), &_S385); - _s_diff_ctx_2->_S371 = _S385; - _s_diff_ctx_2->_S372 = _S386; - float2 uv_9 = _S385; - bool _S387 = !_S386; - if(_S387) + float2 _S427 = float2 {intrins_4.z, intrins_4.w}; + float2 _S428 = float2 {intrins_4.x, intrins_4.y}; + float2 uv_15 = (pix_center_1 + make_float2 (-1.0f, -0.0f) - _S427) / _S428; + float2 _S429 = _S423; + FixedArray _S430 = dist_coeffs_8; + bool _S431 = undistort_point_0(uv_15, &_S430, int(12), &_S429); + (&_S424)->_S415 = _S429; + (&_S424)->_S416 = _S431; + bool _S432 = !!_S431; + if(_S432) { - normal_4 = make_float3 (0.0f); - } - bool _S388 = !_S387; - int _S389; - FixedArray points_3; - if(_S388) - { - float3 _S390 = make_float3 (dpdepths_0.x) * s_primal_ctx_unproject_raydir_0(uv_9, camera_model_8, is_ray_depth_8); - float2 _S391 = (pix_center_1 + make_float2 (1.0f, -0.0f) - _S382) / _S383; - float2 _S392 = _S391; - bool _S393 = undistort_point_0(_S391, dist_coeffs_7, int(12), &_S392); - _s_diff_ctx_2->_S373 = _S392; - _s_diff_ctx_2->_S374 = _S393; - float2 uv_10 = _S392; - bool _S394 = !_S393; - if(_S394) + float2 uv_16 = (pix_center_1 + make_float2 (1.0f, -0.0f) - _S427) / _S428; + float2 _S433 = _S423; + FixedArray _S434 = dist_coeffs_8; + bool _S435 = undistort_point_0(uv_16, &_S434, int(12), &_S433); + (&_S424)->_S417 = _S433; + (&_S424)->_S418 = _S435; + if(!!_S435) { - normal_4 = make_float3 (0.0f); - } - bool _S395 = !_S394; - if(_S395) - { - float3 _S396 = make_float3 (dpdepths_0.y) * s_primal_ctx_unproject_raydir_0(uv_10, camera_model_8, is_ray_depth_8); - _S389 = int(2); - points_3[int(0)] = _S390; - points_3[int(1)] = _S396; - points_3[int(2)] = _S380; - points_3[int(3)] = _S380; + _S426 = int(2); } else { - _S389 = int(0); - points_3[int(0)] = _S390; - points_3[int(1)] = _S380; - points_3[int(2)] = _S380; - points_3[int(3)] = _S380; + _S426 = int(0); } - if(_S389 != int(2)) + if(_S426 != int(2)) { _runFlag_0 = false; } else { - _runFlag_0 = _S388; - _S389 = int(0); + _runFlag_0 = _S432; } if(_runFlag_0) { - float2 _S397 = (pix_center_1 + make_float2 (0.0f, -1.0f) - _S382) / _S383; - float2 _S398 = _S397; - bool _S399 = undistort_point_0(_S397, dist_coeffs_7, int(12), &_S398); - _s_diff_ctx_2->_S375 = _S398; - _s_diff_ctx_2->_S376 = _S399; - float2 uv_11 = _S398; - if(!_S399) + float2 uv_17 = (pix_center_1 + make_float2 (0.0f, -1.0f) - _S427) / _S428; + float2 _S436 = _S423; + FixedArray _S437 = dist_coeffs_8; + bool _S438 = undistort_point_0(uv_17, &_S437, int(12), &_S436); + (&_S424)->_S419 = _S436; + (&_S424)->_S420 = _S438; + if(!_S438) { - float3 _S400 = make_float3 (0.0f); _runFlag_0 = false; - _S389 = int(0); - normal_4 = _S400; } if(_runFlag_0) { - points_3[int(2)] = make_float3 (dpdepths_0.z) * s_primal_ctx_unproject_raydir_0(uv_11, camera_model_8, is_ray_depth_8); - float2 _S401 = (pix_center_1 + make_float2 (0.0f, 1.0f) - _S382) / _S383; - float2 _S402 = _S401; - bool _S403 = undistort_point_0(_S401, dist_coeffs_7, int(12), &_S402); - _s_diff_ctx_2->_S377 = _S402; - _s_diff_ctx_2->_S378 = _S403; - float2 uv_12 = _S402; - bool _S404 = !_S403; - if(_S404) - { - normal_4 = make_float3 (0.0f); - } - bool _S405 = !_S404; - int _S406; - if(_S405) - { - points_3[int(3)] = make_float3 (dpdepths_0.w) * s_primal_ctx_unproject_raydir_0(uv_12, camera_model_8, is_ray_depth_8); - _S406 = int(2); - } - else - { - _S406 = int(0); - } - if(_S406 != int(2)) - { - _runFlag_0 = false; - _S389 = _S406; - } - if(_runFlag_0) - { - _S389 = int(1); - } + float2 uv_18 = (pix_center_1 + make_float2 (0.0f, 1.0f) - _S427) / _S428; + float2 _S439 = _S423; + FixedArray _S440 = dist_coeffs_8; + bool _S441 = undistort_point_0(uv_18, &_S440, int(12), &_S439); + (&_S424)->_S421 = _S439; + (&_S424)->_S422 = _S441; } } } - else - { - _S389 = int(0); - points_3[int(0)] = _S380; - points_3[int(1)] = _S380; - points_3[int(2)] = _S380; - points_3[int(3)] = _S380; - } - if(_S389 != int(1)) - { - _runFlag_0 = false; - } - else - { - _runFlag_0 = _S381; - } - if(_runFlag_0) - { - float3 _S407 = s_primal_ctx_cross_0(points_3[int(1)] - points_3[int(0)], - (points_3[int(3)] - points_3[int(2)])); - if((s_primal_ctx_dot_0(_S407, _S407)) != 0.0f) - { - normal_4 = _S407 / make_float3 (length_1(_S407)); - } - else - { - normal_4 = _S407; - } - } } - return normal_4; -} - -inline __device__ void s_bwd_prop_depth_to_normal_0(float2 pix_center_2, float4 intrins_7, FixedArray * dist_coeffs_8, int camera_model_9, bool is_ray_depth_9, DiffPair_vectorx3Cfloatx2C4x3E_0 * dpdepths_1, float3 _s_dOut_7, s_bwd_prop_depth_to_normal_Intermediates_0 * _s_diff_ctx_3) -{ - DiffPair_vectorx3Cfloatx2C4x3E_0 _S408 = *dpdepths_1; - float3 _S409 = make_float3 (0.0f); + s_bwd_prop_depth_to_normal_Intermediates_0 _S442 = _S424; + float3 _S443 = make_float3 (0.0f); + if(_S425) + { + _runFlag_0 = true; + } + else + { + _runFlag_0 = (depths_1.y) == 0.0f; + } + if(_runFlag_0) + { + _runFlag_0 = true; + } + else + { + _runFlag_0 = (depths_1.z) == 0.0f; + } + if(_runFlag_0) + { + _runFlag_0 = true; + } + else + { + _runFlag_0 = (depths_1.w) == 0.0f; + } + bool _S444 = !_runFlag_0; bool _runFlag_1; - if(((*dpdepths_1).primal_0.x) == 0.0f) - { - _runFlag_1 = true; - } - else - { - _runFlag_1 = (_S408.primal_0.y) == 0.0f; - } - if(_runFlag_1) - { - _runFlag_1 = true; - } - else - { - _runFlag_1 = (_S408.primal_0.z) == 0.0f; - } - if(_runFlag_1) - { - _runFlag_1 = true; - } - else - { - _runFlag_1 = (_S408.primal_0.w) == 0.0f; - } - bool _S410 = !_runFlag_1; bool _runFlag_2; + bool _S445; bool _runFlag_3; - bool _S411; - bool _runFlag_4; - bool _S412; - bool _S413; - FixedArray points_4; - float3 _S414; - float3 _S415; - float3 _S416; - float3 _S417; - float3 _S418; - float3 _S419; - float3 _S420; - float3 _S421; - float3 _S422; - if(_S410) + bool _S446; + bool _S447; + FixedArray points_3; + float3 _S448; + float3 _S449; + float3 _S450; + float3 _S451; + float3 _S452; + float3 _S453; + float3 _S454; + float3 _S455; + float3 _S456; + if(_S444) { - float2 _S423 = _s_diff_ctx_3->_S371; - bool _S424 = !!_s_diff_ctx_3->_S372; - int _S425; - if(_S424) + bool _S457 = !!_S442._S416; + if(_S457) { - float3 _S426 = s_primal_ctx_unproject_raydir_0(_S423, camera_model_9, is_ray_depth_9); - float3 _S427 = make_float3 (_S408.primal_0.x) * _S426; - float2 _S428 = _s_diff_ctx_3->_S373; - bool _S429 = !!_s_diff_ctx_3->_S374; - if(_S429) + float3 _S458 = s_primal_ctx_unproject_raydir_0(_S442._S415, camera_model_6, is_ray_depth_6); + float3 _S459 = make_float3 (depths_1.x) * _S458; + bool _S460 = !!_S442._S418; + if(_S460) { - float3 _S430 = s_primal_ctx_unproject_raydir_0(_S428, camera_model_9, is_ray_depth_9); - float3 _S431 = make_float3 (_S408.primal_0.y) * _S430; - _S425 = int(2); - points_4[int(0)] = _S427; - points_4[int(1)] = _S431; - points_4[int(2)] = _S409; - points_4[int(3)] = _S409; - _S414 = _S430; + float3 _S461 = s_primal_ctx_unproject_raydir_0(_S442._S417, camera_model_6, is_ray_depth_6); + float3 _S462 = make_float3 (depths_1.y) * _S461; + _S426 = int(2); + points_3[int(0)] = _S459; + points_3[int(1)] = _S462; + points_3[int(2)] = _S443; + points_3[int(3)] = _S443; + _S448 = _S461; } else { - _S425 = int(0); - points_4[int(0)] = _S427; - points_4[int(1)] = _S409; - points_4[int(2)] = _S409; - points_4[int(3)] = _S409; - _S414 = _S409; + _S426 = int(0); + points_3[int(0)] = _S459; + points_3[int(1)] = _S443; + points_3[int(2)] = _S443; + points_3[int(3)] = _S443; + _S448 = _S443; } - if(_S425 != int(2)) + if(_S426 != int(2)) { - _runFlag_1 = false; + _runFlag_0 = false; } else { - _runFlag_1 = _S424; - _S425 = int(0); + _runFlag_0 = _S457; + _S426 = int(0); } - if(_runFlag_1) + if(_runFlag_0) { - float2 _S432 = _s_diff_ctx_3->_S375; - if(!_s_diff_ctx_3->_S376) + if(!_S442._S420) + { + _runFlag_1 = false; + _S426 = int(0); + } + else + { + _runFlag_1 = _runFlag_0; + } + if(_runFlag_1) + { + float3 _S463 = s_primal_ctx_unproject_raydir_0(_S442._S419, camera_model_6, is_ray_depth_6); + points_3[int(2)] = make_float3 (depths_1.z) * _S463; + bool _S464 = !!_S442._S422; + int _S465; + if(_S464) + { + float3 _S466 = s_primal_ctx_unproject_raydir_0(_S442._S421, camera_model_6, is_ray_depth_6); + points_3[int(3)] = make_float3 (depths_1.w) * _S466; + _S465 = int(2); + _S449 = _S466; + } + else + { + _S465 = int(0); + _S449 = _S443; + } + if(_S465 != int(2)) + { + _runFlag_2 = false; + _S426 = _S465; + } + else + { + _runFlag_2 = _runFlag_1; + } + if(_runFlag_2) + { + _S426 = int(1); + } + _runFlag_2 = _S464; + _S450 = _S463; + } + else { _runFlag_2 = false; - _S425 = int(0); - } - else - { - _runFlag_2 = _runFlag_1; - } - if(_runFlag_2) - { - float3 _S433 = s_primal_ctx_unproject_raydir_0(_S432, camera_model_9, is_ray_depth_9); - points_4[int(2)] = make_float3 (_S408.primal_0.z) * _S433; - float2 _S434 = _s_diff_ctx_3->_S377; - bool _S435 = !!_s_diff_ctx_3->_S378; - int _S436; - if(_S435) - { - float3 _S437 = s_primal_ctx_unproject_raydir_0(_S434, camera_model_9, is_ray_depth_9); - points_4[int(3)] = make_float3 (_S408.primal_0.w) * _S437; - _S436 = int(2); - _S415 = _S437; - } - else - { - _S436 = int(0); - _S415 = _S409; - } - if(_S436 != int(2)) - { - _runFlag_3 = false; - _S425 = _S436; - } - else - { - _runFlag_3 = _runFlag_2; - } - if(_runFlag_3) - { - _S425 = int(1); - } - _runFlag_3 = _S435; - _S416 = _S433; - } - else - { - _runFlag_3 = false; - _S415 = _S409; - _S416 = _S409; + _S449 = _S443; + _S450 = _S443; } } else { + _runFlag_1 = false; _runFlag_2 = false; - _runFlag_3 = false; - _S415 = _S409; - _S416 = _S409; + _S449 = _S443; + _S450 = _S443; } - float3 _S438 = _S414; - _S414 = _S415; - _S415 = _S416; - _S411 = _S429; - _S416 = _S438; - _S417 = _S426; + float3 _S467 = _S448; + _S448 = _S449; + _S449 = _S450; + _S445 = _S460; + _S450 = _S467; + _S451 = _S458; } else { - _S425 = int(0); - points_4[int(0)] = _S409; - points_4[int(1)] = _S409; - points_4[int(2)] = _S409; - points_4[int(3)] = _S409; + _S426 = int(0); + points_3[int(0)] = _S443; + points_3[int(1)] = _S443; + points_3[int(2)] = _S443; + points_3[int(3)] = _S443; + _runFlag_0 = false; _runFlag_1 = false; _runFlag_2 = false; - _runFlag_3 = false; - _S414 = _S409; - _S415 = _S409; - _S411 = false; - _S416 = _S409; - _S417 = _S409; + _S448 = _S443; + _S449 = _S443; + _S445 = false; + _S450 = _S443; + _S451 = _S443; } - if(_S425 != int(1)) + if(_S426 != int(1)) + { + _runFlag_3 = false; + } + else + { + _runFlag_3 = _S444; + } + if(_runFlag_3) + { + float3 dx_1 = points_3[int(1)] - points_3[int(0)]; + float3 _S468 = - (points_3[int(3)] - points_3[int(2)]); + float3 _S469 = s_primal_ctx_cross_0(dx_1, _S468); + bool _S470 = (s_primal_ctx_dot_0(_S469, _S469)) != 0.0f; + if(_S470) + { + float _S471 = length_0(_S469); + float3 _S472 = make_float3 (_S471); + _S452 = make_float3 (_S471 * _S471); + _S453 = _S472; + } + else + { + _S452 = _S443; + _S453 = _S443; + } + float3 _S473 = _S453; + _S446 = _S470; + _S453 = _S469; + _S454 = _S473; + _S455 = dx_1; + _S456 = _S468; + } + else + { + _S446 = false; + _S452 = _S443; + _S453 = _S443; + _S454 = _S443; + _S455 = _S443; + _S456 = _S443; + } + bool _S474 = _runFlag_0; + bool _S475 = _runFlag_1; + bool _S476 = _runFlag_2; + float3 _S477 = _S448; + float3 _S478 = _S449; + bool _S479 = _S445; + float3 _S480 = _S450; + float3 _S481 = _S451; + _runFlag_0 = _runFlag_3; + _runFlag_1 = _S446; + _S448 = _S452; + _S449 = _S453; + _S450 = _S454; + _S451 = _S455; + _S452 = _S456; + _runFlag_2 = _S457; + _S445 = _S474; + _runFlag_3 = _S475; + _S446 = _S476; + _S453 = _S477; + _S454 = _S478; + _S447 = _S479; + _S455 = _S480; + _S456 = _S481; + } + else + { + _runFlag_0 = false; + _runFlag_1 = false; + _S448 = _S443; + _S449 = _S443; + _S450 = _S443; + _S451 = _S443; + _S452 = _S443; + _runFlag_2 = false; + _S445 = false; + _runFlag_3 = false; + _S446 = false; + _S453 = _S443; + _S454 = _S443; + _S447 = false; + _S455 = _S443; + _S456 = _S443; + } + float4 _S482 = make_float4 (0.0f); + float4 _S483; + if(_S444) + { + if(_runFlag_0) + { + if(_runFlag_1) + { + float3 _S484 = v_normal_1 / _S448; + float3 _S485 = _S449 * - _S484; + float3 _S486 = _S450 * _S484; + float _S487 = _S485.x + _S485.y + _S485.z; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S488; + (&_S488)->primal_0 = _S449; + (&_S488)->differential_0 = _S443; + s_bwd_length_impl_0(&_S488, _S487); + _S448 = _S486 + _S488.differential_0; + } + else + { + _S448 = v_normal_1; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S489; + (&_S489)->primal_0 = _S449; + (&_S489)->differential_0 = _S443; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S490; + (&_S490)->primal_0 = _S449; + (&_S490)->differential_0 = _S443; + s_bwd_prop_dot_0(&_S489, &_S490, 0.0f); + float3 _S491 = _S490.differential_0 + _S489.differential_0 + _S448; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S492; + (&_S492)->primal_0 = _S451; + (&_S492)->differential_0 = _S443; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S493; + (&_S493)->primal_0 = _S452; + (&_S493)->differential_0 = _S443; + s_bwd_prop_cross_0(&_S492, &_S493, _S491); + float3 s_diff_dy_T_1 = - _S493.differential_0; + float3 _S494 = - s_diff_dy_T_1; + float3 _S495 = - _S492.differential_0; + FixedArray _S496; + _S496[int(0)] = _S443; + _S496[int(1)] = _S443; + _S496[int(2)] = _S443; + _S496[int(3)] = _S443; + _S496[int(2)] = _S494; + _S496[int(3)] = s_diff_dy_T_1; + _S496[int(0)] = _S495; + _S496[int(1)] = _S492.differential_0; + points_3[int(0)] = _S496[int(0)]; + points_3[int(1)] = _S496[int(1)]; + points_3[int(2)] = _S496[int(2)]; + points_3[int(3)] = _S496[int(3)]; + } + else + { + points_3[int(0)] = _S443; + points_3[int(1)] = _S443; + points_3[int(2)] = _S443; + points_3[int(3)] = _S443; + } + if(_runFlag_2) + { + if(_S445) + { + if(_runFlag_3) + { + FixedArray _S497 = points_3; + FixedArray _S498 = points_3; + FixedArray _S499 = points_3; + FixedArray _S500 = points_3; + if(_S446) + { + float3 _S501 = _S453 * _S500[int(3)]; + float _S502 = _S501.x + _S501.y + _S501.z; + float4 _S503 = _S482; + *&((&_S503)->w) = _S502; + points_3[int(0)] = _S497[int(0)]; + points_3[int(1)] = _S498[int(1)]; + points_3[int(2)] = _S499[int(2)]; + points_3[int(3)] = _S443; + _S483 = _S503; + } + else + { + points_3[int(0)] = _S497[int(0)]; + points_3[int(1)] = _S498[int(1)]; + points_3[int(2)] = _S499[int(2)]; + points_3[int(3)] = _S500[int(3)]; + _S483 = _S482; + } + float3 _S504 = _S454 * points_3[int(2)]; + float _S505 = _S504.x + _S504.y + _S504.z; + FixedArray _S506 = points_3; + FixedArray _S507 = points_3; + float4 _S508 = _S482; + *&((&_S508)->z) = _S505; + float4 _S509 = _S483 + _S508; + points_3[int(0)] = points_3[int(0)]; + points_3[int(1)] = _S506[int(1)]; + points_3[int(2)] = _S443; + points_3[int(3)] = _S507[int(3)]; + _S483 = _S509; + } + else + { + FixedArray _S510 = points_3; + FixedArray _S511 = points_3; + FixedArray _S512 = points_3; + points_3[int(0)] = points_3[int(0)]; + points_3[int(1)] = _S510[int(1)]; + points_3[int(2)] = _S511[int(2)]; + points_3[int(3)] = _S512[int(3)]; + _S483 = _S482; + } + } + else + { + FixedArray _S513 = points_3; + FixedArray _S514 = points_3; + FixedArray _S515 = points_3; + points_3[int(0)] = points_3[int(0)]; + points_3[int(1)] = _S513[int(1)]; + points_3[int(2)] = _S514[int(2)]; + points_3[int(3)] = _S515[int(3)]; + _S483 = _S482; + } + if(_S447) + { + FixedArray _S516 = points_3; + float3 _S517 = _S455 * points_3[int(1)]; + float _S518 = _S517.x + _S517.y + _S517.z; + float4 _S519 = _S482; + *&((&_S519)->y) = _S518; + float4 _S520 = _S483 + _S519; + points_3[int(0)] = _S443; + points_3[int(1)] = _S443; + points_3[int(2)] = _S443; + points_3[int(3)] = _S443; + _S448 = _S516[int(0)]; + _S483 = _S520; + } + else + { + FixedArray _S521 = points_3; + FixedArray _S522 = points_3; + FixedArray _S523 = points_3; + points_3[int(0)] = points_3[int(0)]; + points_3[int(1)] = _S521[int(1)]; + points_3[int(2)] = _S522[int(2)]; + points_3[int(3)] = _S523[int(3)]; + _S448 = _S443; + } + float3 _S524 = _S456 * (points_3[int(0)] + _S448); + float _S525 = _S524.x + _S524.y + _S524.z; + float4 _S526 = _S482; + *&((&_S526)->x) = _S525; + _S483 = _S483 + _S526; + } + else + { + _S483 = _S482; + } + } + else + { + _S483 = _S482; + } + *v_depths_0 = _S483; + return; +} + +inline __device__ float ray_depth_to_linear_depth_factor_none(float2 pix_center_2, float4 intrins_5, FixedArray dist_coeffs_9, int camera_model_7) +{ + float _S527; + for(;;) + { + float2 uv_19 = (pix_center_2 - float2 {intrins_5.z, intrins_5.w}) / float2 {intrins_5.x, intrins_5.y}; + FixedArray _S528 = dist_coeffs_9; + float2 uv_u_6; + bool _S529 = undistort_point_0(uv_19, &_S528, int(12), &uv_u_6); + if(!_S529) + { + _S527 = 0.0f; + break; + } + float3 raydir_2 = unproject_raydir_0(uv_u_6, camera_model_7, false); + _S527 = float((F32_sign((raydir_2.z)))) / length_0(raydir_2); + break; + } + return _S527; +} + +inline __device__ float depth_normal_loss_none(float2 pix_center_3, float4 intrins_6, FixedArray dist_coeffs_10, int camera_model_8, bool is_ray_depth_7, float4 depths_2, float3 gt_normal_0) +{ + float _S530; + for(;;) + { + float3 _S531; + float3 * _S532; + float3 * _S533; + float3 * _S534; + float3 * _S535; + int _S536; + FixedArray points_4; + for(;;) + { + float2 _S537 = float2 {intrins_6.z, intrins_6.w}; + float2 _S538 = float2 {intrins_6.x, intrins_6.y}; + float2 uv_20 = (pix_center_3 + make_float2 (-1.0f, -0.0f) - _S537) / _S538; + FixedArray _S539 = dist_coeffs_10; + float2 uv_u_7; + bool _S540 = undistort_point_0(uv_20, &_S539, int(12), &uv_u_7); + float3 _S541 = make_float3 (0.0f); + if(!_S540) + { + _S536 = int(0); + _S535 = nullptr; + _S534 = nullptr; + _S533 = nullptr; + _S532 = nullptr; + _S531 = _S541; + break; + } + float3 raydir_3 = unproject_raydir_0(uv_u_7, camera_model_8, is_ray_depth_7); + points_4[int(0)] = make_float3 (depths_2.x) * raydir_3; + float2 uv_21 = (pix_center_3 + make_float2 (1.0f, -0.0f) - _S537) / _S538; + FixedArray _S542 = dist_coeffs_10; + float2 uv_u_8; + bool _S543 = undistort_point_0(uv_21, &_S542, int(12), &uv_u_8); + if(!_S543) + { + _S536 = int(0); + _S535 = nullptr; + _S534 = &points_4[int(0)]; + _S533 = nullptr; + _S532 = nullptr; + _S531 = _S541; + break; + } + float3 raydir_4 = unproject_raydir_0(uv_u_8, camera_model_8, is_ray_depth_7); + points_4[int(1)] = make_float3 (depths_2.y) * raydir_4; + float2 uv_22 = (pix_center_3 + make_float2 (0.0f, -1.0f) - _S537) / _S538; + FixedArray _S544 = dist_coeffs_10; + float2 uv_u_9; + bool _S545 = undistort_point_0(uv_22, &_S544, int(12), &uv_u_9); + if(!_S545) + { + _S536 = int(0); + _S535 = &points_4[int(1)]; + _S534 = &points_4[int(0)]; + _S533 = nullptr; + _S532 = nullptr; + _S531 = _S541; + break; + } + float3 raydir_5 = unproject_raydir_0(uv_u_9, camera_model_8, is_ray_depth_7); + points_4[int(2)] = make_float3 (depths_2.z) * raydir_5; + float2 uv_23 = (pix_center_3 + make_float2 (0.0f, 1.0f) - _S537) / _S538; + FixedArray _S546 = dist_coeffs_10; + float2 uv_u_10; + bool _S547 = undistort_point_0(uv_23, &_S546, int(12), &uv_u_10); + if(!_S547) + { + _S536 = int(0); + _S535 = &points_4[int(1)]; + _S534 = &points_4[int(0)]; + _S533 = nullptr; + _S532 = &points_4[int(2)]; + _S531 = _S541; + break; + } + float3 raydir_6 = unproject_raydir_0(uv_u_10, camera_model_8, is_ray_depth_7); + points_4[int(3)] = make_float3 (depths_2.w) * raydir_6; + float2 uv_24 = (pix_center_3 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S537) / _S538; + FixedArray _S548 = dist_coeffs_10; + float2 uv_u_11; + bool _S549 = undistort_point_0(uv_24, &_S548, int(12), &uv_u_11); + if(!_S549) + { + _S536 = int(0); + _S535 = &points_4[int(1)]; + _S534 = &points_4[int(0)]; + _S533 = &points_4[int(3)]; + _S532 = &points_4[int(2)]; + _S531 = _S541; + break; + } + float3 raydir_7 = unproject_raydir_0(uv_u_11, camera_model_8, is_ray_depth_7); + _S536 = int(1); + _S535 = &points_4[int(1)]; + _S534 = &points_4[int(0)]; + _S533 = &points_4[int(3)]; + _S532 = &points_4[int(2)]; + _S531 = raydir_7; + break; + } + if(_S536 != int(1)) + { + _S530 = 0.0f; + break; + } + float3 normal_4 = cross_0(*_S535 - *_S534, - (*_S533 - *_S532)); + float3 normal_5; + if((dot_0(normal_4, normal_4)) != 0.0f) + { + normal_5 = normalize_0(normal_4); + } + else + { + normal_5 = normal_4; + } + float3 _S550; + if((dot_0(gt_normal_0, gt_normal_0)) != 0.0f) + { + _S550 = normalize_0(gt_normal_0); + } + else + { + _S550 = gt_normal_0; + } + _S530 = (1.0f - dot_0(normal_5, _S550) + 0.00100000004749745f) / ((F32_max((dot_0(normal_5, - normalize_0(_S531))), (0.0f))) + 0.00100000004749745f); + break; + } + return _S530; +} + +struct s_bwd_prop_depth_normal_loss_Intermediates_0 +{ + float2 _S551; + bool _S552; + float2 _S553; + bool _S554; + float2 _S555; + bool _S556; + float2 _S557; + bool _S558; + float2 _S559; + bool _S560; +}; + +inline __device__ void s_bwd_prop_normalize_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_8, float3 _s_dOut_6) +{ + float _S561 = length_0((*dpx_8).primal_0); + float3 _S562 = (*dpx_8).primal_0 * _s_dOut_6; + float3 _S563 = make_float3 (1.0f / _S561) * _s_dOut_6; + float _S564 = - ((_S562.x + _S562.y + _S562.z) / (_S561 * _S561)); + float3 _S565 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S566; + (&_S566)->primal_0 = (*dpx_8).primal_0; + (&_S566)->differential_0 = _S565; + s_bwd_length_impl_0(&_S566, _S564); + float3 _S567 = _S563 + _S566.differential_0; + dpx_8->primal_0 = (*dpx_8).primal_0; + dpx_8->differential_0 = _S567; + return; +} + +inline __device__ void s_bwd_normalize_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S568, float3 _S569) +{ + s_bwd_prop_normalize_impl_0(_S568, _S569); + return; +} + +inline __device__ void depth_normal_loss_vjp_none(float2 pix_center_4, float4 intrins_7, FixedArray dist_coeffs_11, int camera_model_9, bool is_ray_depth_8, float4 depths_3, float3 gt_normal_1, float v_loss_0, float4 * v_depths_1, float3 * v_gt_normal_0) +{ + float2 _S570 = make_float2 (0.0f); + s_bwd_prop_depth_normal_loss_Intermediates_0 _S571; + (&_S571)->_S551 = _S570; + (&_S571)->_S552 = false; + (&_S571)->_S553 = _S570; + (&_S571)->_S554 = false; + (&_S571)->_S555 = _S570; + (&_S571)->_S556 = false; + (&_S571)->_S557 = _S570; + (&_S571)->_S558 = false; + (&_S571)->_S559 = _S570; + (&_S571)->_S560 = false; + (&_S571)->_S553 = _S570; + (&_S571)->_S554 = false; + (&_S571)->_S555 = _S570; + (&_S571)->_S556 = false; + (&_S571)->_S557 = _S570; + (&_S571)->_S558 = false; + (&_S571)->_S559 = _S570; + (&_S571)->_S560 = false; + float2 _S572 = float2 {intrins_7.z, intrins_7.w}; + float2 _S573 = float2 {intrins_7.x, intrins_7.y}; + float2 uv_25 = (pix_center_4 + make_float2 (-1.0f, -0.0f) - _S572) / _S573; + float2 _S574 = _S570; + FixedArray _S575 = dist_coeffs_11; + bool _S576 = undistort_point_0(uv_25, &_S575, int(12), &_S574); + (&_S571)->_S551 = _S574; + (&_S571)->_S552 = _S576; + bool _S577 = !!_S576; + bool _runFlag_4; + if(_S577) + { + float2 uv_26 = (pix_center_4 + make_float2 (1.0f, -0.0f) - _S572) / _S573; + float2 _S578 = _S570; + FixedArray _S579 = dist_coeffs_11; + bool _S580 = undistort_point_0(uv_26, &_S579, int(12), &_S578); + (&_S571)->_S553 = _S578; + (&_S571)->_S554 = _S580; + if(!_S580) { _runFlag_4 = false; } else { - _runFlag_4 = _S410; + _runFlag_4 = _S577; } if(_runFlag_4) { - float3 dx_1 = points_4[int(1)] - points_4[int(0)]; - float3 _S439 = - (points_4[int(3)] - points_4[int(2)]); - float3 _S440 = s_primal_ctx_cross_0(dx_1, _S439); - bool _S441 = (s_primal_ctx_dot_0(_S440, _S440)) != 0.0f; - if(_S441) + float2 uv_27 = (pix_center_4 + make_float2 (0.0f, -1.0f) - _S572) / _S573; + float2 _S581 = _S570; + FixedArray _S582 = dist_coeffs_11; + bool _S583 = undistort_point_0(uv_27, &_S582, int(12), &_S581); + (&_S571)->_S555 = _S581; + (&_S571)->_S556 = _S583; + if(!_S583) { - float _S442 = length_1(_S440); - float3 _S443 = make_float3 (_S442); - _S418 = make_float3 (_S442 * _S442); - _S419 = _S443; + _runFlag_4 = false; } - else - { - _S418 = _S409; - _S419 = _S409; - } - float3 _S444 = _S419; - _S412 = _S441; - _S419 = _S440; - _S420 = _S444; - _S421 = dx_1; - _S422 = _S439; - } - else - { - _S412 = false; - _S418 = _S409; - _S419 = _S409; - _S420 = _S409; - _S421 = _S409; - _S422 = _S409; - } - bool _S445 = _runFlag_1; - bool _S446 = _runFlag_2; - bool _S447 = _runFlag_3; - float3 _S448 = _S414; - float3 _S449 = _S415; - bool _S450 = _S411; - float3 _S451 = _S416; - float3 _S452 = _S417; - _runFlag_1 = _runFlag_4; - _runFlag_2 = _S412; - _S414 = _S418; - _S415 = _S419; - _S416 = _S420; - _S417 = _S421; - _S418 = _S422; - _runFlag_3 = _S424; - _S411 = _S445; - _runFlag_4 = _S446; - _S412 = _S447; - _S419 = _S448; - _S420 = _S449; - _S413 = _S450; - _S421 = _S451; - _S422 = _S452; - } - else - { - _runFlag_1 = false; - _runFlag_2 = false; - _S414 = _S409; - _S415 = _S409; - _S416 = _S409; - _S417 = _S409; - _S418 = _S409; - _runFlag_3 = false; - _S411 = false; - _runFlag_4 = false; - _S412 = false; - _S419 = _S409; - _S420 = _S409; - _S413 = false; - _S421 = _S409; - _S422 = _S409; - } - float4 _S453 = make_float4 (0.0f); - float4 _S454; - if(_S410) - { - if(_runFlag_1) - { - if(_runFlag_2) - { - float3 _S455 = _s_dOut_7 / _S414; - float3 _S456 = _S415 * - _S455; - float3 _S457 = _S416 * _S455; - float _S458 = _S456.x + _S456.y + _S456.z; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S459; - (&_S459)->primal_0 = _S415; - (&_S459)->differential_0 = _S409; - s_bwd_length_impl_0(&_S459, _S458); - _S414 = _S457 + _S459.differential_0; - } - else - { - _S414 = _s_dOut_7; - } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S460; - (&_S460)->primal_0 = _S415; - (&_S460)->differential_0 = _S409; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S461; - (&_S461)->primal_0 = _S415; - (&_S461)->differential_0 = _S409; - s_bwd_prop_dot_0(&_S460, &_S461, 0.0f); - float3 _S462 = _S461.differential_0 + _S460.differential_0 + _S414; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S463; - (&_S463)->primal_0 = _S417; - (&_S463)->differential_0 = _S409; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S464; - (&_S464)->primal_0 = _S418; - (&_S464)->differential_0 = _S409; - s_bwd_prop_cross_0(&_S463, &_S464, _S462); - float3 s_diff_dy_T_1 = - _S464.differential_0; - float3 _S465 = - s_diff_dy_T_1; - float3 _S466 = - _S463.differential_0; - FixedArray _S467; - _S467[int(0)] = _S409; - _S467[int(1)] = _S409; - _S467[int(2)] = _S409; - _S467[int(3)] = _S409; - _S467[int(2)] = _S465; - _S467[int(3)] = s_diff_dy_T_1; - _S467[int(0)] = _S466; - _S467[int(1)] = _S463.differential_0; - points_4[int(0)] = _S467[int(0)]; - points_4[int(1)] = _S467[int(1)]; - points_4[int(2)] = _S467[int(2)]; - points_4[int(3)] = _S467[int(3)]; - } - else - { - points_4[int(0)] = _S409; - points_4[int(1)] = _S409; - points_4[int(2)] = _S409; - points_4[int(3)] = _S409; - } - if(_runFlag_3) - { - if(_S411) + if(_runFlag_4) { + float2 uv_28 = (pix_center_4 + make_float2 (0.0f, 1.0f) - _S572) / _S573; + float2 _S584 = _S570; + FixedArray _S585 = dist_coeffs_11; + bool _S586 = undistort_point_0(uv_28, &_S585, int(12), &_S584); + (&_S571)->_S557 = _S584; + (&_S571)->_S558 = _S586; + if(!_S586) + { + _runFlag_4 = false; + } if(_runFlag_4) { - FixedArray _S468 = points_4; - FixedArray _S469 = points_4; - FixedArray _S470 = points_4; - FixedArray _S471 = points_4; - if(_S412) - { - float3 _S472 = _S419 * _S471[int(3)]; - float _S473 = _S472.x + _S472.y + _S472.z; - float4 _S474 = _S453; - *&((&_S474)->w) = _S473; - points_4[int(0)] = _S468[int(0)]; - points_4[int(1)] = _S469[int(1)]; - points_4[int(2)] = _S470[int(2)]; - points_4[int(3)] = _S409; - _S454 = _S474; - } - else - { - points_4[int(0)] = _S468[int(0)]; - points_4[int(1)] = _S469[int(1)]; - points_4[int(2)] = _S470[int(2)]; - points_4[int(3)] = _S471[int(3)]; - _S454 = _S453; - } - float3 _S475 = _S420 * points_4[int(2)]; - float _S476 = _S475.x + _S475.y + _S475.z; - FixedArray _S477 = points_4; - FixedArray _S478 = points_4; - float4 _S479 = _S453; - *&((&_S479)->z) = _S476; - float4 _S480 = _S454 + _S479; - points_4[int(0)] = points_4[int(0)]; - points_4[int(1)] = _S477[int(1)]; - points_4[int(2)] = _S409; - points_4[int(3)] = _S478[int(3)]; - _S454 = _S480; - } - else - { - FixedArray _S481 = points_4; - FixedArray _S482 = points_4; - FixedArray _S483 = points_4; - points_4[int(0)] = points_4[int(0)]; - points_4[int(1)] = _S481[int(1)]; - points_4[int(2)] = _S482[int(2)]; - points_4[int(3)] = _S483[int(3)]; - _S454 = _S453; + float2 uv_29 = (pix_center_4 - _S572) / _S573; + float2 _S587 = _S570; + FixedArray _S588 = dist_coeffs_11; + bool _S589 = undistort_point_0(uv_29, &_S588, int(12), &_S587); + (&_S571)->_S559 = _S587; + (&_S571)->_S560 = _S589; } } - else - { - FixedArray _S484 = points_4; - FixedArray _S485 = points_4; - FixedArray _S486 = points_4; - points_4[int(0)] = points_4[int(0)]; - points_4[int(1)] = _S484[int(1)]; - points_4[int(2)] = _S485[int(2)]; - points_4[int(3)] = _S486[int(3)]; - _S454 = _S453; - } - if(_S413) - { - FixedArray _S487 = points_4; - float3 _S488 = _S421 * points_4[int(1)]; - float _S489 = _S488.x + _S488.y + _S488.z; - float4 _S490 = _S453; - *&((&_S490)->y) = _S489; - float4 _S491 = _S454 + _S490; - points_4[int(0)] = _S409; - points_4[int(1)] = _S409; - points_4[int(2)] = _S409; - points_4[int(3)] = _S409; - _S414 = _S487[int(0)]; - _S454 = _S491; - } - else - { - FixedArray _S492 = points_4; - FixedArray _S493 = points_4; - FixedArray _S494 = points_4; - points_4[int(0)] = points_4[int(0)]; - points_4[int(1)] = _S492[int(1)]; - points_4[int(2)] = _S493[int(2)]; - points_4[int(3)] = _S494[int(3)]; - _S414 = _S409; - } - float3 _S495 = _S422 * (points_4[int(0)] + _S414); - float _S496 = _S495.x + _S495.y + _S495.z; - float4 _S497 = _S453; - *&((&_S497)->x) = _S496; - _S454 = _S454 + _S497; - } - else - { - _S454 = _S453; } } - else - { - _S454 = _S453; - } - dpdepths_1->primal_0 = (*dpdepths_1).primal_0; - dpdepths_1->differential_0 = _S454; - return; -} - -inline __device__ void s_bwd_depth_to_normal_0(float2 _S498, float4 _S499, FixedArray * _S500, int _S501, bool _S502, DiffPair_vectorx3Cfloatx2C4x3E_0 * _S503, float3 _S504) -{ - s_bwd_prop_depth_to_normal_Intermediates_0 _S505; - float3 _S506 = s_primal_ctx_depth_to_normal_0(_S498, _S499, _S500, _S501, _S502, (*_S503).primal_0, &_S505); - s_bwd_prop_depth_to_normal_Intermediates_0 _S507 = _S505; - s_bwd_prop_depth_to_normal_0(_S498, _S499, _S500, _S501, _S502, _S503, _S504, &_S507); - return; -} - -inline __device__ void depth_to_normal_vjp(float2 pix_center_3, float4 intrins_8, FixedArray dist_coeffs_9, int camera_model_10, bool is_ray_depth_10, float4 depths_1, float3 v_normal_1, float4 * v_depths_0) -{ - float4 _S508 = make_float4 (0.0f); - DiffPair_vectorx3Cfloatx2C4x3E_0 dp_depths_0; - (&dp_depths_0)->primal_0 = depths_1; - (&dp_depths_0)->differential_0 = _S508; - FixedArray _S509 = dist_coeffs_9; - s_bwd_depth_to_normal_0(pix_center_3, intrins_8, &_S509, camera_model_10, is_ray_depth_10, &dp_depths_0, v_normal_1); - *v_depths_0 = dp_depths_0.differential_0; - return; -} - -inline __device__ float ray_depth_to_linear_depth_factor(float2 pix_center_4, float4 intrins_9, FixedArray dist_coeffs_10, int camera_model_11) -{ - float2 _S510 = (pix_center_4 - float2 {intrins_9.z, intrins_9.w}) / float2 {intrins_9.x, intrins_9.y}; - float2 uv_13 = _S510; - FixedArray _S511 = dist_coeffs_10; - bool _S512 = undistort_point_0(_S510, &_S511, int(12), &uv_13); - if(!_S512) - { - return 0.0f; - } - float3 raydir_2 = unproject_raydir_0(uv_13, camera_model_11, false); - return float((F32_sign((raydir_2.z)))) / length_1(raydir_2); -} - -inline __device__ float depth_normal_loss(float2 pix_center_5, float4 intrins_10, FixedArray dist_coeffs_11, int camera_model_12, bool is_ray_depth_11, float4 depths_2, float3 gt_normal_0) -{ - FixedArray points_5; - float2 _S513 = float2 {intrins_10.z, intrins_10.w}; - float2 _S514 = float2 {intrins_10.x, intrins_10.y}; - float2 _S515 = (pix_center_5 + make_float2 (-1.0f, -0.0f) - _S513) / _S514; - float2 uv_14 = _S515; - FixedArray _S516 = dist_coeffs_11; - bool _S517 = undistort_point_0(_S515, &_S516, int(12), &uv_14); - if(!_S517) - { - return 0.0f; - } - float3 raydir_3 = unproject_raydir_0(uv_14, camera_model_12, is_ray_depth_11); - points_5[int(0)] = make_float3 (depths_2.x) * raydir_3; - float2 _S518 = (pix_center_5 + make_float2 (1.0f, -0.0f) - _S513) / _S514; - float2 uv_15 = _S518; - FixedArray _S519 = dist_coeffs_11; - bool _S520 = undistort_point_0(_S518, &_S519, int(12), &uv_15); - if(!_S520) - { - return 0.0f; - } - float3 raydir_4 = unproject_raydir_0(uv_15, camera_model_12, is_ray_depth_11); - points_5[int(1)] = make_float3 (depths_2.y) * raydir_4; - float2 _S521 = (pix_center_5 + make_float2 (0.0f, -1.0f) - _S513) / _S514; - float2 uv_16 = _S521; - FixedArray _S522 = dist_coeffs_11; - bool _S523 = undistort_point_0(_S521, &_S522, int(12), &uv_16); - if(!_S523) - { - return 0.0f; - } - float3 raydir_5 = unproject_raydir_0(uv_16, camera_model_12, is_ray_depth_11); - points_5[int(2)] = make_float3 (depths_2.z) * raydir_5; - float2 _S524 = (pix_center_5 + make_float2 (0.0f, 1.0f) - _S513) / _S514; - float2 uv_17 = _S524; - FixedArray _S525 = dist_coeffs_11; - bool _S526 = undistort_point_0(_S524, &_S525, int(12), &uv_17); - if(!_S526) - { - return 0.0f; - } - float3 raydir_6 = unproject_raydir_0(uv_17, camera_model_12, is_ray_depth_11); - points_5[int(3)] = make_float3 (depths_2.w) * raydir_6; - float2 _S527 = (pix_center_5 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S513) / _S514; - float2 uv_18 = _S527; - FixedArray _S528 = dist_coeffs_11; - bool _S529 = undistort_point_0(_S527, &_S528, int(12), &uv_18); - if(!_S529) - { - return 0.0f; - } - float3 raydir_7 = unproject_raydir_0(uv_18, camera_model_12, is_ray_depth_11); - float3 normal_5 = cross_0(points_5[int(1)] - points_5[int(0)], - (points_5[int(3)] - points_5[int(2)])); - float3 normal_6; - if((dot_0(normal_5, normal_5)) != 0.0f) - { - normal_6 = normalize_0(normal_5); - } - else - { - normal_6 = normal_5; - } - float3 _S530; - if((dot_0(gt_normal_0, gt_normal_0)) != 0.0f) - { - _S530 = normalize_0(gt_normal_0); - } - else - { - _S530 = gt_normal_0; - } - return (1.0f - dot_0(normal_6, _S530) + 0.00100000004749745f) / ((F32_max((dot_0(normal_6, - normalize_0(raydir_7))), (0.0f))) + 0.00100000004749745f); -} - -struct s_bwd_prop_depth_normal_loss_Intermediates_0 -{ - float2 _S531; - bool _S532; - float2 _S533; - bool _S534; - float2 _S535; - bool _S536; - float2 _S537; - bool _S538; - float2 _S539; - bool _S540; -}; - -inline __device__ float s_primal_ctx_depth_normal_loss_0(float2 pix_center_6, float4 intrins_11, FixedArray * dist_coeffs_12, int camera_model_13, bool is_ray_depth_12, float4 dpdepths_2, float3 dpgt_normal_0, s_bwd_prop_depth_normal_loss_Intermediates_0 * _s_diff_ctx_4) -{ - float2 _S541 = make_float2 (0.0f); - _s_diff_ctx_4->_S531 = _S541; - _s_diff_ctx_4->_S532 = false; - _s_diff_ctx_4->_S533 = _S541; - _s_diff_ctx_4->_S534 = false; - _s_diff_ctx_4->_S535 = _S541; - _s_diff_ctx_4->_S536 = false; - _s_diff_ctx_4->_S537 = _S541; - _s_diff_ctx_4->_S538 = false; - _s_diff_ctx_4->_S539 = _S541; - _s_diff_ctx_4->_S540 = false; - _s_diff_ctx_4->_S533 = _S541; - _s_diff_ctx_4->_S534 = false; - _s_diff_ctx_4->_S535 = _S541; - _s_diff_ctx_4->_S536 = false; - _s_diff_ctx_4->_S537 = _S541; - _s_diff_ctx_4->_S538 = false; - _s_diff_ctx_4->_S539 = _S541; - _s_diff_ctx_4->_S540 = false; - float3 _S542 = make_float3 (0.0f); - float2 _S543 = float2 {intrins_11.z, intrins_11.w}; - float2 _S544 = float2 {intrins_11.x, intrins_11.y}; - float2 _S545 = (pix_center_6 + make_float2 (-1.0f, -0.0f) - _S543) / _S544; - float2 _S546 = _S545; - bool _S547 = undistort_point_0(_S545, dist_coeffs_12, int(12), &_S546); - _s_diff_ctx_4->_S531 = _S546; - _s_diff_ctx_4->_S532 = _S547; - float2 uv_19 = _S546; - bool _S548 = !!_S547; - int _S549; + s_bwd_prop_depth_normal_loss_Intermediates_0 _S590 = _S571; + float3 _S591 = make_float3 (0.0f); + bool _S592 = !!_S571._S552; + bool _runFlag_5; + bool _runFlag_6; + bool _runFlag_7; + int _S593; float3 raydir_8; - FixedArray points_6; - if(_S548) + float3 _S594; + float3 _S595; + float3 _S596; + float3 _S597; + FixedArray points_5; + if(_S592) { - float3 _S550 = s_primal_ctx_unproject_raydir_0(uv_19, camera_model_13, is_ray_depth_12); - float3 _S551 = make_float3 (dpdepths_2.x) * _S550; - float2 _S552 = (pix_center_6 + make_float2 (1.0f, -0.0f) - _S543) / _S544; - float2 _S553 = _S552; - bool _S554 = undistort_point_0(_S552, dist_coeffs_12, int(12), &_S553); - _s_diff_ctx_4->_S533 = _S553; - _s_diff_ctx_4->_S534 = _S554; - float2 uv_20 = _S553; - bool _runFlag_5; - if(!_S554) + float3 _S598 = s_primal_ctx_unproject_raydir_0(_S590._S551, camera_model_9, is_ray_depth_8); + float3 _S599 = make_float3 (depths_3.x) * _S598; + if(!_S590._S554) { - _runFlag_5 = false; + _runFlag_4 = false; } else { - _runFlag_5 = _S548; + _runFlag_4 = _S592; } - if(_runFlag_5) + if(_runFlag_4) { - float3 _S555 = s_primal_ctx_unproject_raydir_0(uv_20, camera_model_13, is_ray_depth_12); - float3 _S556 = make_float3 (dpdepths_2.y) * _S555; - float2 _S557 = (pix_center_6 + make_float2 (0.0f, -1.0f) - _S543) / _S544; - float2 _S558 = _S557; - bool _S559 = undistort_point_0(_S557, dist_coeffs_12, int(12), &_S558); - _s_diff_ctx_4->_S535 = _S558; - _s_diff_ctx_4->_S536 = _S559; - float2 uv_21 = _S558; - if(!_S559) + float3 _S600 = s_primal_ctx_unproject_raydir_0(_S590._S553, camera_model_9, is_ray_depth_8); + float3 _S601 = make_float3 (depths_3.y) * _S600; + if(!_S590._S556) { _runFlag_5 = false; } + else + { + _runFlag_5 = _runFlag_4; + } if(_runFlag_5) { - float3 _S560 = s_primal_ctx_unproject_raydir_0(uv_21, camera_model_13, is_ray_depth_12); - float3 _S561 = make_float3 (dpdepths_2.z) * _S560; - float2 _S562 = (pix_center_6 + make_float2 (0.0f, 1.0f) - _S543) / _S544; - float2 _S563 = _S562; - bool _S564 = undistort_point_0(_S562, dist_coeffs_12, int(12), &_S563); - _s_diff_ctx_4->_S537 = _S563; - _s_diff_ctx_4->_S538 = _S564; - float2 uv_22 = _S563; - if(!_S564) + float3 _S602 = s_primal_ctx_unproject_raydir_0(_S590._S555, camera_model_9, is_ray_depth_8); + float3 _S603 = make_float3 (depths_3.z) * _S602; + if(!_S590._S558) { - _runFlag_5 = false; - } - if(_runFlag_5) - { - float3 _S565 = s_primal_ctx_unproject_raydir_0(uv_22, camera_model_13, is_ray_depth_12); - float3 _S566 = make_float3 (dpdepths_2.w) * _S565; - float2 _S567 = (pix_center_6 - _S543) / _S544; - float2 _S568 = _S567; - bool _S569 = undistort_point_0(_S567, dist_coeffs_12, int(12), &_S568); - _s_diff_ctx_4->_S539 = _S568; - _s_diff_ctx_4->_S540 = _S569; - float2 uv_23 = _S568; - if(!_S569) - { - _runFlag_5 = false; - } - if(_runFlag_5) - { - float3 _S570 = s_primal_ctx_unproject_raydir_0(uv_23, camera_model_13, is_ray_depth_12); - _S549 = int(1); - raydir_8 = _S570; - } - else - { - _S549 = int(0); - raydir_8 = _S565; - } - points_6[int(0)] = _S551; - points_6[int(1)] = _S556; - points_6[int(2)] = _S561; - points_6[int(3)] = _S566; - points_6[int(4)] = _S542; + _runFlag_6 = false; } else { - _S549 = int(0); - raydir_8 = _S560; - points_6[int(0)] = _S551; - points_6[int(1)] = _S556; - points_6[int(2)] = _S561; - points_6[int(3)] = _S542; - points_6[int(4)] = _S542; + _runFlag_6 = _runFlag_5; } + if(_runFlag_6) + { + float3 _S604 = s_primal_ctx_unproject_raydir_0(_S590._S557, camera_model_9, is_ray_depth_8); + float3 _S605 = make_float3 (depths_3.w) * _S604; + if(!_S590._S560) + { + _runFlag_7 = false; + } + else + { + _runFlag_7 = _runFlag_6; + } + if(_runFlag_7) + { + float3 _S606 = s_primal_ctx_unproject_raydir_0(_S590._S559, camera_model_9, is_ray_depth_8); + _S593 = int(1); + raydir_8 = _S606; + } + else + { + _S593 = int(0); + raydir_8 = _S604; + } + points_5[int(0)] = _S599; + points_5[int(1)] = _S601; + points_5[int(2)] = _S603; + points_5[int(3)] = _S605; + points_5[int(4)] = _S591; + _S594 = _S604; + } + else + { + _S593 = int(0); + raydir_8 = _S602; + points_5[int(0)] = _S599; + points_5[int(1)] = _S601; + points_5[int(2)] = _S603; + points_5[int(3)] = _S591; + points_5[int(4)] = _S591; + _S594 = _S591; + } + _S595 = _S602; } else { - _S549 = int(0); - raydir_8 = _S555; - points_6[int(0)] = _S551; - points_6[int(1)] = _S556; - points_6[int(2)] = _S542; - points_6[int(3)] = _S542; - points_6[int(4)] = _S542; + _S593 = int(0); + raydir_8 = _S600; + points_5[int(0)] = _S599; + points_5[int(1)] = _S601; + points_5[int(2)] = _S591; + points_5[int(3)] = _S591; + points_5[int(4)] = _S591; + _runFlag_6 = false; + _S594 = _S591; + _S595 = _S591; } + _S596 = _S600; } else { - _S549 = int(0); - raydir_8 = _S550; - points_6[int(0)] = _S551; - points_6[int(1)] = _S542; - points_6[int(2)] = _S542; - points_6[int(3)] = _S542; - points_6[int(4)] = _S542; - } - } - else - { - _S549 = int(0); - points_6[int(0)] = _S542; - points_6[int(1)] = _S542; - points_6[int(2)] = _S542; - points_6[int(3)] = _S542; - points_6[int(4)] = _S542; - } - float _S571; - if(!(_S549 != int(1))) - { - float3 _S572 = s_primal_ctx_cross_0(points_6[int(1)] - points_6[int(0)], - (points_6[int(3)] - points_6[int(2)])); - float3 normal_7; - if((s_primal_ctx_dot_0(_S572, _S572)) != 0.0f) - { - normal_7 = normalize_0(_S572); - } - else - { - normal_7 = _S572; - } - float3 _S573; - if((s_primal_ctx_dot_0(dpgt_normal_0, dpgt_normal_0)) != 0.0f) - { - _S573 = normalize_0(dpgt_normal_0); - } - else - { - _S573 = dpgt_normal_0; - } - _S571 = (1.0f - s_primal_ctx_dot_0(normal_7, _S573) + 0.00100000004749745f) / ((F32_max((s_primal_ctx_dot_0(normal_7, - normalize_0(raydir_8))), (0.0f))) + 0.00100000004749745f); - } - else - { - _S571 = 0.0f; - } - return _S571; -} - -inline __device__ void s_bwd_prop_normalize_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_8, float3 _s_dOut_8) -{ - float _S574 = length_1((*dpx_8).primal_0); - float3 _S575 = (*dpx_8).primal_0 * _s_dOut_8; - float3 _S576 = make_float3 (1.0f / _S574) * _s_dOut_8; - float _S577 = - ((_S575.x + _S575.y + _S575.z) / (_S574 * _S574)); - float3 _S578 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S579; - (&_S579)->primal_0 = (*dpx_8).primal_0; - (&_S579)->differential_0 = _S578; - s_bwd_length_impl_0(&_S579, _S577); - float3 _S580 = _S576 + _S579.differential_0; - dpx_8->primal_0 = (*dpx_8).primal_0; - dpx_8->differential_0 = _S580; - return; -} - -inline __device__ void s_bwd_normalize_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S581, float3 _S582) -{ - s_bwd_prop_normalize_impl_0(_S581, _S582); - return; -} - -inline __device__ void s_bwd_prop_depth_normal_loss_0(float2 pix_center_7, float4 intrins_12, FixedArray * dist_coeffs_13, int camera_model_14, bool is_ray_depth_13, DiffPair_vectorx3Cfloatx2C4x3E_0 * dpdepths_3, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpgt_normal_1, float _s_dOut_9, s_bwd_prop_depth_normal_loss_Intermediates_0 * _s_diff_ctx_5) -{ - DiffPair_vectorx3Cfloatx2C4x3E_0 _S583 = *dpdepths_3; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S584 = *dpgt_normal_1; - float3 _S585 = make_float3 (0.0f); - float2 _S586 = _s_diff_ctx_5->_S531; - bool _S587 = !!_s_diff_ctx_5->_S532; - bool _runFlag_6; - bool _runFlag_7; - bool _runFlag_8; - bool _runFlag_9; - int _S588; - float3 raydir_9; - float3 _S589; - float3 _S590; - float3 _S591; - float3 _S592; - FixedArray points_7; - if(_S587) - { - float3 _S593 = s_primal_ctx_unproject_raydir_0(_S586, camera_model_14, is_ray_depth_13); - float3 _S594 = make_float3 (_S583.primal_0.x) * _S593; - float2 _S595 = _s_diff_ctx_5->_S533; - if(!_s_diff_ctx_5->_S534) - { + _S593 = int(0); + raydir_8 = _S598; + points_5[int(0)] = _S599; + points_5[int(1)] = _S591; + points_5[int(2)] = _S591; + points_5[int(3)] = _S591; + points_5[int(4)] = _S591; + _runFlag_5 = false; _runFlag_6 = false; + _S594 = _S591; + _S595 = _S591; + _S596 = _S591; } - else - { - _runFlag_6 = _S587; - } - if(_runFlag_6) - { - float3 _S596 = s_primal_ctx_unproject_raydir_0(_S595, camera_model_14, is_ray_depth_13); - float3 _S597 = make_float3 (_S583.primal_0.y) * _S596; - float2 _S598 = _s_diff_ctx_5->_S535; - if(!_s_diff_ctx_5->_S536) - { - _runFlag_7 = false; - } - else - { - _runFlag_7 = _runFlag_6; - } - if(_runFlag_7) - { - float3 _S599 = s_primal_ctx_unproject_raydir_0(_S598, camera_model_14, is_ray_depth_13); - float3 _S600 = make_float3 (_S583.primal_0.z) * _S599; - float2 _S601 = _s_diff_ctx_5->_S537; - if(!_s_diff_ctx_5->_S538) - { - _runFlag_8 = false; - } - else - { - _runFlag_8 = _runFlag_7; - } - if(_runFlag_8) - { - float3 _S602 = s_primal_ctx_unproject_raydir_0(_S601, camera_model_14, is_ray_depth_13); - float3 _S603 = make_float3 (_S583.primal_0.w) * _S602; - float2 _S604 = _s_diff_ctx_5->_S539; - if(!_s_diff_ctx_5->_S540) - { - _runFlag_9 = false; - } - else - { - _runFlag_9 = _runFlag_8; - } - if(_runFlag_9) - { - float3 _S605 = s_primal_ctx_unproject_raydir_0(_S604, camera_model_14, is_ray_depth_13); - _S588 = int(1); - raydir_9 = _S605; - } - else - { - _S588 = int(0); - raydir_9 = _S602; - } - points_7[int(0)] = _S594; - points_7[int(1)] = _S597; - points_7[int(2)] = _S600; - points_7[int(3)] = _S603; - points_7[int(4)] = _S585; - _S589 = _S602; - } - else - { - _S588 = int(0); - raydir_9 = _S599; - points_7[int(0)] = _S594; - points_7[int(1)] = _S597; - points_7[int(2)] = _S600; - points_7[int(3)] = _S585; - points_7[int(4)] = _S585; - _S589 = _S585; - } - _S590 = _S599; - } - else - { - _S588 = int(0); - raydir_9 = _S596; - points_7[int(0)] = _S594; - points_7[int(1)] = _S597; - points_7[int(2)] = _S585; - points_7[int(3)] = _S585; - points_7[int(4)] = _S585; - _runFlag_8 = false; - _S589 = _S585; - _S590 = _S585; - } - _S591 = _S596; - } - else - { - _S588 = int(0); - raydir_9 = _S593; - points_7[int(0)] = _S594; - points_7[int(1)] = _S585; - points_7[int(2)] = _S585; - points_7[int(3)] = _S585; - points_7[int(4)] = _S585; - _runFlag_7 = false; - _runFlag_8 = false; - _S589 = _S585; - _S590 = _S585; - _S591 = _S585; - } - _S592 = _S593; + _S597 = _S598; } else { - _S588 = int(0); - points_7[int(0)] = _S585; - points_7[int(1)] = _S585; - points_7[int(2)] = _S585; - points_7[int(3)] = _S585; - points_7[int(4)] = _S585; + _S593 = int(0); + points_5[int(0)] = _S591; + points_5[int(1)] = _S591; + points_5[int(2)] = _S591; + points_5[int(3)] = _S591; + points_5[int(4)] = _S591; + _runFlag_4 = false; + _runFlag_5 = false; _runFlag_6 = false; - _runFlag_7 = false; - _runFlag_8 = false; - _S589 = _S585; - _S590 = _S585; - _S591 = _S585; - _S592 = _S585; + _S594 = _S591; + _S595 = _S591; + _S596 = _S591; + _S597 = _S591; } - bool _S606 = !(_S588 != int(1)); - bool _S607; - float3 normal_8; - float3 _S608; + bool _S607 = !(_S593 != int(1)); + bool _S608; + float3 normal_6; float3 _S609; float3 _S610; float3 _S611; - float _S612; + float3 _S612; float _S613; float _S614; float _S615; - if(_S606) + float _S616; + if(_S607) { - float3 dx_2 = points_7[int(1)] - points_7[int(0)]; - float3 _S616 = - (points_7[int(3)] - points_7[int(2)]); - float3 _S617 = s_primal_ctx_cross_0(dx_2, _S616); - bool _S618 = (s_primal_ctx_dot_0(_S617, _S617)) != 0.0f; - if(_S618) - { - normal_8 = normalize_0(_S617); - } - else - { - normal_8 = _S617; - } - bool _S619 = (s_primal_ctx_dot_0(_S584.primal_0, _S584.primal_0)) != 0.0f; + float3 dx_2 = points_5[int(1)] - points_5[int(0)]; + float3 _S617 = - (points_5[int(3)] - points_5[int(2)]); + float3 _S618 = s_primal_ctx_cross_0(dx_2, _S617); + bool _S619 = (s_primal_ctx_dot_0(_S618, _S618)) != 0.0f; if(_S619) { - _S608 = normalize_0(_S584.primal_0); + normal_6 = normalize_0(_S618); } else { - _S608 = _S584.primal_0; + normal_6 = _S618; } - float3 _S620 = - normalize_0(raydir_9); - float _S621 = s_primal_ctx_dot_0(normal_8, _S620); - float _S622 = 1.0f - s_primal_ctx_dot_0(normal_8, _S608) + 0.00100000004749745f; - float _S623 = (F32_max((_S621), (0.0f))) + 0.00100000004749745f; - _S612 = _S623 * _S623; - _S613 = _S622; + bool _S620 = (s_primal_ctx_dot_0(gt_normal_1, gt_normal_1)) != 0.0f; + if(_S620) + { + _S609 = normalize_0(gt_normal_1); + } + else + { + _S609 = gt_normal_1; + } + float3 _S621 = - normalize_0(raydir_8); + float _S622 = s_primal_ctx_dot_0(normal_6, _S621); + float _S623 = 1.0f - s_primal_ctx_dot_0(normal_6, _S609) + 0.00100000004749745f; + float _S624 = (F32_max((_S622), (0.0f))) + 0.00100000004749745f; + _S613 = _S624 * _S624; _S614 = _S623; - _S615 = _S621; - raydir_9 = normal_8; - normal_8 = _S620; - _runFlag_9 = _S619; - _S607 = _S618; - _S609 = _S617; - _S610 = dx_2; - _S611 = _S616; + _S615 = _S624; + _S616 = _S622; + raydir_8 = normal_6; + normal_6 = _S621; + _runFlag_7 = _S620; + _S608 = _S619; + _S610 = _S618; + _S611 = dx_2; + _S612 = _S617; } else { - _S612 = 0.0f; _S613 = 0.0f; _S614 = 0.0f; _S615 = 0.0f; - raydir_9 = _S585; - normal_8 = _S585; - _S608 = _S585; - _runFlag_9 = false; - _S607 = false; - _S609 = _S585; - _S610 = _S585; - _S611 = _S585; + _S616 = 0.0f; + raydir_8 = _S591; + normal_6 = _S591; + _S609 = _S591; + _runFlag_7 = false; + _S608 = false; + _S610 = _S591; + _S611 = _S591; + _S612 = _S591; } - float4 _S624 = make_float4 (0.0f); - if(_S606) + float4 _S625 = make_float4 (0.0f); + if(_S607) { - float _S625 = _s_dOut_9 / _S612; - float _S626 = _S613 * - _S625; - float s_diff_num_T_0 = _S614 * _S625; - DiffPair_float_0 _S627; - (&_S627)->primal_0 = _S615; - (&_S627)->differential_0 = 0.0f; + float _S626 = v_loss_0 / _S613; + float _S627 = _S614 * - _S626; + float s_diff_num_T_0 = _S615 * _S626; DiffPair_float_0 _S628; - (&_S628)->primal_0 = 0.0f; + (&_S628)->primal_0 = _S616; (&_S628)->differential_0 = 0.0f; - _d_max_0(&_S627, &_S628, _S626); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S629; - (&_S629)->primal_0 = raydir_9; - (&_S629)->differential_0 = _S585; + DiffPair_float_0 _S629; + (&_S629)->primal_0 = 0.0f; + (&_S629)->differential_0 = 0.0f; + _d_max_0(&_S628, &_S629, _S627); DiffPair_vectorx3Cfloatx2C3x3E_0 _S630; - (&_S630)->primal_0 = normal_8; - (&_S630)->differential_0 = _S585; - s_bwd_prop_dot_0(&_S629, &_S630, _S627.differential_0); - float _S631 = - s_diff_num_T_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S632; - (&_S632)->primal_0 = raydir_9; - (&_S632)->differential_0 = _S585; + (&_S630)->primal_0 = raydir_8; + (&_S630)->differential_0 = _S591; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S631; + (&_S631)->primal_0 = normal_6; + (&_S631)->differential_0 = _S591; + s_bwd_prop_dot_0(&_S630, &_S631, _S628.differential_0); + float _S632 = - s_diff_num_T_0; DiffPair_vectorx3Cfloatx2C3x3E_0 _S633; - (&_S633)->primal_0 = _S608; - (&_S633)->differential_0 = _S585; - s_bwd_prop_dot_0(&_S632, &_S633, _S631); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S634 = _S633; - float3 _S635 = _S629.differential_0 + _S632.differential_0; - if(_runFlag_9) + (&_S633)->primal_0 = raydir_8; + (&_S633)->differential_0 = _S591; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S634; + (&_S634)->primal_0 = _S609; + (&_S634)->differential_0 = _S591; + s_bwd_prop_dot_0(&_S633, &_S634, _S632); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S635 = _S634; + float3 _S636 = _S630.differential_0 + _S633.differential_0; + if(_runFlag_7) { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S636; - (&_S636)->primal_0 = _S584.primal_0; - (&_S636)->differential_0 = _S585; - s_bwd_normalize_impl_0(&_S636, _S634.differential_0); - raydir_9 = _S636.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S637; + (&_S637)->primal_0 = gt_normal_1; + (&_S637)->differential_0 = _S591; + s_bwd_normalize_impl_0(&_S637, _S635.differential_0); + raydir_8 = _S637.differential_0; } else { - raydir_9 = _S634.differential_0; + raydir_8 = _S635.differential_0; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S637; - (&_S637)->primal_0 = _S584.primal_0; - (&_S637)->differential_0 = _S585; DiffPair_vectorx3Cfloatx2C3x3E_0 _S638; - (&_S638)->primal_0 = _S584.primal_0; - (&_S638)->differential_0 = _S585; - s_bwd_prop_dot_0(&_S637, &_S638, 0.0f); - float3 _S639 = _S638.differential_0 + _S637.differential_0 + raydir_9; - if(_S607) + (&_S638)->primal_0 = gt_normal_1; + (&_S638)->differential_0 = _S591; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S639; + (&_S639)->primal_0 = gt_normal_1; + (&_S639)->differential_0 = _S591; + s_bwd_prop_dot_0(&_S638, &_S639, 0.0f); + float3 _S640 = _S639.differential_0 + _S638.differential_0 + raydir_8; + if(_S608) { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S640; - (&_S640)->primal_0 = _S609; - (&_S640)->differential_0 = _S585; - s_bwd_normalize_impl_0(&_S640, _S635); - raydir_9 = _S640.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S641; + (&_S641)->primal_0 = _S610; + (&_S641)->differential_0 = _S591; + s_bwd_normalize_impl_0(&_S641, _S636); + raydir_8 = _S641.differential_0; } else { - raydir_9 = _S635; + raydir_8 = _S636; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S641; - (&_S641)->primal_0 = _S609; - (&_S641)->differential_0 = _S585; DiffPair_vectorx3Cfloatx2C3x3E_0 _S642; - (&_S642)->primal_0 = _S609; - (&_S642)->differential_0 = _S585; - s_bwd_prop_dot_0(&_S641, &_S642, 0.0f); - float3 _S643 = _S642.differential_0 + _S641.differential_0 + raydir_9; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S644; - (&_S644)->primal_0 = _S610; - (&_S644)->differential_0 = _S585; + (&_S642)->primal_0 = _S610; + (&_S642)->differential_0 = _S591; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S643; + (&_S643)->primal_0 = _S610; + (&_S643)->differential_0 = _S591; + s_bwd_prop_dot_0(&_S642, &_S643, 0.0f); + float3 _S644 = _S643.differential_0 + _S642.differential_0 + raydir_8; DiffPair_vectorx3Cfloatx2C3x3E_0 _S645; (&_S645)->primal_0 = _S611; - (&_S645)->differential_0 = _S585; - s_bwd_prop_cross_0(&_S644, &_S645, _S643); - float3 s_diff_dy_T_2 = - _S645.differential_0; - float3 _S646 = - s_diff_dy_T_2; - float3 _S647 = - _S644.differential_0; - FixedArray _S648; - _S648[int(0)] = _S585; - _S648[int(1)] = _S585; - _S648[int(2)] = _S585; - _S648[int(3)] = _S585; - _S648[int(4)] = _S585; - _S648[int(2)] = _S646; - _S648[int(3)] = s_diff_dy_T_2; - _S648[int(0)] = _S647; - _S648[int(1)] = _S644.differential_0; - points_7[int(0)] = _S648[int(0)]; - points_7[int(1)] = _S648[int(1)]; - points_7[int(2)] = _S648[int(2)]; - points_7[int(3)] = _S648[int(3)]; - points_7[int(4)] = _S648[int(4)]; - raydir_9 = _S639; + (&_S645)->differential_0 = _S591; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S646; + (&_S646)->primal_0 = _S612; + (&_S646)->differential_0 = _S591; + s_bwd_prop_cross_0(&_S645, &_S646, _S644); + float3 s_diff_dy_T_2 = - _S646.differential_0; + float3 _S647 = - s_diff_dy_T_2; + float3 _S648 = - _S645.differential_0; + FixedArray _S649; + _S649[int(0)] = _S591; + _S649[int(1)] = _S591; + _S649[int(2)] = _S591; + _S649[int(3)] = _S591; + _S649[int(4)] = _S591; + _S649[int(2)] = _S647; + _S649[int(3)] = s_diff_dy_T_2; + _S649[int(0)] = _S648; + _S649[int(1)] = _S645.differential_0; + points_5[int(0)] = _S649[int(0)]; + points_5[int(1)] = _S649[int(1)]; + points_5[int(2)] = _S649[int(2)]; + points_5[int(3)] = _S649[int(3)]; + points_5[int(4)] = _S649[int(4)]; + raydir_8 = _S640; } else { - points_7[int(0)] = _S585; - points_7[int(1)] = _S585; - points_7[int(2)] = _S585; - points_7[int(3)] = _S585; - points_7[int(4)] = _S585; - raydir_9 = _S585; + points_5[int(0)] = _S591; + points_5[int(1)] = _S591; + points_5[int(2)] = _S591; + points_5[int(3)] = _S591; + points_5[int(4)] = _S591; + raydir_8 = _S591; } - float4 _S649; - if(_S587) + float4 _S650; + if(_S592) { - if(_runFlag_6) + if(_runFlag_4) { - if(_runFlag_7) + if(_runFlag_5) { - if(_runFlag_8) + if(_runFlag_6) { - FixedArray _S650 = points_7; - FixedArray _S651 = points_7; - FixedArray _S652 = points_7; - float3 _S653 = _S589 * points_7[int(3)]; - float _S654 = _S653.x + _S653.y + _S653.z; - float4 _S655 = _S624; - *&((&_S655)->w) = _S654; - points_7[int(0)] = _S585; - points_7[int(1)] = _S585; - points_7[int(2)] = _S585; - points_7[int(3)] = _S585; - points_7[int(4)] = _S585; - _S589 = _S652[int(2)]; - normal_8 = _S650[int(0)]; - _S608 = _S651[int(1)]; - _S649 = _S655; + FixedArray _S651 = points_5; + FixedArray _S652 = points_5; + FixedArray _S653 = points_5; + float3 _S654 = _S594 * points_5[int(3)]; + float _S655 = _S654.x + _S654.y + _S654.z; + float4 _S656 = _S625; + *&((&_S656)->w) = _S655; + points_5[int(0)] = _S591; + points_5[int(1)] = _S591; + points_5[int(2)] = _S591; + points_5[int(3)] = _S591; + points_5[int(4)] = _S591; + _S594 = _S653[int(2)]; + normal_6 = _S651[int(0)]; + _S609 = _S652[int(1)]; + _S650 = _S656; } else { - FixedArray _S656 = points_7; - FixedArray _S657 = points_7; - FixedArray _S658 = points_7; - FixedArray _S659 = points_7; - points_7[int(0)] = points_7[int(0)]; - points_7[int(1)] = _S656[int(1)]; - points_7[int(2)] = _S657[int(2)]; - points_7[int(3)] = _S658[int(3)]; - points_7[int(4)] = _S659[int(4)]; - _S589 = _S585; - normal_8 = _S585; - _S608 = _S585; - _S649 = _S624; + FixedArray _S657 = points_5; + FixedArray _S658 = points_5; + FixedArray _S659 = points_5; + FixedArray _S660 = points_5; + points_5[int(0)] = points_5[int(0)]; + points_5[int(1)] = _S657[int(1)]; + points_5[int(2)] = _S658[int(2)]; + points_5[int(3)] = _S659[int(3)]; + points_5[int(4)] = _S660[int(4)]; + _S594 = _S591; + normal_6 = _S591; + _S609 = _S591; + _S650 = _S625; } - float3 _S660 = _S590 * (points_7[int(2)] + _S589); - float _S661 = _S660.x + _S660.y + _S660.z; - float3 _S662 = points_7[int(0)] + normal_8; - float3 _S663 = points_7[int(1)] + _S608; - float4 _S664 = _S624; - *&((&_S664)->z) = _S661; - float4 _S665 = _S649 + _S664; - points_7[int(0)] = _S585; - points_7[int(1)] = _S585; - points_7[int(2)] = _S585; - points_7[int(3)] = _S585; - points_7[int(4)] = _S585; - _S589 = _S663; - _S590 = _S662; - _S649 = _S665; + float3 _S661 = _S595 * (points_5[int(2)] + _S594); + float _S662 = _S661.x + _S661.y + _S661.z; + float3 _S663 = points_5[int(0)] + normal_6; + float3 _S664 = points_5[int(1)] + _S609; + float4 _S665 = _S625; + *&((&_S665)->z) = _S662; + float4 _S666 = _S650 + _S665; + points_5[int(0)] = _S591; + points_5[int(1)] = _S591; + points_5[int(2)] = _S591; + points_5[int(3)] = _S591; + points_5[int(4)] = _S591; + _S594 = _S664; + _S595 = _S663; + _S650 = _S666; } else { - FixedArray _S666 = points_7; - FixedArray _S667 = points_7; - FixedArray _S668 = points_7; - FixedArray _S669 = points_7; - points_7[int(0)] = points_7[int(0)]; - points_7[int(1)] = _S666[int(1)]; - points_7[int(2)] = _S667[int(2)]; - points_7[int(3)] = _S668[int(3)]; - points_7[int(4)] = _S669[int(4)]; - _S589 = _S585; - _S590 = _S585; - _S649 = _S624; + FixedArray _S667 = points_5; + FixedArray _S668 = points_5; + FixedArray _S669 = points_5; + FixedArray _S670 = points_5; + points_5[int(0)] = points_5[int(0)]; + points_5[int(1)] = _S667[int(1)]; + points_5[int(2)] = _S668[int(2)]; + points_5[int(3)] = _S669[int(3)]; + points_5[int(4)] = _S670[int(4)]; + _S594 = _S591; + _S595 = _S591; + _S650 = _S625; } - float3 _S670 = _S591 * (points_7[int(1)] + _S589); - float _S671 = _S670.x + _S670.y + _S670.z; - float3 _S672 = points_7[int(0)] + _S590; - float4 _S673 = _S624; - *&((&_S673)->y) = _S671; - float4 _S674 = _S649 + _S673; - points_7[int(0)] = _S585; - points_7[int(1)] = _S585; - points_7[int(2)] = _S585; - points_7[int(3)] = _S585; - points_7[int(4)] = _S585; - _S589 = _S672; - _S649 = _S674; + float3 _S671 = _S596 * (points_5[int(1)] + _S594); + float _S672 = _S671.x + _S671.y + _S671.z; + float3 _S673 = points_5[int(0)] + _S595; + float4 _S674 = _S625; + *&((&_S674)->y) = _S672; + float4 _S675 = _S650 + _S674; + points_5[int(0)] = _S591; + points_5[int(1)] = _S591; + points_5[int(2)] = _S591; + points_5[int(3)] = _S591; + points_5[int(4)] = _S591; + _S594 = _S673; + _S650 = _S675; } else { - FixedArray _S675 = points_7; - FixedArray _S676 = points_7; - FixedArray _S677 = points_7; - FixedArray _S678 = points_7; - points_7[int(0)] = points_7[int(0)]; - points_7[int(1)] = _S675[int(1)]; - points_7[int(2)] = _S676[int(2)]; - points_7[int(3)] = _S677[int(3)]; - points_7[int(4)] = _S678[int(4)]; - _S589 = _S585; - _S649 = _S624; + FixedArray _S676 = points_5; + FixedArray _S677 = points_5; + FixedArray _S678 = points_5; + FixedArray _S679 = points_5; + points_5[int(0)] = points_5[int(0)]; + points_5[int(1)] = _S676[int(1)]; + points_5[int(2)] = _S677[int(2)]; + points_5[int(3)] = _S678[int(3)]; + points_5[int(4)] = _S679[int(4)]; + _S594 = _S591; + _S650 = _S625; } - float3 _S679 = _S592 * (points_7[int(0)] + _S589); - float _S680 = _S679.x + _S679.y + _S679.z; - float4 _S681 = _S624; - *&((&_S681)->x) = _S680; - _S649 = _S649 + _S681; + float3 _S680 = _S597 * (points_5[int(0)] + _S594); + float _S681 = _S680.x + _S680.y + _S680.z; + float4 _S682 = _S625; + *&((&_S682)->x) = _S681; + _S650 = _S650 + _S682; } else { - _S649 = _S624; + _S650 = _S625; } - dpgt_normal_1->primal_0 = (*dpgt_normal_1).primal_0; - dpgt_normal_1->differential_0 = raydir_9; - dpdepths_3->primal_0 = (*dpdepths_3).primal_0; - dpdepths_3->differential_0 = _S649; + *v_depths_1 = _S650; + *v_gt_normal_0 = raydir_8; return; } -inline __device__ void s_bwd_depth_normal_loss_0(float2 _S682, float4 _S683, FixedArray * _S684, int _S685, bool _S686, DiffPair_vectorx3Cfloatx2C4x3E_0 * _S687, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S688, float _S689) +inline __device__ float3 generate_ray_d2n_opencv(float2 pix_pos_3, float4 intrins_8, FixedArray dist_coeffs_12, int camera_model_10, bool is_ray_depth_9) { - s_bwd_prop_depth_normal_loss_Intermediates_0 _S690; - float _S691 = s_primal_ctx_depth_normal_loss_0(_S682, _S683, _S684, _S685, _S686, (*_S687).primal_0, (*_S688).primal_0, &_S690); - s_bwd_prop_depth_normal_loss_Intermediates_0 _S692 = _S690; - s_bwd_prop_depth_normal_loss_0(_S682, _S683, _S684, _S685, _S686, _S687, _S688, _S689, &_S692); - return; + float3 _S683; + for(;;) + { + float2 uv_30 = (pix_pos_3 - float2 {intrins_8.z, intrins_8.w}) / float2 {intrins_8.x, intrins_8.y}; + FixedArray _S684 = dist_coeffs_12; + float2 uv_u_12; + bool _S685 = undistort_point_1(uv_30, &_S684, int(12), &uv_u_12); + if(!_S685) + { + int3 _S686 = make_int3 (int(0)); + float3 _S687 = make_float3 ((float)_S686.x, (float)_S686.y, (float)_S686.z); + _S683 = _S687; + break; + } + _S683 = unproject_raydir_0(uv_u_12, camera_model_10, is_ray_depth_9); + break; + } + return _S683; } -inline __device__ void depth_normal_loss_vjp(float2 pix_center_8, float4 intrins_13, FixedArray dist_coeffs_14, int camera_model_15, bool is_ray_depth_14, float4 depths_3, float3 gt_normal_1, float v_loss_0, float4 * v_depths_1, float3 * v_gt_normal_0) +inline __device__ float3 depth_to_point_opencv(float2 pix_pos_4, float4 intrins_9, FixedArray dist_coeffs_13, int camera_model_11, bool is_ray_depth_10, float depth_4) { - float4 _S693 = make_float4 (0.0f); - DiffPair_vectorx3Cfloatx2C4x3E_0 dp_depths_1; - (&dp_depths_1)->primal_0 = depths_3; - (&dp_depths_1)->differential_0 = _S693; - float3 _S694 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 dp_gt_normal_0; - (&dp_gt_normal_0)->primal_0 = gt_normal_1; - (&dp_gt_normal_0)->differential_0 = _S694; - FixedArray _S695 = dist_coeffs_14; - s_bwd_depth_normal_loss_0(pix_center_8, intrins_13, &_S695, camera_model_15, is_ray_depth_14, &dp_depths_1, &dp_gt_normal_0, v_loss_0); - *v_depths_1 = dp_depths_1.differential_0; - *v_gt_normal_0 = dp_gt_normal_0.differential_0; + float3 _S688; + for(;;) + { + float2 uv_31 = (pix_pos_4 - float2 {intrins_9.z, intrins_9.w}) / float2 {intrins_9.x, intrins_9.y}; + FixedArray _S689 = dist_coeffs_13; + float2 uv_u_13; + bool _S690 = undistort_point_1(uv_31, &_S689, int(12), &uv_u_13); + if(!_S690) + { + _S688 = make_float3 (0.0f); + break; + } + _S688 = make_float3 (depth_4) * unproject_raydir_0(uv_u_13, camera_model_11, is_ray_depth_10); + break; + } + return _S688; +} + +struct s_bwd_prop_depth_to_point_Intermediates_1 +{ + float2 _S691; + bool _S692; +}; + +inline __device__ float depth_to_point_vjp_opencv(float2 pix_pos_5, float4 intrins_10, FixedArray dist_coeffs_14, int camera_model_12, bool is_ray_depth_11, float depth_5, float3 v_point_1) +{ + float2 _S693 = make_float2 (0.0f); + s_bwd_prop_depth_to_point_Intermediates_1 _S694; + (&_S694)->_S691 = _S693; + (&_S694)->_S692 = false; + float2 uv_32 = (pix_pos_5 - float2 {intrins_10.z, intrins_10.w}) / float2 {intrins_10.x, intrins_10.y}; + float2 _S695 = _S693; + FixedArray _S696 = dist_coeffs_14; + bool _S697 = undistort_point_1(uv_32, &_S696, int(12), &_S695); + (&_S694)->_S691 = _S695; + (&_S694)->_S692 = _S697; + s_bwd_prop_depth_to_point_Intermediates_1 _S698 = _S694; + float3 _S699 = make_float3 (0.0f); + bool _S700 = !!_S694._S692; + float3 _S701; + if(_S700) + { + _S701 = s_primal_ctx_unproject_raydir_0(_S698._S691, camera_model_12, is_ray_depth_11); + } + else + { + _S701 = _S699; + } + if(_S700) + { + _S701 = _S701 * v_point_1; + } + else + { + _S701 = _S699; + } + return _S701.x + _S701.y + _S701.z; +} + +inline __device__ float3 depth_to_normal_opencv(float2 pix_center_5, float4 intrins_11, FixedArray dist_coeffs_15, int camera_model_13, bool is_ray_depth_12, float4 depths_4) +{ + float3 normal_7; + for(;;) + { + bool _S702; + if((depths_4.x) == 0.0f) + { + _S702 = true; + } + else + { + _S702 = (depths_4.y) == 0.0f; + } + if(_S702) + { + _S702 = true; + } + else + { + _S702 = (depths_4.z) == 0.0f; + } + if(_S702) + { + _S702 = true; + } + else + { + _S702 = (depths_4.w) == 0.0f; + } + if(_S702) + { + normal_7 = make_float3 (0.0f); + break; + } + float3 * _S703; + float3 * _S704; + float3 * _S705; + float3 * _S706; + int _S707; + FixedArray points_6; + for(;;) + { + float2 _S708 = float2 {intrins_11.z, intrins_11.w}; + float2 _S709 = float2 {intrins_11.x, intrins_11.y}; + float2 uv_33 = (pix_center_5 + make_float2 (-1.0f, -0.0f) - _S708) / _S709; + FixedArray _S710 = dist_coeffs_15; + float2 uv_u_14; + bool _S711 = undistort_point_1(uv_33, &_S710, int(12), &uv_u_14); + if(!_S711) + { + float3 _S712 = make_float3 (0.0f); + _S707 = int(0); + _S706 = nullptr; + _S705 = nullptr; + _S704 = nullptr; + _S703 = nullptr; + normal_7 = _S712; + break; + } + points_6[int(0)] = make_float3 (depths_4.x) * unproject_raydir_0(uv_u_14, camera_model_13, is_ray_depth_12); + for(;;) + { + float2 uv_34 = (pix_center_5 + make_float2 (1.0f, -0.0f) - _S708) / _S709; + FixedArray _S713 = dist_coeffs_15; + float2 uv_u_15; + bool _S714 = undistort_point_1(uv_34, &_S713, int(12), &uv_u_15); + if(!_S714) + { + float3 _S715 = make_float3 (0.0f); + _S707 = int(0); + _S706 = nullptr; + normal_7 = _S715; + break; + } + points_6[int(1)] = make_float3 (depths_4.y) * unproject_raydir_0(uv_u_15, camera_model_13, is_ray_depth_12); + _S707 = int(2); + _S706 = &points_6[int(1)]; + break; + } + if(_S707 != int(2)) + { + _S705 = &points_6[int(0)]; + _S704 = nullptr; + _S703 = nullptr; + break; + } + float2 uv_35 = (pix_center_5 + make_float2 (0.0f, -1.0f) - _S708) / _S709; + FixedArray _S716 = dist_coeffs_15; + float2 uv_u_16; + bool _S717 = undistort_point_1(uv_35, &_S716, int(12), &uv_u_16); + if(!_S717) + { + float3 _S718 = make_float3 (0.0f); + _S707 = int(0); + _S705 = &points_6[int(0)]; + _S704 = nullptr; + _S703 = nullptr; + normal_7 = _S718; + break; + } + points_6[int(2)] = make_float3 (depths_4.z) * unproject_raydir_0(uv_u_16, camera_model_13, is_ray_depth_12); + for(;;) + { + float2 uv_36 = (pix_center_5 + make_float2 (0.0f, 1.0f) - _S708) / _S709; + FixedArray _S719 = dist_coeffs_15; + float2 uv_u_17; + bool _S720 = undistort_point_1(uv_36, &_S719, int(12), &uv_u_17); + if(!_S720) + { + float3 _S721 = make_float3 (0.0f); + _S707 = int(0); + _S705 = nullptr; + normal_7 = _S721; + break; + } + points_6[int(3)] = make_float3 (depths_4.w) * unproject_raydir_0(uv_u_17, camera_model_13, is_ray_depth_12); + _S707 = int(2); + _S705 = &points_6[int(3)]; + break; + } + if(_S707 != int(2)) + { + float3 * _S722 = _S705; + _S705 = &points_6[int(0)]; + _S704 = _S722; + _S703 = &points_6[int(2)]; + break; + } + float3 * _S723 = _S705; + _S707 = int(1); + _S705 = &points_6[int(0)]; + _S704 = _S723; + _S703 = &points_6[int(2)]; + break; + } + if(_S707 != int(1)) + { + break; + } + float3 normal_8 = cross_0(*_S706 - *_S705, - (*_S704 - *_S703)); + if((dot_0(normal_8, normal_8)) != 0.0f) + { + normal_7 = normal_8 / make_float3 (length_0(normal_8)); + } + else + { + normal_7 = normal_8; + } + break; + } + return normal_7; +} + +struct s_bwd_prop_depth_to_normal_Intermediates_1 +{ + float2 _S724; + bool _S725; + float2 _S726; + bool _S727; + float2 _S728; + bool _S729; + float2 _S730; + bool _S731; +}; + +inline __device__ void depth_to_normal_vjp_opencv(float2 pix_center_6, float4 intrins_12, FixedArray dist_coeffs_16, int camera_model_14, bool is_ray_depth_13, float4 depths_5, float3 v_normal_2, float4 * v_depths_2) +{ + float2 _S732 = make_float2 (0.0f); + s_bwd_prop_depth_to_normal_Intermediates_1 _S733; + (&_S733)->_S724 = _S732; + (&_S733)->_S725 = false; + (&_S733)->_S726 = _S732; + (&_S733)->_S727 = false; + (&_S733)->_S728 = _S732; + (&_S733)->_S729 = false; + (&_S733)->_S730 = _S732; + (&_S733)->_S731 = false; + (&_S733)->_S724 = _S732; + (&_S733)->_S725 = false; + (&_S733)->_S726 = _S732; + (&_S733)->_S727 = false; + (&_S733)->_S728 = _S732; + (&_S733)->_S729 = false; + (&_S733)->_S730 = _S732; + (&_S733)->_S731 = false; + bool _S734 = (depths_5.x) == 0.0f; + bool _runFlag_8; + if(_S734) + { + _runFlag_8 = true; + } + else + { + _runFlag_8 = (depths_5.y) == 0.0f; + } + if(_runFlag_8) + { + _runFlag_8 = true; + } + else + { + _runFlag_8 = (depths_5.z) == 0.0f; + } + if(_runFlag_8) + { + _runFlag_8 = true; + } + else + { + _runFlag_8 = (depths_5.w) == 0.0f; + } + int _S735; + if(!_runFlag_8) + { + float2 _S736 = float2 {intrins_12.z, intrins_12.w}; + float2 _S737 = float2 {intrins_12.x, intrins_12.y}; + float2 uv_37 = (pix_center_6 + make_float2 (-1.0f, -0.0f) - _S736) / _S737; + float2 _S738 = _S732; + FixedArray _S739 = dist_coeffs_16; + bool _S740 = undistort_point_1(uv_37, &_S739, int(12), &_S738); + (&_S733)->_S724 = _S738; + (&_S733)->_S725 = _S740; + bool _S741 = !!_S740; + if(_S741) + { + float2 uv_38 = (pix_center_6 + make_float2 (1.0f, -0.0f) - _S736) / _S737; + float2 _S742 = _S732; + FixedArray _S743 = dist_coeffs_16; + bool _S744 = undistort_point_1(uv_38, &_S743, int(12), &_S742); + (&_S733)->_S726 = _S742; + (&_S733)->_S727 = _S744; + if(!!_S744) + { + _S735 = int(2); + } + else + { + _S735 = int(0); + } + if(_S735 != int(2)) + { + _runFlag_8 = false; + } + else + { + _runFlag_8 = _S741; + } + if(_runFlag_8) + { + float2 uv_39 = (pix_center_6 + make_float2 (0.0f, -1.0f) - _S736) / _S737; + float2 _S745 = _S732; + FixedArray _S746 = dist_coeffs_16; + bool _S747 = undistort_point_1(uv_39, &_S746, int(12), &_S745); + (&_S733)->_S728 = _S745; + (&_S733)->_S729 = _S747; + if(!_S747) + { + _runFlag_8 = false; + } + if(_runFlag_8) + { + float2 uv_40 = (pix_center_6 + make_float2 (0.0f, 1.0f) - _S736) / _S737; + float2 _S748 = _S732; + FixedArray _S749 = dist_coeffs_16; + bool _S750 = undistort_point_1(uv_40, &_S749, int(12), &_S748); + (&_S733)->_S730 = _S748; + (&_S733)->_S731 = _S750; + } + } + } + } + s_bwd_prop_depth_to_normal_Intermediates_1 _S751 = _S733; + float3 _S752 = make_float3 (0.0f); + if(_S734) + { + _runFlag_8 = true; + } + else + { + _runFlag_8 = (depths_5.y) == 0.0f; + } + if(_runFlag_8) + { + _runFlag_8 = true; + } + else + { + _runFlag_8 = (depths_5.z) == 0.0f; + } + if(_runFlag_8) + { + _runFlag_8 = true; + } + else + { + _runFlag_8 = (depths_5.w) == 0.0f; + } + bool _S753 = !_runFlag_8; + bool _runFlag_9; + bool _runFlag_10; + bool _S754; + bool _runFlag_11; + bool _S755; + bool _S756; + FixedArray points_7; + float3 _S757; + float3 _S758; + float3 _S759; + float3 _S760; + float3 _S761; + float3 _S762; + float3 _S763; + float3 _S764; + float3 _S765; + if(_S753) + { + bool _S766 = !!_S751._S725; + if(_S766) + { + float3 _S767 = s_primal_ctx_unproject_raydir_0(_S751._S724, camera_model_14, is_ray_depth_13); + float3 _S768 = make_float3 (depths_5.x) * _S767; + bool _S769 = !!_S751._S727; + if(_S769) + { + float3 _S770 = s_primal_ctx_unproject_raydir_0(_S751._S726, camera_model_14, is_ray_depth_13); + float3 _S771 = make_float3 (depths_5.y) * _S770; + _S735 = int(2); + points_7[int(0)] = _S768; + points_7[int(1)] = _S771; + points_7[int(2)] = _S752; + points_7[int(3)] = _S752; + _S757 = _S770; + } + else + { + _S735 = int(0); + points_7[int(0)] = _S768; + points_7[int(1)] = _S752; + points_7[int(2)] = _S752; + points_7[int(3)] = _S752; + _S757 = _S752; + } + if(_S735 != int(2)) + { + _runFlag_8 = false; + } + else + { + _runFlag_8 = _S766; + _S735 = int(0); + } + if(_runFlag_8) + { + if(!_S751._S729) + { + _runFlag_9 = false; + _S735 = int(0); + } + else + { + _runFlag_9 = _runFlag_8; + } + if(_runFlag_9) + { + float3 _S772 = s_primal_ctx_unproject_raydir_0(_S751._S728, camera_model_14, is_ray_depth_13); + points_7[int(2)] = make_float3 (depths_5.z) * _S772; + bool _S773 = !!_S751._S731; + int _S774; + if(_S773) + { + float3 _S775 = s_primal_ctx_unproject_raydir_0(_S751._S730, camera_model_14, is_ray_depth_13); + points_7[int(3)] = make_float3 (depths_5.w) * _S775; + _S774 = int(2); + _S758 = _S775; + } + else + { + _S774 = int(0); + _S758 = _S752; + } + if(_S774 != int(2)) + { + _runFlag_10 = false; + _S735 = _S774; + } + else + { + _runFlag_10 = _runFlag_9; + } + if(_runFlag_10) + { + _S735 = int(1); + } + _runFlag_10 = _S773; + _S759 = _S772; + } + else + { + _runFlag_10 = false; + _S758 = _S752; + _S759 = _S752; + } + } + else + { + _runFlag_9 = false; + _runFlag_10 = false; + _S758 = _S752; + _S759 = _S752; + } + float3 _S776 = _S757; + _S757 = _S758; + _S758 = _S759; + _S754 = _S769; + _S759 = _S776; + _S760 = _S767; + } + else + { + _S735 = int(0); + points_7[int(0)] = _S752; + points_7[int(1)] = _S752; + points_7[int(2)] = _S752; + points_7[int(3)] = _S752; + _runFlag_8 = false; + _runFlag_9 = false; + _runFlag_10 = false; + _S757 = _S752; + _S758 = _S752; + _S754 = false; + _S759 = _S752; + _S760 = _S752; + } + if(_S735 != int(1)) + { + _runFlag_11 = false; + } + else + { + _runFlag_11 = _S753; + } + if(_runFlag_11) + { + float3 dx_3 = points_7[int(1)] - points_7[int(0)]; + float3 _S777 = - (points_7[int(3)] - points_7[int(2)]); + float3 _S778 = s_primal_ctx_cross_0(dx_3, _S777); + bool _S779 = (s_primal_ctx_dot_0(_S778, _S778)) != 0.0f; + if(_S779) + { + float _S780 = length_0(_S778); + float3 _S781 = make_float3 (_S780); + _S761 = make_float3 (_S780 * _S780); + _S762 = _S781; + } + else + { + _S761 = _S752; + _S762 = _S752; + } + float3 _S782 = _S762; + _S755 = _S779; + _S762 = _S778; + _S763 = _S782; + _S764 = dx_3; + _S765 = _S777; + } + else + { + _S755 = false; + _S761 = _S752; + _S762 = _S752; + _S763 = _S752; + _S764 = _S752; + _S765 = _S752; + } + bool _S783 = _runFlag_8; + bool _S784 = _runFlag_9; + bool _S785 = _runFlag_10; + float3 _S786 = _S757; + float3 _S787 = _S758; + bool _S788 = _S754; + float3 _S789 = _S759; + float3 _S790 = _S760; + _runFlag_8 = _runFlag_11; + _runFlag_9 = _S755; + _S757 = _S761; + _S758 = _S762; + _S759 = _S763; + _S760 = _S764; + _S761 = _S765; + _runFlag_10 = _S766; + _S754 = _S783; + _runFlag_11 = _S784; + _S755 = _S785; + _S762 = _S786; + _S763 = _S787; + _S756 = _S788; + _S764 = _S789; + _S765 = _S790; + } + else + { + _runFlag_8 = false; + _runFlag_9 = false; + _S757 = _S752; + _S758 = _S752; + _S759 = _S752; + _S760 = _S752; + _S761 = _S752; + _runFlag_10 = false; + _S754 = false; + _runFlag_11 = false; + _S755 = false; + _S762 = _S752; + _S763 = _S752; + _S756 = false; + _S764 = _S752; + _S765 = _S752; + } + float4 _S791 = make_float4 (0.0f); + float4 _S792; + if(_S753) + { + if(_runFlag_8) + { + if(_runFlag_9) + { + float3 _S793 = v_normal_2 / _S757; + float3 _S794 = _S758 * - _S793; + float3 _S795 = _S759 * _S793; + float _S796 = _S794.x + _S794.y + _S794.z; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S797; + (&_S797)->primal_0 = _S758; + (&_S797)->differential_0 = _S752; + s_bwd_length_impl_0(&_S797, _S796); + _S757 = _S795 + _S797.differential_0; + } + else + { + _S757 = v_normal_2; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S798; + (&_S798)->primal_0 = _S758; + (&_S798)->differential_0 = _S752; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S799; + (&_S799)->primal_0 = _S758; + (&_S799)->differential_0 = _S752; + s_bwd_prop_dot_0(&_S798, &_S799, 0.0f); + float3 _S800 = _S799.differential_0 + _S798.differential_0 + _S757; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S801; + (&_S801)->primal_0 = _S760; + (&_S801)->differential_0 = _S752; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S802; + (&_S802)->primal_0 = _S761; + (&_S802)->differential_0 = _S752; + s_bwd_prop_cross_0(&_S801, &_S802, _S800); + float3 s_diff_dy_T_3 = - _S802.differential_0; + float3 _S803 = - s_diff_dy_T_3; + float3 _S804 = - _S801.differential_0; + FixedArray _S805; + _S805[int(0)] = _S752; + _S805[int(1)] = _S752; + _S805[int(2)] = _S752; + _S805[int(3)] = _S752; + _S805[int(2)] = _S803; + _S805[int(3)] = s_diff_dy_T_3; + _S805[int(0)] = _S804; + _S805[int(1)] = _S801.differential_0; + points_7[int(0)] = _S805[int(0)]; + points_7[int(1)] = _S805[int(1)]; + points_7[int(2)] = _S805[int(2)]; + points_7[int(3)] = _S805[int(3)]; + } + else + { + points_7[int(0)] = _S752; + points_7[int(1)] = _S752; + points_7[int(2)] = _S752; + points_7[int(3)] = _S752; + } + if(_runFlag_10) + { + if(_S754) + { + if(_runFlag_11) + { + FixedArray _S806 = points_7; + FixedArray _S807 = points_7; + FixedArray _S808 = points_7; + FixedArray _S809 = points_7; + if(_S755) + { + float3 _S810 = _S762 * _S809[int(3)]; + float _S811 = _S810.x + _S810.y + _S810.z; + float4 _S812 = _S791; + *&((&_S812)->w) = _S811; + points_7[int(0)] = _S806[int(0)]; + points_7[int(1)] = _S807[int(1)]; + points_7[int(2)] = _S808[int(2)]; + points_7[int(3)] = _S752; + _S792 = _S812; + } + else + { + points_7[int(0)] = _S806[int(0)]; + points_7[int(1)] = _S807[int(1)]; + points_7[int(2)] = _S808[int(2)]; + points_7[int(3)] = _S809[int(3)]; + _S792 = _S791; + } + float3 _S813 = _S763 * points_7[int(2)]; + float _S814 = _S813.x + _S813.y + _S813.z; + FixedArray _S815 = points_7; + FixedArray _S816 = points_7; + float4 _S817 = _S791; + *&((&_S817)->z) = _S814; + float4 _S818 = _S792 + _S817; + points_7[int(0)] = points_7[int(0)]; + points_7[int(1)] = _S815[int(1)]; + points_7[int(2)] = _S752; + points_7[int(3)] = _S816[int(3)]; + _S792 = _S818; + } + else + { + FixedArray _S819 = points_7; + FixedArray _S820 = points_7; + FixedArray _S821 = points_7; + points_7[int(0)] = points_7[int(0)]; + points_7[int(1)] = _S819[int(1)]; + points_7[int(2)] = _S820[int(2)]; + points_7[int(3)] = _S821[int(3)]; + _S792 = _S791; + } + } + else + { + FixedArray _S822 = points_7; + FixedArray _S823 = points_7; + FixedArray _S824 = points_7; + points_7[int(0)] = points_7[int(0)]; + points_7[int(1)] = _S822[int(1)]; + points_7[int(2)] = _S823[int(2)]; + points_7[int(3)] = _S824[int(3)]; + _S792 = _S791; + } + if(_S756) + { + FixedArray _S825 = points_7; + float3 _S826 = _S764 * points_7[int(1)]; + float _S827 = _S826.x + _S826.y + _S826.z; + float4 _S828 = _S791; + *&((&_S828)->y) = _S827; + float4 _S829 = _S792 + _S828; + points_7[int(0)] = _S752; + points_7[int(1)] = _S752; + points_7[int(2)] = _S752; + points_7[int(3)] = _S752; + _S757 = _S825[int(0)]; + _S792 = _S829; + } + else + { + FixedArray _S830 = points_7; + FixedArray _S831 = points_7; + FixedArray _S832 = points_7; + points_7[int(0)] = points_7[int(0)]; + points_7[int(1)] = _S830[int(1)]; + points_7[int(2)] = _S831[int(2)]; + points_7[int(3)] = _S832[int(3)]; + _S757 = _S752; + } + float3 _S833 = _S765 * (points_7[int(0)] + _S757); + float _S834 = _S833.x + _S833.y + _S833.z; + float4 _S835 = _S791; + *&((&_S835)->x) = _S834; + _S792 = _S792 + _S835; + } + else + { + _S792 = _S791; + } + } + else + { + _S792 = _S791; + } + *v_depths_2 = _S792; + return; +} + +inline __device__ float ray_depth_to_linear_depth_factor_opencv(float2 pix_center_7, float4 intrins_13, FixedArray dist_coeffs_17, int camera_model_15) +{ + float _S836; + for(;;) + { + float2 uv_41 = (pix_center_7 - float2 {intrins_13.z, intrins_13.w}) / float2 {intrins_13.x, intrins_13.y}; + FixedArray _S837 = dist_coeffs_17; + float2 uv_u_18; + bool _S838 = undistort_point_1(uv_41, &_S837, int(12), &uv_u_18); + if(!_S838) + { + _S836 = 0.0f; + break; + } + float3 raydir_9 = unproject_raydir_0(uv_u_18, camera_model_15, false); + _S836 = float((F32_sign((raydir_9.z)))) / length_0(raydir_9); + break; + } + return _S836; +} + +inline __device__ float depth_normal_loss_opencv(float2 pix_center_8, float4 intrins_14, FixedArray dist_coeffs_18, int camera_model_16, bool is_ray_depth_14, float4 depths_6, float3 gt_normal_2) +{ + float _S839; + for(;;) + { + float3 _S840; + float3 * _S841; + float3 * _S842; + float3 * _S843; + float3 * _S844; + int _S845; + FixedArray points_8; + for(;;) + { + float2 _S846 = float2 {intrins_14.z, intrins_14.w}; + float2 _S847 = float2 {intrins_14.x, intrins_14.y}; + float2 uv_42 = (pix_center_8 + make_float2 (-1.0f, -0.0f) - _S846) / _S847; + FixedArray _S848 = dist_coeffs_18; + float2 uv_u_19; + bool _S849 = undistort_point_1(uv_42, &_S848, int(12), &uv_u_19); + float3 _S850 = make_float3 (0.0f); + if(!_S849) + { + _S845 = int(0); + _S844 = nullptr; + _S843 = nullptr; + _S842 = nullptr; + _S841 = nullptr; + _S840 = _S850; + break; + } + float3 raydir_10 = unproject_raydir_0(uv_u_19, camera_model_16, is_ray_depth_14); + points_8[int(0)] = make_float3 (depths_6.x) * raydir_10; + float2 uv_43 = (pix_center_8 + make_float2 (1.0f, -0.0f) - _S846) / _S847; + FixedArray _S851 = dist_coeffs_18; + float2 uv_u_20; + bool _S852 = undistort_point_1(uv_43, &_S851, int(12), &uv_u_20); + if(!_S852) + { + _S845 = int(0); + _S844 = nullptr; + _S843 = &points_8[int(0)]; + _S842 = nullptr; + _S841 = nullptr; + _S840 = _S850; + break; + } + float3 raydir_11 = unproject_raydir_0(uv_u_20, camera_model_16, is_ray_depth_14); + points_8[int(1)] = make_float3 (depths_6.y) * raydir_11; + float2 uv_44 = (pix_center_8 + make_float2 (0.0f, -1.0f) - _S846) / _S847; + FixedArray _S853 = dist_coeffs_18; + float2 uv_u_21; + bool _S854 = undistort_point_1(uv_44, &_S853, int(12), &uv_u_21); + if(!_S854) + { + _S845 = int(0); + _S844 = &points_8[int(1)]; + _S843 = &points_8[int(0)]; + _S842 = nullptr; + _S841 = nullptr; + _S840 = _S850; + break; + } + float3 raydir_12 = unproject_raydir_0(uv_u_21, camera_model_16, is_ray_depth_14); + points_8[int(2)] = make_float3 (depths_6.z) * raydir_12; + float2 uv_45 = (pix_center_8 + make_float2 (0.0f, 1.0f) - _S846) / _S847; + FixedArray _S855 = dist_coeffs_18; + float2 uv_u_22; + bool _S856 = undistort_point_1(uv_45, &_S855, int(12), &uv_u_22); + if(!_S856) + { + _S845 = int(0); + _S844 = &points_8[int(1)]; + _S843 = &points_8[int(0)]; + _S842 = nullptr; + _S841 = &points_8[int(2)]; + _S840 = _S850; + break; + } + float3 raydir_13 = unproject_raydir_0(uv_u_22, camera_model_16, is_ray_depth_14); + points_8[int(3)] = make_float3 (depths_6.w) * raydir_13; + float2 uv_46 = (pix_center_8 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S846) / _S847; + FixedArray _S857 = dist_coeffs_18; + float2 uv_u_23; + bool _S858 = undistort_point_1(uv_46, &_S857, int(12), &uv_u_23); + if(!_S858) + { + _S845 = int(0); + _S844 = &points_8[int(1)]; + _S843 = &points_8[int(0)]; + _S842 = &points_8[int(3)]; + _S841 = &points_8[int(2)]; + _S840 = _S850; + break; + } + float3 raydir_14 = unproject_raydir_0(uv_u_23, camera_model_16, is_ray_depth_14); + _S845 = int(1); + _S844 = &points_8[int(1)]; + _S843 = &points_8[int(0)]; + _S842 = &points_8[int(3)]; + _S841 = &points_8[int(2)]; + _S840 = raydir_14; + break; + } + if(_S845 != int(1)) + { + _S839 = 0.0f; + break; + } + float3 normal_9 = cross_0(*_S844 - *_S843, - (*_S842 - *_S841)); + float3 normal_10; + if((dot_0(normal_9, normal_9)) != 0.0f) + { + normal_10 = normalize_0(normal_9); + } + else + { + normal_10 = normal_9; + } + float3 _S859; + if((dot_0(gt_normal_2, gt_normal_2)) != 0.0f) + { + _S859 = normalize_0(gt_normal_2); + } + else + { + _S859 = gt_normal_2; + } + _S839 = (1.0f - dot_0(normal_10, _S859) + 0.00100000004749745f) / ((F32_max((dot_0(normal_10, - normalize_0(_S840))), (0.0f))) + 0.00100000004749745f); + break; + } + return _S839; +} + +struct s_bwd_prop_depth_normal_loss_Intermediates_1 +{ + float2 _S860; + bool _S861; + float2 _S862; + bool _S863; + float2 _S864; + bool _S865; + float2 _S866; + bool _S867; + float2 _S868; + bool _S869; +}; + +inline __device__ void depth_normal_loss_vjp_opencv(float2 pix_center_9, float4 intrins_15, FixedArray dist_coeffs_19, int camera_model_17, bool is_ray_depth_15, float4 depths_7, float3 gt_normal_3, float v_loss_1, float4 * v_depths_3, float3 * v_gt_normal_1) +{ + float2 _S870 = make_float2 (0.0f); + s_bwd_prop_depth_normal_loss_Intermediates_1 _S871; + (&_S871)->_S860 = _S870; + (&_S871)->_S861 = false; + (&_S871)->_S862 = _S870; + (&_S871)->_S863 = false; + (&_S871)->_S864 = _S870; + (&_S871)->_S865 = false; + (&_S871)->_S866 = _S870; + (&_S871)->_S867 = false; + (&_S871)->_S868 = _S870; + (&_S871)->_S869 = false; + (&_S871)->_S862 = _S870; + (&_S871)->_S863 = false; + (&_S871)->_S864 = _S870; + (&_S871)->_S865 = false; + (&_S871)->_S866 = _S870; + (&_S871)->_S867 = false; + (&_S871)->_S868 = _S870; + (&_S871)->_S869 = false; + float2 _S872 = float2 {intrins_15.z, intrins_15.w}; + float2 _S873 = float2 {intrins_15.x, intrins_15.y}; + float2 uv_47 = (pix_center_9 + make_float2 (-1.0f, -0.0f) - _S872) / _S873; + float2 _S874 = _S870; + FixedArray _S875 = dist_coeffs_19; + bool _S876 = undistort_point_1(uv_47, &_S875, int(12), &_S874); + (&_S871)->_S860 = _S874; + (&_S871)->_S861 = _S876; + bool _S877 = !!_S876; + bool _runFlag_12; + if(_S877) + { + float2 uv_48 = (pix_center_9 + make_float2 (1.0f, -0.0f) - _S872) / _S873; + float2 _S878 = _S870; + FixedArray _S879 = dist_coeffs_19; + bool _S880 = undistort_point_1(uv_48, &_S879, int(12), &_S878); + (&_S871)->_S862 = _S878; + (&_S871)->_S863 = _S880; + if(!_S880) + { + _runFlag_12 = false; + } + else + { + _runFlag_12 = _S877; + } + if(_runFlag_12) + { + float2 uv_49 = (pix_center_9 + make_float2 (0.0f, -1.0f) - _S872) / _S873; + float2 _S881 = _S870; + FixedArray _S882 = dist_coeffs_19; + bool _S883 = undistort_point_1(uv_49, &_S882, int(12), &_S881); + (&_S871)->_S864 = _S881; + (&_S871)->_S865 = _S883; + if(!_S883) + { + _runFlag_12 = false; + } + if(_runFlag_12) + { + float2 uv_50 = (pix_center_9 + make_float2 (0.0f, 1.0f) - _S872) / _S873; + float2 _S884 = _S870; + FixedArray _S885 = dist_coeffs_19; + bool _S886 = undistort_point_1(uv_50, &_S885, int(12), &_S884); + (&_S871)->_S866 = _S884; + (&_S871)->_S867 = _S886; + if(!_S886) + { + _runFlag_12 = false; + } + if(_runFlag_12) + { + float2 uv_51 = (pix_center_9 - _S872) / _S873; + float2 _S887 = _S870; + FixedArray _S888 = dist_coeffs_19; + bool _S889 = undistort_point_1(uv_51, &_S888, int(12), &_S887); + (&_S871)->_S868 = _S887; + (&_S871)->_S869 = _S889; + } + } + } + } + s_bwd_prop_depth_normal_loss_Intermediates_1 _S890 = _S871; + float3 _S891 = make_float3 (0.0f); + bool _S892 = !!_S871._S861; + bool _runFlag_13; + bool _runFlag_14; + bool _runFlag_15; + int _S893; + float3 raydir_15; + float3 _S894; + float3 _S895; + float3 _S896; + float3 _S897; + FixedArray points_9; + if(_S892) + { + float3 _S898 = s_primal_ctx_unproject_raydir_0(_S890._S860, camera_model_17, is_ray_depth_15); + float3 _S899 = make_float3 (depths_7.x) * _S898; + if(!_S890._S863) + { + _runFlag_12 = false; + } + else + { + _runFlag_12 = _S892; + } + if(_runFlag_12) + { + float3 _S900 = s_primal_ctx_unproject_raydir_0(_S890._S862, camera_model_17, is_ray_depth_15); + float3 _S901 = make_float3 (depths_7.y) * _S900; + if(!_S890._S865) + { + _runFlag_13 = false; + } + else + { + _runFlag_13 = _runFlag_12; + } + if(_runFlag_13) + { + float3 _S902 = s_primal_ctx_unproject_raydir_0(_S890._S864, camera_model_17, is_ray_depth_15); + float3 _S903 = make_float3 (depths_7.z) * _S902; + if(!_S890._S867) + { + _runFlag_14 = false; + } + else + { + _runFlag_14 = _runFlag_13; + } + if(_runFlag_14) + { + float3 _S904 = s_primal_ctx_unproject_raydir_0(_S890._S866, camera_model_17, is_ray_depth_15); + float3 _S905 = make_float3 (depths_7.w) * _S904; + if(!_S890._S869) + { + _runFlag_15 = false; + } + else + { + _runFlag_15 = _runFlag_14; + } + if(_runFlag_15) + { + float3 _S906 = s_primal_ctx_unproject_raydir_0(_S890._S868, camera_model_17, is_ray_depth_15); + _S893 = int(1); + raydir_15 = _S906; + } + else + { + _S893 = int(0); + raydir_15 = _S904; + } + points_9[int(0)] = _S899; + points_9[int(1)] = _S901; + points_9[int(2)] = _S903; + points_9[int(3)] = _S905; + points_9[int(4)] = _S891; + _S894 = _S904; + } + else + { + _S893 = int(0); + raydir_15 = _S902; + points_9[int(0)] = _S899; + points_9[int(1)] = _S901; + points_9[int(2)] = _S903; + points_9[int(3)] = _S891; + points_9[int(4)] = _S891; + _S894 = _S891; + } + _S895 = _S902; + } + else + { + _S893 = int(0); + raydir_15 = _S900; + points_9[int(0)] = _S899; + points_9[int(1)] = _S901; + points_9[int(2)] = _S891; + points_9[int(3)] = _S891; + points_9[int(4)] = _S891; + _runFlag_14 = false; + _S894 = _S891; + _S895 = _S891; + } + _S896 = _S900; + } + else + { + _S893 = int(0); + raydir_15 = _S898; + points_9[int(0)] = _S899; + points_9[int(1)] = _S891; + points_9[int(2)] = _S891; + points_9[int(3)] = _S891; + points_9[int(4)] = _S891; + _runFlag_13 = false; + _runFlag_14 = false; + _S894 = _S891; + _S895 = _S891; + _S896 = _S891; + } + _S897 = _S898; + } + else + { + _S893 = int(0); + points_9[int(0)] = _S891; + points_9[int(1)] = _S891; + points_9[int(2)] = _S891; + points_9[int(3)] = _S891; + points_9[int(4)] = _S891; + _runFlag_12 = false; + _runFlag_13 = false; + _runFlag_14 = false; + _S894 = _S891; + _S895 = _S891; + _S896 = _S891; + _S897 = _S891; + } + bool _S907 = !(_S893 != int(1)); + bool _S908; + float3 normal_11; + float3 _S909; + float3 _S910; + float3 _S911; + float3 _S912; + float _S913; + float _S914; + float _S915; + float _S916; + if(_S907) + { + float3 dx_4 = points_9[int(1)] - points_9[int(0)]; + float3 _S917 = - (points_9[int(3)] - points_9[int(2)]); + float3 _S918 = s_primal_ctx_cross_0(dx_4, _S917); + bool _S919 = (s_primal_ctx_dot_0(_S918, _S918)) != 0.0f; + if(_S919) + { + normal_11 = normalize_0(_S918); + } + else + { + normal_11 = _S918; + } + bool _S920 = (s_primal_ctx_dot_0(gt_normal_3, gt_normal_3)) != 0.0f; + if(_S920) + { + _S909 = normalize_0(gt_normal_3); + } + else + { + _S909 = gt_normal_3; + } + float3 _S921 = - normalize_0(raydir_15); + float _S922 = s_primal_ctx_dot_0(normal_11, _S921); + float _S923 = 1.0f - s_primal_ctx_dot_0(normal_11, _S909) + 0.00100000004749745f; + float _S924 = (F32_max((_S922), (0.0f))) + 0.00100000004749745f; + _S913 = _S924 * _S924; + _S914 = _S923; + _S915 = _S924; + _S916 = _S922; + raydir_15 = normal_11; + normal_11 = _S921; + _runFlag_15 = _S920; + _S908 = _S919; + _S910 = _S918; + _S911 = dx_4; + _S912 = _S917; + } + else + { + _S913 = 0.0f; + _S914 = 0.0f; + _S915 = 0.0f; + _S916 = 0.0f; + raydir_15 = _S891; + normal_11 = _S891; + _S909 = _S891; + _runFlag_15 = false; + _S908 = false; + _S910 = _S891; + _S911 = _S891; + _S912 = _S891; + } + float4 _S925 = make_float4 (0.0f); + if(_S907) + { + float _S926 = v_loss_1 / _S913; + float _S927 = _S914 * - _S926; + float s_diff_num_T_1 = _S915 * _S926; + DiffPair_float_0 _S928; + (&_S928)->primal_0 = _S916; + (&_S928)->differential_0 = 0.0f; + DiffPair_float_0 _S929; + (&_S929)->primal_0 = 0.0f; + (&_S929)->differential_0 = 0.0f; + _d_max_0(&_S928, &_S929, _S927); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S930; + (&_S930)->primal_0 = raydir_15; + (&_S930)->differential_0 = _S891; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S931; + (&_S931)->primal_0 = normal_11; + (&_S931)->differential_0 = _S891; + s_bwd_prop_dot_0(&_S930, &_S931, _S928.differential_0); + float _S932 = - s_diff_num_T_1; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S933; + (&_S933)->primal_0 = raydir_15; + (&_S933)->differential_0 = _S891; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S934; + (&_S934)->primal_0 = _S909; + (&_S934)->differential_0 = _S891; + s_bwd_prop_dot_0(&_S933, &_S934, _S932); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S935 = _S934; + float3 _S936 = _S930.differential_0 + _S933.differential_0; + if(_runFlag_15) + { + DiffPair_vectorx3Cfloatx2C3x3E_0 _S937; + (&_S937)->primal_0 = gt_normal_3; + (&_S937)->differential_0 = _S891; + s_bwd_normalize_impl_0(&_S937, _S935.differential_0); + raydir_15 = _S937.differential_0; + } + else + { + raydir_15 = _S935.differential_0; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S938; + (&_S938)->primal_0 = gt_normal_3; + (&_S938)->differential_0 = _S891; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S939; + (&_S939)->primal_0 = gt_normal_3; + (&_S939)->differential_0 = _S891; + s_bwd_prop_dot_0(&_S938, &_S939, 0.0f); + float3 _S940 = _S939.differential_0 + _S938.differential_0 + raydir_15; + if(_S908) + { + DiffPair_vectorx3Cfloatx2C3x3E_0 _S941; + (&_S941)->primal_0 = _S910; + (&_S941)->differential_0 = _S891; + s_bwd_normalize_impl_0(&_S941, _S936); + raydir_15 = _S941.differential_0; + } + else + { + raydir_15 = _S936; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S942; + (&_S942)->primal_0 = _S910; + (&_S942)->differential_0 = _S891; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S943; + (&_S943)->primal_0 = _S910; + (&_S943)->differential_0 = _S891; + s_bwd_prop_dot_0(&_S942, &_S943, 0.0f); + float3 _S944 = _S943.differential_0 + _S942.differential_0 + raydir_15; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S945; + (&_S945)->primal_0 = _S911; + (&_S945)->differential_0 = _S891; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S946; + (&_S946)->primal_0 = _S912; + (&_S946)->differential_0 = _S891; + s_bwd_prop_cross_0(&_S945, &_S946, _S944); + float3 s_diff_dy_T_4 = - _S946.differential_0; + float3 _S947 = - s_diff_dy_T_4; + float3 _S948 = - _S945.differential_0; + FixedArray _S949; + _S949[int(0)] = _S891; + _S949[int(1)] = _S891; + _S949[int(2)] = _S891; + _S949[int(3)] = _S891; + _S949[int(4)] = _S891; + _S949[int(2)] = _S947; + _S949[int(3)] = s_diff_dy_T_4; + _S949[int(0)] = _S948; + _S949[int(1)] = _S945.differential_0; + points_9[int(0)] = _S949[int(0)]; + points_9[int(1)] = _S949[int(1)]; + points_9[int(2)] = _S949[int(2)]; + points_9[int(3)] = _S949[int(3)]; + points_9[int(4)] = _S949[int(4)]; + raydir_15 = _S940; + } + else + { + points_9[int(0)] = _S891; + points_9[int(1)] = _S891; + points_9[int(2)] = _S891; + points_9[int(3)] = _S891; + points_9[int(4)] = _S891; + raydir_15 = _S891; + } + float4 _S950; + if(_S892) + { + if(_runFlag_12) + { + if(_runFlag_13) + { + if(_runFlag_14) + { + FixedArray _S951 = points_9; + FixedArray _S952 = points_9; + FixedArray _S953 = points_9; + float3 _S954 = _S894 * points_9[int(3)]; + float _S955 = _S954.x + _S954.y + _S954.z; + float4 _S956 = _S925; + *&((&_S956)->w) = _S955; + points_9[int(0)] = _S891; + points_9[int(1)] = _S891; + points_9[int(2)] = _S891; + points_9[int(3)] = _S891; + points_9[int(4)] = _S891; + _S894 = _S953[int(2)]; + normal_11 = _S951[int(0)]; + _S909 = _S952[int(1)]; + _S950 = _S956; + } + else + { + FixedArray _S957 = points_9; + FixedArray _S958 = points_9; + FixedArray _S959 = points_9; + FixedArray _S960 = points_9; + points_9[int(0)] = points_9[int(0)]; + points_9[int(1)] = _S957[int(1)]; + points_9[int(2)] = _S958[int(2)]; + points_9[int(3)] = _S959[int(3)]; + points_9[int(4)] = _S960[int(4)]; + _S894 = _S891; + normal_11 = _S891; + _S909 = _S891; + _S950 = _S925; + } + float3 _S961 = _S895 * (points_9[int(2)] + _S894); + float _S962 = _S961.x + _S961.y + _S961.z; + float3 _S963 = points_9[int(0)] + normal_11; + float3 _S964 = points_9[int(1)] + _S909; + float4 _S965 = _S925; + *&((&_S965)->z) = _S962; + float4 _S966 = _S950 + _S965; + points_9[int(0)] = _S891; + points_9[int(1)] = _S891; + points_9[int(2)] = _S891; + points_9[int(3)] = _S891; + points_9[int(4)] = _S891; + _S894 = _S964; + _S895 = _S963; + _S950 = _S966; + } + else + { + FixedArray _S967 = points_9; + FixedArray _S968 = points_9; + FixedArray _S969 = points_9; + FixedArray _S970 = points_9; + points_9[int(0)] = points_9[int(0)]; + points_9[int(1)] = _S967[int(1)]; + points_9[int(2)] = _S968[int(2)]; + points_9[int(3)] = _S969[int(3)]; + points_9[int(4)] = _S970[int(4)]; + _S894 = _S891; + _S895 = _S891; + _S950 = _S925; + } + float3 _S971 = _S896 * (points_9[int(1)] + _S894); + float _S972 = _S971.x + _S971.y + _S971.z; + float3 _S973 = points_9[int(0)] + _S895; + float4 _S974 = _S925; + *&((&_S974)->y) = _S972; + float4 _S975 = _S950 + _S974; + points_9[int(0)] = _S891; + points_9[int(1)] = _S891; + points_9[int(2)] = _S891; + points_9[int(3)] = _S891; + points_9[int(4)] = _S891; + _S894 = _S973; + _S950 = _S975; + } + else + { + FixedArray _S976 = points_9; + FixedArray _S977 = points_9; + FixedArray _S978 = points_9; + FixedArray _S979 = points_9; + points_9[int(0)] = points_9[int(0)]; + points_9[int(1)] = _S976[int(1)]; + points_9[int(2)] = _S977[int(2)]; + points_9[int(3)] = _S978[int(3)]; + points_9[int(4)] = _S979[int(4)]; + _S894 = _S891; + _S950 = _S925; + } + float3 _S980 = _S897 * (points_9[int(0)] + _S894); + float _S981 = _S980.x + _S980.y + _S980.z; + float4 _S982 = _S925; + *&((&_S982)->x) = _S981; + _S950 = _S950 + _S982; + } + else + { + _S950 = _S925; + } + *v_depths_3 = _S950; + *v_gt_normal_1 = raydir_15; + return; +} + +inline __device__ float3 generate_ray_d2n_prism(float2 pix_pos_6, float4 intrins_16, FixedArray dist_coeffs_20, int camera_model_18, bool is_ray_depth_16) +{ + float3 _S983; + for(;;) + { + float2 uv_52 = (pix_pos_6 - float2 {intrins_16.z, intrins_16.w}) / float2 {intrins_16.x, intrins_16.y}; + FixedArray _S984 = dist_coeffs_20; + float2 uv_u_24; + bool _S985 = undistort_point_2(uv_52, &_S984, int(12), &uv_u_24); + if(!_S985) + { + int3 _S986 = make_int3 (int(0)); + float3 _S987 = make_float3 ((float)_S986.x, (float)_S986.y, (float)_S986.z); + _S983 = _S987; + break; + } + _S983 = unproject_raydir_0(uv_u_24, camera_model_18, is_ray_depth_16); + break; + } + return _S983; +} + +inline __device__ float3 depth_to_point_prism(float2 pix_pos_7, float4 intrins_17, FixedArray dist_coeffs_21, int camera_model_19, bool is_ray_depth_17, float depth_6) +{ + float3 _S988; + for(;;) + { + float2 uv_53 = (pix_pos_7 - float2 {intrins_17.z, intrins_17.w}) / float2 {intrins_17.x, intrins_17.y}; + FixedArray _S989 = dist_coeffs_21; + float2 uv_u_25; + bool _S990 = undistort_point_2(uv_53, &_S989, int(12), &uv_u_25); + if(!_S990) + { + _S988 = make_float3 (0.0f); + break; + } + _S988 = make_float3 (depth_6) * unproject_raydir_0(uv_u_25, camera_model_19, is_ray_depth_17); + break; + } + return _S988; +} + +struct s_bwd_prop_depth_to_point_Intermediates_2 +{ + float2 _S991; + bool _S992; +}; + +inline __device__ float depth_to_point_vjp_prism(float2 pix_pos_8, float4 intrins_18, FixedArray dist_coeffs_22, int camera_model_20, bool is_ray_depth_18, float depth_7, float3 v_point_2) +{ + float2 _S993 = make_float2 (0.0f); + s_bwd_prop_depth_to_point_Intermediates_2 _S994; + (&_S994)->_S991 = _S993; + (&_S994)->_S992 = false; + float2 uv_54 = (pix_pos_8 - float2 {intrins_18.z, intrins_18.w}) / float2 {intrins_18.x, intrins_18.y}; + float2 _S995 = _S993; + FixedArray _S996 = dist_coeffs_22; + bool _S997 = undistort_point_2(uv_54, &_S996, int(12), &_S995); + (&_S994)->_S991 = _S995; + (&_S994)->_S992 = _S997; + s_bwd_prop_depth_to_point_Intermediates_2 _S998 = _S994; + float3 _S999 = make_float3 (0.0f); + bool _S1000 = !!_S994._S992; + float3 _S1001; + if(_S1000) + { + _S1001 = s_primal_ctx_unproject_raydir_0(_S998._S991, camera_model_20, is_ray_depth_18); + } + else + { + _S1001 = _S999; + } + if(_S1000) + { + _S1001 = _S1001 * v_point_2; + } + else + { + _S1001 = _S999; + } + return _S1001.x + _S1001.y + _S1001.z; +} + +inline __device__ float3 depth_to_normal_prism(float2 pix_center_10, float4 intrins_19, FixedArray dist_coeffs_23, int camera_model_21, bool is_ray_depth_19, float4 depths_8) +{ + float3 normal_12; + for(;;) + { + bool _S1002; + if((depths_8.x) == 0.0f) + { + _S1002 = true; + } + else + { + _S1002 = (depths_8.y) == 0.0f; + } + if(_S1002) + { + _S1002 = true; + } + else + { + _S1002 = (depths_8.z) == 0.0f; + } + if(_S1002) + { + _S1002 = true; + } + else + { + _S1002 = (depths_8.w) == 0.0f; + } + if(_S1002) + { + normal_12 = make_float3 (0.0f); + break; + } + float3 * _S1003; + float3 * _S1004; + float3 * _S1005; + float3 * _S1006; + int _S1007; + FixedArray points_10; + for(;;) + { + float2 _S1008 = float2 {intrins_19.z, intrins_19.w}; + float2 _S1009 = float2 {intrins_19.x, intrins_19.y}; + float2 uv_55 = (pix_center_10 + make_float2 (-1.0f, -0.0f) - _S1008) / _S1009; + FixedArray _S1010 = dist_coeffs_23; + float2 uv_u_26; + bool _S1011 = undistort_point_2(uv_55, &_S1010, int(12), &uv_u_26); + if(!_S1011) + { + float3 _S1012 = make_float3 (0.0f); + _S1007 = int(0); + _S1006 = nullptr; + _S1005 = nullptr; + _S1004 = nullptr; + _S1003 = nullptr; + normal_12 = _S1012; + break; + } + points_10[int(0)] = make_float3 (depths_8.x) * unproject_raydir_0(uv_u_26, camera_model_21, is_ray_depth_19); + for(;;) + { + float2 uv_56 = (pix_center_10 + make_float2 (1.0f, -0.0f) - _S1008) / _S1009; + FixedArray _S1013 = dist_coeffs_23; + float2 uv_u_27; + bool _S1014 = undistort_point_2(uv_56, &_S1013, int(12), &uv_u_27); + if(!_S1014) + { + float3 _S1015 = make_float3 (0.0f); + _S1007 = int(0); + _S1006 = nullptr; + normal_12 = _S1015; + break; + } + points_10[int(1)] = make_float3 (depths_8.y) * unproject_raydir_0(uv_u_27, camera_model_21, is_ray_depth_19); + _S1007 = int(2); + _S1006 = &points_10[int(1)]; + break; + } + if(_S1007 != int(2)) + { + _S1005 = &points_10[int(0)]; + _S1004 = nullptr; + _S1003 = nullptr; + break; + } + float2 uv_57 = (pix_center_10 + make_float2 (0.0f, -1.0f) - _S1008) / _S1009; + FixedArray _S1016 = dist_coeffs_23; + float2 uv_u_28; + bool _S1017 = undistort_point_2(uv_57, &_S1016, int(12), &uv_u_28); + if(!_S1017) + { + float3 _S1018 = make_float3 (0.0f); + _S1007 = int(0); + _S1005 = &points_10[int(0)]; + _S1004 = nullptr; + _S1003 = nullptr; + normal_12 = _S1018; + break; + } + points_10[int(2)] = make_float3 (depths_8.z) * unproject_raydir_0(uv_u_28, camera_model_21, is_ray_depth_19); + for(;;) + { + float2 uv_58 = (pix_center_10 + make_float2 (0.0f, 1.0f) - _S1008) / _S1009; + FixedArray _S1019 = dist_coeffs_23; + float2 uv_u_29; + bool _S1020 = undistort_point_2(uv_58, &_S1019, int(12), &uv_u_29); + if(!_S1020) + { + float3 _S1021 = make_float3 (0.0f); + _S1007 = int(0); + _S1005 = nullptr; + normal_12 = _S1021; + break; + } + points_10[int(3)] = make_float3 (depths_8.w) * unproject_raydir_0(uv_u_29, camera_model_21, is_ray_depth_19); + _S1007 = int(2); + _S1005 = &points_10[int(3)]; + break; + } + if(_S1007 != int(2)) + { + float3 * _S1022 = _S1005; + _S1005 = &points_10[int(0)]; + _S1004 = _S1022; + _S1003 = &points_10[int(2)]; + break; + } + float3 * _S1023 = _S1005; + _S1007 = int(1); + _S1005 = &points_10[int(0)]; + _S1004 = _S1023; + _S1003 = &points_10[int(2)]; + break; + } + if(_S1007 != int(1)) + { + break; + } + float3 normal_13 = cross_0(*_S1006 - *_S1005, - (*_S1004 - *_S1003)); + if((dot_0(normal_13, normal_13)) != 0.0f) + { + normal_12 = normal_13 / make_float3 (length_0(normal_13)); + } + else + { + normal_12 = normal_13; + } + break; + } + return normal_12; +} + +struct s_bwd_prop_depth_to_normal_Intermediates_2 +{ + float2 _S1024; + bool _S1025; + float2 _S1026; + bool _S1027; + float2 _S1028; + bool _S1029; + float2 _S1030; + bool _S1031; +}; + +inline __device__ void depth_to_normal_vjp_prism(float2 pix_center_11, float4 intrins_20, FixedArray dist_coeffs_24, int camera_model_22, bool is_ray_depth_20, float4 depths_9, float3 v_normal_3, float4 * v_depths_4) +{ + float2 _S1032 = make_float2 (0.0f); + s_bwd_prop_depth_to_normal_Intermediates_2 _S1033; + (&_S1033)->_S1024 = _S1032; + (&_S1033)->_S1025 = false; + (&_S1033)->_S1026 = _S1032; + (&_S1033)->_S1027 = false; + (&_S1033)->_S1028 = _S1032; + (&_S1033)->_S1029 = false; + (&_S1033)->_S1030 = _S1032; + (&_S1033)->_S1031 = false; + (&_S1033)->_S1024 = _S1032; + (&_S1033)->_S1025 = false; + (&_S1033)->_S1026 = _S1032; + (&_S1033)->_S1027 = false; + (&_S1033)->_S1028 = _S1032; + (&_S1033)->_S1029 = false; + (&_S1033)->_S1030 = _S1032; + (&_S1033)->_S1031 = false; + bool _S1034 = (depths_9.x) == 0.0f; + bool _runFlag_16; + if(_S1034) + { + _runFlag_16 = true; + } + else + { + _runFlag_16 = (depths_9.y) == 0.0f; + } + if(_runFlag_16) + { + _runFlag_16 = true; + } + else + { + _runFlag_16 = (depths_9.z) == 0.0f; + } + if(_runFlag_16) + { + _runFlag_16 = true; + } + else + { + _runFlag_16 = (depths_9.w) == 0.0f; + } + int _S1035; + if(!_runFlag_16) + { + float2 _S1036 = float2 {intrins_20.z, intrins_20.w}; + float2 _S1037 = float2 {intrins_20.x, intrins_20.y}; + float2 uv_59 = (pix_center_11 + make_float2 (-1.0f, -0.0f) - _S1036) / _S1037; + float2 _S1038 = _S1032; + FixedArray _S1039 = dist_coeffs_24; + bool _S1040 = undistort_point_2(uv_59, &_S1039, int(12), &_S1038); + (&_S1033)->_S1024 = _S1038; + (&_S1033)->_S1025 = _S1040; + bool _S1041 = !!_S1040; + if(_S1041) + { + float2 uv_60 = (pix_center_11 + make_float2 (1.0f, -0.0f) - _S1036) / _S1037; + float2 _S1042 = _S1032; + FixedArray _S1043 = dist_coeffs_24; + bool _S1044 = undistort_point_2(uv_60, &_S1043, int(12), &_S1042); + (&_S1033)->_S1026 = _S1042; + (&_S1033)->_S1027 = _S1044; + if(!!_S1044) + { + _S1035 = int(2); + } + else + { + _S1035 = int(0); + } + if(_S1035 != int(2)) + { + _runFlag_16 = false; + } + else + { + _runFlag_16 = _S1041; + } + if(_runFlag_16) + { + float2 uv_61 = (pix_center_11 + make_float2 (0.0f, -1.0f) - _S1036) / _S1037; + float2 _S1045 = _S1032; + FixedArray _S1046 = dist_coeffs_24; + bool _S1047 = undistort_point_2(uv_61, &_S1046, int(12), &_S1045); + (&_S1033)->_S1028 = _S1045; + (&_S1033)->_S1029 = _S1047; + if(!_S1047) + { + _runFlag_16 = false; + } + if(_runFlag_16) + { + float2 uv_62 = (pix_center_11 + make_float2 (0.0f, 1.0f) - _S1036) / _S1037; + float2 _S1048 = _S1032; + FixedArray _S1049 = dist_coeffs_24; + bool _S1050 = undistort_point_2(uv_62, &_S1049, int(12), &_S1048); + (&_S1033)->_S1030 = _S1048; + (&_S1033)->_S1031 = _S1050; + } + } + } + } + s_bwd_prop_depth_to_normal_Intermediates_2 _S1051 = _S1033; + float3 _S1052 = make_float3 (0.0f); + if(_S1034) + { + _runFlag_16 = true; + } + else + { + _runFlag_16 = (depths_9.y) == 0.0f; + } + if(_runFlag_16) + { + _runFlag_16 = true; + } + else + { + _runFlag_16 = (depths_9.z) == 0.0f; + } + if(_runFlag_16) + { + _runFlag_16 = true; + } + else + { + _runFlag_16 = (depths_9.w) == 0.0f; + } + bool _S1053 = !_runFlag_16; + bool _runFlag_17; + bool _runFlag_18; + bool _S1054; + bool _runFlag_19; + bool _S1055; + bool _S1056; + FixedArray points_11; + float3 _S1057; + float3 _S1058; + float3 _S1059; + float3 _S1060; + float3 _S1061; + float3 _S1062; + float3 _S1063; + float3 _S1064; + float3 _S1065; + if(_S1053) + { + bool _S1066 = !!_S1051._S1025; + if(_S1066) + { + float3 _S1067 = s_primal_ctx_unproject_raydir_0(_S1051._S1024, camera_model_22, is_ray_depth_20); + float3 _S1068 = make_float3 (depths_9.x) * _S1067; + bool _S1069 = !!_S1051._S1027; + if(_S1069) + { + float3 _S1070 = s_primal_ctx_unproject_raydir_0(_S1051._S1026, camera_model_22, is_ray_depth_20); + float3 _S1071 = make_float3 (depths_9.y) * _S1070; + _S1035 = int(2); + points_11[int(0)] = _S1068; + points_11[int(1)] = _S1071; + points_11[int(2)] = _S1052; + points_11[int(3)] = _S1052; + _S1057 = _S1070; + } + else + { + _S1035 = int(0); + points_11[int(0)] = _S1068; + points_11[int(1)] = _S1052; + points_11[int(2)] = _S1052; + points_11[int(3)] = _S1052; + _S1057 = _S1052; + } + if(_S1035 != int(2)) + { + _runFlag_16 = false; + } + else + { + _runFlag_16 = _S1066; + _S1035 = int(0); + } + if(_runFlag_16) + { + if(!_S1051._S1029) + { + _runFlag_17 = false; + _S1035 = int(0); + } + else + { + _runFlag_17 = _runFlag_16; + } + if(_runFlag_17) + { + float3 _S1072 = s_primal_ctx_unproject_raydir_0(_S1051._S1028, camera_model_22, is_ray_depth_20); + points_11[int(2)] = make_float3 (depths_9.z) * _S1072; + bool _S1073 = !!_S1051._S1031; + int _S1074; + if(_S1073) + { + float3 _S1075 = s_primal_ctx_unproject_raydir_0(_S1051._S1030, camera_model_22, is_ray_depth_20); + points_11[int(3)] = make_float3 (depths_9.w) * _S1075; + _S1074 = int(2); + _S1058 = _S1075; + } + else + { + _S1074 = int(0); + _S1058 = _S1052; + } + if(_S1074 != int(2)) + { + _runFlag_18 = false; + _S1035 = _S1074; + } + else + { + _runFlag_18 = _runFlag_17; + } + if(_runFlag_18) + { + _S1035 = int(1); + } + _runFlag_18 = _S1073; + _S1059 = _S1072; + } + else + { + _runFlag_18 = false; + _S1058 = _S1052; + _S1059 = _S1052; + } + } + else + { + _runFlag_17 = false; + _runFlag_18 = false; + _S1058 = _S1052; + _S1059 = _S1052; + } + float3 _S1076 = _S1057; + _S1057 = _S1058; + _S1058 = _S1059; + _S1054 = _S1069; + _S1059 = _S1076; + _S1060 = _S1067; + } + else + { + _S1035 = int(0); + points_11[int(0)] = _S1052; + points_11[int(1)] = _S1052; + points_11[int(2)] = _S1052; + points_11[int(3)] = _S1052; + _runFlag_16 = false; + _runFlag_17 = false; + _runFlag_18 = false; + _S1057 = _S1052; + _S1058 = _S1052; + _S1054 = false; + _S1059 = _S1052; + _S1060 = _S1052; + } + if(_S1035 != int(1)) + { + _runFlag_19 = false; + } + else + { + _runFlag_19 = _S1053; + } + if(_runFlag_19) + { + float3 dx_5 = points_11[int(1)] - points_11[int(0)]; + float3 _S1077 = - (points_11[int(3)] - points_11[int(2)]); + float3 _S1078 = s_primal_ctx_cross_0(dx_5, _S1077); + bool _S1079 = (s_primal_ctx_dot_0(_S1078, _S1078)) != 0.0f; + if(_S1079) + { + float _S1080 = length_0(_S1078); + float3 _S1081 = make_float3 (_S1080); + _S1061 = make_float3 (_S1080 * _S1080); + _S1062 = _S1081; + } + else + { + _S1061 = _S1052; + _S1062 = _S1052; + } + float3 _S1082 = _S1062; + _S1055 = _S1079; + _S1062 = _S1078; + _S1063 = _S1082; + _S1064 = dx_5; + _S1065 = _S1077; + } + else + { + _S1055 = false; + _S1061 = _S1052; + _S1062 = _S1052; + _S1063 = _S1052; + _S1064 = _S1052; + _S1065 = _S1052; + } + bool _S1083 = _runFlag_16; + bool _S1084 = _runFlag_17; + bool _S1085 = _runFlag_18; + float3 _S1086 = _S1057; + float3 _S1087 = _S1058; + bool _S1088 = _S1054; + float3 _S1089 = _S1059; + float3 _S1090 = _S1060; + _runFlag_16 = _runFlag_19; + _runFlag_17 = _S1055; + _S1057 = _S1061; + _S1058 = _S1062; + _S1059 = _S1063; + _S1060 = _S1064; + _S1061 = _S1065; + _runFlag_18 = _S1066; + _S1054 = _S1083; + _runFlag_19 = _S1084; + _S1055 = _S1085; + _S1062 = _S1086; + _S1063 = _S1087; + _S1056 = _S1088; + _S1064 = _S1089; + _S1065 = _S1090; + } + else + { + _runFlag_16 = false; + _runFlag_17 = false; + _S1057 = _S1052; + _S1058 = _S1052; + _S1059 = _S1052; + _S1060 = _S1052; + _S1061 = _S1052; + _runFlag_18 = false; + _S1054 = false; + _runFlag_19 = false; + _S1055 = false; + _S1062 = _S1052; + _S1063 = _S1052; + _S1056 = false; + _S1064 = _S1052; + _S1065 = _S1052; + } + float4 _S1091 = make_float4 (0.0f); + float4 _S1092; + if(_S1053) + { + if(_runFlag_16) + { + if(_runFlag_17) + { + float3 _S1093 = v_normal_3 / _S1057; + float3 _S1094 = _S1058 * - _S1093; + float3 _S1095 = _S1059 * _S1093; + float _S1096 = _S1094.x + _S1094.y + _S1094.z; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1097; + (&_S1097)->primal_0 = _S1058; + (&_S1097)->differential_0 = _S1052; + s_bwd_length_impl_0(&_S1097, _S1096); + _S1057 = _S1095 + _S1097.differential_0; + } + else + { + _S1057 = v_normal_3; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1098; + (&_S1098)->primal_0 = _S1058; + (&_S1098)->differential_0 = _S1052; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1099; + (&_S1099)->primal_0 = _S1058; + (&_S1099)->differential_0 = _S1052; + s_bwd_prop_dot_0(&_S1098, &_S1099, 0.0f); + float3 _S1100 = _S1099.differential_0 + _S1098.differential_0 + _S1057; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1101; + (&_S1101)->primal_0 = _S1060; + (&_S1101)->differential_0 = _S1052; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1102; + (&_S1102)->primal_0 = _S1061; + (&_S1102)->differential_0 = _S1052; + s_bwd_prop_cross_0(&_S1101, &_S1102, _S1100); + float3 s_diff_dy_T_5 = - _S1102.differential_0; + float3 _S1103 = - s_diff_dy_T_5; + float3 _S1104 = - _S1101.differential_0; + FixedArray _S1105; + _S1105[int(0)] = _S1052; + _S1105[int(1)] = _S1052; + _S1105[int(2)] = _S1052; + _S1105[int(3)] = _S1052; + _S1105[int(2)] = _S1103; + _S1105[int(3)] = s_diff_dy_T_5; + _S1105[int(0)] = _S1104; + _S1105[int(1)] = _S1101.differential_0; + points_11[int(0)] = _S1105[int(0)]; + points_11[int(1)] = _S1105[int(1)]; + points_11[int(2)] = _S1105[int(2)]; + points_11[int(3)] = _S1105[int(3)]; + } + else + { + points_11[int(0)] = _S1052; + points_11[int(1)] = _S1052; + points_11[int(2)] = _S1052; + points_11[int(3)] = _S1052; + } + if(_runFlag_18) + { + if(_S1054) + { + if(_runFlag_19) + { + FixedArray _S1106 = points_11; + FixedArray _S1107 = points_11; + FixedArray _S1108 = points_11; + FixedArray _S1109 = points_11; + if(_S1055) + { + float3 _S1110 = _S1062 * _S1109[int(3)]; + float _S1111 = _S1110.x + _S1110.y + _S1110.z; + float4 _S1112 = _S1091; + *&((&_S1112)->w) = _S1111; + points_11[int(0)] = _S1106[int(0)]; + points_11[int(1)] = _S1107[int(1)]; + points_11[int(2)] = _S1108[int(2)]; + points_11[int(3)] = _S1052; + _S1092 = _S1112; + } + else + { + points_11[int(0)] = _S1106[int(0)]; + points_11[int(1)] = _S1107[int(1)]; + points_11[int(2)] = _S1108[int(2)]; + points_11[int(3)] = _S1109[int(3)]; + _S1092 = _S1091; + } + float3 _S1113 = _S1063 * points_11[int(2)]; + float _S1114 = _S1113.x + _S1113.y + _S1113.z; + FixedArray _S1115 = points_11; + FixedArray _S1116 = points_11; + float4 _S1117 = _S1091; + *&((&_S1117)->z) = _S1114; + float4 _S1118 = _S1092 + _S1117; + points_11[int(0)] = points_11[int(0)]; + points_11[int(1)] = _S1115[int(1)]; + points_11[int(2)] = _S1052; + points_11[int(3)] = _S1116[int(3)]; + _S1092 = _S1118; + } + else + { + FixedArray _S1119 = points_11; + FixedArray _S1120 = points_11; + FixedArray _S1121 = points_11; + points_11[int(0)] = points_11[int(0)]; + points_11[int(1)] = _S1119[int(1)]; + points_11[int(2)] = _S1120[int(2)]; + points_11[int(3)] = _S1121[int(3)]; + _S1092 = _S1091; + } + } + else + { + FixedArray _S1122 = points_11; + FixedArray _S1123 = points_11; + FixedArray _S1124 = points_11; + points_11[int(0)] = points_11[int(0)]; + points_11[int(1)] = _S1122[int(1)]; + points_11[int(2)] = _S1123[int(2)]; + points_11[int(3)] = _S1124[int(3)]; + _S1092 = _S1091; + } + if(_S1056) + { + FixedArray _S1125 = points_11; + float3 _S1126 = _S1064 * points_11[int(1)]; + float _S1127 = _S1126.x + _S1126.y + _S1126.z; + float4 _S1128 = _S1091; + *&((&_S1128)->y) = _S1127; + float4 _S1129 = _S1092 + _S1128; + points_11[int(0)] = _S1052; + points_11[int(1)] = _S1052; + points_11[int(2)] = _S1052; + points_11[int(3)] = _S1052; + _S1057 = _S1125[int(0)]; + _S1092 = _S1129; + } + else + { + FixedArray _S1130 = points_11; + FixedArray _S1131 = points_11; + FixedArray _S1132 = points_11; + points_11[int(0)] = points_11[int(0)]; + points_11[int(1)] = _S1130[int(1)]; + points_11[int(2)] = _S1131[int(2)]; + points_11[int(3)] = _S1132[int(3)]; + _S1057 = _S1052; + } + float3 _S1133 = _S1065 * (points_11[int(0)] + _S1057); + float _S1134 = _S1133.x + _S1133.y + _S1133.z; + float4 _S1135 = _S1091; + *&((&_S1135)->x) = _S1134; + _S1092 = _S1092 + _S1135; + } + else + { + _S1092 = _S1091; + } + } + else + { + _S1092 = _S1091; + } + *v_depths_4 = _S1092; + return; +} + +inline __device__ float ray_depth_to_linear_depth_factor_prism(float2 pix_center_12, float4 intrins_21, FixedArray dist_coeffs_25, int camera_model_23) +{ + float _S1136; + for(;;) + { + float2 uv_63 = (pix_center_12 - float2 {intrins_21.z, intrins_21.w}) / float2 {intrins_21.x, intrins_21.y}; + FixedArray _S1137 = dist_coeffs_25; + float2 uv_u_30; + bool _S1138 = undistort_point_2(uv_63, &_S1137, int(12), &uv_u_30); + if(!_S1138) + { + _S1136 = 0.0f; + break; + } + float3 raydir_16 = unproject_raydir_0(uv_u_30, camera_model_23, false); + _S1136 = float((F32_sign((raydir_16.z)))) / length_0(raydir_16); + break; + } + return _S1136; +} + +inline __device__ float depth_normal_loss_prism(float2 pix_center_13, float4 intrins_22, FixedArray dist_coeffs_26, int camera_model_24, bool is_ray_depth_21, float4 depths_10, float3 gt_normal_4) +{ + float _S1139; + for(;;) + { + float3 _S1140; + float3 * _S1141; + float3 * _S1142; + float3 * _S1143; + float3 * _S1144; + int _S1145; + FixedArray points_12; + for(;;) + { + float2 _S1146 = float2 {intrins_22.z, intrins_22.w}; + float2 _S1147 = float2 {intrins_22.x, intrins_22.y}; + float2 uv_64 = (pix_center_13 + make_float2 (-1.0f, -0.0f) - _S1146) / _S1147; + FixedArray _S1148 = dist_coeffs_26; + float2 uv_u_31; + bool _S1149 = undistort_point_2(uv_64, &_S1148, int(12), &uv_u_31); + float3 _S1150 = make_float3 (0.0f); + if(!_S1149) + { + _S1145 = int(0); + _S1144 = nullptr; + _S1143 = nullptr; + _S1142 = nullptr; + _S1141 = nullptr; + _S1140 = _S1150; + break; + } + float3 raydir_17 = unproject_raydir_0(uv_u_31, camera_model_24, is_ray_depth_21); + points_12[int(0)] = make_float3 (depths_10.x) * raydir_17; + float2 uv_65 = (pix_center_13 + make_float2 (1.0f, -0.0f) - _S1146) / _S1147; + FixedArray _S1151 = dist_coeffs_26; + float2 uv_u_32; + bool _S1152 = undistort_point_2(uv_65, &_S1151, int(12), &uv_u_32); + if(!_S1152) + { + _S1145 = int(0); + _S1144 = nullptr; + _S1143 = &points_12[int(0)]; + _S1142 = nullptr; + _S1141 = nullptr; + _S1140 = _S1150; + break; + } + float3 raydir_18 = unproject_raydir_0(uv_u_32, camera_model_24, is_ray_depth_21); + points_12[int(1)] = make_float3 (depths_10.y) * raydir_18; + float2 uv_66 = (pix_center_13 + make_float2 (0.0f, -1.0f) - _S1146) / _S1147; + FixedArray _S1153 = dist_coeffs_26; + float2 uv_u_33; + bool _S1154 = undistort_point_2(uv_66, &_S1153, int(12), &uv_u_33); + if(!_S1154) + { + _S1145 = int(0); + _S1144 = &points_12[int(1)]; + _S1143 = &points_12[int(0)]; + _S1142 = nullptr; + _S1141 = nullptr; + _S1140 = _S1150; + break; + } + float3 raydir_19 = unproject_raydir_0(uv_u_33, camera_model_24, is_ray_depth_21); + points_12[int(2)] = make_float3 (depths_10.z) * raydir_19; + float2 uv_67 = (pix_center_13 + make_float2 (0.0f, 1.0f) - _S1146) / _S1147; + FixedArray _S1155 = dist_coeffs_26; + float2 uv_u_34; + bool _S1156 = undistort_point_2(uv_67, &_S1155, int(12), &uv_u_34); + if(!_S1156) + { + _S1145 = int(0); + _S1144 = &points_12[int(1)]; + _S1143 = &points_12[int(0)]; + _S1142 = nullptr; + _S1141 = &points_12[int(2)]; + _S1140 = _S1150; + break; + } + float3 raydir_20 = unproject_raydir_0(uv_u_34, camera_model_24, is_ray_depth_21); + points_12[int(3)] = make_float3 (depths_10.w) * raydir_20; + float2 uv_68 = (pix_center_13 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S1146) / _S1147; + FixedArray _S1157 = dist_coeffs_26; + float2 uv_u_35; + bool _S1158 = undistort_point_2(uv_68, &_S1157, int(12), &uv_u_35); + if(!_S1158) + { + _S1145 = int(0); + _S1144 = &points_12[int(1)]; + _S1143 = &points_12[int(0)]; + _S1142 = &points_12[int(3)]; + _S1141 = &points_12[int(2)]; + _S1140 = _S1150; + break; + } + float3 raydir_21 = unproject_raydir_0(uv_u_35, camera_model_24, is_ray_depth_21); + _S1145 = int(1); + _S1144 = &points_12[int(1)]; + _S1143 = &points_12[int(0)]; + _S1142 = &points_12[int(3)]; + _S1141 = &points_12[int(2)]; + _S1140 = raydir_21; + break; + } + if(_S1145 != int(1)) + { + _S1139 = 0.0f; + break; + } + float3 normal_14 = cross_0(*_S1144 - *_S1143, - (*_S1142 - *_S1141)); + float3 normal_15; + if((dot_0(normal_14, normal_14)) != 0.0f) + { + normal_15 = normalize_0(normal_14); + } + else + { + normal_15 = normal_14; + } + float3 _S1159; + if((dot_0(gt_normal_4, gt_normal_4)) != 0.0f) + { + _S1159 = normalize_0(gt_normal_4); + } + else + { + _S1159 = gt_normal_4; + } + _S1139 = (1.0f - dot_0(normal_15, _S1159) + 0.00100000004749745f) / ((F32_max((dot_0(normal_15, - normalize_0(_S1140))), (0.0f))) + 0.00100000004749745f); + break; + } + return _S1139; +} + +struct s_bwd_prop_depth_normal_loss_Intermediates_2 +{ + float2 _S1160; + bool _S1161; + float2 _S1162; + bool _S1163; + float2 _S1164; + bool _S1165; + float2 _S1166; + bool _S1167; + float2 _S1168; + bool _S1169; +}; + +inline __device__ void depth_normal_loss_vjp_prism(float2 pix_center_14, float4 intrins_23, FixedArray dist_coeffs_27, int camera_model_25, bool is_ray_depth_22, float4 depths_11, float3 gt_normal_5, float v_loss_2, float4 * v_depths_5, float3 * v_gt_normal_2) +{ + float2 _S1170 = make_float2 (0.0f); + s_bwd_prop_depth_normal_loss_Intermediates_2 _S1171; + (&_S1171)->_S1160 = _S1170; + (&_S1171)->_S1161 = false; + (&_S1171)->_S1162 = _S1170; + (&_S1171)->_S1163 = false; + (&_S1171)->_S1164 = _S1170; + (&_S1171)->_S1165 = false; + (&_S1171)->_S1166 = _S1170; + (&_S1171)->_S1167 = false; + (&_S1171)->_S1168 = _S1170; + (&_S1171)->_S1169 = false; + (&_S1171)->_S1162 = _S1170; + (&_S1171)->_S1163 = false; + (&_S1171)->_S1164 = _S1170; + (&_S1171)->_S1165 = false; + (&_S1171)->_S1166 = _S1170; + (&_S1171)->_S1167 = false; + (&_S1171)->_S1168 = _S1170; + (&_S1171)->_S1169 = false; + float2 _S1172 = float2 {intrins_23.z, intrins_23.w}; + float2 _S1173 = float2 {intrins_23.x, intrins_23.y}; + float2 uv_69 = (pix_center_14 + make_float2 (-1.0f, -0.0f) - _S1172) / _S1173; + float2 _S1174 = _S1170; + FixedArray _S1175 = dist_coeffs_27; + bool _S1176 = undistort_point_2(uv_69, &_S1175, int(12), &_S1174); + (&_S1171)->_S1160 = _S1174; + (&_S1171)->_S1161 = _S1176; + bool _S1177 = !!_S1176; + bool _runFlag_20; + if(_S1177) + { + float2 uv_70 = (pix_center_14 + make_float2 (1.0f, -0.0f) - _S1172) / _S1173; + float2 _S1178 = _S1170; + FixedArray _S1179 = dist_coeffs_27; + bool _S1180 = undistort_point_2(uv_70, &_S1179, int(12), &_S1178); + (&_S1171)->_S1162 = _S1178; + (&_S1171)->_S1163 = _S1180; + if(!_S1180) + { + _runFlag_20 = false; + } + else + { + _runFlag_20 = _S1177; + } + if(_runFlag_20) + { + float2 uv_71 = (pix_center_14 + make_float2 (0.0f, -1.0f) - _S1172) / _S1173; + float2 _S1181 = _S1170; + FixedArray _S1182 = dist_coeffs_27; + bool _S1183 = undistort_point_2(uv_71, &_S1182, int(12), &_S1181); + (&_S1171)->_S1164 = _S1181; + (&_S1171)->_S1165 = _S1183; + if(!_S1183) + { + _runFlag_20 = false; + } + if(_runFlag_20) + { + float2 uv_72 = (pix_center_14 + make_float2 (0.0f, 1.0f) - _S1172) / _S1173; + float2 _S1184 = _S1170; + FixedArray _S1185 = dist_coeffs_27; + bool _S1186 = undistort_point_2(uv_72, &_S1185, int(12), &_S1184); + (&_S1171)->_S1166 = _S1184; + (&_S1171)->_S1167 = _S1186; + if(!_S1186) + { + _runFlag_20 = false; + } + if(_runFlag_20) + { + float2 uv_73 = (pix_center_14 - _S1172) / _S1173; + float2 _S1187 = _S1170; + FixedArray _S1188 = dist_coeffs_27; + bool _S1189 = undistort_point_2(uv_73, &_S1188, int(12), &_S1187); + (&_S1171)->_S1168 = _S1187; + (&_S1171)->_S1169 = _S1189; + } + } + } + } + s_bwd_prop_depth_normal_loss_Intermediates_2 _S1190 = _S1171; + float3 _S1191 = make_float3 (0.0f); + bool _S1192 = !!_S1171._S1161; + bool _runFlag_21; + bool _runFlag_22; + bool _runFlag_23; + int _S1193; + float3 raydir_22; + float3 _S1194; + float3 _S1195; + float3 _S1196; + float3 _S1197; + FixedArray points_13; + if(_S1192) + { + float3 _S1198 = s_primal_ctx_unproject_raydir_0(_S1190._S1160, camera_model_25, is_ray_depth_22); + float3 _S1199 = make_float3 (depths_11.x) * _S1198; + if(!_S1190._S1163) + { + _runFlag_20 = false; + } + else + { + _runFlag_20 = _S1192; + } + if(_runFlag_20) + { + float3 _S1200 = s_primal_ctx_unproject_raydir_0(_S1190._S1162, camera_model_25, is_ray_depth_22); + float3 _S1201 = make_float3 (depths_11.y) * _S1200; + if(!_S1190._S1165) + { + _runFlag_21 = false; + } + else + { + _runFlag_21 = _runFlag_20; + } + if(_runFlag_21) + { + float3 _S1202 = s_primal_ctx_unproject_raydir_0(_S1190._S1164, camera_model_25, is_ray_depth_22); + float3 _S1203 = make_float3 (depths_11.z) * _S1202; + if(!_S1190._S1167) + { + _runFlag_22 = false; + } + else + { + _runFlag_22 = _runFlag_21; + } + if(_runFlag_22) + { + float3 _S1204 = s_primal_ctx_unproject_raydir_0(_S1190._S1166, camera_model_25, is_ray_depth_22); + float3 _S1205 = make_float3 (depths_11.w) * _S1204; + if(!_S1190._S1169) + { + _runFlag_23 = false; + } + else + { + _runFlag_23 = _runFlag_22; + } + if(_runFlag_23) + { + float3 _S1206 = s_primal_ctx_unproject_raydir_0(_S1190._S1168, camera_model_25, is_ray_depth_22); + _S1193 = int(1); + raydir_22 = _S1206; + } + else + { + _S1193 = int(0); + raydir_22 = _S1204; + } + points_13[int(0)] = _S1199; + points_13[int(1)] = _S1201; + points_13[int(2)] = _S1203; + points_13[int(3)] = _S1205; + points_13[int(4)] = _S1191; + _S1194 = _S1204; + } + else + { + _S1193 = int(0); + raydir_22 = _S1202; + points_13[int(0)] = _S1199; + points_13[int(1)] = _S1201; + points_13[int(2)] = _S1203; + points_13[int(3)] = _S1191; + points_13[int(4)] = _S1191; + _S1194 = _S1191; + } + _S1195 = _S1202; + } + else + { + _S1193 = int(0); + raydir_22 = _S1200; + points_13[int(0)] = _S1199; + points_13[int(1)] = _S1201; + points_13[int(2)] = _S1191; + points_13[int(3)] = _S1191; + points_13[int(4)] = _S1191; + _runFlag_22 = false; + _S1194 = _S1191; + _S1195 = _S1191; + } + _S1196 = _S1200; + } + else + { + _S1193 = int(0); + raydir_22 = _S1198; + points_13[int(0)] = _S1199; + points_13[int(1)] = _S1191; + points_13[int(2)] = _S1191; + points_13[int(3)] = _S1191; + points_13[int(4)] = _S1191; + _runFlag_21 = false; + _runFlag_22 = false; + _S1194 = _S1191; + _S1195 = _S1191; + _S1196 = _S1191; + } + _S1197 = _S1198; + } + else + { + _S1193 = int(0); + points_13[int(0)] = _S1191; + points_13[int(1)] = _S1191; + points_13[int(2)] = _S1191; + points_13[int(3)] = _S1191; + points_13[int(4)] = _S1191; + _runFlag_20 = false; + _runFlag_21 = false; + _runFlag_22 = false; + _S1194 = _S1191; + _S1195 = _S1191; + _S1196 = _S1191; + _S1197 = _S1191; + } + bool _S1207 = !(_S1193 != int(1)); + bool _S1208; + float3 normal_16; + float3 _S1209; + float3 _S1210; + float3 _S1211; + float3 _S1212; + float _S1213; + float _S1214; + float _S1215; + float _S1216; + if(_S1207) + { + float3 dx_6 = points_13[int(1)] - points_13[int(0)]; + float3 _S1217 = - (points_13[int(3)] - points_13[int(2)]); + float3 _S1218 = s_primal_ctx_cross_0(dx_6, _S1217); + bool _S1219 = (s_primal_ctx_dot_0(_S1218, _S1218)) != 0.0f; + if(_S1219) + { + normal_16 = normalize_0(_S1218); + } + else + { + normal_16 = _S1218; + } + bool _S1220 = (s_primal_ctx_dot_0(gt_normal_5, gt_normal_5)) != 0.0f; + if(_S1220) + { + _S1209 = normalize_0(gt_normal_5); + } + else + { + _S1209 = gt_normal_5; + } + float3 _S1221 = - normalize_0(raydir_22); + float _S1222 = s_primal_ctx_dot_0(normal_16, _S1221); + float _S1223 = 1.0f - s_primal_ctx_dot_0(normal_16, _S1209) + 0.00100000004749745f; + float _S1224 = (F32_max((_S1222), (0.0f))) + 0.00100000004749745f; + _S1213 = _S1224 * _S1224; + _S1214 = _S1223; + _S1215 = _S1224; + _S1216 = _S1222; + raydir_22 = normal_16; + normal_16 = _S1221; + _runFlag_23 = _S1220; + _S1208 = _S1219; + _S1210 = _S1218; + _S1211 = dx_6; + _S1212 = _S1217; + } + else + { + _S1213 = 0.0f; + _S1214 = 0.0f; + _S1215 = 0.0f; + _S1216 = 0.0f; + raydir_22 = _S1191; + normal_16 = _S1191; + _S1209 = _S1191; + _runFlag_23 = false; + _S1208 = false; + _S1210 = _S1191; + _S1211 = _S1191; + _S1212 = _S1191; + } + float4 _S1225 = make_float4 (0.0f); + if(_S1207) + { + float _S1226 = v_loss_2 / _S1213; + float _S1227 = _S1214 * - _S1226; + float s_diff_num_T_2 = _S1215 * _S1226; + DiffPair_float_0 _S1228; + (&_S1228)->primal_0 = _S1216; + (&_S1228)->differential_0 = 0.0f; + DiffPair_float_0 _S1229; + (&_S1229)->primal_0 = 0.0f; + (&_S1229)->differential_0 = 0.0f; + _d_max_0(&_S1228, &_S1229, _S1227); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1230; + (&_S1230)->primal_0 = raydir_22; + (&_S1230)->differential_0 = _S1191; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1231; + (&_S1231)->primal_0 = normal_16; + (&_S1231)->differential_0 = _S1191; + s_bwd_prop_dot_0(&_S1230, &_S1231, _S1228.differential_0); + float _S1232 = - s_diff_num_T_2; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1233; + (&_S1233)->primal_0 = raydir_22; + (&_S1233)->differential_0 = _S1191; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1234; + (&_S1234)->primal_0 = _S1209; + (&_S1234)->differential_0 = _S1191; + s_bwd_prop_dot_0(&_S1233, &_S1234, _S1232); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1235 = _S1234; + float3 _S1236 = _S1230.differential_0 + _S1233.differential_0; + if(_runFlag_23) + { + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1237; + (&_S1237)->primal_0 = gt_normal_5; + (&_S1237)->differential_0 = _S1191; + s_bwd_normalize_impl_0(&_S1237, _S1235.differential_0); + raydir_22 = _S1237.differential_0; + } + else + { + raydir_22 = _S1235.differential_0; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1238; + (&_S1238)->primal_0 = gt_normal_5; + (&_S1238)->differential_0 = _S1191; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1239; + (&_S1239)->primal_0 = gt_normal_5; + (&_S1239)->differential_0 = _S1191; + s_bwd_prop_dot_0(&_S1238, &_S1239, 0.0f); + float3 _S1240 = _S1239.differential_0 + _S1238.differential_0 + raydir_22; + if(_S1208) + { + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1241; + (&_S1241)->primal_0 = _S1210; + (&_S1241)->differential_0 = _S1191; + s_bwd_normalize_impl_0(&_S1241, _S1236); + raydir_22 = _S1241.differential_0; + } + else + { + raydir_22 = _S1236; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1242; + (&_S1242)->primal_0 = _S1210; + (&_S1242)->differential_0 = _S1191; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1243; + (&_S1243)->primal_0 = _S1210; + (&_S1243)->differential_0 = _S1191; + s_bwd_prop_dot_0(&_S1242, &_S1243, 0.0f); + float3 _S1244 = _S1243.differential_0 + _S1242.differential_0 + raydir_22; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1245; + (&_S1245)->primal_0 = _S1211; + (&_S1245)->differential_0 = _S1191; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1246; + (&_S1246)->primal_0 = _S1212; + (&_S1246)->differential_0 = _S1191; + s_bwd_prop_cross_0(&_S1245, &_S1246, _S1244); + float3 s_diff_dy_T_6 = - _S1246.differential_0; + float3 _S1247 = - s_diff_dy_T_6; + float3 _S1248 = - _S1245.differential_0; + FixedArray _S1249; + _S1249[int(0)] = _S1191; + _S1249[int(1)] = _S1191; + _S1249[int(2)] = _S1191; + _S1249[int(3)] = _S1191; + _S1249[int(4)] = _S1191; + _S1249[int(2)] = _S1247; + _S1249[int(3)] = s_diff_dy_T_6; + _S1249[int(0)] = _S1248; + _S1249[int(1)] = _S1245.differential_0; + points_13[int(0)] = _S1249[int(0)]; + points_13[int(1)] = _S1249[int(1)]; + points_13[int(2)] = _S1249[int(2)]; + points_13[int(3)] = _S1249[int(3)]; + points_13[int(4)] = _S1249[int(4)]; + raydir_22 = _S1240; + } + else + { + points_13[int(0)] = _S1191; + points_13[int(1)] = _S1191; + points_13[int(2)] = _S1191; + points_13[int(3)] = _S1191; + points_13[int(4)] = _S1191; + raydir_22 = _S1191; + } + float4 _S1250; + if(_S1192) + { + if(_runFlag_20) + { + if(_runFlag_21) + { + if(_runFlag_22) + { + FixedArray _S1251 = points_13; + FixedArray _S1252 = points_13; + FixedArray _S1253 = points_13; + float3 _S1254 = _S1194 * points_13[int(3)]; + float _S1255 = _S1254.x + _S1254.y + _S1254.z; + float4 _S1256 = _S1225; + *&((&_S1256)->w) = _S1255; + points_13[int(0)] = _S1191; + points_13[int(1)] = _S1191; + points_13[int(2)] = _S1191; + points_13[int(3)] = _S1191; + points_13[int(4)] = _S1191; + _S1194 = _S1253[int(2)]; + normal_16 = _S1251[int(0)]; + _S1209 = _S1252[int(1)]; + _S1250 = _S1256; + } + else + { + FixedArray _S1257 = points_13; + FixedArray _S1258 = points_13; + FixedArray _S1259 = points_13; + FixedArray _S1260 = points_13; + points_13[int(0)] = points_13[int(0)]; + points_13[int(1)] = _S1257[int(1)]; + points_13[int(2)] = _S1258[int(2)]; + points_13[int(3)] = _S1259[int(3)]; + points_13[int(4)] = _S1260[int(4)]; + _S1194 = _S1191; + normal_16 = _S1191; + _S1209 = _S1191; + _S1250 = _S1225; + } + float3 _S1261 = _S1195 * (points_13[int(2)] + _S1194); + float _S1262 = _S1261.x + _S1261.y + _S1261.z; + float3 _S1263 = points_13[int(0)] + normal_16; + float3 _S1264 = points_13[int(1)] + _S1209; + float4 _S1265 = _S1225; + *&((&_S1265)->z) = _S1262; + float4 _S1266 = _S1250 + _S1265; + points_13[int(0)] = _S1191; + points_13[int(1)] = _S1191; + points_13[int(2)] = _S1191; + points_13[int(3)] = _S1191; + points_13[int(4)] = _S1191; + _S1194 = _S1264; + _S1195 = _S1263; + _S1250 = _S1266; + } + else + { + FixedArray _S1267 = points_13; + FixedArray _S1268 = points_13; + FixedArray _S1269 = points_13; + FixedArray _S1270 = points_13; + points_13[int(0)] = points_13[int(0)]; + points_13[int(1)] = _S1267[int(1)]; + points_13[int(2)] = _S1268[int(2)]; + points_13[int(3)] = _S1269[int(3)]; + points_13[int(4)] = _S1270[int(4)]; + _S1194 = _S1191; + _S1195 = _S1191; + _S1250 = _S1225; + } + float3 _S1271 = _S1196 * (points_13[int(1)] + _S1194); + float _S1272 = _S1271.x + _S1271.y + _S1271.z; + float3 _S1273 = points_13[int(0)] + _S1195; + float4 _S1274 = _S1225; + *&((&_S1274)->y) = _S1272; + float4 _S1275 = _S1250 + _S1274; + points_13[int(0)] = _S1191; + points_13[int(1)] = _S1191; + points_13[int(2)] = _S1191; + points_13[int(3)] = _S1191; + points_13[int(4)] = _S1191; + _S1194 = _S1273; + _S1250 = _S1275; + } + else + { + FixedArray _S1276 = points_13; + FixedArray _S1277 = points_13; + FixedArray _S1278 = points_13; + FixedArray _S1279 = points_13; + points_13[int(0)] = points_13[int(0)]; + points_13[int(1)] = _S1276[int(1)]; + points_13[int(2)] = _S1277[int(2)]; + points_13[int(3)] = _S1278[int(3)]; + points_13[int(4)] = _S1279[int(4)]; + _S1194 = _S1191; + _S1250 = _S1225; + } + float3 _S1280 = _S1197 * (points_13[int(0)] + _S1194); + float _S1281 = _S1280.x + _S1280.y + _S1280.z; + float4 _S1282 = _S1225; + *&((&_S1282)->x) = _S1281; + _S1250 = _S1250 + _S1282; + } + else + { + _S1250 = _S1225; + } + *v_depths_5 = _S1250; + *v_gt_normal_2 = raydir_22; + return; +} + +inline __device__ float3 generate_ray_d2n_rational(float2 pix_pos_9, float4 intrins_24, FixedArray dist_coeffs_28, int camera_model_26, bool is_ray_depth_23) +{ + float3 _S1283; + for(;;) + { + float2 uv_74 = (pix_pos_9 - float2 {intrins_24.z, intrins_24.w}) / float2 {intrins_24.x, intrins_24.y}; + FixedArray _S1284 = dist_coeffs_28; + float2 uv_u_36; + bool _S1285 = undistort_point_3(uv_74, &_S1284, int(12), &uv_u_36); + if(!_S1285) + { + int3 _S1286 = make_int3 (int(0)); + float3 _S1287 = make_float3 ((float)_S1286.x, (float)_S1286.y, (float)_S1286.z); + _S1283 = _S1287; + break; + } + _S1283 = unproject_raydir_0(uv_u_36, camera_model_26, is_ray_depth_23); + break; + } + return _S1283; +} + +inline __device__ float3 depth_to_point_rational(float2 pix_pos_10, float4 intrins_25, FixedArray dist_coeffs_29, int camera_model_27, bool is_ray_depth_24, float depth_8) +{ + float3 _S1288; + for(;;) + { + float2 uv_75 = (pix_pos_10 - float2 {intrins_25.z, intrins_25.w}) / float2 {intrins_25.x, intrins_25.y}; + FixedArray _S1289 = dist_coeffs_29; + float2 uv_u_37; + bool _S1290 = undistort_point_3(uv_75, &_S1289, int(12), &uv_u_37); + if(!_S1290) + { + _S1288 = make_float3 (0.0f); + break; + } + _S1288 = make_float3 (depth_8) * unproject_raydir_0(uv_u_37, camera_model_27, is_ray_depth_24); + break; + } + return _S1288; +} + +struct s_bwd_prop_depth_to_point_Intermediates_3 +{ + float2 _S1291; + bool _S1292; +}; + +inline __device__ float depth_to_point_vjp_rational(float2 pix_pos_11, float4 intrins_26, FixedArray dist_coeffs_30, int camera_model_28, bool is_ray_depth_25, float depth_9, float3 v_point_3) +{ + float2 _S1293 = make_float2 (0.0f); + s_bwd_prop_depth_to_point_Intermediates_3 _S1294; + (&_S1294)->_S1291 = _S1293; + (&_S1294)->_S1292 = false; + float2 uv_76 = (pix_pos_11 - float2 {intrins_26.z, intrins_26.w}) / float2 {intrins_26.x, intrins_26.y}; + float2 _S1295 = _S1293; + FixedArray _S1296 = dist_coeffs_30; + bool _S1297 = undistort_point_3(uv_76, &_S1296, int(12), &_S1295); + (&_S1294)->_S1291 = _S1295; + (&_S1294)->_S1292 = _S1297; + s_bwd_prop_depth_to_point_Intermediates_3 _S1298 = _S1294; + float3 _S1299 = make_float3 (0.0f); + bool _S1300 = !!_S1294._S1292; + float3 _S1301; + if(_S1300) + { + _S1301 = s_primal_ctx_unproject_raydir_0(_S1298._S1291, camera_model_28, is_ray_depth_25); + } + else + { + _S1301 = _S1299; + } + if(_S1300) + { + _S1301 = _S1301 * v_point_3; + } + else + { + _S1301 = _S1299; + } + return _S1301.x + _S1301.y + _S1301.z; +} + +inline __device__ float3 depth_to_normal_rational(float2 pix_center_15, float4 intrins_27, FixedArray dist_coeffs_31, int camera_model_29, bool is_ray_depth_26, float4 depths_12) +{ + float3 normal_17; + for(;;) + { + bool _S1302; + if((depths_12.x) == 0.0f) + { + _S1302 = true; + } + else + { + _S1302 = (depths_12.y) == 0.0f; + } + if(_S1302) + { + _S1302 = true; + } + else + { + _S1302 = (depths_12.z) == 0.0f; + } + if(_S1302) + { + _S1302 = true; + } + else + { + _S1302 = (depths_12.w) == 0.0f; + } + if(_S1302) + { + normal_17 = make_float3 (0.0f); + break; + } + float3 * _S1303; + float3 * _S1304; + float3 * _S1305; + float3 * _S1306; + int _S1307; + FixedArray points_14; + for(;;) + { + float2 _S1308 = float2 {intrins_27.z, intrins_27.w}; + float2 _S1309 = float2 {intrins_27.x, intrins_27.y}; + float2 uv_77 = (pix_center_15 + make_float2 (-1.0f, -0.0f) - _S1308) / _S1309; + FixedArray _S1310 = dist_coeffs_31; + float2 uv_u_38; + bool _S1311 = undistort_point_3(uv_77, &_S1310, int(12), &uv_u_38); + if(!_S1311) + { + float3 _S1312 = make_float3 (0.0f); + _S1307 = int(0); + _S1306 = nullptr; + _S1305 = nullptr; + _S1304 = nullptr; + _S1303 = nullptr; + normal_17 = _S1312; + break; + } + points_14[int(0)] = make_float3 (depths_12.x) * unproject_raydir_0(uv_u_38, camera_model_29, is_ray_depth_26); + for(;;) + { + float2 uv_78 = (pix_center_15 + make_float2 (1.0f, -0.0f) - _S1308) / _S1309; + FixedArray _S1313 = dist_coeffs_31; + float2 uv_u_39; + bool _S1314 = undistort_point_3(uv_78, &_S1313, int(12), &uv_u_39); + if(!_S1314) + { + float3 _S1315 = make_float3 (0.0f); + _S1307 = int(0); + _S1306 = nullptr; + normal_17 = _S1315; + break; + } + points_14[int(1)] = make_float3 (depths_12.y) * unproject_raydir_0(uv_u_39, camera_model_29, is_ray_depth_26); + _S1307 = int(2); + _S1306 = &points_14[int(1)]; + break; + } + if(_S1307 != int(2)) + { + _S1305 = &points_14[int(0)]; + _S1304 = nullptr; + _S1303 = nullptr; + break; + } + float2 uv_79 = (pix_center_15 + make_float2 (0.0f, -1.0f) - _S1308) / _S1309; + FixedArray _S1316 = dist_coeffs_31; + float2 uv_u_40; + bool _S1317 = undistort_point_3(uv_79, &_S1316, int(12), &uv_u_40); + if(!_S1317) + { + float3 _S1318 = make_float3 (0.0f); + _S1307 = int(0); + _S1305 = &points_14[int(0)]; + _S1304 = nullptr; + _S1303 = nullptr; + normal_17 = _S1318; + break; + } + points_14[int(2)] = make_float3 (depths_12.z) * unproject_raydir_0(uv_u_40, camera_model_29, is_ray_depth_26); + for(;;) + { + float2 uv_80 = (pix_center_15 + make_float2 (0.0f, 1.0f) - _S1308) / _S1309; + FixedArray _S1319 = dist_coeffs_31; + float2 uv_u_41; + bool _S1320 = undistort_point_3(uv_80, &_S1319, int(12), &uv_u_41); + if(!_S1320) + { + float3 _S1321 = make_float3 (0.0f); + _S1307 = int(0); + _S1305 = nullptr; + normal_17 = _S1321; + break; + } + points_14[int(3)] = make_float3 (depths_12.w) * unproject_raydir_0(uv_u_41, camera_model_29, is_ray_depth_26); + _S1307 = int(2); + _S1305 = &points_14[int(3)]; + break; + } + if(_S1307 != int(2)) + { + float3 * _S1322 = _S1305; + _S1305 = &points_14[int(0)]; + _S1304 = _S1322; + _S1303 = &points_14[int(2)]; + break; + } + float3 * _S1323 = _S1305; + _S1307 = int(1); + _S1305 = &points_14[int(0)]; + _S1304 = _S1323; + _S1303 = &points_14[int(2)]; + break; + } + if(_S1307 != int(1)) + { + break; + } + float3 normal_18 = cross_0(*_S1306 - *_S1305, - (*_S1304 - *_S1303)); + if((dot_0(normal_18, normal_18)) != 0.0f) + { + normal_17 = normal_18 / make_float3 (length_0(normal_18)); + } + else + { + normal_17 = normal_18; + } + break; + } + return normal_17; +} + +struct s_bwd_prop_depth_to_normal_Intermediates_3 +{ + float2 _S1324; + bool _S1325; + float2 _S1326; + bool _S1327; + float2 _S1328; + bool _S1329; + float2 _S1330; + bool _S1331; +}; + +inline __device__ void depth_to_normal_vjp_rational(float2 pix_center_16, float4 intrins_28, FixedArray dist_coeffs_32, int camera_model_30, bool is_ray_depth_27, float4 depths_13, float3 v_normal_4, float4 * v_depths_6) +{ + float2 _S1332 = make_float2 (0.0f); + s_bwd_prop_depth_to_normal_Intermediates_3 _S1333; + (&_S1333)->_S1324 = _S1332; + (&_S1333)->_S1325 = false; + (&_S1333)->_S1326 = _S1332; + (&_S1333)->_S1327 = false; + (&_S1333)->_S1328 = _S1332; + (&_S1333)->_S1329 = false; + (&_S1333)->_S1330 = _S1332; + (&_S1333)->_S1331 = false; + (&_S1333)->_S1324 = _S1332; + (&_S1333)->_S1325 = false; + (&_S1333)->_S1326 = _S1332; + (&_S1333)->_S1327 = false; + (&_S1333)->_S1328 = _S1332; + (&_S1333)->_S1329 = false; + (&_S1333)->_S1330 = _S1332; + (&_S1333)->_S1331 = false; + bool _S1334 = (depths_13.x) == 0.0f; + bool _runFlag_24; + if(_S1334) + { + _runFlag_24 = true; + } + else + { + _runFlag_24 = (depths_13.y) == 0.0f; + } + if(_runFlag_24) + { + _runFlag_24 = true; + } + else + { + _runFlag_24 = (depths_13.z) == 0.0f; + } + if(_runFlag_24) + { + _runFlag_24 = true; + } + else + { + _runFlag_24 = (depths_13.w) == 0.0f; + } + int _S1335; + if(!_runFlag_24) + { + float2 _S1336 = float2 {intrins_28.z, intrins_28.w}; + float2 _S1337 = float2 {intrins_28.x, intrins_28.y}; + float2 uv_81 = (pix_center_16 + make_float2 (-1.0f, -0.0f) - _S1336) / _S1337; + float2 _S1338 = _S1332; + FixedArray _S1339 = dist_coeffs_32; + bool _S1340 = undistort_point_3(uv_81, &_S1339, int(12), &_S1338); + (&_S1333)->_S1324 = _S1338; + (&_S1333)->_S1325 = _S1340; + bool _S1341 = !!_S1340; + if(_S1341) + { + float2 uv_82 = (pix_center_16 + make_float2 (1.0f, -0.0f) - _S1336) / _S1337; + float2 _S1342 = _S1332; + FixedArray _S1343 = dist_coeffs_32; + bool _S1344 = undistort_point_3(uv_82, &_S1343, int(12), &_S1342); + (&_S1333)->_S1326 = _S1342; + (&_S1333)->_S1327 = _S1344; + if(!!_S1344) + { + _S1335 = int(2); + } + else + { + _S1335 = int(0); + } + if(_S1335 != int(2)) + { + _runFlag_24 = false; + } + else + { + _runFlag_24 = _S1341; + } + if(_runFlag_24) + { + float2 uv_83 = (pix_center_16 + make_float2 (0.0f, -1.0f) - _S1336) / _S1337; + float2 _S1345 = _S1332; + FixedArray _S1346 = dist_coeffs_32; + bool _S1347 = undistort_point_3(uv_83, &_S1346, int(12), &_S1345); + (&_S1333)->_S1328 = _S1345; + (&_S1333)->_S1329 = _S1347; + if(!_S1347) + { + _runFlag_24 = false; + } + if(_runFlag_24) + { + float2 uv_84 = (pix_center_16 + make_float2 (0.0f, 1.0f) - _S1336) / _S1337; + float2 _S1348 = _S1332; + FixedArray _S1349 = dist_coeffs_32; + bool _S1350 = undistort_point_3(uv_84, &_S1349, int(12), &_S1348); + (&_S1333)->_S1330 = _S1348; + (&_S1333)->_S1331 = _S1350; + } + } + } + } + s_bwd_prop_depth_to_normal_Intermediates_3 _S1351 = _S1333; + float3 _S1352 = make_float3 (0.0f); + if(_S1334) + { + _runFlag_24 = true; + } + else + { + _runFlag_24 = (depths_13.y) == 0.0f; + } + if(_runFlag_24) + { + _runFlag_24 = true; + } + else + { + _runFlag_24 = (depths_13.z) == 0.0f; + } + if(_runFlag_24) + { + _runFlag_24 = true; + } + else + { + _runFlag_24 = (depths_13.w) == 0.0f; + } + bool _S1353 = !_runFlag_24; + bool _runFlag_25; + bool _runFlag_26; + bool _S1354; + bool _runFlag_27; + bool _S1355; + bool _S1356; + FixedArray points_15; + float3 _S1357; + float3 _S1358; + float3 _S1359; + float3 _S1360; + float3 _S1361; + float3 _S1362; + float3 _S1363; + float3 _S1364; + float3 _S1365; + if(_S1353) + { + bool _S1366 = !!_S1351._S1325; + if(_S1366) + { + float3 _S1367 = s_primal_ctx_unproject_raydir_0(_S1351._S1324, camera_model_30, is_ray_depth_27); + float3 _S1368 = make_float3 (depths_13.x) * _S1367; + bool _S1369 = !!_S1351._S1327; + if(_S1369) + { + float3 _S1370 = s_primal_ctx_unproject_raydir_0(_S1351._S1326, camera_model_30, is_ray_depth_27); + float3 _S1371 = make_float3 (depths_13.y) * _S1370; + _S1335 = int(2); + points_15[int(0)] = _S1368; + points_15[int(1)] = _S1371; + points_15[int(2)] = _S1352; + points_15[int(3)] = _S1352; + _S1357 = _S1370; + } + else + { + _S1335 = int(0); + points_15[int(0)] = _S1368; + points_15[int(1)] = _S1352; + points_15[int(2)] = _S1352; + points_15[int(3)] = _S1352; + _S1357 = _S1352; + } + if(_S1335 != int(2)) + { + _runFlag_24 = false; + } + else + { + _runFlag_24 = _S1366; + _S1335 = int(0); + } + if(_runFlag_24) + { + if(!_S1351._S1329) + { + _runFlag_25 = false; + _S1335 = int(0); + } + else + { + _runFlag_25 = _runFlag_24; + } + if(_runFlag_25) + { + float3 _S1372 = s_primal_ctx_unproject_raydir_0(_S1351._S1328, camera_model_30, is_ray_depth_27); + points_15[int(2)] = make_float3 (depths_13.z) * _S1372; + bool _S1373 = !!_S1351._S1331; + int _S1374; + if(_S1373) + { + float3 _S1375 = s_primal_ctx_unproject_raydir_0(_S1351._S1330, camera_model_30, is_ray_depth_27); + points_15[int(3)] = make_float3 (depths_13.w) * _S1375; + _S1374 = int(2); + _S1358 = _S1375; + } + else + { + _S1374 = int(0); + _S1358 = _S1352; + } + if(_S1374 != int(2)) + { + _runFlag_26 = false; + _S1335 = _S1374; + } + else + { + _runFlag_26 = _runFlag_25; + } + if(_runFlag_26) + { + _S1335 = int(1); + } + _runFlag_26 = _S1373; + _S1359 = _S1372; + } + else + { + _runFlag_26 = false; + _S1358 = _S1352; + _S1359 = _S1352; + } + } + else + { + _runFlag_25 = false; + _runFlag_26 = false; + _S1358 = _S1352; + _S1359 = _S1352; + } + float3 _S1376 = _S1357; + _S1357 = _S1358; + _S1358 = _S1359; + _S1354 = _S1369; + _S1359 = _S1376; + _S1360 = _S1367; + } + else + { + _S1335 = int(0); + points_15[int(0)] = _S1352; + points_15[int(1)] = _S1352; + points_15[int(2)] = _S1352; + points_15[int(3)] = _S1352; + _runFlag_24 = false; + _runFlag_25 = false; + _runFlag_26 = false; + _S1357 = _S1352; + _S1358 = _S1352; + _S1354 = false; + _S1359 = _S1352; + _S1360 = _S1352; + } + if(_S1335 != int(1)) + { + _runFlag_27 = false; + } + else + { + _runFlag_27 = _S1353; + } + if(_runFlag_27) + { + float3 dx_7 = points_15[int(1)] - points_15[int(0)]; + float3 _S1377 = - (points_15[int(3)] - points_15[int(2)]); + float3 _S1378 = s_primal_ctx_cross_0(dx_7, _S1377); + bool _S1379 = (s_primal_ctx_dot_0(_S1378, _S1378)) != 0.0f; + if(_S1379) + { + float _S1380 = length_0(_S1378); + float3 _S1381 = make_float3 (_S1380); + _S1361 = make_float3 (_S1380 * _S1380); + _S1362 = _S1381; + } + else + { + _S1361 = _S1352; + _S1362 = _S1352; + } + float3 _S1382 = _S1362; + _S1355 = _S1379; + _S1362 = _S1378; + _S1363 = _S1382; + _S1364 = dx_7; + _S1365 = _S1377; + } + else + { + _S1355 = false; + _S1361 = _S1352; + _S1362 = _S1352; + _S1363 = _S1352; + _S1364 = _S1352; + _S1365 = _S1352; + } + bool _S1383 = _runFlag_24; + bool _S1384 = _runFlag_25; + bool _S1385 = _runFlag_26; + float3 _S1386 = _S1357; + float3 _S1387 = _S1358; + bool _S1388 = _S1354; + float3 _S1389 = _S1359; + float3 _S1390 = _S1360; + _runFlag_24 = _runFlag_27; + _runFlag_25 = _S1355; + _S1357 = _S1361; + _S1358 = _S1362; + _S1359 = _S1363; + _S1360 = _S1364; + _S1361 = _S1365; + _runFlag_26 = _S1366; + _S1354 = _S1383; + _runFlag_27 = _S1384; + _S1355 = _S1385; + _S1362 = _S1386; + _S1363 = _S1387; + _S1356 = _S1388; + _S1364 = _S1389; + _S1365 = _S1390; + } + else + { + _runFlag_24 = false; + _runFlag_25 = false; + _S1357 = _S1352; + _S1358 = _S1352; + _S1359 = _S1352; + _S1360 = _S1352; + _S1361 = _S1352; + _runFlag_26 = false; + _S1354 = false; + _runFlag_27 = false; + _S1355 = false; + _S1362 = _S1352; + _S1363 = _S1352; + _S1356 = false; + _S1364 = _S1352; + _S1365 = _S1352; + } + float4 _S1391 = make_float4 (0.0f); + float4 _S1392; + if(_S1353) + { + if(_runFlag_24) + { + if(_runFlag_25) + { + float3 _S1393 = v_normal_4 / _S1357; + float3 _S1394 = _S1358 * - _S1393; + float3 _S1395 = _S1359 * _S1393; + float _S1396 = _S1394.x + _S1394.y + _S1394.z; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1397; + (&_S1397)->primal_0 = _S1358; + (&_S1397)->differential_0 = _S1352; + s_bwd_length_impl_0(&_S1397, _S1396); + _S1357 = _S1395 + _S1397.differential_0; + } + else + { + _S1357 = v_normal_4; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1398; + (&_S1398)->primal_0 = _S1358; + (&_S1398)->differential_0 = _S1352; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1399; + (&_S1399)->primal_0 = _S1358; + (&_S1399)->differential_0 = _S1352; + s_bwd_prop_dot_0(&_S1398, &_S1399, 0.0f); + float3 _S1400 = _S1399.differential_0 + _S1398.differential_0 + _S1357; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1401; + (&_S1401)->primal_0 = _S1360; + (&_S1401)->differential_0 = _S1352; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1402; + (&_S1402)->primal_0 = _S1361; + (&_S1402)->differential_0 = _S1352; + s_bwd_prop_cross_0(&_S1401, &_S1402, _S1400); + float3 s_diff_dy_T_7 = - _S1402.differential_0; + float3 _S1403 = - s_diff_dy_T_7; + float3 _S1404 = - _S1401.differential_0; + FixedArray _S1405; + _S1405[int(0)] = _S1352; + _S1405[int(1)] = _S1352; + _S1405[int(2)] = _S1352; + _S1405[int(3)] = _S1352; + _S1405[int(2)] = _S1403; + _S1405[int(3)] = s_diff_dy_T_7; + _S1405[int(0)] = _S1404; + _S1405[int(1)] = _S1401.differential_0; + points_15[int(0)] = _S1405[int(0)]; + points_15[int(1)] = _S1405[int(1)]; + points_15[int(2)] = _S1405[int(2)]; + points_15[int(3)] = _S1405[int(3)]; + } + else + { + points_15[int(0)] = _S1352; + points_15[int(1)] = _S1352; + points_15[int(2)] = _S1352; + points_15[int(3)] = _S1352; + } + if(_runFlag_26) + { + if(_S1354) + { + if(_runFlag_27) + { + FixedArray _S1406 = points_15; + FixedArray _S1407 = points_15; + FixedArray _S1408 = points_15; + FixedArray _S1409 = points_15; + if(_S1355) + { + float3 _S1410 = _S1362 * _S1409[int(3)]; + float _S1411 = _S1410.x + _S1410.y + _S1410.z; + float4 _S1412 = _S1391; + *&((&_S1412)->w) = _S1411; + points_15[int(0)] = _S1406[int(0)]; + points_15[int(1)] = _S1407[int(1)]; + points_15[int(2)] = _S1408[int(2)]; + points_15[int(3)] = _S1352; + _S1392 = _S1412; + } + else + { + points_15[int(0)] = _S1406[int(0)]; + points_15[int(1)] = _S1407[int(1)]; + points_15[int(2)] = _S1408[int(2)]; + points_15[int(3)] = _S1409[int(3)]; + _S1392 = _S1391; + } + float3 _S1413 = _S1363 * points_15[int(2)]; + float _S1414 = _S1413.x + _S1413.y + _S1413.z; + FixedArray _S1415 = points_15; + FixedArray _S1416 = points_15; + float4 _S1417 = _S1391; + *&((&_S1417)->z) = _S1414; + float4 _S1418 = _S1392 + _S1417; + points_15[int(0)] = points_15[int(0)]; + points_15[int(1)] = _S1415[int(1)]; + points_15[int(2)] = _S1352; + points_15[int(3)] = _S1416[int(3)]; + _S1392 = _S1418; + } + else + { + FixedArray _S1419 = points_15; + FixedArray _S1420 = points_15; + FixedArray _S1421 = points_15; + points_15[int(0)] = points_15[int(0)]; + points_15[int(1)] = _S1419[int(1)]; + points_15[int(2)] = _S1420[int(2)]; + points_15[int(3)] = _S1421[int(3)]; + _S1392 = _S1391; + } + } + else + { + FixedArray _S1422 = points_15; + FixedArray _S1423 = points_15; + FixedArray _S1424 = points_15; + points_15[int(0)] = points_15[int(0)]; + points_15[int(1)] = _S1422[int(1)]; + points_15[int(2)] = _S1423[int(2)]; + points_15[int(3)] = _S1424[int(3)]; + _S1392 = _S1391; + } + if(_S1356) + { + FixedArray _S1425 = points_15; + float3 _S1426 = _S1364 * points_15[int(1)]; + float _S1427 = _S1426.x + _S1426.y + _S1426.z; + float4 _S1428 = _S1391; + *&((&_S1428)->y) = _S1427; + float4 _S1429 = _S1392 + _S1428; + points_15[int(0)] = _S1352; + points_15[int(1)] = _S1352; + points_15[int(2)] = _S1352; + points_15[int(3)] = _S1352; + _S1357 = _S1425[int(0)]; + _S1392 = _S1429; + } + else + { + FixedArray _S1430 = points_15; + FixedArray _S1431 = points_15; + FixedArray _S1432 = points_15; + points_15[int(0)] = points_15[int(0)]; + points_15[int(1)] = _S1430[int(1)]; + points_15[int(2)] = _S1431[int(2)]; + points_15[int(3)] = _S1432[int(3)]; + _S1357 = _S1352; + } + float3 _S1433 = _S1365 * (points_15[int(0)] + _S1357); + float _S1434 = _S1433.x + _S1433.y + _S1433.z; + float4 _S1435 = _S1391; + *&((&_S1435)->x) = _S1434; + _S1392 = _S1392 + _S1435; + } + else + { + _S1392 = _S1391; + } + } + else + { + _S1392 = _S1391; + } + *v_depths_6 = _S1392; + return; +} + +inline __device__ float ray_depth_to_linear_depth_factor_rational(float2 pix_center_17, float4 intrins_29, FixedArray dist_coeffs_33, int camera_model_31) +{ + float _S1436; + for(;;) + { + float2 uv_85 = (pix_center_17 - float2 {intrins_29.z, intrins_29.w}) / float2 {intrins_29.x, intrins_29.y}; + FixedArray _S1437 = dist_coeffs_33; + float2 uv_u_42; + bool _S1438 = undistort_point_3(uv_85, &_S1437, int(12), &uv_u_42); + if(!_S1438) + { + _S1436 = 0.0f; + break; + } + float3 raydir_23 = unproject_raydir_0(uv_u_42, camera_model_31, false); + _S1436 = float((F32_sign((raydir_23.z)))) / length_0(raydir_23); + break; + } + return _S1436; +} + +inline __device__ float depth_normal_loss_rational(float2 pix_center_18, float4 intrins_30, FixedArray dist_coeffs_34, int camera_model_32, bool is_ray_depth_28, float4 depths_14, float3 gt_normal_6) +{ + float _S1439; + for(;;) + { + float3 _S1440; + float3 * _S1441; + float3 * _S1442; + float3 * _S1443; + float3 * _S1444; + int _S1445; + FixedArray points_16; + for(;;) + { + float2 _S1446 = float2 {intrins_30.z, intrins_30.w}; + float2 _S1447 = float2 {intrins_30.x, intrins_30.y}; + float2 uv_86 = (pix_center_18 + make_float2 (-1.0f, -0.0f) - _S1446) / _S1447; + FixedArray _S1448 = dist_coeffs_34; + float2 uv_u_43; + bool _S1449 = undistort_point_3(uv_86, &_S1448, int(12), &uv_u_43); + float3 _S1450 = make_float3 (0.0f); + if(!_S1449) + { + _S1445 = int(0); + _S1444 = nullptr; + _S1443 = nullptr; + _S1442 = nullptr; + _S1441 = nullptr; + _S1440 = _S1450; + break; + } + float3 raydir_24 = unproject_raydir_0(uv_u_43, camera_model_32, is_ray_depth_28); + points_16[int(0)] = make_float3 (depths_14.x) * raydir_24; + float2 uv_87 = (pix_center_18 + make_float2 (1.0f, -0.0f) - _S1446) / _S1447; + FixedArray _S1451 = dist_coeffs_34; + float2 uv_u_44; + bool _S1452 = undistort_point_3(uv_87, &_S1451, int(12), &uv_u_44); + if(!_S1452) + { + _S1445 = int(0); + _S1444 = nullptr; + _S1443 = &points_16[int(0)]; + _S1442 = nullptr; + _S1441 = nullptr; + _S1440 = _S1450; + break; + } + float3 raydir_25 = unproject_raydir_0(uv_u_44, camera_model_32, is_ray_depth_28); + points_16[int(1)] = make_float3 (depths_14.y) * raydir_25; + float2 uv_88 = (pix_center_18 + make_float2 (0.0f, -1.0f) - _S1446) / _S1447; + FixedArray _S1453 = dist_coeffs_34; + float2 uv_u_45; + bool _S1454 = undistort_point_3(uv_88, &_S1453, int(12), &uv_u_45); + if(!_S1454) + { + _S1445 = int(0); + _S1444 = &points_16[int(1)]; + _S1443 = &points_16[int(0)]; + _S1442 = nullptr; + _S1441 = nullptr; + _S1440 = _S1450; + break; + } + float3 raydir_26 = unproject_raydir_0(uv_u_45, camera_model_32, is_ray_depth_28); + points_16[int(2)] = make_float3 (depths_14.z) * raydir_26; + float2 uv_89 = (pix_center_18 + make_float2 (0.0f, 1.0f) - _S1446) / _S1447; + FixedArray _S1455 = dist_coeffs_34; + float2 uv_u_46; + bool _S1456 = undistort_point_3(uv_89, &_S1455, int(12), &uv_u_46); + if(!_S1456) + { + _S1445 = int(0); + _S1444 = &points_16[int(1)]; + _S1443 = &points_16[int(0)]; + _S1442 = nullptr; + _S1441 = &points_16[int(2)]; + _S1440 = _S1450; + break; + } + float3 raydir_27 = unproject_raydir_0(uv_u_46, camera_model_32, is_ray_depth_28); + points_16[int(3)] = make_float3 (depths_14.w) * raydir_27; + float2 uv_90 = (pix_center_18 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S1446) / _S1447; + FixedArray _S1457 = dist_coeffs_34; + float2 uv_u_47; + bool _S1458 = undistort_point_3(uv_90, &_S1457, int(12), &uv_u_47); + if(!_S1458) + { + _S1445 = int(0); + _S1444 = &points_16[int(1)]; + _S1443 = &points_16[int(0)]; + _S1442 = &points_16[int(3)]; + _S1441 = &points_16[int(2)]; + _S1440 = _S1450; + break; + } + float3 raydir_28 = unproject_raydir_0(uv_u_47, camera_model_32, is_ray_depth_28); + _S1445 = int(1); + _S1444 = &points_16[int(1)]; + _S1443 = &points_16[int(0)]; + _S1442 = &points_16[int(3)]; + _S1441 = &points_16[int(2)]; + _S1440 = raydir_28; + break; + } + if(_S1445 != int(1)) + { + _S1439 = 0.0f; + break; + } + float3 normal_19 = cross_0(*_S1444 - *_S1443, - (*_S1442 - *_S1441)); + float3 normal_20; + if((dot_0(normal_19, normal_19)) != 0.0f) + { + normal_20 = normalize_0(normal_19); + } + else + { + normal_20 = normal_19; + } + float3 _S1459; + if((dot_0(gt_normal_6, gt_normal_6)) != 0.0f) + { + _S1459 = normalize_0(gt_normal_6); + } + else + { + _S1459 = gt_normal_6; + } + _S1439 = (1.0f - dot_0(normal_20, _S1459) + 0.00100000004749745f) / ((F32_max((dot_0(normal_20, - normalize_0(_S1440))), (0.0f))) + 0.00100000004749745f); + break; + } + return _S1439; +} + +struct s_bwd_prop_depth_normal_loss_Intermediates_3 +{ + float2 _S1460; + bool _S1461; + float2 _S1462; + bool _S1463; + float2 _S1464; + bool _S1465; + float2 _S1466; + bool _S1467; + float2 _S1468; + bool _S1469; +}; + +inline __device__ void depth_normal_loss_vjp_rational(float2 pix_center_19, float4 intrins_31, FixedArray dist_coeffs_35, int camera_model_33, bool is_ray_depth_29, float4 depths_15, float3 gt_normal_7, float v_loss_3, float4 * v_depths_7, float3 * v_gt_normal_3) +{ + float2 _S1470 = make_float2 (0.0f); + s_bwd_prop_depth_normal_loss_Intermediates_3 _S1471; + (&_S1471)->_S1460 = _S1470; + (&_S1471)->_S1461 = false; + (&_S1471)->_S1462 = _S1470; + (&_S1471)->_S1463 = false; + (&_S1471)->_S1464 = _S1470; + (&_S1471)->_S1465 = false; + (&_S1471)->_S1466 = _S1470; + (&_S1471)->_S1467 = false; + (&_S1471)->_S1468 = _S1470; + (&_S1471)->_S1469 = false; + (&_S1471)->_S1462 = _S1470; + (&_S1471)->_S1463 = false; + (&_S1471)->_S1464 = _S1470; + (&_S1471)->_S1465 = false; + (&_S1471)->_S1466 = _S1470; + (&_S1471)->_S1467 = false; + (&_S1471)->_S1468 = _S1470; + (&_S1471)->_S1469 = false; + float2 _S1472 = float2 {intrins_31.z, intrins_31.w}; + float2 _S1473 = float2 {intrins_31.x, intrins_31.y}; + float2 uv_91 = (pix_center_19 + make_float2 (-1.0f, -0.0f) - _S1472) / _S1473; + float2 _S1474 = _S1470; + FixedArray _S1475 = dist_coeffs_35; + bool _S1476 = undistort_point_3(uv_91, &_S1475, int(12), &_S1474); + (&_S1471)->_S1460 = _S1474; + (&_S1471)->_S1461 = _S1476; + bool _S1477 = !!_S1476; + bool _runFlag_28; + if(_S1477) + { + float2 uv_92 = (pix_center_19 + make_float2 (1.0f, -0.0f) - _S1472) / _S1473; + float2 _S1478 = _S1470; + FixedArray _S1479 = dist_coeffs_35; + bool _S1480 = undistort_point_3(uv_92, &_S1479, int(12), &_S1478); + (&_S1471)->_S1462 = _S1478; + (&_S1471)->_S1463 = _S1480; + if(!_S1480) + { + _runFlag_28 = false; + } + else + { + _runFlag_28 = _S1477; + } + if(_runFlag_28) + { + float2 uv_93 = (pix_center_19 + make_float2 (0.0f, -1.0f) - _S1472) / _S1473; + float2 _S1481 = _S1470; + FixedArray _S1482 = dist_coeffs_35; + bool _S1483 = undistort_point_3(uv_93, &_S1482, int(12), &_S1481); + (&_S1471)->_S1464 = _S1481; + (&_S1471)->_S1465 = _S1483; + if(!_S1483) + { + _runFlag_28 = false; + } + if(_runFlag_28) + { + float2 uv_94 = (pix_center_19 + make_float2 (0.0f, 1.0f) - _S1472) / _S1473; + float2 _S1484 = _S1470; + FixedArray _S1485 = dist_coeffs_35; + bool _S1486 = undistort_point_3(uv_94, &_S1485, int(12), &_S1484); + (&_S1471)->_S1466 = _S1484; + (&_S1471)->_S1467 = _S1486; + if(!_S1486) + { + _runFlag_28 = false; + } + if(_runFlag_28) + { + float2 uv_95 = (pix_center_19 - _S1472) / _S1473; + float2 _S1487 = _S1470; + FixedArray _S1488 = dist_coeffs_35; + bool _S1489 = undistort_point_3(uv_95, &_S1488, int(12), &_S1487); + (&_S1471)->_S1468 = _S1487; + (&_S1471)->_S1469 = _S1489; + } + } + } + } + s_bwd_prop_depth_normal_loss_Intermediates_3 _S1490 = _S1471; + float3 _S1491 = make_float3 (0.0f); + bool _S1492 = !!_S1471._S1461; + bool _runFlag_29; + bool _runFlag_30; + bool _runFlag_31; + int _S1493; + float3 raydir_29; + float3 _S1494; + float3 _S1495; + float3 _S1496; + float3 _S1497; + FixedArray points_17; + if(_S1492) + { + float3 _S1498 = s_primal_ctx_unproject_raydir_0(_S1490._S1460, camera_model_33, is_ray_depth_29); + float3 _S1499 = make_float3 (depths_15.x) * _S1498; + if(!_S1490._S1463) + { + _runFlag_28 = false; + } + else + { + _runFlag_28 = _S1492; + } + if(_runFlag_28) + { + float3 _S1500 = s_primal_ctx_unproject_raydir_0(_S1490._S1462, camera_model_33, is_ray_depth_29); + float3 _S1501 = make_float3 (depths_15.y) * _S1500; + if(!_S1490._S1465) + { + _runFlag_29 = false; + } + else + { + _runFlag_29 = _runFlag_28; + } + if(_runFlag_29) + { + float3 _S1502 = s_primal_ctx_unproject_raydir_0(_S1490._S1464, camera_model_33, is_ray_depth_29); + float3 _S1503 = make_float3 (depths_15.z) * _S1502; + if(!_S1490._S1467) + { + _runFlag_30 = false; + } + else + { + _runFlag_30 = _runFlag_29; + } + if(_runFlag_30) + { + float3 _S1504 = s_primal_ctx_unproject_raydir_0(_S1490._S1466, camera_model_33, is_ray_depth_29); + float3 _S1505 = make_float3 (depths_15.w) * _S1504; + if(!_S1490._S1469) + { + _runFlag_31 = false; + } + else + { + _runFlag_31 = _runFlag_30; + } + if(_runFlag_31) + { + float3 _S1506 = s_primal_ctx_unproject_raydir_0(_S1490._S1468, camera_model_33, is_ray_depth_29); + _S1493 = int(1); + raydir_29 = _S1506; + } + else + { + _S1493 = int(0); + raydir_29 = _S1504; + } + points_17[int(0)] = _S1499; + points_17[int(1)] = _S1501; + points_17[int(2)] = _S1503; + points_17[int(3)] = _S1505; + points_17[int(4)] = _S1491; + _S1494 = _S1504; + } + else + { + _S1493 = int(0); + raydir_29 = _S1502; + points_17[int(0)] = _S1499; + points_17[int(1)] = _S1501; + points_17[int(2)] = _S1503; + points_17[int(3)] = _S1491; + points_17[int(4)] = _S1491; + _S1494 = _S1491; + } + _S1495 = _S1502; + } + else + { + _S1493 = int(0); + raydir_29 = _S1500; + points_17[int(0)] = _S1499; + points_17[int(1)] = _S1501; + points_17[int(2)] = _S1491; + points_17[int(3)] = _S1491; + points_17[int(4)] = _S1491; + _runFlag_30 = false; + _S1494 = _S1491; + _S1495 = _S1491; + } + _S1496 = _S1500; + } + else + { + _S1493 = int(0); + raydir_29 = _S1498; + points_17[int(0)] = _S1499; + points_17[int(1)] = _S1491; + points_17[int(2)] = _S1491; + points_17[int(3)] = _S1491; + points_17[int(4)] = _S1491; + _runFlag_29 = false; + _runFlag_30 = false; + _S1494 = _S1491; + _S1495 = _S1491; + _S1496 = _S1491; + } + _S1497 = _S1498; + } + else + { + _S1493 = int(0); + points_17[int(0)] = _S1491; + points_17[int(1)] = _S1491; + points_17[int(2)] = _S1491; + points_17[int(3)] = _S1491; + points_17[int(4)] = _S1491; + _runFlag_28 = false; + _runFlag_29 = false; + _runFlag_30 = false; + _S1494 = _S1491; + _S1495 = _S1491; + _S1496 = _S1491; + _S1497 = _S1491; + } + bool _S1507 = !(_S1493 != int(1)); + bool _S1508; + float3 normal_21; + float3 _S1509; + float3 _S1510; + float3 _S1511; + float3 _S1512; + float _S1513; + float _S1514; + float _S1515; + float _S1516; + if(_S1507) + { + float3 dx_8 = points_17[int(1)] - points_17[int(0)]; + float3 _S1517 = - (points_17[int(3)] - points_17[int(2)]); + float3 _S1518 = s_primal_ctx_cross_0(dx_8, _S1517); + bool _S1519 = (s_primal_ctx_dot_0(_S1518, _S1518)) != 0.0f; + if(_S1519) + { + normal_21 = normalize_0(_S1518); + } + else + { + normal_21 = _S1518; + } + bool _S1520 = (s_primal_ctx_dot_0(gt_normal_7, gt_normal_7)) != 0.0f; + if(_S1520) + { + _S1509 = normalize_0(gt_normal_7); + } + else + { + _S1509 = gt_normal_7; + } + float3 _S1521 = - normalize_0(raydir_29); + float _S1522 = s_primal_ctx_dot_0(normal_21, _S1521); + float _S1523 = 1.0f - s_primal_ctx_dot_0(normal_21, _S1509) + 0.00100000004749745f; + float _S1524 = (F32_max((_S1522), (0.0f))) + 0.00100000004749745f; + _S1513 = _S1524 * _S1524; + _S1514 = _S1523; + _S1515 = _S1524; + _S1516 = _S1522; + raydir_29 = normal_21; + normal_21 = _S1521; + _runFlag_31 = _S1520; + _S1508 = _S1519; + _S1510 = _S1518; + _S1511 = dx_8; + _S1512 = _S1517; + } + else + { + _S1513 = 0.0f; + _S1514 = 0.0f; + _S1515 = 0.0f; + _S1516 = 0.0f; + raydir_29 = _S1491; + normal_21 = _S1491; + _S1509 = _S1491; + _runFlag_31 = false; + _S1508 = false; + _S1510 = _S1491; + _S1511 = _S1491; + _S1512 = _S1491; + } + float4 _S1525 = make_float4 (0.0f); + if(_S1507) + { + float _S1526 = v_loss_3 / _S1513; + float _S1527 = _S1514 * - _S1526; + float s_diff_num_T_3 = _S1515 * _S1526; + DiffPair_float_0 _S1528; + (&_S1528)->primal_0 = _S1516; + (&_S1528)->differential_0 = 0.0f; + DiffPair_float_0 _S1529; + (&_S1529)->primal_0 = 0.0f; + (&_S1529)->differential_0 = 0.0f; + _d_max_0(&_S1528, &_S1529, _S1527); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1530; + (&_S1530)->primal_0 = raydir_29; + (&_S1530)->differential_0 = _S1491; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1531; + (&_S1531)->primal_0 = normal_21; + (&_S1531)->differential_0 = _S1491; + s_bwd_prop_dot_0(&_S1530, &_S1531, _S1528.differential_0); + float _S1532 = - s_diff_num_T_3; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1533; + (&_S1533)->primal_0 = raydir_29; + (&_S1533)->differential_0 = _S1491; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1534; + (&_S1534)->primal_0 = _S1509; + (&_S1534)->differential_0 = _S1491; + s_bwd_prop_dot_0(&_S1533, &_S1534, _S1532); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1535 = _S1534; + float3 _S1536 = _S1530.differential_0 + _S1533.differential_0; + if(_runFlag_31) + { + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1537; + (&_S1537)->primal_0 = gt_normal_7; + (&_S1537)->differential_0 = _S1491; + s_bwd_normalize_impl_0(&_S1537, _S1535.differential_0); + raydir_29 = _S1537.differential_0; + } + else + { + raydir_29 = _S1535.differential_0; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1538; + (&_S1538)->primal_0 = gt_normal_7; + (&_S1538)->differential_0 = _S1491; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1539; + (&_S1539)->primal_0 = gt_normal_7; + (&_S1539)->differential_0 = _S1491; + s_bwd_prop_dot_0(&_S1538, &_S1539, 0.0f); + float3 _S1540 = _S1539.differential_0 + _S1538.differential_0 + raydir_29; + if(_S1508) + { + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1541; + (&_S1541)->primal_0 = _S1510; + (&_S1541)->differential_0 = _S1491; + s_bwd_normalize_impl_0(&_S1541, _S1536); + raydir_29 = _S1541.differential_0; + } + else + { + raydir_29 = _S1536; + } + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1542; + (&_S1542)->primal_0 = _S1510; + (&_S1542)->differential_0 = _S1491; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1543; + (&_S1543)->primal_0 = _S1510; + (&_S1543)->differential_0 = _S1491; + s_bwd_prop_dot_0(&_S1542, &_S1543, 0.0f); + float3 _S1544 = _S1543.differential_0 + _S1542.differential_0 + raydir_29; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1545; + (&_S1545)->primal_0 = _S1511; + (&_S1545)->differential_0 = _S1491; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1546; + (&_S1546)->primal_0 = _S1512; + (&_S1546)->differential_0 = _S1491; + s_bwd_prop_cross_0(&_S1545, &_S1546, _S1544); + float3 s_diff_dy_T_8 = - _S1546.differential_0; + float3 _S1547 = - s_diff_dy_T_8; + float3 _S1548 = - _S1545.differential_0; + FixedArray _S1549; + _S1549[int(0)] = _S1491; + _S1549[int(1)] = _S1491; + _S1549[int(2)] = _S1491; + _S1549[int(3)] = _S1491; + _S1549[int(4)] = _S1491; + _S1549[int(2)] = _S1547; + _S1549[int(3)] = s_diff_dy_T_8; + _S1549[int(0)] = _S1548; + _S1549[int(1)] = _S1545.differential_0; + points_17[int(0)] = _S1549[int(0)]; + points_17[int(1)] = _S1549[int(1)]; + points_17[int(2)] = _S1549[int(2)]; + points_17[int(3)] = _S1549[int(3)]; + points_17[int(4)] = _S1549[int(4)]; + raydir_29 = _S1540; + } + else + { + points_17[int(0)] = _S1491; + points_17[int(1)] = _S1491; + points_17[int(2)] = _S1491; + points_17[int(3)] = _S1491; + points_17[int(4)] = _S1491; + raydir_29 = _S1491; + } + float4 _S1550; + if(_S1492) + { + if(_runFlag_28) + { + if(_runFlag_29) + { + if(_runFlag_30) + { + FixedArray _S1551 = points_17; + FixedArray _S1552 = points_17; + FixedArray _S1553 = points_17; + float3 _S1554 = _S1494 * points_17[int(3)]; + float _S1555 = _S1554.x + _S1554.y + _S1554.z; + float4 _S1556 = _S1525; + *&((&_S1556)->w) = _S1555; + points_17[int(0)] = _S1491; + points_17[int(1)] = _S1491; + points_17[int(2)] = _S1491; + points_17[int(3)] = _S1491; + points_17[int(4)] = _S1491; + _S1494 = _S1553[int(2)]; + normal_21 = _S1551[int(0)]; + _S1509 = _S1552[int(1)]; + _S1550 = _S1556; + } + else + { + FixedArray _S1557 = points_17; + FixedArray _S1558 = points_17; + FixedArray _S1559 = points_17; + FixedArray _S1560 = points_17; + points_17[int(0)] = points_17[int(0)]; + points_17[int(1)] = _S1557[int(1)]; + points_17[int(2)] = _S1558[int(2)]; + points_17[int(3)] = _S1559[int(3)]; + points_17[int(4)] = _S1560[int(4)]; + _S1494 = _S1491; + normal_21 = _S1491; + _S1509 = _S1491; + _S1550 = _S1525; + } + float3 _S1561 = _S1495 * (points_17[int(2)] + _S1494); + float _S1562 = _S1561.x + _S1561.y + _S1561.z; + float3 _S1563 = points_17[int(0)] + normal_21; + float3 _S1564 = points_17[int(1)] + _S1509; + float4 _S1565 = _S1525; + *&((&_S1565)->z) = _S1562; + float4 _S1566 = _S1550 + _S1565; + points_17[int(0)] = _S1491; + points_17[int(1)] = _S1491; + points_17[int(2)] = _S1491; + points_17[int(3)] = _S1491; + points_17[int(4)] = _S1491; + _S1494 = _S1564; + _S1495 = _S1563; + _S1550 = _S1566; + } + else + { + FixedArray _S1567 = points_17; + FixedArray _S1568 = points_17; + FixedArray _S1569 = points_17; + FixedArray _S1570 = points_17; + points_17[int(0)] = points_17[int(0)]; + points_17[int(1)] = _S1567[int(1)]; + points_17[int(2)] = _S1568[int(2)]; + points_17[int(3)] = _S1569[int(3)]; + points_17[int(4)] = _S1570[int(4)]; + _S1494 = _S1491; + _S1495 = _S1491; + _S1550 = _S1525; + } + float3 _S1571 = _S1496 * (points_17[int(1)] + _S1494); + float _S1572 = _S1571.x + _S1571.y + _S1571.z; + float3 _S1573 = points_17[int(0)] + _S1495; + float4 _S1574 = _S1525; + *&((&_S1574)->y) = _S1572; + float4 _S1575 = _S1550 + _S1574; + points_17[int(0)] = _S1491; + points_17[int(1)] = _S1491; + points_17[int(2)] = _S1491; + points_17[int(3)] = _S1491; + points_17[int(4)] = _S1491; + _S1494 = _S1573; + _S1550 = _S1575; + } + else + { + FixedArray _S1576 = points_17; + FixedArray _S1577 = points_17; + FixedArray _S1578 = points_17; + FixedArray _S1579 = points_17; + points_17[int(0)] = points_17[int(0)]; + points_17[int(1)] = _S1576[int(1)]; + points_17[int(2)] = _S1577[int(2)]; + points_17[int(3)] = _S1578[int(3)]; + points_17[int(4)] = _S1579[int(4)]; + _S1494 = _S1491; + _S1550 = _S1525; + } + float3 _S1580 = _S1497 * (points_17[int(0)] + _S1494); + float _S1581 = _S1580.x + _S1580.y + _S1580.z; + float4 _S1582 = _S1525; + *&((&_S1582)->x) = _S1581; + _S1550 = _S1550 + _S1582; + } + else + { + _S1550 = _S1525; + } + *v_depths_7 = _S1550; + *v_gt_normal_3 = raydir_29; return; } diff --git a/src/generated/primitive_3dgs.cuh b/src/generated/primitive_3dgs.cuh index 5c70ec71..a5bf035e 100644 --- a/src/generated/primitive_3dgs.cuh +++ b/src/generated/primitive_3dgs.cuh @@ -179,55 +179,138 @@ inline __device__ void _d_min_0(DiffPair_float_0 * dpx_0, DiffPair_float_0 * dpy return; } -inline __device__ void _d_max_0(DiffPair_float_0 * dpx_1, DiffPair_float_0 * dpy_1, float dOut_1) +struct DiffPair_vectorx3Cfloatx2C3x3E_0 { - DiffPair_float_0 _S4 = *dpx_1; - float _S5; - if(((*dpx_1).primal_0) > ((*dpy_1).primal_0)) - { - _S5 = dOut_1; - } - else - { - if(((*dpx_1).primal_0) < ((*dpy_1).primal_0)) - { - _S5 = 0.0f; - } - else - { - _S5 = 0.5f * dOut_1; - } - } - dpx_1->primal_0 = _S4.primal_0; - dpx_1->differential_0 = _S5; - DiffPair_float_0 _S6 = *dpy_1; - if(((*dpy_1).primal_0) > (_S4.primal_0)) - { - _S5 = dOut_1; - } - else - { - if(((*dpy_1).primal_0) < ((*dpx_1).primal_0)) - { - _S5 = 0.0f; - } - else - { - _S5 = 0.5f * dOut_1; - } - } - dpy_1->primal_0 = _S6.primal_0; - dpy_1->differential_0 = _S5; + float3 primal_0; + float3 differential_0; +}; + +inline __device__ void _d_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_1, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpy_1, float dOut_1) +{ + float3 x_d_result_0; + *&((&x_d_result_0)->x) = (*dpy_1).primal_0.x * dOut_1; + float3 y_d_result_0; + *&((&y_d_result_0)->x) = (*dpx_1).primal_0.x * dOut_1; + *&((&x_d_result_0)->y) = (*dpy_1).primal_0.y * dOut_1; + *&((&y_d_result_0)->y) = (*dpx_1).primal_0.y * dOut_1; + *&((&x_d_result_0)->z) = (*dpy_1).primal_0.z * dOut_1; + *&((&y_d_result_0)->z) = (*dpx_1).primal_0.z * dOut_1; + dpx_1->primal_0 = (*dpx_1).primal_0; + dpx_1->differential_0 = x_d_result_0; + dpy_1->primal_0 = (*dpy_1).primal_0; + dpy_1->differential_0 = y_d_result_0; return; } -inline __device__ void _d_clamp_0(DiffPair_float_0 * dpx_2, DiffPair_float_0 * dpMin_0, DiffPair_float_0 * dpMax_0, float dOut_2) +inline __device__ float dot_0(float2 x_4, float2 y_0) { - DiffPair_float_0 _S7 = *dpx_2; - bool _S8; - if(((*dpx_2).primal_0) >= ((*dpMin_0).primal_0)) + int i_0 = int(0); + float result_4 = 0.0f; + for(;;) { - _S8 = ((*dpx_2).primal_0) <= ((*dpMax_0).primal_0); + if(i_0 < int(2)) + { + } + else + { + break; + } + float result_5 = result_4 + _slang_vector_get_element(x_4, i_0) * _slang_vector_get_element(y_0, i_0); + i_0 = i_0 + int(1); + result_4 = result_5; + } + return result_4; +} + +inline __device__ float dot_1(float3 x_5, float3 y_1) +{ + int i_1 = int(0); + float result_6 = 0.0f; + for(;;) + { + if(i_1 < int(3)) + { + } + else + { + break; + } + float result_7 = result_6 + _slang_vector_get_element(x_5, i_1) * _slang_vector_get_element(y_1, i_1); + i_1 = i_1 + int(1); + result_6 = result_7; + } + return result_6; +} + +inline __device__ float dot_2(float4 x_6, float4 y_2) +{ + int i_2 = int(0); + float result_8 = 0.0f; + for(;;) + { + if(i_2 < int(4)) + { + } + else + { + break; + } + float result_9 = result_8 + _slang_vector_get_element(x_6, i_2) * _slang_vector_get_element(y_2, i_2); + i_2 = i_2 + int(1); + result_8 = result_9; + } + return result_8; +} + +inline __device__ void _d_max_0(DiffPair_float_0 * dpx_2, DiffPair_float_0 * dpy_2, float dOut_2) +{ + DiffPair_float_0 _S4 = *dpx_2; + float _S5; + if(((*dpx_2).primal_0) > ((*dpy_2).primal_0)) + { + _S5 = dOut_2; + } + else + { + if(((*dpx_2).primal_0) < ((*dpy_2).primal_0)) + { + _S5 = 0.0f; + } + else + { + _S5 = 0.5f * dOut_2; + } + } + dpx_2->primal_0 = _S4.primal_0; + dpx_2->differential_0 = _S5; + DiffPair_float_0 _S6 = *dpy_2; + if(((*dpy_2).primal_0) > (_S4.primal_0)) + { + _S5 = dOut_2; + } + else + { + if(((*dpy_2).primal_0) < ((*dpx_2).primal_0)) + { + _S5 = 0.0f; + } + else + { + _S5 = 0.5f * dOut_2; + } + } + dpy_2->primal_0 = _S6.primal_0; + dpy_2->differential_0 = _S5; + return; +} + +inline __device__ void _d_clamp_0(DiffPair_float_0 * dpx_3, DiffPair_float_0 * dpMin_0, DiffPair_float_0 * dpMax_0, float dOut_3) +{ + DiffPair_float_0 _S7 = *dpx_3; + bool _S8; + if(((*dpx_3).primal_0) >= ((*dpMin_0).primal_0)) + { + _S8 = ((*dpx_3).primal_0) <= ((*dpMax_0).primal_0); } else { @@ -236,18 +319,18 @@ inline __device__ void _d_clamp_0(DiffPair_float_0 * dpx_2, DiffPair_float_0 * d float _S9; if(_S8) { - _S9 = dOut_2; + _S9 = dOut_3; } else { _S9 = 0.0f; } - dpx_2->primal_0 = _S7.primal_0; - dpx_2->differential_0 = _S9; + dpx_3->primal_0 = _S7.primal_0; + dpx_3->differential_0 = _S9; DiffPair_float_0 _S10 = *dpMin_0; if((_S7.primal_0) < ((*dpMin_0).primal_0)) { - _S9 = dOut_2; + _S9 = dOut_3; } else { @@ -256,9 +339,9 @@ inline __device__ void _d_clamp_0(DiffPair_float_0 * dpx_2, DiffPair_float_0 * d dpMin_0->primal_0 = _S10.primal_0; dpMin_0->differential_0 = _S9; DiffPair_float_0 _S11 = *dpMax_0; - if(((*dpx_2).primal_0) > ((*dpMax_0).primal_0)) + if(((*dpx_3).primal_0) > ((*dpMax_0).primal_0)) { - _S9 = dOut_2; + _S9 = dOut_3; } else { @@ -269,9 +352,9 @@ inline __device__ void _d_clamp_0(DiffPair_float_0 * dpx_2, DiffPair_float_0 * d return; } -inline __device__ float clamp_0(float x_4, float minBound_0, float maxBound_0) +inline __device__ float clamp_0(float x_7, float minBound_0, float maxBound_0) { - return (F32_min(((F32_max((x_4), (minBound_0)))), (maxBound_0))); + return (F32_min(((F32_max((x_7), (minBound_0)))), (maxBound_0))); } struct DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 @@ -286,7 +369,7 @@ struct DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 Matrix differential_0; }; -inline __device__ void mul_0(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * left_0, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * right_0, Matrix dOut_3) +inline __device__ void mul_0(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * left_0, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * right_0, Matrix dOut_4) { Matrix left_d_result_0; *&(((&left_d_result_0)->rows + (int(0)))->x) = 0.0f; @@ -305,42 +388,42 @@ inline __device__ void mul_0(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * left_0, Diff *&(((&right_d_result_0)->rows + (int(2)))->x) = 0.0f; *&(((&right_d_result_0)->rows + (int(2)))->y) = 0.0f; *&(((&right_d_result_0)->rows + (int(2)))->z) = 0.0f; - *&(((&left_d_result_0)->rows + (int(0)))->x) = *&(((&left_d_result_0)->rows + (int(0)))->x) + (*right_0).primal_0.rows[int(0)].x * dOut_3.rows[int(0)].x; - *&(((&right_d_result_0)->rows + (int(0)))->x) = *&(((&right_d_result_0)->rows + (int(0)))->x) + (*left_0).primal_0.rows[int(0)].x * dOut_3.rows[int(0)].x; - *&(((&left_d_result_0)->rows + (int(0)))->y) = *&(((&left_d_result_0)->rows + (int(0)))->y) + (*right_0).primal_0.rows[int(1)].x * dOut_3.rows[int(0)].x; - *&(((&right_d_result_0)->rows + (int(1)))->x) = *&(((&right_d_result_0)->rows + (int(1)))->x) + (*left_0).primal_0.rows[int(0)].y * dOut_3.rows[int(0)].x; - *&(((&left_d_result_0)->rows + (int(0)))->z) = *&(((&left_d_result_0)->rows + (int(0)))->z) + (*right_0).primal_0.rows[int(2)].x * dOut_3.rows[int(0)].x; - *&(((&right_d_result_0)->rows + (int(2)))->x) = *&(((&right_d_result_0)->rows + (int(2)))->x) + (*left_0).primal_0.rows[int(0)].z * dOut_3.rows[int(0)].x; - *&(((&left_d_result_0)->rows + (int(0)))->x) = *&(((&left_d_result_0)->rows + (int(0)))->x) + (*right_0).primal_0.rows[int(0)].y * dOut_3.rows[int(0)].y; - *&(((&right_d_result_0)->rows + (int(0)))->y) = *&(((&right_d_result_0)->rows + (int(0)))->y) + (*left_0).primal_0.rows[int(0)].x * dOut_3.rows[int(0)].y; - *&(((&left_d_result_0)->rows + (int(0)))->y) = *&(((&left_d_result_0)->rows + (int(0)))->y) + (*right_0).primal_0.rows[int(1)].y * dOut_3.rows[int(0)].y; - *&(((&right_d_result_0)->rows + (int(1)))->y) = *&(((&right_d_result_0)->rows + (int(1)))->y) + (*left_0).primal_0.rows[int(0)].y * dOut_3.rows[int(0)].y; - *&(((&left_d_result_0)->rows + (int(0)))->z) = *&(((&left_d_result_0)->rows + (int(0)))->z) + (*right_0).primal_0.rows[int(2)].y * dOut_3.rows[int(0)].y; - *&(((&right_d_result_0)->rows + (int(2)))->y) = *&(((&right_d_result_0)->rows + (int(2)))->y) + (*left_0).primal_0.rows[int(0)].z * dOut_3.rows[int(0)].y; - *&(((&left_d_result_0)->rows + (int(0)))->x) = *&(((&left_d_result_0)->rows + (int(0)))->x) + (*right_0).primal_0.rows[int(0)].z * dOut_3.rows[int(0)].z; - *&(((&right_d_result_0)->rows + (int(0)))->z) = *&(((&right_d_result_0)->rows + (int(0)))->z) + (*left_0).primal_0.rows[int(0)].x * dOut_3.rows[int(0)].z; - *&(((&left_d_result_0)->rows + (int(0)))->y) = *&(((&left_d_result_0)->rows + (int(0)))->y) + (*right_0).primal_0.rows[int(1)].z * dOut_3.rows[int(0)].z; - *&(((&right_d_result_0)->rows + (int(1)))->z) = *&(((&right_d_result_0)->rows + (int(1)))->z) + (*left_0).primal_0.rows[int(0)].y * dOut_3.rows[int(0)].z; - *&(((&left_d_result_0)->rows + (int(0)))->z) = *&(((&left_d_result_0)->rows + (int(0)))->z) + (*right_0).primal_0.rows[int(2)].z * dOut_3.rows[int(0)].z; - *&(((&right_d_result_0)->rows + (int(2)))->z) = *&(((&right_d_result_0)->rows + (int(2)))->z) + (*left_0).primal_0.rows[int(0)].z * dOut_3.rows[int(0)].z; - *&(((&left_d_result_0)->rows + (int(1)))->x) = *&(((&left_d_result_0)->rows + (int(1)))->x) + (*right_0).primal_0.rows[int(0)].x * dOut_3.rows[int(1)].x; - *&(((&right_d_result_0)->rows + (int(0)))->x) = *&(((&right_d_result_0)->rows + (int(0)))->x) + (*left_0).primal_0.rows[int(1)].x * dOut_3.rows[int(1)].x; - *&(((&left_d_result_0)->rows + (int(1)))->y) = *&(((&left_d_result_0)->rows + (int(1)))->y) + (*right_0).primal_0.rows[int(1)].x * dOut_3.rows[int(1)].x; - *&(((&right_d_result_0)->rows + (int(1)))->x) = *&(((&right_d_result_0)->rows + (int(1)))->x) + (*left_0).primal_0.rows[int(1)].y * dOut_3.rows[int(1)].x; - *&(((&left_d_result_0)->rows + (int(1)))->z) = *&(((&left_d_result_0)->rows + (int(1)))->z) + (*right_0).primal_0.rows[int(2)].x * dOut_3.rows[int(1)].x; - *&(((&right_d_result_0)->rows + (int(2)))->x) = *&(((&right_d_result_0)->rows + (int(2)))->x) + (*left_0).primal_0.rows[int(1)].z * dOut_3.rows[int(1)].x; - *&(((&left_d_result_0)->rows + (int(1)))->x) = *&(((&left_d_result_0)->rows + (int(1)))->x) + (*right_0).primal_0.rows[int(0)].y * dOut_3.rows[int(1)].y; - *&(((&right_d_result_0)->rows + (int(0)))->y) = *&(((&right_d_result_0)->rows + (int(0)))->y) + (*left_0).primal_0.rows[int(1)].x * dOut_3.rows[int(1)].y; - *&(((&left_d_result_0)->rows + (int(1)))->y) = *&(((&left_d_result_0)->rows + (int(1)))->y) + (*right_0).primal_0.rows[int(1)].y * dOut_3.rows[int(1)].y; - *&(((&right_d_result_0)->rows + (int(1)))->y) = *&(((&right_d_result_0)->rows + (int(1)))->y) + (*left_0).primal_0.rows[int(1)].y * dOut_3.rows[int(1)].y; - *&(((&left_d_result_0)->rows + (int(1)))->z) = *&(((&left_d_result_0)->rows + (int(1)))->z) + (*right_0).primal_0.rows[int(2)].y * dOut_3.rows[int(1)].y; - *&(((&right_d_result_0)->rows + (int(2)))->y) = *&(((&right_d_result_0)->rows + (int(2)))->y) + (*left_0).primal_0.rows[int(1)].z * dOut_3.rows[int(1)].y; - *&(((&left_d_result_0)->rows + (int(1)))->x) = *&(((&left_d_result_0)->rows + (int(1)))->x) + (*right_0).primal_0.rows[int(0)].z * dOut_3.rows[int(1)].z; - *&(((&right_d_result_0)->rows + (int(0)))->z) = *&(((&right_d_result_0)->rows + (int(0)))->z) + (*left_0).primal_0.rows[int(1)].x * dOut_3.rows[int(1)].z; - *&(((&left_d_result_0)->rows + (int(1)))->y) = *&(((&left_d_result_0)->rows + (int(1)))->y) + (*right_0).primal_0.rows[int(1)].z * dOut_3.rows[int(1)].z; - *&(((&right_d_result_0)->rows + (int(1)))->z) = *&(((&right_d_result_0)->rows + (int(1)))->z) + (*left_0).primal_0.rows[int(1)].y * dOut_3.rows[int(1)].z; - *&(((&left_d_result_0)->rows + (int(1)))->z) = *&(((&left_d_result_0)->rows + (int(1)))->z) + (*right_0).primal_0.rows[int(2)].z * dOut_3.rows[int(1)].z; - *&(((&right_d_result_0)->rows + (int(2)))->z) = *&(((&right_d_result_0)->rows + (int(2)))->z) + (*left_0).primal_0.rows[int(1)].z * dOut_3.rows[int(1)].z; + *&(((&left_d_result_0)->rows + (int(0)))->x) = *&(((&left_d_result_0)->rows + (int(0)))->x) + (*right_0).primal_0.rows[int(0)].x * dOut_4.rows[int(0)].x; + *&(((&right_d_result_0)->rows + (int(0)))->x) = *&(((&right_d_result_0)->rows + (int(0)))->x) + (*left_0).primal_0.rows[int(0)].x * dOut_4.rows[int(0)].x; + *&(((&left_d_result_0)->rows + (int(0)))->y) = *&(((&left_d_result_0)->rows + (int(0)))->y) + (*right_0).primal_0.rows[int(1)].x * dOut_4.rows[int(0)].x; + *&(((&right_d_result_0)->rows + (int(1)))->x) = *&(((&right_d_result_0)->rows + (int(1)))->x) + (*left_0).primal_0.rows[int(0)].y * dOut_4.rows[int(0)].x; + *&(((&left_d_result_0)->rows + (int(0)))->z) = *&(((&left_d_result_0)->rows + (int(0)))->z) + (*right_0).primal_0.rows[int(2)].x * dOut_4.rows[int(0)].x; + *&(((&right_d_result_0)->rows + (int(2)))->x) = *&(((&right_d_result_0)->rows + (int(2)))->x) + (*left_0).primal_0.rows[int(0)].z * dOut_4.rows[int(0)].x; + *&(((&left_d_result_0)->rows + (int(0)))->x) = *&(((&left_d_result_0)->rows + (int(0)))->x) + (*right_0).primal_0.rows[int(0)].y * dOut_4.rows[int(0)].y; + *&(((&right_d_result_0)->rows + (int(0)))->y) = *&(((&right_d_result_0)->rows + (int(0)))->y) + (*left_0).primal_0.rows[int(0)].x * dOut_4.rows[int(0)].y; + *&(((&left_d_result_0)->rows + (int(0)))->y) = *&(((&left_d_result_0)->rows + (int(0)))->y) + (*right_0).primal_0.rows[int(1)].y * dOut_4.rows[int(0)].y; + *&(((&right_d_result_0)->rows + (int(1)))->y) = *&(((&right_d_result_0)->rows + (int(1)))->y) + (*left_0).primal_0.rows[int(0)].y * dOut_4.rows[int(0)].y; + *&(((&left_d_result_0)->rows + (int(0)))->z) = *&(((&left_d_result_0)->rows + (int(0)))->z) + (*right_0).primal_0.rows[int(2)].y * dOut_4.rows[int(0)].y; + *&(((&right_d_result_0)->rows + (int(2)))->y) = *&(((&right_d_result_0)->rows + (int(2)))->y) + (*left_0).primal_0.rows[int(0)].z * dOut_4.rows[int(0)].y; + *&(((&left_d_result_0)->rows + (int(0)))->x) = *&(((&left_d_result_0)->rows + (int(0)))->x) + (*right_0).primal_0.rows[int(0)].z * dOut_4.rows[int(0)].z; + *&(((&right_d_result_0)->rows + (int(0)))->z) = *&(((&right_d_result_0)->rows + (int(0)))->z) + (*left_0).primal_0.rows[int(0)].x * dOut_4.rows[int(0)].z; + *&(((&left_d_result_0)->rows + (int(0)))->y) = *&(((&left_d_result_0)->rows + (int(0)))->y) + (*right_0).primal_0.rows[int(1)].z * dOut_4.rows[int(0)].z; + *&(((&right_d_result_0)->rows + (int(1)))->z) = *&(((&right_d_result_0)->rows + (int(1)))->z) + (*left_0).primal_0.rows[int(0)].y * dOut_4.rows[int(0)].z; + *&(((&left_d_result_0)->rows + (int(0)))->z) = *&(((&left_d_result_0)->rows + (int(0)))->z) + (*right_0).primal_0.rows[int(2)].z * dOut_4.rows[int(0)].z; + *&(((&right_d_result_0)->rows + (int(2)))->z) = *&(((&right_d_result_0)->rows + (int(2)))->z) + (*left_0).primal_0.rows[int(0)].z * dOut_4.rows[int(0)].z; + *&(((&left_d_result_0)->rows + (int(1)))->x) = *&(((&left_d_result_0)->rows + (int(1)))->x) + (*right_0).primal_0.rows[int(0)].x * dOut_4.rows[int(1)].x; + *&(((&right_d_result_0)->rows + (int(0)))->x) = *&(((&right_d_result_0)->rows + (int(0)))->x) + (*left_0).primal_0.rows[int(1)].x * dOut_4.rows[int(1)].x; + *&(((&left_d_result_0)->rows + (int(1)))->y) = *&(((&left_d_result_0)->rows + (int(1)))->y) + (*right_0).primal_0.rows[int(1)].x * dOut_4.rows[int(1)].x; + *&(((&right_d_result_0)->rows + (int(1)))->x) = *&(((&right_d_result_0)->rows + (int(1)))->x) + (*left_0).primal_0.rows[int(1)].y * dOut_4.rows[int(1)].x; + *&(((&left_d_result_0)->rows + (int(1)))->z) = *&(((&left_d_result_0)->rows + (int(1)))->z) + (*right_0).primal_0.rows[int(2)].x * dOut_4.rows[int(1)].x; + *&(((&right_d_result_0)->rows + (int(2)))->x) = *&(((&right_d_result_0)->rows + (int(2)))->x) + (*left_0).primal_0.rows[int(1)].z * dOut_4.rows[int(1)].x; + *&(((&left_d_result_0)->rows + (int(1)))->x) = *&(((&left_d_result_0)->rows + (int(1)))->x) + (*right_0).primal_0.rows[int(0)].y * dOut_4.rows[int(1)].y; + *&(((&right_d_result_0)->rows + (int(0)))->y) = *&(((&right_d_result_0)->rows + (int(0)))->y) + (*left_0).primal_0.rows[int(1)].x * dOut_4.rows[int(1)].y; + *&(((&left_d_result_0)->rows + (int(1)))->y) = *&(((&left_d_result_0)->rows + (int(1)))->y) + (*right_0).primal_0.rows[int(1)].y * dOut_4.rows[int(1)].y; + *&(((&right_d_result_0)->rows + (int(1)))->y) = *&(((&right_d_result_0)->rows + (int(1)))->y) + (*left_0).primal_0.rows[int(1)].y * dOut_4.rows[int(1)].y; + *&(((&left_d_result_0)->rows + (int(1)))->z) = *&(((&left_d_result_0)->rows + (int(1)))->z) + (*right_0).primal_0.rows[int(2)].y * dOut_4.rows[int(1)].y; + *&(((&right_d_result_0)->rows + (int(2)))->y) = *&(((&right_d_result_0)->rows + (int(2)))->y) + (*left_0).primal_0.rows[int(1)].z * dOut_4.rows[int(1)].y; + *&(((&left_d_result_0)->rows + (int(1)))->x) = *&(((&left_d_result_0)->rows + (int(1)))->x) + (*right_0).primal_0.rows[int(0)].z * dOut_4.rows[int(1)].z; + *&(((&right_d_result_0)->rows + (int(0)))->z) = *&(((&right_d_result_0)->rows + (int(0)))->z) + (*left_0).primal_0.rows[int(1)].x * dOut_4.rows[int(1)].z; + *&(((&left_d_result_0)->rows + (int(1)))->y) = *&(((&left_d_result_0)->rows + (int(1)))->y) + (*right_0).primal_0.rows[int(1)].z * dOut_4.rows[int(1)].z; + *&(((&right_d_result_0)->rows + (int(1)))->z) = *&(((&right_d_result_0)->rows + (int(1)))->z) + (*left_0).primal_0.rows[int(1)].y * dOut_4.rows[int(1)].z; + *&(((&left_d_result_0)->rows + (int(1)))->z) = *&(((&left_d_result_0)->rows + (int(1)))->z) + (*right_0).primal_0.rows[int(2)].z * dOut_4.rows[int(1)].z; + *&(((&right_d_result_0)->rows + (int(2)))->z) = *&(((&right_d_result_0)->rows + (int(2)))->z) + (*left_0).primal_0.rows[int(1)].z * dOut_4.rows[int(1)].z; left_0->primal_0 = (*left_0).primal_0; left_0->differential_0 = left_d_result_0; right_0->primal_0 = (*right_0).primal_0; @@ -354,7 +437,7 @@ struct DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 Matrix differential_0; }; -inline __device__ void mul_1(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * left_1, DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 * right_1, Matrix dOut_4) +inline __device__ void mul_1(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * left_1, DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 * right_1, Matrix dOut_5) { Matrix left_d_result_1; *&(((&left_d_result_1)->rows + (int(0)))->x) = 0.0f; @@ -370,30 +453,30 @@ inline __device__ void mul_1(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * left_1, Diff *&(((&right_d_result_1)->rows + (int(1)))->y) = 0.0f; *&(((&right_d_result_1)->rows + (int(2)))->x) = 0.0f; *&(((&right_d_result_1)->rows + (int(2)))->y) = 0.0f; - *&(((&left_d_result_1)->rows + (int(0)))->x) = *&(((&left_d_result_1)->rows + (int(0)))->x) + (*right_1).primal_0.rows[int(0)].x * dOut_4.rows[int(0)].x; - *&(((&right_d_result_1)->rows + (int(0)))->x) = *&(((&right_d_result_1)->rows + (int(0)))->x) + (*left_1).primal_0.rows[int(0)].x * dOut_4.rows[int(0)].x; - *&(((&left_d_result_1)->rows + (int(0)))->y) = *&(((&left_d_result_1)->rows + (int(0)))->y) + (*right_1).primal_0.rows[int(1)].x * dOut_4.rows[int(0)].x; - *&(((&right_d_result_1)->rows + (int(1)))->x) = *&(((&right_d_result_1)->rows + (int(1)))->x) + (*left_1).primal_0.rows[int(0)].y * dOut_4.rows[int(0)].x; - *&(((&left_d_result_1)->rows + (int(0)))->z) = *&(((&left_d_result_1)->rows + (int(0)))->z) + (*right_1).primal_0.rows[int(2)].x * dOut_4.rows[int(0)].x; - *&(((&right_d_result_1)->rows + (int(2)))->x) = *&(((&right_d_result_1)->rows + (int(2)))->x) + (*left_1).primal_0.rows[int(0)].z * dOut_4.rows[int(0)].x; - *&(((&left_d_result_1)->rows + (int(0)))->x) = *&(((&left_d_result_1)->rows + (int(0)))->x) + (*right_1).primal_0.rows[int(0)].y * dOut_4.rows[int(0)].y; - *&(((&right_d_result_1)->rows + (int(0)))->y) = *&(((&right_d_result_1)->rows + (int(0)))->y) + (*left_1).primal_0.rows[int(0)].x * dOut_4.rows[int(0)].y; - *&(((&left_d_result_1)->rows + (int(0)))->y) = *&(((&left_d_result_1)->rows + (int(0)))->y) + (*right_1).primal_0.rows[int(1)].y * dOut_4.rows[int(0)].y; - *&(((&right_d_result_1)->rows + (int(1)))->y) = *&(((&right_d_result_1)->rows + (int(1)))->y) + (*left_1).primal_0.rows[int(0)].y * dOut_4.rows[int(0)].y; - *&(((&left_d_result_1)->rows + (int(0)))->z) = *&(((&left_d_result_1)->rows + (int(0)))->z) + (*right_1).primal_0.rows[int(2)].y * dOut_4.rows[int(0)].y; - *&(((&right_d_result_1)->rows + (int(2)))->y) = *&(((&right_d_result_1)->rows + (int(2)))->y) + (*left_1).primal_0.rows[int(0)].z * dOut_4.rows[int(0)].y; - *&(((&left_d_result_1)->rows + (int(1)))->x) = *&(((&left_d_result_1)->rows + (int(1)))->x) + (*right_1).primal_0.rows[int(0)].x * dOut_4.rows[int(1)].x; - *&(((&right_d_result_1)->rows + (int(0)))->x) = *&(((&right_d_result_1)->rows + (int(0)))->x) + (*left_1).primal_0.rows[int(1)].x * dOut_4.rows[int(1)].x; - *&(((&left_d_result_1)->rows + (int(1)))->y) = *&(((&left_d_result_1)->rows + (int(1)))->y) + (*right_1).primal_0.rows[int(1)].x * dOut_4.rows[int(1)].x; - *&(((&right_d_result_1)->rows + (int(1)))->x) = *&(((&right_d_result_1)->rows + (int(1)))->x) + (*left_1).primal_0.rows[int(1)].y * dOut_4.rows[int(1)].x; - *&(((&left_d_result_1)->rows + (int(1)))->z) = *&(((&left_d_result_1)->rows + (int(1)))->z) + (*right_1).primal_0.rows[int(2)].x * dOut_4.rows[int(1)].x; - *&(((&right_d_result_1)->rows + (int(2)))->x) = *&(((&right_d_result_1)->rows + (int(2)))->x) + (*left_1).primal_0.rows[int(1)].z * dOut_4.rows[int(1)].x; - *&(((&left_d_result_1)->rows + (int(1)))->x) = *&(((&left_d_result_1)->rows + (int(1)))->x) + (*right_1).primal_0.rows[int(0)].y * dOut_4.rows[int(1)].y; - *&(((&right_d_result_1)->rows + (int(0)))->y) = *&(((&right_d_result_1)->rows + (int(0)))->y) + (*left_1).primal_0.rows[int(1)].x * dOut_4.rows[int(1)].y; - *&(((&left_d_result_1)->rows + (int(1)))->y) = *&(((&left_d_result_1)->rows + (int(1)))->y) + (*right_1).primal_0.rows[int(1)].y * dOut_4.rows[int(1)].y; - *&(((&right_d_result_1)->rows + (int(1)))->y) = *&(((&right_d_result_1)->rows + (int(1)))->y) + (*left_1).primal_0.rows[int(1)].y * dOut_4.rows[int(1)].y; - *&(((&left_d_result_1)->rows + (int(1)))->z) = *&(((&left_d_result_1)->rows + (int(1)))->z) + (*right_1).primal_0.rows[int(2)].y * dOut_4.rows[int(1)].y; - *&(((&right_d_result_1)->rows + (int(2)))->y) = *&(((&right_d_result_1)->rows + (int(2)))->y) + (*left_1).primal_0.rows[int(1)].z * dOut_4.rows[int(1)].y; + *&(((&left_d_result_1)->rows + (int(0)))->x) = *&(((&left_d_result_1)->rows + (int(0)))->x) + (*right_1).primal_0.rows[int(0)].x * dOut_5.rows[int(0)].x; + *&(((&right_d_result_1)->rows + (int(0)))->x) = *&(((&right_d_result_1)->rows + (int(0)))->x) + (*left_1).primal_0.rows[int(0)].x * dOut_5.rows[int(0)].x; + *&(((&left_d_result_1)->rows + (int(0)))->y) = *&(((&left_d_result_1)->rows + (int(0)))->y) + (*right_1).primal_0.rows[int(1)].x * dOut_5.rows[int(0)].x; + *&(((&right_d_result_1)->rows + (int(1)))->x) = *&(((&right_d_result_1)->rows + (int(1)))->x) + (*left_1).primal_0.rows[int(0)].y * dOut_5.rows[int(0)].x; + *&(((&left_d_result_1)->rows + (int(0)))->z) = *&(((&left_d_result_1)->rows + (int(0)))->z) + (*right_1).primal_0.rows[int(2)].x * dOut_5.rows[int(0)].x; + *&(((&right_d_result_1)->rows + (int(2)))->x) = *&(((&right_d_result_1)->rows + (int(2)))->x) + (*left_1).primal_0.rows[int(0)].z * dOut_5.rows[int(0)].x; + *&(((&left_d_result_1)->rows + (int(0)))->x) = *&(((&left_d_result_1)->rows + (int(0)))->x) + (*right_1).primal_0.rows[int(0)].y * dOut_5.rows[int(0)].y; + *&(((&right_d_result_1)->rows + (int(0)))->y) = *&(((&right_d_result_1)->rows + (int(0)))->y) + (*left_1).primal_0.rows[int(0)].x * dOut_5.rows[int(0)].y; + *&(((&left_d_result_1)->rows + (int(0)))->y) = *&(((&left_d_result_1)->rows + (int(0)))->y) + (*right_1).primal_0.rows[int(1)].y * dOut_5.rows[int(0)].y; + *&(((&right_d_result_1)->rows + (int(1)))->y) = *&(((&right_d_result_1)->rows + (int(1)))->y) + (*left_1).primal_0.rows[int(0)].y * dOut_5.rows[int(0)].y; + *&(((&left_d_result_1)->rows + (int(0)))->z) = *&(((&left_d_result_1)->rows + (int(0)))->z) + (*right_1).primal_0.rows[int(2)].y * dOut_5.rows[int(0)].y; + *&(((&right_d_result_1)->rows + (int(2)))->y) = *&(((&right_d_result_1)->rows + (int(2)))->y) + (*left_1).primal_0.rows[int(0)].z * dOut_5.rows[int(0)].y; + *&(((&left_d_result_1)->rows + (int(1)))->x) = *&(((&left_d_result_1)->rows + (int(1)))->x) + (*right_1).primal_0.rows[int(0)].x * dOut_5.rows[int(1)].x; + *&(((&right_d_result_1)->rows + (int(0)))->x) = *&(((&right_d_result_1)->rows + (int(0)))->x) + (*left_1).primal_0.rows[int(1)].x * dOut_5.rows[int(1)].x; + *&(((&left_d_result_1)->rows + (int(1)))->y) = *&(((&left_d_result_1)->rows + (int(1)))->y) + (*right_1).primal_0.rows[int(1)].x * dOut_5.rows[int(1)].x; + *&(((&right_d_result_1)->rows + (int(1)))->x) = *&(((&right_d_result_1)->rows + (int(1)))->x) + (*left_1).primal_0.rows[int(1)].y * dOut_5.rows[int(1)].x; + *&(((&left_d_result_1)->rows + (int(1)))->z) = *&(((&left_d_result_1)->rows + (int(1)))->z) + (*right_1).primal_0.rows[int(2)].x * dOut_5.rows[int(1)].x; + *&(((&right_d_result_1)->rows + (int(2)))->x) = *&(((&right_d_result_1)->rows + (int(2)))->x) + (*left_1).primal_0.rows[int(1)].z * dOut_5.rows[int(1)].x; + *&(((&left_d_result_1)->rows + (int(1)))->x) = *&(((&left_d_result_1)->rows + (int(1)))->x) + (*right_1).primal_0.rows[int(0)].y * dOut_5.rows[int(1)].y; + *&(((&right_d_result_1)->rows + (int(0)))->y) = *&(((&right_d_result_1)->rows + (int(0)))->y) + (*left_1).primal_0.rows[int(1)].x * dOut_5.rows[int(1)].y; + *&(((&left_d_result_1)->rows + (int(1)))->y) = *&(((&left_d_result_1)->rows + (int(1)))->y) + (*right_1).primal_0.rows[int(1)].y * dOut_5.rows[int(1)].y; + *&(((&right_d_result_1)->rows + (int(1)))->y) = *&(((&right_d_result_1)->rows + (int(1)))->y) + (*left_1).primal_0.rows[int(1)].y * dOut_5.rows[int(1)].y; + *&(((&left_d_result_1)->rows + (int(1)))->z) = *&(((&left_d_result_1)->rows + (int(1)))->z) + (*right_1).primal_0.rows[int(2)].y * dOut_5.rows[int(1)].y; + *&(((&right_d_result_1)->rows + (int(2)))->y) = *&(((&right_d_result_1)->rows + (int(2)))->y) + (*left_1).primal_0.rows[int(1)].z * dOut_5.rows[int(1)].y; left_1->primal_0 = (*left_1).primal_0; left_1->differential_0 = left_d_result_1; right_1->primal_0 = (*right_1).primal_0; @@ -401,7 +484,7 @@ inline __device__ void mul_1(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * left_1, Diff return; } -inline __device__ void mul_2(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * left_2, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * right_2, Matrix dOut_5) +inline __device__ void mul_2(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * left_2, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * right_2, Matrix dOut_6) { Matrix left_d_result_2; *&(((&left_d_result_2)->rows + (int(0)))->x) = 0.0f; @@ -423,60 +506,60 @@ inline __device__ void mul_2(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * left_2, Diff *&(((&right_d_result_2)->rows + (int(2)))->x) = 0.0f; *&(((&right_d_result_2)->rows + (int(2)))->y) = 0.0f; *&(((&right_d_result_2)->rows + (int(2)))->z) = 0.0f; - *&(((&left_d_result_2)->rows + (int(0)))->x) = *&(((&left_d_result_2)->rows + (int(0)))->x) + (*right_2).primal_0.rows[int(0)].x * dOut_5.rows[int(0)].x; - *&(((&right_d_result_2)->rows + (int(0)))->x) = *&(((&right_d_result_2)->rows + (int(0)))->x) + (*left_2).primal_0.rows[int(0)].x * dOut_5.rows[int(0)].x; - *&(((&left_d_result_2)->rows + (int(0)))->y) = *&(((&left_d_result_2)->rows + (int(0)))->y) + (*right_2).primal_0.rows[int(1)].x * dOut_5.rows[int(0)].x; - *&(((&right_d_result_2)->rows + (int(1)))->x) = *&(((&right_d_result_2)->rows + (int(1)))->x) + (*left_2).primal_0.rows[int(0)].y * dOut_5.rows[int(0)].x; - *&(((&left_d_result_2)->rows + (int(0)))->z) = *&(((&left_d_result_2)->rows + (int(0)))->z) + (*right_2).primal_0.rows[int(2)].x * dOut_5.rows[int(0)].x; - *&(((&right_d_result_2)->rows + (int(2)))->x) = *&(((&right_d_result_2)->rows + (int(2)))->x) + (*left_2).primal_0.rows[int(0)].z * dOut_5.rows[int(0)].x; - *&(((&left_d_result_2)->rows + (int(0)))->x) = *&(((&left_d_result_2)->rows + (int(0)))->x) + (*right_2).primal_0.rows[int(0)].y * dOut_5.rows[int(0)].y; - *&(((&right_d_result_2)->rows + (int(0)))->y) = *&(((&right_d_result_2)->rows + (int(0)))->y) + (*left_2).primal_0.rows[int(0)].x * dOut_5.rows[int(0)].y; - *&(((&left_d_result_2)->rows + (int(0)))->y) = *&(((&left_d_result_2)->rows + (int(0)))->y) + (*right_2).primal_0.rows[int(1)].y * dOut_5.rows[int(0)].y; - *&(((&right_d_result_2)->rows + (int(1)))->y) = *&(((&right_d_result_2)->rows + (int(1)))->y) + (*left_2).primal_0.rows[int(0)].y * dOut_5.rows[int(0)].y; - *&(((&left_d_result_2)->rows + (int(0)))->z) = *&(((&left_d_result_2)->rows + (int(0)))->z) + (*right_2).primal_0.rows[int(2)].y * dOut_5.rows[int(0)].y; - *&(((&right_d_result_2)->rows + (int(2)))->y) = *&(((&right_d_result_2)->rows + (int(2)))->y) + (*left_2).primal_0.rows[int(0)].z * dOut_5.rows[int(0)].y; - *&(((&left_d_result_2)->rows + (int(0)))->x) = *&(((&left_d_result_2)->rows + (int(0)))->x) + (*right_2).primal_0.rows[int(0)].z * dOut_5.rows[int(0)].z; - *&(((&right_d_result_2)->rows + (int(0)))->z) = *&(((&right_d_result_2)->rows + (int(0)))->z) + (*left_2).primal_0.rows[int(0)].x * dOut_5.rows[int(0)].z; - *&(((&left_d_result_2)->rows + (int(0)))->y) = *&(((&left_d_result_2)->rows + (int(0)))->y) + (*right_2).primal_0.rows[int(1)].z * dOut_5.rows[int(0)].z; - *&(((&right_d_result_2)->rows + (int(1)))->z) = *&(((&right_d_result_2)->rows + (int(1)))->z) + (*left_2).primal_0.rows[int(0)].y * dOut_5.rows[int(0)].z; - *&(((&left_d_result_2)->rows + (int(0)))->z) = *&(((&left_d_result_2)->rows + (int(0)))->z) + (*right_2).primal_0.rows[int(2)].z * dOut_5.rows[int(0)].z; - *&(((&right_d_result_2)->rows + (int(2)))->z) = *&(((&right_d_result_2)->rows + (int(2)))->z) + (*left_2).primal_0.rows[int(0)].z * dOut_5.rows[int(0)].z; - *&(((&left_d_result_2)->rows + (int(1)))->x) = *&(((&left_d_result_2)->rows + (int(1)))->x) + (*right_2).primal_0.rows[int(0)].x * dOut_5.rows[int(1)].x; - *&(((&right_d_result_2)->rows + (int(0)))->x) = *&(((&right_d_result_2)->rows + (int(0)))->x) + (*left_2).primal_0.rows[int(1)].x * dOut_5.rows[int(1)].x; - *&(((&left_d_result_2)->rows + (int(1)))->y) = *&(((&left_d_result_2)->rows + (int(1)))->y) + (*right_2).primal_0.rows[int(1)].x * dOut_5.rows[int(1)].x; - *&(((&right_d_result_2)->rows + (int(1)))->x) = *&(((&right_d_result_2)->rows + (int(1)))->x) + (*left_2).primal_0.rows[int(1)].y * dOut_5.rows[int(1)].x; - *&(((&left_d_result_2)->rows + (int(1)))->z) = *&(((&left_d_result_2)->rows + (int(1)))->z) + (*right_2).primal_0.rows[int(2)].x * dOut_5.rows[int(1)].x; - *&(((&right_d_result_2)->rows + (int(2)))->x) = *&(((&right_d_result_2)->rows + (int(2)))->x) + (*left_2).primal_0.rows[int(1)].z * dOut_5.rows[int(1)].x; - *&(((&left_d_result_2)->rows + (int(1)))->x) = *&(((&left_d_result_2)->rows + (int(1)))->x) + (*right_2).primal_0.rows[int(0)].y * dOut_5.rows[int(1)].y; - *&(((&right_d_result_2)->rows + (int(0)))->y) = *&(((&right_d_result_2)->rows + (int(0)))->y) + (*left_2).primal_0.rows[int(1)].x * dOut_5.rows[int(1)].y; - *&(((&left_d_result_2)->rows + (int(1)))->y) = *&(((&left_d_result_2)->rows + (int(1)))->y) + (*right_2).primal_0.rows[int(1)].y * dOut_5.rows[int(1)].y; - *&(((&right_d_result_2)->rows + (int(1)))->y) = *&(((&right_d_result_2)->rows + (int(1)))->y) + (*left_2).primal_0.rows[int(1)].y * dOut_5.rows[int(1)].y; - *&(((&left_d_result_2)->rows + (int(1)))->z) = *&(((&left_d_result_2)->rows + (int(1)))->z) + (*right_2).primal_0.rows[int(2)].y * dOut_5.rows[int(1)].y; - *&(((&right_d_result_2)->rows + (int(2)))->y) = *&(((&right_d_result_2)->rows + (int(2)))->y) + (*left_2).primal_0.rows[int(1)].z * dOut_5.rows[int(1)].y; - *&(((&left_d_result_2)->rows + (int(1)))->x) = *&(((&left_d_result_2)->rows + (int(1)))->x) + (*right_2).primal_0.rows[int(0)].z * dOut_5.rows[int(1)].z; - *&(((&right_d_result_2)->rows + (int(0)))->z) = *&(((&right_d_result_2)->rows + (int(0)))->z) + (*left_2).primal_0.rows[int(1)].x * dOut_5.rows[int(1)].z; - *&(((&left_d_result_2)->rows + (int(1)))->y) = *&(((&left_d_result_2)->rows + (int(1)))->y) + (*right_2).primal_0.rows[int(1)].z * dOut_5.rows[int(1)].z; - *&(((&right_d_result_2)->rows + (int(1)))->z) = *&(((&right_d_result_2)->rows + (int(1)))->z) + (*left_2).primal_0.rows[int(1)].y * dOut_5.rows[int(1)].z; - *&(((&left_d_result_2)->rows + (int(1)))->z) = *&(((&left_d_result_2)->rows + (int(1)))->z) + (*right_2).primal_0.rows[int(2)].z * dOut_5.rows[int(1)].z; - *&(((&right_d_result_2)->rows + (int(2)))->z) = *&(((&right_d_result_2)->rows + (int(2)))->z) + (*left_2).primal_0.rows[int(1)].z * dOut_5.rows[int(1)].z; - *&(((&left_d_result_2)->rows + (int(2)))->x) = *&(((&left_d_result_2)->rows + (int(2)))->x) + (*right_2).primal_0.rows[int(0)].x * dOut_5.rows[int(2)].x; - *&(((&right_d_result_2)->rows + (int(0)))->x) = *&(((&right_d_result_2)->rows + (int(0)))->x) + (*left_2).primal_0.rows[int(2)].x * dOut_5.rows[int(2)].x; - *&(((&left_d_result_2)->rows + (int(2)))->y) = *&(((&left_d_result_2)->rows + (int(2)))->y) + (*right_2).primal_0.rows[int(1)].x * dOut_5.rows[int(2)].x; - *&(((&right_d_result_2)->rows + (int(1)))->x) = *&(((&right_d_result_2)->rows + (int(1)))->x) + (*left_2).primal_0.rows[int(2)].y * dOut_5.rows[int(2)].x; - *&(((&left_d_result_2)->rows + (int(2)))->z) = *&(((&left_d_result_2)->rows + (int(2)))->z) + (*right_2).primal_0.rows[int(2)].x * dOut_5.rows[int(2)].x; - *&(((&right_d_result_2)->rows + (int(2)))->x) = *&(((&right_d_result_2)->rows + (int(2)))->x) + (*left_2).primal_0.rows[int(2)].z * dOut_5.rows[int(2)].x; - *&(((&left_d_result_2)->rows + (int(2)))->x) = *&(((&left_d_result_2)->rows + (int(2)))->x) + (*right_2).primal_0.rows[int(0)].y * dOut_5.rows[int(2)].y; - *&(((&right_d_result_2)->rows + (int(0)))->y) = *&(((&right_d_result_2)->rows + (int(0)))->y) + (*left_2).primal_0.rows[int(2)].x * dOut_5.rows[int(2)].y; - *&(((&left_d_result_2)->rows + (int(2)))->y) = *&(((&left_d_result_2)->rows + (int(2)))->y) + (*right_2).primal_0.rows[int(1)].y * dOut_5.rows[int(2)].y; - *&(((&right_d_result_2)->rows + (int(1)))->y) = *&(((&right_d_result_2)->rows + (int(1)))->y) + (*left_2).primal_0.rows[int(2)].y * dOut_5.rows[int(2)].y; - *&(((&left_d_result_2)->rows + (int(2)))->z) = *&(((&left_d_result_2)->rows + (int(2)))->z) + (*right_2).primal_0.rows[int(2)].y * dOut_5.rows[int(2)].y; - *&(((&right_d_result_2)->rows + (int(2)))->y) = *&(((&right_d_result_2)->rows + (int(2)))->y) + (*left_2).primal_0.rows[int(2)].z * dOut_5.rows[int(2)].y; - *&(((&left_d_result_2)->rows + (int(2)))->x) = *&(((&left_d_result_2)->rows + (int(2)))->x) + (*right_2).primal_0.rows[int(0)].z * dOut_5.rows[int(2)].z; - *&(((&right_d_result_2)->rows + (int(0)))->z) = *&(((&right_d_result_2)->rows + (int(0)))->z) + (*left_2).primal_0.rows[int(2)].x * dOut_5.rows[int(2)].z; - *&(((&left_d_result_2)->rows + (int(2)))->y) = *&(((&left_d_result_2)->rows + (int(2)))->y) + (*right_2).primal_0.rows[int(1)].z * dOut_5.rows[int(2)].z; - *&(((&right_d_result_2)->rows + (int(1)))->z) = *&(((&right_d_result_2)->rows + (int(1)))->z) + (*left_2).primal_0.rows[int(2)].y * dOut_5.rows[int(2)].z; - *&(((&left_d_result_2)->rows + (int(2)))->z) = *&(((&left_d_result_2)->rows + (int(2)))->z) + (*right_2).primal_0.rows[int(2)].z * dOut_5.rows[int(2)].z; - *&(((&right_d_result_2)->rows + (int(2)))->z) = *&(((&right_d_result_2)->rows + (int(2)))->z) + (*left_2).primal_0.rows[int(2)].z * dOut_5.rows[int(2)].z; + *&(((&left_d_result_2)->rows + (int(0)))->x) = *&(((&left_d_result_2)->rows + (int(0)))->x) + (*right_2).primal_0.rows[int(0)].x * dOut_6.rows[int(0)].x; + *&(((&right_d_result_2)->rows + (int(0)))->x) = *&(((&right_d_result_2)->rows + (int(0)))->x) + (*left_2).primal_0.rows[int(0)].x * dOut_6.rows[int(0)].x; + *&(((&left_d_result_2)->rows + (int(0)))->y) = *&(((&left_d_result_2)->rows + (int(0)))->y) + (*right_2).primal_0.rows[int(1)].x * dOut_6.rows[int(0)].x; + *&(((&right_d_result_2)->rows + (int(1)))->x) = *&(((&right_d_result_2)->rows + (int(1)))->x) + (*left_2).primal_0.rows[int(0)].y * dOut_6.rows[int(0)].x; + *&(((&left_d_result_2)->rows + (int(0)))->z) = *&(((&left_d_result_2)->rows + (int(0)))->z) + (*right_2).primal_0.rows[int(2)].x * dOut_6.rows[int(0)].x; + *&(((&right_d_result_2)->rows + (int(2)))->x) = *&(((&right_d_result_2)->rows + (int(2)))->x) + (*left_2).primal_0.rows[int(0)].z * dOut_6.rows[int(0)].x; + *&(((&left_d_result_2)->rows + (int(0)))->x) = *&(((&left_d_result_2)->rows + (int(0)))->x) + (*right_2).primal_0.rows[int(0)].y * dOut_6.rows[int(0)].y; + *&(((&right_d_result_2)->rows + (int(0)))->y) = *&(((&right_d_result_2)->rows + (int(0)))->y) + (*left_2).primal_0.rows[int(0)].x * dOut_6.rows[int(0)].y; + *&(((&left_d_result_2)->rows + (int(0)))->y) = *&(((&left_d_result_2)->rows + (int(0)))->y) + (*right_2).primal_0.rows[int(1)].y * dOut_6.rows[int(0)].y; + *&(((&right_d_result_2)->rows + (int(1)))->y) = *&(((&right_d_result_2)->rows + (int(1)))->y) + (*left_2).primal_0.rows[int(0)].y * dOut_6.rows[int(0)].y; + *&(((&left_d_result_2)->rows + (int(0)))->z) = *&(((&left_d_result_2)->rows + (int(0)))->z) + (*right_2).primal_0.rows[int(2)].y * dOut_6.rows[int(0)].y; + *&(((&right_d_result_2)->rows + (int(2)))->y) = *&(((&right_d_result_2)->rows + (int(2)))->y) + (*left_2).primal_0.rows[int(0)].z * dOut_6.rows[int(0)].y; + *&(((&left_d_result_2)->rows + (int(0)))->x) = *&(((&left_d_result_2)->rows + (int(0)))->x) + (*right_2).primal_0.rows[int(0)].z * dOut_6.rows[int(0)].z; + *&(((&right_d_result_2)->rows + (int(0)))->z) = *&(((&right_d_result_2)->rows + (int(0)))->z) + (*left_2).primal_0.rows[int(0)].x * dOut_6.rows[int(0)].z; + *&(((&left_d_result_2)->rows + (int(0)))->y) = *&(((&left_d_result_2)->rows + (int(0)))->y) + (*right_2).primal_0.rows[int(1)].z * dOut_6.rows[int(0)].z; + *&(((&right_d_result_2)->rows + (int(1)))->z) = *&(((&right_d_result_2)->rows + (int(1)))->z) + (*left_2).primal_0.rows[int(0)].y * dOut_6.rows[int(0)].z; + *&(((&left_d_result_2)->rows + (int(0)))->z) = *&(((&left_d_result_2)->rows + (int(0)))->z) + (*right_2).primal_0.rows[int(2)].z * dOut_6.rows[int(0)].z; + *&(((&right_d_result_2)->rows + (int(2)))->z) = *&(((&right_d_result_2)->rows + (int(2)))->z) + (*left_2).primal_0.rows[int(0)].z * dOut_6.rows[int(0)].z; + *&(((&left_d_result_2)->rows + (int(1)))->x) = *&(((&left_d_result_2)->rows + (int(1)))->x) + (*right_2).primal_0.rows[int(0)].x * dOut_6.rows[int(1)].x; + *&(((&right_d_result_2)->rows + (int(0)))->x) = *&(((&right_d_result_2)->rows + (int(0)))->x) + (*left_2).primal_0.rows[int(1)].x * dOut_6.rows[int(1)].x; + *&(((&left_d_result_2)->rows + (int(1)))->y) = *&(((&left_d_result_2)->rows + (int(1)))->y) + (*right_2).primal_0.rows[int(1)].x * dOut_6.rows[int(1)].x; + *&(((&right_d_result_2)->rows + (int(1)))->x) = *&(((&right_d_result_2)->rows + (int(1)))->x) + (*left_2).primal_0.rows[int(1)].y * dOut_6.rows[int(1)].x; + *&(((&left_d_result_2)->rows + (int(1)))->z) = *&(((&left_d_result_2)->rows + (int(1)))->z) + (*right_2).primal_0.rows[int(2)].x * dOut_6.rows[int(1)].x; + *&(((&right_d_result_2)->rows + (int(2)))->x) = *&(((&right_d_result_2)->rows + (int(2)))->x) + (*left_2).primal_0.rows[int(1)].z * dOut_6.rows[int(1)].x; + *&(((&left_d_result_2)->rows + (int(1)))->x) = *&(((&left_d_result_2)->rows + (int(1)))->x) + (*right_2).primal_0.rows[int(0)].y * dOut_6.rows[int(1)].y; + *&(((&right_d_result_2)->rows + (int(0)))->y) = *&(((&right_d_result_2)->rows + (int(0)))->y) + (*left_2).primal_0.rows[int(1)].x * dOut_6.rows[int(1)].y; + *&(((&left_d_result_2)->rows + (int(1)))->y) = *&(((&left_d_result_2)->rows + (int(1)))->y) + (*right_2).primal_0.rows[int(1)].y * dOut_6.rows[int(1)].y; + *&(((&right_d_result_2)->rows + (int(1)))->y) = *&(((&right_d_result_2)->rows + (int(1)))->y) + (*left_2).primal_0.rows[int(1)].y * dOut_6.rows[int(1)].y; + *&(((&left_d_result_2)->rows + (int(1)))->z) = *&(((&left_d_result_2)->rows + (int(1)))->z) + (*right_2).primal_0.rows[int(2)].y * dOut_6.rows[int(1)].y; + *&(((&right_d_result_2)->rows + (int(2)))->y) = *&(((&right_d_result_2)->rows + (int(2)))->y) + (*left_2).primal_0.rows[int(1)].z * dOut_6.rows[int(1)].y; + *&(((&left_d_result_2)->rows + (int(1)))->x) = *&(((&left_d_result_2)->rows + (int(1)))->x) + (*right_2).primal_0.rows[int(0)].z * dOut_6.rows[int(1)].z; + *&(((&right_d_result_2)->rows + (int(0)))->z) = *&(((&right_d_result_2)->rows + (int(0)))->z) + (*left_2).primal_0.rows[int(1)].x * dOut_6.rows[int(1)].z; + *&(((&left_d_result_2)->rows + (int(1)))->y) = *&(((&left_d_result_2)->rows + (int(1)))->y) + (*right_2).primal_0.rows[int(1)].z * dOut_6.rows[int(1)].z; + *&(((&right_d_result_2)->rows + (int(1)))->z) = *&(((&right_d_result_2)->rows + (int(1)))->z) + (*left_2).primal_0.rows[int(1)].y * dOut_6.rows[int(1)].z; + *&(((&left_d_result_2)->rows + (int(1)))->z) = *&(((&left_d_result_2)->rows + (int(1)))->z) + (*right_2).primal_0.rows[int(2)].z * dOut_6.rows[int(1)].z; + *&(((&right_d_result_2)->rows + (int(2)))->z) = *&(((&right_d_result_2)->rows + (int(2)))->z) + (*left_2).primal_0.rows[int(1)].z * dOut_6.rows[int(1)].z; + *&(((&left_d_result_2)->rows + (int(2)))->x) = *&(((&left_d_result_2)->rows + (int(2)))->x) + (*right_2).primal_0.rows[int(0)].x * dOut_6.rows[int(2)].x; + *&(((&right_d_result_2)->rows + (int(0)))->x) = *&(((&right_d_result_2)->rows + (int(0)))->x) + (*left_2).primal_0.rows[int(2)].x * dOut_6.rows[int(2)].x; + *&(((&left_d_result_2)->rows + (int(2)))->y) = *&(((&left_d_result_2)->rows + (int(2)))->y) + (*right_2).primal_0.rows[int(1)].x * dOut_6.rows[int(2)].x; + *&(((&right_d_result_2)->rows + (int(1)))->x) = *&(((&right_d_result_2)->rows + (int(1)))->x) + (*left_2).primal_0.rows[int(2)].y * dOut_6.rows[int(2)].x; + *&(((&left_d_result_2)->rows + (int(2)))->z) = *&(((&left_d_result_2)->rows + (int(2)))->z) + (*right_2).primal_0.rows[int(2)].x * dOut_6.rows[int(2)].x; + *&(((&right_d_result_2)->rows + (int(2)))->x) = *&(((&right_d_result_2)->rows + (int(2)))->x) + (*left_2).primal_0.rows[int(2)].z * dOut_6.rows[int(2)].x; + *&(((&left_d_result_2)->rows + (int(2)))->x) = *&(((&left_d_result_2)->rows + (int(2)))->x) + (*right_2).primal_0.rows[int(0)].y * dOut_6.rows[int(2)].y; + *&(((&right_d_result_2)->rows + (int(0)))->y) = *&(((&right_d_result_2)->rows + (int(0)))->y) + (*left_2).primal_0.rows[int(2)].x * dOut_6.rows[int(2)].y; + *&(((&left_d_result_2)->rows + (int(2)))->y) = *&(((&left_d_result_2)->rows + (int(2)))->y) + (*right_2).primal_0.rows[int(1)].y * dOut_6.rows[int(2)].y; + *&(((&right_d_result_2)->rows + (int(1)))->y) = *&(((&right_d_result_2)->rows + (int(1)))->y) + (*left_2).primal_0.rows[int(2)].y * dOut_6.rows[int(2)].y; + *&(((&left_d_result_2)->rows + (int(2)))->z) = *&(((&left_d_result_2)->rows + (int(2)))->z) + (*right_2).primal_0.rows[int(2)].y * dOut_6.rows[int(2)].y; + *&(((&right_d_result_2)->rows + (int(2)))->y) = *&(((&right_d_result_2)->rows + (int(2)))->y) + (*left_2).primal_0.rows[int(2)].z * dOut_6.rows[int(2)].y; + *&(((&left_d_result_2)->rows + (int(2)))->x) = *&(((&left_d_result_2)->rows + (int(2)))->x) + (*right_2).primal_0.rows[int(0)].z * dOut_6.rows[int(2)].z; + *&(((&right_d_result_2)->rows + (int(0)))->z) = *&(((&right_d_result_2)->rows + (int(0)))->z) + (*left_2).primal_0.rows[int(2)].x * dOut_6.rows[int(2)].z; + *&(((&left_d_result_2)->rows + (int(2)))->y) = *&(((&left_d_result_2)->rows + (int(2)))->y) + (*right_2).primal_0.rows[int(1)].z * dOut_6.rows[int(2)].z; + *&(((&right_d_result_2)->rows + (int(1)))->z) = *&(((&right_d_result_2)->rows + (int(1)))->z) + (*left_2).primal_0.rows[int(2)].y * dOut_6.rows[int(2)].z; + *&(((&left_d_result_2)->rows + (int(2)))->z) = *&(((&left_d_result_2)->rows + (int(2)))->z) + (*right_2).primal_0.rows[int(2)].z * dOut_6.rows[int(2)].z; + *&(((&right_d_result_2)->rows + (int(2)))->z) = *&(((&right_d_result_2)->rows + (int(2)))->z) + (*left_2).primal_0.rows[int(2)].z * dOut_6.rows[int(2)].z; left_2->primal_0 = (*left_2).primal_0; left_2->differential_0 = left_d_result_2; right_2->primal_0 = (*right_2).primal_0; @@ -486,7 +569,7 @@ inline __device__ void mul_2(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * left_2, Diff inline __device__ Matrix mul_3(Matrix left_3, Matrix right_3) { - Matrix result_4; + Matrix result_10; int r_4 = int(0); for(;;) { @@ -507,32 +590,32 @@ inline __device__ Matrix mul_3(Matrix left_3, Matrix { break; } - int i_0 = int(0); + int i_3 = int(0); float sum_0 = 0.0f; for(;;) { - if(i_0 < int(3)) + if(i_3 < int(3)) { } else { break; } - float sum_1 = sum_0 + _slang_vector_get_element(left_3.rows[r_4], i_0) * _slang_vector_get_element(right_3.rows[i_0], c_4); - i_0 = i_0 + int(1); + float sum_1 = sum_0 + _slang_vector_get_element(left_3.rows[r_4], i_3) * _slang_vector_get_element(right_3.rows[i_3], c_4); + i_3 = i_3 + int(1); sum_0 = sum_1; } - *_slang_vector_get_element_ptr(((&result_4)->rows + (r_4)), c_4) = sum_0; + *_slang_vector_get_element_ptr(((&result_10)->rows + (r_4)), c_4) = sum_0; c_4 = c_4 + int(1); } r_4 = r_4 + int(1); } - return result_4; + return result_10; } inline __device__ Matrix mul_4(Matrix left_4, Matrix right_4) { - Matrix result_5; + Matrix result_11; int r_5 = int(0); for(;;) { @@ -553,32 +636,32 @@ inline __device__ Matrix mul_4(Matrix left_4, Matrix { break; } - int i_1 = int(0); + int i_4 = int(0); float sum_2 = 0.0f; for(;;) { - if(i_1 < int(3)) + if(i_4 < int(3)) { } else { break; } - float sum_3 = sum_2 + _slang_vector_get_element(left_4.rows[r_5], i_1) * _slang_vector_get_element(right_4.rows[i_1], c_5); - i_1 = i_1 + int(1); + float sum_3 = sum_2 + _slang_vector_get_element(left_4.rows[r_5], i_4) * _slang_vector_get_element(right_4.rows[i_4], c_5); + i_4 = i_4 + int(1); sum_2 = sum_3; } - *_slang_vector_get_element_ptr(((&result_5)->rows + (r_5)), c_5) = sum_2; + *_slang_vector_get_element_ptr(((&result_11)->rows + (r_5)), c_5) = sum_2; c_5 = c_5 + int(1); } r_5 = r_5 + int(1); } - return result_5; + return result_11; } inline __device__ Matrix mul_5(Matrix left_5, Matrix right_5) { - Matrix result_6; + Matrix result_12; int r_6 = int(0); for(;;) { @@ -599,259 +682,143 @@ inline __device__ Matrix mul_5(Matrix left_5, Matrix { break; } - int i_2 = int(0); + int i_5 = int(0); float sum_4 = 0.0f; for(;;) { - if(i_2 < int(3)) + if(i_5 < int(3)) { } else { break; } - float sum_5 = sum_4 + _slang_vector_get_element(left_5.rows[r_6], i_2) * _slang_vector_get_element(right_5.rows[i_2], c_6); - i_2 = i_2 + int(1); + float sum_5 = sum_4 + _slang_vector_get_element(left_5.rows[r_6], i_5) * _slang_vector_get_element(right_5.rows[i_5], c_6); + i_5 = i_5 + int(1); sum_4 = sum_5; } - *_slang_vector_get_element_ptr(((&result_6)->rows + (r_6)), c_6) = sum_4; + *_slang_vector_get_element_ptr(((&result_12)->rows + (r_6)), c_6) = sum_4; c_6 = c_6 + int(1); } r_6 = r_6 + int(1); } - return result_6; + return result_12; } -inline __device__ bool persp_proj_3dgs_nav(float3 mean3d_0, Matrix cov3d_0, float4 intrins_0, FixedArray dist_coeffs_0, uint width_0, uint height_0, Matrix * cov2d_0, float2 * mean2d_0) +inline __device__ float2 DistNone_distort_0(float2 uv_0, FixedArray * coeffs_0) { - bool _S12; - float2 _S13; - float _S14; + return uv_0; +} + +struct DiffPair_vectorx3Cfloatx2C2x3E_0 +{ + float2 primal_0; + float2 differential_0; +}; + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistNone_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_0, FixedArray * coeffs_1) +{ + DiffPair_vectorx3Cfloatx2C2x3E_0 _S12 = { dpuv_0->primal_0, dpuv_0->differential_0 }; + return _S12; +} + +inline __device__ bool persp_proj_3dgs_nav_none(float3 mean3d_0, Matrix cov3d_0, float4 intrins_0, FixedArray dist_coeffs_0, uint width_0, uint height_0, Matrix * cov2d_0, float2 * mean2d_0) +{ + bool _S13; + float2 _S14; + float _S15; for(;;) { float cx_0 = intrins_0.z; float cy_0 = intrins_0.w; + *cov2d_0 = makeMatrix (0.0f); for(;;) { - float2 _S15 = float2 {mean3d_0.x, mean3d_0.y}; - _S13 = _S15; - float _S16 = mean3d_0.z; + float2 _S16 = float2 {mean3d_0.x, mean3d_0.y}; _S14 = _S16; - *mean2d_0 = _S15 / make_float2 (_S16); - if(_S16 < 0.0f) - { - _S12 = true; - } - else - { - float u_0 = (*mean2d_0).x; - float v_0 = (*mean2d_0).y; - float _S17 = u_0 + u_0; - float r2_0 = u_0 * u_0 + v_0 * v_0; - float _S18 = dist_coeffs_0[int(2)] + r2_0 * dist_coeffs_0[int(3)]; - float _S19 = dist_coeffs_0[int(1)] + r2_0 * _S18; - float _S20 = dist_coeffs_0[int(0)] + r2_0 * _S19; - float radial_0 = 1.0f + r2_0 * _S20; - float _S21 = 2.0f * dist_coeffs_0[int(4)]; - float _S22 = 2.0f * u_0; - float _S23 = 2.0f * dist_coeffs_0[int(5)]; - float _S24 = 2.0f * v_0; - float2 _S25 = make_float2 (1.0f, 0.0f) * make_float2 (radial_0) + make_float2 (_S17 * _S20 + (_S17 * _S19 + (_S17 * _S18 + _S17 * dist_coeffs_0[int(3)] * r2_0) * r2_0) * r2_0) * *mean2d_0 + make_float2 (_S21 * v_0 + (_S17 + (_S22 + _S22)) * dist_coeffs_0[int(5)] + _S17 * dist_coeffs_0[int(6)], _S23 * v_0 + _S17 * dist_coeffs_0[int(4)] + _S17 * dist_coeffs_0[int(7)]); - float _S26 = v_0 + v_0; - float2 _S27 = make_float2 (0.0f, 1.0f) * make_float2 (radial_0) + make_float2 (_S26 * _S20 + (_S26 * _S19 + (_S26 * _S18 + _S26 * dist_coeffs_0[int(3)] * r2_0) * r2_0) * r2_0) * *mean2d_0 + make_float2 (_S21 * u_0 + _S26 * dist_coeffs_0[int(5)] + _S26 * dist_coeffs_0[int(6)], _S23 * u_0 + (_S26 + (_S24 + _S24)) * dist_coeffs_0[int(4)] + _S26 * dist_coeffs_0[int(7)]); - Matrix _S28 = transpose_0(makeMatrix (_S25 + make_float2 (_S25.x * dist_coeffs_0[int(8)] + _S25.y * dist_coeffs_0[int(9)], 0.0f), _S27 + make_float2 (_S27.x * dist_coeffs_0[int(8)] + _S27.y * dist_coeffs_0[int(9)], 0.0f))); - _S12 = !((F32_min((determinant_0(_S28)), ((F32_min((_S28.rows[int(0)].x), (_S28.rows[int(1)].y)))))) > 0.0f); - } - if(_S12) + float _S17 = mean3d_0.z; + _S15 = _S17; + float2 uv0_0 = _S16 / make_float2 (_S17); + bool _S18 = _S17 < 0.0f; + if(_S18) { + *mean2d_0 = uv0_0; + _S13 = false; break; } - float u_1 = (*mean2d_0).x; - float v_1 = (*mean2d_0).y; - float r2_1 = u_1 * u_1 + v_1 * v_1; - float2 _S29 = *mean2d_0 * make_float2 (1.0f + r2_1 * (dist_coeffs_0[int(0)] + r2_1 * (dist_coeffs_0[int(1)] + r2_1 * (dist_coeffs_0[int(2)] + r2_1 * dist_coeffs_0[int(3)])))) + make_float2 (2.0f * dist_coeffs_0[int(4)] * u_1 * v_1 + dist_coeffs_0[int(5)] * (r2_1 + 2.0f * u_1 * u_1) + dist_coeffs_0[int(6)] * r2_1, 2.0f * dist_coeffs_0[int(5)] * u_1 * v_1 + dist_coeffs_0[int(4)] * (r2_1 + 2.0f * v_1 * v_1) + dist_coeffs_0[int(7)] * r2_1); - float2 _S30 = _S29 + make_float2 (dist_coeffs_0[int(8)] * _S29.x + dist_coeffs_0[int(9)] * _S29.y, 0.0f); - *mean2d_0 = make_float2 (intrins_0.x * _S30.x + cx_0, intrins_0.y * _S30.y + cy_0); + float2 uv_1 = _S16 / make_float2 (_S17); + FixedArray _S19 = dist_coeffs_0; + float2 _S20 = DistNone_distort_0(uv_1, &_S19); + *mean2d_0 = make_float2 (intrins_0.x * _S20.x + cx_0, intrins_0.y * _S20.y + cy_0); + _S13 = true; break; } - if(!!_S12) + if(!_S13) { - _S12 = false; + _S13 = false; break; } Matrix J_0; - float2 _S31 = _S13 / make_float2 (_S14); - float _S32 = _S14 * _S14; - float2 _S33 = make_float2 (1.0f, 0.0f) * make_float2 (_S14) / make_float2 (_S32); - float u_2 = _S31.x; - float s_diff_u_0 = _S33.x; - float v_2 = _S31.y; - float s_diff_v_0 = _S33.y; - float _S34 = s_diff_u_0 * u_2; - float _S35 = s_diff_v_0 * v_2; - float r2_2 = u_2 * u_2 + v_2 * v_2; - float s_diff_r2_0 = _S34 + _S34 + (_S35 + _S35); - float _S36 = dist_coeffs_0[int(2)] + r2_2 * dist_coeffs_0[int(3)]; - float _S37 = dist_coeffs_0[int(1)] + r2_2 * _S36; - float _S38 = dist_coeffs_0[int(0)] + r2_2 * _S37; - float _S39 = 2.0f * dist_coeffs_0[int(4)]; - float _S40 = 2.0f * dist_coeffs_0[int(5)]; - float2 _S41 = _S33 * make_float2 (1.0f + r2_2 * _S38) + make_float2 (s_diff_r2_0 * _S38 + (s_diff_r2_0 * _S37 + (s_diff_r2_0 * _S36 + s_diff_r2_0 * dist_coeffs_0[int(3)] * r2_2) * r2_2) * r2_2) * _S31 + make_float2 (s_diff_u_0 * _S39 * v_2 + s_diff_v_0 * (_S39 * u_2) + (s_diff_r2_0 + (s_diff_u_0 * 2.0f * u_2 + s_diff_u_0 * (2.0f * u_2))) * dist_coeffs_0[int(5)] + s_diff_r2_0 * dist_coeffs_0[int(6)], s_diff_u_0 * _S40 * v_2 + s_diff_v_0 * (_S40 * u_2) + (s_diff_r2_0 + (s_diff_v_0 * 2.0f * v_2 + s_diff_v_0 * (2.0f * v_2))) * dist_coeffs_0[int(4)] + s_diff_r2_0 * dist_coeffs_0[int(7)]); - float2 _S42 = _S41 + make_float2 (_S41.x * dist_coeffs_0[int(8)] + _S41.y * dist_coeffs_0[int(9)], 0.0f); + float _S21 = _S15 * _S15; + float2 s_diff_uv_0 = make_float2 (1.0f, 0.0f) * make_float2 (_S15) / make_float2 (_S21); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S22; + (&_S22)->primal_0 = _S14 / make_float2 (_S15); + (&_S22)->differential_0 = s_diff_uv_0; + FixedArray _S23 = dist_coeffs_0; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S24 = s_fwd_DistNone_distort_0(&_S22, &_S23); float fx_0 = intrins_0.x; float fy_0 = intrins_0.y; - float _S43 = _S42.y * fy_0; + float _S25 = _S24.differential_0.y * fy_0; Matrix J_1; - *&(((&J_1)->rows + (int(0)))->x) = _S42.x * fx_0; - *&(((&J_1)->rows + (int(1)))->x) = _S43; - float2 _S44 = _S13 / make_float2 (_S14); - float2 _S45 = make_float2 (0.0f, 1.0f) * make_float2 (_S14) / make_float2 (_S32); - float u_3 = _S44.x; - float s_diff_u_1 = _S45.x; - float v_3 = _S44.y; - float s_diff_v_1 = _S45.y; - float _S46 = s_diff_u_1 * u_3; - float _S47 = s_diff_v_1 * v_3; - float r2_3 = u_3 * u_3 + v_3 * v_3; - float s_diff_r2_1 = _S46 + _S46 + (_S47 + _S47); - float _S48 = dist_coeffs_0[int(2)] + r2_3 * dist_coeffs_0[int(3)]; - float _S49 = dist_coeffs_0[int(1)] + r2_3 * _S48; - float _S50 = dist_coeffs_0[int(0)] + r2_3 * _S49; - float2 _S51 = _S45 * make_float2 (1.0f + r2_3 * _S50) + make_float2 (s_diff_r2_1 * _S50 + (s_diff_r2_1 * _S49 + (s_diff_r2_1 * _S48 + s_diff_r2_1 * dist_coeffs_0[int(3)] * r2_3) * r2_3) * r2_3) * _S44 + make_float2 (s_diff_u_1 * _S39 * v_3 + s_diff_v_1 * (_S39 * u_3) + (s_diff_r2_1 + (s_diff_u_1 * 2.0f * u_3 + s_diff_u_1 * (2.0f * u_3))) * dist_coeffs_0[int(5)] + s_diff_r2_1 * dist_coeffs_0[int(6)], s_diff_u_1 * _S40 * v_3 + s_diff_v_1 * (_S40 * u_3) + (s_diff_r2_1 + (s_diff_v_1 * 2.0f * v_3 + s_diff_v_1 * (2.0f * v_3))) * dist_coeffs_0[int(4)] + s_diff_r2_1 * dist_coeffs_0[int(7)]); - float2 _S52 = _S51 + make_float2 (_S51.x * dist_coeffs_0[int(8)] + _S51.y * dist_coeffs_0[int(9)], 0.0f); - float _S53 = _S52.y * fy_0; - *&(((&J_1)->rows + (int(0)))->y) = _S52.x * fx_0; - *&(((&J_1)->rows + (int(1)))->y) = _S53; - float2 _S54 = _S13 / make_float2 (_S14); - float2 _S55 = (make_float2 (0.0f, 0.0f) - _S13) / make_float2 (_S32); - float u_4 = _S54.x; - float s_diff_u_2 = _S55.x; - float v_4 = _S54.y; - float s_diff_v_2 = _S55.y; - float _S56 = s_diff_u_2 * u_4; - float _S57 = s_diff_v_2 * v_4; - float r2_4 = u_4 * u_4 + v_4 * v_4; - float s_diff_r2_2 = _S56 + _S56 + (_S57 + _S57); - float _S58 = dist_coeffs_0[int(2)] + r2_4 * dist_coeffs_0[int(3)]; - float _S59 = dist_coeffs_0[int(1)] + r2_4 * _S58; - float _S60 = dist_coeffs_0[int(0)] + r2_4 * _S59; - float2 _S61 = _S55 * make_float2 (1.0f + r2_4 * _S60) + make_float2 (s_diff_r2_2 * _S60 + (s_diff_r2_2 * _S59 + (s_diff_r2_2 * _S58 + s_diff_r2_2 * dist_coeffs_0[int(3)] * r2_4) * r2_4) * r2_4) * _S54 + make_float2 (s_diff_u_2 * _S39 * v_4 + s_diff_v_2 * (_S39 * u_4) + (s_diff_r2_2 + (s_diff_u_2 * 2.0f * u_4 + s_diff_u_2 * (2.0f * u_4))) * dist_coeffs_0[int(5)] + s_diff_r2_2 * dist_coeffs_0[int(6)], s_diff_u_2 * _S40 * v_4 + s_diff_v_2 * (_S40 * u_4) + (s_diff_r2_2 + (s_diff_v_2 * 2.0f * v_4 + s_diff_v_2 * (2.0f * v_4))) * dist_coeffs_0[int(4)] + s_diff_r2_2 * dist_coeffs_0[int(7)]); - float2 _S62 = _S61 + make_float2 (_S61.x * dist_coeffs_0[int(8)] + _S61.y * dist_coeffs_0[int(9)], 0.0f); - float _S63 = _S62.y * fy_0; - *&(((&J_1)->rows + (int(0)))->z) = _S62.x * fx_0; - *&(((&J_1)->rows + (int(1)))->z) = _S63; + *&(((&J_1)->rows + (int(0)))->x) = _S24.differential_0.x * fx_0; + *&(((&J_1)->rows + (int(1)))->x) = _S25; + float2 s_diff_uv_1 = make_float2 (0.0f, 1.0f) * make_float2 (_S15) / make_float2 (_S21); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S26; + (&_S26)->primal_0 = _S14 / make_float2 (_S15); + (&_S26)->differential_0 = s_diff_uv_1; + FixedArray _S27 = dist_coeffs_0; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S28 = s_fwd_DistNone_distort_0(&_S26, &_S27); + float _S29 = _S28.differential_0.y * fy_0; + *&(((&J_1)->rows + (int(0)))->y) = _S28.differential_0.x * fx_0; + *&(((&J_1)->rows + (int(1)))->y) = _S29; + float2 s_diff_uv_2 = (make_float2 (0.0f, 0.0f) - _S14) / make_float2 (_S21); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S30; + (&_S30)->primal_0 = _S14 / make_float2 (_S15); + (&_S30)->differential_0 = s_diff_uv_2; + FixedArray _S31 = dist_coeffs_0; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S32 = s_fwd_DistNone_distort_0(&_S30, &_S31); + float _S33 = _S32.differential_0.y * fy_0; + *&(((&J_1)->rows + (int(0)))->z) = _S32.differential_0.x * fx_0; + *&(((&J_1)->rows + (int(1)))->z) = _S33; J_0 = J_1; - float _S64 = float(width_0); - float _S65 = 0.30000001192092896f * (0.5f * _S64); - float lim_x_pos_0 = _S64 + _S65; - float rz_0 = 1.0f / _S14; - float _S66 = - _S65; - float max_Jyz_0 = - (_S66 - cy_0) * rz_0; + float _S34 = float(width_0); + float _S35 = 0.30000001192092896f * (0.5f * _S34); + float lim_x_pos_0 = _S34 + _S35; + float rz_0 = 1.0f / _S15; + float _S36 = - _S35; + float max_Jyz_0 = - (_S36 - cy_0) * rz_0; float min_Jyz_0 = - (lim_x_pos_0 - cy_0) * rz_0; - *&(((&J_0)->rows + (int(0)))->z) = clamp_0(*&(((&J_0)->rows + (int(0)))->z), - (lim_x_pos_0 - cx_0) * rz_0, - (_S66 - cx_0) * rz_0); + *&(((&J_0)->rows + (int(0)))->z) = clamp_0(*&(((&J_0)->rows + (int(0)))->z), - (lim_x_pos_0 - cx_0) * rz_0, - (_S36 - cx_0) * rz_0); *&(((&J_0)->rows + (int(1)))->z) = clamp_0(*&(((&J_0)->rows + (int(1)))->z), min_Jyz_0, max_Jyz_0); *cov2d_0 = mul_4(mul_3(J_0, cov3d_0), transpose_1(J_0)); - _S12 = true; + _S13 = true; break; } - return _S12; + return _S13; } -inline __device__ void _d_sqrt_0(DiffPair_float_0 * dpx_3, float dOut_6) +inline __device__ void _d_sqrt_0(DiffPair_float_0 * dpx_4, float dOut_7) { - float _S67 = 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), ((*dpx_3).primal_0)))))) * dOut_6; - dpx_3->primal_0 = (*dpx_3).primal_0; - dpx_3->differential_0 = _S67; + float _S37 = 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), ((*dpx_4).primal_0)))))) * dOut_7; + dpx_4->primal_0 = (*dpx_4).primal_0; + dpx_4->differential_0 = _S37; return; } -inline __device__ DiffPair_float_0 _d_sqrt_1(DiffPair_float_0 * dpx_4) +inline __device__ DiffPair_float_0 _d_sqrt_1(DiffPair_float_0 * dpx_5) { - DiffPair_float_0 _S68 = { (F32_sqrt((dpx_4->primal_0))), 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), (dpx_4->primal_0)))))) * dpx_4->differential_0 }; - return _S68; -} - -struct DiffPair_vectorx3Cfloatx2C3x3E_0 -{ - float3 primal_0; - float3 differential_0; -}; - -inline __device__ void _d_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_5, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpy_2, float dOut_7) -{ - float3 x_d_result_0; - *&((&x_d_result_0)->x) = (*dpy_2).primal_0.x * dOut_7; - float3 y_d_result_0; - *&((&y_d_result_0)->x) = (*dpx_5).primal_0.x * dOut_7; - *&((&x_d_result_0)->y) = (*dpy_2).primal_0.y * dOut_7; - *&((&y_d_result_0)->y) = (*dpx_5).primal_0.y * dOut_7; - *&((&x_d_result_0)->z) = (*dpy_2).primal_0.z * dOut_7; - *&((&y_d_result_0)->z) = (*dpx_5).primal_0.z * dOut_7; - dpx_5->primal_0 = (*dpx_5).primal_0; - dpx_5->differential_0 = x_d_result_0; - dpy_2->primal_0 = (*dpy_2).primal_0; - dpy_2->differential_0 = y_d_result_0; - return; -} - -inline __device__ float dot_0(float2 x_5, float2 y_0) -{ - int i_3 = int(0); - float result_7 = 0.0f; - for(;;) - { - if(i_3 < int(2)) - { - } - else - { - break; - } - float result_8 = result_7 + _slang_vector_get_element(x_5, i_3) * _slang_vector_get_element(y_0, i_3); - i_3 = i_3 + int(1); - result_7 = result_8; - } - return result_7; -} - -inline __device__ float dot_1(float3 x_6, float3 y_1) -{ - int i_4 = int(0); - float result_9 = 0.0f; - for(;;) - { - if(i_4 < int(3)) - { - } - else - { - break; - } - float result_10 = result_9 + _slang_vector_get_element(x_6, i_4) * _slang_vector_get_element(y_1, i_4); - i_4 = i_4 + int(1); - result_9 = result_10; - } - return result_9; -} - -inline __device__ float dot_2(float4 x_7, float4 y_2) -{ - int i_5 = int(0); - float result_11 = 0.0f; - for(;;) - { - if(i_5 < int(4)) - { - } - else - { - break; - } - float result_12 = result_11 + _slang_vector_get_element(x_7, i_5) * _slang_vector_get_element(y_2, i_5); - i_5 = i_5 + int(1); - result_11 = result_12; - } - return result_11; + DiffPair_float_0 _S38 = { (F32_sqrt((dpx_5->primal_0))), 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), (dpx_5->primal_0)))))) * dpx_5->differential_0 }; + return _S38; } inline __device__ float length_0(float2 x_8) @@ -871,623 +838,2162 @@ inline __device__ float length_2(float4 x_10) inline __device__ void _d_atan2_0(DiffPair_float_0 * dpy_3, DiffPair_float_0 * dpx_6, float dOut_8) { - DiffPair_float_0 _S69 = *dpx_6; - float _S70 = - (*dpy_3).primal_0 / ((*dpx_6).primal_0 * (*dpx_6).primal_0 + (*dpy_3).primal_0 * (*dpy_3).primal_0) * dOut_8; + DiffPair_float_0 _S39 = *dpx_6; + float _S40 = - (*dpy_3).primal_0 / ((*dpx_6).primal_0 * (*dpx_6).primal_0 + (*dpy_3).primal_0 * (*dpy_3).primal_0) * dOut_8; dpx_6->primal_0 = (*dpx_6).primal_0; - dpx_6->differential_0 = _S70; - float _S71 = _S69.primal_0 / (_S69.primal_0 * _S69.primal_0 + (*dpy_3).primal_0 * (*dpy_3).primal_0) * dOut_8; + dpx_6->differential_0 = _S40; + float _S41 = _S39.primal_0 / (_S39.primal_0 * _S39.primal_0 + (*dpy_3).primal_0 * (*dpy_3).primal_0) * dOut_8; dpy_3->primal_0 = (*dpy_3).primal_0; - dpy_3->differential_0 = _S71; + dpy_3->differential_0 = _S41; return; } inline __device__ DiffPair_float_0 _d_atan2_1(DiffPair_float_0 * dpy_4, DiffPair_float_0 * dpx_7) { - float _S72 = dpx_7->primal_0 * dpx_7->primal_0 + dpy_4->primal_0 * dpy_4->primal_0; - DiffPair_float_0 _S73 = { (F32_atan2((dpy_4->primal_0), (dpx_7->primal_0))), - dpy_4->primal_0 / _S72 * dpx_7->differential_0 + dpx_7->primal_0 / _S72 * dpy_4->differential_0 }; - return _S73; + float _S42 = dpx_7->primal_0 * dpx_7->primal_0 + dpy_4->primal_0 * dpy_4->primal_0; + DiffPair_float_0 _S43 = { (F32_atan2((dpy_4->primal_0), (dpx_7->primal_0))), - dpy_4->primal_0 / _S42 * dpx_7->differential_0 + dpx_7->primal_0 / _S42 * dpy_4->differential_0 }; + return _S43; } -struct DiffPair_vectorx3Cfloatx2C2x3E_0 -{ - float2 primal_0; - float2 differential_0; -}; - inline __device__ DiffPair_float_0 s_fwd_length_impl_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpx_8) { - float _S74 = *&((&dpx_8->differential_0)->x) * *&((&dpx_8->primal_0)->x); - float _S75 = *&((&dpx_8->differential_0)->y) * *&((&dpx_8->primal_0)->y); - float s_diff_len_0 = _S74 + _S74 + (_S75 + _S75); - DiffPair_float_0 _S76; - (&_S76)->primal_0 = *&((&dpx_8->primal_0)->x) * *&((&dpx_8->primal_0)->x) + *&((&dpx_8->primal_0)->y) * *&((&dpx_8->primal_0)->y); - (&_S76)->differential_0 = s_diff_len_0; - DiffPair_float_0 _S77 = _d_sqrt_1(&_S76); - DiffPair_float_0 _S78 = { _S77.primal_0, _S77.differential_0 }; - return _S78; + float _S44 = *&((&dpx_8->differential_0)->x) * *&((&dpx_8->primal_0)->x); + float _S45 = *&((&dpx_8->differential_0)->y) * *&((&dpx_8->primal_0)->y); + float s_diff_len_0 = _S44 + _S44 + (_S45 + _S45); + DiffPair_float_0 _S46; + (&_S46)->primal_0 = *&((&dpx_8->primal_0)->x) * *&((&dpx_8->primal_0)->x) + *&((&dpx_8->primal_0)->y) * *&((&dpx_8->primal_0)->y); + (&_S46)->differential_0 = s_diff_len_0; + DiffPair_float_0 _S47 = _d_sqrt_1(&_S46); + DiffPair_float_0 _S48 = { _S47.primal_0, _S47.differential_0 }; + return _S48; } -inline __device__ bool fisheye_proj_3dgs_nav(float3 mean3d_1, Matrix cov3d_1, float4 intrins_1, FixedArray dist_coeffs_1, Matrix * cov2d_1, float2 * mean2d_1) +inline __device__ bool fisheye_proj_3dgs_nav_none(float3 mean3d_1, Matrix cov3d_1, float4 intrins_1, FixedArray dist_coeffs_1, Matrix * cov2d_1, float2 * mean2d_1) { - bool _S79; - float2 _S80; - float _S81; - float _S82; - float _S83; - float _S84; - float _S85; - float _S86; - float _S87; - float _S88; - float _S89; - float _S90; - float _S91; - float _S92; - float _S93; - bool _S94; - for(;;) + *cov2d_1 = makeMatrix (0.0f); + float2 _S49 = float2 {mean3d_1.x, mean3d_1.y}; + float r_7 = length_0(_S49); + float _S50 = mean3d_1.z; + float theta_0 = (F32_atan2((r_7), (_S50))); + float k_0; + if(theta_0 < 0.00100000004749745f) { - float k_0; - for(;;) - { - float2 _S95 = float2 {mean3d_1.x, mean3d_1.y}; - _S80 = _S95; - float r_7 = length_0(_S95); - float _S96 = mean3d_1.z; - _S81 = _S96; - float theta_0 = (F32_atan2((r_7), (_S96))); - if(theta_0 < 0.00100000004749745f) - { - k_0 = (1.0f - theta_0 * theta_0 / 3.0f) / _S96; - } - else - { - k_0 = theta_0 / r_7; - } - float2 _S97 = _S95 * make_float2 (k_0); - *mean2d_1 = _S97; - float2 _S98 = make_float2 (1.0f, 0.0f); - _S82 = dist_coeffs_1[int(0)]; - _S83 = dist_coeffs_1[int(1)]; - _S84 = dist_coeffs_1[int(2)]; - _S85 = dist_coeffs_1[int(3)]; - _S86 = dist_coeffs_1[int(4)]; - _S87 = dist_coeffs_1[int(5)]; - _S88 = dist_coeffs_1[int(6)]; - _S89 = dist_coeffs_1[int(7)]; - _S90 = dist_coeffs_1[int(8)]; - _S91 = dist_coeffs_1[int(9)]; - float u_5 = _S97.x; - float v_5 = _S97.y; - float _S99 = u_5 + u_5; - float r2_5 = u_5 * u_5 + v_5 * v_5; - float _S100 = dist_coeffs_1[int(2)] + r2_5 * dist_coeffs_1[int(3)]; - float _S101 = dist_coeffs_1[int(1)] + r2_5 * _S100; - float _S102 = dist_coeffs_1[int(0)] + r2_5 * _S101; - float _S103 = _S99 * _S102 + (_S99 * _S101 + (_S99 * _S100 + _S99 * dist_coeffs_1[int(3)] * r2_5) * r2_5) * r2_5; - float radial_1 = 1.0f + r2_5 * _S102; - float _S104 = 2.0f * dist_coeffs_1[int(4)]; - _S92 = _S104; - float _S105 = _S104 * u_5; - float _S106 = 2.0f * u_5; - float s_diff_du_0 = _S104 * v_5 + (_S99 + (_S106 + _S106)) * dist_coeffs_1[int(5)] + _S99 * dist_coeffs_1[int(6)]; - float _S107 = 2.0f * dist_coeffs_1[int(5)]; - _S93 = _S107; - float _S108 = 2.0f * v_5; - float2 _S109 = _S98 * make_float2 (radial_1) + make_float2 (_S103) * _S97 + make_float2 (s_diff_du_0, _S107 * v_5 + _S99 * dist_coeffs_1[int(4)] + _S99 * dist_coeffs_1[int(7)]); - float _S110 = v_5 + v_5; - float2 _S111 = make_float2 (0.0f, 1.0f) * make_float2 (radial_1) + make_float2 (_S110 * _S102 + (_S110 * _S101 + (_S110 * _S100 + _S110 * dist_coeffs_1[int(3)] * r2_5) * r2_5) * r2_5) * _S97 + make_float2 (_S105 + _S110 * dist_coeffs_1[int(5)] + _S110 * dist_coeffs_1[int(6)], _S107 * u_5 + (_S110 + (_S108 + _S108)) * dist_coeffs_1[int(4)] + _S110 * dist_coeffs_1[int(7)]); - Matrix _S112 = transpose_0(makeMatrix (_S109 + make_float2 (_S109.x * dist_coeffs_1[int(8)] + _S109.y * dist_coeffs_1[int(9)], 0.0f), _S111 + make_float2 (_S111.x * dist_coeffs_1[int(8)] + _S111.y * dist_coeffs_1[int(9)], 0.0f))); - bool _S113 = !((F32_min((determinant_0(_S112)), ((F32_min((_S112.rows[int(0)].x), (_S112.rows[int(1)].y)))))) > 0.0f); - _S94 = _S113; - if(_S113) - { - break; - } - float u_6 = (*mean2d_1).x; - float v_6 = (*mean2d_1).y; - float r2_6 = u_6 * u_6 + v_6 * v_6; - float2 _S114 = *mean2d_1 * make_float2 (1.0f + r2_6 * (dist_coeffs_1[int(0)] + r2_6 * (dist_coeffs_1[int(1)] + r2_6 * (dist_coeffs_1[int(2)] + r2_6 * dist_coeffs_1[int(3)])))) + make_float2 (_S104 * u_6 * v_6 + dist_coeffs_1[int(5)] * (r2_6 + 2.0f * u_6 * u_6) + dist_coeffs_1[int(6)] * r2_6, _S107 * u_6 * v_6 + dist_coeffs_1[int(4)] * (r2_6 + 2.0f * v_6 * v_6) + dist_coeffs_1[int(7)] * r2_6); - float2 _S115 = _S114 + make_float2 (dist_coeffs_1[int(8)] * _S114.x + dist_coeffs_1[int(9)] * _S114.y, 0.0f); - *mean2d_1 = make_float2 (intrins_1.x * _S115.x + intrins_1.z, intrins_1.y * _S115.y + intrins_1.w); - break; - } - if(!!_S94) - { - _S79 = false; - break; - } - Matrix J_2; - float2 _S116 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S117; - (&_S117)->primal_0 = _S80; - (&_S117)->differential_0 = _S116; - DiffPair_float_0 _S118 = s_fwd_length_impl_0(&_S117); - float _S119 = _S81; - DiffPair_float_0 _S120; - (&_S120)->primal_0 = _S118.primal_0; - (&_S120)->differential_0 = _S118.differential_0; - DiffPair_float_0 _S121; - (&_S121)->primal_0 = _S81; - (&_S121)->differential_0 = 0.0f; - DiffPair_float_0 _S122 = _d_atan2_1(&_S120, &_S121); - float s_diff_k_0; - if((_S122.primal_0) < 0.00100000004749745f) - { - float _S123 = _S122.differential_0 * _S122.primal_0; - float _S124 = (0.0f - (_S123 + _S123) * 0.3333333432674408f) * _S81 / (_S81 * _S81); - k_0 = (1.0f - _S122.primal_0 * _S122.primal_0 / 3.0f) / _S81; - s_diff_k_0 = _S124; - } - else - { - float _S125 = (_S122.differential_0 * _S118.primal_0 - _S122.primal_0 * _S118.differential_0) / (_S118.primal_0 * _S118.primal_0); - k_0 = _S122.primal_0 / _S118.primal_0; - s_diff_k_0 = _S125; - } - float2 _S126 = _S80 * make_float2 (k_0); - float2 _S127 = _S116 * make_float2 (k_0) + make_float2 (s_diff_k_0) * _S80; - float u_7 = _S126.x; - float s_diff_u_3 = _S127.x; - float v_7 = _S126.y; - float s_diff_v_3 = _S127.y; - float _S128 = s_diff_u_3 * u_7; - float _S129 = s_diff_v_3 * v_7; - float r2_7 = u_7 * u_7 + v_7 * v_7; - float s_diff_r2_3 = _S128 + _S128 + (_S129 + _S129); - float _S130 = _S84 + r2_7 * _S85; - float _S131 = _S83 + r2_7 * _S130; - float _S132 = _S82 + r2_7 * _S131; - float2 _S133 = _S127 * make_float2 (1.0f + r2_7 * _S132) + make_float2 (s_diff_r2_3 * _S132 + (s_diff_r2_3 * _S131 + (s_diff_r2_3 * _S130 + s_diff_r2_3 * _S85 * r2_7) * r2_7) * r2_7) * _S126 + make_float2 (s_diff_u_3 * _S92 * v_7 + s_diff_v_3 * (_S92 * u_7) + (s_diff_r2_3 + (s_diff_u_3 * 2.0f * u_7 + s_diff_u_3 * (2.0f * u_7))) * _S87 + s_diff_r2_3 * _S88, s_diff_u_3 * _S93 * v_7 + s_diff_v_3 * (_S93 * u_7) + (s_diff_r2_3 + (s_diff_v_3 * 2.0f * v_7 + s_diff_v_3 * (2.0f * v_7))) * _S86 + s_diff_r2_3 * _S89); - float2 _S134 = _S133 + make_float2 (_S133.x * _S90 + _S133.y * _S91, 0.0f); - float fx_1 = intrins_1.x; - float fy_1 = intrins_1.y; - float _S135 = _S134.y * fy_1; - *&(((&J_2)->rows + (int(0)))->x) = _S134.x * fx_1; - *&(((&J_2)->rows + (int(1)))->x) = _S135; - float2 _S136 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S137; - (&_S137)->primal_0 = _S80; - (&_S137)->differential_0 = _S136; - DiffPair_float_0 _S138 = s_fwd_length_impl_0(&_S137); - DiffPair_float_0 _S139; - (&_S139)->primal_0 = _S138.primal_0; - (&_S139)->differential_0 = _S138.differential_0; - DiffPair_float_0 _S140; - (&_S140)->primal_0 = _S119; - (&_S140)->differential_0 = 0.0f; - DiffPair_float_0 _S141 = _d_atan2_1(&_S139, &_S140); - if((_S141.primal_0) < 0.00100000004749745f) - { - float _S142 = _S141.differential_0 * _S141.primal_0; - float _S143 = (0.0f - (_S142 + _S142) * 0.3333333432674408f) * _S81 / (_S81 * _S81); - k_0 = (1.0f - _S141.primal_0 * _S141.primal_0 / 3.0f) / _S81; - s_diff_k_0 = _S143; - } - else - { - float _S144 = (_S141.differential_0 * _S138.primal_0 - _S141.primal_0 * _S138.differential_0) / (_S138.primal_0 * _S138.primal_0); - k_0 = _S141.primal_0 / _S138.primal_0; - s_diff_k_0 = _S144; - } - float2 _S145 = _S80 * make_float2 (k_0); - float2 _S146 = _S136 * make_float2 (k_0) + make_float2 (s_diff_k_0) * _S80; - float u_8 = _S145.x; - float s_diff_u_4 = _S146.x; - float v_8 = _S145.y; - float s_diff_v_4 = _S146.y; - float _S147 = s_diff_u_4 * u_8; - float _S148 = s_diff_v_4 * v_8; - float r2_8 = u_8 * u_8 + v_8 * v_8; - float s_diff_r2_4 = _S147 + _S147 + (_S148 + _S148); - float _S149 = _S84 + r2_8 * _S85; - float _S150 = _S83 + r2_8 * _S149; - float _S151 = _S82 + r2_8 * _S150; - float2 _S152 = _S146 * make_float2 (1.0f + r2_8 * _S151) + make_float2 (s_diff_r2_4 * _S151 + (s_diff_r2_4 * _S150 + (s_diff_r2_4 * _S149 + s_diff_r2_4 * _S85 * r2_8) * r2_8) * r2_8) * _S145 + make_float2 (s_diff_u_4 * _S92 * v_8 + s_diff_v_4 * (_S92 * u_8) + (s_diff_r2_4 + (s_diff_u_4 * 2.0f * u_8 + s_diff_u_4 * (2.0f * u_8))) * _S87 + s_diff_r2_4 * _S88, s_diff_u_4 * _S93 * v_8 + s_diff_v_4 * (_S93 * u_8) + (s_diff_r2_4 + (s_diff_v_4 * 2.0f * v_8 + s_diff_v_4 * (2.0f * v_8))) * _S86 + s_diff_r2_4 * _S89); - float2 _S153 = _S152 + make_float2 (_S152.x * _S90 + _S152.y * _S91, 0.0f); - float _S154 = _S153.y * fy_1; - *&(((&J_2)->rows + (int(0)))->y) = _S153.x * fx_1; - *&(((&J_2)->rows + (int(1)))->y) = _S154; - float2 _S155 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S156; - (&_S156)->primal_0 = _S80; - (&_S156)->differential_0 = _S155; - DiffPair_float_0 _S157 = s_fwd_length_impl_0(&_S156); - DiffPair_float_0 _S158; - (&_S158)->primal_0 = _S157.primal_0; - (&_S158)->differential_0 = _S157.differential_0; - DiffPair_float_0 _S159; - (&_S159)->primal_0 = _S81; - (&_S159)->differential_0 = 1.0f; - DiffPair_float_0 _S160 = _d_atan2_1(&_S158, &_S159); - if((_S160.primal_0) < 0.00100000004749745f) - { - float _S161 = _S160.differential_0 * _S160.primal_0; - float _S162 = 1.0f - _S160.primal_0 * _S160.primal_0 / 3.0f; - float _S163 = ((0.0f - (_S161 + _S161) * 0.3333333432674408f) * _S81 - _S162) / (_S81 * _S81); - k_0 = _S162 / _S81; - s_diff_k_0 = _S163; - } - else - { - float _S164 = (_S160.differential_0 * _S157.primal_0 - _S160.primal_0 * _S157.differential_0) / (_S157.primal_0 * _S157.primal_0); - k_0 = _S160.primal_0 / _S157.primal_0; - s_diff_k_0 = _S164; - } - float2 _S165 = _S80 * make_float2 (k_0); - float2 _S166 = make_float2 (s_diff_k_0) * _S80; - float u_9 = _S165.x; - float s_diff_u_5 = _S166.x; - float v_9 = _S165.y; - float s_diff_v_5 = _S166.y; - float _S167 = s_diff_u_5 * u_9; - float _S168 = s_diff_v_5 * v_9; - float r2_9 = u_9 * u_9 + v_9 * v_9; - float s_diff_r2_5 = _S167 + _S167 + (_S168 + _S168); - float _S169 = _S84 + r2_9 * _S85; - float _S170 = _S83 + r2_9 * _S169; - float _S171 = _S82 + r2_9 * _S170; - float2 _S172 = _S166 * make_float2 (1.0f + r2_9 * _S171) + make_float2 (s_diff_r2_5 * _S171 + (s_diff_r2_5 * _S170 + (s_diff_r2_5 * _S169 + s_diff_r2_5 * _S85 * r2_9) * r2_9) * r2_9) * _S165 + make_float2 (s_diff_u_5 * _S92 * v_9 + s_diff_v_5 * (_S92 * u_9) + (s_diff_r2_5 + (s_diff_u_5 * 2.0f * u_9 + s_diff_u_5 * (2.0f * u_9))) * _S87 + s_diff_r2_5 * _S88, s_diff_u_5 * _S93 * v_9 + s_diff_v_5 * (_S93 * u_9) + (s_diff_r2_5 + (s_diff_v_5 * 2.0f * v_9 + s_diff_v_5 * (2.0f * v_9))) * _S86 + s_diff_r2_5 * _S89); - float2 _S173 = _S172 + make_float2 (_S172.x * _S90 + _S172.y * _S91, 0.0f); - float _S174 = _S173.y * fy_1; - *&(((&J_2)->rows + (int(0)))->z) = _S173.x * fx_1; - *&(((&J_2)->rows + (int(1)))->z) = _S174; - *cov2d_1 = mul_4(mul_3(J_2, cov3d_1), transpose_1(J_2)); - _S79 = true; - break; + k_0 = (1.0f - theta_0 * theta_0 / 3.0f) / _S50; } - return _S79; + else + { + k_0 = theta_0 / r_7; + } + float2 _S51 = _S49 * make_float2 (k_0); + FixedArray _S52 = dist_coeffs_1; + float2 _S53 = DistNone_distort_0(_S51, &_S52); + float fx_1 = intrins_1.x; + float fy_1 = intrins_1.y; + *mean2d_1 = make_float2 (fx_1 * _S53.x + intrins_1.z, fy_1 * _S53.y + intrins_1.w); + Matrix J_2; + float2 _S54 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S55; + (&_S55)->primal_0 = _S49; + (&_S55)->differential_0 = _S54; + DiffPair_float_0 _S56 = s_fwd_length_impl_0(&_S55); + DiffPair_float_0 _S57; + (&_S57)->primal_0 = _S56.primal_0; + (&_S57)->differential_0 = _S56.differential_0; + DiffPair_float_0 _S58; + (&_S58)->primal_0 = _S50; + (&_S58)->differential_0 = 0.0f; + DiffPair_float_0 _S59 = _d_atan2_1(&_S57, &_S58); + float s_diff_k_0; + if((_S59.primal_0) < 0.00100000004749745f) + { + float _S60 = _S59.differential_0 * _S59.primal_0; + float _S61 = (0.0f - (_S60 + _S60) * 0.3333333432674408f) * _S50 / (_S50 * _S50); + k_0 = (1.0f - _S59.primal_0 * _S59.primal_0 / 3.0f) / _S50; + s_diff_k_0 = _S61; + } + else + { + float _S62 = (_S59.differential_0 * _S56.primal_0 - _S59.primal_0 * _S56.differential_0) / (_S56.primal_0 * _S56.primal_0); + k_0 = _S59.primal_0 / _S56.primal_0; + s_diff_k_0 = _S62; + } + float2 _S63 = _S49 * make_float2 (k_0); + float2 _S64 = _S54 * make_float2 (k_0) + make_float2 (s_diff_k_0) * _S49; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S65; + (&_S65)->primal_0 = _S63; + (&_S65)->differential_0 = _S64; + FixedArray _S66 = dist_coeffs_1; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S67 = s_fwd_DistNone_distort_0(&_S65, &_S66); + float _S68 = _S67.differential_0.y * fy_1; + *&(((&J_2)->rows + (int(0)))->x) = _S67.differential_0.x * fx_1; + *&(((&J_2)->rows + (int(1)))->x) = _S68; + float2 _S69 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S70; + (&_S70)->primal_0 = _S49; + (&_S70)->differential_0 = _S69; + DiffPair_float_0 _S71 = s_fwd_length_impl_0(&_S70); + DiffPair_float_0 _S72; + (&_S72)->primal_0 = _S71.primal_0; + (&_S72)->differential_0 = _S71.differential_0; + DiffPair_float_0 _S73; + (&_S73)->primal_0 = _S50; + (&_S73)->differential_0 = 0.0f; + DiffPair_float_0 _S74 = _d_atan2_1(&_S72, &_S73); + if((_S74.primal_0) < 0.00100000004749745f) + { + float _S75 = _S74.differential_0 * _S74.primal_0; + float _S76 = (0.0f - (_S75 + _S75) * 0.3333333432674408f) * _S50 / (_S50 * _S50); + k_0 = (1.0f - _S74.primal_0 * _S74.primal_0 / 3.0f) / _S50; + s_diff_k_0 = _S76; + } + else + { + float _S77 = (_S74.differential_0 * _S71.primal_0 - _S74.primal_0 * _S71.differential_0) / (_S71.primal_0 * _S71.primal_0); + k_0 = _S74.primal_0 / _S71.primal_0; + s_diff_k_0 = _S77; + } + float2 _S78 = _S49 * make_float2 (k_0); + float2 _S79 = _S69 * make_float2 (k_0) + make_float2 (s_diff_k_0) * _S49; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S80; + (&_S80)->primal_0 = _S78; + (&_S80)->differential_0 = _S79; + FixedArray _S81 = dist_coeffs_1; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S82 = s_fwd_DistNone_distort_0(&_S80, &_S81); + float _S83 = _S82.differential_0.y * fy_1; + *&(((&J_2)->rows + (int(0)))->y) = _S82.differential_0.x * fx_1; + *&(((&J_2)->rows + (int(1)))->y) = _S83; + float2 _S84 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S85; + (&_S85)->primal_0 = _S49; + (&_S85)->differential_0 = _S84; + DiffPair_float_0 _S86 = s_fwd_length_impl_0(&_S85); + DiffPair_float_0 _S87; + (&_S87)->primal_0 = _S86.primal_0; + (&_S87)->differential_0 = _S86.differential_0; + DiffPair_float_0 _S88; + (&_S88)->primal_0 = _S50; + (&_S88)->differential_0 = 1.0f; + DiffPair_float_0 _S89 = _d_atan2_1(&_S87, &_S88); + if((_S89.primal_0) < 0.00100000004749745f) + { + float _S90 = _S89.differential_0 * _S89.primal_0; + float _S91 = 1.0f - _S89.primal_0 * _S89.primal_0 / 3.0f; + float _S92 = ((0.0f - (_S90 + _S90) * 0.3333333432674408f) * _S50 - _S91) / (_S50 * _S50); + k_0 = _S91 / _S50; + s_diff_k_0 = _S92; + } + else + { + float _S93 = (_S89.differential_0 * _S86.primal_0 - _S89.primal_0 * _S86.differential_0) / (_S86.primal_0 * _S86.primal_0); + k_0 = _S89.primal_0 / _S86.primal_0; + s_diff_k_0 = _S93; + } + float2 _S94 = _S49 * make_float2 (k_0); + float2 _S95 = make_float2 (s_diff_k_0) * _S49; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S96; + (&_S96)->primal_0 = _S94; + (&_S96)->differential_0 = _S95; + FixedArray _S97 = dist_coeffs_1; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S98 = s_fwd_DistNone_distort_0(&_S96, &_S97); + float _S99 = _S98.differential_0.y * fy_1; + *&(((&J_2)->rows + (int(0)))->z) = _S98.differential_0.x * fx_1; + *&(((&J_2)->rows + (int(1)))->z) = _S99; + *cov2d_1 = mul_4(mul_3(J_2, cov3d_1), transpose_1(J_2)); + return true; } inline __device__ void _d_cos_0(DiffPair_float_0 * dpx_9, float dOut_9) { - float _S175 = - (F32_sin(((*dpx_9).primal_0))) * dOut_9; + float _S100 = - (F32_sin(((*dpx_9).primal_0))) * dOut_9; dpx_9->primal_0 = (*dpx_9).primal_0; - dpx_9->differential_0 = _S175; + dpx_9->differential_0 = _S100; return; } inline __device__ void _d_sin_0(DiffPair_float_0 * dpx_10, float dOut_10) { - float _S176 = (F32_cos(((*dpx_10).primal_0))) * dOut_10; + float _S101 = (F32_cos(((*dpx_10).primal_0))) * dOut_10; dpx_10->primal_0 = (*dpx_10).primal_0; - dpx_10->differential_0 = _S176; + dpx_10->differential_0 = _S101; return; } inline __device__ DiffPair_float_0 _d_sin_1(DiffPair_float_0 * dpx_11) { - DiffPair_float_0 _S177 = { (F32_sin((dpx_11->primal_0))), (F32_cos((dpx_11->primal_0))) * dpx_11->differential_0 }; - return _S177; + DiffPair_float_0 _S102 = { (F32_sin((dpx_11->primal_0))), (F32_cos((dpx_11->primal_0))) * dpx_11->differential_0 }; + return _S102; } -inline __device__ bool equisolid_proj_3dgs_nav(float3 mean3d_2, Matrix cov3d_2, float4 intrins_2, FixedArray dist_coeffs_2, Matrix * cov2d_2, float2 * mean2d_2) +inline __device__ bool equisolid_proj_3dgs_nav_none(float3 mean3d_2, Matrix cov3d_2, float4 intrins_2, FixedArray dist_coeffs_2, Matrix * cov2d_2, float2 * mean2d_2) { - bool _S178; - float2 _S179; - float _S180; - float _S181; - float _S182; - float _S183; - float _S184; - float _S185; - float _S186; - float _S187; - float _S188; - float _S189; - float _S190; - float _S191; - float _S192; - bool _S193; + *cov2d_2 = makeMatrix (0.0f); + float2 _S103 = float2 {mean3d_2.x, mean3d_2.y}; + float r_8 = length_0(_S103); + float _S104 = mean3d_2.z; + float theta_1 = (F32_atan2((r_8), (_S104))); + float k_1; + if(r_8 < 9.99999997475242708e-07f) + { + k_1 = (1.0f - theta_1 * theta_1 / 24.0f) / _S104; + } + else + { + k_1 = 2.0f * (F32_sin((0.5f * theta_1))) / r_8; + } + float2 _S105 = _S103 * make_float2 (k_1); + FixedArray _S106 = dist_coeffs_2; + float2 _S107 = DistNone_distort_0(_S105, &_S106); + float fx_2 = intrins_2.x; + float fy_2 = intrins_2.y; + *mean2d_2 = make_float2 (fx_2 * _S107.x + intrins_2.z, fy_2 * _S107.y + intrins_2.w); + Matrix J_3; + float2 _S108 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S109; + (&_S109)->primal_0 = _S103; + (&_S109)->differential_0 = _S108; + DiffPair_float_0 _S110 = s_fwd_length_impl_0(&_S109); + DiffPair_float_0 _S111; + (&_S111)->primal_0 = _S110.primal_0; + (&_S111)->differential_0 = _S110.differential_0; + DiffPair_float_0 _S112; + (&_S112)->primal_0 = _S104; + (&_S112)->differential_0 = 0.0f; + DiffPair_float_0 _S113 = _d_atan2_1(&_S111, &_S112); + float s_diff_k_1; + if((_S110.primal_0) < 9.99999997475242708e-07f) + { + float _S114 = _S113.differential_0 * _S113.primal_0; + float _S115 = (0.0f - (_S114 + _S114) * 0.0416666679084301f) * _S104 / (_S104 * _S104); + k_1 = (1.0f - _S113.primal_0 * _S113.primal_0 / 24.0f) / _S104; + s_diff_k_1 = _S115; + } + else + { + float _S116 = _S113.differential_0 * 0.5f; + DiffPair_float_0 _S117; + (&_S117)->primal_0 = 0.5f * _S113.primal_0; + (&_S117)->differential_0 = _S116; + DiffPair_float_0 _S118 = _d_sin_1(&_S117); + float _S119 = 2.0f * _S118.primal_0; + float _S120 = (_S118.differential_0 * 2.0f * _S110.primal_0 - _S119 * _S110.differential_0) / (_S110.primal_0 * _S110.primal_0); + k_1 = _S119 / _S110.primal_0; + s_diff_k_1 = _S120; + } + float2 _S121 = _S103 * make_float2 (k_1); + float2 _S122 = _S108 * make_float2 (k_1) + make_float2 (s_diff_k_1) * _S103; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S123; + (&_S123)->primal_0 = _S121; + (&_S123)->differential_0 = _S122; + FixedArray _S124 = dist_coeffs_2; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S125 = s_fwd_DistNone_distort_0(&_S123, &_S124); + float _S126 = _S125.differential_0.y * fy_2; + *&(((&J_3)->rows + (int(0)))->x) = _S125.differential_0.x * fx_2; + *&(((&J_3)->rows + (int(1)))->x) = _S126; + float2 _S127 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S128; + (&_S128)->primal_0 = _S103; + (&_S128)->differential_0 = _S127; + DiffPair_float_0 _S129 = s_fwd_length_impl_0(&_S128); + DiffPair_float_0 _S130; + (&_S130)->primal_0 = _S129.primal_0; + (&_S130)->differential_0 = _S129.differential_0; + DiffPair_float_0 _S131; + (&_S131)->primal_0 = _S104; + (&_S131)->differential_0 = 0.0f; + DiffPair_float_0 _S132 = _d_atan2_1(&_S130, &_S131); + if((_S129.primal_0) < 9.99999997475242708e-07f) + { + float _S133 = _S132.differential_0 * _S132.primal_0; + float _S134 = (0.0f - (_S133 + _S133) * 0.0416666679084301f) * _S104 / (_S104 * _S104); + k_1 = (1.0f - _S132.primal_0 * _S132.primal_0 / 24.0f) / _S104; + s_diff_k_1 = _S134; + } + else + { + float _S135 = _S132.differential_0 * 0.5f; + DiffPair_float_0 _S136; + (&_S136)->primal_0 = 0.5f * _S132.primal_0; + (&_S136)->differential_0 = _S135; + DiffPair_float_0 _S137 = _d_sin_1(&_S136); + float _S138 = 2.0f * _S137.primal_0; + float _S139 = (_S137.differential_0 * 2.0f * _S129.primal_0 - _S138 * _S129.differential_0) / (_S129.primal_0 * _S129.primal_0); + k_1 = _S138 / _S129.primal_0; + s_diff_k_1 = _S139; + } + float2 _S140 = _S103 * make_float2 (k_1); + float2 _S141 = _S127 * make_float2 (k_1) + make_float2 (s_diff_k_1) * _S103; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S142; + (&_S142)->primal_0 = _S140; + (&_S142)->differential_0 = _S141; + FixedArray _S143 = dist_coeffs_2; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S144 = s_fwd_DistNone_distort_0(&_S142, &_S143); + float _S145 = _S144.differential_0.y * fy_2; + *&(((&J_3)->rows + (int(0)))->y) = _S144.differential_0.x * fx_2; + *&(((&J_3)->rows + (int(1)))->y) = _S145; + float2 _S146 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S147; + (&_S147)->primal_0 = _S103; + (&_S147)->differential_0 = _S146; + DiffPair_float_0 _S148 = s_fwd_length_impl_0(&_S147); + DiffPair_float_0 _S149; + (&_S149)->primal_0 = _S148.primal_0; + (&_S149)->differential_0 = _S148.differential_0; + DiffPair_float_0 _S150; + (&_S150)->primal_0 = _S104; + (&_S150)->differential_0 = 1.0f; + DiffPair_float_0 _S151 = _d_atan2_1(&_S149, &_S150); + if((_S148.primal_0) < 9.99999997475242708e-07f) + { + float _S152 = _S151.differential_0 * _S151.primal_0; + float _S153 = 1.0f - _S151.primal_0 * _S151.primal_0 / 24.0f; + float _S154 = ((0.0f - (_S152 + _S152) * 0.0416666679084301f) * _S104 - _S153) / (_S104 * _S104); + k_1 = _S153 / _S104; + s_diff_k_1 = _S154; + } + else + { + float _S155 = _S151.differential_0 * 0.5f; + DiffPair_float_0 _S156; + (&_S156)->primal_0 = 0.5f * _S151.primal_0; + (&_S156)->differential_0 = _S155; + DiffPair_float_0 _S157 = _d_sin_1(&_S156); + float _S158 = 2.0f * _S157.primal_0; + float _S159 = (_S157.differential_0 * 2.0f * _S148.primal_0 - _S158 * _S148.differential_0) / (_S148.primal_0 * _S148.primal_0); + k_1 = _S158 / _S148.primal_0; + s_diff_k_1 = _S159; + } + float2 _S160 = _S103 * make_float2 (k_1); + float2 _S161 = make_float2 (s_diff_k_1) * _S103; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S162; + (&_S162)->primal_0 = _S160; + (&_S162)->differential_0 = _S161; + FixedArray _S163 = dist_coeffs_2; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S164 = s_fwd_DistNone_distort_0(&_S162, &_S163); + float _S165 = _S164.differential_0.y * fy_2; + *&(((&J_3)->rows + (int(0)))->z) = _S164.differential_0.x * fx_2; + *&(((&J_3)->rows + (int(1)))->z) = _S165; + *cov2d_2 = mul_4(mul_3(J_3, cov3d_2), transpose_1(J_3)); + return true; +} + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistOpenCV_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_1, FixedArray * coeffs_2) +{ + float u_0 = dpuv_1->primal_0.x; + float s_diff_u_0 = dpuv_1->differential_0.x; + float v_0 = dpuv_1->primal_0.y; + float s_diff_v_0 = dpuv_1->differential_0.y; + float _S166 = s_diff_u_0 * u_0; + float _S167 = s_diff_v_0 * v_0; + float r2_0 = u_0 * u_0 + v_0 * v_0; + float s_diff_r2_0 = _S166 + _S166 + (_S167 + _S167); + float _S168 = (*coeffs_2)[int(0)] + r2_0 * (*coeffs_2)[int(1)]; + float radial_0 = 1.0f + r2_0 * _S168; + float _S169 = 2.0f * (*coeffs_2)[int(2)]; + float _S170 = _S169 * u_0; + float _S171 = 2.0f * u_0; + float _S172 = 2.0f * (*coeffs_2)[int(3)]; + float _S173 = _S172 * u_0; + float _S174 = 2.0f * v_0; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S175 = { dpuv_1->primal_0 * make_float2 (radial_0) + make_float2 (_S170 * v_0 + (*coeffs_2)[int(3)] * (r2_0 + _S171 * u_0), _S173 * v_0 + (*coeffs_2)[int(2)] * (r2_0 + _S174 * v_0)), dpuv_1->differential_0 * make_float2 (radial_0) + make_float2 (s_diff_r2_0 * _S168 + s_diff_r2_0 * (*coeffs_2)[int(1)] * r2_0) * dpuv_1->primal_0 + make_float2 (s_diff_u_0 * _S169 * v_0 + s_diff_v_0 * _S170 + (s_diff_r2_0 + (s_diff_u_0 * 2.0f * u_0 + s_diff_u_0 * _S171)) * (*coeffs_2)[int(3)], s_diff_u_0 * _S172 * v_0 + s_diff_v_0 * _S173 + (s_diff_r2_0 + (s_diff_v_0 * 2.0f * v_0 + s_diff_v_0 * _S174)) * (*coeffs_2)[int(2)]) }; + return _S175; +} + +inline __device__ float2 DistOpenCV_distort_0(float2 uv_2, FixedArray * coeffs_3) +{ + float u_1 = uv_2.x; + float v_1 = uv_2.y; + float r2_1 = u_1 * u_1 + v_1 * v_1; + return uv_2 * make_float2 (1.0f + r2_1 * ((*coeffs_3)[int(0)] + r2_1 * (*coeffs_3)[int(1)])) + make_float2 (2.0f * (*coeffs_3)[int(2)] * u_1 * v_1 + (*coeffs_3)[int(3)] * (r2_1 + 2.0f * u_1 * u_1), 2.0f * (*coeffs_3)[int(3)] * u_1 * v_1 + (*coeffs_3)[int(2)] * (r2_1 + 2.0f * v_1 * v_1)); +} + +inline __device__ bool persp_proj_3dgs_nav_opencv(float3 mean3d_3, Matrix cov3d_3, float4 intrins_3, FixedArray dist_coeffs_3, uint width_1, uint height_1, Matrix * cov2d_3, float2 * mean2d_3) +{ + bool _S176; + float2 _S177; + float _S178; for(;;) { - float k_1; + float cx_1 = intrins_3.z; + float cy_1 = intrins_3.w; + *cov2d_3 = makeMatrix (0.0f); for(;;) { - float2 _S194 = float2 {mean3d_2.x, mean3d_2.y}; - _S179 = _S194; - float r_8 = length_0(_S194); - float _S195 = mean3d_2.z; - _S180 = _S195; - float theta_1 = (F32_atan2((r_8), (_S195))); - if(r_8 < 9.99999997475242708e-07f) + float2 _S179 = float2 {mean3d_3.x, mean3d_3.y}; + _S177 = _S179; + float _S180 = mean3d_3.z; + _S178 = _S180; + float2 uv0_1 = _S179 / make_float2 (_S180); + if(_S180 < 0.0f) { - k_1 = (1.0f - theta_1 * theta_1 / 24.0f) / _S195; + _S176 = true; } else { - k_1 = 2.0f * (F32_sin((0.5f * theta_1))) / r_8; + float2 _S181 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S182; + (&_S182)->primal_0 = uv0_1; + (&_S182)->differential_0 = _S181; + FixedArray _S183 = dist_coeffs_3; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S184 = s_fwd_DistOpenCV_distort_0(&_S182, &_S183); + float2 _S185 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S186; + (&_S186)->primal_0 = uv0_1; + (&_S186)->differential_0 = _S185; + FixedArray _S187 = dist_coeffs_3; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S188 = s_fwd_DistOpenCV_distort_0(&_S186, &_S187); + Matrix _S189 = transpose_0(makeMatrix (_S184.differential_0, _S188.differential_0)); + float _S190 = (F32_min((determinant_0(_S189)), ((F32_min((_S189.rows[int(0)].x), (_S189.rows[int(1)].y)))))); + if(_S190 > 0.25f) + { + _S176 = _S190 < 4.0f; + } + else + { + _S176 = false; + } + if(_S176) + { + FixedArray _S191 = dist_coeffs_3; + float2 _S192 = DistOpenCV_distort_0(uv0_1, &_S191); + _S176 = (dot_0(uv0_1, _S192)) >= 0.0f; + } + else + { + _S176 = false; + } + _S176 = !_S176; } - float2 _S196 = _S194 * make_float2 (k_1); - *mean2d_2 = _S196; - float2 _S197 = make_float2 (1.0f, 0.0f); - _S181 = dist_coeffs_2[int(0)]; - _S182 = dist_coeffs_2[int(1)]; - _S183 = dist_coeffs_2[int(2)]; - _S184 = dist_coeffs_2[int(3)]; - _S185 = dist_coeffs_2[int(4)]; - _S186 = dist_coeffs_2[int(5)]; - _S187 = dist_coeffs_2[int(6)]; - _S188 = dist_coeffs_2[int(7)]; - _S189 = dist_coeffs_2[int(8)]; - _S190 = dist_coeffs_2[int(9)]; - float u_10 = _S196.x; - float v_10 = _S196.y; - float _S198 = u_10 + u_10; - float r2_10 = u_10 * u_10 + v_10 * v_10; - float _S199 = dist_coeffs_2[int(2)] + r2_10 * dist_coeffs_2[int(3)]; - float _S200 = dist_coeffs_2[int(1)] + r2_10 * _S199; - float _S201 = dist_coeffs_2[int(0)] + r2_10 * _S200; - float _S202 = _S198 * _S201 + (_S198 * _S200 + (_S198 * _S199 + _S198 * dist_coeffs_2[int(3)] * r2_10) * r2_10) * r2_10; - float radial_2 = 1.0f + r2_10 * _S201; - float _S203 = 2.0f * dist_coeffs_2[int(4)]; - _S191 = _S203; - float _S204 = _S203 * u_10; - float _S205 = 2.0f * u_10; - float s_diff_du_1 = _S203 * v_10 + (_S198 + (_S205 + _S205)) * dist_coeffs_2[int(5)] + _S198 * dist_coeffs_2[int(6)]; - float _S206 = 2.0f * dist_coeffs_2[int(5)]; - _S192 = _S206; - float _S207 = 2.0f * v_10; - float2 _S208 = _S197 * make_float2 (radial_2) + make_float2 (_S202) * _S196 + make_float2 (s_diff_du_1, _S206 * v_10 + _S198 * dist_coeffs_2[int(4)] + _S198 * dist_coeffs_2[int(7)]); - float _S209 = v_10 + v_10; - float2 _S210 = make_float2 (0.0f, 1.0f) * make_float2 (radial_2) + make_float2 (_S209 * _S201 + (_S209 * _S200 + (_S209 * _S199 + _S209 * dist_coeffs_2[int(3)] * r2_10) * r2_10) * r2_10) * _S196 + make_float2 (_S204 + _S209 * dist_coeffs_2[int(5)] + _S209 * dist_coeffs_2[int(6)], _S206 * u_10 + (_S209 + (_S207 + _S207)) * dist_coeffs_2[int(4)] + _S209 * dist_coeffs_2[int(7)]); - Matrix _S211 = transpose_0(makeMatrix (_S208 + make_float2 (_S208.x * dist_coeffs_2[int(8)] + _S208.y * dist_coeffs_2[int(9)], 0.0f), _S210 + make_float2 (_S210.x * dist_coeffs_2[int(8)] + _S210.y * dist_coeffs_2[int(9)], 0.0f))); - bool _S212 = !((F32_min((determinant_0(_S211)), ((F32_min((_S211.rows[int(0)].x), (_S211.rows[int(1)].y)))))) > 0.0f); - _S193 = _S212; - if(_S212) + if(_S176) { + *mean2d_3 = uv0_1; + _S176 = false; break; } - float u_11 = (*mean2d_2).x; - float v_11 = (*mean2d_2).y; - float r2_11 = u_11 * u_11 + v_11 * v_11; - float2 _S213 = *mean2d_2 * make_float2 (1.0f + r2_11 * (dist_coeffs_2[int(0)] + r2_11 * (dist_coeffs_2[int(1)] + r2_11 * (dist_coeffs_2[int(2)] + r2_11 * dist_coeffs_2[int(3)])))) + make_float2 (_S203 * u_11 * v_11 + dist_coeffs_2[int(5)] * (r2_11 + 2.0f * u_11 * u_11) + dist_coeffs_2[int(6)] * r2_11, _S206 * u_11 * v_11 + dist_coeffs_2[int(4)] * (r2_11 + 2.0f * v_11 * v_11) + dist_coeffs_2[int(7)] * r2_11); - float2 _S214 = _S213 + make_float2 (dist_coeffs_2[int(8)] * _S213.x + dist_coeffs_2[int(9)] * _S213.y, 0.0f); - *mean2d_2 = make_float2 (intrins_2.x * _S214.x + intrins_2.z, intrins_2.y * _S214.y + intrins_2.w); + float2 uv_3 = _S179 / make_float2 (_S180); + FixedArray _S193 = dist_coeffs_3; + float2 _S194 = DistOpenCV_distort_0(uv_3, &_S193); + *mean2d_3 = make_float2 (intrins_3.x * _S194.x + cx_1, intrins_3.y * _S194.y + cy_1); + _S176 = true; break; } - if(!!_S193) + if(!_S176) { - _S178 = false; + _S176 = false; break; } - Matrix J_3; - float2 _S215 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S216; - (&_S216)->primal_0 = _S179; - (&_S216)->differential_0 = _S215; - DiffPair_float_0 _S217 = s_fwd_length_impl_0(&_S216); - float _S218 = _S180; - DiffPair_float_0 _S219; - (&_S219)->primal_0 = _S217.primal_0; - (&_S219)->differential_0 = _S217.differential_0; - DiffPair_float_0 _S220; - (&_S220)->primal_0 = _S180; - (&_S220)->differential_0 = 0.0f; - DiffPair_float_0 _S221 = _d_atan2_1(&_S219, &_S220); - float s_diff_k_1; - if((_S217.primal_0) < 9.99999997475242708e-07f) - { - float _S222 = _S221.differential_0 * _S221.primal_0; - float _S223 = (0.0f - (_S222 + _S222) * 0.0416666679084301f) * _S180 / (_S180 * _S180); - k_1 = (1.0f - _S221.primal_0 * _S221.primal_0 / 24.0f) / _S180; - s_diff_k_1 = _S223; - } - else - { - float _S224 = _S221.differential_0 * 0.5f; - DiffPair_float_0 _S225; - (&_S225)->primal_0 = 0.5f * _S221.primal_0; - (&_S225)->differential_0 = _S224; - DiffPair_float_0 _S226 = _d_sin_1(&_S225); - float _S227 = 2.0f * _S226.primal_0; - float _S228 = (_S226.differential_0 * 2.0f * _S217.primal_0 - _S227 * _S217.differential_0) / (_S217.primal_0 * _S217.primal_0); - k_1 = _S227 / _S217.primal_0; - s_diff_k_1 = _S228; - } - float2 _S229 = _S179 * make_float2 (k_1); - float2 _S230 = _S215 * make_float2 (k_1) + make_float2 (s_diff_k_1) * _S179; - float u_12 = _S229.x; - float s_diff_u_6 = _S230.x; - float v_12 = _S229.y; - float s_diff_v_6 = _S230.y; - float _S231 = s_diff_u_6 * u_12; - float _S232 = s_diff_v_6 * v_12; - float r2_12 = u_12 * u_12 + v_12 * v_12; - float s_diff_r2_6 = _S231 + _S231 + (_S232 + _S232); - float _S233 = _S183 + r2_12 * _S184; - float _S234 = _S182 + r2_12 * _S233; - float _S235 = _S181 + r2_12 * _S234; - float2 _S236 = _S230 * make_float2 (1.0f + r2_12 * _S235) + make_float2 (s_diff_r2_6 * _S235 + (s_diff_r2_6 * _S234 + (s_diff_r2_6 * _S233 + s_diff_r2_6 * _S184 * r2_12) * r2_12) * r2_12) * _S229 + make_float2 (s_diff_u_6 * _S191 * v_12 + s_diff_v_6 * (_S191 * u_12) + (s_diff_r2_6 + (s_diff_u_6 * 2.0f * u_12 + s_diff_u_6 * (2.0f * u_12))) * _S186 + s_diff_r2_6 * _S187, s_diff_u_6 * _S192 * v_12 + s_diff_v_6 * (_S192 * u_12) + (s_diff_r2_6 + (s_diff_v_6 * 2.0f * v_12 + s_diff_v_6 * (2.0f * v_12))) * _S185 + s_diff_r2_6 * _S188); - float2 _S237 = _S236 + make_float2 (_S236.x * _S189 + _S236.y * _S190, 0.0f); - float fx_2 = intrins_2.x; - float fy_2 = intrins_2.y; - float _S238 = _S237.y * fy_2; - *&(((&J_3)->rows + (int(0)))->x) = _S237.x * fx_2; - *&(((&J_3)->rows + (int(1)))->x) = _S238; - float2 _S239 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S240; - (&_S240)->primal_0 = _S179; - (&_S240)->differential_0 = _S239; - DiffPair_float_0 _S241 = s_fwd_length_impl_0(&_S240); - DiffPair_float_0 _S242; - (&_S242)->primal_0 = _S241.primal_0; - (&_S242)->differential_0 = _S241.differential_0; - DiffPair_float_0 _S243; - (&_S243)->primal_0 = _S218; - (&_S243)->differential_0 = 0.0f; - DiffPair_float_0 _S244 = _d_atan2_1(&_S242, &_S243); - if((_S241.primal_0) < 9.99999997475242708e-07f) - { - float _S245 = _S244.differential_0 * _S244.primal_0; - float _S246 = (0.0f - (_S245 + _S245) * 0.0416666679084301f) * _S180 / (_S180 * _S180); - k_1 = (1.0f - _S244.primal_0 * _S244.primal_0 / 24.0f) / _S180; - s_diff_k_1 = _S246; - } - else - { - float _S247 = _S244.differential_0 * 0.5f; - DiffPair_float_0 _S248; - (&_S248)->primal_0 = 0.5f * _S244.primal_0; - (&_S248)->differential_0 = _S247; - DiffPair_float_0 _S249 = _d_sin_1(&_S248); - float _S250 = 2.0f * _S249.primal_0; - float _S251 = (_S249.differential_0 * 2.0f * _S241.primal_0 - _S250 * _S241.differential_0) / (_S241.primal_0 * _S241.primal_0); - k_1 = _S250 / _S241.primal_0; - s_diff_k_1 = _S251; - } - float2 _S252 = _S179 * make_float2 (k_1); - float2 _S253 = _S239 * make_float2 (k_1) + make_float2 (s_diff_k_1) * _S179; - float u_13 = _S252.x; - float s_diff_u_7 = _S253.x; - float v_13 = _S252.y; - float s_diff_v_7 = _S253.y; - float _S254 = s_diff_u_7 * u_13; - float _S255 = s_diff_v_7 * v_13; - float r2_13 = u_13 * u_13 + v_13 * v_13; - float s_diff_r2_7 = _S254 + _S254 + (_S255 + _S255); - float _S256 = _S183 + r2_13 * _S184; - float _S257 = _S182 + r2_13 * _S256; - float _S258 = _S181 + r2_13 * _S257; - float2 _S259 = _S253 * make_float2 (1.0f + r2_13 * _S258) + make_float2 (s_diff_r2_7 * _S258 + (s_diff_r2_7 * _S257 + (s_diff_r2_7 * _S256 + s_diff_r2_7 * _S184 * r2_13) * r2_13) * r2_13) * _S252 + make_float2 (s_diff_u_7 * _S191 * v_13 + s_diff_v_7 * (_S191 * u_13) + (s_diff_r2_7 + (s_diff_u_7 * 2.0f * u_13 + s_diff_u_7 * (2.0f * u_13))) * _S186 + s_diff_r2_7 * _S187, s_diff_u_7 * _S192 * v_13 + s_diff_v_7 * (_S192 * u_13) + (s_diff_r2_7 + (s_diff_v_7 * 2.0f * v_13 + s_diff_v_7 * (2.0f * v_13))) * _S185 + s_diff_r2_7 * _S188); - float2 _S260 = _S259 + make_float2 (_S259.x * _S189 + _S259.y * _S190, 0.0f); - float _S261 = _S260.y * fy_2; - *&(((&J_3)->rows + (int(0)))->y) = _S260.x * fx_2; - *&(((&J_3)->rows + (int(1)))->y) = _S261; - float2 _S262 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S263; - (&_S263)->primal_0 = _S179; - (&_S263)->differential_0 = _S262; - DiffPair_float_0 _S264 = s_fwd_length_impl_0(&_S263); - DiffPair_float_0 _S265; - (&_S265)->primal_0 = _S264.primal_0; - (&_S265)->differential_0 = _S264.differential_0; - DiffPair_float_0 _S266; - (&_S266)->primal_0 = _S180; - (&_S266)->differential_0 = 1.0f; - DiffPair_float_0 _S267 = _d_atan2_1(&_S265, &_S266); - if((_S264.primal_0) < 9.99999997475242708e-07f) - { - float _S268 = _S267.differential_0 * _S267.primal_0; - float _S269 = 1.0f - _S267.primal_0 * _S267.primal_0 / 24.0f; - float _S270 = ((0.0f - (_S268 + _S268) * 0.0416666679084301f) * _S180 - _S269) / (_S180 * _S180); - k_1 = _S269 / _S180; - s_diff_k_1 = _S270; - } - else - { - float _S271 = _S267.differential_0 * 0.5f; - DiffPair_float_0 _S272; - (&_S272)->primal_0 = 0.5f * _S267.primal_0; - (&_S272)->differential_0 = _S271; - DiffPair_float_0 _S273 = _d_sin_1(&_S272); - float _S274 = 2.0f * _S273.primal_0; - float _S275 = (_S273.differential_0 * 2.0f * _S264.primal_0 - _S274 * _S264.differential_0) / (_S264.primal_0 * _S264.primal_0); - k_1 = _S274 / _S264.primal_0; - s_diff_k_1 = _S275; - } - float2 _S276 = _S179 * make_float2 (k_1); - float2 _S277 = make_float2 (s_diff_k_1) * _S179; - float u_14 = _S276.x; - float s_diff_u_8 = _S277.x; - float v_14 = _S276.y; - float s_diff_v_8 = _S277.y; - float _S278 = s_diff_u_8 * u_14; - float _S279 = s_diff_v_8 * v_14; - float r2_14 = u_14 * u_14 + v_14 * v_14; - float s_diff_r2_8 = _S278 + _S278 + (_S279 + _S279); - float _S280 = _S183 + r2_14 * _S184; - float _S281 = _S182 + r2_14 * _S280; - float _S282 = _S181 + r2_14 * _S281; - float2 _S283 = _S277 * make_float2 (1.0f + r2_14 * _S282) + make_float2 (s_diff_r2_8 * _S282 + (s_diff_r2_8 * _S281 + (s_diff_r2_8 * _S280 + s_diff_r2_8 * _S184 * r2_14) * r2_14) * r2_14) * _S276 + make_float2 (s_diff_u_8 * _S191 * v_14 + s_diff_v_8 * (_S191 * u_14) + (s_diff_r2_8 + (s_diff_u_8 * 2.0f * u_14 + s_diff_u_8 * (2.0f * u_14))) * _S186 + s_diff_r2_8 * _S187, s_diff_u_8 * _S192 * v_14 + s_diff_v_8 * (_S192 * u_14) + (s_diff_r2_8 + (s_diff_v_8 * 2.0f * v_14 + s_diff_v_8 * (2.0f * v_14))) * _S185 + s_diff_r2_8 * _S188); - float2 _S284 = _S283 + make_float2 (_S283.x * _S189 + _S283.y * _S190, 0.0f); - float _S285 = _S284.y * fy_2; - *&(((&J_3)->rows + (int(0)))->z) = _S284.x * fx_2; - *&(((&J_3)->rows + (int(1)))->z) = _S285; - *cov2d_2 = mul_4(mul_3(J_3, cov3d_2), transpose_1(J_3)); - _S178 = true; + Matrix J_4; + float _S195 = _S178 * _S178; + float2 s_diff_uv_3 = make_float2 (1.0f, 0.0f) * make_float2 (_S178) / make_float2 (_S195); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S196; + (&_S196)->primal_0 = _S177 / make_float2 (_S178); + (&_S196)->differential_0 = s_diff_uv_3; + FixedArray _S197 = dist_coeffs_3; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S198 = s_fwd_DistOpenCV_distort_0(&_S196, &_S197); + float fx_3 = intrins_3.x; + float fy_3 = intrins_3.y; + float _S199 = _S198.differential_0.y * fy_3; + Matrix J_5; + *&(((&J_5)->rows + (int(0)))->x) = _S198.differential_0.x * fx_3; + *&(((&J_5)->rows + (int(1)))->x) = _S199; + float2 s_diff_uv_4 = make_float2 (0.0f, 1.0f) * make_float2 (_S178) / make_float2 (_S195); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S200; + (&_S200)->primal_0 = _S177 / make_float2 (_S178); + (&_S200)->differential_0 = s_diff_uv_4; + FixedArray _S201 = dist_coeffs_3; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S202 = s_fwd_DistOpenCV_distort_0(&_S200, &_S201); + float _S203 = _S202.differential_0.y * fy_3; + *&(((&J_5)->rows + (int(0)))->y) = _S202.differential_0.x * fx_3; + *&(((&J_5)->rows + (int(1)))->y) = _S203; + float2 s_diff_uv_5 = (make_float2 (0.0f, 0.0f) - _S177) / make_float2 (_S195); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S204; + (&_S204)->primal_0 = _S177 / make_float2 (_S178); + (&_S204)->differential_0 = s_diff_uv_5; + FixedArray _S205 = dist_coeffs_3; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S206 = s_fwd_DistOpenCV_distort_0(&_S204, &_S205); + float _S207 = _S206.differential_0.y * fy_3; + *&(((&J_5)->rows + (int(0)))->z) = _S206.differential_0.x * fx_3; + *&(((&J_5)->rows + (int(1)))->z) = _S207; + J_4 = J_5; + float _S208 = float(width_1); + float _S209 = 0.30000001192092896f * (0.5f * _S208); + float lim_x_pos_1 = _S208 + _S209; + float rz_1 = 1.0f / _S178; + float _S210 = - _S209; + float max_Jyz_1 = - (_S210 - cy_1) * rz_1; + float min_Jyz_1 = - (lim_x_pos_1 - cy_1) * rz_1; + *&(((&J_4)->rows + (int(0)))->z) = clamp_0(*&(((&J_4)->rows + (int(0)))->z), - (lim_x_pos_1 - cx_1) * rz_1, - (_S210 - cx_1) * rz_1); + *&(((&J_4)->rows + (int(1)))->z) = clamp_0(*&(((&J_4)->rows + (int(1)))->z), min_Jyz_1, max_Jyz_1); + *cov2d_3 = mul_4(mul_3(J_4, cov3d_3), transpose_1(J_4)); + _S176 = true; break; } - return _S178; + return _S176; } -inline __device__ bool equirect_proj_3dgs_nav(float3 mean3d_3, Matrix cov3d_3, float4 intrins_3, FixedArray dist_coeffs_3, Matrix * cov2d_3, float2 * mean2d_3) +inline __device__ bool fisheye_proj_3dgs_nav_opencv(float3 mean3d_4, Matrix cov3d_4, float4 intrins_4, FixedArray dist_coeffs_4, Matrix * cov2d_4, float2 * mean2d_4) { - float _S286 = mean3d_3.x; - float _S287 = mean3d_3.z; - float _S288 = mean3d_3.y; - float2 _S289 = float2 {mean3d_3.x, mean3d_3.z}; - float fx_3 = intrins_3.x; - float fy_3 = intrins_3.y; - *mean2d_3 = make_float2 (fx_3 * (F32_atan2((_S286), (_S287))) + intrins_3.z, fy_3 * (F32_atan2((_S288), (length_0(_S289)))) + intrins_3.w); - DiffPair_float_0 _S290; - (&_S290)->primal_0 = _S286; - (&_S290)->differential_0 = 1.0f; - DiffPair_float_0 _S291; - (&_S291)->primal_0 = _S287; - (&_S291)->differential_0 = 0.0f; - DiffPair_float_0 _S292 = _d_atan2_1(&_S290, &_S291); - float2 _S293 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S294; - (&_S294)->primal_0 = _S289; - (&_S294)->differential_0 = _S293; - DiffPair_float_0 _S295 = s_fwd_length_impl_0(&_S294); - DiffPair_float_0 _S296; - (&_S296)->primal_0 = _S288; - (&_S296)->differential_0 = 0.0f; - DiffPair_float_0 _S297; - (&_S297)->primal_0 = _S295.primal_0; - (&_S297)->differential_0 = _S295.differential_0; - DiffPair_float_0 _S298 = _d_atan2_1(&_S296, &_S297); - float _S299 = _S298.differential_0 * fy_3; - Matrix J_4; - *&(((&J_4)->rows + (int(0)))->x) = _S292.differential_0 * fx_3; - *&(((&J_4)->rows + (int(1)))->x) = _S299; - DiffPair_float_0 _S300; - (&_S300)->primal_0 = _S286; - (&_S300)->differential_0 = 0.0f; - DiffPair_float_0 _S301; - (&_S301)->primal_0 = _S287; - (&_S301)->differential_0 = 0.0f; - DiffPair_float_0 _S302 = _d_atan2_1(&_S300, &_S301); - float2 _S303 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S304; - (&_S304)->primal_0 = _S289; - (&_S304)->differential_0 = _S303; - DiffPair_float_0 _S305 = s_fwd_length_impl_0(&_S304); - DiffPair_float_0 _S306; - (&_S306)->primal_0 = _S288; - (&_S306)->differential_0 = 1.0f; - DiffPair_float_0 _S307; - (&_S307)->primal_0 = _S305.primal_0; - (&_S307)->differential_0 = _S305.differential_0; - DiffPair_float_0 _S308 = _d_atan2_1(&_S306, &_S307); - float _S309 = _S308.differential_0 * fy_3; - *&(((&J_4)->rows + (int(0)))->y) = _S302.differential_0 * fx_3; - *&(((&J_4)->rows + (int(1)))->y) = _S309; - DiffPair_float_0 _S310; - (&_S310)->primal_0 = _S286; - (&_S310)->differential_0 = 0.0f; - DiffPair_float_0 _S311; - (&_S311)->primal_0 = _S287; - (&_S311)->differential_0 = 1.0f; - DiffPair_float_0 _S312 = _d_atan2_1(&_S310, &_S311); - float2 _S313 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S314; - (&_S314)->primal_0 = _S289; - (&_S314)->differential_0 = _S313; - DiffPair_float_0 _S315 = s_fwd_length_impl_0(&_S314); - DiffPair_float_0 _S316; - (&_S316)->primal_0 = _S288; - (&_S316)->differential_0 = 0.0f; - DiffPair_float_0 _S317; - (&_S317)->primal_0 = _S315.primal_0; - (&_S317)->differential_0 = _S315.differential_0; - DiffPair_float_0 _S318 = _d_atan2_1(&_S316, &_S317); - float _S319 = _S318.differential_0 * fy_3; - *&(((&J_4)->rows + (int(0)))->z) = _S312.differential_0 * fx_3; - *&(((&J_4)->rows + (int(1)))->z) = _S319; - *cov2d_3 = mul_4(mul_3(J_4, cov3d_3), transpose_1(J_4)); + bool _S211; + float2 _S212; + float _S213; + for(;;) + { + float k_2; + *cov2d_4 = makeMatrix (0.0f); + for(;;) + { + float2 _S214 = float2 {mean3d_4.x, mean3d_4.y}; + _S212 = _S214; + float r_9 = length_0(_S214); + float _S215 = mean3d_4.z; + _S213 = _S215; + float theta_2 = (F32_atan2((r_9), (_S215))); + bool _S216 = theta_2 < 0.00100000004749745f; + if(_S216) + { + k_2 = (1.0f - theta_2 * theta_2 / 3.0f) / _S215; + } + else + { + k_2 = theta_2 / r_9; + } + float2 _S217 = _S214 * make_float2 (k_2); + float2 _S218 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S219; + (&_S219)->primal_0 = _S217; + (&_S219)->differential_0 = _S218; + FixedArray _S220 = dist_coeffs_4; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S221 = s_fwd_DistOpenCV_distort_0(&_S219, &_S220); + float2 _S222 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S223; + (&_S223)->primal_0 = _S217; + (&_S223)->differential_0 = _S222; + FixedArray _S224 = dist_coeffs_4; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S225 = s_fwd_DistOpenCV_distort_0(&_S223, &_S224); + Matrix _S226 = transpose_0(makeMatrix (_S221.differential_0, _S225.differential_0)); + float _S227 = (F32_min((determinant_0(_S226)), ((F32_min((_S226.rows[int(0)].x), (_S226.rows[int(1)].y)))))); + if(_S227 > 0.25f) + { + _S211 = _S227 < 4.0f; + } + else + { + _S211 = false; + } + if(_S211) + { + FixedArray _S228 = dist_coeffs_4; + float2 _S229 = DistOpenCV_distort_0(_S217, &_S228); + _S211 = (dot_0(_S217, _S229)) >= 0.0f; + } + else + { + _S211 = false; + } + if(!_S211) + { + *mean2d_4 = _S217; + _S211 = false; + break; + } + if(_S216) + { + k_2 = (1.0f - theta_2 * theta_2 / 3.0f) / _S215; + } + else + { + k_2 = theta_2 / r_9; + } + float2 _S230 = _S214 * make_float2 (k_2); + FixedArray _S231 = dist_coeffs_4; + float2 _S232 = DistOpenCV_distort_0(_S230, &_S231); + *mean2d_4 = make_float2 (intrins_4.x * _S232.x + intrins_4.z, intrins_4.y * _S232.y + intrins_4.w); + _S211 = true; + break; + } + if(!_S211) + { + _S211 = false; + break; + } + Matrix J_6; + float2 _S233 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S234; + (&_S234)->primal_0 = _S212; + (&_S234)->differential_0 = _S233; + DiffPair_float_0 _S235 = s_fwd_length_impl_0(&_S234); + float _S236 = _S213; + DiffPair_float_0 _S237; + (&_S237)->primal_0 = _S235.primal_0; + (&_S237)->differential_0 = _S235.differential_0; + DiffPair_float_0 _S238; + (&_S238)->primal_0 = _S213; + (&_S238)->differential_0 = 0.0f; + DiffPair_float_0 _S239 = _d_atan2_1(&_S237, &_S238); + float s_diff_k_2; + if((_S239.primal_0) < 0.00100000004749745f) + { + float _S240 = _S239.differential_0 * _S239.primal_0; + float _S241 = (0.0f - (_S240 + _S240) * 0.3333333432674408f) * _S213 / (_S213 * _S213); + k_2 = (1.0f - _S239.primal_0 * _S239.primal_0 / 3.0f) / _S213; + s_diff_k_2 = _S241; + } + else + { + float _S242 = (_S239.differential_0 * _S235.primal_0 - _S239.primal_0 * _S235.differential_0) / (_S235.primal_0 * _S235.primal_0); + k_2 = _S239.primal_0 / _S235.primal_0; + s_diff_k_2 = _S242; + } + float2 _S243 = _S212 * make_float2 (k_2); + float2 _S244 = _S233 * make_float2 (k_2) + make_float2 (s_diff_k_2) * _S212; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S245; + (&_S245)->primal_0 = _S243; + (&_S245)->differential_0 = _S244; + FixedArray _S246 = dist_coeffs_4; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S247 = s_fwd_DistOpenCV_distort_0(&_S245, &_S246); + float fx_4 = intrins_4.x; + float fy_4 = intrins_4.y; + float _S248 = _S247.differential_0.y * fy_4; + *&(((&J_6)->rows + (int(0)))->x) = _S247.differential_0.x * fx_4; + *&(((&J_6)->rows + (int(1)))->x) = _S248; + float2 _S249 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S250; + (&_S250)->primal_0 = _S212; + (&_S250)->differential_0 = _S249; + DiffPair_float_0 _S251 = s_fwd_length_impl_0(&_S250); + DiffPair_float_0 _S252; + (&_S252)->primal_0 = _S251.primal_0; + (&_S252)->differential_0 = _S251.differential_0; + DiffPair_float_0 _S253; + (&_S253)->primal_0 = _S236; + (&_S253)->differential_0 = 0.0f; + DiffPair_float_0 _S254 = _d_atan2_1(&_S252, &_S253); + if((_S254.primal_0) < 0.00100000004749745f) + { + float _S255 = _S254.differential_0 * _S254.primal_0; + float _S256 = (0.0f - (_S255 + _S255) * 0.3333333432674408f) * _S213 / (_S213 * _S213); + k_2 = (1.0f - _S254.primal_0 * _S254.primal_0 / 3.0f) / _S213; + s_diff_k_2 = _S256; + } + else + { + float _S257 = (_S254.differential_0 * _S251.primal_0 - _S254.primal_0 * _S251.differential_0) / (_S251.primal_0 * _S251.primal_0); + k_2 = _S254.primal_0 / _S251.primal_0; + s_diff_k_2 = _S257; + } + float2 _S258 = _S212 * make_float2 (k_2); + float2 _S259 = _S249 * make_float2 (k_2) + make_float2 (s_diff_k_2) * _S212; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S260; + (&_S260)->primal_0 = _S258; + (&_S260)->differential_0 = _S259; + FixedArray _S261 = dist_coeffs_4; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S262 = s_fwd_DistOpenCV_distort_0(&_S260, &_S261); + float _S263 = _S262.differential_0.y * fy_4; + *&(((&J_6)->rows + (int(0)))->y) = _S262.differential_0.x * fx_4; + *&(((&J_6)->rows + (int(1)))->y) = _S263; + float2 _S264 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S265; + (&_S265)->primal_0 = _S212; + (&_S265)->differential_0 = _S264; + DiffPair_float_0 _S266 = s_fwd_length_impl_0(&_S265); + DiffPair_float_0 _S267; + (&_S267)->primal_0 = _S266.primal_0; + (&_S267)->differential_0 = _S266.differential_0; + DiffPair_float_0 _S268; + (&_S268)->primal_0 = _S213; + (&_S268)->differential_0 = 1.0f; + DiffPair_float_0 _S269 = _d_atan2_1(&_S267, &_S268); + if((_S269.primal_0) < 0.00100000004749745f) + { + float _S270 = _S269.differential_0 * _S269.primal_0; + float _S271 = 1.0f - _S269.primal_0 * _S269.primal_0 / 3.0f; + float _S272 = ((0.0f - (_S270 + _S270) * 0.3333333432674408f) * _S213 - _S271) / (_S213 * _S213); + k_2 = _S271 / _S213; + s_diff_k_2 = _S272; + } + else + { + float _S273 = (_S269.differential_0 * _S266.primal_0 - _S269.primal_0 * _S266.differential_0) / (_S266.primal_0 * _S266.primal_0); + k_2 = _S269.primal_0 / _S266.primal_0; + s_diff_k_2 = _S273; + } + float2 _S274 = _S212 * make_float2 (k_2); + float2 _S275 = make_float2 (s_diff_k_2) * _S212; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S276; + (&_S276)->primal_0 = _S274; + (&_S276)->differential_0 = _S275; + FixedArray _S277 = dist_coeffs_4; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S278 = s_fwd_DistOpenCV_distort_0(&_S276, &_S277); + float _S279 = _S278.differential_0.y * fy_4; + *&(((&J_6)->rows + (int(0)))->z) = _S278.differential_0.x * fx_4; + *&(((&J_6)->rows + (int(1)))->z) = _S279; + *cov2d_4 = mul_4(mul_3(J_6, cov3d_4), transpose_1(J_6)); + _S211 = true; + break; + } + return _S211; +} + +inline __device__ bool equisolid_proj_3dgs_nav_opencv(float3 mean3d_5, Matrix cov3d_5, float4 intrins_5, FixedArray dist_coeffs_5, Matrix * cov2d_5, float2 * mean2d_5) +{ + bool _S280; + float2 _S281; + float _S282; + for(;;) + { + float k_3; + *cov2d_5 = makeMatrix (0.0f); + for(;;) + { + float2 _S283 = float2 {mean3d_5.x, mean3d_5.y}; + _S281 = _S283; + float r_10 = length_0(_S283); + float _S284 = mean3d_5.z; + _S282 = _S284; + float theta_3 = (F32_atan2((r_10), (_S284))); + bool _S285 = r_10 < 9.99999997475242708e-07f; + if(_S285) + { + k_3 = (1.0f - theta_3 * theta_3 / 24.0f) / _S284; + } + else + { + k_3 = 2.0f * (F32_sin((0.5f * theta_3))) / r_10; + } + float2 _S286 = _S283 * make_float2 (k_3); + float2 _S287 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S288; + (&_S288)->primal_0 = _S286; + (&_S288)->differential_0 = _S287; + FixedArray _S289 = dist_coeffs_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S290 = s_fwd_DistOpenCV_distort_0(&_S288, &_S289); + float2 _S291 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S292; + (&_S292)->primal_0 = _S286; + (&_S292)->differential_0 = _S291; + FixedArray _S293 = dist_coeffs_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S294 = s_fwd_DistOpenCV_distort_0(&_S292, &_S293); + Matrix _S295 = transpose_0(makeMatrix (_S290.differential_0, _S294.differential_0)); + float _S296 = (F32_min((determinant_0(_S295)), ((F32_min((_S295.rows[int(0)].x), (_S295.rows[int(1)].y)))))); + if(_S296 > 0.25f) + { + _S280 = _S296 < 4.0f; + } + else + { + _S280 = false; + } + if(_S280) + { + FixedArray _S297 = dist_coeffs_5; + float2 _S298 = DistOpenCV_distort_0(_S286, &_S297); + _S280 = (dot_0(_S286, _S298)) >= 0.0f; + } + else + { + _S280 = false; + } + if(!_S280) + { + *mean2d_5 = _S286; + _S280 = false; + break; + } + if(_S285) + { + k_3 = (1.0f - theta_3 * theta_3 / 24.0f) / _S284; + } + else + { + k_3 = 2.0f * (F32_sin((0.5f * theta_3))) / r_10; + } + float2 _S299 = _S283 * make_float2 (k_3); + FixedArray _S300 = dist_coeffs_5; + float2 _S301 = DistOpenCV_distort_0(_S299, &_S300); + *mean2d_5 = make_float2 (intrins_5.x * _S301.x + intrins_5.z, intrins_5.y * _S301.y + intrins_5.w); + _S280 = true; + break; + } + if(!_S280) + { + _S280 = false; + break; + } + Matrix J_7; + float2 _S302 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S303; + (&_S303)->primal_0 = _S281; + (&_S303)->differential_0 = _S302; + DiffPair_float_0 _S304 = s_fwd_length_impl_0(&_S303); + float _S305 = _S282; + DiffPair_float_0 _S306; + (&_S306)->primal_0 = _S304.primal_0; + (&_S306)->differential_0 = _S304.differential_0; + DiffPair_float_0 _S307; + (&_S307)->primal_0 = _S282; + (&_S307)->differential_0 = 0.0f; + DiffPair_float_0 _S308 = _d_atan2_1(&_S306, &_S307); + float s_diff_k_3; + if((_S304.primal_0) < 9.99999997475242708e-07f) + { + float _S309 = _S308.differential_0 * _S308.primal_0; + float _S310 = (0.0f - (_S309 + _S309) * 0.0416666679084301f) * _S282 / (_S282 * _S282); + k_3 = (1.0f - _S308.primal_0 * _S308.primal_0 / 24.0f) / _S282; + s_diff_k_3 = _S310; + } + else + { + float _S311 = _S308.differential_0 * 0.5f; + DiffPair_float_0 _S312; + (&_S312)->primal_0 = 0.5f * _S308.primal_0; + (&_S312)->differential_0 = _S311; + DiffPair_float_0 _S313 = _d_sin_1(&_S312); + float _S314 = 2.0f * _S313.primal_0; + float _S315 = (_S313.differential_0 * 2.0f * _S304.primal_0 - _S314 * _S304.differential_0) / (_S304.primal_0 * _S304.primal_0); + k_3 = _S314 / _S304.primal_0; + s_diff_k_3 = _S315; + } + float2 _S316 = _S281 * make_float2 (k_3); + float2 _S317 = _S302 * make_float2 (k_3) + make_float2 (s_diff_k_3) * _S281; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S318; + (&_S318)->primal_0 = _S316; + (&_S318)->differential_0 = _S317; + FixedArray _S319 = dist_coeffs_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S320 = s_fwd_DistOpenCV_distort_0(&_S318, &_S319); + float fx_5 = intrins_5.x; + float fy_5 = intrins_5.y; + float _S321 = _S320.differential_0.y * fy_5; + *&(((&J_7)->rows + (int(0)))->x) = _S320.differential_0.x * fx_5; + *&(((&J_7)->rows + (int(1)))->x) = _S321; + float2 _S322 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S323; + (&_S323)->primal_0 = _S281; + (&_S323)->differential_0 = _S322; + DiffPair_float_0 _S324 = s_fwd_length_impl_0(&_S323); + DiffPair_float_0 _S325; + (&_S325)->primal_0 = _S324.primal_0; + (&_S325)->differential_0 = _S324.differential_0; + DiffPair_float_0 _S326; + (&_S326)->primal_0 = _S305; + (&_S326)->differential_0 = 0.0f; + DiffPair_float_0 _S327 = _d_atan2_1(&_S325, &_S326); + if((_S324.primal_0) < 9.99999997475242708e-07f) + { + float _S328 = _S327.differential_0 * _S327.primal_0; + float _S329 = (0.0f - (_S328 + _S328) * 0.0416666679084301f) * _S282 / (_S282 * _S282); + k_3 = (1.0f - _S327.primal_0 * _S327.primal_0 / 24.0f) / _S282; + s_diff_k_3 = _S329; + } + else + { + float _S330 = _S327.differential_0 * 0.5f; + DiffPair_float_0 _S331; + (&_S331)->primal_0 = 0.5f * _S327.primal_0; + (&_S331)->differential_0 = _S330; + DiffPair_float_0 _S332 = _d_sin_1(&_S331); + float _S333 = 2.0f * _S332.primal_0; + float _S334 = (_S332.differential_0 * 2.0f * _S324.primal_0 - _S333 * _S324.differential_0) / (_S324.primal_0 * _S324.primal_0); + k_3 = _S333 / _S324.primal_0; + s_diff_k_3 = _S334; + } + float2 _S335 = _S281 * make_float2 (k_3); + float2 _S336 = _S322 * make_float2 (k_3) + make_float2 (s_diff_k_3) * _S281; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S337; + (&_S337)->primal_0 = _S335; + (&_S337)->differential_0 = _S336; + FixedArray _S338 = dist_coeffs_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S339 = s_fwd_DistOpenCV_distort_0(&_S337, &_S338); + float _S340 = _S339.differential_0.y * fy_5; + *&(((&J_7)->rows + (int(0)))->y) = _S339.differential_0.x * fx_5; + *&(((&J_7)->rows + (int(1)))->y) = _S340; + float2 _S341 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S342; + (&_S342)->primal_0 = _S281; + (&_S342)->differential_0 = _S341; + DiffPair_float_0 _S343 = s_fwd_length_impl_0(&_S342); + DiffPair_float_0 _S344; + (&_S344)->primal_0 = _S343.primal_0; + (&_S344)->differential_0 = _S343.differential_0; + DiffPair_float_0 _S345; + (&_S345)->primal_0 = _S282; + (&_S345)->differential_0 = 1.0f; + DiffPair_float_0 _S346 = _d_atan2_1(&_S344, &_S345); + if((_S343.primal_0) < 9.99999997475242708e-07f) + { + float _S347 = _S346.differential_0 * _S346.primal_0; + float _S348 = 1.0f - _S346.primal_0 * _S346.primal_0 / 24.0f; + float _S349 = ((0.0f - (_S347 + _S347) * 0.0416666679084301f) * _S282 - _S348) / (_S282 * _S282); + k_3 = _S348 / _S282; + s_diff_k_3 = _S349; + } + else + { + float _S350 = _S346.differential_0 * 0.5f; + DiffPair_float_0 _S351; + (&_S351)->primal_0 = 0.5f * _S346.primal_0; + (&_S351)->differential_0 = _S350; + DiffPair_float_0 _S352 = _d_sin_1(&_S351); + float _S353 = 2.0f * _S352.primal_0; + float _S354 = (_S352.differential_0 * 2.0f * _S343.primal_0 - _S353 * _S343.differential_0) / (_S343.primal_0 * _S343.primal_0); + k_3 = _S353 / _S343.primal_0; + s_diff_k_3 = _S354; + } + float2 _S355 = _S281 * make_float2 (k_3); + float2 _S356 = make_float2 (s_diff_k_3) * _S281; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S357; + (&_S357)->primal_0 = _S355; + (&_S357)->differential_0 = _S356; + FixedArray _S358 = dist_coeffs_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S359 = s_fwd_DistOpenCV_distort_0(&_S357, &_S358); + float _S360 = _S359.differential_0.y * fy_5; + *&(((&J_7)->rows + (int(0)))->z) = _S359.differential_0.x * fx_5; + *&(((&J_7)->rows + (int(1)))->z) = _S360; + *cov2d_5 = mul_4(mul_3(J_7, cov3d_5), transpose_1(J_7)); + _S280 = true; + break; + } + return _S280; +} + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistThinPrism_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_2, FixedArray * coeffs_4) +{ + float u_2 = dpuv_2->primal_0.x; + float s_diff_u_1 = dpuv_2->differential_0.x; + float v_2 = dpuv_2->primal_0.y; + float s_diff_v_1 = dpuv_2->differential_0.y; + float _S361 = s_diff_u_1 * u_2; + float _S362 = s_diff_v_1 * v_2; + float r2_2 = u_2 * u_2 + v_2 * v_2; + float s_diff_r2_1 = _S361 + _S361 + (_S362 + _S362); + float _S363 = (*coeffs_4)[int(2)] + r2_2 * (*coeffs_4)[int(3)]; + float _S364 = (*coeffs_4)[int(1)] + r2_2 * _S363; + float _S365 = (*coeffs_4)[int(0)] + r2_2 * _S364; + float radial_1 = 1.0f + r2_2 * _S365; + float _S366 = 2.0f * (*coeffs_4)[int(4)]; + float _S367 = _S366 * u_2; + float _S368 = 2.0f * u_2; + float _S369 = 2.0f * (*coeffs_4)[int(5)]; + float _S370 = _S369 * u_2; + float _S371 = 2.0f * v_2; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S372 = { dpuv_2->primal_0 * make_float2 (radial_1) + make_float2 (_S367 * v_2 + (*coeffs_4)[int(5)] * (r2_2 + _S368 * u_2) + (*coeffs_4)[int(6)] * r2_2, _S370 * v_2 + (*coeffs_4)[int(4)] * (r2_2 + _S371 * v_2) + (*coeffs_4)[int(7)] * r2_2), dpuv_2->differential_0 * make_float2 (radial_1) + make_float2 (s_diff_r2_1 * _S365 + (s_diff_r2_1 * _S364 + (s_diff_r2_1 * _S363 + s_diff_r2_1 * (*coeffs_4)[int(3)] * r2_2) * r2_2) * r2_2) * dpuv_2->primal_0 + make_float2 (s_diff_u_1 * _S366 * v_2 + s_diff_v_1 * _S367 + (s_diff_r2_1 + (s_diff_u_1 * 2.0f * u_2 + s_diff_u_1 * _S368)) * (*coeffs_4)[int(5)] + s_diff_r2_1 * (*coeffs_4)[int(6)], s_diff_u_1 * _S369 * v_2 + s_diff_v_1 * _S370 + (s_diff_r2_1 + (s_diff_v_1 * 2.0f * v_2 + s_diff_v_1 * _S371)) * (*coeffs_4)[int(4)] + s_diff_r2_1 * (*coeffs_4)[int(7)]) }; + return _S372; +} + +inline __device__ float2 DistThinPrism_distort_0(float2 uv_4, FixedArray * coeffs_5) +{ + float u_3 = uv_4.x; + float v_3 = uv_4.y; + float r2_3 = u_3 * u_3 + v_3 * v_3; + return uv_4 * make_float2 (1.0f + r2_3 * ((*coeffs_5)[int(0)] + r2_3 * ((*coeffs_5)[int(1)] + r2_3 * ((*coeffs_5)[int(2)] + r2_3 * (*coeffs_5)[int(3)])))) + make_float2 (2.0f * (*coeffs_5)[int(4)] * u_3 * v_3 + (*coeffs_5)[int(5)] * (r2_3 + 2.0f * u_3 * u_3) + (*coeffs_5)[int(6)] * r2_3, 2.0f * (*coeffs_5)[int(5)] * u_3 * v_3 + (*coeffs_5)[int(4)] * (r2_3 + 2.0f * v_3 * v_3) + (*coeffs_5)[int(7)] * r2_3); +} + +inline __device__ bool persp_proj_3dgs_nav_prism(float3 mean3d_6, Matrix cov3d_6, float4 intrins_6, FixedArray dist_coeffs_6, uint width_2, uint height_2, Matrix * cov2d_6, float2 * mean2d_6) +{ + bool _S373; + float2 _S374; + float _S375; + for(;;) + { + float cx_2 = intrins_6.z; + float cy_2 = intrins_6.w; + *cov2d_6 = makeMatrix (0.0f); + for(;;) + { + float2 _S376 = float2 {mean3d_6.x, mean3d_6.y}; + _S374 = _S376; + float _S377 = mean3d_6.z; + _S375 = _S377; + float2 uv0_2 = _S376 / make_float2 (_S377); + if(_S377 < 0.0f) + { + _S373 = true; + } + else + { + float2 _S378 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S379; + (&_S379)->primal_0 = uv0_2; + (&_S379)->differential_0 = _S378; + FixedArray _S380 = dist_coeffs_6; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S381 = s_fwd_DistThinPrism_distort_0(&_S379, &_S380); + float2 _S382 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S383; + (&_S383)->primal_0 = uv0_2; + (&_S383)->differential_0 = _S382; + FixedArray _S384 = dist_coeffs_6; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S385 = s_fwd_DistThinPrism_distort_0(&_S383, &_S384); + Matrix _S386 = transpose_0(makeMatrix (_S381.differential_0, _S385.differential_0)); + float _S387 = (F32_min((determinant_0(_S386)), ((F32_min((_S386.rows[int(0)].x), (_S386.rows[int(1)].y)))))); + if(_S387 > 0.25f) + { + _S373 = _S387 < 4.0f; + } + else + { + _S373 = false; + } + if(_S373) + { + FixedArray _S388 = dist_coeffs_6; + float2 _S389 = DistThinPrism_distort_0(uv0_2, &_S388); + _S373 = (dot_0(uv0_2, _S389)) >= 0.0f; + } + else + { + _S373 = false; + } + _S373 = !_S373; + } + if(_S373) + { + *mean2d_6 = uv0_2; + _S373 = false; + break; + } + float2 uv_5 = _S376 / make_float2 (_S377); + FixedArray _S390 = dist_coeffs_6; + float2 _S391 = DistThinPrism_distort_0(uv_5, &_S390); + *mean2d_6 = make_float2 (intrins_6.x * _S391.x + cx_2, intrins_6.y * _S391.y + cy_2); + _S373 = true; + break; + } + if(!_S373) + { + _S373 = false; + break; + } + Matrix J_8; + float _S392 = _S375 * _S375; + float2 s_diff_uv_6 = make_float2 (1.0f, 0.0f) * make_float2 (_S375) / make_float2 (_S392); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S393; + (&_S393)->primal_0 = _S374 / make_float2 (_S375); + (&_S393)->differential_0 = s_diff_uv_6; + FixedArray _S394 = dist_coeffs_6; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S395 = s_fwd_DistThinPrism_distort_0(&_S393, &_S394); + float fx_6 = intrins_6.x; + float fy_6 = intrins_6.y; + float _S396 = _S395.differential_0.y * fy_6; + Matrix J_9; + *&(((&J_9)->rows + (int(0)))->x) = _S395.differential_0.x * fx_6; + *&(((&J_9)->rows + (int(1)))->x) = _S396; + float2 s_diff_uv_7 = make_float2 (0.0f, 1.0f) * make_float2 (_S375) / make_float2 (_S392); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S397; + (&_S397)->primal_0 = _S374 / make_float2 (_S375); + (&_S397)->differential_0 = s_diff_uv_7; + FixedArray _S398 = dist_coeffs_6; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S399 = s_fwd_DistThinPrism_distort_0(&_S397, &_S398); + float _S400 = _S399.differential_0.y * fy_6; + *&(((&J_9)->rows + (int(0)))->y) = _S399.differential_0.x * fx_6; + *&(((&J_9)->rows + (int(1)))->y) = _S400; + float2 s_diff_uv_8 = (make_float2 (0.0f, 0.0f) - _S374) / make_float2 (_S392); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S401; + (&_S401)->primal_0 = _S374 / make_float2 (_S375); + (&_S401)->differential_0 = s_diff_uv_8; + FixedArray _S402 = dist_coeffs_6; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S403 = s_fwd_DistThinPrism_distort_0(&_S401, &_S402); + float _S404 = _S403.differential_0.y * fy_6; + *&(((&J_9)->rows + (int(0)))->z) = _S403.differential_0.x * fx_6; + *&(((&J_9)->rows + (int(1)))->z) = _S404; + J_8 = J_9; + float _S405 = float(width_2); + float _S406 = 0.30000001192092896f * (0.5f * _S405); + float lim_x_pos_2 = _S405 + _S406; + float rz_2 = 1.0f / _S375; + float _S407 = - _S406; + float max_Jyz_2 = - (_S407 - cy_2) * rz_2; + float min_Jyz_2 = - (lim_x_pos_2 - cy_2) * rz_2; + *&(((&J_8)->rows + (int(0)))->z) = clamp_0(*&(((&J_8)->rows + (int(0)))->z), - (lim_x_pos_2 - cx_2) * rz_2, - (_S407 - cx_2) * rz_2); + *&(((&J_8)->rows + (int(1)))->z) = clamp_0(*&(((&J_8)->rows + (int(1)))->z), min_Jyz_2, max_Jyz_2); + *cov2d_6 = mul_4(mul_3(J_8, cov3d_6), transpose_1(J_8)); + _S373 = true; + break; + } + return _S373; +} + +inline __device__ bool fisheye_proj_3dgs_nav_prism(float3 mean3d_7, Matrix cov3d_7, float4 intrins_7, FixedArray dist_coeffs_7, Matrix * cov2d_7, float2 * mean2d_7) +{ + bool _S408; + float2 _S409; + float _S410; + for(;;) + { + float k_4; + *cov2d_7 = makeMatrix (0.0f); + for(;;) + { + float2 _S411 = float2 {mean3d_7.x, mean3d_7.y}; + _S409 = _S411; + float r_11 = length_0(_S411); + float _S412 = mean3d_7.z; + _S410 = _S412; + float theta_4 = (F32_atan2((r_11), (_S412))); + bool _S413 = theta_4 < 0.00100000004749745f; + if(_S413) + { + k_4 = (1.0f - theta_4 * theta_4 / 3.0f) / _S412; + } + else + { + k_4 = theta_4 / r_11; + } + float2 _S414 = _S411 * make_float2 (k_4); + float2 _S415 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S416; + (&_S416)->primal_0 = _S414; + (&_S416)->differential_0 = _S415; + FixedArray _S417 = dist_coeffs_7; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S418 = s_fwd_DistThinPrism_distort_0(&_S416, &_S417); + float2 _S419 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S420; + (&_S420)->primal_0 = _S414; + (&_S420)->differential_0 = _S419; + FixedArray _S421 = dist_coeffs_7; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S422 = s_fwd_DistThinPrism_distort_0(&_S420, &_S421); + Matrix _S423 = transpose_0(makeMatrix (_S418.differential_0, _S422.differential_0)); + float _S424 = (F32_min((determinant_0(_S423)), ((F32_min((_S423.rows[int(0)].x), (_S423.rows[int(1)].y)))))); + if(_S424 > 0.25f) + { + _S408 = _S424 < 4.0f; + } + else + { + _S408 = false; + } + if(_S408) + { + FixedArray _S425 = dist_coeffs_7; + float2 _S426 = DistThinPrism_distort_0(_S414, &_S425); + _S408 = (dot_0(_S414, _S426)) >= 0.0f; + } + else + { + _S408 = false; + } + if(!_S408) + { + *mean2d_7 = _S414; + _S408 = false; + break; + } + if(_S413) + { + k_4 = (1.0f - theta_4 * theta_4 / 3.0f) / _S412; + } + else + { + k_4 = theta_4 / r_11; + } + float2 _S427 = _S411 * make_float2 (k_4); + FixedArray _S428 = dist_coeffs_7; + float2 _S429 = DistThinPrism_distort_0(_S427, &_S428); + *mean2d_7 = make_float2 (intrins_7.x * _S429.x + intrins_7.z, intrins_7.y * _S429.y + intrins_7.w); + _S408 = true; + break; + } + if(!_S408) + { + _S408 = false; + break; + } + Matrix J_10; + float2 _S430 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S431; + (&_S431)->primal_0 = _S409; + (&_S431)->differential_0 = _S430; + DiffPair_float_0 _S432 = s_fwd_length_impl_0(&_S431); + float _S433 = _S410; + DiffPair_float_0 _S434; + (&_S434)->primal_0 = _S432.primal_0; + (&_S434)->differential_0 = _S432.differential_0; + DiffPair_float_0 _S435; + (&_S435)->primal_0 = _S410; + (&_S435)->differential_0 = 0.0f; + DiffPair_float_0 _S436 = _d_atan2_1(&_S434, &_S435); + float s_diff_k_4; + if((_S436.primal_0) < 0.00100000004749745f) + { + float _S437 = _S436.differential_0 * _S436.primal_0; + float _S438 = (0.0f - (_S437 + _S437) * 0.3333333432674408f) * _S410 / (_S410 * _S410); + k_4 = (1.0f - _S436.primal_0 * _S436.primal_0 / 3.0f) / _S410; + s_diff_k_4 = _S438; + } + else + { + float _S439 = (_S436.differential_0 * _S432.primal_0 - _S436.primal_0 * _S432.differential_0) / (_S432.primal_0 * _S432.primal_0); + k_4 = _S436.primal_0 / _S432.primal_0; + s_diff_k_4 = _S439; + } + float2 _S440 = _S409 * make_float2 (k_4); + float2 _S441 = _S430 * make_float2 (k_4) + make_float2 (s_diff_k_4) * _S409; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S442; + (&_S442)->primal_0 = _S440; + (&_S442)->differential_0 = _S441; + FixedArray _S443 = dist_coeffs_7; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S444 = s_fwd_DistThinPrism_distort_0(&_S442, &_S443); + float fx_7 = intrins_7.x; + float fy_7 = intrins_7.y; + float _S445 = _S444.differential_0.y * fy_7; + *&(((&J_10)->rows + (int(0)))->x) = _S444.differential_0.x * fx_7; + *&(((&J_10)->rows + (int(1)))->x) = _S445; + float2 _S446 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S447; + (&_S447)->primal_0 = _S409; + (&_S447)->differential_0 = _S446; + DiffPair_float_0 _S448 = s_fwd_length_impl_0(&_S447); + DiffPair_float_0 _S449; + (&_S449)->primal_0 = _S448.primal_0; + (&_S449)->differential_0 = _S448.differential_0; + DiffPair_float_0 _S450; + (&_S450)->primal_0 = _S433; + (&_S450)->differential_0 = 0.0f; + DiffPair_float_0 _S451 = _d_atan2_1(&_S449, &_S450); + if((_S451.primal_0) < 0.00100000004749745f) + { + float _S452 = _S451.differential_0 * _S451.primal_0; + float _S453 = (0.0f - (_S452 + _S452) * 0.3333333432674408f) * _S410 / (_S410 * _S410); + k_4 = (1.0f - _S451.primal_0 * _S451.primal_0 / 3.0f) / _S410; + s_diff_k_4 = _S453; + } + else + { + float _S454 = (_S451.differential_0 * _S448.primal_0 - _S451.primal_0 * _S448.differential_0) / (_S448.primal_0 * _S448.primal_0); + k_4 = _S451.primal_0 / _S448.primal_0; + s_diff_k_4 = _S454; + } + float2 _S455 = _S409 * make_float2 (k_4); + float2 _S456 = _S446 * make_float2 (k_4) + make_float2 (s_diff_k_4) * _S409; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S457; + (&_S457)->primal_0 = _S455; + (&_S457)->differential_0 = _S456; + FixedArray _S458 = dist_coeffs_7; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S459 = s_fwd_DistThinPrism_distort_0(&_S457, &_S458); + float _S460 = _S459.differential_0.y * fy_7; + *&(((&J_10)->rows + (int(0)))->y) = _S459.differential_0.x * fx_7; + *&(((&J_10)->rows + (int(1)))->y) = _S460; + float2 _S461 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S462; + (&_S462)->primal_0 = _S409; + (&_S462)->differential_0 = _S461; + DiffPair_float_0 _S463 = s_fwd_length_impl_0(&_S462); + DiffPair_float_0 _S464; + (&_S464)->primal_0 = _S463.primal_0; + (&_S464)->differential_0 = _S463.differential_0; + DiffPair_float_0 _S465; + (&_S465)->primal_0 = _S410; + (&_S465)->differential_0 = 1.0f; + DiffPair_float_0 _S466 = _d_atan2_1(&_S464, &_S465); + if((_S466.primal_0) < 0.00100000004749745f) + { + float _S467 = _S466.differential_0 * _S466.primal_0; + float _S468 = 1.0f - _S466.primal_0 * _S466.primal_0 / 3.0f; + float _S469 = ((0.0f - (_S467 + _S467) * 0.3333333432674408f) * _S410 - _S468) / (_S410 * _S410); + k_4 = _S468 / _S410; + s_diff_k_4 = _S469; + } + else + { + float _S470 = (_S466.differential_0 * _S463.primal_0 - _S466.primal_0 * _S463.differential_0) / (_S463.primal_0 * _S463.primal_0); + k_4 = _S466.primal_0 / _S463.primal_0; + s_diff_k_4 = _S470; + } + float2 _S471 = _S409 * make_float2 (k_4); + float2 _S472 = make_float2 (s_diff_k_4) * _S409; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S473; + (&_S473)->primal_0 = _S471; + (&_S473)->differential_0 = _S472; + FixedArray _S474 = dist_coeffs_7; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S475 = s_fwd_DistThinPrism_distort_0(&_S473, &_S474); + float _S476 = _S475.differential_0.y * fy_7; + *&(((&J_10)->rows + (int(0)))->z) = _S475.differential_0.x * fx_7; + *&(((&J_10)->rows + (int(1)))->z) = _S476; + *cov2d_7 = mul_4(mul_3(J_10, cov3d_7), transpose_1(J_10)); + _S408 = true; + break; + } + return _S408; +} + +inline __device__ bool equisolid_proj_3dgs_nav_prism(float3 mean3d_8, Matrix cov3d_8, float4 intrins_8, FixedArray dist_coeffs_8, Matrix * cov2d_8, float2 * mean2d_8) +{ + bool _S477; + float2 _S478; + float _S479; + for(;;) + { + float k_5; + *cov2d_8 = makeMatrix (0.0f); + for(;;) + { + float2 _S480 = float2 {mean3d_8.x, mean3d_8.y}; + _S478 = _S480; + float r_12 = length_0(_S480); + float _S481 = mean3d_8.z; + _S479 = _S481; + float theta_5 = (F32_atan2((r_12), (_S481))); + bool _S482 = r_12 < 9.99999997475242708e-07f; + if(_S482) + { + k_5 = (1.0f - theta_5 * theta_5 / 24.0f) / _S481; + } + else + { + k_5 = 2.0f * (F32_sin((0.5f * theta_5))) / r_12; + } + float2 _S483 = _S480 * make_float2 (k_5); + float2 _S484 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S485; + (&_S485)->primal_0 = _S483; + (&_S485)->differential_0 = _S484; + FixedArray _S486 = dist_coeffs_8; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S487 = s_fwd_DistThinPrism_distort_0(&_S485, &_S486); + float2 _S488 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S489; + (&_S489)->primal_0 = _S483; + (&_S489)->differential_0 = _S488; + FixedArray _S490 = dist_coeffs_8; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S491 = s_fwd_DistThinPrism_distort_0(&_S489, &_S490); + Matrix _S492 = transpose_0(makeMatrix (_S487.differential_0, _S491.differential_0)); + float _S493 = (F32_min((determinant_0(_S492)), ((F32_min((_S492.rows[int(0)].x), (_S492.rows[int(1)].y)))))); + if(_S493 > 0.25f) + { + _S477 = _S493 < 4.0f; + } + else + { + _S477 = false; + } + if(_S477) + { + FixedArray _S494 = dist_coeffs_8; + float2 _S495 = DistThinPrism_distort_0(_S483, &_S494); + _S477 = (dot_0(_S483, _S495)) >= 0.0f; + } + else + { + _S477 = false; + } + if(!_S477) + { + *mean2d_8 = _S483; + _S477 = false; + break; + } + if(_S482) + { + k_5 = (1.0f - theta_5 * theta_5 / 24.0f) / _S481; + } + else + { + k_5 = 2.0f * (F32_sin((0.5f * theta_5))) / r_12; + } + float2 _S496 = _S480 * make_float2 (k_5); + FixedArray _S497 = dist_coeffs_8; + float2 _S498 = DistThinPrism_distort_0(_S496, &_S497); + *mean2d_8 = make_float2 (intrins_8.x * _S498.x + intrins_8.z, intrins_8.y * _S498.y + intrins_8.w); + _S477 = true; + break; + } + if(!_S477) + { + _S477 = false; + break; + } + Matrix J_11; + float2 _S499 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S500; + (&_S500)->primal_0 = _S478; + (&_S500)->differential_0 = _S499; + DiffPair_float_0 _S501 = s_fwd_length_impl_0(&_S500); + float _S502 = _S479; + DiffPair_float_0 _S503; + (&_S503)->primal_0 = _S501.primal_0; + (&_S503)->differential_0 = _S501.differential_0; + DiffPair_float_0 _S504; + (&_S504)->primal_0 = _S479; + (&_S504)->differential_0 = 0.0f; + DiffPair_float_0 _S505 = _d_atan2_1(&_S503, &_S504); + float s_diff_k_5; + if((_S501.primal_0) < 9.99999997475242708e-07f) + { + float _S506 = _S505.differential_0 * _S505.primal_0; + float _S507 = (0.0f - (_S506 + _S506) * 0.0416666679084301f) * _S479 / (_S479 * _S479); + k_5 = (1.0f - _S505.primal_0 * _S505.primal_0 / 24.0f) / _S479; + s_diff_k_5 = _S507; + } + else + { + float _S508 = _S505.differential_0 * 0.5f; + DiffPair_float_0 _S509; + (&_S509)->primal_0 = 0.5f * _S505.primal_0; + (&_S509)->differential_0 = _S508; + DiffPair_float_0 _S510 = _d_sin_1(&_S509); + float _S511 = 2.0f * _S510.primal_0; + float _S512 = (_S510.differential_0 * 2.0f * _S501.primal_0 - _S511 * _S501.differential_0) / (_S501.primal_0 * _S501.primal_0); + k_5 = _S511 / _S501.primal_0; + s_diff_k_5 = _S512; + } + float2 _S513 = _S478 * make_float2 (k_5); + float2 _S514 = _S499 * make_float2 (k_5) + make_float2 (s_diff_k_5) * _S478; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S515; + (&_S515)->primal_0 = _S513; + (&_S515)->differential_0 = _S514; + FixedArray _S516 = dist_coeffs_8; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S517 = s_fwd_DistThinPrism_distort_0(&_S515, &_S516); + float fx_8 = intrins_8.x; + float fy_8 = intrins_8.y; + float _S518 = _S517.differential_0.y * fy_8; + *&(((&J_11)->rows + (int(0)))->x) = _S517.differential_0.x * fx_8; + *&(((&J_11)->rows + (int(1)))->x) = _S518; + float2 _S519 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S520; + (&_S520)->primal_0 = _S478; + (&_S520)->differential_0 = _S519; + DiffPair_float_0 _S521 = s_fwd_length_impl_0(&_S520); + DiffPair_float_0 _S522; + (&_S522)->primal_0 = _S521.primal_0; + (&_S522)->differential_0 = _S521.differential_0; + DiffPair_float_0 _S523; + (&_S523)->primal_0 = _S502; + (&_S523)->differential_0 = 0.0f; + DiffPair_float_0 _S524 = _d_atan2_1(&_S522, &_S523); + if((_S521.primal_0) < 9.99999997475242708e-07f) + { + float _S525 = _S524.differential_0 * _S524.primal_0; + float _S526 = (0.0f - (_S525 + _S525) * 0.0416666679084301f) * _S479 / (_S479 * _S479); + k_5 = (1.0f - _S524.primal_0 * _S524.primal_0 / 24.0f) / _S479; + s_diff_k_5 = _S526; + } + else + { + float _S527 = _S524.differential_0 * 0.5f; + DiffPair_float_0 _S528; + (&_S528)->primal_0 = 0.5f * _S524.primal_0; + (&_S528)->differential_0 = _S527; + DiffPair_float_0 _S529 = _d_sin_1(&_S528); + float _S530 = 2.0f * _S529.primal_0; + float _S531 = (_S529.differential_0 * 2.0f * _S521.primal_0 - _S530 * _S521.differential_0) / (_S521.primal_0 * _S521.primal_0); + k_5 = _S530 / _S521.primal_0; + s_diff_k_5 = _S531; + } + float2 _S532 = _S478 * make_float2 (k_5); + float2 _S533 = _S519 * make_float2 (k_5) + make_float2 (s_diff_k_5) * _S478; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S534; + (&_S534)->primal_0 = _S532; + (&_S534)->differential_0 = _S533; + FixedArray _S535 = dist_coeffs_8; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S536 = s_fwd_DistThinPrism_distort_0(&_S534, &_S535); + float _S537 = _S536.differential_0.y * fy_8; + *&(((&J_11)->rows + (int(0)))->y) = _S536.differential_0.x * fx_8; + *&(((&J_11)->rows + (int(1)))->y) = _S537; + float2 _S538 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S539; + (&_S539)->primal_0 = _S478; + (&_S539)->differential_0 = _S538; + DiffPair_float_0 _S540 = s_fwd_length_impl_0(&_S539); + DiffPair_float_0 _S541; + (&_S541)->primal_0 = _S540.primal_0; + (&_S541)->differential_0 = _S540.differential_0; + DiffPair_float_0 _S542; + (&_S542)->primal_0 = _S479; + (&_S542)->differential_0 = 1.0f; + DiffPair_float_0 _S543 = _d_atan2_1(&_S541, &_S542); + if((_S540.primal_0) < 9.99999997475242708e-07f) + { + float _S544 = _S543.differential_0 * _S543.primal_0; + float _S545 = 1.0f - _S543.primal_0 * _S543.primal_0 / 24.0f; + float _S546 = ((0.0f - (_S544 + _S544) * 0.0416666679084301f) * _S479 - _S545) / (_S479 * _S479); + k_5 = _S545 / _S479; + s_diff_k_5 = _S546; + } + else + { + float _S547 = _S543.differential_0 * 0.5f; + DiffPair_float_0 _S548; + (&_S548)->primal_0 = 0.5f * _S543.primal_0; + (&_S548)->differential_0 = _S547; + DiffPair_float_0 _S549 = _d_sin_1(&_S548); + float _S550 = 2.0f * _S549.primal_0; + float _S551 = (_S549.differential_0 * 2.0f * _S540.primal_0 - _S550 * _S540.differential_0) / (_S540.primal_0 * _S540.primal_0); + k_5 = _S550 / _S540.primal_0; + s_diff_k_5 = _S551; + } + float2 _S552 = _S478 * make_float2 (k_5); + float2 _S553 = make_float2 (s_diff_k_5) * _S478; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S554; + (&_S554)->primal_0 = _S552; + (&_S554)->differential_0 = _S553; + FixedArray _S555 = dist_coeffs_8; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S556 = s_fwd_DistThinPrism_distort_0(&_S554, &_S555); + float _S557 = _S556.differential_0.y * fy_8; + *&(((&J_11)->rows + (int(0)))->z) = _S556.differential_0.x * fx_8; + *&(((&J_11)->rows + (int(1)))->z) = _S557; + *cov2d_8 = mul_4(mul_3(J_11, cov3d_8), transpose_1(J_11)); + _S477 = true; + break; + } + return _S477; +} + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistRational_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_3, FixedArray * coeffs_6) +{ + float u_4 = dpuv_3->primal_0.x; + float s_diff_u_2 = dpuv_3->differential_0.x; + float v_4 = dpuv_3->primal_0.y; + float s_diff_v_2 = dpuv_3->differential_0.y; + float _S558 = s_diff_u_2 * u_4; + float _S559 = s_diff_v_2 * v_4; + float r2_4 = u_4 * u_4 + v_4 * v_4; + float s_diff_r2_2 = _S558 + _S558 + (_S559 + _S559); + float _S560 = (*coeffs_6)[int(1)] + r2_4 * (*coeffs_6)[int(2)]; + float _S561 = (*coeffs_6)[int(0)] + r2_4 * _S560; + float _S562 = 1.0f + r2_4 * _S561; + float _S563 = (*coeffs_6)[int(4)] + r2_4 * (*coeffs_6)[int(5)]; + float _S564 = (*coeffs_6)[int(3)] + r2_4 * _S563; + float _S565 = 1.0f + r2_4 * _S564; + float radial_2 = _S562 / _S565; + float _S566 = 2.0f * (*coeffs_6)[int(6)]; + float _S567 = _S566 * u_4; + float _S568 = 2.0f * u_4; + float _S569 = 2.0f * (*coeffs_6)[int(7)]; + float _S570 = _S569 * u_4; + float _S571 = 2.0f * v_4; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S572 = { dpuv_3->primal_0 * make_float2 (radial_2) + make_float2 (_S567 * v_4 + (*coeffs_6)[int(7)] * (r2_4 + _S568 * u_4), _S570 * v_4 + (*coeffs_6)[int(6)] * (r2_4 + _S571 * v_4)), dpuv_3->differential_0 * make_float2 (radial_2) + make_float2 (((s_diff_r2_2 * _S561 + (s_diff_r2_2 * _S560 + s_diff_r2_2 * (*coeffs_6)[int(2)] * r2_4) * r2_4) * _S565 - _S562 * (s_diff_r2_2 * _S564 + (s_diff_r2_2 * _S563 + s_diff_r2_2 * (*coeffs_6)[int(5)] * r2_4) * r2_4)) / (_S565 * _S565)) * dpuv_3->primal_0 + make_float2 (s_diff_u_2 * _S566 * v_4 + s_diff_v_2 * _S567 + (s_diff_r2_2 + (s_diff_u_2 * 2.0f * u_4 + s_diff_u_2 * _S568)) * (*coeffs_6)[int(7)], s_diff_u_2 * _S569 * v_4 + s_diff_v_2 * _S570 + (s_diff_r2_2 + (s_diff_v_2 * 2.0f * v_4 + s_diff_v_2 * _S571)) * (*coeffs_6)[int(6)]) }; + return _S572; +} + +inline __device__ float2 DistRational_distort_0(float2 uv_6, FixedArray * coeffs_7) +{ + float u_5 = uv_6.x; + float v_5 = uv_6.y; + float r2_5 = u_5 * u_5 + v_5 * v_5; + return uv_6 * make_float2 ((1.0f + r2_5 * ((*coeffs_7)[int(0)] + r2_5 * ((*coeffs_7)[int(1)] + r2_5 * (*coeffs_7)[int(2)]))) / (1.0f + r2_5 * ((*coeffs_7)[int(3)] + r2_5 * ((*coeffs_7)[int(4)] + r2_5 * (*coeffs_7)[int(5)])))) + make_float2 (2.0f * (*coeffs_7)[int(6)] * u_5 * v_5 + (*coeffs_7)[int(7)] * (r2_5 + 2.0f * u_5 * u_5), 2.0f * (*coeffs_7)[int(7)] * u_5 * v_5 + (*coeffs_7)[int(6)] * (r2_5 + 2.0f * v_5 * v_5)); +} + +inline __device__ bool persp_proj_3dgs_nav_rational(float3 mean3d_9, Matrix cov3d_9, float4 intrins_9, FixedArray dist_coeffs_9, uint width_3, uint height_3, Matrix * cov2d_9, float2 * mean2d_9) +{ + bool _S573; + float2 _S574; + float _S575; + for(;;) + { + float cx_3 = intrins_9.z; + float cy_3 = intrins_9.w; + *cov2d_9 = makeMatrix (0.0f); + for(;;) + { + float2 _S576 = float2 {mean3d_9.x, mean3d_9.y}; + _S574 = _S576; + float _S577 = mean3d_9.z; + _S575 = _S577; + float2 uv0_3 = _S576 / make_float2 (_S577); + if(_S577 < 0.0f) + { + _S573 = true; + } + else + { + float2 _S578 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S579; + (&_S579)->primal_0 = uv0_3; + (&_S579)->differential_0 = _S578; + FixedArray _S580 = dist_coeffs_9; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S581 = s_fwd_DistRational_distort_0(&_S579, &_S580); + float2 _S582 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S583; + (&_S583)->primal_0 = uv0_3; + (&_S583)->differential_0 = _S582; + FixedArray _S584 = dist_coeffs_9; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S585 = s_fwd_DistRational_distort_0(&_S583, &_S584); + Matrix _S586 = transpose_0(makeMatrix (_S581.differential_0, _S585.differential_0)); + float _S587 = (F32_min((determinant_0(_S586)), ((F32_min((_S586.rows[int(0)].x), (_S586.rows[int(1)].y)))))); + if(_S587 > 0.25f) + { + _S573 = _S587 < 4.0f; + } + else + { + _S573 = false; + } + if(_S573) + { + FixedArray _S588 = dist_coeffs_9; + float2 _S589 = DistRational_distort_0(uv0_3, &_S588); + _S573 = (dot_0(uv0_3, _S589)) >= 0.0f; + } + else + { + _S573 = false; + } + _S573 = !_S573; + } + if(_S573) + { + *mean2d_9 = uv0_3; + _S573 = false; + break; + } + float2 uv_7 = _S576 / make_float2 (_S577); + FixedArray _S590 = dist_coeffs_9; + float2 _S591 = DistRational_distort_0(uv_7, &_S590); + *mean2d_9 = make_float2 (intrins_9.x * _S591.x + cx_3, intrins_9.y * _S591.y + cy_3); + _S573 = true; + break; + } + if(!_S573) + { + _S573 = false; + break; + } + Matrix J_12; + float _S592 = _S575 * _S575; + float2 s_diff_uv_9 = make_float2 (1.0f, 0.0f) * make_float2 (_S575) / make_float2 (_S592); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S593; + (&_S593)->primal_0 = _S574 / make_float2 (_S575); + (&_S593)->differential_0 = s_diff_uv_9; + FixedArray _S594 = dist_coeffs_9; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S595 = s_fwd_DistRational_distort_0(&_S593, &_S594); + float fx_9 = intrins_9.x; + float fy_9 = intrins_9.y; + float _S596 = _S595.differential_0.y * fy_9; + Matrix J_13; + *&(((&J_13)->rows + (int(0)))->x) = _S595.differential_0.x * fx_9; + *&(((&J_13)->rows + (int(1)))->x) = _S596; + float2 s_diff_uv_10 = make_float2 (0.0f, 1.0f) * make_float2 (_S575) / make_float2 (_S592); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S597; + (&_S597)->primal_0 = _S574 / make_float2 (_S575); + (&_S597)->differential_0 = s_diff_uv_10; + FixedArray _S598 = dist_coeffs_9; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S599 = s_fwd_DistRational_distort_0(&_S597, &_S598); + float _S600 = _S599.differential_0.y * fy_9; + *&(((&J_13)->rows + (int(0)))->y) = _S599.differential_0.x * fx_9; + *&(((&J_13)->rows + (int(1)))->y) = _S600; + float2 s_diff_uv_11 = (make_float2 (0.0f, 0.0f) - _S574) / make_float2 (_S592); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S601; + (&_S601)->primal_0 = _S574 / make_float2 (_S575); + (&_S601)->differential_0 = s_diff_uv_11; + FixedArray _S602 = dist_coeffs_9; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S603 = s_fwd_DistRational_distort_0(&_S601, &_S602); + float _S604 = _S603.differential_0.y * fy_9; + *&(((&J_13)->rows + (int(0)))->z) = _S603.differential_0.x * fx_9; + *&(((&J_13)->rows + (int(1)))->z) = _S604; + J_12 = J_13; + float _S605 = float(width_3); + float _S606 = 0.30000001192092896f * (0.5f * _S605); + float lim_x_pos_3 = _S605 + _S606; + float rz_3 = 1.0f / _S575; + float _S607 = - _S606; + float max_Jyz_3 = - (_S607 - cy_3) * rz_3; + float min_Jyz_3 = - (lim_x_pos_3 - cy_3) * rz_3; + *&(((&J_12)->rows + (int(0)))->z) = clamp_0(*&(((&J_12)->rows + (int(0)))->z), - (lim_x_pos_3 - cx_3) * rz_3, - (_S607 - cx_3) * rz_3); + *&(((&J_12)->rows + (int(1)))->z) = clamp_0(*&(((&J_12)->rows + (int(1)))->z), min_Jyz_3, max_Jyz_3); + *cov2d_9 = mul_4(mul_3(J_12, cov3d_9), transpose_1(J_12)); + _S573 = true; + break; + } + return _S573; +} + +inline __device__ bool fisheye_proj_3dgs_nav_rational(float3 mean3d_10, Matrix cov3d_10, float4 intrins_10, FixedArray dist_coeffs_10, Matrix * cov2d_10, float2 * mean2d_10) +{ + bool _S608; + float2 _S609; + float _S610; + for(;;) + { + float k_6; + *cov2d_10 = makeMatrix (0.0f); + for(;;) + { + float2 _S611 = float2 {mean3d_10.x, mean3d_10.y}; + _S609 = _S611; + float r_13 = length_0(_S611); + float _S612 = mean3d_10.z; + _S610 = _S612; + float theta_6 = (F32_atan2((r_13), (_S612))); + bool _S613 = theta_6 < 0.00100000004749745f; + if(_S613) + { + k_6 = (1.0f - theta_6 * theta_6 / 3.0f) / _S612; + } + else + { + k_6 = theta_6 / r_13; + } + float2 _S614 = _S611 * make_float2 (k_6); + float2 _S615 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S616; + (&_S616)->primal_0 = _S614; + (&_S616)->differential_0 = _S615; + FixedArray _S617 = dist_coeffs_10; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S618 = s_fwd_DistRational_distort_0(&_S616, &_S617); + float2 _S619 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S620; + (&_S620)->primal_0 = _S614; + (&_S620)->differential_0 = _S619; + FixedArray _S621 = dist_coeffs_10; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S622 = s_fwd_DistRational_distort_0(&_S620, &_S621); + Matrix _S623 = transpose_0(makeMatrix (_S618.differential_0, _S622.differential_0)); + float _S624 = (F32_min((determinant_0(_S623)), ((F32_min((_S623.rows[int(0)].x), (_S623.rows[int(1)].y)))))); + if(_S624 > 0.25f) + { + _S608 = _S624 < 4.0f; + } + else + { + _S608 = false; + } + if(_S608) + { + FixedArray _S625 = dist_coeffs_10; + float2 _S626 = DistRational_distort_0(_S614, &_S625); + _S608 = (dot_0(_S614, _S626)) >= 0.0f; + } + else + { + _S608 = false; + } + if(!_S608) + { + *mean2d_10 = _S614; + _S608 = false; + break; + } + if(_S613) + { + k_6 = (1.0f - theta_6 * theta_6 / 3.0f) / _S612; + } + else + { + k_6 = theta_6 / r_13; + } + float2 _S627 = _S611 * make_float2 (k_6); + FixedArray _S628 = dist_coeffs_10; + float2 _S629 = DistRational_distort_0(_S627, &_S628); + *mean2d_10 = make_float2 (intrins_10.x * _S629.x + intrins_10.z, intrins_10.y * _S629.y + intrins_10.w); + _S608 = true; + break; + } + if(!_S608) + { + _S608 = false; + break; + } + Matrix J_14; + float2 _S630 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S631; + (&_S631)->primal_0 = _S609; + (&_S631)->differential_0 = _S630; + DiffPair_float_0 _S632 = s_fwd_length_impl_0(&_S631); + float _S633 = _S610; + DiffPair_float_0 _S634; + (&_S634)->primal_0 = _S632.primal_0; + (&_S634)->differential_0 = _S632.differential_0; + DiffPair_float_0 _S635; + (&_S635)->primal_0 = _S610; + (&_S635)->differential_0 = 0.0f; + DiffPair_float_0 _S636 = _d_atan2_1(&_S634, &_S635); + float s_diff_k_6; + if((_S636.primal_0) < 0.00100000004749745f) + { + float _S637 = _S636.differential_0 * _S636.primal_0; + float _S638 = (0.0f - (_S637 + _S637) * 0.3333333432674408f) * _S610 / (_S610 * _S610); + k_6 = (1.0f - _S636.primal_0 * _S636.primal_0 / 3.0f) / _S610; + s_diff_k_6 = _S638; + } + else + { + float _S639 = (_S636.differential_0 * _S632.primal_0 - _S636.primal_0 * _S632.differential_0) / (_S632.primal_0 * _S632.primal_0); + k_6 = _S636.primal_0 / _S632.primal_0; + s_diff_k_6 = _S639; + } + float2 _S640 = _S609 * make_float2 (k_6); + float2 _S641 = _S630 * make_float2 (k_6) + make_float2 (s_diff_k_6) * _S609; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S642; + (&_S642)->primal_0 = _S640; + (&_S642)->differential_0 = _S641; + FixedArray _S643 = dist_coeffs_10; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S644 = s_fwd_DistRational_distort_0(&_S642, &_S643); + float fx_10 = intrins_10.x; + float fy_10 = intrins_10.y; + float _S645 = _S644.differential_0.y * fy_10; + *&(((&J_14)->rows + (int(0)))->x) = _S644.differential_0.x * fx_10; + *&(((&J_14)->rows + (int(1)))->x) = _S645; + float2 _S646 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S647; + (&_S647)->primal_0 = _S609; + (&_S647)->differential_0 = _S646; + DiffPair_float_0 _S648 = s_fwd_length_impl_0(&_S647); + DiffPair_float_0 _S649; + (&_S649)->primal_0 = _S648.primal_0; + (&_S649)->differential_0 = _S648.differential_0; + DiffPair_float_0 _S650; + (&_S650)->primal_0 = _S633; + (&_S650)->differential_0 = 0.0f; + DiffPair_float_0 _S651 = _d_atan2_1(&_S649, &_S650); + if((_S651.primal_0) < 0.00100000004749745f) + { + float _S652 = _S651.differential_0 * _S651.primal_0; + float _S653 = (0.0f - (_S652 + _S652) * 0.3333333432674408f) * _S610 / (_S610 * _S610); + k_6 = (1.0f - _S651.primal_0 * _S651.primal_0 / 3.0f) / _S610; + s_diff_k_6 = _S653; + } + else + { + float _S654 = (_S651.differential_0 * _S648.primal_0 - _S651.primal_0 * _S648.differential_0) / (_S648.primal_0 * _S648.primal_0); + k_6 = _S651.primal_0 / _S648.primal_0; + s_diff_k_6 = _S654; + } + float2 _S655 = _S609 * make_float2 (k_6); + float2 _S656 = _S646 * make_float2 (k_6) + make_float2 (s_diff_k_6) * _S609; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S657; + (&_S657)->primal_0 = _S655; + (&_S657)->differential_0 = _S656; + FixedArray _S658 = dist_coeffs_10; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S659 = s_fwd_DistRational_distort_0(&_S657, &_S658); + float _S660 = _S659.differential_0.y * fy_10; + *&(((&J_14)->rows + (int(0)))->y) = _S659.differential_0.x * fx_10; + *&(((&J_14)->rows + (int(1)))->y) = _S660; + float2 _S661 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S662; + (&_S662)->primal_0 = _S609; + (&_S662)->differential_0 = _S661; + DiffPair_float_0 _S663 = s_fwd_length_impl_0(&_S662); + DiffPair_float_0 _S664; + (&_S664)->primal_0 = _S663.primal_0; + (&_S664)->differential_0 = _S663.differential_0; + DiffPair_float_0 _S665; + (&_S665)->primal_0 = _S610; + (&_S665)->differential_0 = 1.0f; + DiffPair_float_0 _S666 = _d_atan2_1(&_S664, &_S665); + if((_S666.primal_0) < 0.00100000004749745f) + { + float _S667 = _S666.differential_0 * _S666.primal_0; + float _S668 = 1.0f - _S666.primal_0 * _S666.primal_0 / 3.0f; + float _S669 = ((0.0f - (_S667 + _S667) * 0.3333333432674408f) * _S610 - _S668) / (_S610 * _S610); + k_6 = _S668 / _S610; + s_diff_k_6 = _S669; + } + else + { + float _S670 = (_S666.differential_0 * _S663.primal_0 - _S666.primal_0 * _S663.differential_0) / (_S663.primal_0 * _S663.primal_0); + k_6 = _S666.primal_0 / _S663.primal_0; + s_diff_k_6 = _S670; + } + float2 _S671 = _S609 * make_float2 (k_6); + float2 _S672 = make_float2 (s_diff_k_6) * _S609; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S673; + (&_S673)->primal_0 = _S671; + (&_S673)->differential_0 = _S672; + FixedArray _S674 = dist_coeffs_10; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S675 = s_fwd_DistRational_distort_0(&_S673, &_S674); + float _S676 = _S675.differential_0.y * fy_10; + *&(((&J_14)->rows + (int(0)))->z) = _S675.differential_0.x * fx_10; + *&(((&J_14)->rows + (int(1)))->z) = _S676; + *cov2d_10 = mul_4(mul_3(J_14, cov3d_10), transpose_1(J_14)); + _S608 = true; + break; + } + return _S608; +} + +inline __device__ bool equisolid_proj_3dgs_nav_rational(float3 mean3d_11, Matrix cov3d_11, float4 intrins_11, FixedArray dist_coeffs_11, Matrix * cov2d_11, float2 * mean2d_11) +{ + bool _S677; + float2 _S678; + float _S679; + for(;;) + { + float k_7; + *cov2d_11 = makeMatrix (0.0f); + for(;;) + { + float2 _S680 = float2 {mean3d_11.x, mean3d_11.y}; + _S678 = _S680; + float r_14 = length_0(_S680); + float _S681 = mean3d_11.z; + _S679 = _S681; + float theta_7 = (F32_atan2((r_14), (_S681))); + bool _S682 = r_14 < 9.99999997475242708e-07f; + if(_S682) + { + k_7 = (1.0f - theta_7 * theta_7 / 24.0f) / _S681; + } + else + { + k_7 = 2.0f * (F32_sin((0.5f * theta_7))) / r_14; + } + float2 _S683 = _S680 * make_float2 (k_7); + float2 _S684 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S685; + (&_S685)->primal_0 = _S683; + (&_S685)->differential_0 = _S684; + FixedArray _S686 = dist_coeffs_11; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S687 = s_fwd_DistRational_distort_0(&_S685, &_S686); + float2 _S688 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S689; + (&_S689)->primal_0 = _S683; + (&_S689)->differential_0 = _S688; + FixedArray _S690 = dist_coeffs_11; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S691 = s_fwd_DistRational_distort_0(&_S689, &_S690); + Matrix _S692 = transpose_0(makeMatrix (_S687.differential_0, _S691.differential_0)); + float _S693 = (F32_min((determinant_0(_S692)), ((F32_min((_S692.rows[int(0)].x), (_S692.rows[int(1)].y)))))); + if(_S693 > 0.25f) + { + _S677 = _S693 < 4.0f; + } + else + { + _S677 = false; + } + if(_S677) + { + FixedArray _S694 = dist_coeffs_11; + float2 _S695 = DistRational_distort_0(_S683, &_S694); + _S677 = (dot_0(_S683, _S695)) >= 0.0f; + } + else + { + _S677 = false; + } + if(!_S677) + { + *mean2d_11 = _S683; + _S677 = false; + break; + } + if(_S682) + { + k_7 = (1.0f - theta_7 * theta_7 / 24.0f) / _S681; + } + else + { + k_7 = 2.0f * (F32_sin((0.5f * theta_7))) / r_14; + } + float2 _S696 = _S680 * make_float2 (k_7); + FixedArray _S697 = dist_coeffs_11; + float2 _S698 = DistRational_distort_0(_S696, &_S697); + *mean2d_11 = make_float2 (intrins_11.x * _S698.x + intrins_11.z, intrins_11.y * _S698.y + intrins_11.w); + _S677 = true; + break; + } + if(!_S677) + { + _S677 = false; + break; + } + Matrix J_15; + float2 _S699 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S700; + (&_S700)->primal_0 = _S678; + (&_S700)->differential_0 = _S699; + DiffPair_float_0 _S701 = s_fwd_length_impl_0(&_S700); + float _S702 = _S679; + DiffPair_float_0 _S703; + (&_S703)->primal_0 = _S701.primal_0; + (&_S703)->differential_0 = _S701.differential_0; + DiffPair_float_0 _S704; + (&_S704)->primal_0 = _S679; + (&_S704)->differential_0 = 0.0f; + DiffPair_float_0 _S705 = _d_atan2_1(&_S703, &_S704); + float s_diff_k_7; + if((_S701.primal_0) < 9.99999997475242708e-07f) + { + float _S706 = _S705.differential_0 * _S705.primal_0; + float _S707 = (0.0f - (_S706 + _S706) * 0.0416666679084301f) * _S679 / (_S679 * _S679); + k_7 = (1.0f - _S705.primal_0 * _S705.primal_0 / 24.0f) / _S679; + s_diff_k_7 = _S707; + } + else + { + float _S708 = _S705.differential_0 * 0.5f; + DiffPair_float_0 _S709; + (&_S709)->primal_0 = 0.5f * _S705.primal_0; + (&_S709)->differential_0 = _S708; + DiffPair_float_0 _S710 = _d_sin_1(&_S709); + float _S711 = 2.0f * _S710.primal_0; + float _S712 = (_S710.differential_0 * 2.0f * _S701.primal_0 - _S711 * _S701.differential_0) / (_S701.primal_0 * _S701.primal_0); + k_7 = _S711 / _S701.primal_0; + s_diff_k_7 = _S712; + } + float2 _S713 = _S678 * make_float2 (k_7); + float2 _S714 = _S699 * make_float2 (k_7) + make_float2 (s_diff_k_7) * _S678; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S715; + (&_S715)->primal_0 = _S713; + (&_S715)->differential_0 = _S714; + FixedArray _S716 = dist_coeffs_11; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S717 = s_fwd_DistRational_distort_0(&_S715, &_S716); + float fx_11 = intrins_11.x; + float fy_11 = intrins_11.y; + float _S718 = _S717.differential_0.y * fy_11; + *&(((&J_15)->rows + (int(0)))->x) = _S717.differential_0.x * fx_11; + *&(((&J_15)->rows + (int(1)))->x) = _S718; + float2 _S719 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S720; + (&_S720)->primal_0 = _S678; + (&_S720)->differential_0 = _S719; + DiffPair_float_0 _S721 = s_fwd_length_impl_0(&_S720); + DiffPair_float_0 _S722; + (&_S722)->primal_0 = _S721.primal_0; + (&_S722)->differential_0 = _S721.differential_0; + DiffPair_float_0 _S723; + (&_S723)->primal_0 = _S702; + (&_S723)->differential_0 = 0.0f; + DiffPair_float_0 _S724 = _d_atan2_1(&_S722, &_S723); + if((_S721.primal_0) < 9.99999997475242708e-07f) + { + float _S725 = _S724.differential_0 * _S724.primal_0; + float _S726 = (0.0f - (_S725 + _S725) * 0.0416666679084301f) * _S679 / (_S679 * _S679); + k_7 = (1.0f - _S724.primal_0 * _S724.primal_0 / 24.0f) / _S679; + s_diff_k_7 = _S726; + } + else + { + float _S727 = _S724.differential_0 * 0.5f; + DiffPair_float_0 _S728; + (&_S728)->primal_0 = 0.5f * _S724.primal_0; + (&_S728)->differential_0 = _S727; + DiffPair_float_0 _S729 = _d_sin_1(&_S728); + float _S730 = 2.0f * _S729.primal_0; + float _S731 = (_S729.differential_0 * 2.0f * _S721.primal_0 - _S730 * _S721.differential_0) / (_S721.primal_0 * _S721.primal_0); + k_7 = _S730 / _S721.primal_0; + s_diff_k_7 = _S731; + } + float2 _S732 = _S678 * make_float2 (k_7); + float2 _S733 = _S719 * make_float2 (k_7) + make_float2 (s_diff_k_7) * _S678; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S734; + (&_S734)->primal_0 = _S732; + (&_S734)->differential_0 = _S733; + FixedArray _S735 = dist_coeffs_11; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S736 = s_fwd_DistRational_distort_0(&_S734, &_S735); + float _S737 = _S736.differential_0.y * fy_11; + *&(((&J_15)->rows + (int(0)))->y) = _S736.differential_0.x * fx_11; + *&(((&J_15)->rows + (int(1)))->y) = _S737; + float2 _S738 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S739; + (&_S739)->primal_0 = _S678; + (&_S739)->differential_0 = _S738; + DiffPair_float_0 _S740 = s_fwd_length_impl_0(&_S739); + DiffPair_float_0 _S741; + (&_S741)->primal_0 = _S740.primal_0; + (&_S741)->differential_0 = _S740.differential_0; + DiffPair_float_0 _S742; + (&_S742)->primal_0 = _S679; + (&_S742)->differential_0 = 1.0f; + DiffPair_float_0 _S743 = _d_atan2_1(&_S741, &_S742); + if((_S740.primal_0) < 9.99999997475242708e-07f) + { + float _S744 = _S743.differential_0 * _S743.primal_0; + float _S745 = 1.0f - _S743.primal_0 * _S743.primal_0 / 24.0f; + float _S746 = ((0.0f - (_S744 + _S744) * 0.0416666679084301f) * _S679 - _S745) / (_S679 * _S679); + k_7 = _S745 / _S679; + s_diff_k_7 = _S746; + } + else + { + float _S747 = _S743.differential_0 * 0.5f; + DiffPair_float_0 _S748; + (&_S748)->primal_0 = 0.5f * _S743.primal_0; + (&_S748)->differential_0 = _S747; + DiffPair_float_0 _S749 = _d_sin_1(&_S748); + float _S750 = 2.0f * _S749.primal_0; + float _S751 = (_S749.differential_0 * 2.0f * _S740.primal_0 - _S750 * _S740.differential_0) / (_S740.primal_0 * _S740.primal_0); + k_7 = _S750 / _S740.primal_0; + s_diff_k_7 = _S751; + } + float2 _S752 = _S678 * make_float2 (k_7); + float2 _S753 = make_float2 (s_diff_k_7) * _S678; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S754; + (&_S754)->primal_0 = _S752; + (&_S754)->differential_0 = _S753; + FixedArray _S755 = dist_coeffs_11; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S756 = s_fwd_DistRational_distort_0(&_S754, &_S755); + float _S757 = _S756.differential_0.y * fy_11; + *&(((&J_15)->rows + (int(0)))->z) = _S756.differential_0.x * fx_11; + *&(((&J_15)->rows + (int(1)))->z) = _S757; + *cov2d_11 = mul_4(mul_3(J_15, cov3d_11), transpose_1(J_15)); + _S677 = true; + break; + } + return _S677; +} + +inline __device__ bool equirect_proj_3dgs_nav(float3 mean3d_12, Matrix cov3d_12, float4 intrins_12, Matrix * cov2d_12, float2 * mean2d_12) +{ + float _S758 = mean3d_12.x; + float _S759 = mean3d_12.z; + float _S760 = mean3d_12.y; + float2 _S761 = float2 {mean3d_12.x, mean3d_12.z}; + float fx_12 = intrins_12.x; + float fy_12 = intrins_12.y; + *mean2d_12 = make_float2 (fx_12 * (F32_atan2((_S758), (_S759))) + intrins_12.z, fy_12 * (F32_atan2((_S760), (length_0(_S761)))) + intrins_12.w); + DiffPair_float_0 _S762; + (&_S762)->primal_0 = _S758; + (&_S762)->differential_0 = 1.0f; + DiffPair_float_0 _S763; + (&_S763)->primal_0 = _S759; + (&_S763)->differential_0 = 0.0f; + DiffPair_float_0 _S764 = _d_atan2_1(&_S762, &_S763); + float2 _S765 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S766; + (&_S766)->primal_0 = _S761; + (&_S766)->differential_0 = _S765; + DiffPair_float_0 _S767 = s_fwd_length_impl_0(&_S766); + DiffPair_float_0 _S768; + (&_S768)->primal_0 = _S760; + (&_S768)->differential_0 = 0.0f; + DiffPair_float_0 _S769; + (&_S769)->primal_0 = _S767.primal_0; + (&_S769)->differential_0 = _S767.differential_0; + DiffPair_float_0 _S770 = _d_atan2_1(&_S768, &_S769); + float _S771 = _S770.differential_0 * fy_12; + Matrix J_16; + *&(((&J_16)->rows + (int(0)))->x) = _S764.differential_0 * fx_12; + *&(((&J_16)->rows + (int(1)))->x) = _S771; + DiffPair_float_0 _S772; + (&_S772)->primal_0 = _S758; + (&_S772)->differential_0 = 0.0f; + DiffPair_float_0 _S773; + (&_S773)->primal_0 = _S759; + (&_S773)->differential_0 = 0.0f; + DiffPair_float_0 _S774 = _d_atan2_1(&_S772, &_S773); + float2 _S775 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S776; + (&_S776)->primal_0 = _S761; + (&_S776)->differential_0 = _S775; + DiffPair_float_0 _S777 = s_fwd_length_impl_0(&_S776); + DiffPair_float_0 _S778; + (&_S778)->primal_0 = _S760; + (&_S778)->differential_0 = 1.0f; + DiffPair_float_0 _S779; + (&_S779)->primal_0 = _S777.primal_0; + (&_S779)->differential_0 = _S777.differential_0; + DiffPair_float_0 _S780 = _d_atan2_1(&_S778, &_S779); + float _S781 = _S780.differential_0 * fy_12; + *&(((&J_16)->rows + (int(0)))->y) = _S774.differential_0 * fx_12; + *&(((&J_16)->rows + (int(1)))->y) = _S781; + DiffPair_float_0 _S782; + (&_S782)->primal_0 = _S758; + (&_S782)->differential_0 = 0.0f; + DiffPair_float_0 _S783; + (&_S783)->primal_0 = _S759; + (&_S783)->differential_0 = 1.0f; + DiffPair_float_0 _S784 = _d_atan2_1(&_S782, &_S783); + float2 _S785 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S786; + (&_S786)->primal_0 = _S761; + (&_S786)->differential_0 = _S785; + DiffPair_float_0 _S787 = s_fwd_length_impl_0(&_S786); + DiffPair_float_0 _S788; + (&_S788)->primal_0 = _S760; + (&_S788)->differential_0 = 0.0f; + DiffPair_float_0 _S789; + (&_S789)->primal_0 = _S787.primal_0; + (&_S789)->differential_0 = _S787.differential_0; + DiffPair_float_0 _S790 = _d_atan2_1(&_S788, &_S789); + float _S791 = _S790.differential_0 * fy_12; + *&(((&J_16)->rows + (int(0)))->z) = _S784.differential_0 * fx_12; + *&(((&J_16)->rows + (int(1)))->z) = _S791; + *cov2d_12 = mul_4(mul_3(J_16, cov3d_12), transpose_1(J_16)); return true; } @@ -1531,25 +3037,25 @@ inline __device__ float2 max_0(float2 x_12, float2 y_4) inline __device__ void _d_mul_0(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * left_6, DiffPair_vectorx3Cfloatx2C3x3E_0 * right_6, float3 dOut_11) { - float _S320 = (*left_6).primal_0.rows[int(0)].x * dOut_11.x; + float _S792 = (*left_6).primal_0.rows[int(0)].x * dOut_11.x; Matrix left_d_result_3; *&(((&left_d_result_3)->rows + (int(0)))->x) = (*right_6).primal_0.x * dOut_11.x; - float sum_6 = _S320 + (*left_6).primal_0.rows[int(1)].x * dOut_11.y; + float sum_6 = _S792 + (*left_6).primal_0.rows[int(1)].x * dOut_11.y; *&(((&left_d_result_3)->rows + (int(1)))->x) = (*right_6).primal_0.x * dOut_11.y; float sum_7 = sum_6 + (*left_6).primal_0.rows[int(2)].x * dOut_11.z; *&(((&left_d_result_3)->rows + (int(2)))->x) = (*right_6).primal_0.x * dOut_11.z; float3 right_d_result_3; *&((&right_d_result_3)->x) = sum_7; - float _S321 = (*left_6).primal_0.rows[int(0)].y * dOut_11.x; + float _S793 = (*left_6).primal_0.rows[int(0)].y * dOut_11.x; *&(((&left_d_result_3)->rows + (int(0)))->y) = (*right_6).primal_0.y * dOut_11.x; - float sum_8 = _S321 + (*left_6).primal_0.rows[int(1)].y * dOut_11.y; + float sum_8 = _S793 + (*left_6).primal_0.rows[int(1)].y * dOut_11.y; *&(((&left_d_result_3)->rows + (int(1)))->y) = (*right_6).primal_0.y * dOut_11.y; float sum_9 = sum_8 + (*left_6).primal_0.rows[int(2)].y * dOut_11.z; *&(((&left_d_result_3)->rows + (int(2)))->y) = (*right_6).primal_0.y * dOut_11.z; *&((&right_d_result_3)->y) = sum_9; - float _S322 = (*left_6).primal_0.rows[int(0)].z * dOut_11.x; + float _S794 = (*left_6).primal_0.rows[int(0)].z * dOut_11.x; *&(((&left_d_result_3)->rows + (int(0)))->z) = (*right_6).primal_0.z * dOut_11.x; - float sum_10 = _S322 + (*left_6).primal_0.rows[int(1)].z * dOut_11.y; + float sum_10 = _S794 + (*left_6).primal_0.rows[int(1)].z * dOut_11.y; *&(((&left_d_result_3)->rows + (int(1)))->z) = (*right_6).primal_0.z * dOut_11.y; float sum_11 = sum_10 + (*left_6).primal_0.rows[int(2)].z * dOut_11.z; *&(((&left_d_result_3)->rows + (int(2)))->z) = (*right_6).primal_0.z * dOut_11.z; @@ -1631,9 +3137,9 @@ inline __device__ float2 mul_7(Matrix left_8, float2 right_8) inline __device__ void _d_exp_0(DiffPair_float_0 * dpx_12, float dOut_12) { - float _S323 = (F32_exp(((*dpx_12).primal_0))) * dOut_12; + float _S795 = (F32_exp(((*dpx_12).primal_0))) * dOut_12; dpx_12->primal_0 = (*dpx_12).primal_0; - dpx_12->differential_0 = _S323; + dpx_12->differential_0 = _S795; return; } @@ -1658,9 +3164,9 @@ inline __device__ float3 exp_0(float3 x_13) inline __device__ void _d_exp_vector_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_13, float3 dOut_13) { - float3 _S324 = exp_0((*dpx_13).primal_0) * dOut_13; + float3 _S796 = exp_0((*dpx_13).primal_0) * dOut_13; dpx_13->primal_0 = (*dpx_13).primal_0; - dpx_13->differential_0 = _S324; + dpx_13->differential_0 = _S796; return; } @@ -1671,9 +3177,9 @@ inline __device__ float4 normalize_0(float4 x_14) inline __device__ void _d_log_0(DiffPair_float_0 * dpx_14, float dOut_14) { - float _S325 = 1.0f / (*dpx_14).primal_0 * dOut_14; + float _S797 = 1.0f / (*dpx_14).primal_0 * dOut_14; dpx_14->primal_0 = (*dpx_14).primal_0; - dpx_14->differential_0 = _S325; + dpx_14->differential_0 = _S797; return; } @@ -1684,161 +3190,119 @@ inline __device__ float view_radius_3dgs_0(float3 mean_0, float3 log_scale_0, return radius_0 / ((F32_max((dist_0), (radius_0))) + (F32_sqrt(((F32_max((dist_0 * dist_0 - radius_0 * radius_0), (0.0f))))))); } -inline __device__ void projection_3dgs_persp(bool antialiased_0, float3 mean_1, float4 quat_0, float3 scale_0, float in_opacity_0, Matrix R_0, float3 t_0, float fx_4, float fy_4, float cx_1, float cy_1, FixedArray dist_coeffs_4, uint image_width_0, uint image_height_0, float4 * aabb_xyxy_0, float * sorting_depth_0, float * radius_1, float2 * mean2d_4, float * depth_0, float3 * conic_0, float * opacity_0) +inline __device__ void projection_3dgs_persp_none(bool antialiased_0, float3 mean_1, float4 quat_0, float3 scale_0, float in_opacity_0, Matrix R_0, float3 t_0, float fx_13, float fy_13, float cx_4, float cy_4, FixedArray dist_coeffs_12, uint image_width_0, uint image_height_0, float4 * aabb_xyxy_0, float * sorting_depth_0, float * radius_1, float2 * mean2d_13, float * depth_0, float3 * conic_0, float * opacity_0) { - float2 _S326; + float2 _S798; for(;;) { + float4 _S799 = make_float4 (0.0f); + *aabb_xyxy_0 = _S799; + *sorting_depth_0 = 0.0f; + *radius_1 = 0.0f; + *mean2d_13 = make_float2 (0.0f); + *conic_0 = make_float3 (0.0f); + *opacity_0 = 0.0f; float3 mean_c_0 = mul_6(R_0, mean_1) + t_0; - float _S327 = mean_c_0.z; + float _S800 = mean_c_0.z; *depth_0 = length_1(mean_c_0); - if(_S327 <= 0.0f) + if(_S800 <= 0.0f) { - *aabb_xyxy_0 = make_float4 (0.0f); + *aabb_xyxy_0 = _S799; break; } Matrix covar2d_0; + Matrix _S801 = makeMatrix (0.0f); *opacity_0 = 1.0f / (1.0f + (F32_exp((- in_opacity_0)))); - bool _S328; - float4 _S329 = normalize_0(quat_0); - float3 _S330 = exp_0(scale_0); - float x_15 = _S329.y; + bool _S802; + float4 _S803 = normalize_0(quat_0); + float3 _S804 = exp_0(scale_0); + float x_15 = _S803.y; float x2_0 = x_15 * x_15; - float y2_0 = _S329.z * _S329.z; - float z2_0 = _S329.w * _S329.w; - float xy_0 = _S329.y * _S329.z; - float xz_0 = _S329.y * _S329.w; - float yz_0 = _S329.z * _S329.w; - float wx_0 = _S329.x * _S329.y; - float wy_0 = _S329.x * _S329.z; - float wz_0 = _S329.x * _S329.w; - Matrix M_0 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_0 + z2_0), 2.0f * (xy_0 + wz_0), 2.0f * (xz_0 - wy_0), 2.0f * (xy_0 - wz_0), 1.0f - 2.0f * (x2_0 + z2_0), 2.0f * (yz_0 + wx_0), 2.0f * (xz_0 + wy_0), 2.0f * (yz_0 - wx_0), 1.0f - 2.0f * (x2_0 + y2_0))), makeMatrix (_S330.x, 0.0f, 0.0f, 0.0f, _S330.y, 0.0f, 0.0f, 0.0f, _S330.z)); - Matrix _S331 = transpose_3(R_0); - Matrix covar_c_0 = mul_5(mul_5(R_0, mul_5(M_0, transpose_3(M_0))), _S331); + float y2_0 = _S803.z * _S803.z; + float z2_0 = _S803.w * _S803.w; + float xy_0 = _S803.y * _S803.z; + float xz_0 = _S803.y * _S803.w; + float yz_0 = _S803.z * _S803.w; + float wx_0 = _S803.x * _S803.y; + float wy_0 = _S803.x * _S803.z; + float wz_0 = _S803.x * _S803.w; + Matrix M_0 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_0 + z2_0), 2.0f * (xy_0 + wz_0), 2.0f * (xz_0 - wy_0), 2.0f * (xy_0 - wz_0), 1.0f - 2.0f * (x2_0 + z2_0), 2.0f * (yz_0 + wx_0), 2.0f * (xz_0 + wy_0), 2.0f * (yz_0 - wx_0), 1.0f - 2.0f * (x2_0 + y2_0))), makeMatrix (_S804.x, 0.0f, 0.0f, 0.0f, _S804.y, 0.0f, 0.0f, 0.0f, _S804.z)); + Matrix _S805 = transpose_3(R_0); + Matrix covar_c_0 = mul_5(mul_5(R_0, mul_5(M_0, transpose_3(M_0))), _S805); for(;;) { + covar2d_0 = _S801; for(;;) { - float2 _S332 = float2 {mean_c_0.x, mean_c_0.y}; - _S326 = _S332; - *mean2d_4 = _S332 / make_float2 (_S327); - if(_S327 < 0.0f) - { - _S328 = true; - } - else - { - float u_15 = (*mean2d_4).x; - float v_15 = (*mean2d_4).y; - float _S333 = u_15 + u_15; - float r2_15 = u_15 * u_15 + v_15 * v_15; - float _S334 = dist_coeffs_4[int(2)] + r2_15 * dist_coeffs_4[int(3)]; - float _S335 = dist_coeffs_4[int(1)] + r2_15 * _S334; - float _S336 = dist_coeffs_4[int(0)] + r2_15 * _S335; - float radial_3 = 1.0f + r2_15 * _S336; - float _S337 = 2.0f * dist_coeffs_4[int(4)]; - float _S338 = 2.0f * u_15; - float _S339 = 2.0f * dist_coeffs_4[int(5)]; - float _S340 = 2.0f * v_15; - float2 _S341 = make_float2 (1.0f, 0.0f) * make_float2 (radial_3) + make_float2 (_S333 * _S336 + (_S333 * _S335 + (_S333 * _S334 + _S333 * dist_coeffs_4[int(3)] * r2_15) * r2_15) * r2_15) * *mean2d_4 + make_float2 (_S337 * v_15 + (_S333 + (_S338 + _S338)) * dist_coeffs_4[int(5)] + _S333 * dist_coeffs_4[int(6)], _S339 * v_15 + _S333 * dist_coeffs_4[int(4)] + _S333 * dist_coeffs_4[int(7)]); - float _S342 = v_15 + v_15; - float2 _S343 = make_float2 (0.0f, 1.0f) * make_float2 (radial_3) + make_float2 (_S342 * _S336 + (_S342 * _S335 + (_S342 * _S334 + _S342 * dist_coeffs_4[int(3)] * r2_15) * r2_15) * r2_15) * *mean2d_4 + make_float2 (_S337 * u_15 + _S342 * dist_coeffs_4[int(5)] + _S342 * dist_coeffs_4[int(6)], _S339 * u_15 + (_S342 + (_S340 + _S340)) * dist_coeffs_4[int(4)] + _S342 * dist_coeffs_4[int(7)]); - Matrix _S344 = transpose_0(makeMatrix (_S341 + make_float2 (_S341.x * dist_coeffs_4[int(8)] + _S341.y * dist_coeffs_4[int(9)], 0.0f), _S343 + make_float2 (_S343.x * dist_coeffs_4[int(8)] + _S343.y * dist_coeffs_4[int(9)], 0.0f))); - _S328 = !((F32_min((determinant_0(_S344)), ((F32_min((_S344.rows[int(0)].x), (_S344.rows[int(1)].y)))))) > 0.0f); - } - if(_S328) + float2 _S806 = float2 {mean_c_0.x, mean_c_0.y}; + _S798 = _S806; + float2 uv0_4 = _S806 / make_float2 (_S800); + bool _S807 = _S800 < 0.0f; + if(_S807) { + *mean2d_13 = uv0_4; + _S802 = false; break; } - float u_16 = (*mean2d_4).x; - float v_16 = (*mean2d_4).y; - float r2_16 = u_16 * u_16 + v_16 * v_16; - float2 _S345 = *mean2d_4 * make_float2 (1.0f + r2_16 * (dist_coeffs_4[int(0)] + r2_16 * (dist_coeffs_4[int(1)] + r2_16 * (dist_coeffs_4[int(2)] + r2_16 * dist_coeffs_4[int(3)])))) + make_float2 (2.0f * dist_coeffs_4[int(4)] * u_16 * v_16 + dist_coeffs_4[int(5)] * (r2_16 + 2.0f * u_16 * u_16) + dist_coeffs_4[int(6)] * r2_16, 2.0f * dist_coeffs_4[int(5)] * u_16 * v_16 + dist_coeffs_4[int(4)] * (r2_16 + 2.0f * v_16 * v_16) + dist_coeffs_4[int(7)] * r2_16); - float2 _S346 = _S345 + make_float2 (dist_coeffs_4[int(8)] * _S345.x + dist_coeffs_4[int(9)] * _S345.y, 0.0f); - *mean2d_4 = make_float2 (fx_4 * _S346.x + cx_1, fy_4 * _S346.y + cy_1); + float2 uv_8 = _S806 / make_float2 (_S800); + FixedArray _S808 = dist_coeffs_12; + float2 _S809 = DistNone_distort_0(uv_8, &_S808); + *mean2d_13 = make_float2 (fx_13 * _S809.x + cx_4, fy_13 * _S809.y + cy_4); + _S802 = true; break; } - if(!!_S328) + if(!_S802) { - _S328 = false; + _S802 = false; break; } - Matrix J_5; - float2 _S347 = _S326 / make_float2 (_S327); - float _S348 = _S327 * _S327; - float2 _S349 = make_float2 (1.0f, 0.0f) * make_float2 (_S327) / make_float2 (_S348); - float u_17 = _S347.x; - float s_diff_u_9 = _S349.x; - float v_17 = _S347.y; - float s_diff_v_9 = _S349.y; - float _S350 = s_diff_u_9 * u_17; - float _S351 = s_diff_v_9 * v_17; - float r2_17 = u_17 * u_17 + v_17 * v_17; - float s_diff_r2_9 = _S350 + _S350 + (_S351 + _S351); - float _S352 = dist_coeffs_4[int(2)] + r2_17 * dist_coeffs_4[int(3)]; - float _S353 = dist_coeffs_4[int(1)] + r2_17 * _S352; - float _S354 = dist_coeffs_4[int(0)] + r2_17 * _S353; - float _S355 = 2.0f * dist_coeffs_4[int(4)]; - float _S356 = 2.0f * dist_coeffs_4[int(5)]; - float2 _S357 = _S349 * make_float2 (1.0f + r2_17 * _S354) + make_float2 (s_diff_r2_9 * _S354 + (s_diff_r2_9 * _S353 + (s_diff_r2_9 * _S352 + s_diff_r2_9 * dist_coeffs_4[int(3)] * r2_17) * r2_17) * r2_17) * _S347 + make_float2 (s_diff_u_9 * _S355 * v_17 + s_diff_v_9 * (_S355 * u_17) + (s_diff_r2_9 + (s_diff_u_9 * 2.0f * u_17 + s_diff_u_9 * (2.0f * u_17))) * dist_coeffs_4[int(5)] + s_diff_r2_9 * dist_coeffs_4[int(6)], s_diff_u_9 * _S356 * v_17 + s_diff_v_9 * (_S356 * u_17) + (s_diff_r2_9 + (s_diff_v_9 * 2.0f * v_17 + s_diff_v_9 * (2.0f * v_17))) * dist_coeffs_4[int(4)] + s_diff_r2_9 * dist_coeffs_4[int(7)]); - float2 _S358 = _S357 + make_float2 (_S357.x * dist_coeffs_4[int(8)] + _S357.y * dist_coeffs_4[int(9)], 0.0f); - float _S359 = _S358.y * fy_4; - Matrix J_6; - *&(((&J_6)->rows + (int(0)))->x) = _S358.x * fx_4; - *&(((&J_6)->rows + (int(1)))->x) = _S359; - float2 _S360 = _S326 / make_float2 (_S327); - float2 _S361 = make_float2 (0.0f, 1.0f) * make_float2 (_S327) / make_float2 (_S348); - float u_18 = _S360.x; - float s_diff_u_10 = _S361.x; - float v_18 = _S360.y; - float s_diff_v_10 = _S361.y; - float _S362 = s_diff_u_10 * u_18; - float _S363 = s_diff_v_10 * v_18; - float r2_18 = u_18 * u_18 + v_18 * v_18; - float s_diff_r2_10 = _S362 + _S362 + (_S363 + _S363); - float _S364 = dist_coeffs_4[int(2)] + r2_18 * dist_coeffs_4[int(3)]; - float _S365 = dist_coeffs_4[int(1)] + r2_18 * _S364; - float _S366 = dist_coeffs_4[int(0)] + r2_18 * _S365; - float2 _S367 = _S361 * make_float2 (1.0f + r2_18 * _S366) + make_float2 (s_diff_r2_10 * _S366 + (s_diff_r2_10 * _S365 + (s_diff_r2_10 * _S364 + s_diff_r2_10 * dist_coeffs_4[int(3)] * r2_18) * r2_18) * r2_18) * _S360 + make_float2 (s_diff_u_10 * _S355 * v_18 + s_diff_v_10 * (_S355 * u_18) + (s_diff_r2_10 + (s_diff_u_10 * 2.0f * u_18 + s_diff_u_10 * (2.0f * u_18))) * dist_coeffs_4[int(5)] + s_diff_r2_10 * dist_coeffs_4[int(6)], s_diff_u_10 * _S356 * v_18 + s_diff_v_10 * (_S356 * u_18) + (s_diff_r2_10 + (s_diff_v_10 * 2.0f * v_18 + s_diff_v_10 * (2.0f * v_18))) * dist_coeffs_4[int(4)] + s_diff_r2_10 * dist_coeffs_4[int(7)]); - float2 _S368 = _S367 + make_float2 (_S367.x * dist_coeffs_4[int(8)] + _S367.y * dist_coeffs_4[int(9)], 0.0f); - float _S369 = _S368.y * fy_4; - *&(((&J_6)->rows + (int(0)))->y) = _S368.x * fx_4; - *&(((&J_6)->rows + (int(1)))->y) = _S369; - float2 _S370 = _S326 / make_float2 (_S327); - float2 _S371 = (make_float2 (0.0f, 0.0f) - _S326) / make_float2 (_S348); - float u_19 = _S370.x; - float s_diff_u_11 = _S371.x; - float v_19 = _S370.y; - float s_diff_v_11 = _S371.y; - float _S372 = s_diff_u_11 * u_19; - float _S373 = s_diff_v_11 * v_19; - float r2_19 = u_19 * u_19 + v_19 * v_19; - float s_diff_r2_11 = _S372 + _S372 + (_S373 + _S373); - float _S374 = dist_coeffs_4[int(2)] + r2_19 * dist_coeffs_4[int(3)]; - float _S375 = dist_coeffs_4[int(1)] + r2_19 * _S374; - float _S376 = dist_coeffs_4[int(0)] + r2_19 * _S375; - float2 _S377 = _S371 * make_float2 (1.0f + r2_19 * _S376) + make_float2 (s_diff_r2_11 * _S376 + (s_diff_r2_11 * _S375 + (s_diff_r2_11 * _S374 + s_diff_r2_11 * dist_coeffs_4[int(3)] * r2_19) * r2_19) * r2_19) * _S370 + make_float2 (s_diff_u_11 * _S355 * v_19 + s_diff_v_11 * (_S355 * u_19) + (s_diff_r2_11 + (s_diff_u_11 * 2.0f * u_19 + s_diff_u_11 * (2.0f * u_19))) * dist_coeffs_4[int(5)] + s_diff_r2_11 * dist_coeffs_4[int(6)], s_diff_u_11 * _S356 * v_19 + s_diff_v_11 * (_S356 * u_19) + (s_diff_r2_11 + (s_diff_v_11 * 2.0f * v_19 + s_diff_v_11 * (2.0f * v_19))) * dist_coeffs_4[int(4)] + s_diff_r2_11 * dist_coeffs_4[int(7)]); - float2 _S378 = _S377 + make_float2 (_S377.x * dist_coeffs_4[int(8)] + _S377.y * dist_coeffs_4[int(9)], 0.0f); - float _S379 = _S378.y * fy_4; - *&(((&J_6)->rows + (int(0)))->z) = _S378.x * fx_4; - *&(((&J_6)->rows + (int(1)))->z) = _S379; - J_5 = J_6; - float _S380 = float(image_width_0); - float _S381 = 0.30000001192092896f * (0.5f * _S380); - float lim_x_pos_1 = _S380 + _S381; - float rz_1 = 1.0f / _S327; - float _S382 = - _S381; - float max_Jyz_1 = - (_S382 - cy_1) * rz_1; - float min_Jyz_1 = - (lim_x_pos_1 - cy_1) * rz_1; - *&(((&J_5)->rows + (int(0)))->z) = clamp_0(*&(((&J_5)->rows + (int(0)))->z), - (lim_x_pos_1 - cx_1) * rz_1, - (_S382 - cx_1) * rz_1); - *&(((&J_5)->rows + (int(1)))->z) = clamp_0(*&(((&J_5)->rows + (int(1)))->z), min_Jyz_1, max_Jyz_1); - covar2d_0 = mul_4(mul_3(J_5, covar_c_0), transpose_1(J_5)); - _S328 = true; + Matrix J_17; + float _S810 = _S800 * _S800; + float2 s_diff_uv_12 = make_float2 (1.0f, 0.0f) * make_float2 (_S800) / make_float2 (_S810); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S811; + (&_S811)->primal_0 = _S798 / make_float2 (_S800); + (&_S811)->differential_0 = s_diff_uv_12; + FixedArray _S812 = dist_coeffs_12; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S813 = s_fwd_DistNone_distort_0(&_S811, &_S812); + float _S814 = _S813.differential_0.y * fy_13; + Matrix J_18; + *&(((&J_18)->rows + (int(0)))->x) = _S813.differential_0.x * fx_13; + *&(((&J_18)->rows + (int(1)))->x) = _S814; + float2 s_diff_uv_13 = make_float2 (0.0f, 1.0f) * make_float2 (_S800) / make_float2 (_S810); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S815; + (&_S815)->primal_0 = _S798 / make_float2 (_S800); + (&_S815)->differential_0 = s_diff_uv_13; + FixedArray _S816 = dist_coeffs_12; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S817 = s_fwd_DistNone_distort_0(&_S815, &_S816); + float _S818 = _S817.differential_0.y * fy_13; + *&(((&J_18)->rows + (int(0)))->y) = _S817.differential_0.x * fx_13; + *&(((&J_18)->rows + (int(1)))->y) = _S818; + float2 s_diff_uv_14 = (make_float2 (0.0f, 0.0f) - _S798) / make_float2 (_S810); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S819; + (&_S819)->primal_0 = _S798 / make_float2 (_S800); + (&_S819)->differential_0 = s_diff_uv_14; + FixedArray _S820 = dist_coeffs_12; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S821 = s_fwd_DistNone_distort_0(&_S819, &_S820); + float _S822 = _S821.differential_0.y * fy_13; + *&(((&J_18)->rows + (int(0)))->z) = _S821.differential_0.x * fx_13; + *&(((&J_18)->rows + (int(1)))->z) = _S822; + J_17 = J_18; + float _S823 = float(image_width_0); + float _S824 = 0.30000001192092896f * (0.5f * _S823); + float lim_x_pos_4 = _S823 + _S824; + float rz_4 = 1.0f / _S800; + float _S825 = - _S824; + float max_Jyz_4 = - (_S825 - cy_4) * rz_4; + float min_Jyz_4 = - (lim_x_pos_4 - cy_4) * rz_4; + *&(((&J_17)->rows + (int(0)))->z) = clamp_0(*&(((&J_17)->rows + (int(0)))->z), - (lim_x_pos_4 - cx_4) * rz_4, - (_S825 - cx_4) * rz_4); + *&(((&J_17)->rows + (int(1)))->z) = clamp_0(*&(((&J_17)->rows + (int(1)))->z), min_Jyz_4, max_Jyz_4); + covar2d_0 = mul_4(mul_3(J_17, covar_c_0), transpose_1(J_17)); + _S802 = true; break; } - if(!(true & _S328)) + if(!(true & _S802)) { - *aabb_xyxy_0 = make_float4 (0.0f); + *aabb_xyxy_0 = _S799; break; } float eps2d_0; @@ -1851,334 +3315,1268 @@ inline __device__ void projection_3dgs_persp(bool antialiased_0, float3 mean_1, eps2d_0 = 0.30000001192092896f; } float det_orig_0 = *&(((&covar2d_0)->rows + (int(0)))->x) * *&(((&covar2d_0)->rows + (int(1)))->y) - *&(((&covar2d_0)->rows + (int(0)))->y) * *&(((&covar2d_0)->rows + (int(1)))->x); - float _S383 = *&(((&covar2d_0)->rows + (int(0)))->x) + eps2d_0; - *&(((&covar2d_0)->rows + (int(0)))->x) = _S383; - float _S384 = *&(((&covar2d_0)->rows + (int(1)))->y) + eps2d_0; - *&(((&covar2d_0)->rows + (int(1)))->y) = _S384; - float det_blur_0 = _S383 * _S384 - *&(((&covar2d_0)->rows + (int(0)))->y) * *&(((&covar2d_0)->rows + (int(1)))->x); + float _S826 = *&(((&covar2d_0)->rows + (int(0)))->x) + eps2d_0; + *&(((&covar2d_0)->rows + (int(0)))->x) = _S826; + float _S827 = *&(((&covar2d_0)->rows + (int(1)))->y) + eps2d_0; + *&(((&covar2d_0)->rows + (int(1)))->y) = _S827; + float det_blur_0 = _S826 * _S827 - *&(((&covar2d_0)->rows + (int(0)))->y) * *&(((&covar2d_0)->rows + (int(1)))->x); float compensation_0 = (F32_sqrt(((F32_max((0.0f), (det_orig_0 / det_blur_0)))))); if(det_blur_0 <= 0.0f) { - *aabb_xyxy_0 = make_float4 (0.0f); + *aabb_xyxy_0 = _S799; break; } float invdet_0 = 1.0f / (covar2d_0.rows[int(0)].x * covar2d_0.rows[int(1)].y - covar2d_0.rows[int(0)].y * covar2d_0.rows[int(1)].x); - Matrix _S385 = makeMatrix (covar2d_0.rows[int(1)].y * invdet_0, - covar2d_0.rows[int(0)].y * invdet_0, - covar2d_0.rows[int(1)].x * invdet_0, covar2d_0.rows[int(0)].x * invdet_0); + Matrix _S828 = makeMatrix (covar2d_0.rows[int(1)].y * invdet_0, - covar2d_0.rows[int(0)].y * invdet_0, - covar2d_0.rows[int(1)].x * invdet_0, covar2d_0.rows[int(0)].x * invdet_0); if(antialiased_0) { *opacity_0 = *opacity_0 * compensation_0; } if((*opacity_0) < 0.00392156885936856f) { - *aabb_xyxy_0 = make_float4 (0.0f); + *aabb_xyxy_0 = _S799; break; } - float _S386 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_0 / 0.00392156885936856f))))))))); - float radius_x_0 = _S386 * (F32_sqrt((covar2d_0[int(0)].x))); - float radius_y_0 = _S386 * (F32_sqrt((covar2d_0[int(1)].y))); - float _S387 = (*mean2d_4).x - radius_x_0; - float _S388 = (*mean2d_4).x + radius_x_0; - float _S389 = (*mean2d_4).y - radius_y_0; - float _S390 = (*mean2d_4).y + radius_y_0; - if(_S388 <= 0.0f) + float _S829 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_0 / 0.00392156885936856f))))))))); + float radius_x_0 = _S829 * (F32_sqrt((covar2d_0[int(0)].x))); + float radius_y_0 = _S829 * (F32_sqrt((covar2d_0[int(1)].y))); + float _S830 = (*mean2d_13).x - radius_x_0; + float _S831 = (*mean2d_13).x + radius_x_0; + float _S832 = (*mean2d_13).y - radius_y_0; + float _S833 = (*mean2d_13).y + radius_y_0; + if(_S831 <= 0.0f) { - _S328 = true; + _S802 = true; } else { - _S328 = _S387 >= float(image_width_0); + _S802 = _S830 >= float(image_width_0); } - if(_S328) + if(_S802) { - _S328 = true; + _S802 = true; } else { - _S328 = _S390 <= 0.0f; + _S802 = _S833 <= 0.0f; } - if(_S328) + if(_S802) { - _S328 = true; + _S802 = true; } else { - _S328 = _S389 >= float(image_height_0); + _S802 = _S832 >= float(image_height_0); } - if(_S328) + if(_S802) { - *aabb_xyxy_0 = make_float4 (0.0f); + *aabb_xyxy_0 = _S799; break; } - *aabb_xyxy_0 = make_float4 (_S387, _S389, _S388, _S390); - *sorting_depth_0 = _S327; - *conic_0 = make_float3 (_S385.rows[int(0)].x, _S385.rows[int(0)].y, _S385.rows[int(1)].y); - *radius_1 = view_radius_3dgs_0(mean_1, scale_0, in_opacity_0, - mul_6(_S331, t_0)); + *aabb_xyxy_0 = make_float4 (_S830, _S832, _S831, _S833); + *sorting_depth_0 = _S800; + *conic_0 = make_float3 (_S828.rows[int(0)].x, _S828.rows[int(0)].y, _S828.rows[int(1)].y); + *radius_1 = view_radius_3dgs_0(mean_1, scale_0, in_opacity_0, - mul_6(_S805, t_0)); break; } return; } -inline __device__ void projection_3dgs_fisheye(bool antialiased_1, float3 mean_2, float4 quat_1, float3 scale_1, float in_opacity_1, Matrix R_1, float3 t_1, float fx_5, float fy_5, float cx_2, float cy_2, FixedArray dist_coeffs_5, uint image_width_1, uint image_height_1, float4 * aabb_xyxy_1, float * sorting_depth_1, float * radius_2, float2 * mean2d_5, float * depth_1, float3 * conic_1, float * opacity_1) +inline __device__ void projection_3dgs_persp_opencv(bool antialiased_1, float3 mean_2, float4 quat_1, float3 scale_1, float in_opacity_1, Matrix R_1, float3 t_1, float fx_14, float fy_14, float cx_5, float cy_5, FixedArray dist_coeffs_13, uint image_width_1, uint image_height_1, float4 * aabb_xyxy_1, float * sorting_depth_1, float * radius_2, float2 * mean2d_14, float * depth_1, float3 * conic_1, float * opacity_1) { - float2 _S391; - float _S392; - float _S393; - float _S394; - float _S395; - float _S396; - float _S397; - float _S398; - float _S399; - float _S400; - float _S401; - float _S402; - float _S403; - float _S404; - bool _S405; + float2 _S834; for(;;) { + float4 _S835 = make_float4 (0.0f); + *aabb_xyxy_1 = _S835; + *sorting_depth_1 = 0.0f; + *radius_2 = 0.0f; + *mean2d_14 = make_float2 (0.0f); + *conic_1 = make_float3 (0.0f); + *opacity_1 = 0.0f; float3 mean_c_1 = mul_6(R_1, mean_2) + t_1; - float _S406 = length_1(mean_c_1); - *depth_1 = _S406; - if(_S406 <= 0.0f) + float _S836 = mean_c_1.z; + *depth_1 = length_1(mean_c_1); + if(_S836 <= 0.0f) { - *aabb_xyxy_1 = make_float4 (0.0f); + *aabb_xyxy_1 = _S835; break; } Matrix covar2d_1; + Matrix _S837 = makeMatrix (0.0f); *opacity_1 = 1.0f / (1.0f + (F32_exp((- in_opacity_1)))); - bool is_valid_0; - float eps2d_1; - float4 _S407 = normalize_0(quat_1); - float3 _S408 = exp_0(scale_1); - float x_16 = _S407.y; + bool _S838; + float4 _S839 = normalize_0(quat_1); + float3 _S840 = exp_0(scale_1); + float x_16 = _S839.y; float x2_1 = x_16 * x_16; - float y2_1 = _S407.z * _S407.z; - float z2_1 = _S407.w * _S407.w; - float xy_1 = _S407.y * _S407.z; - float xz_1 = _S407.y * _S407.w; - float yz_1 = _S407.z * _S407.w; - float wx_1 = _S407.x * _S407.y; - float wy_1 = _S407.x * _S407.z; - float wz_1 = _S407.x * _S407.w; - Matrix M_1 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_1 + z2_1), 2.0f * (xy_1 + wz_1), 2.0f * (xz_1 - wy_1), 2.0f * (xy_1 - wz_1), 1.0f - 2.0f * (x2_1 + z2_1), 2.0f * (yz_1 + wx_1), 2.0f * (xz_1 + wy_1), 2.0f * (yz_1 - wx_1), 1.0f - 2.0f * (x2_1 + y2_1))), makeMatrix (_S408.x, 0.0f, 0.0f, 0.0f, _S408.y, 0.0f, 0.0f, 0.0f, _S408.z)); - Matrix _S409 = transpose_3(R_1); - Matrix covar_c_1 = mul_5(mul_5(R_1, mul_5(M_1, transpose_3(M_1))), _S409); + float y2_1 = _S839.z * _S839.z; + float z2_1 = _S839.w * _S839.w; + float xy_1 = _S839.y * _S839.z; + float xz_1 = _S839.y * _S839.w; + float yz_1 = _S839.z * _S839.w; + float wx_1 = _S839.x * _S839.y; + float wy_1 = _S839.x * _S839.z; + float wz_1 = _S839.x * _S839.w; + Matrix M_1 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_1 + z2_1), 2.0f * (xy_1 + wz_1), 2.0f * (xz_1 - wy_1), 2.0f * (xy_1 - wz_1), 1.0f - 2.0f * (x2_1 + z2_1), 2.0f * (yz_1 + wx_1), 2.0f * (xz_1 + wy_1), 2.0f * (yz_1 - wx_1), 1.0f - 2.0f * (x2_1 + y2_1))), makeMatrix (_S840.x, 0.0f, 0.0f, 0.0f, _S840.y, 0.0f, 0.0f, 0.0f, _S840.z)); + Matrix _S841 = transpose_3(R_1); + Matrix covar_c_1 = mul_5(mul_5(R_1, mul_5(M_1, transpose_3(M_1))), _S841); for(;;) { - float k_2; + covar2d_1 = _S837; for(;;) { - float2 _S410 = float2 {mean_c_1.x, mean_c_1.y}; - _S391 = _S410; - float r_9 = length_0(_S410); - float _S411 = mean_c_1.z; - _S392 = _S411; - float theta_2 = (F32_atan2((r_9), (_S411))); - if(theta_2 < 0.00100000004749745f) + float2 _S842 = float2 {mean_c_1.x, mean_c_1.y}; + _S834 = _S842; + float2 uv0_5 = _S842 / make_float2 (_S836); + if(_S836 < 0.0f) { - k_2 = (1.0f - theta_2 * theta_2 / 3.0f) / _S411; + _S838 = true; } else { - k_2 = theta_2 / r_9; + float2 _S843 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S844; + (&_S844)->primal_0 = uv0_5; + (&_S844)->differential_0 = _S843; + FixedArray _S845 = dist_coeffs_13; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S846 = s_fwd_DistOpenCV_distort_0(&_S844, &_S845); + float2 _S847 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S848; + (&_S848)->primal_0 = uv0_5; + (&_S848)->differential_0 = _S847; + FixedArray _S849 = dist_coeffs_13; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S850 = s_fwd_DistOpenCV_distort_0(&_S848, &_S849); + Matrix _S851 = transpose_0(makeMatrix (_S846.differential_0, _S850.differential_0)); + float _S852 = (F32_min((determinant_0(_S851)), ((F32_min((_S851.rows[int(0)].x), (_S851.rows[int(1)].y)))))); + if(_S852 > 0.25f) + { + _S838 = _S852 < 4.0f; + } + else + { + _S838 = false; + } + if(_S838) + { + FixedArray _S853 = dist_coeffs_13; + float2 _S854 = DistOpenCV_distort_0(uv0_5, &_S853); + _S838 = (dot_0(uv0_5, _S854)) >= 0.0f; + } + else + { + _S838 = false; + } + _S838 = !_S838; } - float2 _S412 = _S410 * make_float2 (k_2); - *mean2d_5 = _S412; - float2 _S413 = make_float2 (1.0f, 0.0f); - _S393 = dist_coeffs_5[int(0)]; - _S394 = dist_coeffs_5[int(1)]; - _S395 = dist_coeffs_5[int(2)]; - _S396 = dist_coeffs_5[int(3)]; - _S397 = dist_coeffs_5[int(4)]; - _S398 = dist_coeffs_5[int(5)]; - _S399 = dist_coeffs_5[int(6)]; - _S400 = dist_coeffs_5[int(7)]; - _S401 = dist_coeffs_5[int(8)]; - _S402 = dist_coeffs_5[int(9)]; - float u_20 = _S412.x; - float v_20 = _S412.y; - float _S414 = u_20 + u_20; - float r2_20 = u_20 * u_20 + v_20 * v_20; - float _S415 = dist_coeffs_5[int(2)] + r2_20 * dist_coeffs_5[int(3)]; - float _S416 = dist_coeffs_5[int(1)] + r2_20 * _S415; - float _S417 = dist_coeffs_5[int(0)] + r2_20 * _S416; - float _S418 = _S414 * _S417 + (_S414 * _S416 + (_S414 * _S415 + _S414 * dist_coeffs_5[int(3)] * r2_20) * r2_20) * r2_20; - float radial_4 = 1.0f + r2_20 * _S417; - float _S419 = 2.0f * dist_coeffs_5[int(4)]; - _S403 = _S419; - float _S420 = _S419 * u_20; - float _S421 = 2.0f * u_20; - float s_diff_du_2 = _S419 * v_20 + (_S414 + (_S421 + _S421)) * dist_coeffs_5[int(5)] + _S414 * dist_coeffs_5[int(6)]; - float _S422 = 2.0f * dist_coeffs_5[int(5)]; - _S404 = _S422; - float _S423 = 2.0f * v_20; - float2 _S424 = _S413 * make_float2 (radial_4) + make_float2 (_S418) * _S412 + make_float2 (s_diff_du_2, _S422 * v_20 + _S414 * dist_coeffs_5[int(4)] + _S414 * dist_coeffs_5[int(7)]); - float _S425 = v_20 + v_20; - float2 _S426 = make_float2 (0.0f, 1.0f) * make_float2 (radial_4) + make_float2 (_S425 * _S417 + (_S425 * _S416 + (_S425 * _S415 + _S425 * dist_coeffs_5[int(3)] * r2_20) * r2_20) * r2_20) * _S412 + make_float2 (_S420 + _S425 * dist_coeffs_5[int(5)] + _S425 * dist_coeffs_5[int(6)], _S422 * u_20 + (_S425 + (_S423 + _S423)) * dist_coeffs_5[int(4)] + _S425 * dist_coeffs_5[int(7)]); - Matrix _S427 = transpose_0(makeMatrix (_S424 + make_float2 (_S424.x * dist_coeffs_5[int(8)] + _S424.y * dist_coeffs_5[int(9)], 0.0f), _S426 + make_float2 (_S426.x * dist_coeffs_5[int(8)] + _S426.y * dist_coeffs_5[int(9)], 0.0f))); - bool _S428 = !((F32_min((determinant_0(_S427)), ((F32_min((_S427.rows[int(0)].x), (_S427.rows[int(1)].y)))))) > 0.0f); - _S405 = _S428; - if(_S428) + if(_S838) { + *mean2d_14 = uv0_5; + _S838 = false; break; } - float u_21 = (*mean2d_5).x; - float v_21 = (*mean2d_5).y; - float r2_21 = u_21 * u_21 + v_21 * v_21; - float2 _S429 = *mean2d_5 * make_float2 (1.0f + r2_21 * (dist_coeffs_5[int(0)] + r2_21 * (dist_coeffs_5[int(1)] + r2_21 * (dist_coeffs_5[int(2)] + r2_21 * dist_coeffs_5[int(3)])))) + make_float2 (_S419 * u_21 * v_21 + dist_coeffs_5[int(5)] * (r2_21 + 2.0f * u_21 * u_21) + dist_coeffs_5[int(6)] * r2_21, _S422 * u_21 * v_21 + dist_coeffs_5[int(4)] * (r2_21 + 2.0f * v_21 * v_21) + dist_coeffs_5[int(7)] * r2_21); - float2 _S430 = _S429 + make_float2 (dist_coeffs_5[int(8)] * _S429.x + dist_coeffs_5[int(9)] * _S429.y, 0.0f); - *mean2d_5 = make_float2 (fx_5 * _S430.x + cx_2, fy_5 * _S430.y + cy_2); + float2 uv_9 = _S842 / make_float2 (_S836); + FixedArray _S855 = dist_coeffs_13; + float2 _S856 = DistOpenCV_distort_0(uv_9, &_S855); + *mean2d_14 = make_float2 (fx_14 * _S856.x + cx_5, fy_14 * _S856.y + cy_5); + _S838 = true; break; } - if(!!_S405) + if(!_S838) + { + _S838 = false; + break; + } + Matrix J_19; + float _S857 = _S836 * _S836; + float2 s_diff_uv_15 = make_float2 (1.0f, 0.0f) * make_float2 (_S836) / make_float2 (_S857); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S858; + (&_S858)->primal_0 = _S834 / make_float2 (_S836); + (&_S858)->differential_0 = s_diff_uv_15; + FixedArray _S859 = dist_coeffs_13; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S860 = s_fwd_DistOpenCV_distort_0(&_S858, &_S859); + float _S861 = _S860.differential_0.y * fy_14; + Matrix J_20; + *&(((&J_20)->rows + (int(0)))->x) = _S860.differential_0.x * fx_14; + *&(((&J_20)->rows + (int(1)))->x) = _S861; + float2 s_diff_uv_16 = make_float2 (0.0f, 1.0f) * make_float2 (_S836) / make_float2 (_S857); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S862; + (&_S862)->primal_0 = _S834 / make_float2 (_S836); + (&_S862)->differential_0 = s_diff_uv_16; + FixedArray _S863 = dist_coeffs_13; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S864 = s_fwd_DistOpenCV_distort_0(&_S862, &_S863); + float _S865 = _S864.differential_0.y * fy_14; + *&(((&J_20)->rows + (int(0)))->y) = _S864.differential_0.x * fx_14; + *&(((&J_20)->rows + (int(1)))->y) = _S865; + float2 s_diff_uv_17 = (make_float2 (0.0f, 0.0f) - _S834) / make_float2 (_S857); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S866; + (&_S866)->primal_0 = _S834 / make_float2 (_S836); + (&_S866)->differential_0 = s_diff_uv_17; + FixedArray _S867 = dist_coeffs_13; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S868 = s_fwd_DistOpenCV_distort_0(&_S866, &_S867); + float _S869 = _S868.differential_0.y * fy_14; + *&(((&J_20)->rows + (int(0)))->z) = _S868.differential_0.x * fx_14; + *&(((&J_20)->rows + (int(1)))->z) = _S869; + J_19 = J_20; + float _S870 = float(image_width_1); + float _S871 = 0.30000001192092896f * (0.5f * _S870); + float lim_x_pos_5 = _S870 + _S871; + float rz_5 = 1.0f / _S836; + float _S872 = - _S871; + float max_Jyz_5 = - (_S872 - cy_5) * rz_5; + float min_Jyz_5 = - (lim_x_pos_5 - cy_5) * rz_5; + *&(((&J_19)->rows + (int(0)))->z) = clamp_0(*&(((&J_19)->rows + (int(0)))->z), - (lim_x_pos_5 - cx_5) * rz_5, - (_S872 - cx_5) * rz_5); + *&(((&J_19)->rows + (int(1)))->z) = clamp_0(*&(((&J_19)->rows + (int(1)))->z), min_Jyz_5, max_Jyz_5); + covar2d_1 = mul_4(mul_3(J_19, covar_c_1), transpose_1(J_19)); + _S838 = true; + break; + } + if(!(true & _S838)) + { + *aabb_xyxy_1 = _S835; + break; + } + float eps2d_1; + if(antialiased_1) + { + eps2d_1 = 0.10000000149011612f; + } + else + { + eps2d_1 = 0.30000001192092896f; + } + float det_orig_1 = *&(((&covar2d_1)->rows + (int(0)))->x) * *&(((&covar2d_1)->rows + (int(1)))->y) - *&(((&covar2d_1)->rows + (int(0)))->y) * *&(((&covar2d_1)->rows + (int(1)))->x); + float _S873 = *&(((&covar2d_1)->rows + (int(0)))->x) + eps2d_1; + *&(((&covar2d_1)->rows + (int(0)))->x) = _S873; + float _S874 = *&(((&covar2d_1)->rows + (int(1)))->y) + eps2d_1; + *&(((&covar2d_1)->rows + (int(1)))->y) = _S874; + float det_blur_1 = _S873 * _S874 - *&(((&covar2d_1)->rows + (int(0)))->y) * *&(((&covar2d_1)->rows + (int(1)))->x); + float compensation_1 = (F32_sqrt(((F32_max((0.0f), (det_orig_1 / det_blur_1)))))); + if(det_blur_1 <= 0.0f) + { + *aabb_xyxy_1 = _S835; + break; + } + float invdet_1 = 1.0f / (covar2d_1.rows[int(0)].x * covar2d_1.rows[int(1)].y - covar2d_1.rows[int(0)].y * covar2d_1.rows[int(1)].x); + Matrix _S875 = makeMatrix (covar2d_1.rows[int(1)].y * invdet_1, - covar2d_1.rows[int(0)].y * invdet_1, - covar2d_1.rows[int(1)].x * invdet_1, covar2d_1.rows[int(0)].x * invdet_1); + if(antialiased_1) + { + *opacity_1 = *opacity_1 * compensation_1; + } + if((*opacity_1) < 0.00392156885936856f) + { + *aabb_xyxy_1 = _S835; + break; + } + float _S876 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_1 / 0.00392156885936856f))))))))); + float radius_x_1 = _S876 * (F32_sqrt((covar2d_1[int(0)].x))); + float radius_y_1 = _S876 * (F32_sqrt((covar2d_1[int(1)].y))); + float _S877 = (*mean2d_14).x - radius_x_1; + float _S878 = (*mean2d_14).x + radius_x_1; + float _S879 = (*mean2d_14).y - radius_y_1; + float _S880 = (*mean2d_14).y + radius_y_1; + if(_S878 <= 0.0f) + { + _S838 = true; + } + else + { + _S838 = _S877 >= float(image_width_1); + } + if(_S838) + { + _S838 = true; + } + else + { + _S838 = _S880 <= 0.0f; + } + if(_S838) + { + _S838 = true; + } + else + { + _S838 = _S879 >= float(image_height_1); + } + if(_S838) + { + *aabb_xyxy_1 = _S835; + break; + } + *aabb_xyxy_1 = make_float4 (_S877, _S879, _S878, _S880); + *sorting_depth_1 = _S836; + *conic_1 = make_float3 (_S875.rows[int(0)].x, _S875.rows[int(0)].y, _S875.rows[int(1)].y); + *radius_2 = view_radius_3dgs_0(mean_2, scale_1, in_opacity_1, - mul_6(_S841, t_1)); + break; + } + return; +} + +inline __device__ void projection_3dgs_persp_prism(bool antialiased_2, float3 mean_3, float4 quat_2, float3 scale_2, float in_opacity_2, Matrix R_2, float3 t_2, float fx_15, float fy_15, float cx_6, float cy_6, FixedArray dist_coeffs_14, uint image_width_2, uint image_height_2, float4 * aabb_xyxy_2, float * sorting_depth_2, float * radius_3, float2 * mean2d_15, float * depth_2, float3 * conic_2, float * opacity_2) +{ + float2 _S881; + for(;;) + { + float4 _S882 = make_float4 (0.0f); + *aabb_xyxy_2 = _S882; + *sorting_depth_2 = 0.0f; + *radius_3 = 0.0f; + *mean2d_15 = make_float2 (0.0f); + *conic_2 = make_float3 (0.0f); + *opacity_2 = 0.0f; + float3 mean_c_2 = mul_6(R_2, mean_3) + t_2; + float _S883 = mean_c_2.z; + *depth_2 = length_1(mean_c_2); + if(_S883 <= 0.0f) + { + *aabb_xyxy_2 = _S882; + break; + } + Matrix covar2d_2; + Matrix _S884 = makeMatrix (0.0f); + *opacity_2 = 1.0f / (1.0f + (F32_exp((- in_opacity_2)))); + bool _S885; + float4 _S886 = normalize_0(quat_2); + float3 _S887 = exp_0(scale_2); + float x_17 = _S886.y; + float x2_2 = x_17 * x_17; + float y2_2 = _S886.z * _S886.z; + float z2_2 = _S886.w * _S886.w; + float xy_2 = _S886.y * _S886.z; + float xz_2 = _S886.y * _S886.w; + float yz_2 = _S886.z * _S886.w; + float wx_2 = _S886.x * _S886.y; + float wy_2 = _S886.x * _S886.z; + float wz_2 = _S886.x * _S886.w; + Matrix M_2 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_2 + z2_2), 2.0f * (xy_2 + wz_2), 2.0f * (xz_2 - wy_2), 2.0f * (xy_2 - wz_2), 1.0f - 2.0f * (x2_2 + z2_2), 2.0f * (yz_2 + wx_2), 2.0f * (xz_2 + wy_2), 2.0f * (yz_2 - wx_2), 1.0f - 2.0f * (x2_2 + y2_2))), makeMatrix (_S887.x, 0.0f, 0.0f, 0.0f, _S887.y, 0.0f, 0.0f, 0.0f, _S887.z)); + Matrix _S888 = transpose_3(R_2); + Matrix covar_c_2 = mul_5(mul_5(R_2, mul_5(M_2, transpose_3(M_2))), _S888); + for(;;) + { + covar2d_2 = _S884; + for(;;) + { + float2 _S889 = float2 {mean_c_2.x, mean_c_2.y}; + _S881 = _S889; + float2 uv0_6 = _S889 / make_float2 (_S883); + if(_S883 < 0.0f) + { + _S885 = true; + } + else + { + float2 _S890 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S891; + (&_S891)->primal_0 = uv0_6; + (&_S891)->differential_0 = _S890; + FixedArray _S892 = dist_coeffs_14; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S893 = s_fwd_DistThinPrism_distort_0(&_S891, &_S892); + float2 _S894 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S895; + (&_S895)->primal_0 = uv0_6; + (&_S895)->differential_0 = _S894; + FixedArray _S896 = dist_coeffs_14; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S897 = s_fwd_DistThinPrism_distort_0(&_S895, &_S896); + Matrix _S898 = transpose_0(makeMatrix (_S893.differential_0, _S897.differential_0)); + float _S899 = (F32_min((determinant_0(_S898)), ((F32_min((_S898.rows[int(0)].x), (_S898.rows[int(1)].y)))))); + if(_S899 > 0.25f) + { + _S885 = _S899 < 4.0f; + } + else + { + _S885 = false; + } + if(_S885) + { + FixedArray _S900 = dist_coeffs_14; + float2 _S901 = DistThinPrism_distort_0(uv0_6, &_S900); + _S885 = (dot_0(uv0_6, _S901)) >= 0.0f; + } + else + { + _S885 = false; + } + _S885 = !_S885; + } + if(_S885) + { + *mean2d_15 = uv0_6; + _S885 = false; + break; + } + float2 uv_10 = _S889 / make_float2 (_S883); + FixedArray _S902 = dist_coeffs_14; + float2 _S903 = DistThinPrism_distort_0(uv_10, &_S902); + *mean2d_15 = make_float2 (fx_15 * _S903.x + cx_6, fy_15 * _S903.y + cy_6); + _S885 = true; + break; + } + if(!_S885) + { + _S885 = false; + break; + } + Matrix J_21; + float _S904 = _S883 * _S883; + float2 s_diff_uv_18 = make_float2 (1.0f, 0.0f) * make_float2 (_S883) / make_float2 (_S904); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S905; + (&_S905)->primal_0 = _S881 / make_float2 (_S883); + (&_S905)->differential_0 = s_diff_uv_18; + FixedArray _S906 = dist_coeffs_14; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S907 = s_fwd_DistThinPrism_distort_0(&_S905, &_S906); + float _S908 = _S907.differential_0.y * fy_15; + Matrix J_22; + *&(((&J_22)->rows + (int(0)))->x) = _S907.differential_0.x * fx_15; + *&(((&J_22)->rows + (int(1)))->x) = _S908; + float2 s_diff_uv_19 = make_float2 (0.0f, 1.0f) * make_float2 (_S883) / make_float2 (_S904); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S909; + (&_S909)->primal_0 = _S881 / make_float2 (_S883); + (&_S909)->differential_0 = s_diff_uv_19; + FixedArray _S910 = dist_coeffs_14; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S911 = s_fwd_DistThinPrism_distort_0(&_S909, &_S910); + float _S912 = _S911.differential_0.y * fy_15; + *&(((&J_22)->rows + (int(0)))->y) = _S911.differential_0.x * fx_15; + *&(((&J_22)->rows + (int(1)))->y) = _S912; + float2 s_diff_uv_20 = (make_float2 (0.0f, 0.0f) - _S881) / make_float2 (_S904); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S913; + (&_S913)->primal_0 = _S881 / make_float2 (_S883); + (&_S913)->differential_0 = s_diff_uv_20; + FixedArray _S914 = dist_coeffs_14; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S915 = s_fwd_DistThinPrism_distort_0(&_S913, &_S914); + float _S916 = _S915.differential_0.y * fy_15; + *&(((&J_22)->rows + (int(0)))->z) = _S915.differential_0.x * fx_15; + *&(((&J_22)->rows + (int(1)))->z) = _S916; + J_21 = J_22; + float _S917 = float(image_width_2); + float _S918 = 0.30000001192092896f * (0.5f * _S917); + float lim_x_pos_6 = _S917 + _S918; + float rz_6 = 1.0f / _S883; + float _S919 = - _S918; + float max_Jyz_6 = - (_S919 - cy_6) * rz_6; + float min_Jyz_6 = - (lim_x_pos_6 - cy_6) * rz_6; + *&(((&J_21)->rows + (int(0)))->z) = clamp_0(*&(((&J_21)->rows + (int(0)))->z), - (lim_x_pos_6 - cx_6) * rz_6, - (_S919 - cx_6) * rz_6); + *&(((&J_21)->rows + (int(1)))->z) = clamp_0(*&(((&J_21)->rows + (int(1)))->z), min_Jyz_6, max_Jyz_6); + covar2d_2 = mul_4(mul_3(J_21, covar_c_2), transpose_1(J_21)); + _S885 = true; + break; + } + if(!(true & _S885)) + { + *aabb_xyxy_2 = _S882; + break; + } + float eps2d_2; + if(antialiased_2) + { + eps2d_2 = 0.10000000149011612f; + } + else + { + eps2d_2 = 0.30000001192092896f; + } + float det_orig_2 = *&(((&covar2d_2)->rows + (int(0)))->x) * *&(((&covar2d_2)->rows + (int(1)))->y) - *&(((&covar2d_2)->rows + (int(0)))->y) * *&(((&covar2d_2)->rows + (int(1)))->x); + float _S920 = *&(((&covar2d_2)->rows + (int(0)))->x) + eps2d_2; + *&(((&covar2d_2)->rows + (int(0)))->x) = _S920; + float _S921 = *&(((&covar2d_2)->rows + (int(1)))->y) + eps2d_2; + *&(((&covar2d_2)->rows + (int(1)))->y) = _S921; + float det_blur_2 = _S920 * _S921 - *&(((&covar2d_2)->rows + (int(0)))->y) * *&(((&covar2d_2)->rows + (int(1)))->x); + float compensation_2 = (F32_sqrt(((F32_max((0.0f), (det_orig_2 / det_blur_2)))))); + if(det_blur_2 <= 0.0f) + { + *aabb_xyxy_2 = _S882; + break; + } + float invdet_2 = 1.0f / (covar2d_2.rows[int(0)].x * covar2d_2.rows[int(1)].y - covar2d_2.rows[int(0)].y * covar2d_2.rows[int(1)].x); + Matrix _S922 = makeMatrix (covar2d_2.rows[int(1)].y * invdet_2, - covar2d_2.rows[int(0)].y * invdet_2, - covar2d_2.rows[int(1)].x * invdet_2, covar2d_2.rows[int(0)].x * invdet_2); + if(antialiased_2) + { + *opacity_2 = *opacity_2 * compensation_2; + } + if((*opacity_2) < 0.00392156885936856f) + { + *aabb_xyxy_2 = _S882; + break; + } + float _S923 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_2 / 0.00392156885936856f))))))))); + float radius_x_2 = _S923 * (F32_sqrt((covar2d_2[int(0)].x))); + float radius_y_2 = _S923 * (F32_sqrt((covar2d_2[int(1)].y))); + float _S924 = (*mean2d_15).x - radius_x_2; + float _S925 = (*mean2d_15).x + radius_x_2; + float _S926 = (*mean2d_15).y - radius_y_2; + float _S927 = (*mean2d_15).y + radius_y_2; + if(_S925 <= 0.0f) + { + _S885 = true; + } + else + { + _S885 = _S924 >= float(image_width_2); + } + if(_S885) + { + _S885 = true; + } + else + { + _S885 = _S927 <= 0.0f; + } + if(_S885) + { + _S885 = true; + } + else + { + _S885 = _S926 >= float(image_height_2); + } + if(_S885) + { + *aabb_xyxy_2 = _S882; + break; + } + *aabb_xyxy_2 = make_float4 (_S924, _S926, _S925, _S927); + *sorting_depth_2 = _S883; + *conic_2 = make_float3 (_S922.rows[int(0)].x, _S922.rows[int(0)].y, _S922.rows[int(1)].y); + *radius_3 = view_radius_3dgs_0(mean_3, scale_2, in_opacity_2, - mul_6(_S888, t_2)); + break; + } + return; +} + +inline __device__ void projection_3dgs_persp_rational(bool antialiased_3, float3 mean_4, float4 quat_3, float3 scale_3, float in_opacity_3, Matrix R_3, float3 t_3, float fx_16, float fy_16, float cx_7, float cy_7, FixedArray dist_coeffs_15, uint image_width_3, uint image_height_3, float4 * aabb_xyxy_3, float * sorting_depth_3, float * radius_4, float2 * mean2d_16, float * depth_3, float3 * conic_3, float * opacity_3) +{ + float2 _S928; + for(;;) + { + float4 _S929 = make_float4 (0.0f); + *aabb_xyxy_3 = _S929; + *sorting_depth_3 = 0.0f; + *radius_4 = 0.0f; + *mean2d_16 = make_float2 (0.0f); + *conic_3 = make_float3 (0.0f); + *opacity_3 = 0.0f; + float3 mean_c_3 = mul_6(R_3, mean_4) + t_3; + float _S930 = mean_c_3.z; + *depth_3 = length_1(mean_c_3); + if(_S930 <= 0.0f) + { + *aabb_xyxy_3 = _S929; + break; + } + Matrix covar2d_3; + Matrix _S931 = makeMatrix (0.0f); + *opacity_3 = 1.0f / (1.0f + (F32_exp((- in_opacity_3)))); + bool _S932; + float4 _S933 = normalize_0(quat_3); + float3 _S934 = exp_0(scale_3); + float x_18 = _S933.y; + float x2_3 = x_18 * x_18; + float y2_3 = _S933.z * _S933.z; + float z2_3 = _S933.w * _S933.w; + float xy_3 = _S933.y * _S933.z; + float xz_3 = _S933.y * _S933.w; + float yz_3 = _S933.z * _S933.w; + float wx_3 = _S933.x * _S933.y; + float wy_3 = _S933.x * _S933.z; + float wz_3 = _S933.x * _S933.w; + Matrix M_3 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_3 + z2_3), 2.0f * (xy_3 + wz_3), 2.0f * (xz_3 - wy_3), 2.0f * (xy_3 - wz_3), 1.0f - 2.0f * (x2_3 + z2_3), 2.0f * (yz_3 + wx_3), 2.0f * (xz_3 + wy_3), 2.0f * (yz_3 - wx_3), 1.0f - 2.0f * (x2_3 + y2_3))), makeMatrix (_S934.x, 0.0f, 0.0f, 0.0f, _S934.y, 0.0f, 0.0f, 0.0f, _S934.z)); + Matrix _S935 = transpose_3(R_3); + Matrix covar_c_3 = mul_5(mul_5(R_3, mul_5(M_3, transpose_3(M_3))), _S935); + for(;;) + { + covar2d_3 = _S931; + for(;;) + { + float2 _S936 = float2 {mean_c_3.x, mean_c_3.y}; + _S928 = _S936; + float2 uv0_7 = _S936 / make_float2 (_S930); + if(_S930 < 0.0f) + { + _S932 = true; + } + else + { + float2 _S937 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S938; + (&_S938)->primal_0 = uv0_7; + (&_S938)->differential_0 = _S937; + FixedArray _S939 = dist_coeffs_15; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S940 = s_fwd_DistRational_distort_0(&_S938, &_S939); + float2 _S941 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S942; + (&_S942)->primal_0 = uv0_7; + (&_S942)->differential_0 = _S941; + FixedArray _S943 = dist_coeffs_15; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S944 = s_fwd_DistRational_distort_0(&_S942, &_S943); + Matrix _S945 = transpose_0(makeMatrix (_S940.differential_0, _S944.differential_0)); + float _S946 = (F32_min((determinant_0(_S945)), ((F32_min((_S945.rows[int(0)].x), (_S945.rows[int(1)].y)))))); + if(_S946 > 0.25f) + { + _S932 = _S946 < 4.0f; + } + else + { + _S932 = false; + } + if(_S932) + { + FixedArray _S947 = dist_coeffs_15; + float2 _S948 = DistRational_distort_0(uv0_7, &_S947); + _S932 = (dot_0(uv0_7, _S948)) >= 0.0f; + } + else + { + _S932 = false; + } + _S932 = !_S932; + } + if(_S932) + { + *mean2d_16 = uv0_7; + _S932 = false; + break; + } + float2 uv_11 = _S936 / make_float2 (_S930); + FixedArray _S949 = dist_coeffs_15; + float2 _S950 = DistRational_distort_0(uv_11, &_S949); + *mean2d_16 = make_float2 (fx_16 * _S950.x + cx_7, fy_16 * _S950.y + cy_7); + _S932 = true; + break; + } + if(!_S932) + { + _S932 = false; + break; + } + Matrix J_23; + float _S951 = _S930 * _S930; + float2 s_diff_uv_21 = make_float2 (1.0f, 0.0f) * make_float2 (_S930) / make_float2 (_S951); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S952; + (&_S952)->primal_0 = _S928 / make_float2 (_S930); + (&_S952)->differential_0 = s_diff_uv_21; + FixedArray _S953 = dist_coeffs_15; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S954 = s_fwd_DistRational_distort_0(&_S952, &_S953); + float _S955 = _S954.differential_0.y * fy_16; + Matrix J_24; + *&(((&J_24)->rows + (int(0)))->x) = _S954.differential_0.x * fx_16; + *&(((&J_24)->rows + (int(1)))->x) = _S955; + float2 s_diff_uv_22 = make_float2 (0.0f, 1.0f) * make_float2 (_S930) / make_float2 (_S951); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S956; + (&_S956)->primal_0 = _S928 / make_float2 (_S930); + (&_S956)->differential_0 = s_diff_uv_22; + FixedArray _S957 = dist_coeffs_15; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S958 = s_fwd_DistRational_distort_0(&_S956, &_S957); + float _S959 = _S958.differential_0.y * fy_16; + *&(((&J_24)->rows + (int(0)))->y) = _S958.differential_0.x * fx_16; + *&(((&J_24)->rows + (int(1)))->y) = _S959; + float2 s_diff_uv_23 = (make_float2 (0.0f, 0.0f) - _S928) / make_float2 (_S951); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S960; + (&_S960)->primal_0 = _S928 / make_float2 (_S930); + (&_S960)->differential_0 = s_diff_uv_23; + FixedArray _S961 = dist_coeffs_15; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S962 = s_fwd_DistRational_distort_0(&_S960, &_S961); + float _S963 = _S962.differential_0.y * fy_16; + *&(((&J_24)->rows + (int(0)))->z) = _S962.differential_0.x * fx_16; + *&(((&J_24)->rows + (int(1)))->z) = _S963; + J_23 = J_24; + float _S964 = float(image_width_3); + float _S965 = 0.30000001192092896f * (0.5f * _S964); + float lim_x_pos_7 = _S964 + _S965; + float rz_7 = 1.0f / _S930; + float _S966 = - _S965; + float max_Jyz_7 = - (_S966 - cy_7) * rz_7; + float min_Jyz_7 = - (lim_x_pos_7 - cy_7) * rz_7; + *&(((&J_23)->rows + (int(0)))->z) = clamp_0(*&(((&J_23)->rows + (int(0)))->z), - (lim_x_pos_7 - cx_7) * rz_7, - (_S966 - cx_7) * rz_7); + *&(((&J_23)->rows + (int(1)))->z) = clamp_0(*&(((&J_23)->rows + (int(1)))->z), min_Jyz_7, max_Jyz_7); + covar2d_3 = mul_4(mul_3(J_23, covar_c_3), transpose_1(J_23)); + _S932 = true; + break; + } + if(!(true & _S932)) + { + *aabb_xyxy_3 = _S929; + break; + } + float eps2d_3; + if(antialiased_3) + { + eps2d_3 = 0.10000000149011612f; + } + else + { + eps2d_3 = 0.30000001192092896f; + } + float det_orig_3 = *&(((&covar2d_3)->rows + (int(0)))->x) * *&(((&covar2d_3)->rows + (int(1)))->y) - *&(((&covar2d_3)->rows + (int(0)))->y) * *&(((&covar2d_3)->rows + (int(1)))->x); + float _S967 = *&(((&covar2d_3)->rows + (int(0)))->x) + eps2d_3; + *&(((&covar2d_3)->rows + (int(0)))->x) = _S967; + float _S968 = *&(((&covar2d_3)->rows + (int(1)))->y) + eps2d_3; + *&(((&covar2d_3)->rows + (int(1)))->y) = _S968; + float det_blur_3 = _S967 * _S968 - *&(((&covar2d_3)->rows + (int(0)))->y) * *&(((&covar2d_3)->rows + (int(1)))->x); + float compensation_3 = (F32_sqrt(((F32_max((0.0f), (det_orig_3 / det_blur_3)))))); + if(det_blur_3 <= 0.0f) + { + *aabb_xyxy_3 = _S929; + break; + } + float invdet_3 = 1.0f / (covar2d_3.rows[int(0)].x * covar2d_3.rows[int(1)].y - covar2d_3.rows[int(0)].y * covar2d_3.rows[int(1)].x); + Matrix _S969 = makeMatrix (covar2d_3.rows[int(1)].y * invdet_3, - covar2d_3.rows[int(0)].y * invdet_3, - covar2d_3.rows[int(1)].x * invdet_3, covar2d_3.rows[int(0)].x * invdet_3); + if(antialiased_3) + { + *opacity_3 = *opacity_3 * compensation_3; + } + if((*opacity_3) < 0.00392156885936856f) + { + *aabb_xyxy_3 = _S929; + break; + } + float _S970 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_3 / 0.00392156885936856f))))))))); + float radius_x_3 = _S970 * (F32_sqrt((covar2d_3[int(0)].x))); + float radius_y_3 = _S970 * (F32_sqrt((covar2d_3[int(1)].y))); + float _S971 = (*mean2d_16).x - radius_x_3; + float _S972 = (*mean2d_16).x + radius_x_3; + float _S973 = (*mean2d_16).y - radius_y_3; + float _S974 = (*mean2d_16).y + radius_y_3; + if(_S972 <= 0.0f) + { + _S932 = true; + } + else + { + _S932 = _S971 >= float(image_width_3); + } + if(_S932) + { + _S932 = true; + } + else + { + _S932 = _S974 <= 0.0f; + } + if(_S932) + { + _S932 = true; + } + else + { + _S932 = _S973 >= float(image_height_3); + } + if(_S932) + { + *aabb_xyxy_3 = _S929; + break; + } + *aabb_xyxy_3 = make_float4 (_S971, _S973, _S972, _S974); + *sorting_depth_3 = _S930; + *conic_3 = make_float3 (_S969.rows[int(0)].x, _S969.rows[int(0)].y, _S969.rows[int(1)].y); + *radius_4 = view_radius_3dgs_0(mean_4, scale_3, in_opacity_3, - mul_6(_S935, t_3)); + break; + } + return; +} + +inline __device__ void projection_3dgs_fisheye_none(bool antialiased_4, float3 mean_5, float4 quat_4, float3 scale_4, float in_opacity_4, Matrix R_4, float3 t_4, float fx_17, float fy_17, float cx_8, float cy_8, FixedArray dist_coeffs_16, uint image_width_4, uint image_height_4, float4 * aabb_xyxy_4, float * sorting_depth_4, float * radius_5, float2 * mean2d_17, float * depth_4, float3 * conic_4, float * opacity_4) +{ + for(;;) + { + float4 _S975 = make_float4 (0.0f); + *aabb_xyxy_4 = _S975; + *sorting_depth_4 = 0.0f; + *radius_5 = 0.0f; + *mean2d_17 = make_float2 (0.0f); + *conic_4 = make_float3 (0.0f); + *opacity_4 = 0.0f; + float3 mean_c_4 = mul_6(R_4, mean_5) + t_4; + float _S976 = length_1(mean_c_4); + *depth_4 = _S976; + if(_S976 <= 0.0f) + { + *aabb_xyxy_4 = _S975; + break; + } + Matrix covar2d_4; + Matrix _S977 = makeMatrix (0.0f); + *opacity_4 = 1.0f / (1.0f + (F32_exp((- in_opacity_4)))); + float4 _S978 = normalize_0(quat_4); + float3 _S979 = exp_0(scale_4); + float x_19 = _S978.y; + float x2_4 = x_19 * x_19; + float y2_4 = _S978.z * _S978.z; + float z2_4 = _S978.w * _S978.w; + float xy_4 = _S978.y * _S978.z; + float xz_4 = _S978.y * _S978.w; + float yz_4 = _S978.z * _S978.w; + float wx_4 = _S978.x * _S978.y; + float wy_4 = _S978.x * _S978.z; + float wz_4 = _S978.x * _S978.w; + Matrix M_4 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_4 + z2_4), 2.0f * (xy_4 + wz_4), 2.0f * (xz_4 - wy_4), 2.0f * (xy_4 - wz_4), 1.0f - 2.0f * (x2_4 + z2_4), 2.0f * (yz_4 + wx_4), 2.0f * (xz_4 + wy_4), 2.0f * (yz_4 - wx_4), 1.0f - 2.0f * (x2_4 + y2_4))), makeMatrix (_S979.x, 0.0f, 0.0f, 0.0f, _S979.y, 0.0f, 0.0f, 0.0f, _S979.z)); + Matrix _S980 = transpose_3(R_4); + Matrix covar_c_4 = mul_5(mul_5(R_4, mul_5(M_4, transpose_3(M_4))), _S980); + covar2d_4 = _S977; + float2 _S981 = float2 {mean_c_4.x, mean_c_4.y}; + float r_15 = length_0(_S981); + float _S982 = mean_c_4.z; + float theta_8 = (F32_atan2((r_15), (_S982))); + float k_8; + if(theta_8 < 0.00100000004749745f) + { + k_8 = (1.0f - theta_8 * theta_8 / 3.0f) / _S982; + } + else + { + k_8 = theta_8 / r_15; + } + float2 _S983 = _S981 * make_float2 (k_8); + FixedArray _S984 = dist_coeffs_16; + float2 _S985 = DistNone_distort_0(_S983, &_S984); + *mean2d_17 = make_float2 (fx_17 * _S985.x + cx_8, fy_17 * _S985.y + cy_8); + Matrix J_25; + float2 _S986 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S987; + (&_S987)->primal_0 = _S981; + (&_S987)->differential_0 = _S986; + DiffPair_float_0 _S988 = s_fwd_length_impl_0(&_S987); + DiffPair_float_0 _S989; + (&_S989)->primal_0 = _S988.primal_0; + (&_S989)->differential_0 = _S988.differential_0; + DiffPair_float_0 _S990; + (&_S990)->primal_0 = _S982; + (&_S990)->differential_0 = 0.0f; + DiffPair_float_0 _S991 = _d_atan2_1(&_S989, &_S990); + float s_diff_k_8; + if((_S991.primal_0) < 0.00100000004749745f) + { + float _S992 = _S991.differential_0 * _S991.primal_0; + float _S993 = (0.0f - (_S992 + _S992) * 0.3333333432674408f) * _S982 / (_S982 * _S982); + k_8 = (1.0f - _S991.primal_0 * _S991.primal_0 / 3.0f) / _S982; + s_diff_k_8 = _S993; + } + else + { + float _S994 = (_S991.differential_0 * _S988.primal_0 - _S991.primal_0 * _S988.differential_0) / (_S988.primal_0 * _S988.primal_0); + k_8 = _S991.primal_0 / _S988.primal_0; + s_diff_k_8 = _S994; + } + float2 _S995 = _S981 * make_float2 (k_8); + float2 _S996 = _S986 * make_float2 (k_8) + make_float2 (s_diff_k_8) * _S981; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S997; + (&_S997)->primal_0 = _S995; + (&_S997)->differential_0 = _S996; + FixedArray _S998 = dist_coeffs_16; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S999 = s_fwd_DistNone_distort_0(&_S997, &_S998); + float _S1000 = _S999.differential_0.y * fy_17; + *&(((&J_25)->rows + (int(0)))->x) = _S999.differential_0.x * fx_17; + *&(((&J_25)->rows + (int(1)))->x) = _S1000; + float2 _S1001 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1002; + (&_S1002)->primal_0 = _S981; + (&_S1002)->differential_0 = _S1001; + DiffPair_float_0 _S1003 = s_fwd_length_impl_0(&_S1002); + DiffPair_float_0 _S1004; + (&_S1004)->primal_0 = _S1003.primal_0; + (&_S1004)->differential_0 = _S1003.differential_0; + DiffPair_float_0 _S1005; + (&_S1005)->primal_0 = _S982; + (&_S1005)->differential_0 = 0.0f; + DiffPair_float_0 _S1006 = _d_atan2_1(&_S1004, &_S1005); + if((_S1006.primal_0) < 0.00100000004749745f) + { + float _S1007 = _S1006.differential_0 * _S1006.primal_0; + float _S1008 = (0.0f - (_S1007 + _S1007) * 0.3333333432674408f) * _S982 / (_S982 * _S982); + k_8 = (1.0f - _S1006.primal_0 * _S1006.primal_0 / 3.0f) / _S982; + s_diff_k_8 = _S1008; + } + else + { + float _S1009 = (_S1006.differential_0 * _S1003.primal_0 - _S1006.primal_0 * _S1003.differential_0) / (_S1003.primal_0 * _S1003.primal_0); + k_8 = _S1006.primal_0 / _S1003.primal_0; + s_diff_k_8 = _S1009; + } + float2 _S1010 = _S981 * make_float2 (k_8); + float2 _S1011 = _S1001 * make_float2 (k_8) + make_float2 (s_diff_k_8) * _S981; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1012; + (&_S1012)->primal_0 = _S1010; + (&_S1012)->differential_0 = _S1011; + FixedArray _S1013 = dist_coeffs_16; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1014 = s_fwd_DistNone_distort_0(&_S1012, &_S1013); + float _S1015 = _S1014.differential_0.y * fy_17; + *&(((&J_25)->rows + (int(0)))->y) = _S1014.differential_0.x * fx_17; + *&(((&J_25)->rows + (int(1)))->y) = _S1015; + float2 _S1016 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1017; + (&_S1017)->primal_0 = _S981; + (&_S1017)->differential_0 = _S1016; + DiffPair_float_0 _S1018 = s_fwd_length_impl_0(&_S1017); + DiffPair_float_0 _S1019; + (&_S1019)->primal_0 = _S1018.primal_0; + (&_S1019)->differential_0 = _S1018.differential_0; + DiffPair_float_0 _S1020; + (&_S1020)->primal_0 = _S982; + (&_S1020)->differential_0 = 1.0f; + DiffPair_float_0 _S1021 = _d_atan2_1(&_S1019, &_S1020); + if((_S1021.primal_0) < 0.00100000004749745f) + { + float _S1022 = _S1021.differential_0 * _S1021.primal_0; + float _S1023 = 1.0f - _S1021.primal_0 * _S1021.primal_0 / 3.0f; + float _S1024 = ((0.0f - (_S1022 + _S1022) * 0.3333333432674408f) * _S982 - _S1023) / (_S982 * _S982); + k_8 = _S1023 / _S982; + s_diff_k_8 = _S1024; + } + else + { + float _S1025 = (_S1021.differential_0 * _S1018.primal_0 - _S1021.primal_0 * _S1018.differential_0) / (_S1018.primal_0 * _S1018.primal_0); + k_8 = _S1021.primal_0 / _S1018.primal_0; + s_diff_k_8 = _S1025; + } + float2 _S1026 = _S981 * make_float2 (k_8); + float2 _S1027 = make_float2 (s_diff_k_8) * _S981; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1028; + (&_S1028)->primal_0 = _S1026; + (&_S1028)->differential_0 = _S1027; + FixedArray _S1029 = dist_coeffs_16; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1030 = s_fwd_DistNone_distort_0(&_S1028, &_S1029); + float _S1031 = _S1030.differential_0.y * fy_17; + *&(((&J_25)->rows + (int(0)))->z) = _S1030.differential_0.x * fx_17; + *&(((&J_25)->rows + (int(1)))->z) = _S1031; + Matrix _S1032 = mul_4(mul_3(J_25, covar_c_4), transpose_1(J_25)); + covar2d_4 = _S1032; + float2 mean2d_c_0 = *mean2d_17 - make_float2 (cx_8, cy_8); + float invdet_4 = 1.0f / (_S1032.rows[int(0)].x * _S1032.rows[int(1)].y - _S1032.rows[int(0)].y * _S1032.rows[int(1)].x); + float opac_0 = *opacity_4 * (F32_exp((-0.5f * dot_0(mul_7(makeMatrix (_S1032.rows[int(1)].y * invdet_4, - _S1032.rows[int(0)].y * invdet_4, - _S1032.rows[int(1)].x * invdet_4, _S1032.rows[int(0)].x * invdet_4), mean2d_c_0), mean2d_c_0)))); + bool _S1033; + if(_S982 < 0.0f) + { + _S1033 = opac_0 > 0.00392156885936856f; + } + else + { + _S1033 = false; + } + if(!!_S1033) + { + *aabb_xyxy_4 = _S975; + break; + } + float eps2d_4; + if(antialiased_4) + { + eps2d_4 = 0.10000000149011612f; + } + else + { + eps2d_4 = 0.30000001192092896f; + } + float det_orig_4 = *&(((&covar2d_4)->rows + (int(0)))->x) * *&(((&covar2d_4)->rows + (int(1)))->y) - *&(((&covar2d_4)->rows + (int(0)))->y) * *&(((&covar2d_4)->rows + (int(1)))->x); + float _S1034 = *&(((&covar2d_4)->rows + (int(0)))->x) + eps2d_4; + *&(((&covar2d_4)->rows + (int(0)))->x) = _S1034; + float _S1035 = *&(((&covar2d_4)->rows + (int(1)))->y) + eps2d_4; + *&(((&covar2d_4)->rows + (int(1)))->y) = _S1035; + float det_blur_4 = _S1034 * _S1035 - *&(((&covar2d_4)->rows + (int(0)))->y) * *&(((&covar2d_4)->rows + (int(1)))->x); + float compensation_4 = (F32_sqrt(((F32_max((0.0f), (det_orig_4 / det_blur_4)))))); + if(det_blur_4 <= 0.0f) + { + *aabb_xyxy_4 = _S975; + break; + } + float invdet_5 = 1.0f / (covar2d_4.rows[int(0)].x * covar2d_4.rows[int(1)].y - covar2d_4.rows[int(0)].y * covar2d_4.rows[int(1)].x); + Matrix _S1036 = makeMatrix (covar2d_4.rows[int(1)].y * invdet_5, - covar2d_4.rows[int(0)].y * invdet_5, - covar2d_4.rows[int(1)].x * invdet_5, covar2d_4.rows[int(0)].x * invdet_5); + if(antialiased_4) + { + *opacity_4 = *opacity_4 * compensation_4; + } + if((*opacity_4) < 0.00392156885936856f) + { + *aabb_xyxy_4 = _S975; + break; + } + float _S1037 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_4 / 0.00392156885936856f))))))))); + float radius_x_4 = _S1037 * (F32_sqrt((covar2d_4[int(0)].x))); + float radius_y_4 = _S1037 * (F32_sqrt((covar2d_4[int(1)].y))); + float _S1038 = (*mean2d_17).x - radius_x_4; + float _S1039 = (*mean2d_17).x + radius_x_4; + float _S1040 = (*mean2d_17).y - radius_y_4; + float _S1041 = (*mean2d_17).y + radius_y_4; + if(_S1039 <= 0.0f) + { + _S1033 = true; + } + else + { + _S1033 = _S1038 >= float(image_width_4); + } + if(_S1033) + { + _S1033 = true; + } + else + { + _S1033 = _S1041 <= 0.0f; + } + if(_S1033) + { + _S1033 = true; + } + else + { + _S1033 = _S1040 >= float(image_height_4); + } + if(_S1033) + { + *aabb_xyxy_4 = _S975; + break; + } + *aabb_xyxy_4 = make_float4 (_S1038, _S1040, _S1039, _S1041); + float x_20 = mean_c_4.x; + float y_5 = mean_c_4.y; + float _S1042 = x_20 * x_20 + y_5 * y_5; + *sorting_depth_4 = _S982 * _S982 * _S982 * _S982 + 0.001953125f * _S1042 * _S1042; + *conic_4 = make_float3 (_S1036.rows[int(0)].x, _S1036.rows[int(0)].y, _S1036.rows[int(1)].y); + *radius_5 = view_radius_3dgs_0(mean_5, scale_4, in_opacity_4, - mul_6(_S980, t_4)); + break; + } + return; +} + +inline __device__ void projection_3dgs_fisheye_opencv(bool antialiased_5, float3 mean_6, float4 quat_5, float3 scale_5, float in_opacity_5, Matrix R_5, float3 t_5, float fx_18, float fy_18, float cx_9, float cy_9, FixedArray dist_coeffs_17, uint image_width_5, uint image_height_5, float4 * aabb_xyxy_5, float * sorting_depth_5, float * radius_6, float2 * mean2d_18, float * depth_5, float3 * conic_5, float * opacity_5) +{ + float2 _S1043; + float _S1044; + for(;;) + { + float4 _S1045 = make_float4 (0.0f); + *aabb_xyxy_5 = _S1045; + *sorting_depth_5 = 0.0f; + *radius_6 = 0.0f; + *mean2d_18 = make_float2 (0.0f); + *conic_5 = make_float3 (0.0f); + *opacity_5 = 0.0f; + float3 mean_c_5 = mul_6(R_5, mean_6) + t_5; + float _S1046 = length_1(mean_c_5); + *depth_5 = _S1046; + if(_S1046 <= 0.0f) + { + *aabb_xyxy_5 = _S1045; + break; + } + Matrix covar2d_5; + Matrix _S1047 = makeMatrix (0.0f); + *opacity_5 = 1.0f / (1.0f + (F32_exp((- in_opacity_5)))); + float eps2d_5; + bool is_valid_0; + float4 _S1048 = normalize_0(quat_5); + float3 _S1049 = exp_0(scale_5); + float x_21 = _S1048.y; + float x2_5 = x_21 * x_21; + float y2_5 = _S1048.z * _S1048.z; + float z2_5 = _S1048.w * _S1048.w; + float xy_5 = _S1048.y * _S1048.z; + float xz_5 = _S1048.y * _S1048.w; + float yz_5 = _S1048.z * _S1048.w; + float wx_5 = _S1048.x * _S1048.y; + float wy_5 = _S1048.x * _S1048.z; + float wz_5 = _S1048.x * _S1048.w; + Matrix M_5 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_5 + z2_5), 2.0f * (xy_5 + wz_5), 2.0f * (xz_5 - wy_5), 2.0f * (xy_5 - wz_5), 1.0f - 2.0f * (x2_5 + z2_5), 2.0f * (yz_5 + wx_5), 2.0f * (xz_5 + wy_5), 2.0f * (yz_5 - wx_5), 1.0f - 2.0f * (x2_5 + y2_5))), makeMatrix (_S1049.x, 0.0f, 0.0f, 0.0f, _S1049.y, 0.0f, 0.0f, 0.0f, _S1049.z)); + Matrix _S1050 = transpose_3(R_5); + Matrix covar_c_5 = mul_5(mul_5(R_5, mul_5(M_5, transpose_3(M_5))), _S1050); + for(;;) + { + float k_9; + covar2d_5 = _S1047; + for(;;) + { + float2 _S1051 = float2 {mean_c_5.x, mean_c_5.y}; + _S1043 = _S1051; + float r_16 = length_0(_S1051); + float _S1052 = mean_c_5.z; + _S1044 = _S1052; + float theta_9 = (F32_atan2((r_16), (_S1052))); + bool _S1053 = theta_9 < 0.00100000004749745f; + if(_S1053) + { + k_9 = (1.0f - theta_9 * theta_9 / 3.0f) / _S1052; + } + else + { + k_9 = theta_9 / r_16; + } + float2 _S1054 = _S1051 * make_float2 (k_9); + float2 _S1055 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1056; + (&_S1056)->primal_0 = _S1054; + (&_S1056)->differential_0 = _S1055; + FixedArray _S1057 = dist_coeffs_17; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1058 = s_fwd_DistOpenCV_distort_0(&_S1056, &_S1057); + float2 _S1059 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1060; + (&_S1060)->primal_0 = _S1054; + (&_S1060)->differential_0 = _S1059; + FixedArray _S1061 = dist_coeffs_17; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1062 = s_fwd_DistOpenCV_distort_0(&_S1060, &_S1061); + Matrix _S1063 = transpose_0(makeMatrix (_S1058.differential_0, _S1062.differential_0)); + float _S1064 = (F32_min((determinant_0(_S1063)), ((F32_min((_S1063.rows[int(0)].x), (_S1063.rows[int(1)].y)))))); + if(_S1064 > 0.25f) + { + is_valid_0 = _S1064 < 4.0f; + } + else + { + is_valid_0 = false; + } + if(is_valid_0) + { + FixedArray _S1065 = dist_coeffs_17; + float2 _S1066 = DistOpenCV_distort_0(_S1054, &_S1065); + is_valid_0 = (dot_0(_S1054, _S1066)) >= 0.0f; + } + else + { + is_valid_0 = false; + } + if(!is_valid_0) + { + *mean2d_18 = _S1054; + is_valid_0 = false; + break; + } + if(_S1053) + { + k_9 = (1.0f - theta_9 * theta_9 / 3.0f) / _S1052; + } + else + { + k_9 = theta_9 / r_16; + } + float2 _S1067 = _S1051 * make_float2 (k_9); + FixedArray _S1068 = dist_coeffs_17; + float2 _S1069 = DistOpenCV_distort_0(_S1067, &_S1068); + *mean2d_18 = make_float2 (fx_18 * _S1069.x + cx_9, fy_18 * _S1069.y + cy_9); + is_valid_0 = true; + break; + } + if(!is_valid_0) { is_valid_0 = false; break; } - Matrix J_7; - float2 _S431 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S432; - (&_S432)->primal_0 = _S391; - (&_S432)->differential_0 = _S431; - DiffPair_float_0 _S433 = s_fwd_length_impl_0(&_S432); - float _S434 = _S392; - DiffPair_float_0 _S435; - (&_S435)->primal_0 = _S433.primal_0; - (&_S435)->differential_0 = _S433.differential_0; - DiffPair_float_0 _S436; - (&_S436)->primal_0 = _S392; - (&_S436)->differential_0 = 0.0f; - DiffPair_float_0 _S437 = _d_atan2_1(&_S435, &_S436); - if((_S437.primal_0) < 0.00100000004749745f) + Matrix J_26; + float2 _S1070 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1071; + (&_S1071)->primal_0 = _S1043; + (&_S1071)->differential_0 = _S1070; + DiffPair_float_0 _S1072 = s_fwd_length_impl_0(&_S1071); + float _S1073 = _S1044; + DiffPair_float_0 _S1074; + (&_S1074)->primal_0 = _S1072.primal_0; + (&_S1074)->differential_0 = _S1072.differential_0; + DiffPair_float_0 _S1075; + (&_S1075)->primal_0 = _S1044; + (&_S1075)->differential_0 = 0.0f; + DiffPair_float_0 _S1076 = _d_atan2_1(&_S1074, &_S1075); + if((_S1076.primal_0) < 0.00100000004749745f) { - float _S438 = _S437.differential_0 * _S437.primal_0; - float _S439 = (0.0f - (_S438 + _S438) * 0.3333333432674408f) * _S392 / (_S392 * _S392); - k_2 = (1.0f - _S437.primal_0 * _S437.primal_0 / 3.0f) / _S392; - eps2d_1 = _S439; + float _S1077 = _S1076.differential_0 * _S1076.primal_0; + float _S1078 = (0.0f - (_S1077 + _S1077) * 0.3333333432674408f) * _S1044 / (_S1044 * _S1044); + k_9 = (1.0f - _S1076.primal_0 * _S1076.primal_0 / 3.0f) / _S1044; + eps2d_5 = _S1078; } else { - float _S440 = (_S437.differential_0 * _S433.primal_0 - _S437.primal_0 * _S433.differential_0) / (_S433.primal_0 * _S433.primal_0); - k_2 = _S437.primal_0 / _S433.primal_0; - eps2d_1 = _S440; + float _S1079 = (_S1076.differential_0 * _S1072.primal_0 - _S1076.primal_0 * _S1072.differential_0) / (_S1072.primal_0 * _S1072.primal_0); + k_9 = _S1076.primal_0 / _S1072.primal_0; + eps2d_5 = _S1079; } - float2 _S441 = _S391 * make_float2 (k_2); - float2 _S442 = _S431 * make_float2 (k_2) + make_float2 (eps2d_1) * _S391; - float u_22 = _S441.x; - float s_diff_u_12 = _S442.x; - float v_22 = _S441.y; - float s_diff_v_12 = _S442.y; - float _S443 = s_diff_u_12 * u_22; - float _S444 = s_diff_v_12 * v_22; - float r2_22 = u_22 * u_22 + v_22 * v_22; - float s_diff_r2_12 = _S443 + _S443 + (_S444 + _S444); - float _S445 = _S395 + r2_22 * _S396; - float _S446 = _S394 + r2_22 * _S445; - float _S447 = _S393 + r2_22 * _S446; - float2 _S448 = _S442 * make_float2 (1.0f + r2_22 * _S447) + make_float2 (s_diff_r2_12 * _S447 + (s_diff_r2_12 * _S446 + (s_diff_r2_12 * _S445 + s_diff_r2_12 * _S396 * r2_22) * r2_22) * r2_22) * _S441 + make_float2 (s_diff_u_12 * _S403 * v_22 + s_diff_v_12 * (_S403 * u_22) + (s_diff_r2_12 + (s_diff_u_12 * 2.0f * u_22 + s_diff_u_12 * (2.0f * u_22))) * _S398 + s_diff_r2_12 * _S399, s_diff_u_12 * _S404 * v_22 + s_diff_v_12 * (_S404 * u_22) + (s_diff_r2_12 + (s_diff_v_12 * 2.0f * v_22 + s_diff_v_12 * (2.0f * v_22))) * _S397 + s_diff_r2_12 * _S400); - float2 _S449 = _S448 + make_float2 (_S448.x * _S401 + _S448.y * _S402, 0.0f); - float _S450 = _S449.y * fy_5; - *&(((&J_7)->rows + (int(0)))->x) = _S449.x * fx_5; - *&(((&J_7)->rows + (int(1)))->x) = _S450; - float2 _S451 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S452; - (&_S452)->primal_0 = _S391; - (&_S452)->differential_0 = _S451; - DiffPair_float_0 _S453 = s_fwd_length_impl_0(&_S452); - DiffPair_float_0 _S454; - (&_S454)->primal_0 = _S453.primal_0; - (&_S454)->differential_0 = _S453.differential_0; - DiffPair_float_0 _S455; - (&_S455)->primal_0 = _S434; - (&_S455)->differential_0 = 0.0f; - DiffPair_float_0 _S456 = _d_atan2_1(&_S454, &_S455); - if((_S456.primal_0) < 0.00100000004749745f) + float2 _S1080 = _S1043 * make_float2 (k_9); + float2 _S1081 = _S1070 * make_float2 (k_9) + make_float2 (eps2d_5) * _S1043; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1082; + (&_S1082)->primal_0 = _S1080; + (&_S1082)->differential_0 = _S1081; + FixedArray _S1083 = dist_coeffs_17; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1084 = s_fwd_DistOpenCV_distort_0(&_S1082, &_S1083); + float _S1085 = _S1084.differential_0.y * fy_18; + *&(((&J_26)->rows + (int(0)))->x) = _S1084.differential_0.x * fx_18; + *&(((&J_26)->rows + (int(1)))->x) = _S1085; + float2 _S1086 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1087; + (&_S1087)->primal_0 = _S1043; + (&_S1087)->differential_0 = _S1086; + DiffPair_float_0 _S1088 = s_fwd_length_impl_0(&_S1087); + DiffPair_float_0 _S1089; + (&_S1089)->primal_0 = _S1088.primal_0; + (&_S1089)->differential_0 = _S1088.differential_0; + DiffPair_float_0 _S1090; + (&_S1090)->primal_0 = _S1073; + (&_S1090)->differential_0 = 0.0f; + DiffPair_float_0 _S1091 = _d_atan2_1(&_S1089, &_S1090); + if((_S1091.primal_0) < 0.00100000004749745f) { - float _S457 = _S456.differential_0 * _S456.primal_0; - float _S458 = (0.0f - (_S457 + _S457) * 0.3333333432674408f) * _S392 / (_S392 * _S392); - k_2 = (1.0f - _S456.primal_0 * _S456.primal_0 / 3.0f) / _S392; - eps2d_1 = _S458; + float _S1092 = _S1091.differential_0 * _S1091.primal_0; + float _S1093 = (0.0f - (_S1092 + _S1092) * 0.3333333432674408f) * _S1044 / (_S1044 * _S1044); + k_9 = (1.0f - _S1091.primal_0 * _S1091.primal_0 / 3.0f) / _S1044; + eps2d_5 = _S1093; } else { - float _S459 = (_S456.differential_0 * _S453.primal_0 - _S456.primal_0 * _S453.differential_0) / (_S453.primal_0 * _S453.primal_0); - k_2 = _S456.primal_0 / _S453.primal_0; - eps2d_1 = _S459; + float _S1094 = (_S1091.differential_0 * _S1088.primal_0 - _S1091.primal_0 * _S1088.differential_0) / (_S1088.primal_0 * _S1088.primal_0); + k_9 = _S1091.primal_0 / _S1088.primal_0; + eps2d_5 = _S1094; } - float2 _S460 = _S391 * make_float2 (k_2); - float2 _S461 = _S451 * make_float2 (k_2) + make_float2 (eps2d_1) * _S391; - float u_23 = _S460.x; - float s_diff_u_13 = _S461.x; - float v_23 = _S460.y; - float s_diff_v_13 = _S461.y; - float _S462 = s_diff_u_13 * u_23; - float _S463 = s_diff_v_13 * v_23; - float r2_23 = u_23 * u_23 + v_23 * v_23; - float s_diff_r2_13 = _S462 + _S462 + (_S463 + _S463); - float _S464 = _S395 + r2_23 * _S396; - float _S465 = _S394 + r2_23 * _S464; - float _S466 = _S393 + r2_23 * _S465; - float2 _S467 = _S461 * make_float2 (1.0f + r2_23 * _S466) + make_float2 (s_diff_r2_13 * _S466 + (s_diff_r2_13 * _S465 + (s_diff_r2_13 * _S464 + s_diff_r2_13 * _S396 * r2_23) * r2_23) * r2_23) * _S460 + make_float2 (s_diff_u_13 * _S403 * v_23 + s_diff_v_13 * (_S403 * u_23) + (s_diff_r2_13 + (s_diff_u_13 * 2.0f * u_23 + s_diff_u_13 * (2.0f * u_23))) * _S398 + s_diff_r2_13 * _S399, s_diff_u_13 * _S404 * v_23 + s_diff_v_13 * (_S404 * u_23) + (s_diff_r2_13 + (s_diff_v_13 * 2.0f * v_23 + s_diff_v_13 * (2.0f * v_23))) * _S397 + s_diff_r2_13 * _S400); - float2 _S468 = _S467 + make_float2 (_S467.x * _S401 + _S467.y * _S402, 0.0f); - float _S469 = _S468.y * fy_5; - *&(((&J_7)->rows + (int(0)))->y) = _S468.x * fx_5; - *&(((&J_7)->rows + (int(1)))->y) = _S469; - float2 _S470 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S471; - (&_S471)->primal_0 = _S391; - (&_S471)->differential_0 = _S470; - DiffPair_float_0 _S472 = s_fwd_length_impl_0(&_S471); - DiffPair_float_0 _S473; - (&_S473)->primal_0 = _S472.primal_0; - (&_S473)->differential_0 = _S472.differential_0; - DiffPair_float_0 _S474; - (&_S474)->primal_0 = _S392; - (&_S474)->differential_0 = 1.0f; - DiffPair_float_0 _S475 = _d_atan2_1(&_S473, &_S474); - if((_S475.primal_0) < 0.00100000004749745f) + float2 _S1095 = _S1043 * make_float2 (k_9); + float2 _S1096 = _S1086 * make_float2 (k_9) + make_float2 (eps2d_5) * _S1043; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1097; + (&_S1097)->primal_0 = _S1095; + (&_S1097)->differential_0 = _S1096; + FixedArray _S1098 = dist_coeffs_17; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1099 = s_fwd_DistOpenCV_distort_0(&_S1097, &_S1098); + float _S1100 = _S1099.differential_0.y * fy_18; + *&(((&J_26)->rows + (int(0)))->y) = _S1099.differential_0.x * fx_18; + *&(((&J_26)->rows + (int(1)))->y) = _S1100; + float2 _S1101 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1102; + (&_S1102)->primal_0 = _S1043; + (&_S1102)->differential_0 = _S1101; + DiffPair_float_0 _S1103 = s_fwd_length_impl_0(&_S1102); + DiffPair_float_0 _S1104; + (&_S1104)->primal_0 = _S1103.primal_0; + (&_S1104)->differential_0 = _S1103.differential_0; + DiffPair_float_0 _S1105; + (&_S1105)->primal_0 = _S1044; + (&_S1105)->differential_0 = 1.0f; + DiffPair_float_0 _S1106 = _d_atan2_1(&_S1104, &_S1105); + if((_S1106.primal_0) < 0.00100000004749745f) { - float _S476 = _S475.differential_0 * _S475.primal_0; - float _S477 = 1.0f - _S475.primal_0 * _S475.primal_0 / 3.0f; - float _S478 = ((0.0f - (_S476 + _S476) * 0.3333333432674408f) * _S392 - _S477) / (_S392 * _S392); - k_2 = _S477 / _S392; - eps2d_1 = _S478; + float _S1107 = _S1106.differential_0 * _S1106.primal_0; + float _S1108 = 1.0f - _S1106.primal_0 * _S1106.primal_0 / 3.0f; + float _S1109 = ((0.0f - (_S1107 + _S1107) * 0.3333333432674408f) * _S1044 - _S1108) / (_S1044 * _S1044); + k_9 = _S1108 / _S1044; + eps2d_5 = _S1109; } else { - float _S479 = (_S475.differential_0 * _S472.primal_0 - _S475.primal_0 * _S472.differential_0) / (_S472.primal_0 * _S472.primal_0); - k_2 = _S475.primal_0 / _S472.primal_0; - eps2d_1 = _S479; + float _S1110 = (_S1106.differential_0 * _S1103.primal_0 - _S1106.primal_0 * _S1103.differential_0) / (_S1103.primal_0 * _S1103.primal_0); + k_9 = _S1106.primal_0 / _S1103.primal_0; + eps2d_5 = _S1110; } - float2 _S480 = _S391 * make_float2 (k_2); - float2 _S481 = make_float2 (eps2d_1) * _S391; - float u_24 = _S480.x; - float s_diff_u_14 = _S481.x; - float v_24 = _S480.y; - float s_diff_v_14 = _S481.y; - float _S482 = s_diff_u_14 * u_24; - float _S483 = s_diff_v_14 * v_24; - float r2_24 = u_24 * u_24 + v_24 * v_24; - float s_diff_r2_14 = _S482 + _S482 + (_S483 + _S483); - float _S484 = _S395 + r2_24 * _S396; - float _S485 = _S394 + r2_24 * _S484; - float _S486 = _S393 + r2_24 * _S485; - float2 _S487 = _S481 * make_float2 (1.0f + r2_24 * _S486) + make_float2 (s_diff_r2_14 * _S486 + (s_diff_r2_14 * _S485 + (s_diff_r2_14 * _S484 + s_diff_r2_14 * _S396 * r2_24) * r2_24) * r2_24) * _S480 + make_float2 (s_diff_u_14 * _S403 * v_24 + s_diff_v_14 * (_S403 * u_24) + (s_diff_r2_14 + (s_diff_u_14 * 2.0f * u_24 + s_diff_u_14 * (2.0f * u_24))) * _S398 + s_diff_r2_14 * _S399, s_diff_u_14 * _S404 * v_24 + s_diff_v_14 * (_S404 * u_24) + (s_diff_r2_14 + (s_diff_v_14 * 2.0f * v_24 + s_diff_v_14 * (2.0f * v_24))) * _S397 + s_diff_r2_14 * _S400); - float2 _S488 = _S487 + make_float2 (_S487.x * _S401 + _S487.y * _S402, 0.0f); - float _S489 = _S488.y * fy_5; - *&(((&J_7)->rows + (int(0)))->z) = _S488.x * fx_5; - *&(((&J_7)->rows + (int(1)))->z) = _S489; - covar2d_1 = mul_4(mul_3(J_7, covar_c_1), transpose_1(J_7)); + float2 _S1111 = _S1043 * make_float2 (k_9); + float2 _S1112 = make_float2 (eps2d_5) * _S1043; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1113; + (&_S1113)->primal_0 = _S1111; + (&_S1113)->differential_0 = _S1112; + FixedArray _S1114 = dist_coeffs_17; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1115 = s_fwd_DistOpenCV_distort_0(&_S1113, &_S1114); + float _S1116 = _S1115.differential_0.y * fy_18; + *&(((&J_26)->rows + (int(0)))->z) = _S1115.differential_0.x * fx_18; + *&(((&J_26)->rows + (int(1)))->z) = _S1116; + covar2d_5 = mul_4(mul_3(J_26, covar_c_5), transpose_1(J_26)); is_valid_0 = true; break; } bool is_valid_1 = true & is_valid_0; - float2 mean2d_c_0 = *mean2d_5 - make_float2 (cx_2, cy_2); - float invdet_1 = 1.0f / (covar2d_1.rows[int(0)].x * covar2d_1.rows[int(1)].y - covar2d_1.rows[int(0)].y * covar2d_1.rows[int(1)].x); - float opac_0 = *opacity_1 * (F32_exp((-0.5f * dot_0(mul_7(makeMatrix (covar2d_1.rows[int(1)].y * invdet_1, - covar2d_1.rows[int(0)].y * invdet_1, - covar2d_1.rows[int(1)].x * invdet_1, covar2d_1.rows[int(0)].x * invdet_1), mean2d_c_0), mean2d_c_0)))); - if(_S392 < 0.0f) + float2 mean2d_c_1 = *mean2d_18 - make_float2 (cx_9, cy_9); + float invdet_6 = 1.0f / (covar2d_5.rows[int(0)].x * covar2d_5.rows[int(1)].y - covar2d_5.rows[int(0)].y * covar2d_5.rows[int(1)].x); + float opac_1 = *opacity_5 * (F32_exp((-0.5f * dot_0(mul_7(makeMatrix (covar2d_5.rows[int(1)].y * invdet_6, - covar2d_5.rows[int(0)].y * invdet_6, - covar2d_5.rows[int(1)].x * invdet_6, covar2d_5.rows[int(0)].x * invdet_6), mean2d_c_1), mean2d_c_1)))); + if(_S1044 < 0.0f) { - is_valid_0 = opac_0 > 0.00392156885936856f; + is_valid_0 = opac_1 > 0.00392156885936856f; } else { @@ -2194,54 +4592,54 @@ inline __device__ void projection_3dgs_fisheye(bool antialiased_1, float3 mean_ } if(!is_valid_0) { - *aabb_xyxy_1 = make_float4 (0.0f); + *aabb_xyxy_5 = _S1045; break; } - if(antialiased_1) + if(antialiased_5) { - eps2d_1 = 0.10000000149011612f; + eps2d_5 = 0.10000000149011612f; } else { - eps2d_1 = 0.30000001192092896f; + eps2d_5 = 0.30000001192092896f; } - float det_orig_1 = *&(((&covar2d_1)->rows + (int(0)))->x) * *&(((&covar2d_1)->rows + (int(1)))->y) - *&(((&covar2d_1)->rows + (int(0)))->y) * *&(((&covar2d_1)->rows + (int(1)))->x); - float _S490 = *&(((&covar2d_1)->rows + (int(0)))->x) + eps2d_1; - *&(((&covar2d_1)->rows + (int(0)))->x) = _S490; - float _S491 = *&(((&covar2d_1)->rows + (int(1)))->y) + eps2d_1; - *&(((&covar2d_1)->rows + (int(1)))->y) = _S491; - float det_blur_1 = _S490 * _S491 - *&(((&covar2d_1)->rows + (int(0)))->y) * *&(((&covar2d_1)->rows + (int(1)))->x); - float compensation_1 = (F32_sqrt(((F32_max((0.0f), (det_orig_1 / det_blur_1)))))); - if(det_blur_1 <= 0.0f) + float det_orig_5 = *&(((&covar2d_5)->rows + (int(0)))->x) * *&(((&covar2d_5)->rows + (int(1)))->y) - *&(((&covar2d_5)->rows + (int(0)))->y) * *&(((&covar2d_5)->rows + (int(1)))->x); + float _S1117 = *&(((&covar2d_5)->rows + (int(0)))->x) + eps2d_5; + *&(((&covar2d_5)->rows + (int(0)))->x) = _S1117; + float _S1118 = *&(((&covar2d_5)->rows + (int(1)))->y) + eps2d_5; + *&(((&covar2d_5)->rows + (int(1)))->y) = _S1118; + float det_blur_5 = _S1117 * _S1118 - *&(((&covar2d_5)->rows + (int(0)))->y) * *&(((&covar2d_5)->rows + (int(1)))->x); + float compensation_5 = (F32_sqrt(((F32_max((0.0f), (det_orig_5 / det_blur_5)))))); + if(det_blur_5 <= 0.0f) { - *aabb_xyxy_1 = make_float4 (0.0f); + *aabb_xyxy_5 = _S1045; break; } - float invdet_2 = 1.0f / (covar2d_1.rows[int(0)].x * covar2d_1.rows[int(1)].y - covar2d_1.rows[int(0)].y * covar2d_1.rows[int(1)].x); - Matrix _S492 = makeMatrix (covar2d_1.rows[int(1)].y * invdet_2, - covar2d_1.rows[int(0)].y * invdet_2, - covar2d_1.rows[int(1)].x * invdet_2, covar2d_1.rows[int(0)].x * invdet_2); - if(antialiased_1) + float invdet_7 = 1.0f / (covar2d_5.rows[int(0)].x * covar2d_5.rows[int(1)].y - covar2d_5.rows[int(0)].y * covar2d_5.rows[int(1)].x); + Matrix _S1119 = makeMatrix (covar2d_5.rows[int(1)].y * invdet_7, - covar2d_5.rows[int(0)].y * invdet_7, - covar2d_5.rows[int(1)].x * invdet_7, covar2d_5.rows[int(0)].x * invdet_7); + if(antialiased_5) { - *opacity_1 = *opacity_1 * compensation_1; + *opacity_5 = *opacity_5 * compensation_5; } - if((*opacity_1) < 0.00392156885936856f) + if((*opacity_5) < 0.00392156885936856f) { - *aabb_xyxy_1 = make_float4 (0.0f); + *aabb_xyxy_5 = _S1045; break; } - float _S493 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_1 / 0.00392156885936856f))))))))); - float radius_x_1 = _S493 * (F32_sqrt((covar2d_1[int(0)].x))); - float radius_y_1 = _S493 * (F32_sqrt((covar2d_1[int(1)].y))); - float _S494 = (*mean2d_5).x - radius_x_1; - float _S495 = (*mean2d_5).x + radius_x_1; - float _S496 = (*mean2d_5).y - radius_y_1; - float _S497 = (*mean2d_5).y + radius_y_1; - if(_S495 <= 0.0f) + float _S1120 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_5 / 0.00392156885936856f))))))))); + float radius_x_5 = _S1120 * (F32_sqrt((covar2d_5[int(0)].x))); + float radius_y_5 = _S1120 * (F32_sqrt((covar2d_5[int(1)].y))); + float _S1121 = (*mean2d_18).x - radius_x_5; + float _S1122 = (*mean2d_18).x + radius_x_5; + float _S1123 = (*mean2d_18).y - radius_y_5; + float _S1124 = (*mean2d_18).y + radius_y_5; + if(_S1122 <= 0.0f) { is_valid_0 = true; } else { - is_valid_0 = _S494 >= float(image_width_1); + is_valid_0 = _S1121 >= float(image_width_5); } if(is_valid_0) { @@ -2249,7 +4647,7 @@ inline __device__ void projection_3dgs_fisheye(bool antialiased_1, float3 mean_ } else { - is_valid_0 = _S497 <= 0.0f; + is_valid_0 = _S1124 <= 0.0f; } if(is_valid_0) { @@ -2257,304 +4655,265 @@ inline __device__ void projection_3dgs_fisheye(bool antialiased_1, float3 mean_ } else { - is_valid_0 = _S496 >= float(image_height_1); + is_valid_0 = _S1123 >= float(image_height_5); } if(is_valid_0) { - *aabb_xyxy_1 = make_float4 (0.0f); + *aabb_xyxy_5 = _S1045; break; } - *aabb_xyxy_1 = make_float4 (_S494, _S496, _S495, _S497); - float x_17 = mean_c_1.x; - float y_5 = mean_c_1.y; - float _S498 = x_17 * x_17 + y_5 * y_5; - *sorting_depth_1 = _S392 * _S392 * _S392 * _S392 + 0.001953125f * _S498 * _S498; - *conic_1 = make_float3 (_S492.rows[int(0)].x, _S492.rows[int(0)].y, _S492.rows[int(1)].y); - *radius_2 = view_radius_3dgs_0(mean_2, scale_1, in_opacity_1, - mul_6(_S409, t_1)); + *aabb_xyxy_5 = make_float4 (_S1121, _S1123, _S1122, _S1124); + float x_22 = mean_c_5.x; + float y_6 = mean_c_5.y; + float _S1125 = x_22 * x_22 + y_6 * y_6; + *sorting_depth_5 = _S1044 * _S1044 * _S1044 * _S1044 + 0.001953125f * _S1125 * _S1125; + *conic_5 = make_float3 (_S1119.rows[int(0)].x, _S1119.rows[int(0)].y, _S1119.rows[int(1)].y); + *radius_6 = view_radius_3dgs_0(mean_6, scale_5, in_opacity_5, - mul_6(_S1050, t_5)); break; } return; } -inline __device__ void projection_3dgs_equisolid(bool antialiased_2, float3 mean_3, float4 quat_2, float3 scale_2, float in_opacity_2, Matrix R_2, float3 t_2, float fx_6, float fy_6, float cx_3, float cy_3, FixedArray dist_coeffs_6, uint image_width_2, uint image_height_2, float4 * aabb_xyxy_2, float * sorting_depth_2, float * radius_3, float2 * mean2d_6, float * depth_2, float3 * conic_2, float * opacity_2) +inline __device__ void projection_3dgs_fisheye_prism(bool antialiased_6, float3 mean_7, float4 quat_6, float3 scale_6, float in_opacity_6, Matrix R_6, float3 t_6, float fx_19, float fy_19, float cx_10, float cy_10, FixedArray dist_coeffs_18, uint image_width_6, uint image_height_6, float4 * aabb_xyxy_6, float * sorting_depth_6, float * radius_7, float2 * mean2d_19, float * depth_6, float3 * conic_6, float * opacity_6) { - float2 _S499; - float _S500; - float _S501; - float _S502; - float _S503; - float _S504; - float _S505; - float _S506; - float _S507; - float _S508; - float _S509; - float _S510; - float _S511; - float _S512; - bool _S513; + float2 _S1126; + float _S1127; for(;;) { - float3 mean_c_2 = mul_6(R_2, mean_3) + t_2; - float _S514 = length_1(mean_c_2); - *depth_2 = _S514; - if(_S514 <= 0.0f) + float4 _S1128 = make_float4 (0.0f); + *aabb_xyxy_6 = _S1128; + *sorting_depth_6 = 0.0f; + *radius_7 = 0.0f; + *mean2d_19 = make_float2 (0.0f); + *conic_6 = make_float3 (0.0f); + *opacity_6 = 0.0f; + float3 mean_c_6 = mul_6(R_6, mean_7) + t_6; + float _S1129 = length_1(mean_c_6); + *depth_6 = _S1129; + if(_S1129 <= 0.0f) { - *aabb_xyxy_2 = make_float4 (0.0f); + *aabb_xyxy_6 = _S1128; break; } - Matrix covar2d_2; - *opacity_2 = 1.0f / (1.0f + (F32_exp((- in_opacity_2)))); + Matrix covar2d_6; + Matrix _S1130 = makeMatrix (0.0f); + *opacity_6 = 1.0f / (1.0f + (F32_exp((- in_opacity_6)))); + float eps2d_6; bool is_valid_2; - float eps2d_2; - float4 _S515 = normalize_0(quat_2); - float3 _S516 = exp_0(scale_2); - float x_18 = _S515.y; - float x2_2 = x_18 * x_18; - float y2_2 = _S515.z * _S515.z; - float z2_2 = _S515.w * _S515.w; - float xy_2 = _S515.y * _S515.z; - float xz_2 = _S515.y * _S515.w; - float yz_2 = _S515.z * _S515.w; - float wx_2 = _S515.x * _S515.y; - float wy_2 = _S515.x * _S515.z; - float wz_2 = _S515.x * _S515.w; - Matrix M_2 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_2 + z2_2), 2.0f * (xy_2 + wz_2), 2.0f * (xz_2 - wy_2), 2.0f * (xy_2 - wz_2), 1.0f - 2.0f * (x2_2 + z2_2), 2.0f * (yz_2 + wx_2), 2.0f * (xz_2 + wy_2), 2.0f * (yz_2 - wx_2), 1.0f - 2.0f * (x2_2 + y2_2))), makeMatrix (_S516.x, 0.0f, 0.0f, 0.0f, _S516.y, 0.0f, 0.0f, 0.0f, _S516.z)); - Matrix _S517 = transpose_3(R_2); - Matrix covar_c_2 = mul_5(mul_5(R_2, mul_5(M_2, transpose_3(M_2))), _S517); + float4 _S1131 = normalize_0(quat_6); + float3 _S1132 = exp_0(scale_6); + float x_23 = _S1131.y; + float x2_6 = x_23 * x_23; + float y2_6 = _S1131.z * _S1131.z; + float z2_6 = _S1131.w * _S1131.w; + float xy_6 = _S1131.y * _S1131.z; + float xz_6 = _S1131.y * _S1131.w; + float yz_6 = _S1131.z * _S1131.w; + float wx_6 = _S1131.x * _S1131.y; + float wy_6 = _S1131.x * _S1131.z; + float wz_6 = _S1131.x * _S1131.w; + Matrix M_6 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_6 + z2_6), 2.0f * (xy_6 + wz_6), 2.0f * (xz_6 - wy_6), 2.0f * (xy_6 - wz_6), 1.0f - 2.0f * (x2_6 + z2_6), 2.0f * (yz_6 + wx_6), 2.0f * (xz_6 + wy_6), 2.0f * (yz_6 - wx_6), 1.0f - 2.0f * (x2_6 + y2_6))), makeMatrix (_S1132.x, 0.0f, 0.0f, 0.0f, _S1132.y, 0.0f, 0.0f, 0.0f, _S1132.z)); + Matrix _S1133 = transpose_3(R_6); + Matrix covar_c_6 = mul_5(mul_5(R_6, mul_5(M_6, transpose_3(M_6))), _S1133); for(;;) { - float k_3; + float k_10; + covar2d_6 = _S1130; for(;;) { - float2 _S518 = float2 {mean_c_2.x, mean_c_2.y}; - _S499 = _S518; - float r_10 = length_0(_S518); - float _S519 = mean_c_2.z; - _S500 = _S519; - float theta_3 = (F32_atan2((r_10), (_S519))); - if(r_10 < 9.99999997475242708e-07f) + float2 _S1134 = float2 {mean_c_6.x, mean_c_6.y}; + _S1126 = _S1134; + float r_17 = length_0(_S1134); + float _S1135 = mean_c_6.z; + _S1127 = _S1135; + float theta_10 = (F32_atan2((r_17), (_S1135))); + bool _S1136 = theta_10 < 0.00100000004749745f; + if(_S1136) { - k_3 = (1.0f - theta_3 * theta_3 / 24.0f) / _S519; + k_10 = (1.0f - theta_10 * theta_10 / 3.0f) / _S1135; } else { - k_3 = 2.0f * (F32_sin((0.5f * theta_3))) / r_10; + k_10 = theta_10 / r_17; } - float2 _S520 = _S518 * make_float2 (k_3); - *mean2d_6 = _S520; - float2 _S521 = make_float2 (1.0f, 0.0f); - _S501 = dist_coeffs_6[int(0)]; - _S502 = dist_coeffs_6[int(1)]; - _S503 = dist_coeffs_6[int(2)]; - _S504 = dist_coeffs_6[int(3)]; - _S505 = dist_coeffs_6[int(4)]; - _S506 = dist_coeffs_6[int(5)]; - _S507 = dist_coeffs_6[int(6)]; - _S508 = dist_coeffs_6[int(7)]; - _S509 = dist_coeffs_6[int(8)]; - _S510 = dist_coeffs_6[int(9)]; - float u_25 = _S520.x; - float v_25 = _S520.y; - float _S522 = u_25 + u_25; - float r2_25 = u_25 * u_25 + v_25 * v_25; - float _S523 = dist_coeffs_6[int(2)] + r2_25 * dist_coeffs_6[int(3)]; - float _S524 = dist_coeffs_6[int(1)] + r2_25 * _S523; - float _S525 = dist_coeffs_6[int(0)] + r2_25 * _S524; - float _S526 = _S522 * _S525 + (_S522 * _S524 + (_S522 * _S523 + _S522 * dist_coeffs_6[int(3)] * r2_25) * r2_25) * r2_25; - float radial_5 = 1.0f + r2_25 * _S525; - float _S527 = 2.0f * dist_coeffs_6[int(4)]; - _S511 = _S527; - float _S528 = _S527 * u_25; - float _S529 = 2.0f * u_25; - float s_diff_du_3 = _S527 * v_25 + (_S522 + (_S529 + _S529)) * dist_coeffs_6[int(5)] + _S522 * dist_coeffs_6[int(6)]; - float _S530 = 2.0f * dist_coeffs_6[int(5)]; - _S512 = _S530; - float _S531 = 2.0f * v_25; - float2 _S532 = _S521 * make_float2 (radial_5) + make_float2 (_S526) * _S520 + make_float2 (s_diff_du_3, _S530 * v_25 + _S522 * dist_coeffs_6[int(4)] + _S522 * dist_coeffs_6[int(7)]); - float _S533 = v_25 + v_25; - float2 _S534 = make_float2 (0.0f, 1.0f) * make_float2 (radial_5) + make_float2 (_S533 * _S525 + (_S533 * _S524 + (_S533 * _S523 + _S533 * dist_coeffs_6[int(3)] * r2_25) * r2_25) * r2_25) * _S520 + make_float2 (_S528 + _S533 * dist_coeffs_6[int(5)] + _S533 * dist_coeffs_6[int(6)], _S530 * u_25 + (_S533 + (_S531 + _S531)) * dist_coeffs_6[int(4)] + _S533 * dist_coeffs_6[int(7)]); - Matrix _S535 = transpose_0(makeMatrix (_S532 + make_float2 (_S532.x * dist_coeffs_6[int(8)] + _S532.y * dist_coeffs_6[int(9)], 0.0f), _S534 + make_float2 (_S534.x * dist_coeffs_6[int(8)] + _S534.y * dist_coeffs_6[int(9)], 0.0f))); - bool _S536 = !((F32_min((determinant_0(_S535)), ((F32_min((_S535.rows[int(0)].x), (_S535.rows[int(1)].y)))))) > 0.0f); - _S513 = _S536; - if(_S536) + float2 _S1137 = _S1134 * make_float2 (k_10); + float2 _S1138 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1139; + (&_S1139)->primal_0 = _S1137; + (&_S1139)->differential_0 = _S1138; + FixedArray _S1140 = dist_coeffs_18; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1141 = s_fwd_DistThinPrism_distort_0(&_S1139, &_S1140); + float2 _S1142 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1143; + (&_S1143)->primal_0 = _S1137; + (&_S1143)->differential_0 = _S1142; + FixedArray _S1144 = dist_coeffs_18; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1145 = s_fwd_DistThinPrism_distort_0(&_S1143, &_S1144); + Matrix _S1146 = transpose_0(makeMatrix (_S1141.differential_0, _S1145.differential_0)); + float _S1147 = (F32_min((determinant_0(_S1146)), ((F32_min((_S1146.rows[int(0)].x), (_S1146.rows[int(1)].y)))))); + if(_S1147 > 0.25f) { + is_valid_2 = _S1147 < 4.0f; + } + else + { + is_valid_2 = false; + } + if(is_valid_2) + { + FixedArray _S1148 = dist_coeffs_18; + float2 _S1149 = DistThinPrism_distort_0(_S1137, &_S1148); + is_valid_2 = (dot_0(_S1137, _S1149)) >= 0.0f; + } + else + { + is_valid_2 = false; + } + if(!is_valid_2) + { + *mean2d_19 = _S1137; + is_valid_2 = false; break; } - float u_26 = (*mean2d_6).x; - float v_26 = (*mean2d_6).y; - float r2_26 = u_26 * u_26 + v_26 * v_26; - float2 _S537 = *mean2d_6 * make_float2 (1.0f + r2_26 * (dist_coeffs_6[int(0)] + r2_26 * (dist_coeffs_6[int(1)] + r2_26 * (dist_coeffs_6[int(2)] + r2_26 * dist_coeffs_6[int(3)])))) + make_float2 (_S527 * u_26 * v_26 + dist_coeffs_6[int(5)] * (r2_26 + 2.0f * u_26 * u_26) + dist_coeffs_6[int(6)] * r2_26, _S530 * u_26 * v_26 + dist_coeffs_6[int(4)] * (r2_26 + 2.0f * v_26 * v_26) + dist_coeffs_6[int(7)] * r2_26); - float2 _S538 = _S537 + make_float2 (dist_coeffs_6[int(8)] * _S537.x + dist_coeffs_6[int(9)] * _S537.y, 0.0f); - *mean2d_6 = make_float2 (fx_6 * _S538.x + cx_3, fy_6 * _S538.y + cy_3); + if(_S1136) + { + k_10 = (1.0f - theta_10 * theta_10 / 3.0f) / _S1135; + } + else + { + k_10 = theta_10 / r_17; + } + float2 _S1150 = _S1134 * make_float2 (k_10); + FixedArray _S1151 = dist_coeffs_18; + float2 _S1152 = DistThinPrism_distort_0(_S1150, &_S1151); + *mean2d_19 = make_float2 (fx_19 * _S1152.x + cx_10, fy_19 * _S1152.y + cy_10); + is_valid_2 = true; break; } - if(!!_S513) + if(!is_valid_2) { is_valid_2 = false; break; } - Matrix J_8; - float2 _S539 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S540; - (&_S540)->primal_0 = _S499; - (&_S540)->differential_0 = _S539; - DiffPair_float_0 _S541 = s_fwd_length_impl_0(&_S540); - float _S542 = _S500; - DiffPair_float_0 _S543; - (&_S543)->primal_0 = _S541.primal_0; - (&_S543)->differential_0 = _S541.differential_0; - DiffPair_float_0 _S544; - (&_S544)->primal_0 = _S500; - (&_S544)->differential_0 = 0.0f; - DiffPair_float_0 _S545 = _d_atan2_1(&_S543, &_S544); - if((_S541.primal_0) < 9.99999997475242708e-07f) + Matrix J_27; + float2 _S1153 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1154; + (&_S1154)->primal_0 = _S1126; + (&_S1154)->differential_0 = _S1153; + DiffPair_float_0 _S1155 = s_fwd_length_impl_0(&_S1154); + float _S1156 = _S1127; + DiffPair_float_0 _S1157; + (&_S1157)->primal_0 = _S1155.primal_0; + (&_S1157)->differential_0 = _S1155.differential_0; + DiffPair_float_0 _S1158; + (&_S1158)->primal_0 = _S1127; + (&_S1158)->differential_0 = 0.0f; + DiffPair_float_0 _S1159 = _d_atan2_1(&_S1157, &_S1158); + if((_S1159.primal_0) < 0.00100000004749745f) { - float _S546 = _S545.differential_0 * _S545.primal_0; - float _S547 = (0.0f - (_S546 + _S546) * 0.0416666679084301f) * _S500 / (_S500 * _S500); - k_3 = (1.0f - _S545.primal_0 * _S545.primal_0 / 24.0f) / _S500; - eps2d_2 = _S547; + float _S1160 = _S1159.differential_0 * _S1159.primal_0; + float _S1161 = (0.0f - (_S1160 + _S1160) * 0.3333333432674408f) * _S1127 / (_S1127 * _S1127); + k_10 = (1.0f - _S1159.primal_0 * _S1159.primal_0 / 3.0f) / _S1127; + eps2d_6 = _S1161; } else { - float _S548 = _S545.differential_0 * 0.5f; - DiffPair_float_0 _S549; - (&_S549)->primal_0 = 0.5f * _S545.primal_0; - (&_S549)->differential_0 = _S548; - DiffPair_float_0 _S550 = _d_sin_1(&_S549); - float _S551 = 2.0f * _S550.primal_0; - float _S552 = (_S550.differential_0 * 2.0f * _S541.primal_0 - _S551 * _S541.differential_0) / (_S541.primal_0 * _S541.primal_0); - k_3 = _S551 / _S541.primal_0; - eps2d_2 = _S552; + float _S1162 = (_S1159.differential_0 * _S1155.primal_0 - _S1159.primal_0 * _S1155.differential_0) / (_S1155.primal_0 * _S1155.primal_0); + k_10 = _S1159.primal_0 / _S1155.primal_0; + eps2d_6 = _S1162; } - float2 _S553 = _S499 * make_float2 (k_3); - float2 _S554 = _S539 * make_float2 (k_3) + make_float2 (eps2d_2) * _S499; - float u_27 = _S553.x; - float s_diff_u_15 = _S554.x; - float v_27 = _S553.y; - float s_diff_v_15 = _S554.y; - float _S555 = s_diff_u_15 * u_27; - float _S556 = s_diff_v_15 * v_27; - float r2_27 = u_27 * u_27 + v_27 * v_27; - float s_diff_r2_15 = _S555 + _S555 + (_S556 + _S556); - float _S557 = _S503 + r2_27 * _S504; - float _S558 = _S502 + r2_27 * _S557; - float _S559 = _S501 + r2_27 * _S558; - float2 _S560 = _S554 * make_float2 (1.0f + r2_27 * _S559) + make_float2 (s_diff_r2_15 * _S559 + (s_diff_r2_15 * _S558 + (s_diff_r2_15 * _S557 + s_diff_r2_15 * _S504 * r2_27) * r2_27) * r2_27) * _S553 + make_float2 (s_diff_u_15 * _S511 * v_27 + s_diff_v_15 * (_S511 * u_27) + (s_diff_r2_15 + (s_diff_u_15 * 2.0f * u_27 + s_diff_u_15 * (2.0f * u_27))) * _S506 + s_diff_r2_15 * _S507, s_diff_u_15 * _S512 * v_27 + s_diff_v_15 * (_S512 * u_27) + (s_diff_r2_15 + (s_diff_v_15 * 2.0f * v_27 + s_diff_v_15 * (2.0f * v_27))) * _S505 + s_diff_r2_15 * _S508); - float2 _S561 = _S560 + make_float2 (_S560.x * _S509 + _S560.y * _S510, 0.0f); - float _S562 = _S561.y * fy_6; - *&(((&J_8)->rows + (int(0)))->x) = _S561.x * fx_6; - *&(((&J_8)->rows + (int(1)))->x) = _S562; - float2 _S563 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S564; - (&_S564)->primal_0 = _S499; - (&_S564)->differential_0 = _S563; - DiffPair_float_0 _S565 = s_fwd_length_impl_0(&_S564); - DiffPair_float_0 _S566; - (&_S566)->primal_0 = _S565.primal_0; - (&_S566)->differential_0 = _S565.differential_0; - DiffPair_float_0 _S567; - (&_S567)->primal_0 = _S542; - (&_S567)->differential_0 = 0.0f; - DiffPair_float_0 _S568 = _d_atan2_1(&_S566, &_S567); - if((_S565.primal_0) < 9.99999997475242708e-07f) + float2 _S1163 = _S1126 * make_float2 (k_10); + float2 _S1164 = _S1153 * make_float2 (k_10) + make_float2 (eps2d_6) * _S1126; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1165; + (&_S1165)->primal_0 = _S1163; + (&_S1165)->differential_0 = _S1164; + FixedArray _S1166 = dist_coeffs_18; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1167 = s_fwd_DistThinPrism_distort_0(&_S1165, &_S1166); + float _S1168 = _S1167.differential_0.y * fy_19; + *&(((&J_27)->rows + (int(0)))->x) = _S1167.differential_0.x * fx_19; + *&(((&J_27)->rows + (int(1)))->x) = _S1168; + float2 _S1169 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1170; + (&_S1170)->primal_0 = _S1126; + (&_S1170)->differential_0 = _S1169; + DiffPair_float_0 _S1171 = s_fwd_length_impl_0(&_S1170); + DiffPair_float_0 _S1172; + (&_S1172)->primal_0 = _S1171.primal_0; + (&_S1172)->differential_0 = _S1171.differential_0; + DiffPair_float_0 _S1173; + (&_S1173)->primal_0 = _S1156; + (&_S1173)->differential_0 = 0.0f; + DiffPair_float_0 _S1174 = _d_atan2_1(&_S1172, &_S1173); + if((_S1174.primal_0) < 0.00100000004749745f) { - float _S569 = _S568.differential_0 * _S568.primal_0; - float _S570 = (0.0f - (_S569 + _S569) * 0.0416666679084301f) * _S500 / (_S500 * _S500); - k_3 = (1.0f - _S568.primal_0 * _S568.primal_0 / 24.0f) / _S500; - eps2d_2 = _S570; + float _S1175 = _S1174.differential_0 * _S1174.primal_0; + float _S1176 = (0.0f - (_S1175 + _S1175) * 0.3333333432674408f) * _S1127 / (_S1127 * _S1127); + k_10 = (1.0f - _S1174.primal_0 * _S1174.primal_0 / 3.0f) / _S1127; + eps2d_6 = _S1176; } else { - float _S571 = _S568.differential_0 * 0.5f; - DiffPair_float_0 _S572; - (&_S572)->primal_0 = 0.5f * _S568.primal_0; - (&_S572)->differential_0 = _S571; - DiffPair_float_0 _S573 = _d_sin_1(&_S572); - float _S574 = 2.0f * _S573.primal_0; - float _S575 = (_S573.differential_0 * 2.0f * _S565.primal_0 - _S574 * _S565.differential_0) / (_S565.primal_0 * _S565.primal_0); - k_3 = _S574 / _S565.primal_0; - eps2d_2 = _S575; + float _S1177 = (_S1174.differential_0 * _S1171.primal_0 - _S1174.primal_0 * _S1171.differential_0) / (_S1171.primal_0 * _S1171.primal_0); + k_10 = _S1174.primal_0 / _S1171.primal_0; + eps2d_6 = _S1177; } - float2 _S576 = _S499 * make_float2 (k_3); - float2 _S577 = _S563 * make_float2 (k_3) + make_float2 (eps2d_2) * _S499; - float u_28 = _S576.x; - float s_diff_u_16 = _S577.x; - float v_28 = _S576.y; - float s_diff_v_16 = _S577.y; - float _S578 = s_diff_u_16 * u_28; - float _S579 = s_diff_v_16 * v_28; - float r2_28 = u_28 * u_28 + v_28 * v_28; - float s_diff_r2_16 = _S578 + _S578 + (_S579 + _S579); - float _S580 = _S503 + r2_28 * _S504; - float _S581 = _S502 + r2_28 * _S580; - float _S582 = _S501 + r2_28 * _S581; - float2 _S583 = _S577 * make_float2 (1.0f + r2_28 * _S582) + make_float2 (s_diff_r2_16 * _S582 + (s_diff_r2_16 * _S581 + (s_diff_r2_16 * _S580 + s_diff_r2_16 * _S504 * r2_28) * r2_28) * r2_28) * _S576 + make_float2 (s_diff_u_16 * _S511 * v_28 + s_diff_v_16 * (_S511 * u_28) + (s_diff_r2_16 + (s_diff_u_16 * 2.0f * u_28 + s_diff_u_16 * (2.0f * u_28))) * _S506 + s_diff_r2_16 * _S507, s_diff_u_16 * _S512 * v_28 + s_diff_v_16 * (_S512 * u_28) + (s_diff_r2_16 + (s_diff_v_16 * 2.0f * v_28 + s_diff_v_16 * (2.0f * v_28))) * _S505 + s_diff_r2_16 * _S508); - float2 _S584 = _S583 + make_float2 (_S583.x * _S509 + _S583.y * _S510, 0.0f); - float _S585 = _S584.y * fy_6; - *&(((&J_8)->rows + (int(0)))->y) = _S584.x * fx_6; - *&(((&J_8)->rows + (int(1)))->y) = _S585; - float2 _S586 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S587; - (&_S587)->primal_0 = _S499; - (&_S587)->differential_0 = _S586; - DiffPair_float_0 _S588 = s_fwd_length_impl_0(&_S587); - DiffPair_float_0 _S589; - (&_S589)->primal_0 = _S588.primal_0; - (&_S589)->differential_0 = _S588.differential_0; - DiffPair_float_0 _S590; - (&_S590)->primal_0 = _S500; - (&_S590)->differential_0 = 1.0f; - DiffPair_float_0 _S591 = _d_atan2_1(&_S589, &_S590); - if((_S588.primal_0) < 9.99999997475242708e-07f) + float2 _S1178 = _S1126 * make_float2 (k_10); + float2 _S1179 = _S1169 * make_float2 (k_10) + make_float2 (eps2d_6) * _S1126; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1180; + (&_S1180)->primal_0 = _S1178; + (&_S1180)->differential_0 = _S1179; + FixedArray _S1181 = dist_coeffs_18; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1182 = s_fwd_DistThinPrism_distort_0(&_S1180, &_S1181); + float _S1183 = _S1182.differential_0.y * fy_19; + *&(((&J_27)->rows + (int(0)))->y) = _S1182.differential_0.x * fx_19; + *&(((&J_27)->rows + (int(1)))->y) = _S1183; + float2 _S1184 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1185; + (&_S1185)->primal_0 = _S1126; + (&_S1185)->differential_0 = _S1184; + DiffPair_float_0 _S1186 = s_fwd_length_impl_0(&_S1185); + DiffPair_float_0 _S1187; + (&_S1187)->primal_0 = _S1186.primal_0; + (&_S1187)->differential_0 = _S1186.differential_0; + DiffPair_float_0 _S1188; + (&_S1188)->primal_0 = _S1127; + (&_S1188)->differential_0 = 1.0f; + DiffPair_float_0 _S1189 = _d_atan2_1(&_S1187, &_S1188); + if((_S1189.primal_0) < 0.00100000004749745f) { - float _S592 = _S591.differential_0 * _S591.primal_0; - float _S593 = 1.0f - _S591.primal_0 * _S591.primal_0 / 24.0f; - float _S594 = ((0.0f - (_S592 + _S592) * 0.0416666679084301f) * _S500 - _S593) / (_S500 * _S500); - k_3 = _S593 / _S500; - eps2d_2 = _S594; + float _S1190 = _S1189.differential_0 * _S1189.primal_0; + float _S1191 = 1.0f - _S1189.primal_0 * _S1189.primal_0 / 3.0f; + float _S1192 = ((0.0f - (_S1190 + _S1190) * 0.3333333432674408f) * _S1127 - _S1191) / (_S1127 * _S1127); + k_10 = _S1191 / _S1127; + eps2d_6 = _S1192; } else { - float _S595 = _S591.differential_0 * 0.5f; - DiffPair_float_0 _S596; - (&_S596)->primal_0 = 0.5f * _S591.primal_0; - (&_S596)->differential_0 = _S595; - DiffPair_float_0 _S597 = _d_sin_1(&_S596); - float _S598 = 2.0f * _S597.primal_0; - float _S599 = (_S597.differential_0 * 2.0f * _S588.primal_0 - _S598 * _S588.differential_0) / (_S588.primal_0 * _S588.primal_0); - k_3 = _S598 / _S588.primal_0; - eps2d_2 = _S599; + float _S1193 = (_S1189.differential_0 * _S1186.primal_0 - _S1189.primal_0 * _S1186.differential_0) / (_S1186.primal_0 * _S1186.primal_0); + k_10 = _S1189.primal_0 / _S1186.primal_0; + eps2d_6 = _S1193; } - float2 _S600 = _S499 * make_float2 (k_3); - float2 _S601 = make_float2 (eps2d_2) * _S499; - float u_29 = _S600.x; - float s_diff_u_17 = _S601.x; - float v_29 = _S600.y; - float s_diff_v_17 = _S601.y; - float _S602 = s_diff_u_17 * u_29; - float _S603 = s_diff_v_17 * v_29; - float r2_29 = u_29 * u_29 + v_29 * v_29; - float s_diff_r2_17 = _S602 + _S602 + (_S603 + _S603); - float _S604 = _S503 + r2_29 * _S504; - float _S605 = _S502 + r2_29 * _S604; - float _S606 = _S501 + r2_29 * _S605; - float2 _S607 = _S601 * make_float2 (1.0f + r2_29 * _S606) + make_float2 (s_diff_r2_17 * _S606 + (s_diff_r2_17 * _S605 + (s_diff_r2_17 * _S604 + s_diff_r2_17 * _S504 * r2_29) * r2_29) * r2_29) * _S600 + make_float2 (s_diff_u_17 * _S511 * v_29 + s_diff_v_17 * (_S511 * u_29) + (s_diff_r2_17 + (s_diff_u_17 * 2.0f * u_29 + s_diff_u_17 * (2.0f * u_29))) * _S506 + s_diff_r2_17 * _S507, s_diff_u_17 * _S512 * v_29 + s_diff_v_17 * (_S512 * u_29) + (s_diff_r2_17 + (s_diff_v_17 * 2.0f * v_29 + s_diff_v_17 * (2.0f * v_29))) * _S505 + s_diff_r2_17 * _S508); - float2 _S608 = _S607 + make_float2 (_S607.x * _S509 + _S607.y * _S510, 0.0f); - float _S609 = _S608.y * fy_6; - *&(((&J_8)->rows + (int(0)))->z) = _S608.x * fx_6; - *&(((&J_8)->rows + (int(1)))->z) = _S609; - covar2d_2 = mul_4(mul_3(J_8, covar_c_2), transpose_1(J_8)); + float2 _S1194 = _S1126 * make_float2 (k_10); + float2 _S1195 = make_float2 (eps2d_6) * _S1126; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1196; + (&_S1196)->primal_0 = _S1194; + (&_S1196)->differential_0 = _S1195; + FixedArray _S1197 = dist_coeffs_18; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1198 = s_fwd_DistThinPrism_distort_0(&_S1196, &_S1197); + float _S1199 = _S1198.differential_0.y * fy_19; + *&(((&J_27)->rows + (int(0)))->z) = _S1198.differential_0.x * fx_19; + *&(((&J_27)->rows + (int(1)))->z) = _S1199; + covar2d_6 = mul_4(mul_3(J_27, covar_c_6), transpose_1(J_27)); is_valid_2 = true; break; } bool is_valid_3 = true & is_valid_2; - float2 mean2d_c_1 = *mean2d_6 - make_float2 (cx_3, cy_3); - float invdet_3 = 1.0f / (covar2d_2.rows[int(0)].x * covar2d_2.rows[int(1)].y - covar2d_2.rows[int(0)].y * covar2d_2.rows[int(1)].x); - float opac_1 = *opacity_2 * (F32_exp((-0.5f * dot_0(mul_7(makeMatrix (covar2d_2.rows[int(1)].y * invdet_3, - covar2d_2.rows[int(0)].y * invdet_3, - covar2d_2.rows[int(1)].x * invdet_3, covar2d_2.rows[int(0)].x * invdet_3), mean2d_c_1), mean2d_c_1)))); - if(_S500 < 0.0f) + float2 mean2d_c_2 = *mean2d_19 - make_float2 (cx_10, cy_10); + float invdet_8 = 1.0f / (covar2d_6.rows[int(0)].x * covar2d_6.rows[int(1)].y - covar2d_6.rows[int(0)].y * covar2d_6.rows[int(1)].x); + float opac_2 = *opacity_6 * (F32_exp((-0.5f * dot_0(mul_7(makeMatrix (covar2d_6.rows[int(1)].y * invdet_8, - covar2d_6.rows[int(0)].y * invdet_8, - covar2d_6.rows[int(1)].x * invdet_8, covar2d_6.rows[int(0)].x * invdet_8), mean2d_c_2), mean2d_c_2)))); + if(_S1127 < 0.0f) { - is_valid_2 = opac_1 > 0.00392156885936856f; + is_valid_2 = opac_2 > 0.00392156885936856f; } else { @@ -2570,54 +4929,54 @@ inline __device__ void projection_3dgs_equisolid(bool antialiased_2, float3 mea } if(!is_valid_2) { - *aabb_xyxy_2 = make_float4 (0.0f); + *aabb_xyxy_6 = _S1128; break; } - if(antialiased_2) + if(antialiased_6) { - eps2d_2 = 0.10000000149011612f; + eps2d_6 = 0.10000000149011612f; } else { - eps2d_2 = 0.30000001192092896f; + eps2d_6 = 0.30000001192092896f; } - float det_orig_2 = *&(((&covar2d_2)->rows + (int(0)))->x) * *&(((&covar2d_2)->rows + (int(1)))->y) - *&(((&covar2d_2)->rows + (int(0)))->y) * *&(((&covar2d_2)->rows + (int(1)))->x); - float _S610 = *&(((&covar2d_2)->rows + (int(0)))->x) + eps2d_2; - *&(((&covar2d_2)->rows + (int(0)))->x) = _S610; - float _S611 = *&(((&covar2d_2)->rows + (int(1)))->y) + eps2d_2; - *&(((&covar2d_2)->rows + (int(1)))->y) = _S611; - float det_blur_2 = _S610 * _S611 - *&(((&covar2d_2)->rows + (int(0)))->y) * *&(((&covar2d_2)->rows + (int(1)))->x); - float compensation_2 = (F32_sqrt(((F32_max((0.0f), (det_orig_2 / det_blur_2)))))); - if(det_blur_2 <= 0.0f) + float det_orig_6 = *&(((&covar2d_6)->rows + (int(0)))->x) * *&(((&covar2d_6)->rows + (int(1)))->y) - *&(((&covar2d_6)->rows + (int(0)))->y) * *&(((&covar2d_6)->rows + (int(1)))->x); + float _S1200 = *&(((&covar2d_6)->rows + (int(0)))->x) + eps2d_6; + *&(((&covar2d_6)->rows + (int(0)))->x) = _S1200; + float _S1201 = *&(((&covar2d_6)->rows + (int(1)))->y) + eps2d_6; + *&(((&covar2d_6)->rows + (int(1)))->y) = _S1201; + float det_blur_6 = _S1200 * _S1201 - *&(((&covar2d_6)->rows + (int(0)))->y) * *&(((&covar2d_6)->rows + (int(1)))->x); + float compensation_6 = (F32_sqrt(((F32_max((0.0f), (det_orig_6 / det_blur_6)))))); + if(det_blur_6 <= 0.0f) { - *aabb_xyxy_2 = make_float4 (0.0f); + *aabb_xyxy_6 = _S1128; break; } - float invdet_4 = 1.0f / (covar2d_2.rows[int(0)].x * covar2d_2.rows[int(1)].y - covar2d_2.rows[int(0)].y * covar2d_2.rows[int(1)].x); - Matrix _S612 = makeMatrix (covar2d_2.rows[int(1)].y * invdet_4, - covar2d_2.rows[int(0)].y * invdet_4, - covar2d_2.rows[int(1)].x * invdet_4, covar2d_2.rows[int(0)].x * invdet_4); - if(antialiased_2) + float invdet_9 = 1.0f / (covar2d_6.rows[int(0)].x * covar2d_6.rows[int(1)].y - covar2d_6.rows[int(0)].y * covar2d_6.rows[int(1)].x); + Matrix _S1202 = makeMatrix (covar2d_6.rows[int(1)].y * invdet_9, - covar2d_6.rows[int(0)].y * invdet_9, - covar2d_6.rows[int(1)].x * invdet_9, covar2d_6.rows[int(0)].x * invdet_9); + if(antialiased_6) { - *opacity_2 = *opacity_2 * compensation_2; + *opacity_6 = *opacity_6 * compensation_6; } - if((*opacity_2) < 0.00392156885936856f) + if((*opacity_6) < 0.00392156885936856f) { - *aabb_xyxy_2 = make_float4 (0.0f); + *aabb_xyxy_6 = _S1128; break; } - float _S613 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_2 / 0.00392156885936856f))))))))); - float radius_x_2 = _S613 * (F32_sqrt((covar2d_2[int(0)].x))); - float radius_y_2 = _S613 * (F32_sqrt((covar2d_2[int(1)].y))); - float _S614 = (*mean2d_6).x - radius_x_2; - float _S615 = (*mean2d_6).x + radius_x_2; - float _S616 = (*mean2d_6).y - radius_y_2; - float _S617 = (*mean2d_6).y + radius_y_2; - if(_S615 <= 0.0f) + float _S1203 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_6 / 0.00392156885936856f))))))))); + float radius_x_6 = _S1203 * (F32_sqrt((covar2d_6[int(0)].x))); + float radius_y_6 = _S1203 * (F32_sqrt((covar2d_6[int(1)].y))); + float _S1204 = (*mean2d_19).x - radius_x_6; + float _S1205 = (*mean2d_19).x + radius_x_6; + float _S1206 = (*mean2d_19).y - radius_y_6; + float _S1207 = (*mean2d_19).y + radius_y_6; + if(_S1205 <= 0.0f) { is_valid_2 = true; } else { - is_valid_2 = _S614 >= float(image_width_2); + is_valid_2 = _S1204 >= float(image_width_6); } if(is_valid_2) { @@ -2625,7 +4984,7 @@ inline __device__ void projection_3dgs_equisolid(bool antialiased_2, float3 mea } else { - is_valid_2 = _S617 <= 0.0f; + is_valid_2 = _S1207 <= 0.0f; } if(is_valid_2) { @@ -2633,200 +4992,1197 @@ inline __device__ void projection_3dgs_equisolid(bool antialiased_2, float3 mea } else { - is_valid_2 = _S616 >= float(image_height_2); + is_valid_2 = _S1206 >= float(image_height_6); } if(is_valid_2) { - *aabb_xyxy_2 = make_float4 (0.0f); + *aabb_xyxy_6 = _S1128; break; } - *aabb_xyxy_2 = make_float4 (_S614, _S616, _S615, _S617); - float x_19 = mean_c_2.x; - float y_6 = mean_c_2.y; - float _S618 = x_19 * x_19 + y_6 * y_6; - *sorting_depth_2 = _S500 * _S500 * _S500 * _S500 + 0.001953125f * _S618 * _S618; - *conic_2 = make_float3 (_S612.rows[int(0)].x, _S612.rows[int(0)].y, _S612.rows[int(1)].y); - *radius_3 = view_radius_3dgs_0(mean_3, scale_2, in_opacity_2, - mul_6(_S517, t_2)); + *aabb_xyxy_6 = make_float4 (_S1204, _S1206, _S1205, _S1207); + float x_24 = mean_c_6.x; + float y_7 = mean_c_6.y; + float _S1208 = x_24 * x_24 + y_7 * y_7; + *sorting_depth_6 = _S1127 * _S1127 * _S1127 * _S1127 + 0.001953125f * _S1208 * _S1208; + *conic_6 = make_float3 (_S1202.rows[int(0)].x, _S1202.rows[int(0)].y, _S1202.rows[int(1)].y); + *radius_7 = view_radius_3dgs_0(mean_7, scale_6, in_opacity_6, - mul_6(_S1133, t_6)); break; } return; } -inline __device__ void projection_3dgs_equirect(bool antialiased_3, float3 mean_4, float4 quat_3, float3 scale_3, float in_opacity_3, Matrix R_3, float3 t_3, float fx_7, float fy_7, float cx_4, float cy_4, FixedArray dist_coeffs_7, uint image_width_3, uint image_height_3, float4 * aabb_xyxy_3, float * sorting_depth_3, float * radius_4, float2 * mean2d_7, float * depth_3, float3 * conic_3, float * opacity_3) +inline __device__ void projection_3dgs_equisolid_none(bool antialiased_7, float3 mean_8, float4 quat_7, float3 scale_7, float in_opacity_7, Matrix R_7, float3 t_7, float fx_20, float fy_20, float cx_11, float cy_11, FixedArray dist_coeffs_19, uint image_width_7, uint image_height_7, float4 * aabb_xyxy_7, float * sorting_depth_7, float * radius_8, float2 * mean2d_20, float * depth_7, float3 * conic_7, float * opacity_7) { for(;;) { - float3 mean_c_3 = mul_6(R_3, mean_4) + t_3; - float _S619 = length_1(mean_c_3); - *depth_3 = _S619; - if(_S619 <= 0.0f) + float4 _S1209 = make_float4 (0.0f); + *aabb_xyxy_7 = _S1209; + *sorting_depth_7 = 0.0f; + *radius_8 = 0.0f; + *mean2d_20 = make_float2 (0.0f); + *conic_7 = make_float3 (0.0f); + *opacity_7 = 0.0f; + float3 mean_c_7 = mul_6(R_7, mean_8) + t_7; + float _S1210 = length_1(mean_c_7); + *depth_7 = _S1210; + if(_S1210 <= 0.0f) { - *aabb_xyxy_3 = make_float4 (0.0f); + *aabb_xyxy_7 = _S1209; break; } - Matrix covar2d_3; - *opacity_3 = 1.0f / (1.0f + (F32_exp((- in_opacity_3)))); - float4 _S620 = normalize_0(quat_3); - float3 _S621 = exp_0(scale_3); - float x_20 = _S620.y; - float x2_3 = x_20 * x_20; - float y2_3 = _S620.z * _S620.z; - float z2_3 = _S620.w * _S620.w; - float xy_3 = _S620.y * _S620.z; - float xz_3 = _S620.y * _S620.w; - float yz_3 = _S620.z * _S620.w; - float wx_3 = _S620.x * _S620.y; - float wy_3 = _S620.x * _S620.z; - float wz_3 = _S620.x * _S620.w; - Matrix M_3 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_3 + z2_3), 2.0f * (xy_3 + wz_3), 2.0f * (xz_3 - wy_3), 2.0f * (xy_3 - wz_3), 1.0f - 2.0f * (x2_3 + z2_3), 2.0f * (yz_3 + wx_3), 2.0f * (xz_3 + wy_3), 2.0f * (yz_3 - wx_3), 1.0f - 2.0f * (x2_3 + y2_3))), makeMatrix (_S621.x, 0.0f, 0.0f, 0.0f, _S621.y, 0.0f, 0.0f, 0.0f, _S621.z)); - Matrix _S622 = transpose_3(R_3); - Matrix covar_c_3 = mul_5(mul_5(R_3, mul_5(M_3, transpose_3(M_3))), _S622); - float _S623 = mean_c_3.x; - float _S624 = mean_c_3.z; - float _S625 = mean_c_3.y; - float2 _S626 = float2 {mean_c_3.x, mean_c_3.z}; - *mean2d_7 = make_float2 (fx_7 * (F32_atan2((_S623), (_S624))) + cx_4, fy_7 * (F32_atan2((_S625), (length_0(_S626)))) + cy_4); - DiffPair_float_0 _S627; - (&_S627)->primal_0 = _S623; - (&_S627)->differential_0 = 1.0f; - DiffPair_float_0 _S628; - (&_S628)->primal_0 = _S624; - (&_S628)->differential_0 = 0.0f; - DiffPair_float_0 _S629 = _d_atan2_1(&_S627, &_S628); - float2 _S630 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S631; - (&_S631)->primal_0 = _S626; - (&_S631)->differential_0 = _S630; - DiffPair_float_0 _S632 = s_fwd_length_impl_0(&_S631); - DiffPair_float_0 _S633; - (&_S633)->primal_0 = _S625; - (&_S633)->differential_0 = 0.0f; - DiffPair_float_0 _S634; - (&_S634)->primal_0 = _S632.primal_0; - (&_S634)->differential_0 = _S632.differential_0; - DiffPair_float_0 _S635 = _d_atan2_1(&_S633, &_S634); - float _S636 = _S635.differential_0 * fy_7; - Matrix J_9; - *&(((&J_9)->rows + (int(0)))->x) = _S629.differential_0 * fx_7; - *&(((&J_9)->rows + (int(1)))->x) = _S636; - DiffPair_float_0 _S637; - (&_S637)->primal_0 = _S623; - (&_S637)->differential_0 = 0.0f; - DiffPair_float_0 _S638; - (&_S638)->primal_0 = _S624; - (&_S638)->differential_0 = 0.0f; - DiffPair_float_0 _S639 = _d_atan2_1(&_S637, &_S638); - float2 _S640 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S641; - (&_S641)->primal_0 = _S626; - (&_S641)->differential_0 = _S640; - DiffPair_float_0 _S642 = s_fwd_length_impl_0(&_S641); - DiffPair_float_0 _S643; - (&_S643)->primal_0 = _S625; - (&_S643)->differential_0 = 1.0f; - DiffPair_float_0 _S644; - (&_S644)->primal_0 = _S642.primal_0; - (&_S644)->differential_0 = _S642.differential_0; - DiffPair_float_0 _S645 = _d_atan2_1(&_S643, &_S644); - float _S646 = _S645.differential_0 * fy_7; - *&(((&J_9)->rows + (int(0)))->y) = _S639.differential_0 * fx_7; - *&(((&J_9)->rows + (int(1)))->y) = _S646; - DiffPair_float_0 _S647; - (&_S647)->primal_0 = _S623; - (&_S647)->differential_0 = 0.0f; - DiffPair_float_0 _S648; - (&_S648)->primal_0 = _S624; - (&_S648)->differential_0 = 1.0f; - DiffPair_float_0 _S649 = _d_atan2_1(&_S647, &_S648); - float2 _S650 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S651; - (&_S651)->primal_0 = _S626; - (&_S651)->differential_0 = _S650; - DiffPair_float_0 _S652 = s_fwd_length_impl_0(&_S651); - DiffPair_float_0 _S653; - (&_S653)->primal_0 = _S625; - (&_S653)->differential_0 = 0.0f; - DiffPair_float_0 _S654; - (&_S654)->primal_0 = _S652.primal_0; - (&_S654)->differential_0 = _S652.differential_0; - DiffPair_float_0 _S655 = _d_atan2_1(&_S653, &_S654); - float _S656 = _S655.differential_0 * fy_7; - *&(((&J_9)->rows + (int(0)))->z) = _S649.differential_0 * fx_7; - *&(((&J_9)->rows + (int(1)))->z) = _S656; - covar2d_3 = mul_4(mul_3(J_9, covar_c_3), transpose_1(J_9)); - float eps2d_3; - if(antialiased_3) + Matrix covar2d_7; + Matrix _S1211 = makeMatrix (0.0f); + *opacity_7 = 1.0f / (1.0f + (F32_exp((- in_opacity_7)))); + float4 _S1212 = normalize_0(quat_7); + float3 _S1213 = exp_0(scale_7); + float x_25 = _S1212.y; + float x2_7 = x_25 * x_25; + float y2_7 = _S1212.z * _S1212.z; + float z2_7 = _S1212.w * _S1212.w; + float xy_7 = _S1212.y * _S1212.z; + float xz_7 = _S1212.y * _S1212.w; + float yz_7 = _S1212.z * _S1212.w; + float wx_7 = _S1212.x * _S1212.y; + float wy_7 = _S1212.x * _S1212.z; + float wz_7 = _S1212.x * _S1212.w; + Matrix M_7 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_7 + z2_7), 2.0f * (xy_7 + wz_7), 2.0f * (xz_7 - wy_7), 2.0f * (xy_7 - wz_7), 1.0f - 2.0f * (x2_7 + z2_7), 2.0f * (yz_7 + wx_7), 2.0f * (xz_7 + wy_7), 2.0f * (yz_7 - wx_7), 1.0f - 2.0f * (x2_7 + y2_7))), makeMatrix (_S1213.x, 0.0f, 0.0f, 0.0f, _S1213.y, 0.0f, 0.0f, 0.0f, _S1213.z)); + Matrix _S1214 = transpose_3(R_7); + Matrix covar_c_7 = mul_5(mul_5(R_7, mul_5(M_7, transpose_3(M_7))), _S1214); + covar2d_7 = _S1211; + float2 _S1215 = float2 {mean_c_7.x, mean_c_7.y}; + float r_18 = length_0(_S1215); + float _S1216 = mean_c_7.z; + float theta_11 = (F32_atan2((r_18), (_S1216))); + float k_11; + if(r_18 < 9.99999997475242708e-07f) { - eps2d_3 = 0.10000000149011612f; + k_11 = (1.0f - theta_11 * theta_11 / 24.0f) / _S1216; } else { - eps2d_3 = 0.30000001192092896f; + k_11 = 2.0f * (F32_sin((0.5f * theta_11))) / r_18; } - float det_orig_3 = *&(((&covar2d_3)->rows + (int(0)))->x) * *&(((&covar2d_3)->rows + (int(1)))->y) - *&(((&covar2d_3)->rows + (int(0)))->y) * *&(((&covar2d_3)->rows + (int(1)))->x); - float _S657 = *&(((&covar2d_3)->rows + (int(0)))->x) + eps2d_3; - *&(((&covar2d_3)->rows + (int(0)))->x) = _S657; - float _S658 = *&(((&covar2d_3)->rows + (int(1)))->y) + eps2d_3; - *&(((&covar2d_3)->rows + (int(1)))->y) = _S658; - float det_blur_3 = _S657 * _S658 - *&(((&covar2d_3)->rows + (int(0)))->y) * *&(((&covar2d_3)->rows + (int(1)))->x); - float compensation_3 = (F32_sqrt(((F32_max((0.0f), (det_orig_3 / det_blur_3)))))); - if(det_blur_3 <= 0.0f) + float2 _S1217 = _S1215 * make_float2 (k_11); + FixedArray _S1218 = dist_coeffs_19; + float2 _S1219 = DistNone_distort_0(_S1217, &_S1218); + *mean2d_20 = make_float2 (fx_20 * _S1219.x + cx_11, fy_20 * _S1219.y + cy_11); + Matrix J_28; + float2 _S1220 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1221; + (&_S1221)->primal_0 = _S1215; + (&_S1221)->differential_0 = _S1220; + DiffPair_float_0 _S1222 = s_fwd_length_impl_0(&_S1221); + DiffPair_float_0 _S1223; + (&_S1223)->primal_0 = _S1222.primal_0; + (&_S1223)->differential_0 = _S1222.differential_0; + DiffPair_float_0 _S1224; + (&_S1224)->primal_0 = _S1216; + (&_S1224)->differential_0 = 0.0f; + DiffPair_float_0 _S1225 = _d_atan2_1(&_S1223, &_S1224); + float s_diff_k_9; + if((_S1222.primal_0) < 9.99999997475242708e-07f) { - *aabb_xyxy_3 = make_float4 (0.0f); - break; - } - float invdet_5 = 1.0f / (covar2d_3.rows[int(0)].x * covar2d_3.rows[int(1)].y - covar2d_3.rows[int(0)].y * covar2d_3.rows[int(1)].x); - Matrix _S659 = makeMatrix (covar2d_3.rows[int(1)].y * invdet_5, - covar2d_3.rows[int(0)].y * invdet_5, - covar2d_3.rows[int(1)].x * invdet_5, covar2d_3.rows[int(0)].x * invdet_5); - if(antialiased_3) - { - *opacity_3 = *opacity_3 * compensation_3; - } - if((*opacity_3) < 0.00392156885936856f) - { - *aabb_xyxy_3 = make_float4 (0.0f); - break; - } - float _S660 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_3 / 0.00392156885936856f))))))))); - float radius_x_3 = _S660 * (F32_sqrt((covar2d_3[int(0)].x))); - float radius_y_3 = _S660 * (F32_sqrt((covar2d_3[int(1)].y))); - float _S661 = (*mean2d_7).x - radius_x_3; - float _S662 = (*mean2d_7).x + radius_x_3; - float _S663 = (*mean2d_7).y - radius_y_3; - float _S664 = (*mean2d_7).y + radius_y_3; - bool _S665; - if(_S662 <= 0.0f) - { - _S665 = true; + float _S1226 = _S1225.differential_0 * _S1225.primal_0; + float _S1227 = (0.0f - (_S1226 + _S1226) * 0.0416666679084301f) * _S1216 / (_S1216 * _S1216); + k_11 = (1.0f - _S1225.primal_0 * _S1225.primal_0 / 24.0f) / _S1216; + s_diff_k_9 = _S1227; } else { - _S665 = _S661 >= float(image_width_3); + float _S1228 = _S1225.differential_0 * 0.5f; + DiffPair_float_0 _S1229; + (&_S1229)->primal_0 = 0.5f * _S1225.primal_0; + (&_S1229)->differential_0 = _S1228; + DiffPair_float_0 _S1230 = _d_sin_1(&_S1229); + float _S1231 = 2.0f * _S1230.primal_0; + float _S1232 = (_S1230.differential_0 * 2.0f * _S1222.primal_0 - _S1231 * _S1222.differential_0) / (_S1222.primal_0 * _S1222.primal_0); + k_11 = _S1231 / _S1222.primal_0; + s_diff_k_9 = _S1232; } - if(_S665) + float2 _S1233 = _S1215 * make_float2 (k_11); + float2 _S1234 = _S1220 * make_float2 (k_11) + make_float2 (s_diff_k_9) * _S1215; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1235; + (&_S1235)->primal_0 = _S1233; + (&_S1235)->differential_0 = _S1234; + FixedArray _S1236 = dist_coeffs_19; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1237 = s_fwd_DistNone_distort_0(&_S1235, &_S1236); + float _S1238 = _S1237.differential_0.y * fy_20; + *&(((&J_28)->rows + (int(0)))->x) = _S1237.differential_0.x * fx_20; + *&(((&J_28)->rows + (int(1)))->x) = _S1238; + float2 _S1239 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1240; + (&_S1240)->primal_0 = _S1215; + (&_S1240)->differential_0 = _S1239; + DiffPair_float_0 _S1241 = s_fwd_length_impl_0(&_S1240); + DiffPair_float_0 _S1242; + (&_S1242)->primal_0 = _S1241.primal_0; + (&_S1242)->differential_0 = _S1241.differential_0; + DiffPair_float_0 _S1243; + (&_S1243)->primal_0 = _S1216; + (&_S1243)->differential_0 = 0.0f; + DiffPair_float_0 _S1244 = _d_atan2_1(&_S1242, &_S1243); + if((_S1241.primal_0) < 9.99999997475242708e-07f) { - _S665 = true; + float _S1245 = _S1244.differential_0 * _S1244.primal_0; + float _S1246 = (0.0f - (_S1245 + _S1245) * 0.0416666679084301f) * _S1216 / (_S1216 * _S1216); + k_11 = (1.0f - _S1244.primal_0 * _S1244.primal_0 / 24.0f) / _S1216; + s_diff_k_9 = _S1246; } else { - _S665 = _S664 <= 0.0f; + float _S1247 = _S1244.differential_0 * 0.5f; + DiffPair_float_0 _S1248; + (&_S1248)->primal_0 = 0.5f * _S1244.primal_0; + (&_S1248)->differential_0 = _S1247; + DiffPair_float_0 _S1249 = _d_sin_1(&_S1248); + float _S1250 = 2.0f * _S1249.primal_0; + float _S1251 = (_S1249.differential_0 * 2.0f * _S1241.primal_0 - _S1250 * _S1241.differential_0) / (_S1241.primal_0 * _S1241.primal_0); + k_11 = _S1250 / _S1241.primal_0; + s_diff_k_9 = _S1251; } - if(_S665) + float2 _S1252 = _S1215 * make_float2 (k_11); + float2 _S1253 = _S1239 * make_float2 (k_11) + make_float2 (s_diff_k_9) * _S1215; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1254; + (&_S1254)->primal_0 = _S1252; + (&_S1254)->differential_0 = _S1253; + FixedArray _S1255 = dist_coeffs_19; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1256 = s_fwd_DistNone_distort_0(&_S1254, &_S1255); + float _S1257 = _S1256.differential_0.y * fy_20; + *&(((&J_28)->rows + (int(0)))->y) = _S1256.differential_0.x * fx_20; + *&(((&J_28)->rows + (int(1)))->y) = _S1257; + float2 _S1258 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1259; + (&_S1259)->primal_0 = _S1215; + (&_S1259)->differential_0 = _S1258; + DiffPair_float_0 _S1260 = s_fwd_length_impl_0(&_S1259); + DiffPair_float_0 _S1261; + (&_S1261)->primal_0 = _S1260.primal_0; + (&_S1261)->differential_0 = _S1260.differential_0; + DiffPair_float_0 _S1262; + (&_S1262)->primal_0 = _S1216; + (&_S1262)->differential_0 = 1.0f; + DiffPair_float_0 _S1263 = _d_atan2_1(&_S1261, &_S1262); + if((_S1260.primal_0) < 9.99999997475242708e-07f) { - _S665 = true; + float _S1264 = _S1263.differential_0 * _S1263.primal_0; + float _S1265 = 1.0f - _S1263.primal_0 * _S1263.primal_0 / 24.0f; + float _S1266 = ((0.0f - (_S1264 + _S1264) * 0.0416666679084301f) * _S1216 - _S1265) / (_S1216 * _S1216); + k_11 = _S1265 / _S1216; + s_diff_k_9 = _S1266; } else { - _S665 = _S663 >= float(image_height_3); + float _S1267 = _S1263.differential_0 * 0.5f; + DiffPair_float_0 _S1268; + (&_S1268)->primal_0 = 0.5f * _S1263.primal_0; + (&_S1268)->differential_0 = _S1267; + DiffPair_float_0 _S1269 = _d_sin_1(&_S1268); + float _S1270 = 2.0f * _S1269.primal_0; + float _S1271 = (_S1269.differential_0 * 2.0f * _S1260.primal_0 - _S1270 * _S1260.differential_0) / (_S1260.primal_0 * _S1260.primal_0); + k_11 = _S1270 / _S1260.primal_0; + s_diff_k_9 = _S1271; } - if(_S665) + float2 _S1272 = _S1215 * make_float2 (k_11); + float2 _S1273 = make_float2 (s_diff_k_9) * _S1215; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1274; + (&_S1274)->primal_0 = _S1272; + (&_S1274)->differential_0 = _S1273; + FixedArray _S1275 = dist_coeffs_19; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1276 = s_fwd_DistNone_distort_0(&_S1274, &_S1275); + float _S1277 = _S1276.differential_0.y * fy_20; + *&(((&J_28)->rows + (int(0)))->z) = _S1276.differential_0.x * fx_20; + *&(((&J_28)->rows + (int(1)))->z) = _S1277; + Matrix _S1278 = mul_4(mul_3(J_28, covar_c_7), transpose_1(J_28)); + covar2d_7 = _S1278; + float2 mean2d_c_3 = *mean2d_20 - make_float2 (cx_11, cy_11); + float invdet_10 = 1.0f / (_S1278.rows[int(0)].x * _S1278.rows[int(1)].y - _S1278.rows[int(0)].y * _S1278.rows[int(1)].x); + float opac_3 = *opacity_7 * (F32_exp((-0.5f * dot_0(mul_7(makeMatrix (_S1278.rows[int(1)].y * invdet_10, - _S1278.rows[int(0)].y * invdet_10, - _S1278.rows[int(1)].x * invdet_10, _S1278.rows[int(0)].x * invdet_10), mean2d_c_3), mean2d_c_3)))); + bool _S1279; + if(_S1216 < 0.0f) { - *aabb_xyxy_3 = make_float4 (0.0f); + _S1279 = opac_3 > 0.00392156885936856f; + } + else + { + _S1279 = false; + } + if(!!_S1279) + { + *aabb_xyxy_7 = _S1209; break; } - *aabb_xyxy_3 = make_float4 (_S661, _S663, _S662, _S664); - *sorting_depth_3 = dot_1(mean_c_3, mean_c_3); - *conic_3 = make_float3 (_S659.rows[int(0)].x, _S659.rows[int(0)].y, _S659.rows[int(1)].y); - *radius_4 = view_radius_3dgs_0(mean_4, scale_3, in_opacity_3, - mul_6(_S622, t_3)); + float eps2d_7; + if(antialiased_7) + { + eps2d_7 = 0.10000000149011612f; + } + else + { + eps2d_7 = 0.30000001192092896f; + } + float det_orig_7 = *&(((&covar2d_7)->rows + (int(0)))->x) * *&(((&covar2d_7)->rows + (int(1)))->y) - *&(((&covar2d_7)->rows + (int(0)))->y) * *&(((&covar2d_7)->rows + (int(1)))->x); + float _S1280 = *&(((&covar2d_7)->rows + (int(0)))->x) + eps2d_7; + *&(((&covar2d_7)->rows + (int(0)))->x) = _S1280; + float _S1281 = *&(((&covar2d_7)->rows + (int(1)))->y) + eps2d_7; + *&(((&covar2d_7)->rows + (int(1)))->y) = _S1281; + float det_blur_7 = _S1280 * _S1281 - *&(((&covar2d_7)->rows + (int(0)))->y) * *&(((&covar2d_7)->rows + (int(1)))->x); + float compensation_7 = (F32_sqrt(((F32_max((0.0f), (det_orig_7 / det_blur_7)))))); + if(det_blur_7 <= 0.0f) + { + *aabb_xyxy_7 = _S1209; + break; + } + float invdet_11 = 1.0f / (covar2d_7.rows[int(0)].x * covar2d_7.rows[int(1)].y - covar2d_7.rows[int(0)].y * covar2d_7.rows[int(1)].x); + Matrix _S1282 = makeMatrix (covar2d_7.rows[int(1)].y * invdet_11, - covar2d_7.rows[int(0)].y * invdet_11, - covar2d_7.rows[int(1)].x * invdet_11, covar2d_7.rows[int(0)].x * invdet_11); + if(antialiased_7) + { + *opacity_7 = *opacity_7 * compensation_7; + } + if((*opacity_7) < 0.00392156885936856f) + { + *aabb_xyxy_7 = _S1209; + break; + } + float _S1283 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_7 / 0.00392156885936856f))))))))); + float radius_x_7 = _S1283 * (F32_sqrt((covar2d_7[int(0)].x))); + float radius_y_7 = _S1283 * (F32_sqrt((covar2d_7[int(1)].y))); + float _S1284 = (*mean2d_20).x - radius_x_7; + float _S1285 = (*mean2d_20).x + radius_x_7; + float _S1286 = (*mean2d_20).y - radius_y_7; + float _S1287 = (*mean2d_20).y + radius_y_7; + if(_S1285 <= 0.0f) + { + _S1279 = true; + } + else + { + _S1279 = _S1284 >= float(image_width_7); + } + if(_S1279) + { + _S1279 = true; + } + else + { + _S1279 = _S1287 <= 0.0f; + } + if(_S1279) + { + _S1279 = true; + } + else + { + _S1279 = _S1286 >= float(image_height_7); + } + if(_S1279) + { + *aabb_xyxy_7 = _S1209; + break; + } + *aabb_xyxy_7 = make_float4 (_S1284, _S1286, _S1285, _S1287); + float x_26 = mean_c_7.x; + float y_8 = mean_c_7.y; + float _S1288 = x_26 * x_26 + y_8 * y_8; + *sorting_depth_7 = _S1216 * _S1216 * _S1216 * _S1216 + 0.001953125f * _S1288 * _S1288; + *conic_7 = make_float3 (_S1282.rows[int(0)].x, _S1282.rows[int(0)].y, _S1282.rows[int(1)].y); + *radius_8 = view_radius_3dgs_0(mean_8, scale_7, in_opacity_7, - mul_6(_S1214, t_7)); + break; + } + return; +} + +inline __device__ void projection_3dgs_equisolid_opencv(bool antialiased_8, float3 mean_9, float4 quat_8, float3 scale_8, float in_opacity_8, Matrix R_8, float3 t_8, float fx_21, float fy_21, float cx_12, float cy_12, FixedArray dist_coeffs_20, uint image_width_8, uint image_height_8, float4 * aabb_xyxy_8, float * sorting_depth_8, float * radius_9, float2 * mean2d_21, float * depth_8, float3 * conic_8, float * opacity_8) +{ + float2 _S1289; + float _S1290; + for(;;) + { + float4 _S1291 = make_float4 (0.0f); + *aabb_xyxy_8 = _S1291; + *sorting_depth_8 = 0.0f; + *radius_9 = 0.0f; + *mean2d_21 = make_float2 (0.0f); + *conic_8 = make_float3 (0.0f); + *opacity_8 = 0.0f; + float3 mean_c_8 = mul_6(R_8, mean_9) + t_8; + float _S1292 = length_1(mean_c_8); + *depth_8 = _S1292; + if(_S1292 <= 0.0f) + { + *aabb_xyxy_8 = _S1291; + break; + } + Matrix covar2d_8; + Matrix _S1293 = makeMatrix (0.0f); + *opacity_8 = 1.0f / (1.0f + (F32_exp((- in_opacity_8)))); + float eps2d_8; + bool is_valid_4; + float4 _S1294 = normalize_0(quat_8); + float3 _S1295 = exp_0(scale_8); + float x_27 = _S1294.y; + float x2_8 = x_27 * x_27; + float y2_8 = _S1294.z * _S1294.z; + float z2_8 = _S1294.w * _S1294.w; + float xy_8 = _S1294.y * _S1294.z; + float xz_8 = _S1294.y * _S1294.w; + float yz_8 = _S1294.z * _S1294.w; + float wx_8 = _S1294.x * _S1294.y; + float wy_8 = _S1294.x * _S1294.z; + float wz_8 = _S1294.x * _S1294.w; + Matrix M_8 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_8 + z2_8), 2.0f * (xy_8 + wz_8), 2.0f * (xz_8 - wy_8), 2.0f * (xy_8 - wz_8), 1.0f - 2.0f * (x2_8 + z2_8), 2.0f * (yz_8 + wx_8), 2.0f * (xz_8 + wy_8), 2.0f * (yz_8 - wx_8), 1.0f - 2.0f * (x2_8 + y2_8))), makeMatrix (_S1295.x, 0.0f, 0.0f, 0.0f, _S1295.y, 0.0f, 0.0f, 0.0f, _S1295.z)); + Matrix _S1296 = transpose_3(R_8); + Matrix covar_c_8 = mul_5(mul_5(R_8, mul_5(M_8, transpose_3(M_8))), _S1296); + for(;;) + { + float k_12; + covar2d_8 = _S1293; + for(;;) + { + float2 _S1297 = float2 {mean_c_8.x, mean_c_8.y}; + _S1289 = _S1297; + float r_19 = length_0(_S1297); + float _S1298 = mean_c_8.z; + _S1290 = _S1298; + float theta_12 = (F32_atan2((r_19), (_S1298))); + bool _S1299 = r_19 < 9.99999997475242708e-07f; + if(_S1299) + { + k_12 = (1.0f - theta_12 * theta_12 / 24.0f) / _S1298; + } + else + { + k_12 = 2.0f * (F32_sin((0.5f * theta_12))) / r_19; + } + float2 _S1300 = _S1297 * make_float2 (k_12); + float2 _S1301 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1302; + (&_S1302)->primal_0 = _S1300; + (&_S1302)->differential_0 = _S1301; + FixedArray _S1303 = dist_coeffs_20; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1304 = s_fwd_DistOpenCV_distort_0(&_S1302, &_S1303); + float2 _S1305 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1306; + (&_S1306)->primal_0 = _S1300; + (&_S1306)->differential_0 = _S1305; + FixedArray _S1307 = dist_coeffs_20; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1308 = s_fwd_DistOpenCV_distort_0(&_S1306, &_S1307); + Matrix _S1309 = transpose_0(makeMatrix (_S1304.differential_0, _S1308.differential_0)); + float _S1310 = (F32_min((determinant_0(_S1309)), ((F32_min((_S1309.rows[int(0)].x), (_S1309.rows[int(1)].y)))))); + if(_S1310 > 0.25f) + { + is_valid_4 = _S1310 < 4.0f; + } + else + { + is_valid_4 = false; + } + if(is_valid_4) + { + FixedArray _S1311 = dist_coeffs_20; + float2 _S1312 = DistOpenCV_distort_0(_S1300, &_S1311); + is_valid_4 = (dot_0(_S1300, _S1312)) >= 0.0f; + } + else + { + is_valid_4 = false; + } + if(!is_valid_4) + { + *mean2d_21 = _S1300; + is_valid_4 = false; + break; + } + if(_S1299) + { + k_12 = (1.0f - theta_12 * theta_12 / 24.0f) / _S1298; + } + else + { + k_12 = 2.0f * (F32_sin((0.5f * theta_12))) / r_19; + } + float2 _S1313 = _S1297 * make_float2 (k_12); + FixedArray _S1314 = dist_coeffs_20; + float2 _S1315 = DistOpenCV_distort_0(_S1313, &_S1314); + *mean2d_21 = make_float2 (fx_21 * _S1315.x + cx_12, fy_21 * _S1315.y + cy_12); + is_valid_4 = true; + break; + } + if(!is_valid_4) + { + is_valid_4 = false; + break; + } + Matrix J_29; + float2 _S1316 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1317; + (&_S1317)->primal_0 = _S1289; + (&_S1317)->differential_0 = _S1316; + DiffPair_float_0 _S1318 = s_fwd_length_impl_0(&_S1317); + float _S1319 = _S1290; + DiffPair_float_0 _S1320; + (&_S1320)->primal_0 = _S1318.primal_0; + (&_S1320)->differential_0 = _S1318.differential_0; + DiffPair_float_0 _S1321; + (&_S1321)->primal_0 = _S1290; + (&_S1321)->differential_0 = 0.0f; + DiffPair_float_0 _S1322 = _d_atan2_1(&_S1320, &_S1321); + if((_S1318.primal_0) < 9.99999997475242708e-07f) + { + float _S1323 = _S1322.differential_0 * _S1322.primal_0; + float _S1324 = (0.0f - (_S1323 + _S1323) * 0.0416666679084301f) * _S1290 / (_S1290 * _S1290); + k_12 = (1.0f - _S1322.primal_0 * _S1322.primal_0 / 24.0f) / _S1290; + eps2d_8 = _S1324; + } + else + { + float _S1325 = _S1322.differential_0 * 0.5f; + DiffPair_float_0 _S1326; + (&_S1326)->primal_0 = 0.5f * _S1322.primal_0; + (&_S1326)->differential_0 = _S1325; + DiffPair_float_0 _S1327 = _d_sin_1(&_S1326); + float _S1328 = 2.0f * _S1327.primal_0; + float _S1329 = (_S1327.differential_0 * 2.0f * _S1318.primal_0 - _S1328 * _S1318.differential_0) / (_S1318.primal_0 * _S1318.primal_0); + k_12 = _S1328 / _S1318.primal_0; + eps2d_8 = _S1329; + } + float2 _S1330 = _S1289 * make_float2 (k_12); + float2 _S1331 = _S1316 * make_float2 (k_12) + make_float2 (eps2d_8) * _S1289; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1332; + (&_S1332)->primal_0 = _S1330; + (&_S1332)->differential_0 = _S1331; + FixedArray _S1333 = dist_coeffs_20; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1334 = s_fwd_DistOpenCV_distort_0(&_S1332, &_S1333); + float _S1335 = _S1334.differential_0.y * fy_21; + *&(((&J_29)->rows + (int(0)))->x) = _S1334.differential_0.x * fx_21; + *&(((&J_29)->rows + (int(1)))->x) = _S1335; + float2 _S1336 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1337; + (&_S1337)->primal_0 = _S1289; + (&_S1337)->differential_0 = _S1336; + DiffPair_float_0 _S1338 = s_fwd_length_impl_0(&_S1337); + DiffPair_float_0 _S1339; + (&_S1339)->primal_0 = _S1338.primal_0; + (&_S1339)->differential_0 = _S1338.differential_0; + DiffPair_float_0 _S1340; + (&_S1340)->primal_0 = _S1319; + (&_S1340)->differential_0 = 0.0f; + DiffPair_float_0 _S1341 = _d_atan2_1(&_S1339, &_S1340); + if((_S1338.primal_0) < 9.99999997475242708e-07f) + { + float _S1342 = _S1341.differential_0 * _S1341.primal_0; + float _S1343 = (0.0f - (_S1342 + _S1342) * 0.0416666679084301f) * _S1290 / (_S1290 * _S1290); + k_12 = (1.0f - _S1341.primal_0 * _S1341.primal_0 / 24.0f) / _S1290; + eps2d_8 = _S1343; + } + else + { + float _S1344 = _S1341.differential_0 * 0.5f; + DiffPair_float_0 _S1345; + (&_S1345)->primal_0 = 0.5f * _S1341.primal_0; + (&_S1345)->differential_0 = _S1344; + DiffPair_float_0 _S1346 = _d_sin_1(&_S1345); + float _S1347 = 2.0f * _S1346.primal_0; + float _S1348 = (_S1346.differential_0 * 2.0f * _S1338.primal_0 - _S1347 * _S1338.differential_0) / (_S1338.primal_0 * _S1338.primal_0); + k_12 = _S1347 / _S1338.primal_0; + eps2d_8 = _S1348; + } + float2 _S1349 = _S1289 * make_float2 (k_12); + float2 _S1350 = _S1336 * make_float2 (k_12) + make_float2 (eps2d_8) * _S1289; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1351; + (&_S1351)->primal_0 = _S1349; + (&_S1351)->differential_0 = _S1350; + FixedArray _S1352 = dist_coeffs_20; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1353 = s_fwd_DistOpenCV_distort_0(&_S1351, &_S1352); + float _S1354 = _S1353.differential_0.y * fy_21; + *&(((&J_29)->rows + (int(0)))->y) = _S1353.differential_0.x * fx_21; + *&(((&J_29)->rows + (int(1)))->y) = _S1354; + float2 _S1355 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1356; + (&_S1356)->primal_0 = _S1289; + (&_S1356)->differential_0 = _S1355; + DiffPair_float_0 _S1357 = s_fwd_length_impl_0(&_S1356); + DiffPair_float_0 _S1358; + (&_S1358)->primal_0 = _S1357.primal_0; + (&_S1358)->differential_0 = _S1357.differential_0; + DiffPair_float_0 _S1359; + (&_S1359)->primal_0 = _S1290; + (&_S1359)->differential_0 = 1.0f; + DiffPair_float_0 _S1360 = _d_atan2_1(&_S1358, &_S1359); + if((_S1357.primal_0) < 9.99999997475242708e-07f) + { + float _S1361 = _S1360.differential_0 * _S1360.primal_0; + float _S1362 = 1.0f - _S1360.primal_0 * _S1360.primal_0 / 24.0f; + float _S1363 = ((0.0f - (_S1361 + _S1361) * 0.0416666679084301f) * _S1290 - _S1362) / (_S1290 * _S1290); + k_12 = _S1362 / _S1290; + eps2d_8 = _S1363; + } + else + { + float _S1364 = _S1360.differential_0 * 0.5f; + DiffPair_float_0 _S1365; + (&_S1365)->primal_0 = 0.5f * _S1360.primal_0; + (&_S1365)->differential_0 = _S1364; + DiffPair_float_0 _S1366 = _d_sin_1(&_S1365); + float _S1367 = 2.0f * _S1366.primal_0; + float _S1368 = (_S1366.differential_0 * 2.0f * _S1357.primal_0 - _S1367 * _S1357.differential_0) / (_S1357.primal_0 * _S1357.primal_0); + k_12 = _S1367 / _S1357.primal_0; + eps2d_8 = _S1368; + } + float2 _S1369 = _S1289 * make_float2 (k_12); + float2 _S1370 = make_float2 (eps2d_8) * _S1289; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1371; + (&_S1371)->primal_0 = _S1369; + (&_S1371)->differential_0 = _S1370; + FixedArray _S1372 = dist_coeffs_20; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1373 = s_fwd_DistOpenCV_distort_0(&_S1371, &_S1372); + float _S1374 = _S1373.differential_0.y * fy_21; + *&(((&J_29)->rows + (int(0)))->z) = _S1373.differential_0.x * fx_21; + *&(((&J_29)->rows + (int(1)))->z) = _S1374; + covar2d_8 = mul_4(mul_3(J_29, covar_c_8), transpose_1(J_29)); + is_valid_4 = true; + break; + } + bool is_valid_5 = true & is_valid_4; + float2 mean2d_c_4 = *mean2d_21 - make_float2 (cx_12, cy_12); + float invdet_12 = 1.0f / (covar2d_8.rows[int(0)].x * covar2d_8.rows[int(1)].y - covar2d_8.rows[int(0)].y * covar2d_8.rows[int(1)].x); + float opac_4 = *opacity_8 * (F32_exp((-0.5f * dot_0(mul_7(makeMatrix (covar2d_8.rows[int(1)].y * invdet_12, - covar2d_8.rows[int(0)].y * invdet_12, - covar2d_8.rows[int(1)].x * invdet_12, covar2d_8.rows[int(0)].x * invdet_12), mean2d_c_4), mean2d_c_4)))); + if(_S1290 < 0.0f) + { + is_valid_4 = opac_4 > 0.00392156885936856f; + } + else + { + is_valid_4 = false; + } + if(is_valid_4) + { + is_valid_4 = false; + } + else + { + is_valid_4 = is_valid_5; + } + if(!is_valid_4) + { + *aabb_xyxy_8 = _S1291; + break; + } + if(antialiased_8) + { + eps2d_8 = 0.10000000149011612f; + } + else + { + eps2d_8 = 0.30000001192092896f; + } + float det_orig_8 = *&(((&covar2d_8)->rows + (int(0)))->x) * *&(((&covar2d_8)->rows + (int(1)))->y) - *&(((&covar2d_8)->rows + (int(0)))->y) * *&(((&covar2d_8)->rows + (int(1)))->x); + float _S1375 = *&(((&covar2d_8)->rows + (int(0)))->x) + eps2d_8; + *&(((&covar2d_8)->rows + (int(0)))->x) = _S1375; + float _S1376 = *&(((&covar2d_8)->rows + (int(1)))->y) + eps2d_8; + *&(((&covar2d_8)->rows + (int(1)))->y) = _S1376; + float det_blur_8 = _S1375 * _S1376 - *&(((&covar2d_8)->rows + (int(0)))->y) * *&(((&covar2d_8)->rows + (int(1)))->x); + float compensation_8 = (F32_sqrt(((F32_max((0.0f), (det_orig_8 / det_blur_8)))))); + if(det_blur_8 <= 0.0f) + { + *aabb_xyxy_8 = _S1291; + break; + } + float invdet_13 = 1.0f / (covar2d_8.rows[int(0)].x * covar2d_8.rows[int(1)].y - covar2d_8.rows[int(0)].y * covar2d_8.rows[int(1)].x); + Matrix _S1377 = makeMatrix (covar2d_8.rows[int(1)].y * invdet_13, - covar2d_8.rows[int(0)].y * invdet_13, - covar2d_8.rows[int(1)].x * invdet_13, covar2d_8.rows[int(0)].x * invdet_13); + if(antialiased_8) + { + *opacity_8 = *opacity_8 * compensation_8; + } + if((*opacity_8) < 0.00392156885936856f) + { + *aabb_xyxy_8 = _S1291; + break; + } + float _S1378 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_8 / 0.00392156885936856f))))))))); + float radius_x_8 = _S1378 * (F32_sqrt((covar2d_8[int(0)].x))); + float radius_y_8 = _S1378 * (F32_sqrt((covar2d_8[int(1)].y))); + float _S1379 = (*mean2d_21).x - radius_x_8; + float _S1380 = (*mean2d_21).x + radius_x_8; + float _S1381 = (*mean2d_21).y - radius_y_8; + float _S1382 = (*mean2d_21).y + radius_y_8; + if(_S1380 <= 0.0f) + { + is_valid_4 = true; + } + else + { + is_valid_4 = _S1379 >= float(image_width_8); + } + if(is_valid_4) + { + is_valid_4 = true; + } + else + { + is_valid_4 = _S1382 <= 0.0f; + } + if(is_valid_4) + { + is_valid_4 = true; + } + else + { + is_valid_4 = _S1381 >= float(image_height_8); + } + if(is_valid_4) + { + *aabb_xyxy_8 = _S1291; + break; + } + *aabb_xyxy_8 = make_float4 (_S1379, _S1381, _S1380, _S1382); + float x_28 = mean_c_8.x; + float y_9 = mean_c_8.y; + float _S1383 = x_28 * x_28 + y_9 * y_9; + *sorting_depth_8 = _S1290 * _S1290 * _S1290 * _S1290 + 0.001953125f * _S1383 * _S1383; + *conic_8 = make_float3 (_S1377.rows[int(0)].x, _S1377.rows[int(0)].y, _S1377.rows[int(1)].y); + *radius_9 = view_radius_3dgs_0(mean_9, scale_8, in_opacity_8, - mul_6(_S1296, t_8)); + break; + } + return; +} + +inline __device__ void projection_3dgs_equisolid_prism(bool antialiased_9, float3 mean_10, float4 quat_9, float3 scale_9, float in_opacity_9, Matrix R_9, float3 t_9, float fx_22, float fy_22, float cx_13, float cy_13, FixedArray dist_coeffs_21, uint image_width_9, uint image_height_9, float4 * aabb_xyxy_9, float * sorting_depth_9, float * radius_10, float2 * mean2d_22, float * depth_9, float3 * conic_9, float * opacity_9) +{ + float2 _S1384; + float _S1385; + for(;;) + { + float4 _S1386 = make_float4 (0.0f); + *aabb_xyxy_9 = _S1386; + *sorting_depth_9 = 0.0f; + *radius_10 = 0.0f; + *mean2d_22 = make_float2 (0.0f); + *conic_9 = make_float3 (0.0f); + *opacity_9 = 0.0f; + float3 mean_c_9 = mul_6(R_9, mean_10) + t_9; + float _S1387 = length_1(mean_c_9); + *depth_9 = _S1387; + if(_S1387 <= 0.0f) + { + *aabb_xyxy_9 = _S1386; + break; + } + Matrix covar2d_9; + Matrix _S1388 = makeMatrix (0.0f); + *opacity_9 = 1.0f / (1.0f + (F32_exp((- in_opacity_9)))); + float eps2d_9; + bool is_valid_6; + float4 _S1389 = normalize_0(quat_9); + float3 _S1390 = exp_0(scale_9); + float x_29 = _S1389.y; + float x2_9 = x_29 * x_29; + float y2_9 = _S1389.z * _S1389.z; + float z2_9 = _S1389.w * _S1389.w; + float xy_9 = _S1389.y * _S1389.z; + float xz_9 = _S1389.y * _S1389.w; + float yz_9 = _S1389.z * _S1389.w; + float wx_9 = _S1389.x * _S1389.y; + float wy_9 = _S1389.x * _S1389.z; + float wz_9 = _S1389.x * _S1389.w; + Matrix M_9 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_9 + z2_9), 2.0f * (xy_9 + wz_9), 2.0f * (xz_9 - wy_9), 2.0f * (xy_9 - wz_9), 1.0f - 2.0f * (x2_9 + z2_9), 2.0f * (yz_9 + wx_9), 2.0f * (xz_9 + wy_9), 2.0f * (yz_9 - wx_9), 1.0f - 2.0f * (x2_9 + y2_9))), makeMatrix (_S1390.x, 0.0f, 0.0f, 0.0f, _S1390.y, 0.0f, 0.0f, 0.0f, _S1390.z)); + Matrix _S1391 = transpose_3(R_9); + Matrix covar_c_9 = mul_5(mul_5(R_9, mul_5(M_9, transpose_3(M_9))), _S1391); + for(;;) + { + float k_13; + covar2d_9 = _S1388; + for(;;) + { + float2 _S1392 = float2 {mean_c_9.x, mean_c_9.y}; + _S1384 = _S1392; + float r_20 = length_0(_S1392); + float _S1393 = mean_c_9.z; + _S1385 = _S1393; + float theta_13 = (F32_atan2((r_20), (_S1393))); + bool _S1394 = r_20 < 9.99999997475242708e-07f; + if(_S1394) + { + k_13 = (1.0f - theta_13 * theta_13 / 24.0f) / _S1393; + } + else + { + k_13 = 2.0f * (F32_sin((0.5f * theta_13))) / r_20; + } + float2 _S1395 = _S1392 * make_float2 (k_13); + float2 _S1396 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1397; + (&_S1397)->primal_0 = _S1395; + (&_S1397)->differential_0 = _S1396; + FixedArray _S1398 = dist_coeffs_21; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1399 = s_fwd_DistThinPrism_distort_0(&_S1397, &_S1398); + float2 _S1400 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1401; + (&_S1401)->primal_0 = _S1395; + (&_S1401)->differential_0 = _S1400; + FixedArray _S1402 = dist_coeffs_21; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1403 = s_fwd_DistThinPrism_distort_0(&_S1401, &_S1402); + Matrix _S1404 = transpose_0(makeMatrix (_S1399.differential_0, _S1403.differential_0)); + float _S1405 = (F32_min((determinant_0(_S1404)), ((F32_min((_S1404.rows[int(0)].x), (_S1404.rows[int(1)].y)))))); + if(_S1405 > 0.25f) + { + is_valid_6 = _S1405 < 4.0f; + } + else + { + is_valid_6 = false; + } + if(is_valid_6) + { + FixedArray _S1406 = dist_coeffs_21; + float2 _S1407 = DistThinPrism_distort_0(_S1395, &_S1406); + is_valid_6 = (dot_0(_S1395, _S1407)) >= 0.0f; + } + else + { + is_valid_6 = false; + } + if(!is_valid_6) + { + *mean2d_22 = _S1395; + is_valid_6 = false; + break; + } + if(_S1394) + { + k_13 = (1.0f - theta_13 * theta_13 / 24.0f) / _S1393; + } + else + { + k_13 = 2.0f * (F32_sin((0.5f * theta_13))) / r_20; + } + float2 _S1408 = _S1392 * make_float2 (k_13); + FixedArray _S1409 = dist_coeffs_21; + float2 _S1410 = DistThinPrism_distort_0(_S1408, &_S1409); + *mean2d_22 = make_float2 (fx_22 * _S1410.x + cx_13, fy_22 * _S1410.y + cy_13); + is_valid_6 = true; + break; + } + if(!is_valid_6) + { + is_valid_6 = false; + break; + } + Matrix J_30; + float2 _S1411 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1412; + (&_S1412)->primal_0 = _S1384; + (&_S1412)->differential_0 = _S1411; + DiffPair_float_0 _S1413 = s_fwd_length_impl_0(&_S1412); + float _S1414 = _S1385; + DiffPair_float_0 _S1415; + (&_S1415)->primal_0 = _S1413.primal_0; + (&_S1415)->differential_0 = _S1413.differential_0; + DiffPair_float_0 _S1416; + (&_S1416)->primal_0 = _S1385; + (&_S1416)->differential_0 = 0.0f; + DiffPair_float_0 _S1417 = _d_atan2_1(&_S1415, &_S1416); + if((_S1413.primal_0) < 9.99999997475242708e-07f) + { + float _S1418 = _S1417.differential_0 * _S1417.primal_0; + float _S1419 = (0.0f - (_S1418 + _S1418) * 0.0416666679084301f) * _S1385 / (_S1385 * _S1385); + k_13 = (1.0f - _S1417.primal_0 * _S1417.primal_0 / 24.0f) / _S1385; + eps2d_9 = _S1419; + } + else + { + float _S1420 = _S1417.differential_0 * 0.5f; + DiffPair_float_0 _S1421; + (&_S1421)->primal_0 = 0.5f * _S1417.primal_0; + (&_S1421)->differential_0 = _S1420; + DiffPair_float_0 _S1422 = _d_sin_1(&_S1421); + float _S1423 = 2.0f * _S1422.primal_0; + float _S1424 = (_S1422.differential_0 * 2.0f * _S1413.primal_0 - _S1423 * _S1413.differential_0) / (_S1413.primal_0 * _S1413.primal_0); + k_13 = _S1423 / _S1413.primal_0; + eps2d_9 = _S1424; + } + float2 _S1425 = _S1384 * make_float2 (k_13); + float2 _S1426 = _S1411 * make_float2 (k_13) + make_float2 (eps2d_9) * _S1384; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1427; + (&_S1427)->primal_0 = _S1425; + (&_S1427)->differential_0 = _S1426; + FixedArray _S1428 = dist_coeffs_21; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1429 = s_fwd_DistThinPrism_distort_0(&_S1427, &_S1428); + float _S1430 = _S1429.differential_0.y * fy_22; + *&(((&J_30)->rows + (int(0)))->x) = _S1429.differential_0.x * fx_22; + *&(((&J_30)->rows + (int(1)))->x) = _S1430; + float2 _S1431 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1432; + (&_S1432)->primal_0 = _S1384; + (&_S1432)->differential_0 = _S1431; + DiffPair_float_0 _S1433 = s_fwd_length_impl_0(&_S1432); + DiffPair_float_0 _S1434; + (&_S1434)->primal_0 = _S1433.primal_0; + (&_S1434)->differential_0 = _S1433.differential_0; + DiffPair_float_0 _S1435; + (&_S1435)->primal_0 = _S1414; + (&_S1435)->differential_0 = 0.0f; + DiffPair_float_0 _S1436 = _d_atan2_1(&_S1434, &_S1435); + if((_S1433.primal_0) < 9.99999997475242708e-07f) + { + float _S1437 = _S1436.differential_0 * _S1436.primal_0; + float _S1438 = (0.0f - (_S1437 + _S1437) * 0.0416666679084301f) * _S1385 / (_S1385 * _S1385); + k_13 = (1.0f - _S1436.primal_0 * _S1436.primal_0 / 24.0f) / _S1385; + eps2d_9 = _S1438; + } + else + { + float _S1439 = _S1436.differential_0 * 0.5f; + DiffPair_float_0 _S1440; + (&_S1440)->primal_0 = 0.5f * _S1436.primal_0; + (&_S1440)->differential_0 = _S1439; + DiffPair_float_0 _S1441 = _d_sin_1(&_S1440); + float _S1442 = 2.0f * _S1441.primal_0; + float _S1443 = (_S1441.differential_0 * 2.0f * _S1433.primal_0 - _S1442 * _S1433.differential_0) / (_S1433.primal_0 * _S1433.primal_0); + k_13 = _S1442 / _S1433.primal_0; + eps2d_9 = _S1443; + } + float2 _S1444 = _S1384 * make_float2 (k_13); + float2 _S1445 = _S1431 * make_float2 (k_13) + make_float2 (eps2d_9) * _S1384; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1446; + (&_S1446)->primal_0 = _S1444; + (&_S1446)->differential_0 = _S1445; + FixedArray _S1447 = dist_coeffs_21; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1448 = s_fwd_DistThinPrism_distort_0(&_S1446, &_S1447); + float _S1449 = _S1448.differential_0.y * fy_22; + *&(((&J_30)->rows + (int(0)))->y) = _S1448.differential_0.x * fx_22; + *&(((&J_30)->rows + (int(1)))->y) = _S1449; + float2 _S1450 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1451; + (&_S1451)->primal_0 = _S1384; + (&_S1451)->differential_0 = _S1450; + DiffPair_float_0 _S1452 = s_fwd_length_impl_0(&_S1451); + DiffPair_float_0 _S1453; + (&_S1453)->primal_0 = _S1452.primal_0; + (&_S1453)->differential_0 = _S1452.differential_0; + DiffPair_float_0 _S1454; + (&_S1454)->primal_0 = _S1385; + (&_S1454)->differential_0 = 1.0f; + DiffPair_float_0 _S1455 = _d_atan2_1(&_S1453, &_S1454); + if((_S1452.primal_0) < 9.99999997475242708e-07f) + { + float _S1456 = _S1455.differential_0 * _S1455.primal_0; + float _S1457 = 1.0f - _S1455.primal_0 * _S1455.primal_0 / 24.0f; + float _S1458 = ((0.0f - (_S1456 + _S1456) * 0.0416666679084301f) * _S1385 - _S1457) / (_S1385 * _S1385); + k_13 = _S1457 / _S1385; + eps2d_9 = _S1458; + } + else + { + float _S1459 = _S1455.differential_0 * 0.5f; + DiffPair_float_0 _S1460; + (&_S1460)->primal_0 = 0.5f * _S1455.primal_0; + (&_S1460)->differential_0 = _S1459; + DiffPair_float_0 _S1461 = _d_sin_1(&_S1460); + float _S1462 = 2.0f * _S1461.primal_0; + float _S1463 = (_S1461.differential_0 * 2.0f * _S1452.primal_0 - _S1462 * _S1452.differential_0) / (_S1452.primal_0 * _S1452.primal_0); + k_13 = _S1462 / _S1452.primal_0; + eps2d_9 = _S1463; + } + float2 _S1464 = _S1384 * make_float2 (k_13); + float2 _S1465 = make_float2 (eps2d_9) * _S1384; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1466; + (&_S1466)->primal_0 = _S1464; + (&_S1466)->differential_0 = _S1465; + FixedArray _S1467 = dist_coeffs_21; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1468 = s_fwd_DistThinPrism_distort_0(&_S1466, &_S1467); + float _S1469 = _S1468.differential_0.y * fy_22; + *&(((&J_30)->rows + (int(0)))->z) = _S1468.differential_0.x * fx_22; + *&(((&J_30)->rows + (int(1)))->z) = _S1469; + covar2d_9 = mul_4(mul_3(J_30, covar_c_9), transpose_1(J_30)); + is_valid_6 = true; + break; + } + bool is_valid_7 = true & is_valid_6; + float2 mean2d_c_5 = *mean2d_22 - make_float2 (cx_13, cy_13); + float invdet_14 = 1.0f / (covar2d_9.rows[int(0)].x * covar2d_9.rows[int(1)].y - covar2d_9.rows[int(0)].y * covar2d_9.rows[int(1)].x); + float opac_5 = *opacity_9 * (F32_exp((-0.5f * dot_0(mul_7(makeMatrix (covar2d_9.rows[int(1)].y * invdet_14, - covar2d_9.rows[int(0)].y * invdet_14, - covar2d_9.rows[int(1)].x * invdet_14, covar2d_9.rows[int(0)].x * invdet_14), mean2d_c_5), mean2d_c_5)))); + if(_S1385 < 0.0f) + { + is_valid_6 = opac_5 > 0.00392156885936856f; + } + else + { + is_valid_6 = false; + } + if(is_valid_6) + { + is_valid_6 = false; + } + else + { + is_valid_6 = is_valid_7; + } + if(!is_valid_6) + { + *aabb_xyxy_9 = _S1386; + break; + } + if(antialiased_9) + { + eps2d_9 = 0.10000000149011612f; + } + else + { + eps2d_9 = 0.30000001192092896f; + } + float det_orig_9 = *&(((&covar2d_9)->rows + (int(0)))->x) * *&(((&covar2d_9)->rows + (int(1)))->y) - *&(((&covar2d_9)->rows + (int(0)))->y) * *&(((&covar2d_9)->rows + (int(1)))->x); + float _S1470 = *&(((&covar2d_9)->rows + (int(0)))->x) + eps2d_9; + *&(((&covar2d_9)->rows + (int(0)))->x) = _S1470; + float _S1471 = *&(((&covar2d_9)->rows + (int(1)))->y) + eps2d_9; + *&(((&covar2d_9)->rows + (int(1)))->y) = _S1471; + float det_blur_9 = _S1470 * _S1471 - *&(((&covar2d_9)->rows + (int(0)))->y) * *&(((&covar2d_9)->rows + (int(1)))->x); + float compensation_9 = (F32_sqrt(((F32_max((0.0f), (det_orig_9 / det_blur_9)))))); + if(det_blur_9 <= 0.0f) + { + *aabb_xyxy_9 = _S1386; + break; + } + float invdet_15 = 1.0f / (covar2d_9.rows[int(0)].x * covar2d_9.rows[int(1)].y - covar2d_9.rows[int(0)].y * covar2d_9.rows[int(1)].x); + Matrix _S1472 = makeMatrix (covar2d_9.rows[int(1)].y * invdet_15, - covar2d_9.rows[int(0)].y * invdet_15, - covar2d_9.rows[int(1)].x * invdet_15, covar2d_9.rows[int(0)].x * invdet_15); + if(antialiased_9) + { + *opacity_9 = *opacity_9 * compensation_9; + } + if((*opacity_9) < 0.00392156885936856f) + { + *aabb_xyxy_9 = _S1386; + break; + } + float _S1473 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_9 / 0.00392156885936856f))))))))); + float radius_x_9 = _S1473 * (F32_sqrt((covar2d_9[int(0)].x))); + float radius_y_9 = _S1473 * (F32_sqrt((covar2d_9[int(1)].y))); + float _S1474 = (*mean2d_22).x - radius_x_9; + float _S1475 = (*mean2d_22).x + radius_x_9; + float _S1476 = (*mean2d_22).y - radius_y_9; + float _S1477 = (*mean2d_22).y + radius_y_9; + if(_S1475 <= 0.0f) + { + is_valid_6 = true; + } + else + { + is_valid_6 = _S1474 >= float(image_width_9); + } + if(is_valid_6) + { + is_valid_6 = true; + } + else + { + is_valid_6 = _S1477 <= 0.0f; + } + if(is_valid_6) + { + is_valid_6 = true; + } + else + { + is_valid_6 = _S1476 >= float(image_height_9); + } + if(is_valid_6) + { + *aabb_xyxy_9 = _S1386; + break; + } + *aabb_xyxy_9 = make_float4 (_S1474, _S1476, _S1475, _S1477); + float x_30 = mean_c_9.x; + float y_10 = mean_c_9.y; + float _S1478 = x_30 * x_30 + y_10 * y_10; + *sorting_depth_9 = _S1385 * _S1385 * _S1385 * _S1385 + 0.001953125f * _S1478 * _S1478; + *conic_9 = make_float3 (_S1472.rows[int(0)].x, _S1472.rows[int(0)].y, _S1472.rows[int(1)].y); + *radius_10 = view_radius_3dgs_0(mean_10, scale_9, in_opacity_9, - mul_6(_S1391, t_9)); + break; + } + return; +} + +inline __device__ void projection_3dgs_equirect_none(bool antialiased_10, float3 mean_11, float4 quat_10, float3 scale_10, float in_opacity_10, Matrix R_10, float3 t_10, float fx_23, float fy_23, float cx_14, float cy_14, FixedArray dist_coeffs_22, uint image_width_10, uint image_height_10, float4 * aabb_xyxy_10, float * sorting_depth_10, float * radius_11, float2 * mean2d_23, float * depth_10, float3 * conic_10, float * opacity_10) +{ + for(;;) + { + float4 _S1479 = make_float4 (0.0f); + *aabb_xyxy_10 = _S1479; + *sorting_depth_10 = 0.0f; + *radius_11 = 0.0f; + *mean2d_23 = make_float2 (0.0f); + *conic_10 = make_float3 (0.0f); + *opacity_10 = 0.0f; + float3 mean_c_10 = mul_6(R_10, mean_11) + t_10; + float _S1480 = length_1(mean_c_10); + *depth_10 = _S1480; + if(_S1480 <= 0.0f) + { + *aabb_xyxy_10 = _S1479; + break; + } + Matrix covar2d_10; + *opacity_10 = 1.0f / (1.0f + (F32_exp((- in_opacity_10)))); + float4 _S1481 = normalize_0(quat_10); + float3 _S1482 = exp_0(scale_10); + float x_31 = _S1481.y; + float x2_10 = x_31 * x_31; + float y2_10 = _S1481.z * _S1481.z; + float z2_10 = _S1481.w * _S1481.w; + float xy_10 = _S1481.y * _S1481.z; + float xz_10 = _S1481.y * _S1481.w; + float yz_10 = _S1481.z * _S1481.w; + float wx_10 = _S1481.x * _S1481.y; + float wy_10 = _S1481.x * _S1481.z; + float wz_10 = _S1481.x * _S1481.w; + Matrix M_10 = mul_5(transpose_3(makeMatrix (1.0f - 2.0f * (y2_10 + z2_10), 2.0f * (xy_10 + wz_10), 2.0f * (xz_10 - wy_10), 2.0f * (xy_10 - wz_10), 1.0f - 2.0f * (x2_10 + z2_10), 2.0f * (yz_10 + wx_10), 2.0f * (xz_10 + wy_10), 2.0f * (yz_10 - wx_10), 1.0f - 2.0f * (x2_10 + y2_10))), makeMatrix (_S1482.x, 0.0f, 0.0f, 0.0f, _S1482.y, 0.0f, 0.0f, 0.0f, _S1482.z)); + Matrix _S1483 = transpose_3(R_10); + Matrix covar_c_10 = mul_5(mul_5(R_10, mul_5(M_10, transpose_3(M_10))), _S1483); + float _S1484 = mean_c_10.x; + float _S1485 = mean_c_10.z; + float _S1486 = mean_c_10.y; + float2 _S1487 = float2 {mean_c_10.x, mean_c_10.z}; + *mean2d_23 = make_float2 (fx_23 * (F32_atan2((_S1484), (_S1485))) + cx_14, fy_23 * (F32_atan2((_S1486), (length_0(_S1487)))) + cy_14); + DiffPair_float_0 _S1488; + (&_S1488)->primal_0 = _S1484; + (&_S1488)->differential_0 = 1.0f; + DiffPair_float_0 _S1489; + (&_S1489)->primal_0 = _S1485; + (&_S1489)->differential_0 = 0.0f; + DiffPair_float_0 _S1490 = _d_atan2_1(&_S1488, &_S1489); + float2 _S1491 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1492; + (&_S1492)->primal_0 = _S1487; + (&_S1492)->differential_0 = _S1491; + DiffPair_float_0 _S1493 = s_fwd_length_impl_0(&_S1492); + DiffPair_float_0 _S1494; + (&_S1494)->primal_0 = _S1486; + (&_S1494)->differential_0 = 0.0f; + DiffPair_float_0 _S1495; + (&_S1495)->primal_0 = _S1493.primal_0; + (&_S1495)->differential_0 = _S1493.differential_0; + DiffPair_float_0 _S1496 = _d_atan2_1(&_S1494, &_S1495); + float _S1497 = _S1496.differential_0 * fy_23; + Matrix J_31; + *&(((&J_31)->rows + (int(0)))->x) = _S1490.differential_0 * fx_23; + *&(((&J_31)->rows + (int(1)))->x) = _S1497; + DiffPair_float_0 _S1498; + (&_S1498)->primal_0 = _S1484; + (&_S1498)->differential_0 = 0.0f; + DiffPair_float_0 _S1499; + (&_S1499)->primal_0 = _S1485; + (&_S1499)->differential_0 = 0.0f; + DiffPair_float_0 _S1500 = _d_atan2_1(&_S1498, &_S1499); + float2 _S1501 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1502; + (&_S1502)->primal_0 = _S1487; + (&_S1502)->differential_0 = _S1501; + DiffPair_float_0 _S1503 = s_fwd_length_impl_0(&_S1502); + DiffPair_float_0 _S1504; + (&_S1504)->primal_0 = _S1486; + (&_S1504)->differential_0 = 1.0f; + DiffPair_float_0 _S1505; + (&_S1505)->primal_0 = _S1503.primal_0; + (&_S1505)->differential_0 = _S1503.differential_0; + DiffPair_float_0 _S1506 = _d_atan2_1(&_S1504, &_S1505); + float _S1507 = _S1506.differential_0 * fy_23; + *&(((&J_31)->rows + (int(0)))->y) = _S1500.differential_0 * fx_23; + *&(((&J_31)->rows + (int(1)))->y) = _S1507; + DiffPair_float_0 _S1508; + (&_S1508)->primal_0 = _S1484; + (&_S1508)->differential_0 = 0.0f; + DiffPair_float_0 _S1509; + (&_S1509)->primal_0 = _S1485; + (&_S1509)->differential_0 = 1.0f; + DiffPair_float_0 _S1510 = _d_atan2_1(&_S1508, &_S1509); + float2 _S1511 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1512; + (&_S1512)->primal_0 = _S1487; + (&_S1512)->differential_0 = _S1511; + DiffPair_float_0 _S1513 = s_fwd_length_impl_0(&_S1512); + DiffPair_float_0 _S1514; + (&_S1514)->primal_0 = _S1486; + (&_S1514)->differential_0 = 0.0f; + DiffPair_float_0 _S1515; + (&_S1515)->primal_0 = _S1513.primal_0; + (&_S1515)->differential_0 = _S1513.differential_0; + DiffPair_float_0 _S1516 = _d_atan2_1(&_S1514, &_S1515); + float _S1517 = _S1516.differential_0 * fy_23; + *&(((&J_31)->rows + (int(0)))->z) = _S1510.differential_0 * fx_23; + *&(((&J_31)->rows + (int(1)))->z) = _S1517; + covar2d_10 = mul_4(mul_3(J_31, covar_c_10), transpose_1(J_31)); + float eps2d_10; + if(antialiased_10) + { + eps2d_10 = 0.10000000149011612f; + } + else + { + eps2d_10 = 0.30000001192092896f; + } + float det_orig_10 = *&(((&covar2d_10)->rows + (int(0)))->x) * *&(((&covar2d_10)->rows + (int(1)))->y) - *&(((&covar2d_10)->rows + (int(0)))->y) * *&(((&covar2d_10)->rows + (int(1)))->x); + float _S1518 = *&(((&covar2d_10)->rows + (int(0)))->x) + eps2d_10; + *&(((&covar2d_10)->rows + (int(0)))->x) = _S1518; + float _S1519 = *&(((&covar2d_10)->rows + (int(1)))->y) + eps2d_10; + *&(((&covar2d_10)->rows + (int(1)))->y) = _S1519; + float det_blur_10 = _S1518 * _S1519 - *&(((&covar2d_10)->rows + (int(0)))->y) * *&(((&covar2d_10)->rows + (int(1)))->x); + float compensation_10 = (F32_sqrt(((F32_max((0.0f), (det_orig_10 / det_blur_10)))))); + if(det_blur_10 <= 0.0f) + { + *aabb_xyxy_10 = _S1479; + break; + } + float invdet_16 = 1.0f / (covar2d_10.rows[int(0)].x * covar2d_10.rows[int(1)].y - covar2d_10.rows[int(0)].y * covar2d_10.rows[int(1)].x); + Matrix _S1520 = makeMatrix (covar2d_10.rows[int(1)].y * invdet_16, - covar2d_10.rows[int(0)].y * invdet_16, - covar2d_10.rows[int(1)].x * invdet_16, covar2d_10.rows[int(0)].x * invdet_16); + if(antialiased_10) + { + *opacity_10 = *opacity_10 * compensation_10; + } + if((*opacity_10) < 0.00392156885936856f) + { + *aabb_xyxy_10 = _S1479; + break; + } + float _S1521 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_10 / 0.00392156885936856f))))))))); + float radius_x_10 = _S1521 * (F32_sqrt((covar2d_10[int(0)].x))); + float radius_y_10 = _S1521 * (F32_sqrt((covar2d_10[int(1)].y))); + float _S1522 = (*mean2d_23).x - radius_x_10; + float _S1523 = (*mean2d_23).x + radius_x_10; + float _S1524 = (*mean2d_23).y - radius_y_10; + float _S1525 = (*mean2d_23).y + radius_y_10; + bool _S1526; + if(_S1523 <= 0.0f) + { + _S1526 = true; + } + else + { + _S1526 = _S1522 >= float(image_width_10); + } + if(_S1526) + { + _S1526 = true; + } + else + { + _S1526 = _S1525 <= 0.0f; + } + if(_S1526) + { + _S1526 = true; + } + else + { + _S1526 = _S1524 >= float(image_height_10); + } + if(_S1526) + { + *aabb_xyxy_10 = _S1479; + break; + } + *aabb_xyxy_10 = make_float4 (_S1522, _S1524, _S1523, _S1525); + *sorting_depth_10 = dot_1(mean_c_10, mean_c_10); + *conic_10 = make_float3 (_S1520.rows[int(0)].x, _S1520.rows[int(0)].y, _S1520.rows[int(1)].y); + *radius_11 = view_radius_3dgs_0(mean_11, scale_10, in_opacity_10, - mul_6(_S1483, t_10)); break; } return; @@ -2839,60 +6195,67 @@ struct SigmaPoints_0 FixedArray w_cov_0; }; -inline __device__ void projection_3dgut_persp(bool antialiased_4, float3 mean_5, float4 quat_4, float3 scale_4, float in_opacity_4, Matrix R_4, float3 t_4, float fx_8, float fy_8, float cx_5, float cy_5, FixedArray dist_coeffs_8, uint image_width_4, uint image_height_4, float4 * aabb_xyxy_4, float * sorting_depth_4, float * radius_5, float2 * mean2d_8, float * depth_4, float3 * conic_4, float * opacity_4) +inline __device__ void projection_3dgut_persp_none(bool antialiased_11, float3 mean_12, float4 quat_11, float3 scale_11, float in_opacity_11, Matrix R_11, float3 t_11, float fx_24, float fy_24, float cx_15, float cy_15, FixedArray dist_coeffs_23, uint image_width_11, uint image_height_11, float4 * aabb_xyxy_11, float * sorting_depth_11, float * radius_12, float2 * mean2d_24, float * depth_11, float3 * conic_11, float * opacity_11) { - float _S666; - float _S667; - float2 * _S668; - float2 * _S669; - float2 * _S670; - bool _S671; - float2 * _S672; - float2 * _S673; - float2 * _S674; - bool _S675; - float2 * _S676; - bool _S677; + float _S1527; + float _S1528; + float2 * _S1529; + float2 * _S1530; + float2 * _S1531; + bool _S1532; + float2 * _S1533; + float2 * _S1534; + float2 * _S1535; + bool _S1536; + float2 * _S1537; + bool _S1538; for(;;) { - float3 mean_c_4 = mul_6(R_4, mean_5) + t_4; - float _S678 = mean_c_4.z; - *depth_4 = length_1(mean_c_4); - if(_S678 <= 0.0f) + float4 _S1539 = make_float4 (0.0f); + *aabb_xyxy_11 = _S1539; + *sorting_depth_11 = 0.0f; + *radius_12 = 0.0f; + *mean2d_24 = make_float2 (0.0f); + *conic_11 = make_float3 (0.0f); + *opacity_11 = 0.0f; + float3 mean_c_11 = mul_6(R_11, mean_12) + t_11; + float _S1540 = mean_c_11.z; + *depth_11 = length_1(mean_c_11); + if(_S1540 <= 0.0f) { - *aabb_xyxy_4 = make_float4 (0.0f); + *aabb_xyxy_11 = _S1539; break; } - Matrix covar2d_4; - *opacity_4 = 1.0f / (1.0f + (F32_exp((- in_opacity_4)))); - bool _S679; - float3 _S680 = exp_0(scale_4); - float4 _S681 = normalize_0(quat_4); - float x_21 = _S681.y; - float x2_4 = x_21 * x_21; - float y2_4 = _S681.z * _S681.z; - float z2_4 = _S681.w * _S681.w; - float xy_4 = _S681.y * _S681.z; - float xz_4 = _S681.y * _S681.w; - float yz_4 = _S681.z * _S681.w; - float wx_4 = _S681.x * _S681.y; - float wy_4 = _S681.x * _S681.z; - float wz_4 = _S681.x * _S681.w; - Matrix _S682 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_4 + z2_4), 2.0f * (xy_4 + wz_4), 2.0f * (xz_4 - wy_4), 2.0f * (xy_4 - wz_4), 1.0f - 2.0f * (x2_4 + z2_4), 2.0f * (yz_4 + wx_4), 2.0f * (xz_4 + wy_4), 2.0f * (yz_4 - wx_4), 1.0f - 2.0f * (x2_4 + y2_4)))); + Matrix covar2d_11; + *opacity_11 = 1.0f / (1.0f + (F32_exp((- in_opacity_11)))); + bool _S1541; + float3 _S1542 = exp_0(scale_11); + float4 _S1543 = normalize_0(quat_11); + float x_32 = _S1543.y; + float x2_11 = x_32 * x_32; + float y2_11 = _S1543.z * _S1543.z; + float z2_11 = _S1543.w * _S1543.w; + float xy_11 = _S1543.y * _S1543.z; + float xz_11 = _S1543.y * _S1543.w; + float yz_11 = _S1543.z * _S1543.w; + float wx_11 = _S1543.x * _S1543.y; + float wy_11 = _S1543.x * _S1543.z; + float wz_11 = _S1543.x * _S1543.w; + Matrix _S1544 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_11 + z2_11), 2.0f * (xy_11 + wz_11), 2.0f * (xz_11 - wy_11), 2.0f * (xy_11 - wz_11), 1.0f - 2.0f * (x2_11 + z2_11), 2.0f * (yz_11 + wx_11), 2.0f * (xz_11 + wy_11), 2.0f * (yz_11 - wx_11), 1.0f - 2.0f * (x2_11 + y2_11)))); SigmaPoints_0 ret_0; - (&ret_0)->p_0[int(0)] = mean_5; + (&ret_0)->p_0[int(0)] = mean_12; (&ret_0)->w_mean_0[int(0)] = 0.0f; (&ret_0)->w_cov_0[int(0)] = 2.0f; - float _S683 = (F32_sqrt((3.0f))); - float3 delta_0 = make_float3 (_S683 * _S680.x) * _S682.rows[0U]; - float3 _S684 = mean_5 + delta_0; - float3 _S685 = mean_5 - delta_0; - float3 delta_1 = make_float3 (_S683 * _S680.y) * _S682.rows[1U]; - float3 _S686 = mean_5 + delta_1; - float3 _S687 = mean_5 - delta_1; - float3 delta_2 = make_float3 (_S683 * _S680.z) * _S682.rows[2U]; - float3 _S688 = mean_5 + delta_2; - float3 _S689 = mean_5 - delta_2; + float _S1545 = (F32_sqrt((3.0f))); + float3 delta_0 = make_float3 (_S1545 * _S1542.x) * _S1544.rows[0U]; + float3 _S1546 = mean_12 + delta_0; + float3 _S1547 = mean_12 - delta_0; + float3 delta_1 = make_float3 (_S1545 * _S1542.y) * _S1544.rows[1U]; + float3 _S1548 = mean_12 + delta_1; + float3 _S1549 = mean_12 - delta_1; + float3 delta_2 = make_float3 (_S1545 * _S1542.z) * _S1544.rows[2U]; + float3 _S1550 = mean_12 + delta_2; + float3 _S1551 = mean_12 - delta_2; (&ret_0)->w_mean_0[1U] = 0.1666666716337204f; (&ret_0)->w_cov_0[1U] = 0.1666666716337204f; (&ret_0)->w_mean_0[2U] = 0.1666666716337204f; @@ -2905,540 +6268,374 @@ inline __device__ void projection_3dgut_persp(bool antialiased_4, float3 mean_5 (&ret_0)->w_cov_0[5U] = 0.1666666716337204f; (&ret_0)->w_mean_0[6U] = 0.1666666716337204f; (&ret_0)->w_cov_0[6U] = 0.1666666716337204f; - (&ret_0)->p_0[0U] = mul_6(R_4, (&ret_0)->p_0[0U]) + t_4; - (&ret_0)->p_0[1U] = mul_6(R_4, _S684) + t_4; - (&ret_0)->p_0[2U] = mul_6(R_4, _S686) + t_4; - (&ret_0)->p_0[3U] = mul_6(R_4, _S688) + t_4; - (&ret_0)->p_0[4U] = mul_6(R_4, _S685) + t_4; - (&ret_0)->p_0[5U] = mul_6(R_4, _S687) + t_4; - (&ret_0)->p_0[6U] = mul_6(R_4, _S689) + t_4; - SigmaPoints_0 _S690 = ret_0; + (&ret_0)->p_0[0U] = mul_6(R_11, (&ret_0)->p_0[0U]) + t_11; + (&ret_0)->p_0[1U] = mul_6(R_11, _S1546) + t_11; + (&ret_0)->p_0[2U] = mul_6(R_11, _S1548) + t_11; + (&ret_0)->p_0[3U] = mul_6(R_11, _S1550) + t_11; + (&ret_0)->p_0[4U] = mul_6(R_11, _S1547) + t_11; + (&ret_0)->p_0[5U] = mul_6(R_11, _S1549) + t_11; + (&ret_0)->p_0[6U] = mul_6(R_11, _S1551) + t_11; + SigmaPoints_0 _S1552 = ret_0; for(;;) { - int2 _S691 = make_int2 (int(0)); - float2 _S692 = make_float2 ((float)_S691.x, (float)_S691.y); - *mean2d_8 = _S692; - covar2d_4 = makeMatrix (0.0f); - float _S693 = float(image_width_4); - _S666 = _S693; - float tan_fovx_0 = 0.5f * _S693 / fx_8; - float _S694 = float(image_height_4); - _S667 = _S694; - float _S695 = 0.30000001192092896f * tan_fovx_0 * fx_8; - float lim_x_pos_2 = _S693 + _S695; - float _S696 = 0.30000001192092896f * (0.5f * _S694 / fy_8) * fy_8; - float lim_y_pos_0 = _S694 + _S696; + int2 _S1553 = make_int2 (int(0)); + float2 _S1554 = make_float2 ((float)_S1553.x, (float)_S1553.y); + *mean2d_24 = _S1554; + covar2d_11 = makeMatrix (0.0f); + float _S1555 = float(image_width_11); + _S1527 = _S1555; + float tan_fovx_0 = 0.5f * _S1555 / fx_24; + float _S1556 = float(image_height_11); + _S1528 = _S1556; + float _S1557 = 0.30000001192092896f * tan_fovx_0 * fx_24; + float lim_x_pos_8 = _S1555 + _S1557; + float _S1558 = 0.30000001192092896f * (0.5f * _S1556 / fy_24) * fy_24; + float lim_y_pos_0 = _S1556 + _S1558; FixedArray proj_points_0; for(;;) { - _S668 = &proj_points_0[int(0)]; + _S1529 = &proj_points_0[int(0)]; for(;;) { - float _S697 = _S690.p_0[int(0)].z; - proj_points_0[int(0)] = float2 {_S690.p_0[int(0)].x, _S690.p_0[int(0)].y} / make_float2 (_S697); - if(_S697 < 0.0f) - { - _S679 = true; - } - else - { - float u_30 = proj_points_0[int(0)].x; - float v_30 = proj_points_0[int(0)].y; - float _S698 = u_30 + u_30; - float r2_30 = u_30 * u_30 + v_30 * v_30; - float _S699 = dist_coeffs_8[int(2)] + r2_30 * dist_coeffs_8[int(3)]; - float _S700 = dist_coeffs_8[int(1)] + r2_30 * _S699; - float _S701 = dist_coeffs_8[int(0)] + r2_30 * _S700; - float radial_6 = 1.0f + r2_30 * _S701; - float _S702 = 2.0f * dist_coeffs_8[int(4)]; - float _S703 = 2.0f * u_30; - float _S704 = 2.0f * dist_coeffs_8[int(5)]; - float _S705 = 2.0f * v_30; - float2 _S706 = make_float2 (1.0f, 0.0f) * make_float2 (radial_6) + make_float2 (_S698 * _S701 + (_S698 * _S700 + (_S698 * _S699 + _S698 * dist_coeffs_8[int(3)] * r2_30) * r2_30) * r2_30) * proj_points_0[int(0)] + make_float2 (_S702 * v_30 + (_S698 + (_S703 + _S703)) * dist_coeffs_8[int(5)] + _S698 * dist_coeffs_8[int(6)], _S704 * v_30 + _S698 * dist_coeffs_8[int(4)] + _S698 * dist_coeffs_8[int(7)]); - float _S707 = v_30 + v_30; - float2 _S708 = make_float2 (0.0f, 1.0f) * make_float2 (radial_6) + make_float2 (_S707 * _S701 + (_S707 * _S700 + (_S707 * _S699 + _S707 * dist_coeffs_8[int(3)] * r2_30) * r2_30) * r2_30) * proj_points_0[int(0)] + make_float2 (_S702 * u_30 + _S707 * dist_coeffs_8[int(5)] + _S707 * dist_coeffs_8[int(6)], _S704 * u_30 + (_S707 + (_S705 + _S705)) * dist_coeffs_8[int(4)] + _S707 * dist_coeffs_8[int(7)]); - Matrix _S709 = transpose_0(makeMatrix (_S706 + make_float2 (_S706.x * dist_coeffs_8[int(8)] + _S706.y * dist_coeffs_8[int(9)], 0.0f), _S708 + make_float2 (_S708.x * dist_coeffs_8[int(8)] + _S708.y * dist_coeffs_8[int(9)], 0.0f))); - _S679 = !((F32_min((determinant_0(_S709)), ((F32_min((_S709.rows[int(0)].x), (_S709.rows[int(1)].y)))))) > 0.0f); - } - if(_S679) + float2 _S1559 = float2 {_S1552.p_0[int(0)].x, _S1552.p_0[int(0)].y}; + float _S1560 = _S1552.p_0[int(0)].z; + float2 uv0_8 = _S1559 / make_float2 (_S1560); + bool _S1561 = _S1560 < 0.0f; + if(_S1561) { + proj_points_0[int(0)] = uv0_8; + _S1541 = false; break; } - float u_31 = proj_points_0[int(0)].x; - float v_31 = proj_points_0[int(0)].y; - float r2_31 = u_31 * u_31 + v_31 * v_31; - float2 _S710 = proj_points_0[int(0)] * make_float2 (1.0f + r2_31 * (dist_coeffs_8[int(0)] + r2_31 * (dist_coeffs_8[int(1)] + r2_31 * (dist_coeffs_8[int(2)] + r2_31 * dist_coeffs_8[int(3)])))) + make_float2 (2.0f * dist_coeffs_8[int(4)] * u_31 * v_31 + dist_coeffs_8[int(5)] * (r2_31 + 2.0f * u_31 * u_31) + dist_coeffs_8[int(6)] * r2_31, 2.0f * dist_coeffs_8[int(5)] * u_31 * v_31 + dist_coeffs_8[int(4)] * (r2_31 + 2.0f * v_31 * v_31) + dist_coeffs_8[int(7)] * r2_31); - float2 _S711 = _S710 + make_float2 (dist_coeffs_8[int(8)] * _S710.x + dist_coeffs_8[int(9)] * _S710.y, 0.0f); - proj_points_0[int(0)] = make_float2 (fx_8 * _S711.x + cx_5, fy_8 * _S711.y + cy_5); + float2 uv_12 = _S1559 / make_float2 (_S1560); + FixedArray _S1562 = dist_coeffs_23; + float2 _S1563 = DistNone_distort_0(uv_12, &_S1562); + proj_points_0[int(0)] = make_float2 (fx_24 * _S1563.x + cx_15, fy_24 * _S1563.y + cy_15); + _S1541 = true; break; } - bool all_valid_0 = true & (!_S679); - _S669 = &proj_points_0[int(1)]; + bool all_valid_0 = true & _S1541; + _S1530 = &proj_points_0[int(1)]; for(;;) { - float _S712 = _S690.p_0[int(1)].z; - proj_points_0[int(1)] = float2 {_S690.p_0[int(1)].x, _S690.p_0[int(1)].y} / make_float2 (_S712); - if(_S712 < 0.0f) - { - _S679 = true; - } - else - { - float u_32 = proj_points_0[int(1)].x; - float v_32 = proj_points_0[int(1)].y; - float _S713 = u_32 + u_32; - float r2_32 = u_32 * u_32 + v_32 * v_32; - float _S714 = dist_coeffs_8[int(2)] + r2_32 * dist_coeffs_8[int(3)]; - float _S715 = dist_coeffs_8[int(1)] + r2_32 * _S714; - float _S716 = dist_coeffs_8[int(0)] + r2_32 * _S715; - float radial_7 = 1.0f + r2_32 * _S716; - float _S717 = 2.0f * dist_coeffs_8[int(4)]; - float _S718 = 2.0f * u_32; - float _S719 = 2.0f * dist_coeffs_8[int(5)]; - float _S720 = 2.0f * v_32; - float2 _S721 = make_float2 (1.0f, 0.0f) * make_float2 (radial_7) + make_float2 (_S713 * _S716 + (_S713 * _S715 + (_S713 * _S714 + _S713 * dist_coeffs_8[int(3)] * r2_32) * r2_32) * r2_32) * proj_points_0[int(1)] + make_float2 (_S717 * v_32 + (_S713 + (_S718 + _S718)) * dist_coeffs_8[int(5)] + _S713 * dist_coeffs_8[int(6)], _S719 * v_32 + _S713 * dist_coeffs_8[int(4)] + _S713 * dist_coeffs_8[int(7)]); - float _S722 = v_32 + v_32; - float2 _S723 = make_float2 (0.0f, 1.0f) * make_float2 (radial_7) + make_float2 (_S722 * _S716 + (_S722 * _S715 + (_S722 * _S714 + _S722 * dist_coeffs_8[int(3)] * r2_32) * r2_32) * r2_32) * proj_points_0[int(1)] + make_float2 (_S717 * u_32 + _S722 * dist_coeffs_8[int(5)] + _S722 * dist_coeffs_8[int(6)], _S719 * u_32 + (_S722 + (_S720 + _S720)) * dist_coeffs_8[int(4)] + _S722 * dist_coeffs_8[int(7)]); - Matrix _S724 = transpose_0(makeMatrix (_S721 + make_float2 (_S721.x * dist_coeffs_8[int(8)] + _S721.y * dist_coeffs_8[int(9)], 0.0f), _S723 + make_float2 (_S723.x * dist_coeffs_8[int(8)] + _S723.y * dist_coeffs_8[int(9)], 0.0f))); - _S679 = !((F32_min((determinant_0(_S724)), ((F32_min((_S724.rows[int(0)].x), (_S724.rows[int(1)].y)))))) > 0.0f); - } - if(_S679) + float2 _S1564 = float2 {_S1552.p_0[int(1)].x, _S1552.p_0[int(1)].y}; + float _S1565 = _S1552.p_0[int(1)].z; + float2 uv0_9 = _S1564 / make_float2 (_S1565); + bool _S1566 = _S1565 < 0.0f; + if(_S1566) { + proj_points_0[int(1)] = uv0_9; + _S1541 = false; break; } - float u_33 = proj_points_0[int(1)].x; - float v_33 = proj_points_0[int(1)].y; - float r2_33 = u_33 * u_33 + v_33 * v_33; - float2 _S725 = proj_points_0[int(1)] * make_float2 (1.0f + r2_33 * (dist_coeffs_8[int(0)] + r2_33 * (dist_coeffs_8[int(1)] + r2_33 * (dist_coeffs_8[int(2)] + r2_33 * dist_coeffs_8[int(3)])))) + make_float2 (2.0f * dist_coeffs_8[int(4)] * u_33 * v_33 + dist_coeffs_8[int(5)] * (r2_33 + 2.0f * u_33 * u_33) + dist_coeffs_8[int(6)] * r2_33, 2.0f * dist_coeffs_8[int(5)] * u_33 * v_33 + dist_coeffs_8[int(4)] * (r2_33 + 2.0f * v_33 * v_33) + dist_coeffs_8[int(7)] * r2_33); - float2 _S726 = _S725 + make_float2 (dist_coeffs_8[int(8)] * _S725.x + dist_coeffs_8[int(9)] * _S725.y, 0.0f); - proj_points_0[int(1)] = make_float2 (fx_8 * _S726.x + cx_5, fy_8 * _S726.y + cy_5); + float2 uv_13 = _S1564 / make_float2 (_S1565); + FixedArray _S1567 = dist_coeffs_23; + float2 _S1568 = DistNone_distort_0(uv_13, &_S1567); + proj_points_0[int(1)] = make_float2 (fx_24 * _S1568.x + cx_15, fy_24 * _S1568.y + cy_15); + _S1541 = true; break; } - bool all_valid_1 = all_valid_0 & (!_S679); + bool all_valid_1 = all_valid_0 & _S1541; for(;;) { - _S670 = &proj_points_0[int(2)]; + _S1531 = &proj_points_0[int(2)]; for(;;) { - float _S727 = _S690.p_0[int(2)].z; - proj_points_0[int(2)] = float2 {_S690.p_0[int(2)].x, _S690.p_0[int(2)].y} / make_float2 (_S727); - if(_S727 < 0.0f) - { - _S679 = true; - } - else - { - float u_34 = proj_points_0[int(2)].x; - float v_34 = proj_points_0[int(2)].y; - float _S728 = u_34 + u_34; - float r2_34 = u_34 * u_34 + v_34 * v_34; - float _S729 = dist_coeffs_8[int(2)] + r2_34 * dist_coeffs_8[int(3)]; - float _S730 = dist_coeffs_8[int(1)] + r2_34 * _S729; - float _S731 = dist_coeffs_8[int(0)] + r2_34 * _S730; - float radial_8 = 1.0f + r2_34 * _S731; - float _S732 = 2.0f * dist_coeffs_8[int(4)]; - float _S733 = 2.0f * u_34; - float _S734 = 2.0f * dist_coeffs_8[int(5)]; - float _S735 = 2.0f * v_34; - float2 _S736 = make_float2 (1.0f, 0.0f) * make_float2 (radial_8) + make_float2 (_S728 * _S731 + (_S728 * _S730 + (_S728 * _S729 + _S728 * dist_coeffs_8[int(3)] * r2_34) * r2_34) * r2_34) * proj_points_0[int(2)] + make_float2 (_S732 * v_34 + (_S728 + (_S733 + _S733)) * dist_coeffs_8[int(5)] + _S728 * dist_coeffs_8[int(6)], _S734 * v_34 + _S728 * dist_coeffs_8[int(4)] + _S728 * dist_coeffs_8[int(7)]); - float _S737 = v_34 + v_34; - float2 _S738 = make_float2 (0.0f, 1.0f) * make_float2 (radial_8) + make_float2 (_S737 * _S731 + (_S737 * _S730 + (_S737 * _S729 + _S737 * dist_coeffs_8[int(3)] * r2_34) * r2_34) * r2_34) * proj_points_0[int(2)] + make_float2 (_S732 * u_34 + _S737 * dist_coeffs_8[int(5)] + _S737 * dist_coeffs_8[int(6)], _S734 * u_34 + (_S737 + (_S735 + _S735)) * dist_coeffs_8[int(4)] + _S737 * dist_coeffs_8[int(7)]); - Matrix _S739 = transpose_0(makeMatrix (_S736 + make_float2 (_S736.x * dist_coeffs_8[int(8)] + _S736.y * dist_coeffs_8[int(9)], 0.0f), _S738 + make_float2 (_S738.x * dist_coeffs_8[int(8)] + _S738.y * dist_coeffs_8[int(9)], 0.0f))); - _S679 = !((F32_min((determinant_0(_S739)), ((F32_min((_S739.rows[int(0)].x), (_S739.rows[int(1)].y)))))) > 0.0f); - } - if(_S679) + float2 _S1569 = float2 {_S1552.p_0[int(2)].x, _S1552.p_0[int(2)].y}; + float _S1570 = _S1552.p_0[int(2)].z; + float2 uv0_10 = _S1569 / make_float2 (_S1570); + bool _S1571 = _S1570 < 0.0f; + if(_S1571) { + proj_points_0[int(2)] = uv0_10; + _S1541 = false; break; } - float u_35 = proj_points_0[int(2)].x; - float v_35 = proj_points_0[int(2)].y; - float r2_35 = u_35 * u_35 + v_35 * v_35; - float2 _S740 = proj_points_0[int(2)] * make_float2 (1.0f + r2_35 * (dist_coeffs_8[int(0)] + r2_35 * (dist_coeffs_8[int(1)] + r2_35 * (dist_coeffs_8[int(2)] + r2_35 * dist_coeffs_8[int(3)])))) + make_float2 (2.0f * dist_coeffs_8[int(4)] * u_35 * v_35 + dist_coeffs_8[int(5)] * (r2_35 + 2.0f * u_35 * u_35) + dist_coeffs_8[int(6)] * r2_35, 2.0f * dist_coeffs_8[int(5)] * u_35 * v_35 + dist_coeffs_8[int(4)] * (r2_35 + 2.0f * v_35 * v_35) + dist_coeffs_8[int(7)] * r2_35); - float2 _S741 = _S740 + make_float2 (dist_coeffs_8[int(8)] * _S740.x + dist_coeffs_8[int(9)] * _S740.y, 0.0f); - proj_points_0[int(2)] = make_float2 (fx_8 * _S741.x + cx_5, fy_8 * _S741.y + cy_5); + float2 uv_14 = _S1569 / make_float2 (_S1570); + FixedArray _S1572 = dist_coeffs_23; + float2 _S1573 = DistNone_distort_0(uv_14, &_S1572); + proj_points_0[int(2)] = make_float2 (fx_24 * _S1573.x + cx_15, fy_24 * _S1573.y + cy_15); + _S1541 = true; break; } - _S671 = all_valid_1 & (!_S679); + _S1532 = all_valid_1 & _S1541; break; } - _S672 = &proj_points_0[int(3)]; + _S1533 = &proj_points_0[int(3)]; for(;;) { - float _S742 = _S690.p_0[int(3)].z; - proj_points_0[int(3)] = float2 {_S690.p_0[int(3)].x, _S690.p_0[int(3)].y} / make_float2 (_S742); - if(_S742 < 0.0f) - { - _S679 = true; - } - else - { - float u_36 = proj_points_0[int(3)].x; - float v_36 = proj_points_0[int(3)].y; - float _S743 = u_36 + u_36; - float r2_36 = u_36 * u_36 + v_36 * v_36; - float _S744 = dist_coeffs_8[int(2)] + r2_36 * dist_coeffs_8[int(3)]; - float _S745 = dist_coeffs_8[int(1)] + r2_36 * _S744; - float _S746 = dist_coeffs_8[int(0)] + r2_36 * _S745; - float radial_9 = 1.0f + r2_36 * _S746; - float _S747 = 2.0f * dist_coeffs_8[int(4)]; - float _S748 = 2.0f * u_36; - float _S749 = 2.0f * dist_coeffs_8[int(5)]; - float _S750 = 2.0f * v_36; - float2 _S751 = make_float2 (1.0f, 0.0f) * make_float2 (radial_9) + make_float2 (_S743 * _S746 + (_S743 * _S745 + (_S743 * _S744 + _S743 * dist_coeffs_8[int(3)] * r2_36) * r2_36) * r2_36) * proj_points_0[int(3)] + make_float2 (_S747 * v_36 + (_S743 + (_S748 + _S748)) * dist_coeffs_8[int(5)] + _S743 * dist_coeffs_8[int(6)], _S749 * v_36 + _S743 * dist_coeffs_8[int(4)] + _S743 * dist_coeffs_8[int(7)]); - float _S752 = v_36 + v_36; - float2 _S753 = make_float2 (0.0f, 1.0f) * make_float2 (radial_9) + make_float2 (_S752 * _S746 + (_S752 * _S745 + (_S752 * _S744 + _S752 * dist_coeffs_8[int(3)] * r2_36) * r2_36) * r2_36) * proj_points_0[int(3)] + make_float2 (_S747 * u_36 + _S752 * dist_coeffs_8[int(5)] + _S752 * dist_coeffs_8[int(6)], _S749 * u_36 + (_S752 + (_S750 + _S750)) * dist_coeffs_8[int(4)] + _S752 * dist_coeffs_8[int(7)]); - Matrix _S754 = transpose_0(makeMatrix (_S751 + make_float2 (_S751.x * dist_coeffs_8[int(8)] + _S751.y * dist_coeffs_8[int(9)], 0.0f), _S753 + make_float2 (_S753.x * dist_coeffs_8[int(8)] + _S753.y * dist_coeffs_8[int(9)], 0.0f))); - _S679 = !((F32_min((determinant_0(_S754)), ((F32_min((_S754.rows[int(0)].x), (_S754.rows[int(1)].y)))))) > 0.0f); - } - if(_S679) + float2 _S1574 = float2 {_S1552.p_0[int(3)].x, _S1552.p_0[int(3)].y}; + float _S1575 = _S1552.p_0[int(3)].z; + float2 uv0_11 = _S1574 / make_float2 (_S1575); + bool _S1576 = _S1575 < 0.0f; + if(_S1576) { + proj_points_0[int(3)] = uv0_11; + _S1541 = false; break; } - float u_37 = proj_points_0[int(3)].x; - float v_37 = proj_points_0[int(3)].y; - float r2_37 = u_37 * u_37 + v_37 * v_37; - float2 _S755 = proj_points_0[int(3)] * make_float2 (1.0f + r2_37 * (dist_coeffs_8[int(0)] + r2_37 * (dist_coeffs_8[int(1)] + r2_37 * (dist_coeffs_8[int(2)] + r2_37 * dist_coeffs_8[int(3)])))) + make_float2 (2.0f * dist_coeffs_8[int(4)] * u_37 * v_37 + dist_coeffs_8[int(5)] * (r2_37 + 2.0f * u_37 * u_37) + dist_coeffs_8[int(6)] * r2_37, 2.0f * dist_coeffs_8[int(5)] * u_37 * v_37 + dist_coeffs_8[int(4)] * (r2_37 + 2.0f * v_37 * v_37) + dist_coeffs_8[int(7)] * r2_37); - float2 _S756 = _S755 + make_float2 (dist_coeffs_8[int(8)] * _S755.x + dist_coeffs_8[int(9)] * _S755.y, 0.0f); - proj_points_0[int(3)] = make_float2 (fx_8 * _S756.x + cx_5, fy_8 * _S756.y + cy_5); + float2 uv_15 = _S1574 / make_float2 (_S1575); + FixedArray _S1577 = dist_coeffs_23; + float2 _S1578 = DistNone_distort_0(uv_15, &_S1577); + proj_points_0[int(3)] = make_float2 (fx_24 * _S1578.x + cx_15, fy_24 * _S1578.y + cy_15); + _S1541 = true; break; } - bool all_valid_2 = _S671 & (!_S679); - _S673 = &proj_points_0[int(4)]; + bool all_valid_2 = _S1532 & _S1541; + _S1534 = &proj_points_0[int(4)]; for(;;) { - float _S757 = _S690.p_0[int(4)].z; - proj_points_0[int(4)] = float2 {_S690.p_0[int(4)].x, _S690.p_0[int(4)].y} / make_float2 (_S757); - if(_S757 < 0.0f) - { - _S679 = true; - } - else - { - float u_38 = proj_points_0[int(4)].x; - float v_38 = proj_points_0[int(4)].y; - float _S758 = u_38 + u_38; - float r2_38 = u_38 * u_38 + v_38 * v_38; - float _S759 = dist_coeffs_8[int(2)] + r2_38 * dist_coeffs_8[int(3)]; - float _S760 = dist_coeffs_8[int(1)] + r2_38 * _S759; - float _S761 = dist_coeffs_8[int(0)] + r2_38 * _S760; - float radial_10 = 1.0f + r2_38 * _S761; - float _S762 = 2.0f * dist_coeffs_8[int(4)]; - float _S763 = 2.0f * u_38; - float _S764 = 2.0f * dist_coeffs_8[int(5)]; - float _S765 = 2.0f * v_38; - float2 _S766 = make_float2 (1.0f, 0.0f) * make_float2 (radial_10) + make_float2 (_S758 * _S761 + (_S758 * _S760 + (_S758 * _S759 + _S758 * dist_coeffs_8[int(3)] * r2_38) * r2_38) * r2_38) * proj_points_0[int(4)] + make_float2 (_S762 * v_38 + (_S758 + (_S763 + _S763)) * dist_coeffs_8[int(5)] + _S758 * dist_coeffs_8[int(6)], _S764 * v_38 + _S758 * dist_coeffs_8[int(4)] + _S758 * dist_coeffs_8[int(7)]); - float _S767 = v_38 + v_38; - float2 _S768 = make_float2 (0.0f, 1.0f) * make_float2 (radial_10) + make_float2 (_S767 * _S761 + (_S767 * _S760 + (_S767 * _S759 + _S767 * dist_coeffs_8[int(3)] * r2_38) * r2_38) * r2_38) * proj_points_0[int(4)] + make_float2 (_S762 * u_38 + _S767 * dist_coeffs_8[int(5)] + _S767 * dist_coeffs_8[int(6)], _S764 * u_38 + (_S767 + (_S765 + _S765)) * dist_coeffs_8[int(4)] + _S767 * dist_coeffs_8[int(7)]); - Matrix _S769 = transpose_0(makeMatrix (_S766 + make_float2 (_S766.x * dist_coeffs_8[int(8)] + _S766.y * dist_coeffs_8[int(9)], 0.0f), _S768 + make_float2 (_S768.x * dist_coeffs_8[int(8)] + _S768.y * dist_coeffs_8[int(9)], 0.0f))); - _S679 = !((F32_min((determinant_0(_S769)), ((F32_min((_S769.rows[int(0)].x), (_S769.rows[int(1)].y)))))) > 0.0f); - } - if(_S679) + float2 _S1579 = float2 {_S1552.p_0[int(4)].x, _S1552.p_0[int(4)].y}; + float _S1580 = _S1552.p_0[int(4)].z; + float2 uv0_12 = _S1579 / make_float2 (_S1580); + bool _S1581 = _S1580 < 0.0f; + if(_S1581) { + proj_points_0[int(4)] = uv0_12; + _S1541 = false; break; } - float u_39 = proj_points_0[int(4)].x; - float v_39 = proj_points_0[int(4)].y; - float r2_39 = u_39 * u_39 + v_39 * v_39; - float2 _S770 = proj_points_0[int(4)] * make_float2 (1.0f + r2_39 * (dist_coeffs_8[int(0)] + r2_39 * (dist_coeffs_8[int(1)] + r2_39 * (dist_coeffs_8[int(2)] + r2_39 * dist_coeffs_8[int(3)])))) + make_float2 (2.0f * dist_coeffs_8[int(4)] * u_39 * v_39 + dist_coeffs_8[int(5)] * (r2_39 + 2.0f * u_39 * u_39) + dist_coeffs_8[int(6)] * r2_39, 2.0f * dist_coeffs_8[int(5)] * u_39 * v_39 + dist_coeffs_8[int(4)] * (r2_39 + 2.0f * v_39 * v_39) + dist_coeffs_8[int(7)] * r2_39); - float2 _S771 = _S770 + make_float2 (dist_coeffs_8[int(8)] * _S770.x + dist_coeffs_8[int(9)] * _S770.y, 0.0f); - proj_points_0[int(4)] = make_float2 (fx_8 * _S771.x + cx_5, fy_8 * _S771.y + cy_5); + float2 uv_16 = _S1579 / make_float2 (_S1580); + FixedArray _S1582 = dist_coeffs_23; + float2 _S1583 = DistNone_distort_0(uv_16, &_S1582); + proj_points_0[int(4)] = make_float2 (fx_24 * _S1583.x + cx_15, fy_24 * _S1583.y + cy_15); + _S1541 = true; break; } - bool all_valid_3 = all_valid_2 & (!_S679); + bool all_valid_3 = all_valid_2 & _S1541; for(;;) { - _S674 = &proj_points_0[int(5)]; + _S1535 = &proj_points_0[int(5)]; for(;;) { - float _S772 = _S690.p_0[int(5)].z; - proj_points_0[int(5)] = float2 {_S690.p_0[int(5)].x, _S690.p_0[int(5)].y} / make_float2 (_S772); - if(_S772 < 0.0f) - { - _S679 = true; - } - else - { - float u_40 = proj_points_0[int(5)].x; - float v_40 = proj_points_0[int(5)].y; - float _S773 = u_40 + u_40; - float r2_40 = u_40 * u_40 + v_40 * v_40; - float _S774 = dist_coeffs_8[int(2)] + r2_40 * dist_coeffs_8[int(3)]; - float _S775 = dist_coeffs_8[int(1)] + r2_40 * _S774; - float _S776 = dist_coeffs_8[int(0)] + r2_40 * _S775; - float radial_11 = 1.0f + r2_40 * _S776; - float _S777 = 2.0f * dist_coeffs_8[int(4)]; - float _S778 = 2.0f * u_40; - float _S779 = 2.0f * dist_coeffs_8[int(5)]; - float _S780 = 2.0f * v_40; - float2 _S781 = make_float2 (1.0f, 0.0f) * make_float2 (radial_11) + make_float2 (_S773 * _S776 + (_S773 * _S775 + (_S773 * _S774 + _S773 * dist_coeffs_8[int(3)] * r2_40) * r2_40) * r2_40) * proj_points_0[int(5)] + make_float2 (_S777 * v_40 + (_S773 + (_S778 + _S778)) * dist_coeffs_8[int(5)] + _S773 * dist_coeffs_8[int(6)], _S779 * v_40 + _S773 * dist_coeffs_8[int(4)] + _S773 * dist_coeffs_8[int(7)]); - float _S782 = v_40 + v_40; - float2 _S783 = make_float2 (0.0f, 1.0f) * make_float2 (radial_11) + make_float2 (_S782 * _S776 + (_S782 * _S775 + (_S782 * _S774 + _S782 * dist_coeffs_8[int(3)] * r2_40) * r2_40) * r2_40) * proj_points_0[int(5)] + make_float2 (_S777 * u_40 + _S782 * dist_coeffs_8[int(5)] + _S782 * dist_coeffs_8[int(6)], _S779 * u_40 + (_S782 + (_S780 + _S780)) * dist_coeffs_8[int(4)] + _S782 * dist_coeffs_8[int(7)]); - Matrix _S784 = transpose_0(makeMatrix (_S781 + make_float2 (_S781.x * dist_coeffs_8[int(8)] + _S781.y * dist_coeffs_8[int(9)], 0.0f), _S783 + make_float2 (_S783.x * dist_coeffs_8[int(8)] + _S783.y * dist_coeffs_8[int(9)], 0.0f))); - _S679 = !((F32_min((determinant_0(_S784)), ((F32_min((_S784.rows[int(0)].x), (_S784.rows[int(1)].y)))))) > 0.0f); - } - if(_S679) + float2 _S1584 = float2 {_S1552.p_0[int(5)].x, _S1552.p_0[int(5)].y}; + float _S1585 = _S1552.p_0[int(5)].z; + float2 uv0_13 = _S1584 / make_float2 (_S1585); + bool _S1586 = _S1585 < 0.0f; + if(_S1586) { + proj_points_0[int(5)] = uv0_13; + _S1541 = false; break; } - float u_41 = proj_points_0[int(5)].x; - float v_41 = proj_points_0[int(5)].y; - float r2_41 = u_41 * u_41 + v_41 * v_41; - float2 _S785 = proj_points_0[int(5)] * make_float2 (1.0f + r2_41 * (dist_coeffs_8[int(0)] + r2_41 * (dist_coeffs_8[int(1)] + r2_41 * (dist_coeffs_8[int(2)] + r2_41 * dist_coeffs_8[int(3)])))) + make_float2 (2.0f * dist_coeffs_8[int(4)] * u_41 * v_41 + dist_coeffs_8[int(5)] * (r2_41 + 2.0f * u_41 * u_41) + dist_coeffs_8[int(6)] * r2_41, 2.0f * dist_coeffs_8[int(5)] * u_41 * v_41 + dist_coeffs_8[int(4)] * (r2_41 + 2.0f * v_41 * v_41) + dist_coeffs_8[int(7)] * r2_41); - float2 _S786 = _S785 + make_float2 (dist_coeffs_8[int(8)] * _S785.x + dist_coeffs_8[int(9)] * _S785.y, 0.0f); - proj_points_0[int(5)] = make_float2 (fx_8 * _S786.x + cx_5, fy_8 * _S786.y + cy_5); + float2 uv_17 = _S1584 / make_float2 (_S1585); + FixedArray _S1587 = dist_coeffs_23; + float2 _S1588 = DistNone_distort_0(uv_17, &_S1587); + proj_points_0[int(5)] = make_float2 (fx_24 * _S1588.x + cx_15, fy_24 * _S1588.y + cy_15); + _S1541 = true; break; } - _S675 = all_valid_3 & (!_S679); + _S1536 = all_valid_3 & _S1541; break; } - _S676 = &proj_points_0[int(6)]; + _S1537 = &proj_points_0[int(6)]; for(;;) { - float _S787 = _S690.p_0[int(6)].z; - proj_points_0[int(6)] = float2 {_S690.p_0[int(6)].x, _S690.p_0[int(6)].y} / make_float2 (_S787); - if(_S787 < 0.0f) - { - _S679 = true; - } - else - { - float u_42 = proj_points_0[int(6)].x; - float v_42 = proj_points_0[int(6)].y; - float _S788 = u_42 + u_42; - float r2_42 = u_42 * u_42 + v_42 * v_42; - float _S789 = dist_coeffs_8[int(2)] + r2_42 * dist_coeffs_8[int(3)]; - float _S790 = dist_coeffs_8[int(1)] + r2_42 * _S789; - float _S791 = dist_coeffs_8[int(0)] + r2_42 * _S790; - float radial_12 = 1.0f + r2_42 * _S791; - float _S792 = 2.0f * dist_coeffs_8[int(4)]; - float _S793 = 2.0f * u_42; - float _S794 = 2.0f * dist_coeffs_8[int(5)]; - float _S795 = 2.0f * v_42; - float2 _S796 = make_float2 (1.0f, 0.0f) * make_float2 (radial_12) + make_float2 (_S788 * _S791 + (_S788 * _S790 + (_S788 * _S789 + _S788 * dist_coeffs_8[int(3)] * r2_42) * r2_42) * r2_42) * proj_points_0[int(6)] + make_float2 (_S792 * v_42 + (_S788 + (_S793 + _S793)) * dist_coeffs_8[int(5)] + _S788 * dist_coeffs_8[int(6)], _S794 * v_42 + _S788 * dist_coeffs_8[int(4)] + _S788 * dist_coeffs_8[int(7)]); - float _S797 = v_42 + v_42; - float2 _S798 = make_float2 (0.0f, 1.0f) * make_float2 (radial_12) + make_float2 (_S797 * _S791 + (_S797 * _S790 + (_S797 * _S789 + _S797 * dist_coeffs_8[int(3)] * r2_42) * r2_42) * r2_42) * proj_points_0[int(6)] + make_float2 (_S792 * u_42 + _S797 * dist_coeffs_8[int(5)] + _S797 * dist_coeffs_8[int(6)], _S794 * u_42 + (_S797 + (_S795 + _S795)) * dist_coeffs_8[int(4)] + _S797 * dist_coeffs_8[int(7)]); - Matrix _S799 = transpose_0(makeMatrix (_S796 + make_float2 (_S796.x * dist_coeffs_8[int(8)] + _S796.y * dist_coeffs_8[int(9)], 0.0f), _S798 + make_float2 (_S798.x * dist_coeffs_8[int(8)] + _S798.y * dist_coeffs_8[int(9)], 0.0f))); - _S679 = !((F32_min((determinant_0(_S799)), ((F32_min((_S799.rows[int(0)].x), (_S799.rows[int(1)].y)))))) > 0.0f); - } - if(_S679) + float2 _S1589 = float2 {_S1552.p_0[int(6)].x, _S1552.p_0[int(6)].y}; + float _S1590 = _S1552.p_0[int(6)].z; + float2 uv0_14 = _S1589 / make_float2 (_S1590); + bool _S1591 = _S1590 < 0.0f; + if(_S1591) { + proj_points_0[int(6)] = uv0_14; + _S1541 = false; break; } - float u_43 = proj_points_0[int(6)].x; - float v_43 = proj_points_0[int(6)].y; - float r2_43 = u_43 * u_43 + v_43 * v_43; - float2 _S800 = proj_points_0[int(6)] * make_float2 (1.0f + r2_43 * (dist_coeffs_8[int(0)] + r2_43 * (dist_coeffs_8[int(1)] + r2_43 * (dist_coeffs_8[int(2)] + r2_43 * dist_coeffs_8[int(3)])))) + make_float2 (2.0f * dist_coeffs_8[int(4)] * u_43 * v_43 + dist_coeffs_8[int(5)] * (r2_43 + 2.0f * u_43 * u_43) + dist_coeffs_8[int(6)] * r2_43, 2.0f * dist_coeffs_8[int(5)] * u_43 * v_43 + dist_coeffs_8[int(4)] * (r2_43 + 2.0f * v_43 * v_43) + dist_coeffs_8[int(7)] * r2_43); - float2 _S801 = _S800 + make_float2 (dist_coeffs_8[int(8)] * _S800.x + dist_coeffs_8[int(9)] * _S800.y, 0.0f); - proj_points_0[int(6)] = make_float2 (fx_8 * _S801.x + cx_5, fy_8 * _S801.y + cy_5); + float2 uv_18 = _S1589 / make_float2 (_S1590); + FixedArray _S1592 = dist_coeffs_23; + float2 _S1593 = DistNone_distort_0(uv_18, &_S1592); + proj_points_0[int(6)] = make_float2 (fx_24 * _S1593.x + cx_15, fy_24 * _S1593.y + cy_15); + _S1541 = true; break; } - _S677 = _S675 & (!_S679); + _S1538 = _S1536 & _S1541; break; } - if(!_S677) + if(!_S1538) { - _S679 = false; + _S1541 = false; break; } - float2 _S802 = *mean2d_8 + make_float2 (_S690.w_mean_0[int(0)]) * *_S668 + make_float2 (_S690.w_mean_0[int(1)]) * *_S669 + make_float2 (_S690.w_mean_0[int(2)]) * *_S670 + make_float2 (_S690.w_mean_0[int(3)]) * *_S672 + make_float2 (_S690.w_mean_0[int(4)]) * *_S673 + make_float2 (_S690.w_mean_0[int(5)]) * *_S674 + make_float2 (_S690.w_mean_0[int(6)]) * *_S676; - *mean2d_8 = _S802; - float _S803 = - _S695; - float _S804 = - _S696; - float2 _S805 = make_float2 (clamp_0(_S802.x, _S803, lim_x_pos_2), clamp_0(_S802.y, _S804, lim_y_pos_0)); - float2 d_0 = make_float2 (clamp_0((*_S668).x, _S803, lim_x_pos_2), clamp_0((*_S668).y, _S804, lim_y_pos_0)) - _S805; - float _S806 = d_0.x; - float _S807 = d_0.y; - float _S808 = _S806 * _S807; - float2 d_1 = make_float2 (clamp_0((*_S669).x, _S803, lim_x_pos_2), clamp_0((*_S669).y, _S804, lim_y_pos_0)) - _S805; - float _S809 = d_1.x; - float _S810 = d_1.y; - float _S811 = _S809 * _S810; - float2 d_2 = make_float2 (clamp_0((*_S670).x, _S803, lim_x_pos_2), clamp_0((*_S670).y, _S804, lim_y_pos_0)) - _S805; - float _S812 = d_2.x; - float _S813 = d_2.y; - float _S814 = _S812 * _S813; - float2 d_3 = make_float2 (clamp_0((*_S672).x, _S803, lim_x_pos_2), clamp_0((*_S672).y, _S804, lim_y_pos_0)) - _S805; - float _S815 = d_3.x; - float _S816 = d_3.y; - float _S817 = _S815 * _S816; - float2 d_4 = make_float2 (clamp_0((*_S673).x, _S803, lim_x_pos_2), clamp_0((*_S673).y, _S804, lim_y_pos_0)) - _S805; - float _S818 = d_4.x; - float _S819 = d_4.y; - float _S820 = _S818 * _S819; - float2 d_5 = make_float2 (clamp_0((*_S674).x, _S803, lim_x_pos_2), clamp_0((*_S674).y, _S804, lim_y_pos_0)) - _S805; - float _S821 = d_5.x; - float _S822 = d_5.y; - float _S823 = _S821 * _S822; - float2 d_6 = make_float2 (clamp_0((*_S676).x, _S803, lim_x_pos_2), clamp_0((*_S676).y, _S804, lim_y_pos_0)) - _S805; - float _S824 = d_6.x; - float _S825 = d_6.y; - float _S826 = _S824 * _S825; - covar2d_4 = covar2d_4 + makeMatrix (_S690.w_cov_0[int(0)]) * makeMatrix (_S806 * _S806, _S808, _S808, _S807 * _S807) + makeMatrix (_S690.w_cov_0[int(1)]) * makeMatrix (_S809 * _S809, _S811, _S811, _S810 * _S810) + makeMatrix (_S690.w_cov_0[int(2)]) * makeMatrix (_S812 * _S812, _S814, _S814, _S813 * _S813) + makeMatrix (_S690.w_cov_0[int(3)]) * makeMatrix (_S815 * _S815, _S817, _S817, _S816 * _S816) + makeMatrix (_S690.w_cov_0[int(4)]) * makeMatrix (_S818 * _S818, _S820, _S820, _S819 * _S819) + makeMatrix (_S690.w_cov_0[int(5)]) * makeMatrix (_S821 * _S821, _S823, _S823, _S822 * _S822) + makeMatrix (_S690.w_cov_0[int(6)]) * makeMatrix (_S824 * _S824, _S826, _S826, _S825 * _S825); - _S679 = true; + float2 _S1594 = *mean2d_24 + make_float2 (_S1552.w_mean_0[int(0)]) * *_S1529 + make_float2 (_S1552.w_mean_0[int(1)]) * *_S1530 + make_float2 (_S1552.w_mean_0[int(2)]) * *_S1531 + make_float2 (_S1552.w_mean_0[int(3)]) * *_S1533 + make_float2 (_S1552.w_mean_0[int(4)]) * *_S1534 + make_float2 (_S1552.w_mean_0[int(5)]) * *_S1535 + make_float2 (_S1552.w_mean_0[int(6)]) * *_S1537; + *mean2d_24 = _S1594; + float _S1595 = - _S1557; + float _S1596 = - _S1558; + float2 _S1597 = make_float2 (clamp_0(_S1594.x, _S1595, lim_x_pos_8), clamp_0(_S1594.y, _S1596, lim_y_pos_0)); + float2 d_0 = make_float2 (clamp_0((*_S1529).x, _S1595, lim_x_pos_8), clamp_0((*_S1529).y, _S1596, lim_y_pos_0)) - _S1597; + float _S1598 = d_0.x; + float _S1599 = d_0.y; + float _S1600 = _S1598 * _S1599; + float2 d_1 = make_float2 (clamp_0((*_S1530).x, _S1595, lim_x_pos_8), clamp_0((*_S1530).y, _S1596, lim_y_pos_0)) - _S1597; + float _S1601 = d_1.x; + float _S1602 = d_1.y; + float _S1603 = _S1601 * _S1602; + float2 d_2 = make_float2 (clamp_0((*_S1531).x, _S1595, lim_x_pos_8), clamp_0((*_S1531).y, _S1596, lim_y_pos_0)) - _S1597; + float _S1604 = d_2.x; + float _S1605 = d_2.y; + float _S1606 = _S1604 * _S1605; + float2 d_3 = make_float2 (clamp_0((*_S1533).x, _S1595, lim_x_pos_8), clamp_0((*_S1533).y, _S1596, lim_y_pos_0)) - _S1597; + float _S1607 = d_3.x; + float _S1608 = d_3.y; + float _S1609 = _S1607 * _S1608; + float2 d_4 = make_float2 (clamp_0((*_S1534).x, _S1595, lim_x_pos_8), clamp_0((*_S1534).y, _S1596, lim_y_pos_0)) - _S1597; + float _S1610 = d_4.x; + float _S1611 = d_4.y; + float _S1612 = _S1610 * _S1611; + float2 d_5 = make_float2 (clamp_0((*_S1535).x, _S1595, lim_x_pos_8), clamp_0((*_S1535).y, _S1596, lim_y_pos_0)) - _S1597; + float _S1613 = d_5.x; + float _S1614 = d_5.y; + float _S1615 = _S1613 * _S1614; + float2 d_6 = make_float2 (clamp_0((*_S1537).x, _S1595, lim_x_pos_8), clamp_0((*_S1537).y, _S1596, lim_y_pos_0)) - _S1597; + float _S1616 = d_6.x; + float _S1617 = d_6.y; + float _S1618 = _S1616 * _S1617; + covar2d_11 = covar2d_11 + makeMatrix (_S1552.w_cov_0[int(0)]) * makeMatrix (_S1598 * _S1598, _S1600, _S1600, _S1599 * _S1599) + makeMatrix (_S1552.w_cov_0[int(1)]) * makeMatrix (_S1601 * _S1601, _S1603, _S1603, _S1602 * _S1602) + makeMatrix (_S1552.w_cov_0[int(2)]) * makeMatrix (_S1604 * _S1604, _S1606, _S1606, _S1605 * _S1605) + makeMatrix (_S1552.w_cov_0[int(3)]) * makeMatrix (_S1607 * _S1607, _S1609, _S1609, _S1608 * _S1608) + makeMatrix (_S1552.w_cov_0[int(4)]) * makeMatrix (_S1610 * _S1610, _S1612, _S1612, _S1611 * _S1611) + makeMatrix (_S1552.w_cov_0[int(5)]) * makeMatrix (_S1613 * _S1613, _S1615, _S1615, _S1614 * _S1614) + makeMatrix (_S1552.w_cov_0[int(6)]) * makeMatrix (_S1616 * _S1616, _S1618, _S1618, _S1617 * _S1617); + _S1541 = true; break; } - if(!(true & _S679)) + if(!(true & _S1541)) { - *aabb_xyxy_4 = make_float4 (0.0f); + *aabb_xyxy_11 = _S1539; break; } - float eps2d_4; - if(antialiased_4) + float eps2d_11; + if(antialiased_11) { - eps2d_4 = 0.10000000149011612f; + eps2d_11 = 0.10000000149011612f; } else { - eps2d_4 = 0.30000001192092896f; + eps2d_11 = 0.30000001192092896f; } - float det_orig_4 = *&(((&covar2d_4)->rows + (int(0)))->x) * *&(((&covar2d_4)->rows + (int(1)))->y) - *&(((&covar2d_4)->rows + (int(0)))->y) * *&(((&covar2d_4)->rows + (int(1)))->x); - float _S827 = *&(((&covar2d_4)->rows + (int(0)))->x) + eps2d_4; - *&(((&covar2d_4)->rows + (int(0)))->x) = _S827; - float _S828 = *&(((&covar2d_4)->rows + (int(1)))->y) + eps2d_4; - *&(((&covar2d_4)->rows + (int(1)))->y) = _S828; - float det_blur_4 = _S827 * _S828 - *&(((&covar2d_4)->rows + (int(0)))->y) * *&(((&covar2d_4)->rows + (int(1)))->x); - float compensation_4 = (F32_sqrt(((F32_max((0.0f), (det_orig_4 / det_blur_4)))))); - if(det_blur_4 <= 0.0f) + float det_orig_11 = *&(((&covar2d_11)->rows + (int(0)))->x) * *&(((&covar2d_11)->rows + (int(1)))->y) - *&(((&covar2d_11)->rows + (int(0)))->y) * *&(((&covar2d_11)->rows + (int(1)))->x); + float _S1619 = *&(((&covar2d_11)->rows + (int(0)))->x) + eps2d_11; + *&(((&covar2d_11)->rows + (int(0)))->x) = _S1619; + float _S1620 = *&(((&covar2d_11)->rows + (int(1)))->y) + eps2d_11; + *&(((&covar2d_11)->rows + (int(1)))->y) = _S1620; + float det_blur_11 = _S1619 * _S1620 - *&(((&covar2d_11)->rows + (int(0)))->y) * *&(((&covar2d_11)->rows + (int(1)))->x); + float compensation_11 = (F32_sqrt(((F32_max((0.0f), (det_orig_11 / det_blur_11)))))); + if(det_blur_11 <= 0.0f) { - *aabb_xyxy_4 = make_float4 (0.0f); + *aabb_xyxy_11 = _S1539; break; } - float invdet_6 = 1.0f / (covar2d_4.rows[int(0)].x * covar2d_4.rows[int(1)].y - covar2d_4.rows[int(0)].y * covar2d_4.rows[int(1)].x); - Matrix _S829 = makeMatrix (covar2d_4.rows[int(1)].y * invdet_6, - covar2d_4.rows[int(0)].y * invdet_6, - covar2d_4.rows[int(1)].x * invdet_6, covar2d_4.rows[int(0)].x * invdet_6); - if(antialiased_4) + float invdet_17 = 1.0f / (covar2d_11.rows[int(0)].x * covar2d_11.rows[int(1)].y - covar2d_11.rows[int(0)].y * covar2d_11.rows[int(1)].x); + Matrix _S1621 = makeMatrix (covar2d_11.rows[int(1)].y * invdet_17, - covar2d_11.rows[int(0)].y * invdet_17, - covar2d_11.rows[int(1)].x * invdet_17, covar2d_11.rows[int(0)].x * invdet_17); + if(antialiased_11) { - *opacity_4 = *opacity_4 * compensation_4; + *opacity_11 = *opacity_11 * compensation_11; } - if((*opacity_4) < 0.00392156885936856f) + if((*opacity_11) < 0.00392156885936856f) { - *aabb_xyxy_4 = make_float4 (0.0f); + *aabb_xyxy_11 = _S1539; break; } - float _S830 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_4 / 0.00392156885936856f))))))))); - float radius_x_4 = _S830 * (F32_sqrt((covar2d_4[int(0)].x))); - float radius_y_4 = _S830 * (F32_sqrt((covar2d_4[int(1)].y))); - float _S831 = (*mean2d_8).x - radius_x_4; - float _S832 = (*mean2d_8).x + radius_x_4; - float _S833 = (*mean2d_8).y - radius_y_4; - float _S834 = (*mean2d_8).y + radius_y_4; - if(_S832 <= 0.0f) + float _S1622 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_11 / 0.00392156885936856f))))))))); + float radius_x_11 = _S1622 * (F32_sqrt((covar2d_11[int(0)].x))); + float radius_y_11 = _S1622 * (F32_sqrt((covar2d_11[int(1)].y))); + float _S1623 = (*mean2d_24).x - radius_x_11; + float _S1624 = (*mean2d_24).x + radius_x_11; + float _S1625 = (*mean2d_24).y - radius_y_11; + float _S1626 = (*mean2d_24).y + radius_y_11; + if(_S1624 <= 0.0f) { - _S679 = true; + _S1541 = true; } else { - _S679 = _S831 >= _S666; + _S1541 = _S1623 >= _S1527; } - if(_S679) + if(_S1541) { - _S679 = true; + _S1541 = true; } else { - _S679 = _S834 <= 0.0f; + _S1541 = _S1626 <= 0.0f; } - if(_S679) + if(_S1541) { - _S679 = true; + _S1541 = true; } else { - _S679 = _S833 >= _S667; + _S1541 = _S1625 >= _S1528; } - if(_S679) + if(_S1541) { - *aabb_xyxy_4 = make_float4 (0.0f); + *aabb_xyxy_11 = _S1539; break; } - *aabb_xyxy_4 = make_float4 (_S831, _S833, _S832, _S834); - *sorting_depth_4 = _S678; - *conic_4 = make_float3 (_S829.rows[int(0)].x, _S829.rows[int(0)].y, _S829.rows[int(1)].y); - *radius_5 = view_radius_3dgs_0(mean_5, scale_4, in_opacity_4, - mul_6(transpose_3(R_4), t_4)); + *aabb_xyxy_11 = make_float4 (_S1623, _S1625, _S1624, _S1626); + *sorting_depth_11 = _S1540; + *conic_11 = make_float3 (_S1621.rows[int(0)].x, _S1621.rows[int(0)].y, _S1621.rows[int(1)].y); + *radius_12 = view_radius_3dgs_0(mean_12, scale_11, in_opacity_11, - mul_6(transpose_3(R_11), t_11)); break; } return; } -inline __device__ void projection_3dgut_fisheye(bool antialiased_5, float3 mean_6, float4 quat_5, float3 scale_5, float in_opacity_5, Matrix R_5, float3 t_5, float fx_9, float fy_9, float cx_6, float cy_6, FixedArray dist_coeffs_9, uint image_width_5, uint image_height_5, float4 * aabb_xyxy_5, float * sorting_depth_5, float * radius_6, float2 * mean2d_9, float * depth_5, float3 * conic_5, float * opacity_5) +inline __device__ void projection_3dgut_persp_opencv(bool antialiased_12, float3 mean_13, float4 quat_12, float3 scale_12, float in_opacity_12, Matrix R_12, float3 t_12, float fx_25, float fy_25, float cx_16, float cy_16, FixedArray dist_coeffs_24, uint image_width_12, uint image_height_12, float4 * aabb_xyxy_12, float * sorting_depth_12, float * radius_13, float2 * mean2d_25, float * depth_12, float3 * conic_12, float * opacity_12) { - float2 * _S835; - float _S836; - float2 _S837; - float _S838; - float _S839; - float _S840; - float _S841; - float _S842; - float _S843; - float _S844; - float _S845; - float _S846; - float _S847; - float _S848; - float _S849; - float2 _S850; - bool _S851; - float2 * _S852; - float _S853; - bool _S854; - float2 * _S855; - float _S856; - bool _S857; - bool _S858; - float2 * _S859; - float _S860; - bool _S861; - float2 * _S862; - float _S863; - bool _S864; - float2 * _S865; - float _S866; - bool _S867; - bool _S868; - float2 * _S869; - float _S870; - bool _S871; - bool _S872; + float _S1627; + float _S1628; + float2 * _S1629; + float2 * _S1630; + float2 * _S1631; + bool _S1632; + float2 * _S1633; + float2 * _S1634; + float2 * _S1635; + bool _S1636; + float2 * _S1637; + bool _S1638; for(;;) { - float3 mean_c_5 = mul_6(R_5, mean_6) + t_5; - float _S873 = length_1(mean_c_5); - *depth_5 = _S873; - if(_S873 <= 0.0f) + float4 _S1639 = make_float4 (0.0f); + *aabb_xyxy_12 = _S1639; + *sorting_depth_12 = 0.0f; + *radius_13 = 0.0f; + *mean2d_25 = make_float2 (0.0f); + *conic_12 = make_float3 (0.0f); + *opacity_12 = 0.0f; + float3 mean_c_12 = mul_6(R_12, mean_13) + t_12; + float _S1640 = mean_c_12.z; + *depth_12 = length_1(mean_c_12); + if(_S1640 <= 0.0f) { - *aabb_xyxy_5 = make_float4 (0.0f); + *aabb_xyxy_12 = _S1639; break; } - Matrix covar2d_5; - *opacity_5 = 1.0f / (1.0f + (F32_exp((- in_opacity_5)))); - bool _S874; - float3 _S875 = exp_0(scale_5); - float4 _S876 = normalize_0(quat_5); - float x_22 = _S876.y; - float x2_5 = x_22 * x_22; - float y2_5 = _S876.z * _S876.z; - float z2_5 = _S876.w * _S876.w; - float xy_5 = _S876.y * _S876.z; - float xz_5 = _S876.y * _S876.w; - float yz_5 = _S876.z * _S876.w; - float wx_5 = _S876.x * _S876.y; - float wy_5 = _S876.x * _S876.z; - float wz_5 = _S876.x * _S876.w; - Matrix _S877 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_5 + z2_5), 2.0f * (xy_5 + wz_5), 2.0f * (xz_5 - wy_5), 2.0f * (xy_5 - wz_5), 1.0f - 2.0f * (x2_5 + z2_5), 2.0f * (yz_5 + wx_5), 2.0f * (xz_5 + wy_5), 2.0f * (yz_5 - wx_5), 1.0f - 2.0f * (x2_5 + y2_5)))); + Matrix covar2d_12; + *opacity_12 = 1.0f / (1.0f + (F32_exp((- in_opacity_12)))); + bool _S1641; + float3 _S1642 = exp_0(scale_12); + float4 _S1643 = normalize_0(quat_12); + float x_33 = _S1643.y; + float x2_12 = x_33 * x_33; + float y2_12 = _S1643.z * _S1643.z; + float z2_12 = _S1643.w * _S1643.w; + float xy_12 = _S1643.y * _S1643.z; + float xz_12 = _S1643.y * _S1643.w; + float yz_12 = _S1643.z * _S1643.w; + float wx_12 = _S1643.x * _S1643.y; + float wy_12 = _S1643.x * _S1643.z; + float wz_12 = _S1643.x * _S1643.w; + Matrix _S1644 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_12 + z2_12), 2.0f * (xy_12 + wz_12), 2.0f * (xz_12 - wy_12), 2.0f * (xy_12 - wz_12), 1.0f - 2.0f * (x2_12 + z2_12), 2.0f * (yz_12 + wx_12), 2.0f * (xz_12 + wy_12), 2.0f * (yz_12 - wx_12), 1.0f - 2.0f * (x2_12 + y2_12)))); SigmaPoints_0 ret_1; - (&ret_1)->p_0[int(0)] = mean_6; + (&ret_1)->p_0[int(0)] = mean_13; (&ret_1)->w_mean_0[int(0)] = 0.0f; (&ret_1)->w_cov_0[int(0)] = 2.0f; - float _S878 = (F32_sqrt((3.0f))); - float3 delta_3 = make_float3 (_S878 * _S875.x) * _S877.rows[0U]; - float3 _S879 = mean_6 + delta_3; - float3 _S880 = mean_6 - delta_3; - float3 delta_4 = make_float3 (_S878 * _S875.y) * _S877.rows[1U]; - float3 _S881 = mean_6 + delta_4; - float3 _S882 = mean_6 - delta_4; - float3 delta_5 = make_float3 (_S878 * _S875.z) * _S877.rows[2U]; - float3 _S883 = mean_6 + delta_5; - float3 _S884 = mean_6 - delta_5; + float _S1645 = (F32_sqrt((3.0f))); + float3 delta_3 = make_float3 (_S1645 * _S1642.x) * _S1644.rows[0U]; + float3 _S1646 = mean_13 + delta_3; + float3 _S1647 = mean_13 - delta_3; + float3 delta_4 = make_float3 (_S1645 * _S1642.y) * _S1644.rows[1U]; + float3 _S1648 = mean_13 + delta_4; + float3 _S1649 = mean_13 - delta_4; + float3 delta_5 = make_float3 (_S1645 * _S1642.z) * _S1644.rows[2U]; + float3 _S1650 = mean_13 + delta_5; + float3 _S1651 = mean_13 - delta_5; (&ret_1)->w_mean_0[1U] = 0.1666666716337204f; (&ret_1)->w_cov_0[1U] = 0.1666666716337204f; (&ret_1)->w_mean_0[2U] = 0.1666666716337204f; @@ -3451,621 +6648,647 @@ inline __device__ void projection_3dgut_fisheye(bool antialiased_5, float3 mean (&ret_1)->w_cov_0[5U] = 0.1666666716337204f; (&ret_1)->w_mean_0[6U] = 0.1666666716337204f; (&ret_1)->w_cov_0[6U] = 0.1666666716337204f; - (&ret_1)->p_0[0U] = mul_6(R_5, (&ret_1)->p_0[0U]) + t_5; - (&ret_1)->p_0[1U] = mul_6(R_5, _S879) + t_5; - (&ret_1)->p_0[2U] = mul_6(R_5, _S881) + t_5; - (&ret_1)->p_0[3U] = mul_6(R_5, _S883) + t_5; - (&ret_1)->p_0[4U] = mul_6(R_5, _S880) + t_5; - (&ret_1)->p_0[5U] = mul_6(R_5, _S882) + t_5; - (&ret_1)->p_0[6U] = mul_6(R_5, _S884) + t_5; - SigmaPoints_0 _S885 = ret_1; + (&ret_1)->p_0[0U] = mul_6(R_12, (&ret_1)->p_0[0U]) + t_12; + (&ret_1)->p_0[1U] = mul_6(R_12, _S1646) + t_12; + (&ret_1)->p_0[2U] = mul_6(R_12, _S1648) + t_12; + (&ret_1)->p_0[3U] = mul_6(R_12, _S1650) + t_12; + (&ret_1)->p_0[4U] = mul_6(R_12, _S1647) + t_12; + (&ret_1)->p_0[5U] = mul_6(R_12, _S1649) + t_12; + (&ret_1)->p_0[6U] = mul_6(R_12, _S1651) + t_12; + SigmaPoints_0 _S1652 = ret_1; for(;;) { - int2 _S886 = make_int2 (int(0)); - float2 _S887 = make_float2 ((float)_S886.x, (float)_S886.y); - *mean2d_9 = _S887; - covar2d_5 = makeMatrix (0.0f); + int2 _S1653 = make_int2 (int(0)); + float2 _S1654 = make_float2 ((float)_S1653.x, (float)_S1653.y); + *mean2d_25 = _S1654; + covar2d_12 = makeMatrix (0.0f); + float _S1655 = float(image_width_12); + _S1627 = _S1655; + float tan_fovx_1 = 0.5f * _S1655 / fx_25; + float _S1656 = float(image_height_12); + _S1628 = _S1656; + float _S1657 = 0.30000001192092896f * tan_fovx_1 * fx_25; + float lim_x_pos_9 = _S1655 + _S1657; + float _S1658 = 0.30000001192092896f * (0.5f * _S1656 / fy_25) * fy_25; + float lim_y_pos_1 = _S1656 + _S1658; FixedArray proj_points_1; for(;;) { - float k_4; - _S835 = &proj_points_1[int(0)]; + _S1629 = &proj_points_1[int(0)]; for(;;) { - float2 _S888 = float2 {_S885.p_0[int(0)].x, _S885.p_0[int(0)].y}; - float r_11 = length_0(_S888); - float _S889 = _S885.p_0[int(0)].z; - _S836 = _S889; - float theta_4 = (F32_atan2((r_11), (_S889))); - if(theta_4 < 0.00100000004749745f) + float2 _S1659 = float2 {_S1652.p_0[int(0)].x, _S1652.p_0[int(0)].y}; + float _S1660 = _S1652.p_0[int(0)].z; + float2 uv0_15 = _S1659 / make_float2 (_S1660); + if(_S1660 < 0.0f) { - k_4 = (1.0f - theta_4 * theta_4 / 3.0f) / _S889; + _S1641 = true; } else { - k_4 = theta_4 / r_11; - } - float2 _S890 = _S888 * make_float2 (k_4); - proj_points_1[int(0)] = _S890; - float2 _S891 = make_float2 (1.0f, 0.0f); - _S837 = _S891; - _S838 = dist_coeffs_9[int(0)]; - _S839 = dist_coeffs_9[int(1)]; - _S840 = dist_coeffs_9[int(2)]; - _S841 = dist_coeffs_9[int(3)]; - _S842 = dist_coeffs_9[int(4)]; - _S843 = dist_coeffs_9[int(5)]; - _S844 = dist_coeffs_9[int(6)]; - _S845 = dist_coeffs_9[int(7)]; - _S846 = dist_coeffs_9[int(8)]; - _S847 = dist_coeffs_9[int(9)]; - float u_44 = _S890.x; - float v_44 = _S890.y; - float _S892 = u_44 + u_44; - float r2_44 = u_44 * u_44 + v_44 * v_44; - float _S893 = dist_coeffs_9[int(2)] + r2_44 * dist_coeffs_9[int(3)]; - float _S894 = dist_coeffs_9[int(1)] + r2_44 * _S893; - float _S895 = dist_coeffs_9[int(0)] + r2_44 * _S894; - float _S896 = _S892 * _S895 + (_S892 * _S894 + (_S892 * _S893 + _S892 * dist_coeffs_9[int(3)] * r2_44) * r2_44) * r2_44; - float radial_13 = 1.0f + r2_44 * _S895; - float _S897 = 2.0f * dist_coeffs_9[int(4)]; - _S848 = _S897; - float _S898 = _S897 * u_44; - float _S899 = 2.0f * u_44; - float s_diff_du_4 = _S897 * v_44 + (_S892 + (_S899 + _S899)) * dist_coeffs_9[int(5)] + _S892 * dist_coeffs_9[int(6)]; - float _S900 = 2.0f * dist_coeffs_9[int(5)]; - _S849 = _S900; - float _S901 = _S900 * u_44; - float _S902 = 2.0f * v_44; - float2 _S903 = _S891 * make_float2 (radial_13) + make_float2 (_S896) * _S890 + make_float2 (s_diff_du_4, _S900 * v_44 + _S892 * dist_coeffs_9[int(4)] + _S892 * dist_coeffs_9[int(7)]); - float2 _S904 = _S903 + make_float2 (_S903.x * dist_coeffs_9[int(8)] + _S903.y * dist_coeffs_9[int(9)], 0.0f); - float2 _S905 = make_float2 (0.0f, 1.0f); - _S850 = _S905; - float _S906 = v_44 + v_44; - float2 _S907 = _S905 * make_float2 (radial_13) + make_float2 (_S906 * _S895 + (_S906 * _S894 + (_S906 * _S893 + _S906 * dist_coeffs_9[int(3)] * r2_44) * r2_44) * r2_44) * _S890 + make_float2 (_S898 + _S906 * dist_coeffs_9[int(5)] + _S906 * dist_coeffs_9[int(6)], _S901 + (_S906 + (_S902 + _S902)) * dist_coeffs_9[int(4)] + _S906 * dist_coeffs_9[int(7)]); - Matrix _S908 = transpose_0(makeMatrix (_S904, _S907 + make_float2 (_S907.x * dist_coeffs_9[int(8)] + _S907.y * dist_coeffs_9[int(9)], 0.0f))); - bool _S909 = !((F32_min((determinant_0(_S908)), ((F32_min((_S908.rows[int(0)].x), (_S908.rows[int(1)].y)))))) > 0.0f); - _S851 = _S909; - if(_S909) - { - break; - } - float u_45 = proj_points_1[int(0)].x; - float v_45 = proj_points_1[int(0)].y; - float r2_45 = u_45 * u_45 + v_45 * v_45; - float2 _S910 = proj_points_1[int(0)] * make_float2 (1.0f + r2_45 * (dist_coeffs_9[int(0)] + r2_45 * (dist_coeffs_9[int(1)] + r2_45 * (dist_coeffs_9[int(2)] + r2_45 * dist_coeffs_9[int(3)])))) + make_float2 (_S897 * u_45 * v_45 + dist_coeffs_9[int(5)] * (r2_45 + 2.0f * u_45 * u_45) + dist_coeffs_9[int(6)] * r2_45, _S900 * u_45 * v_45 + dist_coeffs_9[int(4)] * (r2_45 + 2.0f * v_45 * v_45) + dist_coeffs_9[int(7)] * r2_45); - float2 _S911 = _S910 + make_float2 (dist_coeffs_9[int(8)] * _S910.x + dist_coeffs_9[int(9)] * _S910.y, 0.0f); - proj_points_1[int(0)] = make_float2 (fx_9 * _S911.x + cx_6, fy_9 * _S911.y + cy_6); - break; - } - bool all_valid_4 = true & (!_S851); - _S852 = &proj_points_1[int(1)]; - for(;;) - { - float2 _S912 = float2 {_S885.p_0[int(1)].x, _S885.p_0[int(1)].y}; - float r_12 = length_0(_S912); - float _S913 = _S885.p_0[int(1)].z; - _S853 = _S913; - float theta_5 = (F32_atan2((r_12), (_S913))); - if(theta_5 < 0.00100000004749745f) - { - k_4 = (1.0f - theta_5 * theta_5 / 3.0f) / _S913; - } - else - { - k_4 = theta_5 / r_12; - } - float2 _S914 = _S912 * make_float2 (k_4); - proj_points_1[int(1)] = _S914; - float u_46 = _S914.x; - float v_46 = _S914.y; - float _S915 = u_46 + u_46; - float r2_46 = u_46 * u_46 + v_46 * v_46; - float _S916 = _S840 + r2_46 * _S841; - float _S917 = _S839 + r2_46 * _S916; - float _S918 = _S838 + r2_46 * _S917; - float radial_14 = 1.0f + r2_46 * _S918; - float _S919 = 2.0f * u_46; - float _S920 = 2.0f * v_46; - float2 _S921 = _S837 * make_float2 (radial_14) + make_float2 (_S915 * _S918 + (_S915 * _S917 + (_S915 * _S916 + _S915 * _S841 * r2_46) * r2_46) * r2_46) * _S914 + make_float2 (_S848 * v_46 + (_S915 + (_S919 + _S919)) * _S843 + _S915 * _S844, _S849 * v_46 + _S915 * _S842 + _S915 * _S845); - float _S922 = v_46 + v_46; - float2 _S923 = _S850 * make_float2 (radial_14) + make_float2 (_S922 * _S918 + (_S922 * _S917 + (_S922 * _S916 + _S922 * _S841 * r2_46) * r2_46) * r2_46) * _S914 + make_float2 (_S848 * u_46 + _S922 * _S843 + _S922 * _S844, _S849 * u_46 + (_S922 + (_S920 + _S920)) * _S842 + _S922 * _S845); - Matrix _S924 = transpose_0(makeMatrix (_S921 + make_float2 (_S921.x * _S846 + _S921.y * _S847, 0.0f), _S923 + make_float2 (_S923.x * _S846 + _S923.y * _S847, 0.0f))); - bool _S925 = !((F32_min((determinant_0(_S924)), ((F32_min((_S924.rows[int(0)].x), (_S924.rows[int(1)].y)))))) > 0.0f); - _S854 = _S925; - if(_S925) - { - break; - } - float u_47 = proj_points_1[int(1)].x; - float v_47 = proj_points_1[int(1)].y; - float r2_47 = u_47 * u_47 + v_47 * v_47; - float2 _S926 = proj_points_1[int(1)] * make_float2 (1.0f + r2_47 * (_S838 + r2_47 * (_S839 + r2_47 * (_S840 + r2_47 * _S841)))) + make_float2 (_S848 * u_47 * v_47 + _S843 * (r2_47 + 2.0f * u_47 * u_47) + _S844 * r2_47, _S849 * u_47 * v_47 + _S842 * (r2_47 + 2.0f * v_47 * v_47) + _S845 * r2_47); - float2 _S927 = _S926 + make_float2 (_S846 * _S926.x + _S847 * _S926.y, 0.0f); - proj_points_1[int(1)] = make_float2 (fx_9 * _S927.x + cx_6, fy_9 * _S927.y + cy_6); - break; - } - bool all_valid_5 = all_valid_4 & (!_S854); - for(;;) - { - _S855 = &proj_points_1[int(2)]; - for(;;) - { - float2 _S928 = float2 {_S885.p_0[int(2)].x, _S885.p_0[int(2)].y}; - float r_13 = length_0(_S928); - float _S929 = _S885.p_0[int(2)].z; - _S856 = _S929; - float theta_6 = (F32_atan2((r_13), (_S929))); - if(theta_6 < 0.00100000004749745f) + float2 _S1661 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1662; + (&_S1662)->primal_0 = uv0_15; + (&_S1662)->differential_0 = _S1661; + FixedArray _S1663 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1664 = s_fwd_DistOpenCV_distort_0(&_S1662, &_S1663); + float2 _S1665 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1666; + (&_S1666)->primal_0 = uv0_15; + (&_S1666)->differential_0 = _S1665; + FixedArray _S1667 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1668 = s_fwd_DistOpenCV_distort_0(&_S1666, &_S1667); + Matrix _S1669 = transpose_0(makeMatrix (_S1664.differential_0, _S1668.differential_0)); + float _S1670 = (F32_min((determinant_0(_S1669)), ((F32_min((_S1669.rows[int(0)].x), (_S1669.rows[int(1)].y)))))); + if(_S1670 > 0.25f) { - k_4 = (1.0f - theta_6 * theta_6 / 3.0f) / _S929; + _S1641 = _S1670 < 4.0f; } else { - k_4 = theta_6 / r_13; + _S1641 = false; } - float2 _S930 = _S928 * make_float2 (k_4); - proj_points_1[int(2)] = _S930; - float u_48 = _S930.x; - float v_48 = _S930.y; - float _S931 = u_48 + u_48; - float r2_48 = u_48 * u_48 + v_48 * v_48; - float _S932 = _S840 + r2_48 * _S841; - float _S933 = _S839 + r2_48 * _S932; - float _S934 = _S838 + r2_48 * _S933; - float radial_15 = 1.0f + r2_48 * _S934; - float _S935 = 2.0f * u_48; - float _S936 = 2.0f * v_48; - float2 _S937 = _S837 * make_float2 (radial_15) + make_float2 (_S931 * _S934 + (_S931 * _S933 + (_S931 * _S932 + _S931 * _S841 * r2_48) * r2_48) * r2_48) * _S930 + make_float2 (_S848 * v_48 + (_S931 + (_S935 + _S935)) * _S843 + _S931 * _S844, _S849 * v_48 + _S931 * _S842 + _S931 * _S845); - float _S938 = v_48 + v_48; - float2 _S939 = _S850 * make_float2 (radial_15) + make_float2 (_S938 * _S934 + (_S938 * _S933 + (_S938 * _S932 + _S938 * _S841 * r2_48) * r2_48) * r2_48) * _S930 + make_float2 (_S848 * u_48 + _S938 * _S843 + _S938 * _S844, _S849 * u_48 + (_S938 + (_S936 + _S936)) * _S842 + _S938 * _S845); - Matrix _S940 = transpose_0(makeMatrix (_S937 + make_float2 (_S937.x * _S846 + _S937.y * _S847, 0.0f), _S939 + make_float2 (_S939.x * _S846 + _S939.y * _S847, 0.0f))); - bool _S941 = !((F32_min((determinant_0(_S940)), ((F32_min((_S940.rows[int(0)].x), (_S940.rows[int(1)].y)))))) > 0.0f); - _S857 = _S941; - if(_S941) + if(_S1641) { - break; - } - float u_49 = proj_points_1[int(2)].x; - float v_49 = proj_points_1[int(2)].y; - float r2_49 = u_49 * u_49 + v_49 * v_49; - float2 _S942 = proj_points_1[int(2)] * make_float2 (1.0f + r2_49 * (_S838 + r2_49 * (_S839 + r2_49 * (_S840 + r2_49 * _S841)))) + make_float2 (_S848 * u_49 * v_49 + _S843 * (r2_49 + 2.0f * u_49 * u_49) + _S844 * r2_49, _S849 * u_49 * v_49 + _S842 * (r2_49 + 2.0f * v_49 * v_49) + _S845 * r2_49); - float2 _S943 = _S942 + make_float2 (_S846 * _S942.x + _S847 * _S942.y, 0.0f); - proj_points_1[int(2)] = make_float2 (fx_9 * _S943.x + cx_6, fy_9 * _S943.y + cy_6); - break; - } - _S858 = all_valid_5 & (!_S857); - break; - } - _S859 = &proj_points_1[int(3)]; - for(;;) - { - float2 _S944 = float2 {_S885.p_0[int(3)].x, _S885.p_0[int(3)].y}; - float r_14 = length_0(_S944); - float _S945 = _S885.p_0[int(3)].z; - _S860 = _S945; - float theta_7 = (F32_atan2((r_14), (_S945))); - if(theta_7 < 0.00100000004749745f) - { - k_4 = (1.0f - theta_7 * theta_7 / 3.0f) / _S945; - } - else - { - k_4 = theta_7 / r_14; - } - float2 _S946 = _S944 * make_float2 (k_4); - proj_points_1[int(3)] = _S946; - float u_50 = _S946.x; - float v_50 = _S946.y; - float _S947 = u_50 + u_50; - float r2_50 = u_50 * u_50 + v_50 * v_50; - float _S948 = _S840 + r2_50 * _S841; - float _S949 = _S839 + r2_50 * _S948; - float _S950 = _S838 + r2_50 * _S949; - float radial_16 = 1.0f + r2_50 * _S950; - float _S951 = 2.0f * u_50; - float _S952 = 2.0f * v_50; - float2 _S953 = _S837 * make_float2 (radial_16) + make_float2 (_S947 * _S950 + (_S947 * _S949 + (_S947 * _S948 + _S947 * _S841 * r2_50) * r2_50) * r2_50) * _S946 + make_float2 (_S848 * v_50 + (_S947 + (_S951 + _S951)) * _S843 + _S947 * _S844, _S849 * v_50 + _S947 * _S842 + _S947 * _S845); - float _S954 = v_50 + v_50; - float2 _S955 = _S850 * make_float2 (radial_16) + make_float2 (_S954 * _S950 + (_S954 * _S949 + (_S954 * _S948 + _S954 * _S841 * r2_50) * r2_50) * r2_50) * _S946 + make_float2 (_S848 * u_50 + _S954 * _S843 + _S954 * _S844, _S849 * u_50 + (_S954 + (_S952 + _S952)) * _S842 + _S954 * _S845); - Matrix _S956 = transpose_0(makeMatrix (_S953 + make_float2 (_S953.x * _S846 + _S953.y * _S847, 0.0f), _S955 + make_float2 (_S955.x * _S846 + _S955.y * _S847, 0.0f))); - bool _S957 = !((F32_min((determinant_0(_S956)), ((F32_min((_S956.rows[int(0)].x), (_S956.rows[int(1)].y)))))) > 0.0f); - _S861 = _S957; - if(_S957) - { - break; - } - float u_51 = proj_points_1[int(3)].x; - float v_51 = proj_points_1[int(3)].y; - float r2_51 = u_51 * u_51 + v_51 * v_51; - float2 _S958 = proj_points_1[int(3)] * make_float2 (1.0f + r2_51 * (_S838 + r2_51 * (_S839 + r2_51 * (_S840 + r2_51 * _S841)))) + make_float2 (_S848 * u_51 * v_51 + _S843 * (r2_51 + 2.0f * u_51 * u_51) + _S844 * r2_51, _S849 * u_51 * v_51 + _S842 * (r2_51 + 2.0f * v_51 * v_51) + _S845 * r2_51); - float2 _S959 = _S958 + make_float2 (_S846 * _S958.x + _S847 * _S958.y, 0.0f); - proj_points_1[int(3)] = make_float2 (fx_9 * _S959.x + cx_6, fy_9 * _S959.y + cy_6); - break; - } - bool all_valid_6 = _S858 & (!_S861); - _S862 = &proj_points_1[int(4)]; - for(;;) - { - float2 _S960 = float2 {_S885.p_0[int(4)].x, _S885.p_0[int(4)].y}; - float r_15 = length_0(_S960); - float _S961 = _S885.p_0[int(4)].z; - _S863 = _S961; - float theta_8 = (F32_atan2((r_15), (_S961))); - if(theta_8 < 0.00100000004749745f) - { - k_4 = (1.0f - theta_8 * theta_8 / 3.0f) / _S961; - } - else - { - k_4 = theta_8 / r_15; - } - float2 _S962 = _S960 * make_float2 (k_4); - proj_points_1[int(4)] = _S962; - float u_52 = _S962.x; - float v_52 = _S962.y; - float _S963 = u_52 + u_52; - float r2_52 = u_52 * u_52 + v_52 * v_52; - float _S964 = _S840 + r2_52 * _S841; - float _S965 = _S839 + r2_52 * _S964; - float _S966 = _S838 + r2_52 * _S965; - float radial_17 = 1.0f + r2_52 * _S966; - float _S967 = 2.0f * u_52; - float _S968 = 2.0f * v_52; - float2 _S969 = _S837 * make_float2 (radial_17) + make_float2 (_S963 * _S966 + (_S963 * _S965 + (_S963 * _S964 + _S963 * _S841 * r2_52) * r2_52) * r2_52) * _S962 + make_float2 (_S848 * v_52 + (_S963 + (_S967 + _S967)) * _S843 + _S963 * _S844, _S849 * v_52 + _S963 * _S842 + _S963 * _S845); - float _S970 = v_52 + v_52; - float2 _S971 = _S850 * make_float2 (radial_17) + make_float2 (_S970 * _S966 + (_S970 * _S965 + (_S970 * _S964 + _S970 * _S841 * r2_52) * r2_52) * r2_52) * _S962 + make_float2 (_S848 * u_52 + _S970 * _S843 + _S970 * _S844, _S849 * u_52 + (_S970 + (_S968 + _S968)) * _S842 + _S970 * _S845); - Matrix _S972 = transpose_0(makeMatrix (_S969 + make_float2 (_S969.x * _S846 + _S969.y * _S847, 0.0f), _S971 + make_float2 (_S971.x * _S846 + _S971.y * _S847, 0.0f))); - bool _S973 = !((F32_min((determinant_0(_S972)), ((F32_min((_S972.rows[int(0)].x), (_S972.rows[int(1)].y)))))) > 0.0f); - _S864 = _S973; - if(_S973) - { - break; - } - float u_53 = proj_points_1[int(4)].x; - float v_53 = proj_points_1[int(4)].y; - float r2_53 = u_53 * u_53 + v_53 * v_53; - float2 _S974 = proj_points_1[int(4)] * make_float2 (1.0f + r2_53 * (_S838 + r2_53 * (_S839 + r2_53 * (_S840 + r2_53 * _S841)))) + make_float2 (_S848 * u_53 * v_53 + _S843 * (r2_53 + 2.0f * u_53 * u_53) + _S844 * r2_53, _S849 * u_53 * v_53 + _S842 * (r2_53 + 2.0f * v_53 * v_53) + _S845 * r2_53); - float2 _S975 = _S974 + make_float2 (_S846 * _S974.x + _S847 * _S974.y, 0.0f); - proj_points_1[int(4)] = make_float2 (fx_9 * _S975.x + cx_6, fy_9 * _S975.y + cy_6); - break; - } - bool all_valid_7 = all_valid_6 & (!_S864); - for(;;) - { - _S865 = &proj_points_1[int(5)]; - for(;;) - { - float2 _S976 = float2 {_S885.p_0[int(5)].x, _S885.p_0[int(5)].y}; - float r_16 = length_0(_S976); - float _S977 = _S885.p_0[int(5)].z; - _S866 = _S977; - float theta_9 = (F32_atan2((r_16), (_S977))); - if(theta_9 < 0.00100000004749745f) - { - k_4 = (1.0f - theta_9 * theta_9 / 3.0f) / _S977; + FixedArray _S1671 = dist_coeffs_24; + float2 _S1672 = DistOpenCV_distort_0(uv0_15, &_S1671); + _S1641 = (dot_0(uv0_15, _S1672)) >= 0.0f; } else { - k_4 = theta_9 / r_16; + _S1641 = false; } - float2 _S978 = _S976 * make_float2 (k_4); - proj_points_1[int(5)] = _S978; - float u_54 = _S978.x; - float v_54 = _S978.y; - float _S979 = u_54 + u_54; - float r2_54 = u_54 * u_54 + v_54 * v_54; - float _S980 = _S840 + r2_54 * _S841; - float _S981 = _S839 + r2_54 * _S980; - float _S982 = _S838 + r2_54 * _S981; - float radial_18 = 1.0f + r2_54 * _S982; - float _S983 = 2.0f * u_54; - float _S984 = 2.0f * v_54; - float2 _S985 = _S837 * make_float2 (radial_18) + make_float2 (_S979 * _S982 + (_S979 * _S981 + (_S979 * _S980 + _S979 * _S841 * r2_54) * r2_54) * r2_54) * _S978 + make_float2 (_S848 * v_54 + (_S979 + (_S983 + _S983)) * _S843 + _S979 * _S844, _S849 * v_54 + _S979 * _S842 + _S979 * _S845); - float _S986 = v_54 + v_54; - float2 _S987 = _S850 * make_float2 (radial_18) + make_float2 (_S986 * _S982 + (_S986 * _S981 + (_S986 * _S980 + _S986 * _S841 * r2_54) * r2_54) * r2_54) * _S978 + make_float2 (_S848 * u_54 + _S986 * _S843 + _S986 * _S844, _S849 * u_54 + (_S986 + (_S984 + _S984)) * _S842 + _S986 * _S845); - Matrix _S988 = transpose_0(makeMatrix (_S985 + make_float2 (_S985.x * _S846 + _S985.y * _S847, 0.0f), _S987 + make_float2 (_S987.x * _S846 + _S987.y * _S847, 0.0f))); - bool _S989 = !((F32_min((determinant_0(_S988)), ((F32_min((_S988.rows[int(0)].x), (_S988.rows[int(1)].y)))))) > 0.0f); - _S867 = _S989; - if(_S989) - { - break; - } - float u_55 = proj_points_1[int(5)].x; - float v_55 = proj_points_1[int(5)].y; - float r2_55 = u_55 * u_55 + v_55 * v_55; - float2 _S990 = proj_points_1[int(5)] * make_float2 (1.0f + r2_55 * (_S838 + r2_55 * (_S839 + r2_55 * (_S840 + r2_55 * _S841)))) + make_float2 (_S848 * u_55 * v_55 + _S843 * (r2_55 + 2.0f * u_55 * u_55) + _S844 * r2_55, _S849 * u_55 * v_55 + _S842 * (r2_55 + 2.0f * v_55 * v_55) + _S845 * r2_55); - float2 _S991 = _S990 + make_float2 (_S846 * _S990.x + _S847 * _S990.y, 0.0f); - proj_points_1[int(5)] = make_float2 (fx_9 * _S991.x + cx_6, fy_9 * _S991.y + cy_6); + _S1641 = !_S1641; + } + if(_S1641) + { + proj_points_1[int(0)] = uv0_15; + _S1641 = false; break; } - _S868 = all_valid_7 & (!_S867); + float2 uv_19 = _S1659 / make_float2 (_S1660); + FixedArray _S1673 = dist_coeffs_24; + float2 _S1674 = DistOpenCV_distort_0(uv_19, &_S1673); + proj_points_1[int(0)] = make_float2 (fx_25 * _S1674.x + cx_16, fy_25 * _S1674.y + cy_16); + _S1641 = true; break; } - _S869 = &proj_points_1[int(6)]; + bool all_valid_4 = true & _S1641; + _S1630 = &proj_points_1[int(1)]; for(;;) { - float2 _S992 = float2 {_S885.p_0[int(6)].x, _S885.p_0[int(6)].y}; - float r_17 = length_0(_S992); - float _S993 = _S885.p_0[int(6)].z; - _S870 = _S993; - float theta_10 = (F32_atan2((r_17), (_S993))); - if(theta_10 < 0.00100000004749745f) + float2 _S1675 = float2 {_S1652.p_0[int(1)].x, _S1652.p_0[int(1)].y}; + float _S1676 = _S1652.p_0[int(1)].z; + float2 uv0_16 = _S1675 / make_float2 (_S1676); + if(_S1676 < 0.0f) { - k_4 = (1.0f - theta_10 * theta_10 / 3.0f) / _S993; + _S1641 = true; } else { - k_4 = theta_10 / r_17; + float2 _S1677 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1678; + (&_S1678)->primal_0 = uv0_16; + (&_S1678)->differential_0 = _S1677; + FixedArray _S1679 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1680 = s_fwd_DistOpenCV_distort_0(&_S1678, &_S1679); + float2 _S1681 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1682; + (&_S1682)->primal_0 = uv0_16; + (&_S1682)->differential_0 = _S1681; + FixedArray _S1683 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1684 = s_fwd_DistOpenCV_distort_0(&_S1682, &_S1683); + Matrix _S1685 = transpose_0(makeMatrix (_S1680.differential_0, _S1684.differential_0)); + float _S1686 = (F32_min((determinant_0(_S1685)), ((F32_min((_S1685.rows[int(0)].x), (_S1685.rows[int(1)].y)))))); + if(_S1686 > 0.25f) + { + _S1641 = _S1686 < 4.0f; + } + else + { + _S1641 = false; + } + if(_S1641) + { + FixedArray _S1687 = dist_coeffs_24; + float2 _S1688 = DistOpenCV_distort_0(uv0_16, &_S1687); + _S1641 = (dot_0(uv0_16, _S1688)) >= 0.0f; + } + else + { + _S1641 = false; + } + _S1641 = !_S1641; } - float2 _S994 = _S992 * make_float2 (k_4); - proj_points_1[int(6)] = _S994; - float u_56 = _S994.x; - float v_56 = _S994.y; - float _S995 = u_56 + u_56; - float r2_56 = u_56 * u_56 + v_56 * v_56; - float _S996 = _S840 + r2_56 * _S841; - float _S997 = _S839 + r2_56 * _S996; - float _S998 = _S838 + r2_56 * _S997; - float radial_19 = 1.0f + r2_56 * _S998; - float _S999 = 2.0f * u_56; - float _S1000 = 2.0f * v_56; - float2 _S1001 = _S837 * make_float2 (radial_19) + make_float2 (_S995 * _S998 + (_S995 * _S997 + (_S995 * _S996 + _S995 * _S841 * r2_56) * r2_56) * r2_56) * _S994 + make_float2 (_S848 * v_56 + (_S995 + (_S999 + _S999)) * _S843 + _S995 * _S844, _S849 * v_56 + _S995 * _S842 + _S995 * _S845); - float _S1002 = v_56 + v_56; - float2 _S1003 = _S850 * make_float2 (radial_19) + make_float2 (_S1002 * _S998 + (_S1002 * _S997 + (_S1002 * _S996 + _S1002 * _S841 * r2_56) * r2_56) * r2_56) * _S994 + make_float2 (_S848 * u_56 + _S1002 * _S843 + _S1002 * _S844, _S849 * u_56 + (_S1002 + (_S1000 + _S1000)) * _S842 + _S1002 * _S845); - Matrix _S1004 = transpose_0(makeMatrix (_S1001 + make_float2 (_S1001.x * _S846 + _S1001.y * _S847, 0.0f), _S1003 + make_float2 (_S1003.x * _S846 + _S1003.y * _S847, 0.0f))); - bool _S1005 = !((F32_min((determinant_0(_S1004)), ((F32_min((_S1004.rows[int(0)].x), (_S1004.rows[int(1)].y)))))) > 0.0f); - _S871 = _S1005; - if(_S1005) + if(_S1641) { + proj_points_1[int(1)] = uv0_16; + _S1641 = false; break; } - float u_57 = proj_points_1[int(6)].x; - float v_57 = proj_points_1[int(6)].y; - float r2_57 = u_57 * u_57 + v_57 * v_57; - float2 _S1006 = proj_points_1[int(6)] * make_float2 (1.0f + r2_57 * (_S838 + r2_57 * (_S839 + r2_57 * (_S840 + r2_57 * _S841)))) + make_float2 (_S848 * u_57 * v_57 + _S843 * (r2_57 + 2.0f * u_57 * u_57) + _S844 * r2_57, _S849 * u_57 * v_57 + _S842 * (r2_57 + 2.0f * v_57 * v_57) + _S845 * r2_57); - float2 _S1007 = _S1006 + make_float2 (_S846 * _S1006.x + _S847 * _S1006.y, 0.0f); - proj_points_1[int(6)] = make_float2 (fx_9 * _S1007.x + cx_6, fy_9 * _S1007.y + cy_6); + float2 uv_20 = _S1675 / make_float2 (_S1676); + FixedArray _S1689 = dist_coeffs_24; + float2 _S1690 = DistOpenCV_distort_0(uv_20, &_S1689); + proj_points_1[int(1)] = make_float2 (fx_25 * _S1690.x + cx_16, fy_25 * _S1690.y + cy_16); + _S1641 = true; break; } - _S872 = _S868 & (!_S871); + bool all_valid_5 = all_valid_4 & _S1641; + for(;;) + { + _S1631 = &proj_points_1[int(2)]; + for(;;) + { + float2 _S1691 = float2 {_S1652.p_0[int(2)].x, _S1652.p_0[int(2)].y}; + float _S1692 = _S1652.p_0[int(2)].z; + float2 uv0_17 = _S1691 / make_float2 (_S1692); + if(_S1692 < 0.0f) + { + _S1641 = true; + } + else + { + float2 _S1693 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1694; + (&_S1694)->primal_0 = uv0_17; + (&_S1694)->differential_0 = _S1693; + FixedArray _S1695 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1696 = s_fwd_DistOpenCV_distort_0(&_S1694, &_S1695); + float2 _S1697 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1698; + (&_S1698)->primal_0 = uv0_17; + (&_S1698)->differential_0 = _S1697; + FixedArray _S1699 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1700 = s_fwd_DistOpenCV_distort_0(&_S1698, &_S1699); + Matrix _S1701 = transpose_0(makeMatrix (_S1696.differential_0, _S1700.differential_0)); + float _S1702 = (F32_min((determinant_0(_S1701)), ((F32_min((_S1701.rows[int(0)].x), (_S1701.rows[int(1)].y)))))); + if(_S1702 > 0.25f) + { + _S1641 = _S1702 < 4.0f; + } + else + { + _S1641 = false; + } + if(_S1641) + { + FixedArray _S1703 = dist_coeffs_24; + float2 _S1704 = DistOpenCV_distort_0(uv0_17, &_S1703); + _S1641 = (dot_0(uv0_17, _S1704)) >= 0.0f; + } + else + { + _S1641 = false; + } + _S1641 = !_S1641; + } + if(_S1641) + { + proj_points_1[int(2)] = uv0_17; + _S1641 = false; + break; + } + float2 uv_21 = _S1691 / make_float2 (_S1692); + FixedArray _S1705 = dist_coeffs_24; + float2 _S1706 = DistOpenCV_distort_0(uv_21, &_S1705); + proj_points_1[int(2)] = make_float2 (fx_25 * _S1706.x + cx_16, fy_25 * _S1706.y + cy_16); + _S1641 = true; + break; + } + _S1632 = all_valid_5 & _S1641; + break; + } + _S1633 = &proj_points_1[int(3)]; + for(;;) + { + float2 _S1707 = float2 {_S1652.p_0[int(3)].x, _S1652.p_0[int(3)].y}; + float _S1708 = _S1652.p_0[int(3)].z; + float2 uv0_18 = _S1707 / make_float2 (_S1708); + if(_S1708 < 0.0f) + { + _S1641 = true; + } + else + { + float2 _S1709 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1710; + (&_S1710)->primal_0 = uv0_18; + (&_S1710)->differential_0 = _S1709; + FixedArray _S1711 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1712 = s_fwd_DistOpenCV_distort_0(&_S1710, &_S1711); + float2 _S1713 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1714; + (&_S1714)->primal_0 = uv0_18; + (&_S1714)->differential_0 = _S1713; + FixedArray _S1715 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1716 = s_fwd_DistOpenCV_distort_0(&_S1714, &_S1715); + Matrix _S1717 = transpose_0(makeMatrix (_S1712.differential_0, _S1716.differential_0)); + float _S1718 = (F32_min((determinant_0(_S1717)), ((F32_min((_S1717.rows[int(0)].x), (_S1717.rows[int(1)].y)))))); + if(_S1718 > 0.25f) + { + _S1641 = _S1718 < 4.0f; + } + else + { + _S1641 = false; + } + if(_S1641) + { + FixedArray _S1719 = dist_coeffs_24; + float2 _S1720 = DistOpenCV_distort_0(uv0_18, &_S1719); + _S1641 = (dot_0(uv0_18, _S1720)) >= 0.0f; + } + else + { + _S1641 = false; + } + _S1641 = !_S1641; + } + if(_S1641) + { + proj_points_1[int(3)] = uv0_18; + _S1641 = false; + break; + } + float2 uv_22 = _S1707 / make_float2 (_S1708); + FixedArray _S1721 = dist_coeffs_24; + float2 _S1722 = DistOpenCV_distort_0(uv_22, &_S1721); + proj_points_1[int(3)] = make_float2 (fx_25 * _S1722.x + cx_16, fy_25 * _S1722.y + cy_16); + _S1641 = true; + break; + } + bool all_valid_6 = _S1632 & _S1641; + _S1634 = &proj_points_1[int(4)]; + for(;;) + { + float2 _S1723 = float2 {_S1652.p_0[int(4)].x, _S1652.p_0[int(4)].y}; + float _S1724 = _S1652.p_0[int(4)].z; + float2 uv0_19 = _S1723 / make_float2 (_S1724); + if(_S1724 < 0.0f) + { + _S1641 = true; + } + else + { + float2 _S1725 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1726; + (&_S1726)->primal_0 = uv0_19; + (&_S1726)->differential_0 = _S1725; + FixedArray _S1727 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1728 = s_fwd_DistOpenCV_distort_0(&_S1726, &_S1727); + float2 _S1729 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1730; + (&_S1730)->primal_0 = uv0_19; + (&_S1730)->differential_0 = _S1729; + FixedArray _S1731 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1732 = s_fwd_DistOpenCV_distort_0(&_S1730, &_S1731); + Matrix _S1733 = transpose_0(makeMatrix (_S1728.differential_0, _S1732.differential_0)); + float _S1734 = (F32_min((determinant_0(_S1733)), ((F32_min((_S1733.rows[int(0)].x), (_S1733.rows[int(1)].y)))))); + if(_S1734 > 0.25f) + { + _S1641 = _S1734 < 4.0f; + } + else + { + _S1641 = false; + } + if(_S1641) + { + FixedArray _S1735 = dist_coeffs_24; + float2 _S1736 = DistOpenCV_distort_0(uv0_19, &_S1735); + _S1641 = (dot_0(uv0_19, _S1736)) >= 0.0f; + } + else + { + _S1641 = false; + } + _S1641 = !_S1641; + } + if(_S1641) + { + proj_points_1[int(4)] = uv0_19; + _S1641 = false; + break; + } + float2 uv_23 = _S1723 / make_float2 (_S1724); + FixedArray _S1737 = dist_coeffs_24; + float2 _S1738 = DistOpenCV_distort_0(uv_23, &_S1737); + proj_points_1[int(4)] = make_float2 (fx_25 * _S1738.x + cx_16, fy_25 * _S1738.y + cy_16); + _S1641 = true; + break; + } + bool all_valid_7 = all_valid_6 & _S1641; + for(;;) + { + _S1635 = &proj_points_1[int(5)]; + for(;;) + { + float2 _S1739 = float2 {_S1652.p_0[int(5)].x, _S1652.p_0[int(5)].y}; + float _S1740 = _S1652.p_0[int(5)].z; + float2 uv0_20 = _S1739 / make_float2 (_S1740); + if(_S1740 < 0.0f) + { + _S1641 = true; + } + else + { + float2 _S1741 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1742; + (&_S1742)->primal_0 = uv0_20; + (&_S1742)->differential_0 = _S1741; + FixedArray _S1743 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1744 = s_fwd_DistOpenCV_distort_0(&_S1742, &_S1743); + float2 _S1745 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1746; + (&_S1746)->primal_0 = uv0_20; + (&_S1746)->differential_0 = _S1745; + FixedArray _S1747 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1748 = s_fwd_DistOpenCV_distort_0(&_S1746, &_S1747); + Matrix _S1749 = transpose_0(makeMatrix (_S1744.differential_0, _S1748.differential_0)); + float _S1750 = (F32_min((determinant_0(_S1749)), ((F32_min((_S1749.rows[int(0)].x), (_S1749.rows[int(1)].y)))))); + if(_S1750 > 0.25f) + { + _S1641 = _S1750 < 4.0f; + } + else + { + _S1641 = false; + } + if(_S1641) + { + FixedArray _S1751 = dist_coeffs_24; + float2 _S1752 = DistOpenCV_distort_0(uv0_20, &_S1751); + _S1641 = (dot_0(uv0_20, _S1752)) >= 0.0f; + } + else + { + _S1641 = false; + } + _S1641 = !_S1641; + } + if(_S1641) + { + proj_points_1[int(5)] = uv0_20; + _S1641 = false; + break; + } + float2 uv_24 = _S1739 / make_float2 (_S1740); + FixedArray _S1753 = dist_coeffs_24; + float2 _S1754 = DistOpenCV_distort_0(uv_24, &_S1753); + proj_points_1[int(5)] = make_float2 (fx_25 * _S1754.x + cx_16, fy_25 * _S1754.y + cy_16); + _S1641 = true; + break; + } + _S1636 = all_valid_7 & _S1641; + break; + } + _S1637 = &proj_points_1[int(6)]; + for(;;) + { + float2 _S1755 = float2 {_S1652.p_0[int(6)].x, _S1652.p_0[int(6)].y}; + float _S1756 = _S1652.p_0[int(6)].z; + float2 uv0_21 = _S1755 / make_float2 (_S1756); + if(_S1756 < 0.0f) + { + _S1641 = true; + } + else + { + float2 _S1757 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1758; + (&_S1758)->primal_0 = uv0_21; + (&_S1758)->differential_0 = _S1757; + FixedArray _S1759 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1760 = s_fwd_DistOpenCV_distort_0(&_S1758, &_S1759); + float2 _S1761 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1762; + (&_S1762)->primal_0 = uv0_21; + (&_S1762)->differential_0 = _S1761; + FixedArray _S1763 = dist_coeffs_24; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1764 = s_fwd_DistOpenCV_distort_0(&_S1762, &_S1763); + Matrix _S1765 = transpose_0(makeMatrix (_S1760.differential_0, _S1764.differential_0)); + float _S1766 = (F32_min((determinant_0(_S1765)), ((F32_min((_S1765.rows[int(0)].x), (_S1765.rows[int(1)].y)))))); + if(_S1766 > 0.25f) + { + _S1641 = _S1766 < 4.0f; + } + else + { + _S1641 = false; + } + if(_S1641) + { + FixedArray _S1767 = dist_coeffs_24; + float2 _S1768 = DistOpenCV_distort_0(uv0_21, &_S1767); + _S1641 = (dot_0(uv0_21, _S1768)) >= 0.0f; + } + else + { + _S1641 = false; + } + _S1641 = !_S1641; + } + if(_S1641) + { + proj_points_1[int(6)] = uv0_21; + _S1641 = false; + break; + } + float2 uv_25 = _S1755 / make_float2 (_S1756); + FixedArray _S1769 = dist_coeffs_24; + float2 _S1770 = DistOpenCV_distort_0(uv_25, &_S1769); + proj_points_1[int(6)] = make_float2 (fx_25 * _S1770.x + cx_16, fy_25 * _S1770.y + cy_16); + _S1641 = true; + break; + } + _S1638 = _S1636 & _S1641; break; } - if(!_S872) + if(!_S1638) { - _S874 = false; + _S1641 = false; break; } - float2 p_1 = *_S835 + (*_S852 - *_S835) * make_float2 (3.32899999618530273f); - float2 p_2 = *_S835 + (*_S855 - *_S835) * make_float2 (3.32899999618530273f); - float2 p_3 = *_S835 + (*_S859 - *_S835) * make_float2 (3.32899999618530273f); - float2 p_4 = *_S835 + (*_S862 - *_S835) * make_float2 (3.32899999618530273f); - float2 p_5 = *_S835 + (*_S865 - *_S835) * make_float2 (3.32899999618530273f); - float2 p_6 = *_S835 + (*_S869 - *_S835) * make_float2 (3.32899999618530273f); - float2 _S1008 = make_float2 (cx_6, cy_6); - float2 min_p_0 = min_0(min_0(min_0(min_0(min_0(min_0(*_S835, p_1), p_2), p_3), p_4), p_5), p_6) - _S1008; - float2 max_p_0 = max_0(max_0(max_0(max_0(max_0(max_0(*_S835, p_1), p_2), p_3), p_4), p_5), p_6) - _S1008; - if((F32_max(((F32_max(((F32_max(((F32_max(((F32_max(((F32_max((_S836), (_S853)))), (_S856)))), (_S860)))), (_S863)))), (_S866)))), (_S870))) <= 0.0f) - { - _S874 = (min_p_0.x * max_p_0.x) < 0.0f; - } - else - { - _S874 = false; - } - if(_S874) - { - _S874 = (min_p_0.y * max_p_0.y) < 0.0f; - } - else - { - _S874 = false; - } - if(_S874) - { - _S874 = false; - break; - } - float2 _S1009 = *mean2d_9 + make_float2 (_S885.w_mean_0[int(0)]) * *_S835 + make_float2 (_S885.w_mean_0[int(1)]) * *_S852 + make_float2 (_S885.w_mean_0[int(2)]) * *_S855 + make_float2 (_S885.w_mean_0[int(3)]) * *_S859 + make_float2 (_S885.w_mean_0[int(4)]) * *_S862 + make_float2 (_S885.w_mean_0[int(5)]) * *_S865 + make_float2 (_S885.w_mean_0[int(6)]) * *_S869; - *mean2d_9 = _S1009; - float2 d_7 = *_S835 - _S1009; - float _S1010 = d_7.x; - float _S1011 = d_7.y; - float _S1012 = _S1010 * _S1011; - float2 d_8 = *_S852 - _S1009; - float _S1013 = d_8.x; - float _S1014 = d_8.y; - float _S1015 = _S1013 * _S1014; - float2 d_9 = *_S855 - _S1009; - float _S1016 = d_9.x; - float _S1017 = d_9.y; - float _S1018 = _S1016 * _S1017; - float2 d_10 = *_S859 - _S1009; - float _S1019 = d_10.x; - float _S1020 = d_10.y; - float _S1021 = _S1019 * _S1020; - float2 d_11 = *_S862 - _S1009; - float _S1022 = d_11.x; - float _S1023 = d_11.y; - float _S1024 = _S1022 * _S1023; - float2 d_12 = *_S865 - _S1009; - float _S1025 = d_12.x; - float _S1026 = d_12.y; - float _S1027 = _S1025 * _S1026; - float2 d_13 = *_S869 - _S1009; - float _S1028 = d_13.x; - float _S1029 = d_13.y; - float _S1030 = _S1028 * _S1029; - covar2d_5 = covar2d_5 + makeMatrix (_S885.w_cov_0[int(0)]) * makeMatrix (_S1010 * _S1010, _S1012, _S1012, _S1011 * _S1011) + makeMatrix (_S885.w_cov_0[int(1)]) * makeMatrix (_S1013 * _S1013, _S1015, _S1015, _S1014 * _S1014) + makeMatrix (_S885.w_cov_0[int(2)]) * makeMatrix (_S1016 * _S1016, _S1018, _S1018, _S1017 * _S1017) + makeMatrix (_S885.w_cov_0[int(3)]) * makeMatrix (_S1019 * _S1019, _S1021, _S1021, _S1020 * _S1020) + makeMatrix (_S885.w_cov_0[int(4)]) * makeMatrix (_S1022 * _S1022, _S1024, _S1024, _S1023 * _S1023) + makeMatrix (_S885.w_cov_0[int(5)]) * makeMatrix (_S1025 * _S1025, _S1027, _S1027, _S1026 * _S1026) + makeMatrix (_S885.w_cov_0[int(6)]) * makeMatrix (_S1028 * _S1028, _S1030, _S1030, _S1029 * _S1029); - _S874 = true; + float2 _S1771 = *mean2d_25 + make_float2 (_S1652.w_mean_0[int(0)]) * *_S1629 + make_float2 (_S1652.w_mean_0[int(1)]) * *_S1630 + make_float2 (_S1652.w_mean_0[int(2)]) * *_S1631 + make_float2 (_S1652.w_mean_0[int(3)]) * *_S1633 + make_float2 (_S1652.w_mean_0[int(4)]) * *_S1634 + make_float2 (_S1652.w_mean_0[int(5)]) * *_S1635 + make_float2 (_S1652.w_mean_0[int(6)]) * *_S1637; + *mean2d_25 = _S1771; + float _S1772 = - _S1657; + float _S1773 = - _S1658; + float2 _S1774 = make_float2 (clamp_0(_S1771.x, _S1772, lim_x_pos_9), clamp_0(_S1771.y, _S1773, lim_y_pos_1)); + float2 d_7 = make_float2 (clamp_0((*_S1629).x, _S1772, lim_x_pos_9), clamp_0((*_S1629).y, _S1773, lim_y_pos_1)) - _S1774; + float _S1775 = d_7.x; + float _S1776 = d_7.y; + float _S1777 = _S1775 * _S1776; + float2 d_8 = make_float2 (clamp_0((*_S1630).x, _S1772, lim_x_pos_9), clamp_0((*_S1630).y, _S1773, lim_y_pos_1)) - _S1774; + float _S1778 = d_8.x; + float _S1779 = d_8.y; + float _S1780 = _S1778 * _S1779; + float2 d_9 = make_float2 (clamp_0((*_S1631).x, _S1772, lim_x_pos_9), clamp_0((*_S1631).y, _S1773, lim_y_pos_1)) - _S1774; + float _S1781 = d_9.x; + float _S1782 = d_9.y; + float _S1783 = _S1781 * _S1782; + float2 d_10 = make_float2 (clamp_0((*_S1633).x, _S1772, lim_x_pos_9), clamp_0((*_S1633).y, _S1773, lim_y_pos_1)) - _S1774; + float _S1784 = d_10.x; + float _S1785 = d_10.y; + float _S1786 = _S1784 * _S1785; + float2 d_11 = make_float2 (clamp_0((*_S1634).x, _S1772, lim_x_pos_9), clamp_0((*_S1634).y, _S1773, lim_y_pos_1)) - _S1774; + float _S1787 = d_11.x; + float _S1788 = d_11.y; + float _S1789 = _S1787 * _S1788; + float2 d_12 = make_float2 (clamp_0((*_S1635).x, _S1772, lim_x_pos_9), clamp_0((*_S1635).y, _S1773, lim_y_pos_1)) - _S1774; + float _S1790 = d_12.x; + float _S1791 = d_12.y; + float _S1792 = _S1790 * _S1791; + float2 d_13 = make_float2 (clamp_0((*_S1637).x, _S1772, lim_x_pos_9), clamp_0((*_S1637).y, _S1773, lim_y_pos_1)) - _S1774; + float _S1793 = d_13.x; + float _S1794 = d_13.y; + float _S1795 = _S1793 * _S1794; + covar2d_12 = covar2d_12 + makeMatrix (_S1652.w_cov_0[int(0)]) * makeMatrix (_S1775 * _S1775, _S1777, _S1777, _S1776 * _S1776) + makeMatrix (_S1652.w_cov_0[int(1)]) * makeMatrix (_S1778 * _S1778, _S1780, _S1780, _S1779 * _S1779) + makeMatrix (_S1652.w_cov_0[int(2)]) * makeMatrix (_S1781 * _S1781, _S1783, _S1783, _S1782 * _S1782) + makeMatrix (_S1652.w_cov_0[int(3)]) * makeMatrix (_S1784 * _S1784, _S1786, _S1786, _S1785 * _S1785) + makeMatrix (_S1652.w_cov_0[int(4)]) * makeMatrix (_S1787 * _S1787, _S1789, _S1789, _S1788 * _S1788) + makeMatrix (_S1652.w_cov_0[int(5)]) * makeMatrix (_S1790 * _S1790, _S1792, _S1792, _S1791 * _S1791) + makeMatrix (_S1652.w_cov_0[int(6)]) * makeMatrix (_S1793 * _S1793, _S1795, _S1795, _S1794 * _S1794); + _S1641 = true; break; } - if(!(true & _S874)) + if(!(true & _S1641)) { - *aabb_xyxy_5 = make_float4 (0.0f); + *aabb_xyxy_12 = _S1639; break; } - float eps2d_5; - if(antialiased_5) + float eps2d_12; + if(antialiased_12) { - eps2d_5 = 0.10000000149011612f; + eps2d_12 = 0.10000000149011612f; } else { - eps2d_5 = 0.30000001192092896f; + eps2d_12 = 0.30000001192092896f; } - float det_orig_5 = *&(((&covar2d_5)->rows + (int(0)))->x) * *&(((&covar2d_5)->rows + (int(1)))->y) - *&(((&covar2d_5)->rows + (int(0)))->y) * *&(((&covar2d_5)->rows + (int(1)))->x); - float _S1031 = *&(((&covar2d_5)->rows + (int(0)))->x) + eps2d_5; - *&(((&covar2d_5)->rows + (int(0)))->x) = _S1031; - float _S1032 = *&(((&covar2d_5)->rows + (int(1)))->y) + eps2d_5; - *&(((&covar2d_5)->rows + (int(1)))->y) = _S1032; - float det_blur_5 = _S1031 * _S1032 - *&(((&covar2d_5)->rows + (int(0)))->y) * *&(((&covar2d_5)->rows + (int(1)))->x); - float compensation_5 = (F32_sqrt(((F32_max((0.0f), (det_orig_5 / det_blur_5)))))); - if(det_blur_5 <= 0.0f) + float det_orig_12 = *&(((&covar2d_12)->rows + (int(0)))->x) * *&(((&covar2d_12)->rows + (int(1)))->y) - *&(((&covar2d_12)->rows + (int(0)))->y) * *&(((&covar2d_12)->rows + (int(1)))->x); + float _S1796 = *&(((&covar2d_12)->rows + (int(0)))->x) + eps2d_12; + *&(((&covar2d_12)->rows + (int(0)))->x) = _S1796; + float _S1797 = *&(((&covar2d_12)->rows + (int(1)))->y) + eps2d_12; + *&(((&covar2d_12)->rows + (int(1)))->y) = _S1797; + float det_blur_12 = _S1796 * _S1797 - *&(((&covar2d_12)->rows + (int(0)))->y) * *&(((&covar2d_12)->rows + (int(1)))->x); + float compensation_12 = (F32_sqrt(((F32_max((0.0f), (det_orig_12 / det_blur_12)))))); + if(det_blur_12 <= 0.0f) { - *aabb_xyxy_5 = make_float4 (0.0f); + *aabb_xyxy_12 = _S1639; break; } - float invdet_7 = 1.0f / (covar2d_5.rows[int(0)].x * covar2d_5.rows[int(1)].y - covar2d_5.rows[int(0)].y * covar2d_5.rows[int(1)].x); - Matrix _S1033 = makeMatrix (covar2d_5.rows[int(1)].y * invdet_7, - covar2d_5.rows[int(0)].y * invdet_7, - covar2d_5.rows[int(1)].x * invdet_7, covar2d_5.rows[int(0)].x * invdet_7); - if(antialiased_5) + float invdet_18 = 1.0f / (covar2d_12.rows[int(0)].x * covar2d_12.rows[int(1)].y - covar2d_12.rows[int(0)].y * covar2d_12.rows[int(1)].x); + Matrix _S1798 = makeMatrix (covar2d_12.rows[int(1)].y * invdet_18, - covar2d_12.rows[int(0)].y * invdet_18, - covar2d_12.rows[int(1)].x * invdet_18, covar2d_12.rows[int(0)].x * invdet_18); + if(antialiased_12) { - *opacity_5 = *opacity_5 * compensation_5; + *opacity_12 = *opacity_12 * compensation_12; } - if((*opacity_5) < 0.00392156885936856f) + if((*opacity_12) < 0.00392156885936856f) { - *aabb_xyxy_5 = make_float4 (0.0f); + *aabb_xyxy_12 = _S1639; break; } - float _S1034 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_5 / 0.00392156885936856f))))))))); - float radius_x_5 = _S1034 * (F32_sqrt((covar2d_5[int(0)].x))); - float radius_y_5 = _S1034 * (F32_sqrt((covar2d_5[int(1)].y))); - float _S1035 = (*mean2d_9).x - radius_x_5; - float _S1036 = (*mean2d_9).x + radius_x_5; - float _S1037 = (*mean2d_9).y - radius_y_5; - float _S1038 = (*mean2d_9).y + radius_y_5; - if(_S1036 <= 0.0f) + float _S1799 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_12 / 0.00392156885936856f))))))))); + float radius_x_12 = _S1799 * (F32_sqrt((covar2d_12[int(0)].x))); + float radius_y_12 = _S1799 * (F32_sqrt((covar2d_12[int(1)].y))); + float _S1800 = (*mean2d_25).x - radius_x_12; + float _S1801 = (*mean2d_25).x + radius_x_12; + float _S1802 = (*mean2d_25).y - radius_y_12; + float _S1803 = (*mean2d_25).y + radius_y_12; + if(_S1801 <= 0.0f) { - _S874 = true; + _S1641 = true; } else { - _S874 = _S1035 >= float(image_width_5); + _S1641 = _S1800 >= _S1627; } - if(_S874) + if(_S1641) { - _S874 = true; + _S1641 = true; } else { - _S874 = _S1038 <= 0.0f; + _S1641 = _S1803 <= 0.0f; } - if(_S874) + if(_S1641) { - _S874 = true; + _S1641 = true; } else { - _S874 = _S1037 >= float(image_height_5); + _S1641 = _S1802 >= _S1628; } - if(_S874) + if(_S1641) { - *aabb_xyxy_5 = make_float4 (0.0f); + *aabb_xyxy_12 = _S1639; break; } - *aabb_xyxy_5 = make_float4 (_S1035, _S1037, _S1036, _S1038); - float x_23 = mean_c_5.x; - float y_7 = mean_c_5.y; - float z_0 = mean_c_5.z; - float _S1039 = x_23 * x_23 + y_7 * y_7; - *sorting_depth_5 = z_0 * z_0 * z_0 * z_0 + 0.001953125f * _S1039 * _S1039; - *conic_5 = make_float3 (_S1033.rows[int(0)].x, _S1033.rows[int(0)].y, _S1033.rows[int(1)].y); - *radius_6 = view_radius_3dgs_0(mean_6, scale_5, in_opacity_5, - mul_6(transpose_3(R_5), t_5)); + *aabb_xyxy_12 = make_float4 (_S1800, _S1802, _S1801, _S1803); + *sorting_depth_12 = _S1640; + *conic_12 = make_float3 (_S1798.rows[int(0)].x, _S1798.rows[int(0)].y, _S1798.rows[int(1)].y); + *radius_13 = view_radius_3dgs_0(mean_13, scale_12, in_opacity_12, - mul_6(transpose_3(R_12), t_12)); break; } return; } -inline __device__ void projection_3dgut_equisolid(bool antialiased_6, float3 mean_7, float4 quat_6, float3 scale_6, float in_opacity_6, Matrix R_6, float3 t_6, float fx_10, float fy_10, float cx_7, float cy_7, FixedArray dist_coeffs_10, uint image_width_6, uint image_height_6, float4 * aabb_xyxy_6, float * sorting_depth_6, float * radius_7, float2 * mean2d_10, float * depth_6, float3 * conic_6, float * opacity_6) +inline __device__ void projection_3dgut_persp_prism(bool antialiased_13, float3 mean_14, float4 quat_13, float3 scale_13, float in_opacity_13, Matrix R_13, float3 t_13, float fx_26, float fy_26, float cx_17, float cy_17, FixedArray dist_coeffs_25, uint image_width_13, uint image_height_13, float4 * aabb_xyxy_13, float * sorting_depth_13, float * radius_14, float2 * mean2d_26, float * depth_13, float3 * conic_13, float * opacity_13) { - float2 * _S1040; - float _S1041; - float2 _S1042; - float _S1043; - float _S1044; - float _S1045; - float _S1046; - float _S1047; - float _S1048; - float _S1049; - float _S1050; - float _S1051; - float _S1052; - float _S1053; - float _S1054; - float2 _S1055; - bool _S1056; - float2 * _S1057; - float _S1058; - bool _S1059; - float2 * _S1060; - float _S1061; - bool _S1062; - bool _S1063; - float2 * _S1064; - float _S1065; - bool _S1066; - float2 * _S1067; - float _S1068; - bool _S1069; - float2 * _S1070; - float _S1071; - bool _S1072; - bool _S1073; - float2 * _S1074; - float _S1075; - bool _S1076; - bool _S1077; + float _S1804; + float _S1805; + float2 * _S1806; + float2 * _S1807; + float2 * _S1808; + bool _S1809; + float2 * _S1810; + float2 * _S1811; + float2 * _S1812; + bool _S1813; + float2 * _S1814; + bool _S1815; for(;;) { - float3 mean_c_6 = mul_6(R_6, mean_7) + t_6; - float _S1078 = length_1(mean_c_6); - *depth_6 = _S1078; - if(_S1078 <= 0.0f) + float4 _S1816 = make_float4 (0.0f); + *aabb_xyxy_13 = _S1816; + *sorting_depth_13 = 0.0f; + *radius_14 = 0.0f; + *mean2d_26 = make_float2 (0.0f); + *conic_13 = make_float3 (0.0f); + *opacity_13 = 0.0f; + float3 mean_c_13 = mul_6(R_13, mean_14) + t_13; + float _S1817 = mean_c_13.z; + *depth_13 = length_1(mean_c_13); + if(_S1817 <= 0.0f) { - *aabb_xyxy_6 = make_float4 (0.0f); + *aabb_xyxy_13 = _S1816; break; } - Matrix covar2d_6; - *opacity_6 = 1.0f / (1.0f + (F32_exp((- in_opacity_6)))); - bool _S1079; - float3 _S1080 = exp_0(scale_6); - float4 _S1081 = normalize_0(quat_6); - float x_24 = _S1081.y; - float x2_6 = x_24 * x_24; - float y2_6 = _S1081.z * _S1081.z; - float z2_6 = _S1081.w * _S1081.w; - float xy_6 = _S1081.y * _S1081.z; - float xz_6 = _S1081.y * _S1081.w; - float yz_6 = _S1081.z * _S1081.w; - float wx_6 = _S1081.x * _S1081.y; - float wy_6 = _S1081.x * _S1081.z; - float wz_6 = _S1081.x * _S1081.w; - Matrix _S1082 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_6 + z2_6), 2.0f * (xy_6 + wz_6), 2.0f * (xz_6 - wy_6), 2.0f * (xy_6 - wz_6), 1.0f - 2.0f * (x2_6 + z2_6), 2.0f * (yz_6 + wx_6), 2.0f * (xz_6 + wy_6), 2.0f * (yz_6 - wx_6), 1.0f - 2.0f * (x2_6 + y2_6)))); + Matrix covar2d_13; + *opacity_13 = 1.0f / (1.0f + (F32_exp((- in_opacity_13)))); + bool _S1818; + float3 _S1819 = exp_0(scale_13); + float4 _S1820 = normalize_0(quat_13); + float x_34 = _S1820.y; + float x2_13 = x_34 * x_34; + float y2_13 = _S1820.z * _S1820.z; + float z2_13 = _S1820.w * _S1820.w; + float xy_13 = _S1820.y * _S1820.z; + float xz_13 = _S1820.y * _S1820.w; + float yz_13 = _S1820.z * _S1820.w; + float wx_13 = _S1820.x * _S1820.y; + float wy_13 = _S1820.x * _S1820.z; + float wz_13 = _S1820.x * _S1820.w; + Matrix _S1821 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_13 + z2_13), 2.0f * (xy_13 + wz_13), 2.0f * (xz_13 - wy_13), 2.0f * (xy_13 - wz_13), 1.0f - 2.0f * (x2_13 + z2_13), 2.0f * (yz_13 + wx_13), 2.0f * (xz_13 + wy_13), 2.0f * (yz_13 - wx_13), 1.0f - 2.0f * (x2_13 + y2_13)))); SigmaPoints_0 ret_2; - (&ret_2)->p_0[int(0)] = mean_7; + (&ret_2)->p_0[int(0)] = mean_14; (&ret_2)->w_mean_0[int(0)] = 0.0f; (&ret_2)->w_cov_0[int(0)] = 2.0f; - float _S1083 = (F32_sqrt((3.0f))); - float3 delta_6 = make_float3 (_S1083 * _S1080.x) * _S1082.rows[0U]; - float3 _S1084 = mean_7 + delta_6; - float3 _S1085 = mean_7 - delta_6; - float3 delta_7 = make_float3 (_S1083 * _S1080.y) * _S1082.rows[1U]; - float3 _S1086 = mean_7 + delta_7; - float3 _S1087 = mean_7 - delta_7; - float3 delta_8 = make_float3 (_S1083 * _S1080.z) * _S1082.rows[2U]; - float3 _S1088 = mean_7 + delta_8; - float3 _S1089 = mean_7 - delta_8; + float _S1822 = (F32_sqrt((3.0f))); + float3 delta_6 = make_float3 (_S1822 * _S1819.x) * _S1821.rows[0U]; + float3 _S1823 = mean_14 + delta_6; + float3 _S1824 = mean_14 - delta_6; + float3 delta_7 = make_float3 (_S1822 * _S1819.y) * _S1821.rows[1U]; + float3 _S1825 = mean_14 + delta_7; + float3 _S1826 = mean_14 - delta_7; + float3 delta_8 = make_float3 (_S1822 * _S1819.z) * _S1821.rows[2U]; + float3 _S1827 = mean_14 + delta_8; + float3 _S1828 = mean_14 - delta_8; (&ret_2)->w_mean_0[1U] = 0.1666666716337204f; (&ret_2)->w_cov_0[1U] = 0.1666666716337204f; (&ret_2)->w_mean_0[2U] = 0.1666666716337204f; @@ -4078,582 +7301,647 @@ inline __device__ void projection_3dgut_equisolid(bool antialiased_6, float3 me (&ret_2)->w_cov_0[5U] = 0.1666666716337204f; (&ret_2)->w_mean_0[6U] = 0.1666666716337204f; (&ret_2)->w_cov_0[6U] = 0.1666666716337204f; - (&ret_2)->p_0[0U] = mul_6(R_6, (&ret_2)->p_0[0U]) + t_6; - (&ret_2)->p_0[1U] = mul_6(R_6, _S1084) + t_6; - (&ret_2)->p_0[2U] = mul_6(R_6, _S1086) + t_6; - (&ret_2)->p_0[3U] = mul_6(R_6, _S1088) + t_6; - (&ret_2)->p_0[4U] = mul_6(R_6, _S1085) + t_6; - (&ret_2)->p_0[5U] = mul_6(R_6, _S1087) + t_6; - (&ret_2)->p_0[6U] = mul_6(R_6, _S1089) + t_6; - SigmaPoints_0 _S1090 = ret_2; + (&ret_2)->p_0[0U] = mul_6(R_13, (&ret_2)->p_0[0U]) + t_13; + (&ret_2)->p_0[1U] = mul_6(R_13, _S1823) + t_13; + (&ret_2)->p_0[2U] = mul_6(R_13, _S1825) + t_13; + (&ret_2)->p_0[3U] = mul_6(R_13, _S1827) + t_13; + (&ret_2)->p_0[4U] = mul_6(R_13, _S1824) + t_13; + (&ret_2)->p_0[5U] = mul_6(R_13, _S1826) + t_13; + (&ret_2)->p_0[6U] = mul_6(R_13, _S1828) + t_13; + SigmaPoints_0 _S1829 = ret_2; for(;;) { - int2 _S1091 = make_int2 (int(0)); - float2 _S1092 = make_float2 ((float)_S1091.x, (float)_S1091.y); - *mean2d_10 = _S1092; - covar2d_6 = makeMatrix (0.0f); + int2 _S1830 = make_int2 (int(0)); + float2 _S1831 = make_float2 ((float)_S1830.x, (float)_S1830.y); + *mean2d_26 = _S1831; + covar2d_13 = makeMatrix (0.0f); + float _S1832 = float(image_width_13); + _S1804 = _S1832; + float tan_fovx_2 = 0.5f * _S1832 / fx_26; + float _S1833 = float(image_height_13); + _S1805 = _S1833; + float _S1834 = 0.30000001192092896f * tan_fovx_2 * fx_26; + float lim_x_pos_10 = _S1832 + _S1834; + float _S1835 = 0.30000001192092896f * (0.5f * _S1833 / fy_26) * fy_26; + float lim_y_pos_2 = _S1833 + _S1835; FixedArray proj_points_2; for(;;) { - float k_5; - _S1040 = &proj_points_2[int(0)]; + _S1806 = &proj_points_2[int(0)]; for(;;) { - float2 _S1093 = float2 {_S1090.p_0[int(0)].x, _S1090.p_0[int(0)].y}; - float r_18 = length_0(_S1093); - float _S1094 = _S1090.p_0[int(0)].z; - _S1041 = _S1094; - float theta_11 = (F32_atan2((r_18), (_S1094))); - if(r_18 < 9.99999997475242708e-07f) + float2 _S1836 = float2 {_S1829.p_0[int(0)].x, _S1829.p_0[int(0)].y}; + float _S1837 = _S1829.p_0[int(0)].z; + float2 uv0_22 = _S1836 / make_float2 (_S1837); + if(_S1837 < 0.0f) { - k_5 = (1.0f - theta_11 * theta_11 / 24.0f) / _S1094; + _S1818 = true; } else { - k_5 = 2.0f * (F32_sin((0.5f * theta_11))) / r_18; - } - float2 _S1095 = _S1093 * make_float2 (k_5); - proj_points_2[int(0)] = _S1095; - float2 _S1096 = make_float2 (1.0f, 0.0f); - _S1042 = _S1096; - _S1043 = dist_coeffs_10[int(0)]; - _S1044 = dist_coeffs_10[int(1)]; - _S1045 = dist_coeffs_10[int(2)]; - _S1046 = dist_coeffs_10[int(3)]; - _S1047 = dist_coeffs_10[int(4)]; - _S1048 = dist_coeffs_10[int(5)]; - _S1049 = dist_coeffs_10[int(6)]; - _S1050 = dist_coeffs_10[int(7)]; - _S1051 = dist_coeffs_10[int(8)]; - _S1052 = dist_coeffs_10[int(9)]; - float u_58 = _S1095.x; - float v_58 = _S1095.y; - float _S1097 = u_58 + u_58; - float r2_58 = u_58 * u_58 + v_58 * v_58; - float _S1098 = dist_coeffs_10[int(2)] + r2_58 * dist_coeffs_10[int(3)]; - float _S1099 = dist_coeffs_10[int(1)] + r2_58 * _S1098; - float _S1100 = dist_coeffs_10[int(0)] + r2_58 * _S1099; - float _S1101 = _S1097 * _S1100 + (_S1097 * _S1099 + (_S1097 * _S1098 + _S1097 * dist_coeffs_10[int(3)] * r2_58) * r2_58) * r2_58; - float radial_20 = 1.0f + r2_58 * _S1100; - float _S1102 = 2.0f * dist_coeffs_10[int(4)]; - _S1053 = _S1102; - float _S1103 = _S1102 * u_58; - float _S1104 = 2.0f * u_58; - float s_diff_du_5 = _S1102 * v_58 + (_S1097 + (_S1104 + _S1104)) * dist_coeffs_10[int(5)] + _S1097 * dist_coeffs_10[int(6)]; - float _S1105 = 2.0f * dist_coeffs_10[int(5)]; - _S1054 = _S1105; - float _S1106 = _S1105 * u_58; - float _S1107 = 2.0f * v_58; - float2 _S1108 = _S1096 * make_float2 (radial_20) + make_float2 (_S1101) * _S1095 + make_float2 (s_diff_du_5, _S1105 * v_58 + _S1097 * dist_coeffs_10[int(4)] + _S1097 * dist_coeffs_10[int(7)]); - float2 _S1109 = _S1108 + make_float2 (_S1108.x * dist_coeffs_10[int(8)] + _S1108.y * dist_coeffs_10[int(9)], 0.0f); - float2 _S1110 = make_float2 (0.0f, 1.0f); - _S1055 = _S1110; - float _S1111 = v_58 + v_58; - float2 _S1112 = _S1110 * make_float2 (radial_20) + make_float2 (_S1111 * _S1100 + (_S1111 * _S1099 + (_S1111 * _S1098 + _S1111 * dist_coeffs_10[int(3)] * r2_58) * r2_58) * r2_58) * _S1095 + make_float2 (_S1103 + _S1111 * dist_coeffs_10[int(5)] + _S1111 * dist_coeffs_10[int(6)], _S1106 + (_S1111 + (_S1107 + _S1107)) * dist_coeffs_10[int(4)] + _S1111 * dist_coeffs_10[int(7)]); - Matrix _S1113 = transpose_0(makeMatrix (_S1109, _S1112 + make_float2 (_S1112.x * dist_coeffs_10[int(8)] + _S1112.y * dist_coeffs_10[int(9)], 0.0f))); - bool _S1114 = !((F32_min((determinant_0(_S1113)), ((F32_min((_S1113.rows[int(0)].x), (_S1113.rows[int(1)].y)))))) > 0.0f); - _S1056 = _S1114; - if(_S1114) - { - break; - } - float u_59 = proj_points_2[int(0)].x; - float v_59 = proj_points_2[int(0)].y; - float r2_59 = u_59 * u_59 + v_59 * v_59; - float2 _S1115 = proj_points_2[int(0)] * make_float2 (1.0f + r2_59 * (dist_coeffs_10[int(0)] + r2_59 * (dist_coeffs_10[int(1)] + r2_59 * (dist_coeffs_10[int(2)] + r2_59 * dist_coeffs_10[int(3)])))) + make_float2 (_S1102 * u_59 * v_59 + dist_coeffs_10[int(5)] * (r2_59 + 2.0f * u_59 * u_59) + dist_coeffs_10[int(6)] * r2_59, _S1105 * u_59 * v_59 + dist_coeffs_10[int(4)] * (r2_59 + 2.0f * v_59 * v_59) + dist_coeffs_10[int(7)] * r2_59); - float2 _S1116 = _S1115 + make_float2 (dist_coeffs_10[int(8)] * _S1115.x + dist_coeffs_10[int(9)] * _S1115.y, 0.0f); - proj_points_2[int(0)] = make_float2 (fx_10 * _S1116.x + cx_7, fy_10 * _S1116.y + cy_7); - break; - } - bool all_valid_8 = true & (!_S1056); - _S1057 = &proj_points_2[int(1)]; - for(;;) - { - float2 _S1117 = float2 {_S1090.p_0[int(1)].x, _S1090.p_0[int(1)].y}; - float r_19 = length_0(_S1117); - float _S1118 = _S1090.p_0[int(1)].z; - _S1058 = _S1118; - float theta_12 = (F32_atan2((r_19), (_S1118))); - if(r_19 < 9.99999997475242708e-07f) - { - k_5 = (1.0f - theta_12 * theta_12 / 24.0f) / _S1118; - } - else - { - k_5 = 2.0f * (F32_sin((0.5f * theta_12))) / r_19; - } - float2 _S1119 = _S1117 * make_float2 (k_5); - proj_points_2[int(1)] = _S1119; - float u_60 = _S1119.x; - float v_60 = _S1119.y; - float _S1120 = u_60 + u_60; - float r2_60 = u_60 * u_60 + v_60 * v_60; - float _S1121 = _S1045 + r2_60 * _S1046; - float _S1122 = _S1044 + r2_60 * _S1121; - float _S1123 = _S1043 + r2_60 * _S1122; - float radial_21 = 1.0f + r2_60 * _S1123; - float _S1124 = 2.0f * u_60; - float _S1125 = 2.0f * v_60; - float2 _S1126 = _S1042 * make_float2 (radial_21) + make_float2 (_S1120 * _S1123 + (_S1120 * _S1122 + (_S1120 * _S1121 + _S1120 * _S1046 * r2_60) * r2_60) * r2_60) * _S1119 + make_float2 (_S1053 * v_60 + (_S1120 + (_S1124 + _S1124)) * _S1048 + _S1120 * _S1049, _S1054 * v_60 + _S1120 * _S1047 + _S1120 * _S1050); - float _S1127 = v_60 + v_60; - float2 _S1128 = _S1055 * make_float2 (radial_21) + make_float2 (_S1127 * _S1123 + (_S1127 * _S1122 + (_S1127 * _S1121 + _S1127 * _S1046 * r2_60) * r2_60) * r2_60) * _S1119 + make_float2 (_S1053 * u_60 + _S1127 * _S1048 + _S1127 * _S1049, _S1054 * u_60 + (_S1127 + (_S1125 + _S1125)) * _S1047 + _S1127 * _S1050); - Matrix _S1129 = transpose_0(makeMatrix (_S1126 + make_float2 (_S1126.x * _S1051 + _S1126.y * _S1052, 0.0f), _S1128 + make_float2 (_S1128.x * _S1051 + _S1128.y * _S1052, 0.0f))); - bool _S1130 = !((F32_min((determinant_0(_S1129)), ((F32_min((_S1129.rows[int(0)].x), (_S1129.rows[int(1)].y)))))) > 0.0f); - _S1059 = _S1130; - if(_S1130) - { - break; - } - float u_61 = proj_points_2[int(1)].x; - float v_61 = proj_points_2[int(1)].y; - float r2_61 = u_61 * u_61 + v_61 * v_61; - float2 _S1131 = proj_points_2[int(1)] * make_float2 (1.0f + r2_61 * (_S1043 + r2_61 * (_S1044 + r2_61 * (_S1045 + r2_61 * _S1046)))) + make_float2 (_S1053 * u_61 * v_61 + _S1048 * (r2_61 + 2.0f * u_61 * u_61) + _S1049 * r2_61, _S1054 * u_61 * v_61 + _S1047 * (r2_61 + 2.0f * v_61 * v_61) + _S1050 * r2_61); - float2 _S1132 = _S1131 + make_float2 (_S1051 * _S1131.x + _S1052 * _S1131.y, 0.0f); - proj_points_2[int(1)] = make_float2 (fx_10 * _S1132.x + cx_7, fy_10 * _S1132.y + cy_7); - break; - } - bool all_valid_9 = all_valid_8 & (!_S1059); - for(;;) - { - _S1060 = &proj_points_2[int(2)]; - for(;;) - { - float2 _S1133 = float2 {_S1090.p_0[int(2)].x, _S1090.p_0[int(2)].y}; - float r_20 = length_0(_S1133); - float _S1134 = _S1090.p_0[int(2)].z; - _S1061 = _S1134; - float theta_13 = (F32_atan2((r_20), (_S1134))); - if(r_20 < 9.99999997475242708e-07f) + float2 _S1838 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1839; + (&_S1839)->primal_0 = uv0_22; + (&_S1839)->differential_0 = _S1838; + FixedArray _S1840 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1841 = s_fwd_DistThinPrism_distort_0(&_S1839, &_S1840); + float2 _S1842 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1843; + (&_S1843)->primal_0 = uv0_22; + (&_S1843)->differential_0 = _S1842; + FixedArray _S1844 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1845 = s_fwd_DistThinPrism_distort_0(&_S1843, &_S1844); + Matrix _S1846 = transpose_0(makeMatrix (_S1841.differential_0, _S1845.differential_0)); + float _S1847 = (F32_min((determinant_0(_S1846)), ((F32_min((_S1846.rows[int(0)].x), (_S1846.rows[int(1)].y)))))); + if(_S1847 > 0.25f) { - k_5 = (1.0f - theta_13 * theta_13 / 24.0f) / _S1134; + _S1818 = _S1847 < 4.0f; } else { - k_5 = 2.0f * (F32_sin((0.5f * theta_13))) / r_20; + _S1818 = false; } - float2 _S1135 = _S1133 * make_float2 (k_5); - proj_points_2[int(2)] = _S1135; - float u_62 = _S1135.x; - float v_62 = _S1135.y; - float _S1136 = u_62 + u_62; - float r2_62 = u_62 * u_62 + v_62 * v_62; - float _S1137 = _S1045 + r2_62 * _S1046; - float _S1138 = _S1044 + r2_62 * _S1137; - float _S1139 = _S1043 + r2_62 * _S1138; - float radial_22 = 1.0f + r2_62 * _S1139; - float _S1140 = 2.0f * u_62; - float _S1141 = 2.0f * v_62; - float2 _S1142 = _S1042 * make_float2 (radial_22) + make_float2 (_S1136 * _S1139 + (_S1136 * _S1138 + (_S1136 * _S1137 + _S1136 * _S1046 * r2_62) * r2_62) * r2_62) * _S1135 + make_float2 (_S1053 * v_62 + (_S1136 + (_S1140 + _S1140)) * _S1048 + _S1136 * _S1049, _S1054 * v_62 + _S1136 * _S1047 + _S1136 * _S1050); - float _S1143 = v_62 + v_62; - float2 _S1144 = _S1055 * make_float2 (radial_22) + make_float2 (_S1143 * _S1139 + (_S1143 * _S1138 + (_S1143 * _S1137 + _S1143 * _S1046 * r2_62) * r2_62) * r2_62) * _S1135 + make_float2 (_S1053 * u_62 + _S1143 * _S1048 + _S1143 * _S1049, _S1054 * u_62 + (_S1143 + (_S1141 + _S1141)) * _S1047 + _S1143 * _S1050); - Matrix _S1145 = transpose_0(makeMatrix (_S1142 + make_float2 (_S1142.x * _S1051 + _S1142.y * _S1052, 0.0f), _S1144 + make_float2 (_S1144.x * _S1051 + _S1144.y * _S1052, 0.0f))); - bool _S1146 = !((F32_min((determinant_0(_S1145)), ((F32_min((_S1145.rows[int(0)].x), (_S1145.rows[int(1)].y)))))) > 0.0f); - _S1062 = _S1146; - if(_S1146) + if(_S1818) { - break; - } - float u_63 = proj_points_2[int(2)].x; - float v_63 = proj_points_2[int(2)].y; - float r2_63 = u_63 * u_63 + v_63 * v_63; - float2 _S1147 = proj_points_2[int(2)] * make_float2 (1.0f + r2_63 * (_S1043 + r2_63 * (_S1044 + r2_63 * (_S1045 + r2_63 * _S1046)))) + make_float2 (_S1053 * u_63 * v_63 + _S1048 * (r2_63 + 2.0f * u_63 * u_63) + _S1049 * r2_63, _S1054 * u_63 * v_63 + _S1047 * (r2_63 + 2.0f * v_63 * v_63) + _S1050 * r2_63); - float2 _S1148 = _S1147 + make_float2 (_S1051 * _S1147.x + _S1052 * _S1147.y, 0.0f); - proj_points_2[int(2)] = make_float2 (fx_10 * _S1148.x + cx_7, fy_10 * _S1148.y + cy_7); - break; - } - _S1063 = all_valid_9 & (!_S1062); - break; - } - _S1064 = &proj_points_2[int(3)]; - for(;;) - { - float2 _S1149 = float2 {_S1090.p_0[int(3)].x, _S1090.p_0[int(3)].y}; - float r_21 = length_0(_S1149); - float _S1150 = _S1090.p_0[int(3)].z; - _S1065 = _S1150; - float theta_14 = (F32_atan2((r_21), (_S1150))); - if(r_21 < 9.99999997475242708e-07f) - { - k_5 = (1.0f - theta_14 * theta_14 / 24.0f) / _S1150; - } - else - { - k_5 = 2.0f * (F32_sin((0.5f * theta_14))) / r_21; - } - float2 _S1151 = _S1149 * make_float2 (k_5); - proj_points_2[int(3)] = _S1151; - float u_64 = _S1151.x; - float v_64 = _S1151.y; - float _S1152 = u_64 + u_64; - float r2_64 = u_64 * u_64 + v_64 * v_64; - float _S1153 = _S1045 + r2_64 * _S1046; - float _S1154 = _S1044 + r2_64 * _S1153; - float _S1155 = _S1043 + r2_64 * _S1154; - float radial_23 = 1.0f + r2_64 * _S1155; - float _S1156 = 2.0f * u_64; - float _S1157 = 2.0f * v_64; - float2 _S1158 = _S1042 * make_float2 (radial_23) + make_float2 (_S1152 * _S1155 + (_S1152 * _S1154 + (_S1152 * _S1153 + _S1152 * _S1046 * r2_64) * r2_64) * r2_64) * _S1151 + make_float2 (_S1053 * v_64 + (_S1152 + (_S1156 + _S1156)) * _S1048 + _S1152 * _S1049, _S1054 * v_64 + _S1152 * _S1047 + _S1152 * _S1050); - float _S1159 = v_64 + v_64; - float2 _S1160 = _S1055 * make_float2 (radial_23) + make_float2 (_S1159 * _S1155 + (_S1159 * _S1154 + (_S1159 * _S1153 + _S1159 * _S1046 * r2_64) * r2_64) * r2_64) * _S1151 + make_float2 (_S1053 * u_64 + _S1159 * _S1048 + _S1159 * _S1049, _S1054 * u_64 + (_S1159 + (_S1157 + _S1157)) * _S1047 + _S1159 * _S1050); - Matrix _S1161 = transpose_0(makeMatrix (_S1158 + make_float2 (_S1158.x * _S1051 + _S1158.y * _S1052, 0.0f), _S1160 + make_float2 (_S1160.x * _S1051 + _S1160.y * _S1052, 0.0f))); - bool _S1162 = !((F32_min((determinant_0(_S1161)), ((F32_min((_S1161.rows[int(0)].x), (_S1161.rows[int(1)].y)))))) > 0.0f); - _S1066 = _S1162; - if(_S1162) - { - break; - } - float u_65 = proj_points_2[int(3)].x; - float v_65 = proj_points_2[int(3)].y; - float r2_65 = u_65 * u_65 + v_65 * v_65; - float2 _S1163 = proj_points_2[int(3)] * make_float2 (1.0f + r2_65 * (_S1043 + r2_65 * (_S1044 + r2_65 * (_S1045 + r2_65 * _S1046)))) + make_float2 (_S1053 * u_65 * v_65 + _S1048 * (r2_65 + 2.0f * u_65 * u_65) + _S1049 * r2_65, _S1054 * u_65 * v_65 + _S1047 * (r2_65 + 2.0f * v_65 * v_65) + _S1050 * r2_65); - float2 _S1164 = _S1163 + make_float2 (_S1051 * _S1163.x + _S1052 * _S1163.y, 0.0f); - proj_points_2[int(3)] = make_float2 (fx_10 * _S1164.x + cx_7, fy_10 * _S1164.y + cy_7); - break; - } - bool all_valid_10 = _S1063 & (!_S1066); - _S1067 = &proj_points_2[int(4)]; - for(;;) - { - float2 _S1165 = float2 {_S1090.p_0[int(4)].x, _S1090.p_0[int(4)].y}; - float r_22 = length_0(_S1165); - float _S1166 = _S1090.p_0[int(4)].z; - _S1068 = _S1166; - float theta_15 = (F32_atan2((r_22), (_S1166))); - if(r_22 < 9.99999997475242708e-07f) - { - k_5 = (1.0f - theta_15 * theta_15 / 24.0f) / _S1166; - } - else - { - k_5 = 2.0f * (F32_sin((0.5f * theta_15))) / r_22; - } - float2 _S1167 = _S1165 * make_float2 (k_5); - proj_points_2[int(4)] = _S1167; - float u_66 = _S1167.x; - float v_66 = _S1167.y; - float _S1168 = u_66 + u_66; - float r2_66 = u_66 * u_66 + v_66 * v_66; - float _S1169 = _S1045 + r2_66 * _S1046; - float _S1170 = _S1044 + r2_66 * _S1169; - float _S1171 = _S1043 + r2_66 * _S1170; - float radial_24 = 1.0f + r2_66 * _S1171; - float _S1172 = 2.0f * u_66; - float _S1173 = 2.0f * v_66; - float2 _S1174 = _S1042 * make_float2 (radial_24) + make_float2 (_S1168 * _S1171 + (_S1168 * _S1170 + (_S1168 * _S1169 + _S1168 * _S1046 * r2_66) * r2_66) * r2_66) * _S1167 + make_float2 (_S1053 * v_66 + (_S1168 + (_S1172 + _S1172)) * _S1048 + _S1168 * _S1049, _S1054 * v_66 + _S1168 * _S1047 + _S1168 * _S1050); - float _S1175 = v_66 + v_66; - float2 _S1176 = _S1055 * make_float2 (radial_24) + make_float2 (_S1175 * _S1171 + (_S1175 * _S1170 + (_S1175 * _S1169 + _S1175 * _S1046 * r2_66) * r2_66) * r2_66) * _S1167 + make_float2 (_S1053 * u_66 + _S1175 * _S1048 + _S1175 * _S1049, _S1054 * u_66 + (_S1175 + (_S1173 + _S1173)) * _S1047 + _S1175 * _S1050); - Matrix _S1177 = transpose_0(makeMatrix (_S1174 + make_float2 (_S1174.x * _S1051 + _S1174.y * _S1052, 0.0f), _S1176 + make_float2 (_S1176.x * _S1051 + _S1176.y * _S1052, 0.0f))); - bool _S1178 = !((F32_min((determinant_0(_S1177)), ((F32_min((_S1177.rows[int(0)].x), (_S1177.rows[int(1)].y)))))) > 0.0f); - _S1069 = _S1178; - if(_S1178) - { - break; - } - float u_67 = proj_points_2[int(4)].x; - float v_67 = proj_points_2[int(4)].y; - float r2_67 = u_67 * u_67 + v_67 * v_67; - float2 _S1179 = proj_points_2[int(4)] * make_float2 (1.0f + r2_67 * (_S1043 + r2_67 * (_S1044 + r2_67 * (_S1045 + r2_67 * _S1046)))) + make_float2 (_S1053 * u_67 * v_67 + _S1048 * (r2_67 + 2.0f * u_67 * u_67) + _S1049 * r2_67, _S1054 * u_67 * v_67 + _S1047 * (r2_67 + 2.0f * v_67 * v_67) + _S1050 * r2_67); - float2 _S1180 = _S1179 + make_float2 (_S1051 * _S1179.x + _S1052 * _S1179.y, 0.0f); - proj_points_2[int(4)] = make_float2 (fx_10 * _S1180.x + cx_7, fy_10 * _S1180.y + cy_7); - break; - } - bool all_valid_11 = all_valid_10 & (!_S1069); - for(;;) - { - _S1070 = &proj_points_2[int(5)]; - for(;;) - { - float2 _S1181 = float2 {_S1090.p_0[int(5)].x, _S1090.p_0[int(5)].y}; - float r_23 = length_0(_S1181); - float _S1182 = _S1090.p_0[int(5)].z; - _S1071 = _S1182; - float theta_16 = (F32_atan2((r_23), (_S1182))); - if(r_23 < 9.99999997475242708e-07f) - { - k_5 = (1.0f - theta_16 * theta_16 / 24.0f) / _S1182; + FixedArray _S1848 = dist_coeffs_25; + float2 _S1849 = DistThinPrism_distort_0(uv0_22, &_S1848); + _S1818 = (dot_0(uv0_22, _S1849)) >= 0.0f; } else { - k_5 = 2.0f * (F32_sin((0.5f * theta_16))) / r_23; + _S1818 = false; } - float2 _S1183 = _S1181 * make_float2 (k_5); - proj_points_2[int(5)] = _S1183; - float u_68 = _S1183.x; - float v_68 = _S1183.y; - float _S1184 = u_68 + u_68; - float r2_68 = u_68 * u_68 + v_68 * v_68; - float _S1185 = _S1045 + r2_68 * _S1046; - float _S1186 = _S1044 + r2_68 * _S1185; - float _S1187 = _S1043 + r2_68 * _S1186; - float radial_25 = 1.0f + r2_68 * _S1187; - float _S1188 = 2.0f * u_68; - float _S1189 = 2.0f * v_68; - float2 _S1190 = _S1042 * make_float2 (radial_25) + make_float2 (_S1184 * _S1187 + (_S1184 * _S1186 + (_S1184 * _S1185 + _S1184 * _S1046 * r2_68) * r2_68) * r2_68) * _S1183 + make_float2 (_S1053 * v_68 + (_S1184 + (_S1188 + _S1188)) * _S1048 + _S1184 * _S1049, _S1054 * v_68 + _S1184 * _S1047 + _S1184 * _S1050); - float _S1191 = v_68 + v_68; - float2 _S1192 = _S1055 * make_float2 (radial_25) + make_float2 (_S1191 * _S1187 + (_S1191 * _S1186 + (_S1191 * _S1185 + _S1191 * _S1046 * r2_68) * r2_68) * r2_68) * _S1183 + make_float2 (_S1053 * u_68 + _S1191 * _S1048 + _S1191 * _S1049, _S1054 * u_68 + (_S1191 + (_S1189 + _S1189)) * _S1047 + _S1191 * _S1050); - Matrix _S1193 = transpose_0(makeMatrix (_S1190 + make_float2 (_S1190.x * _S1051 + _S1190.y * _S1052, 0.0f), _S1192 + make_float2 (_S1192.x * _S1051 + _S1192.y * _S1052, 0.0f))); - bool _S1194 = !((F32_min((determinant_0(_S1193)), ((F32_min((_S1193.rows[int(0)].x), (_S1193.rows[int(1)].y)))))) > 0.0f); - _S1072 = _S1194; - if(_S1194) - { - break; - } - float u_69 = proj_points_2[int(5)].x; - float v_69 = proj_points_2[int(5)].y; - float r2_69 = u_69 * u_69 + v_69 * v_69; - float2 _S1195 = proj_points_2[int(5)] * make_float2 (1.0f + r2_69 * (_S1043 + r2_69 * (_S1044 + r2_69 * (_S1045 + r2_69 * _S1046)))) + make_float2 (_S1053 * u_69 * v_69 + _S1048 * (r2_69 + 2.0f * u_69 * u_69) + _S1049 * r2_69, _S1054 * u_69 * v_69 + _S1047 * (r2_69 + 2.0f * v_69 * v_69) + _S1050 * r2_69); - float2 _S1196 = _S1195 + make_float2 (_S1051 * _S1195.x + _S1052 * _S1195.y, 0.0f); - proj_points_2[int(5)] = make_float2 (fx_10 * _S1196.x + cx_7, fy_10 * _S1196.y + cy_7); + _S1818 = !_S1818; + } + if(_S1818) + { + proj_points_2[int(0)] = uv0_22; + _S1818 = false; break; } - _S1073 = all_valid_11 & (!_S1072); + float2 uv_26 = _S1836 / make_float2 (_S1837); + FixedArray _S1850 = dist_coeffs_25; + float2 _S1851 = DistThinPrism_distort_0(uv_26, &_S1850); + proj_points_2[int(0)] = make_float2 (fx_26 * _S1851.x + cx_17, fy_26 * _S1851.y + cy_17); + _S1818 = true; break; } - _S1074 = &proj_points_2[int(6)]; + bool all_valid_8 = true & _S1818; + _S1807 = &proj_points_2[int(1)]; for(;;) { - float2 _S1197 = float2 {_S1090.p_0[int(6)].x, _S1090.p_0[int(6)].y}; - float r_24 = length_0(_S1197); - float _S1198 = _S1090.p_0[int(6)].z; - _S1075 = _S1198; - float theta_17 = (F32_atan2((r_24), (_S1198))); - if(r_24 < 9.99999997475242708e-07f) + float2 _S1852 = float2 {_S1829.p_0[int(1)].x, _S1829.p_0[int(1)].y}; + float _S1853 = _S1829.p_0[int(1)].z; + float2 uv0_23 = _S1852 / make_float2 (_S1853); + if(_S1853 < 0.0f) { - k_5 = (1.0f - theta_17 * theta_17 / 24.0f) / _S1198; + _S1818 = true; } else { - k_5 = 2.0f * (F32_sin((0.5f * theta_17))) / r_24; + float2 _S1854 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1855; + (&_S1855)->primal_0 = uv0_23; + (&_S1855)->differential_0 = _S1854; + FixedArray _S1856 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1857 = s_fwd_DistThinPrism_distort_0(&_S1855, &_S1856); + float2 _S1858 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1859; + (&_S1859)->primal_0 = uv0_23; + (&_S1859)->differential_0 = _S1858; + FixedArray _S1860 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1861 = s_fwd_DistThinPrism_distort_0(&_S1859, &_S1860); + Matrix _S1862 = transpose_0(makeMatrix (_S1857.differential_0, _S1861.differential_0)); + float _S1863 = (F32_min((determinant_0(_S1862)), ((F32_min((_S1862.rows[int(0)].x), (_S1862.rows[int(1)].y)))))); + if(_S1863 > 0.25f) + { + _S1818 = _S1863 < 4.0f; + } + else + { + _S1818 = false; + } + if(_S1818) + { + FixedArray _S1864 = dist_coeffs_25; + float2 _S1865 = DistThinPrism_distort_0(uv0_23, &_S1864); + _S1818 = (dot_0(uv0_23, _S1865)) >= 0.0f; + } + else + { + _S1818 = false; + } + _S1818 = !_S1818; } - float2 _S1199 = _S1197 * make_float2 (k_5); - proj_points_2[int(6)] = _S1199; - float u_70 = _S1199.x; - float v_70 = _S1199.y; - float _S1200 = u_70 + u_70; - float r2_70 = u_70 * u_70 + v_70 * v_70; - float _S1201 = _S1045 + r2_70 * _S1046; - float _S1202 = _S1044 + r2_70 * _S1201; - float _S1203 = _S1043 + r2_70 * _S1202; - float radial_26 = 1.0f + r2_70 * _S1203; - float _S1204 = 2.0f * u_70; - float _S1205 = 2.0f * v_70; - float2 _S1206 = _S1042 * make_float2 (radial_26) + make_float2 (_S1200 * _S1203 + (_S1200 * _S1202 + (_S1200 * _S1201 + _S1200 * _S1046 * r2_70) * r2_70) * r2_70) * _S1199 + make_float2 (_S1053 * v_70 + (_S1200 + (_S1204 + _S1204)) * _S1048 + _S1200 * _S1049, _S1054 * v_70 + _S1200 * _S1047 + _S1200 * _S1050); - float _S1207 = v_70 + v_70; - float2 _S1208 = _S1055 * make_float2 (radial_26) + make_float2 (_S1207 * _S1203 + (_S1207 * _S1202 + (_S1207 * _S1201 + _S1207 * _S1046 * r2_70) * r2_70) * r2_70) * _S1199 + make_float2 (_S1053 * u_70 + _S1207 * _S1048 + _S1207 * _S1049, _S1054 * u_70 + (_S1207 + (_S1205 + _S1205)) * _S1047 + _S1207 * _S1050); - Matrix _S1209 = transpose_0(makeMatrix (_S1206 + make_float2 (_S1206.x * _S1051 + _S1206.y * _S1052, 0.0f), _S1208 + make_float2 (_S1208.x * _S1051 + _S1208.y * _S1052, 0.0f))); - bool _S1210 = !((F32_min((determinant_0(_S1209)), ((F32_min((_S1209.rows[int(0)].x), (_S1209.rows[int(1)].y)))))) > 0.0f); - _S1076 = _S1210; - if(_S1210) + if(_S1818) { + proj_points_2[int(1)] = uv0_23; + _S1818 = false; break; } - float u_71 = proj_points_2[int(6)].x; - float v_71 = proj_points_2[int(6)].y; - float r2_71 = u_71 * u_71 + v_71 * v_71; - float2 _S1211 = proj_points_2[int(6)] * make_float2 (1.0f + r2_71 * (_S1043 + r2_71 * (_S1044 + r2_71 * (_S1045 + r2_71 * _S1046)))) + make_float2 (_S1053 * u_71 * v_71 + _S1048 * (r2_71 + 2.0f * u_71 * u_71) + _S1049 * r2_71, _S1054 * u_71 * v_71 + _S1047 * (r2_71 + 2.0f * v_71 * v_71) + _S1050 * r2_71); - float2 _S1212 = _S1211 + make_float2 (_S1051 * _S1211.x + _S1052 * _S1211.y, 0.0f); - proj_points_2[int(6)] = make_float2 (fx_10 * _S1212.x + cx_7, fy_10 * _S1212.y + cy_7); + float2 uv_27 = _S1852 / make_float2 (_S1853); + FixedArray _S1866 = dist_coeffs_25; + float2 _S1867 = DistThinPrism_distort_0(uv_27, &_S1866); + proj_points_2[int(1)] = make_float2 (fx_26 * _S1867.x + cx_17, fy_26 * _S1867.y + cy_17); + _S1818 = true; break; } - _S1077 = _S1073 & (!_S1076); + bool all_valid_9 = all_valid_8 & _S1818; + for(;;) + { + _S1808 = &proj_points_2[int(2)]; + for(;;) + { + float2 _S1868 = float2 {_S1829.p_0[int(2)].x, _S1829.p_0[int(2)].y}; + float _S1869 = _S1829.p_0[int(2)].z; + float2 uv0_24 = _S1868 / make_float2 (_S1869); + if(_S1869 < 0.0f) + { + _S1818 = true; + } + else + { + float2 _S1870 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1871; + (&_S1871)->primal_0 = uv0_24; + (&_S1871)->differential_0 = _S1870; + FixedArray _S1872 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1873 = s_fwd_DistThinPrism_distort_0(&_S1871, &_S1872); + float2 _S1874 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1875; + (&_S1875)->primal_0 = uv0_24; + (&_S1875)->differential_0 = _S1874; + FixedArray _S1876 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1877 = s_fwd_DistThinPrism_distort_0(&_S1875, &_S1876); + Matrix _S1878 = transpose_0(makeMatrix (_S1873.differential_0, _S1877.differential_0)); + float _S1879 = (F32_min((determinant_0(_S1878)), ((F32_min((_S1878.rows[int(0)].x), (_S1878.rows[int(1)].y)))))); + if(_S1879 > 0.25f) + { + _S1818 = _S1879 < 4.0f; + } + else + { + _S1818 = false; + } + if(_S1818) + { + FixedArray _S1880 = dist_coeffs_25; + float2 _S1881 = DistThinPrism_distort_0(uv0_24, &_S1880); + _S1818 = (dot_0(uv0_24, _S1881)) >= 0.0f; + } + else + { + _S1818 = false; + } + _S1818 = !_S1818; + } + if(_S1818) + { + proj_points_2[int(2)] = uv0_24; + _S1818 = false; + break; + } + float2 uv_28 = _S1868 / make_float2 (_S1869); + FixedArray _S1882 = dist_coeffs_25; + float2 _S1883 = DistThinPrism_distort_0(uv_28, &_S1882); + proj_points_2[int(2)] = make_float2 (fx_26 * _S1883.x + cx_17, fy_26 * _S1883.y + cy_17); + _S1818 = true; + break; + } + _S1809 = all_valid_9 & _S1818; + break; + } + _S1810 = &proj_points_2[int(3)]; + for(;;) + { + float2 _S1884 = float2 {_S1829.p_0[int(3)].x, _S1829.p_0[int(3)].y}; + float _S1885 = _S1829.p_0[int(3)].z; + float2 uv0_25 = _S1884 / make_float2 (_S1885); + if(_S1885 < 0.0f) + { + _S1818 = true; + } + else + { + float2 _S1886 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1887; + (&_S1887)->primal_0 = uv0_25; + (&_S1887)->differential_0 = _S1886; + FixedArray _S1888 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1889 = s_fwd_DistThinPrism_distort_0(&_S1887, &_S1888); + float2 _S1890 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1891; + (&_S1891)->primal_0 = uv0_25; + (&_S1891)->differential_0 = _S1890; + FixedArray _S1892 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1893 = s_fwd_DistThinPrism_distort_0(&_S1891, &_S1892); + Matrix _S1894 = transpose_0(makeMatrix (_S1889.differential_0, _S1893.differential_0)); + float _S1895 = (F32_min((determinant_0(_S1894)), ((F32_min((_S1894.rows[int(0)].x), (_S1894.rows[int(1)].y)))))); + if(_S1895 > 0.25f) + { + _S1818 = _S1895 < 4.0f; + } + else + { + _S1818 = false; + } + if(_S1818) + { + FixedArray _S1896 = dist_coeffs_25; + float2 _S1897 = DistThinPrism_distort_0(uv0_25, &_S1896); + _S1818 = (dot_0(uv0_25, _S1897)) >= 0.0f; + } + else + { + _S1818 = false; + } + _S1818 = !_S1818; + } + if(_S1818) + { + proj_points_2[int(3)] = uv0_25; + _S1818 = false; + break; + } + float2 uv_29 = _S1884 / make_float2 (_S1885); + FixedArray _S1898 = dist_coeffs_25; + float2 _S1899 = DistThinPrism_distort_0(uv_29, &_S1898); + proj_points_2[int(3)] = make_float2 (fx_26 * _S1899.x + cx_17, fy_26 * _S1899.y + cy_17); + _S1818 = true; + break; + } + bool all_valid_10 = _S1809 & _S1818; + _S1811 = &proj_points_2[int(4)]; + for(;;) + { + float2 _S1900 = float2 {_S1829.p_0[int(4)].x, _S1829.p_0[int(4)].y}; + float _S1901 = _S1829.p_0[int(4)].z; + float2 uv0_26 = _S1900 / make_float2 (_S1901); + if(_S1901 < 0.0f) + { + _S1818 = true; + } + else + { + float2 _S1902 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1903; + (&_S1903)->primal_0 = uv0_26; + (&_S1903)->differential_0 = _S1902; + FixedArray _S1904 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1905 = s_fwd_DistThinPrism_distort_0(&_S1903, &_S1904); + float2 _S1906 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1907; + (&_S1907)->primal_0 = uv0_26; + (&_S1907)->differential_0 = _S1906; + FixedArray _S1908 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1909 = s_fwd_DistThinPrism_distort_0(&_S1907, &_S1908); + Matrix _S1910 = transpose_0(makeMatrix (_S1905.differential_0, _S1909.differential_0)); + float _S1911 = (F32_min((determinant_0(_S1910)), ((F32_min((_S1910.rows[int(0)].x), (_S1910.rows[int(1)].y)))))); + if(_S1911 > 0.25f) + { + _S1818 = _S1911 < 4.0f; + } + else + { + _S1818 = false; + } + if(_S1818) + { + FixedArray _S1912 = dist_coeffs_25; + float2 _S1913 = DistThinPrism_distort_0(uv0_26, &_S1912); + _S1818 = (dot_0(uv0_26, _S1913)) >= 0.0f; + } + else + { + _S1818 = false; + } + _S1818 = !_S1818; + } + if(_S1818) + { + proj_points_2[int(4)] = uv0_26; + _S1818 = false; + break; + } + float2 uv_30 = _S1900 / make_float2 (_S1901); + FixedArray _S1914 = dist_coeffs_25; + float2 _S1915 = DistThinPrism_distort_0(uv_30, &_S1914); + proj_points_2[int(4)] = make_float2 (fx_26 * _S1915.x + cx_17, fy_26 * _S1915.y + cy_17); + _S1818 = true; + break; + } + bool all_valid_11 = all_valid_10 & _S1818; + for(;;) + { + _S1812 = &proj_points_2[int(5)]; + for(;;) + { + float2 _S1916 = float2 {_S1829.p_0[int(5)].x, _S1829.p_0[int(5)].y}; + float _S1917 = _S1829.p_0[int(5)].z; + float2 uv0_27 = _S1916 / make_float2 (_S1917); + if(_S1917 < 0.0f) + { + _S1818 = true; + } + else + { + float2 _S1918 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1919; + (&_S1919)->primal_0 = uv0_27; + (&_S1919)->differential_0 = _S1918; + FixedArray _S1920 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1921 = s_fwd_DistThinPrism_distort_0(&_S1919, &_S1920); + float2 _S1922 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1923; + (&_S1923)->primal_0 = uv0_27; + (&_S1923)->differential_0 = _S1922; + FixedArray _S1924 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1925 = s_fwd_DistThinPrism_distort_0(&_S1923, &_S1924); + Matrix _S1926 = transpose_0(makeMatrix (_S1921.differential_0, _S1925.differential_0)); + float _S1927 = (F32_min((determinant_0(_S1926)), ((F32_min((_S1926.rows[int(0)].x), (_S1926.rows[int(1)].y)))))); + if(_S1927 > 0.25f) + { + _S1818 = _S1927 < 4.0f; + } + else + { + _S1818 = false; + } + if(_S1818) + { + FixedArray _S1928 = dist_coeffs_25; + float2 _S1929 = DistThinPrism_distort_0(uv0_27, &_S1928); + _S1818 = (dot_0(uv0_27, _S1929)) >= 0.0f; + } + else + { + _S1818 = false; + } + _S1818 = !_S1818; + } + if(_S1818) + { + proj_points_2[int(5)] = uv0_27; + _S1818 = false; + break; + } + float2 uv_31 = _S1916 / make_float2 (_S1917); + FixedArray _S1930 = dist_coeffs_25; + float2 _S1931 = DistThinPrism_distort_0(uv_31, &_S1930); + proj_points_2[int(5)] = make_float2 (fx_26 * _S1931.x + cx_17, fy_26 * _S1931.y + cy_17); + _S1818 = true; + break; + } + _S1813 = all_valid_11 & _S1818; + break; + } + _S1814 = &proj_points_2[int(6)]; + for(;;) + { + float2 _S1932 = float2 {_S1829.p_0[int(6)].x, _S1829.p_0[int(6)].y}; + float _S1933 = _S1829.p_0[int(6)].z; + float2 uv0_28 = _S1932 / make_float2 (_S1933); + if(_S1933 < 0.0f) + { + _S1818 = true; + } + else + { + float2 _S1934 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1935; + (&_S1935)->primal_0 = uv0_28; + (&_S1935)->differential_0 = _S1934; + FixedArray _S1936 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1937 = s_fwd_DistThinPrism_distort_0(&_S1935, &_S1936); + float2 _S1938 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1939; + (&_S1939)->primal_0 = uv0_28; + (&_S1939)->differential_0 = _S1938; + FixedArray _S1940 = dist_coeffs_25; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S1941 = s_fwd_DistThinPrism_distort_0(&_S1939, &_S1940); + Matrix _S1942 = transpose_0(makeMatrix (_S1937.differential_0, _S1941.differential_0)); + float _S1943 = (F32_min((determinant_0(_S1942)), ((F32_min((_S1942.rows[int(0)].x), (_S1942.rows[int(1)].y)))))); + if(_S1943 > 0.25f) + { + _S1818 = _S1943 < 4.0f; + } + else + { + _S1818 = false; + } + if(_S1818) + { + FixedArray _S1944 = dist_coeffs_25; + float2 _S1945 = DistThinPrism_distort_0(uv0_28, &_S1944); + _S1818 = (dot_0(uv0_28, _S1945)) >= 0.0f; + } + else + { + _S1818 = false; + } + _S1818 = !_S1818; + } + if(_S1818) + { + proj_points_2[int(6)] = uv0_28; + _S1818 = false; + break; + } + float2 uv_32 = _S1932 / make_float2 (_S1933); + FixedArray _S1946 = dist_coeffs_25; + float2 _S1947 = DistThinPrism_distort_0(uv_32, &_S1946); + proj_points_2[int(6)] = make_float2 (fx_26 * _S1947.x + cx_17, fy_26 * _S1947.y + cy_17); + _S1818 = true; + break; + } + _S1815 = _S1813 & _S1818; break; } - if(!_S1077) + if(!_S1815) { - _S1079 = false; + _S1818 = false; break; } - float2 p_7 = *_S1040 + (*_S1057 - *_S1040) * make_float2 (3.32899999618530273f); - float2 p_8 = *_S1040 + (*_S1060 - *_S1040) * make_float2 (3.32899999618530273f); - float2 p_9 = *_S1040 + (*_S1064 - *_S1040) * make_float2 (3.32899999618530273f); - float2 p_10 = *_S1040 + (*_S1067 - *_S1040) * make_float2 (3.32899999618530273f); - float2 p_11 = *_S1040 + (*_S1070 - *_S1040) * make_float2 (3.32899999618530273f); - float2 p_12 = *_S1040 + (*_S1074 - *_S1040) * make_float2 (3.32899999618530273f); - float2 _S1213 = make_float2 (cx_7, cy_7); - float2 min_p_1 = min_0(min_0(min_0(min_0(min_0(min_0(*_S1040, p_7), p_8), p_9), p_10), p_11), p_12) - _S1213; - float2 max_p_1 = max_0(max_0(max_0(max_0(max_0(max_0(*_S1040, p_7), p_8), p_9), p_10), p_11), p_12) - _S1213; - if((F32_max(((F32_max(((F32_max(((F32_max(((F32_max(((F32_max((_S1041), (_S1058)))), (_S1061)))), (_S1065)))), (_S1068)))), (_S1071)))), (_S1075))) <= 0.0f) - { - _S1079 = (min_p_1.x * max_p_1.x) < 0.0f; - } - else - { - _S1079 = false; - } - if(_S1079) - { - _S1079 = (min_p_1.y * max_p_1.y) < 0.0f; - } - else - { - _S1079 = false; - } - if(_S1079) - { - _S1079 = false; - break; - } - float2 _S1214 = *mean2d_10 + make_float2 (_S1090.w_mean_0[int(0)]) * *_S1040 + make_float2 (_S1090.w_mean_0[int(1)]) * *_S1057 + make_float2 (_S1090.w_mean_0[int(2)]) * *_S1060 + make_float2 (_S1090.w_mean_0[int(3)]) * *_S1064 + make_float2 (_S1090.w_mean_0[int(4)]) * *_S1067 + make_float2 (_S1090.w_mean_0[int(5)]) * *_S1070 + make_float2 (_S1090.w_mean_0[int(6)]) * *_S1074; - *mean2d_10 = _S1214; - float2 d_14 = *_S1040 - _S1214; - float _S1215 = d_14.x; - float _S1216 = d_14.y; - float _S1217 = _S1215 * _S1216; - float2 d_15 = *_S1057 - _S1214; - float _S1218 = d_15.x; - float _S1219 = d_15.y; - float _S1220 = _S1218 * _S1219; - float2 d_16 = *_S1060 - _S1214; - float _S1221 = d_16.x; - float _S1222 = d_16.y; - float _S1223 = _S1221 * _S1222; - float2 d_17 = *_S1064 - _S1214; - float _S1224 = d_17.x; - float _S1225 = d_17.y; - float _S1226 = _S1224 * _S1225; - float2 d_18 = *_S1067 - _S1214; - float _S1227 = d_18.x; - float _S1228 = d_18.y; - float _S1229 = _S1227 * _S1228; - float2 d_19 = *_S1070 - _S1214; - float _S1230 = d_19.x; - float _S1231 = d_19.y; - float _S1232 = _S1230 * _S1231; - float2 d_20 = *_S1074 - _S1214; - float _S1233 = d_20.x; - float _S1234 = d_20.y; - float _S1235 = _S1233 * _S1234; - covar2d_6 = covar2d_6 + makeMatrix (_S1090.w_cov_0[int(0)]) * makeMatrix (_S1215 * _S1215, _S1217, _S1217, _S1216 * _S1216) + makeMatrix (_S1090.w_cov_0[int(1)]) * makeMatrix (_S1218 * _S1218, _S1220, _S1220, _S1219 * _S1219) + makeMatrix (_S1090.w_cov_0[int(2)]) * makeMatrix (_S1221 * _S1221, _S1223, _S1223, _S1222 * _S1222) + makeMatrix (_S1090.w_cov_0[int(3)]) * makeMatrix (_S1224 * _S1224, _S1226, _S1226, _S1225 * _S1225) + makeMatrix (_S1090.w_cov_0[int(4)]) * makeMatrix (_S1227 * _S1227, _S1229, _S1229, _S1228 * _S1228) + makeMatrix (_S1090.w_cov_0[int(5)]) * makeMatrix (_S1230 * _S1230, _S1232, _S1232, _S1231 * _S1231) + makeMatrix (_S1090.w_cov_0[int(6)]) * makeMatrix (_S1233 * _S1233, _S1235, _S1235, _S1234 * _S1234); - _S1079 = true; + float2 _S1948 = *mean2d_26 + make_float2 (_S1829.w_mean_0[int(0)]) * *_S1806 + make_float2 (_S1829.w_mean_0[int(1)]) * *_S1807 + make_float2 (_S1829.w_mean_0[int(2)]) * *_S1808 + make_float2 (_S1829.w_mean_0[int(3)]) * *_S1810 + make_float2 (_S1829.w_mean_0[int(4)]) * *_S1811 + make_float2 (_S1829.w_mean_0[int(5)]) * *_S1812 + make_float2 (_S1829.w_mean_0[int(6)]) * *_S1814; + *mean2d_26 = _S1948; + float _S1949 = - _S1834; + float _S1950 = - _S1835; + float2 _S1951 = make_float2 (clamp_0(_S1948.x, _S1949, lim_x_pos_10), clamp_0(_S1948.y, _S1950, lim_y_pos_2)); + float2 d_14 = make_float2 (clamp_0((*_S1806).x, _S1949, lim_x_pos_10), clamp_0((*_S1806).y, _S1950, lim_y_pos_2)) - _S1951; + float _S1952 = d_14.x; + float _S1953 = d_14.y; + float _S1954 = _S1952 * _S1953; + float2 d_15 = make_float2 (clamp_0((*_S1807).x, _S1949, lim_x_pos_10), clamp_0((*_S1807).y, _S1950, lim_y_pos_2)) - _S1951; + float _S1955 = d_15.x; + float _S1956 = d_15.y; + float _S1957 = _S1955 * _S1956; + float2 d_16 = make_float2 (clamp_0((*_S1808).x, _S1949, lim_x_pos_10), clamp_0((*_S1808).y, _S1950, lim_y_pos_2)) - _S1951; + float _S1958 = d_16.x; + float _S1959 = d_16.y; + float _S1960 = _S1958 * _S1959; + float2 d_17 = make_float2 (clamp_0((*_S1810).x, _S1949, lim_x_pos_10), clamp_0((*_S1810).y, _S1950, lim_y_pos_2)) - _S1951; + float _S1961 = d_17.x; + float _S1962 = d_17.y; + float _S1963 = _S1961 * _S1962; + float2 d_18 = make_float2 (clamp_0((*_S1811).x, _S1949, lim_x_pos_10), clamp_0((*_S1811).y, _S1950, lim_y_pos_2)) - _S1951; + float _S1964 = d_18.x; + float _S1965 = d_18.y; + float _S1966 = _S1964 * _S1965; + float2 d_19 = make_float2 (clamp_0((*_S1812).x, _S1949, lim_x_pos_10), clamp_0((*_S1812).y, _S1950, lim_y_pos_2)) - _S1951; + float _S1967 = d_19.x; + float _S1968 = d_19.y; + float _S1969 = _S1967 * _S1968; + float2 d_20 = make_float2 (clamp_0((*_S1814).x, _S1949, lim_x_pos_10), clamp_0((*_S1814).y, _S1950, lim_y_pos_2)) - _S1951; + float _S1970 = d_20.x; + float _S1971 = d_20.y; + float _S1972 = _S1970 * _S1971; + covar2d_13 = covar2d_13 + makeMatrix (_S1829.w_cov_0[int(0)]) * makeMatrix (_S1952 * _S1952, _S1954, _S1954, _S1953 * _S1953) + makeMatrix (_S1829.w_cov_0[int(1)]) * makeMatrix (_S1955 * _S1955, _S1957, _S1957, _S1956 * _S1956) + makeMatrix (_S1829.w_cov_0[int(2)]) * makeMatrix (_S1958 * _S1958, _S1960, _S1960, _S1959 * _S1959) + makeMatrix (_S1829.w_cov_0[int(3)]) * makeMatrix (_S1961 * _S1961, _S1963, _S1963, _S1962 * _S1962) + makeMatrix (_S1829.w_cov_0[int(4)]) * makeMatrix (_S1964 * _S1964, _S1966, _S1966, _S1965 * _S1965) + makeMatrix (_S1829.w_cov_0[int(5)]) * makeMatrix (_S1967 * _S1967, _S1969, _S1969, _S1968 * _S1968) + makeMatrix (_S1829.w_cov_0[int(6)]) * makeMatrix (_S1970 * _S1970, _S1972, _S1972, _S1971 * _S1971); + _S1818 = true; break; } - if(!(true & _S1079)) + if(!(true & _S1818)) { - *aabb_xyxy_6 = make_float4 (0.0f); + *aabb_xyxy_13 = _S1816; break; } - float eps2d_6; - if(antialiased_6) + float eps2d_13; + if(antialiased_13) { - eps2d_6 = 0.10000000149011612f; + eps2d_13 = 0.10000000149011612f; } else { - eps2d_6 = 0.30000001192092896f; + eps2d_13 = 0.30000001192092896f; } - float det_orig_6 = *&(((&covar2d_6)->rows + (int(0)))->x) * *&(((&covar2d_6)->rows + (int(1)))->y) - *&(((&covar2d_6)->rows + (int(0)))->y) * *&(((&covar2d_6)->rows + (int(1)))->x); - float _S1236 = *&(((&covar2d_6)->rows + (int(0)))->x) + eps2d_6; - *&(((&covar2d_6)->rows + (int(0)))->x) = _S1236; - float _S1237 = *&(((&covar2d_6)->rows + (int(1)))->y) + eps2d_6; - *&(((&covar2d_6)->rows + (int(1)))->y) = _S1237; - float det_blur_6 = _S1236 * _S1237 - *&(((&covar2d_6)->rows + (int(0)))->y) * *&(((&covar2d_6)->rows + (int(1)))->x); - float compensation_6 = (F32_sqrt(((F32_max((0.0f), (det_orig_6 / det_blur_6)))))); - if(det_blur_6 <= 0.0f) + float det_orig_13 = *&(((&covar2d_13)->rows + (int(0)))->x) * *&(((&covar2d_13)->rows + (int(1)))->y) - *&(((&covar2d_13)->rows + (int(0)))->y) * *&(((&covar2d_13)->rows + (int(1)))->x); + float _S1973 = *&(((&covar2d_13)->rows + (int(0)))->x) + eps2d_13; + *&(((&covar2d_13)->rows + (int(0)))->x) = _S1973; + float _S1974 = *&(((&covar2d_13)->rows + (int(1)))->y) + eps2d_13; + *&(((&covar2d_13)->rows + (int(1)))->y) = _S1974; + float det_blur_13 = _S1973 * _S1974 - *&(((&covar2d_13)->rows + (int(0)))->y) * *&(((&covar2d_13)->rows + (int(1)))->x); + float compensation_13 = (F32_sqrt(((F32_max((0.0f), (det_orig_13 / det_blur_13)))))); + if(det_blur_13 <= 0.0f) { - *aabb_xyxy_6 = make_float4 (0.0f); + *aabb_xyxy_13 = _S1816; break; } - float invdet_8 = 1.0f / (covar2d_6.rows[int(0)].x * covar2d_6.rows[int(1)].y - covar2d_6.rows[int(0)].y * covar2d_6.rows[int(1)].x); - Matrix _S1238 = makeMatrix (covar2d_6.rows[int(1)].y * invdet_8, - covar2d_6.rows[int(0)].y * invdet_8, - covar2d_6.rows[int(1)].x * invdet_8, covar2d_6.rows[int(0)].x * invdet_8); - if(antialiased_6) + float invdet_19 = 1.0f / (covar2d_13.rows[int(0)].x * covar2d_13.rows[int(1)].y - covar2d_13.rows[int(0)].y * covar2d_13.rows[int(1)].x); + Matrix _S1975 = makeMatrix (covar2d_13.rows[int(1)].y * invdet_19, - covar2d_13.rows[int(0)].y * invdet_19, - covar2d_13.rows[int(1)].x * invdet_19, covar2d_13.rows[int(0)].x * invdet_19); + if(antialiased_13) { - *opacity_6 = *opacity_6 * compensation_6; + *opacity_13 = *opacity_13 * compensation_13; } - if((*opacity_6) < 0.00392156885936856f) + if((*opacity_13) < 0.00392156885936856f) { - *aabb_xyxy_6 = make_float4 (0.0f); + *aabb_xyxy_13 = _S1816; break; } - float _S1239 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_6 / 0.00392156885936856f))))))))); - float radius_x_6 = _S1239 * (F32_sqrt((covar2d_6[int(0)].x))); - float radius_y_6 = _S1239 * (F32_sqrt((covar2d_6[int(1)].y))); - float _S1240 = (*mean2d_10).x - radius_x_6; - float _S1241 = (*mean2d_10).x + radius_x_6; - float _S1242 = (*mean2d_10).y - radius_y_6; - float _S1243 = (*mean2d_10).y + radius_y_6; - if(_S1241 <= 0.0f) + float _S1976 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_13 / 0.00392156885936856f))))))))); + float radius_x_13 = _S1976 * (F32_sqrt((covar2d_13[int(0)].x))); + float radius_y_13 = _S1976 * (F32_sqrt((covar2d_13[int(1)].y))); + float _S1977 = (*mean2d_26).x - radius_x_13; + float _S1978 = (*mean2d_26).x + radius_x_13; + float _S1979 = (*mean2d_26).y - radius_y_13; + float _S1980 = (*mean2d_26).y + radius_y_13; + if(_S1978 <= 0.0f) { - _S1079 = true; + _S1818 = true; } else { - _S1079 = _S1240 >= float(image_width_6); + _S1818 = _S1977 >= _S1804; } - if(_S1079) + if(_S1818) { - _S1079 = true; + _S1818 = true; } else { - _S1079 = _S1243 <= 0.0f; + _S1818 = _S1980 <= 0.0f; } - if(_S1079) + if(_S1818) { - _S1079 = true; + _S1818 = true; } else { - _S1079 = _S1242 >= float(image_height_6); + _S1818 = _S1979 >= _S1805; } - if(_S1079) + if(_S1818) { - *aabb_xyxy_6 = make_float4 (0.0f); + *aabb_xyxy_13 = _S1816; break; } - *aabb_xyxy_6 = make_float4 (_S1240, _S1242, _S1241, _S1243); - float x_25 = mean_c_6.x; - float y_8 = mean_c_6.y; - float z_1 = mean_c_6.z; - float _S1244 = x_25 * x_25 + y_8 * y_8; - *sorting_depth_6 = z_1 * z_1 * z_1 * z_1 + 0.001953125f * _S1244 * _S1244; - *conic_6 = make_float3 (_S1238.rows[int(0)].x, _S1238.rows[int(0)].y, _S1238.rows[int(1)].y); - *radius_7 = view_radius_3dgs_0(mean_7, scale_6, in_opacity_6, - mul_6(transpose_3(R_6), t_6)); + *aabb_xyxy_13 = make_float4 (_S1977, _S1979, _S1978, _S1980); + *sorting_depth_13 = _S1817; + *conic_13 = make_float3 (_S1975.rows[int(0)].x, _S1975.rows[int(0)].y, _S1975.rows[int(1)].y); + *radius_14 = view_radius_3dgs_0(mean_14, scale_13, in_opacity_13, - mul_6(transpose_3(R_13), t_13)); break; } return; } -inline __device__ void projection_3dgut_equirect(bool antialiased_7, float3 mean_8, float4 quat_7, float3 scale_7, float in_opacity_7, Matrix R_7, float3 t_7, float fx_11, float fy_11, float cx_8, float cy_8, FixedArray dist_coeffs_11, uint image_width_7, uint image_height_7, float4 * aabb_xyxy_7, float * sorting_depth_7, float * radius_8, float2 * mean2d_11, float * depth_7, float3 * conic_7, float * opacity_7) +inline __device__ void projection_3dgut_persp_rational(bool antialiased_14, float3 mean_15, float4 quat_14, float3 scale_14, float in_opacity_14, Matrix R_14, float3 t_14, float fx_27, float fy_27, float cx_18, float cy_18, FixedArray dist_coeffs_26, uint image_width_14, uint image_height_14, float4 * aabb_xyxy_14, float * sorting_depth_14, float * radius_15, float2 * mean2d_27, float * depth_14, float3 * conic_14, float * opacity_14) { + float _S1981; + float _S1982; + float2 * _S1983; + float2 * _S1984; + float2 * _S1985; + bool _S1986; + float2 * _S1987; + float2 * _S1988; + float2 * _S1989; + bool _S1990; + float2 * _S1991; + bool _S1992; for(;;) { - float3 mean_c_7 = mul_6(R_7, mean_8) + t_7; - float _S1245 = length_1(mean_c_7); - *depth_7 = _S1245; - if(_S1245 <= 0.0f) + float4 _S1993 = make_float4 (0.0f); + *aabb_xyxy_14 = _S1993; + *sorting_depth_14 = 0.0f; + *radius_15 = 0.0f; + *mean2d_27 = make_float2 (0.0f); + *conic_14 = make_float3 (0.0f); + *opacity_14 = 0.0f; + float3 mean_c_14 = mul_6(R_14, mean_15) + t_14; + float _S1994 = mean_c_14.z; + *depth_14 = length_1(mean_c_14); + if(_S1994 <= 0.0f) { - *aabb_xyxy_7 = make_float4 (0.0f); + *aabb_xyxy_14 = _S1993; break; } - Matrix covar2d_7; - *opacity_7 = 1.0f / (1.0f + (F32_exp((- in_opacity_7)))); - float3 _S1246 = exp_0(scale_7); - float4 _S1247 = normalize_0(quat_7); - float x_26 = _S1247.y; - float x2_7 = x_26 * x_26; - float y2_7 = _S1247.z * _S1247.z; - float z2_7 = _S1247.w * _S1247.w; - float xy_7 = _S1247.y * _S1247.z; - float xz_7 = _S1247.y * _S1247.w; - float yz_7 = _S1247.z * _S1247.w; - float wx_7 = _S1247.x * _S1247.y; - float wy_7 = _S1247.x * _S1247.z; - float wz_7 = _S1247.x * _S1247.w; - Matrix _S1248 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_7 + z2_7), 2.0f * (xy_7 + wz_7), 2.0f * (xz_7 - wy_7), 2.0f * (xy_7 - wz_7), 1.0f - 2.0f * (x2_7 + z2_7), 2.0f * (yz_7 + wx_7), 2.0f * (xz_7 + wy_7), 2.0f * (yz_7 - wx_7), 1.0f - 2.0f * (x2_7 + y2_7)))); + Matrix covar2d_14; + *opacity_14 = 1.0f / (1.0f + (F32_exp((- in_opacity_14)))); + bool _S1995; + float3 _S1996 = exp_0(scale_14); + float4 _S1997 = normalize_0(quat_14); + float x_35 = _S1997.y; + float x2_14 = x_35 * x_35; + float y2_14 = _S1997.z * _S1997.z; + float z2_14 = _S1997.w * _S1997.w; + float xy_14 = _S1997.y * _S1997.z; + float xz_14 = _S1997.y * _S1997.w; + float yz_14 = _S1997.z * _S1997.w; + float wx_14 = _S1997.x * _S1997.y; + float wy_14 = _S1997.x * _S1997.z; + float wz_14 = _S1997.x * _S1997.w; + Matrix _S1998 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_14 + z2_14), 2.0f * (xy_14 + wz_14), 2.0f * (xz_14 - wy_14), 2.0f * (xy_14 - wz_14), 1.0f - 2.0f * (x2_14 + z2_14), 2.0f * (yz_14 + wx_14), 2.0f * (xz_14 + wy_14), 2.0f * (yz_14 - wx_14), 1.0f - 2.0f * (x2_14 + y2_14)))); SigmaPoints_0 ret_3; - (&ret_3)->p_0[int(0)] = mean_8; + (&ret_3)->p_0[int(0)] = mean_15; (&ret_3)->w_mean_0[int(0)] = 0.0f; (&ret_3)->w_cov_0[int(0)] = 2.0f; - float _S1249 = (F32_sqrt((3.0f))); - float3 delta_9 = make_float3 (_S1249 * _S1246.x) * _S1248.rows[0U]; - float3 _S1250 = mean_8 + delta_9; - float3 _S1251 = mean_8 - delta_9; - float3 delta_10 = make_float3 (_S1249 * _S1246.y) * _S1248.rows[1U]; - float3 _S1252 = mean_8 + delta_10; - float3 _S1253 = mean_8 - delta_10; - float3 delta_11 = make_float3 (_S1249 * _S1246.z) * _S1248.rows[2U]; - float3 _S1254 = mean_8 + delta_11; - float3 _S1255 = mean_8 - delta_11; + float _S1999 = (F32_sqrt((3.0f))); + float3 delta_9 = make_float3 (_S1999 * _S1996.x) * _S1998.rows[0U]; + float3 _S2000 = mean_15 + delta_9; + float3 _S2001 = mean_15 - delta_9; + float3 delta_10 = make_float3 (_S1999 * _S1996.y) * _S1998.rows[1U]; + float3 _S2002 = mean_15 + delta_10; + float3 _S2003 = mean_15 - delta_10; + float3 delta_11 = make_float3 (_S1999 * _S1996.z) * _S1998.rows[2U]; + float3 _S2004 = mean_15 + delta_11; + float3 _S2005 = mean_15 - delta_11; (&ret_3)->w_mean_0[1U] = 0.1666666716337204f; (&ret_3)->w_cov_0[1U] = 0.1666666716337204f; (&ret_3)->w_mean_0[2U] = 0.1666666716337204f; @@ -4666,377 +7954,4759 @@ inline __device__ void projection_3dgut_equirect(bool antialiased_7, float3 mea (&ret_3)->w_cov_0[5U] = 0.1666666716337204f; (&ret_3)->w_mean_0[6U] = 0.1666666716337204f; (&ret_3)->w_cov_0[6U] = 0.1666666716337204f; - (&ret_3)->p_0[0U] = mul_6(R_7, (&ret_3)->p_0[0U]) + t_7; - (&ret_3)->p_0[1U] = mul_6(R_7, _S1250) + t_7; - (&ret_3)->p_0[2U] = mul_6(R_7, _S1252) + t_7; - (&ret_3)->p_0[3U] = mul_6(R_7, _S1254) + t_7; - (&ret_3)->p_0[4U] = mul_6(R_7, _S1251) + t_7; - (&ret_3)->p_0[5U] = mul_6(R_7, _S1253) + t_7; - (&ret_3)->p_0[6U] = mul_6(R_7, _S1255) + t_7; - FixedArray proj_points_3; - float _S1256 = fx_11 * (F32_atan2((ret_3.p_0[int(0)].x), (ret_3.p_0[int(0)].z))) + cx_8; - float2 _S1257 = make_float2 (_S1256, fy_11 * (F32_atan2((ret_3.p_0[int(0)].y), (length_0(float2 {ret_3.p_0[int(0)].x, ret_3.p_0[int(0)].z})))) + cy_8); - proj_points_3[int(0)] = _S1257; - float _S1258 = fx_11 * (F32_atan2((ret_3.p_0[int(1)].x), (ret_3.p_0[int(1)].z))) + cx_8; - proj_points_3[int(1)] = make_float2 (_S1258, fy_11 * (F32_atan2((ret_3.p_0[int(1)].y), (length_0(float2 {ret_3.p_0[int(1)].x, ret_3.p_0[int(1)].z})))) + cy_8); - float _S1259 = fx_11 * (F32_atan2((ret_3.p_0[int(2)].x), (ret_3.p_0[int(2)].z))) + cx_8; - proj_points_3[int(2)] = make_float2 (_S1259, fy_11 * (F32_atan2((ret_3.p_0[int(2)].y), (length_0(float2 {ret_3.p_0[int(2)].x, ret_3.p_0[int(2)].z})))) + cy_8); - float _S1260 = fx_11 * (F32_atan2((ret_3.p_0[int(3)].x), (ret_3.p_0[int(3)].z))) + cx_8; - proj_points_3[int(3)] = make_float2 (_S1260, fy_11 * (F32_atan2((ret_3.p_0[int(3)].y), (length_0(float2 {ret_3.p_0[int(3)].x, ret_3.p_0[int(3)].z})))) + cy_8); - float _S1261 = fx_11 * (F32_atan2((ret_3.p_0[int(4)].x), (ret_3.p_0[int(4)].z))) + cx_8; - proj_points_3[int(4)] = make_float2 (_S1261, fy_11 * (F32_atan2((ret_3.p_0[int(4)].y), (length_0(float2 {ret_3.p_0[int(4)].x, ret_3.p_0[int(4)].z})))) + cy_8); - float _S1262 = fx_11 * (F32_atan2((ret_3.p_0[int(5)].x), (ret_3.p_0[int(5)].z))) + cx_8; - proj_points_3[int(5)] = make_float2 (_S1262, fy_11 * (F32_atan2((ret_3.p_0[int(5)].y), (length_0(float2 {ret_3.p_0[int(5)].x, ret_3.p_0[int(5)].z})))) + cy_8); - float _S1263 = fx_11 * (F32_atan2((ret_3.p_0[int(6)].x), (ret_3.p_0[int(6)].z))) + cx_8; - proj_points_3[int(6)] = make_float2 (_S1263, fy_11 * (F32_atan2((ret_3.p_0[int(6)].y), (length_0(float2 {ret_3.p_0[int(6)].x, ret_3.p_0[int(6)].z})))) + cy_8); - float _S1264 = fx_11 * 6.28318548202514648f; - float du_0 = _S1258 - _S1256; - *&((&proj_points_3[int(1)])->x) = _S1256 + (du_0 - _S1264 * (F32_round((du_0 / _S1264)))); - float du_1 = _S1259 - _S1256; - *&((&proj_points_3[int(2)])->x) = _S1256 + (du_1 - _S1264 * (F32_round((du_1 / _S1264)))); - float du_2 = _S1260 - _S1256; - *&((&proj_points_3[int(3)])->x) = _S1256 + (du_2 - _S1264 * (F32_round((du_2 / _S1264)))); - float du_3 = _S1261 - _S1256; - *&((&proj_points_3[int(4)])->x) = _S1256 + (du_3 - _S1264 * (F32_round((du_3 / _S1264)))); - float du_4 = _S1262 - _S1256; - *&((&proj_points_3[int(5)])->x) = _S1256 + (du_4 - _S1264 * (F32_round((du_4 / _S1264)))); - float du_5 = _S1263 - _S1256; - *&((&proj_points_3[int(6)])->x) = _S1256 + (du_5 - _S1264 * (F32_round((du_5 / _S1264)))); - float2 _S1265 = make_float2 (ret_3.w_mean_0[int(0)]) * _S1257 + make_float2 (ret_3.w_mean_0[int(1)]) * proj_points_3[int(1)] + make_float2 (ret_3.w_mean_0[int(2)]) * proj_points_3[int(2)] + make_float2 (ret_3.w_mean_0[int(3)]) * proj_points_3[int(3)] + make_float2 (ret_3.w_mean_0[int(4)]) * proj_points_3[int(4)] + make_float2 (ret_3.w_mean_0[int(5)]) * proj_points_3[int(5)] + make_float2 (ret_3.w_mean_0[int(6)]) * proj_points_3[int(6)]; - *mean2d_11 = _S1265; - float2 d_21 = _S1257 - _S1265; - float _S1266 = d_21.x; - float _S1267 = d_21.y; - float _S1268 = _S1266 * _S1267; - float2 d_22 = proj_points_3[int(1)] - _S1265; - float _S1269 = d_22.x; - float _S1270 = d_22.y; - float _S1271 = _S1269 * _S1270; - float2 d_23 = proj_points_3[int(2)] - _S1265; - float _S1272 = d_23.x; - float _S1273 = d_23.y; - float _S1274 = _S1272 * _S1273; - float2 d_24 = proj_points_3[int(3)] - _S1265; - float _S1275 = d_24.x; - float _S1276 = d_24.y; - float _S1277 = _S1275 * _S1276; - float2 d_25 = proj_points_3[int(4)] - _S1265; - float _S1278 = d_25.x; - float _S1279 = d_25.y; - float _S1280 = _S1278 * _S1279; - float2 d_26 = proj_points_3[int(5)] - _S1265; - float _S1281 = d_26.x; - float _S1282 = d_26.y; - float _S1283 = _S1281 * _S1282; - float2 d_27 = proj_points_3[int(6)] - _S1265; - float _S1284 = d_27.x; - float _S1285 = d_27.y; - float _S1286 = _S1284 * _S1285; - covar2d_7 = makeMatrix (ret_3.w_cov_0[int(0)]) * makeMatrix (_S1266 * _S1266, _S1268, _S1268, _S1267 * _S1267) + makeMatrix (ret_3.w_cov_0[int(1)]) * makeMatrix (_S1269 * _S1269, _S1271, _S1271, _S1270 * _S1270) + makeMatrix (ret_3.w_cov_0[int(2)]) * makeMatrix (_S1272 * _S1272, _S1274, _S1274, _S1273 * _S1273) + makeMatrix (ret_3.w_cov_0[int(3)]) * makeMatrix (_S1275 * _S1275, _S1277, _S1277, _S1276 * _S1276) + makeMatrix (ret_3.w_cov_0[int(4)]) * makeMatrix (_S1278 * _S1278, _S1280, _S1280, _S1279 * _S1279) + makeMatrix (ret_3.w_cov_0[int(5)]) * makeMatrix (_S1281 * _S1281, _S1283, _S1283, _S1282 * _S1282) + makeMatrix (ret_3.w_cov_0[int(6)]) * makeMatrix (_S1284 * _S1284, _S1286, _S1286, _S1285 * _S1285); - float eps2d_7; - if(antialiased_7) + (&ret_3)->p_0[0U] = mul_6(R_14, (&ret_3)->p_0[0U]) + t_14; + (&ret_3)->p_0[1U] = mul_6(R_14, _S2000) + t_14; + (&ret_3)->p_0[2U] = mul_6(R_14, _S2002) + t_14; + (&ret_3)->p_0[3U] = mul_6(R_14, _S2004) + t_14; + (&ret_3)->p_0[4U] = mul_6(R_14, _S2001) + t_14; + (&ret_3)->p_0[5U] = mul_6(R_14, _S2003) + t_14; + (&ret_3)->p_0[6U] = mul_6(R_14, _S2005) + t_14; + SigmaPoints_0 _S2006 = ret_3; + for(;;) { - eps2d_7 = 0.10000000149011612f; - } - else - { - eps2d_7 = 0.30000001192092896f; - } - float det_orig_7 = *&(((&covar2d_7)->rows + (int(0)))->x) * *&(((&covar2d_7)->rows + (int(1)))->y) - *&(((&covar2d_7)->rows + (int(0)))->y) * *&(((&covar2d_7)->rows + (int(1)))->x); - float _S1287 = *&(((&covar2d_7)->rows + (int(0)))->x) + eps2d_7; - *&(((&covar2d_7)->rows + (int(0)))->x) = _S1287; - float _S1288 = *&(((&covar2d_7)->rows + (int(1)))->y) + eps2d_7; - *&(((&covar2d_7)->rows + (int(1)))->y) = _S1288; - float det_blur_7 = _S1287 * _S1288 - *&(((&covar2d_7)->rows + (int(0)))->y) * *&(((&covar2d_7)->rows + (int(1)))->x); - float compensation_7 = (F32_sqrt(((F32_max((0.0f), (det_orig_7 / det_blur_7)))))); - if(det_blur_7 <= 0.0f) - { - *aabb_xyxy_7 = make_float4 (0.0f); + int2 _S2007 = make_int2 (int(0)); + float2 _S2008 = make_float2 ((float)_S2007.x, (float)_S2007.y); + *mean2d_27 = _S2008; + covar2d_14 = makeMatrix (0.0f); + float _S2009 = float(image_width_14); + _S1981 = _S2009; + float tan_fovx_3 = 0.5f * _S2009 / fx_27; + float _S2010 = float(image_height_14); + _S1982 = _S2010; + float _S2011 = 0.30000001192092896f * tan_fovx_3 * fx_27; + float lim_x_pos_11 = _S2009 + _S2011; + float _S2012 = 0.30000001192092896f * (0.5f * _S2010 / fy_27) * fy_27; + float lim_y_pos_3 = _S2010 + _S2012; + FixedArray proj_points_3; + for(;;) + { + _S1983 = &proj_points_3[int(0)]; + for(;;) + { + float2 _S2013 = float2 {_S2006.p_0[int(0)].x, _S2006.p_0[int(0)].y}; + float _S2014 = _S2006.p_0[int(0)].z; + float2 uv0_29 = _S2013 / make_float2 (_S2014); + if(_S2014 < 0.0f) + { + _S1995 = true; + } + else + { + float2 _S2015 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2016; + (&_S2016)->primal_0 = uv0_29; + (&_S2016)->differential_0 = _S2015; + FixedArray _S2017 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2018 = s_fwd_DistRational_distort_0(&_S2016, &_S2017); + float2 _S2019 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2020; + (&_S2020)->primal_0 = uv0_29; + (&_S2020)->differential_0 = _S2019; + FixedArray _S2021 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2022 = s_fwd_DistRational_distort_0(&_S2020, &_S2021); + Matrix _S2023 = transpose_0(makeMatrix (_S2018.differential_0, _S2022.differential_0)); + float _S2024 = (F32_min((determinant_0(_S2023)), ((F32_min((_S2023.rows[int(0)].x), (_S2023.rows[int(1)].y)))))); + if(_S2024 > 0.25f) + { + _S1995 = _S2024 < 4.0f; + } + else + { + _S1995 = false; + } + if(_S1995) + { + FixedArray _S2025 = dist_coeffs_26; + float2 _S2026 = DistRational_distort_0(uv0_29, &_S2025); + _S1995 = (dot_0(uv0_29, _S2026)) >= 0.0f; + } + else + { + _S1995 = false; + } + _S1995 = !_S1995; + } + if(_S1995) + { + proj_points_3[int(0)] = uv0_29; + _S1995 = false; + break; + } + float2 uv_33 = _S2013 / make_float2 (_S2014); + FixedArray _S2027 = dist_coeffs_26; + float2 _S2028 = DistRational_distort_0(uv_33, &_S2027); + proj_points_3[int(0)] = make_float2 (fx_27 * _S2028.x + cx_18, fy_27 * _S2028.y + cy_18); + _S1995 = true; + break; + } + bool all_valid_12 = true & _S1995; + _S1984 = &proj_points_3[int(1)]; + for(;;) + { + float2 _S2029 = float2 {_S2006.p_0[int(1)].x, _S2006.p_0[int(1)].y}; + float _S2030 = _S2006.p_0[int(1)].z; + float2 uv0_30 = _S2029 / make_float2 (_S2030); + if(_S2030 < 0.0f) + { + _S1995 = true; + } + else + { + float2 _S2031 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2032; + (&_S2032)->primal_0 = uv0_30; + (&_S2032)->differential_0 = _S2031; + FixedArray _S2033 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2034 = s_fwd_DistRational_distort_0(&_S2032, &_S2033); + float2 _S2035 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2036; + (&_S2036)->primal_0 = uv0_30; + (&_S2036)->differential_0 = _S2035; + FixedArray _S2037 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2038 = s_fwd_DistRational_distort_0(&_S2036, &_S2037); + Matrix _S2039 = transpose_0(makeMatrix (_S2034.differential_0, _S2038.differential_0)); + float _S2040 = (F32_min((determinant_0(_S2039)), ((F32_min((_S2039.rows[int(0)].x), (_S2039.rows[int(1)].y)))))); + if(_S2040 > 0.25f) + { + _S1995 = _S2040 < 4.0f; + } + else + { + _S1995 = false; + } + if(_S1995) + { + FixedArray _S2041 = dist_coeffs_26; + float2 _S2042 = DistRational_distort_0(uv0_30, &_S2041); + _S1995 = (dot_0(uv0_30, _S2042)) >= 0.0f; + } + else + { + _S1995 = false; + } + _S1995 = !_S1995; + } + if(_S1995) + { + proj_points_3[int(1)] = uv0_30; + _S1995 = false; + break; + } + float2 uv_34 = _S2029 / make_float2 (_S2030); + FixedArray _S2043 = dist_coeffs_26; + float2 _S2044 = DistRational_distort_0(uv_34, &_S2043); + proj_points_3[int(1)] = make_float2 (fx_27 * _S2044.x + cx_18, fy_27 * _S2044.y + cy_18); + _S1995 = true; + break; + } + bool all_valid_13 = all_valid_12 & _S1995; + for(;;) + { + _S1985 = &proj_points_3[int(2)]; + for(;;) + { + float2 _S2045 = float2 {_S2006.p_0[int(2)].x, _S2006.p_0[int(2)].y}; + float _S2046 = _S2006.p_0[int(2)].z; + float2 uv0_31 = _S2045 / make_float2 (_S2046); + if(_S2046 < 0.0f) + { + _S1995 = true; + } + else + { + float2 _S2047 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2048; + (&_S2048)->primal_0 = uv0_31; + (&_S2048)->differential_0 = _S2047; + FixedArray _S2049 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2050 = s_fwd_DistRational_distort_0(&_S2048, &_S2049); + float2 _S2051 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2052; + (&_S2052)->primal_0 = uv0_31; + (&_S2052)->differential_0 = _S2051; + FixedArray _S2053 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2054 = s_fwd_DistRational_distort_0(&_S2052, &_S2053); + Matrix _S2055 = transpose_0(makeMatrix (_S2050.differential_0, _S2054.differential_0)); + float _S2056 = (F32_min((determinant_0(_S2055)), ((F32_min((_S2055.rows[int(0)].x), (_S2055.rows[int(1)].y)))))); + if(_S2056 > 0.25f) + { + _S1995 = _S2056 < 4.0f; + } + else + { + _S1995 = false; + } + if(_S1995) + { + FixedArray _S2057 = dist_coeffs_26; + float2 _S2058 = DistRational_distort_0(uv0_31, &_S2057); + _S1995 = (dot_0(uv0_31, _S2058)) >= 0.0f; + } + else + { + _S1995 = false; + } + _S1995 = !_S1995; + } + if(_S1995) + { + proj_points_3[int(2)] = uv0_31; + _S1995 = false; + break; + } + float2 uv_35 = _S2045 / make_float2 (_S2046); + FixedArray _S2059 = dist_coeffs_26; + float2 _S2060 = DistRational_distort_0(uv_35, &_S2059); + proj_points_3[int(2)] = make_float2 (fx_27 * _S2060.x + cx_18, fy_27 * _S2060.y + cy_18); + _S1995 = true; + break; + } + _S1986 = all_valid_13 & _S1995; + break; + } + _S1987 = &proj_points_3[int(3)]; + for(;;) + { + float2 _S2061 = float2 {_S2006.p_0[int(3)].x, _S2006.p_0[int(3)].y}; + float _S2062 = _S2006.p_0[int(3)].z; + float2 uv0_32 = _S2061 / make_float2 (_S2062); + if(_S2062 < 0.0f) + { + _S1995 = true; + } + else + { + float2 _S2063 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2064; + (&_S2064)->primal_0 = uv0_32; + (&_S2064)->differential_0 = _S2063; + FixedArray _S2065 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2066 = s_fwd_DistRational_distort_0(&_S2064, &_S2065); + float2 _S2067 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2068; + (&_S2068)->primal_0 = uv0_32; + (&_S2068)->differential_0 = _S2067; + FixedArray _S2069 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2070 = s_fwd_DistRational_distort_0(&_S2068, &_S2069); + Matrix _S2071 = transpose_0(makeMatrix (_S2066.differential_0, _S2070.differential_0)); + float _S2072 = (F32_min((determinant_0(_S2071)), ((F32_min((_S2071.rows[int(0)].x), (_S2071.rows[int(1)].y)))))); + if(_S2072 > 0.25f) + { + _S1995 = _S2072 < 4.0f; + } + else + { + _S1995 = false; + } + if(_S1995) + { + FixedArray _S2073 = dist_coeffs_26; + float2 _S2074 = DistRational_distort_0(uv0_32, &_S2073); + _S1995 = (dot_0(uv0_32, _S2074)) >= 0.0f; + } + else + { + _S1995 = false; + } + _S1995 = !_S1995; + } + if(_S1995) + { + proj_points_3[int(3)] = uv0_32; + _S1995 = false; + break; + } + float2 uv_36 = _S2061 / make_float2 (_S2062); + FixedArray _S2075 = dist_coeffs_26; + float2 _S2076 = DistRational_distort_0(uv_36, &_S2075); + proj_points_3[int(3)] = make_float2 (fx_27 * _S2076.x + cx_18, fy_27 * _S2076.y + cy_18); + _S1995 = true; + break; + } + bool all_valid_14 = _S1986 & _S1995; + _S1988 = &proj_points_3[int(4)]; + for(;;) + { + float2 _S2077 = float2 {_S2006.p_0[int(4)].x, _S2006.p_0[int(4)].y}; + float _S2078 = _S2006.p_0[int(4)].z; + float2 uv0_33 = _S2077 / make_float2 (_S2078); + if(_S2078 < 0.0f) + { + _S1995 = true; + } + else + { + float2 _S2079 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2080; + (&_S2080)->primal_0 = uv0_33; + (&_S2080)->differential_0 = _S2079; + FixedArray _S2081 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2082 = s_fwd_DistRational_distort_0(&_S2080, &_S2081); + float2 _S2083 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2084; + (&_S2084)->primal_0 = uv0_33; + (&_S2084)->differential_0 = _S2083; + FixedArray _S2085 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2086 = s_fwd_DistRational_distort_0(&_S2084, &_S2085); + Matrix _S2087 = transpose_0(makeMatrix (_S2082.differential_0, _S2086.differential_0)); + float _S2088 = (F32_min((determinant_0(_S2087)), ((F32_min((_S2087.rows[int(0)].x), (_S2087.rows[int(1)].y)))))); + if(_S2088 > 0.25f) + { + _S1995 = _S2088 < 4.0f; + } + else + { + _S1995 = false; + } + if(_S1995) + { + FixedArray _S2089 = dist_coeffs_26; + float2 _S2090 = DistRational_distort_0(uv0_33, &_S2089); + _S1995 = (dot_0(uv0_33, _S2090)) >= 0.0f; + } + else + { + _S1995 = false; + } + _S1995 = !_S1995; + } + if(_S1995) + { + proj_points_3[int(4)] = uv0_33; + _S1995 = false; + break; + } + float2 uv_37 = _S2077 / make_float2 (_S2078); + FixedArray _S2091 = dist_coeffs_26; + float2 _S2092 = DistRational_distort_0(uv_37, &_S2091); + proj_points_3[int(4)] = make_float2 (fx_27 * _S2092.x + cx_18, fy_27 * _S2092.y + cy_18); + _S1995 = true; + break; + } + bool all_valid_15 = all_valid_14 & _S1995; + for(;;) + { + _S1989 = &proj_points_3[int(5)]; + for(;;) + { + float2 _S2093 = float2 {_S2006.p_0[int(5)].x, _S2006.p_0[int(5)].y}; + float _S2094 = _S2006.p_0[int(5)].z; + float2 uv0_34 = _S2093 / make_float2 (_S2094); + if(_S2094 < 0.0f) + { + _S1995 = true; + } + else + { + float2 _S2095 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2096; + (&_S2096)->primal_0 = uv0_34; + (&_S2096)->differential_0 = _S2095; + FixedArray _S2097 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2098 = s_fwd_DistRational_distort_0(&_S2096, &_S2097); + float2 _S2099 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2100; + (&_S2100)->primal_0 = uv0_34; + (&_S2100)->differential_0 = _S2099; + FixedArray _S2101 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2102 = s_fwd_DistRational_distort_0(&_S2100, &_S2101); + Matrix _S2103 = transpose_0(makeMatrix (_S2098.differential_0, _S2102.differential_0)); + float _S2104 = (F32_min((determinant_0(_S2103)), ((F32_min((_S2103.rows[int(0)].x), (_S2103.rows[int(1)].y)))))); + if(_S2104 > 0.25f) + { + _S1995 = _S2104 < 4.0f; + } + else + { + _S1995 = false; + } + if(_S1995) + { + FixedArray _S2105 = dist_coeffs_26; + float2 _S2106 = DistRational_distort_0(uv0_34, &_S2105); + _S1995 = (dot_0(uv0_34, _S2106)) >= 0.0f; + } + else + { + _S1995 = false; + } + _S1995 = !_S1995; + } + if(_S1995) + { + proj_points_3[int(5)] = uv0_34; + _S1995 = false; + break; + } + float2 uv_38 = _S2093 / make_float2 (_S2094); + FixedArray _S2107 = dist_coeffs_26; + float2 _S2108 = DistRational_distort_0(uv_38, &_S2107); + proj_points_3[int(5)] = make_float2 (fx_27 * _S2108.x + cx_18, fy_27 * _S2108.y + cy_18); + _S1995 = true; + break; + } + _S1990 = all_valid_15 & _S1995; + break; + } + _S1991 = &proj_points_3[int(6)]; + for(;;) + { + float2 _S2109 = float2 {_S2006.p_0[int(6)].x, _S2006.p_0[int(6)].y}; + float _S2110 = _S2006.p_0[int(6)].z; + float2 uv0_35 = _S2109 / make_float2 (_S2110); + if(_S2110 < 0.0f) + { + _S1995 = true; + } + else + { + float2 _S2111 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2112; + (&_S2112)->primal_0 = uv0_35; + (&_S2112)->differential_0 = _S2111; + FixedArray _S2113 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2114 = s_fwd_DistRational_distort_0(&_S2112, &_S2113); + float2 _S2115 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2116; + (&_S2116)->primal_0 = uv0_35; + (&_S2116)->differential_0 = _S2115; + FixedArray _S2117 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2118 = s_fwd_DistRational_distort_0(&_S2116, &_S2117); + Matrix _S2119 = transpose_0(makeMatrix (_S2114.differential_0, _S2118.differential_0)); + float _S2120 = (F32_min((determinant_0(_S2119)), ((F32_min((_S2119.rows[int(0)].x), (_S2119.rows[int(1)].y)))))); + if(_S2120 > 0.25f) + { + _S1995 = _S2120 < 4.0f; + } + else + { + _S1995 = false; + } + if(_S1995) + { + FixedArray _S2121 = dist_coeffs_26; + float2 _S2122 = DistRational_distort_0(uv0_35, &_S2121); + _S1995 = (dot_0(uv0_35, _S2122)) >= 0.0f; + } + else + { + _S1995 = false; + } + _S1995 = !_S1995; + } + if(_S1995) + { + proj_points_3[int(6)] = uv0_35; + _S1995 = false; + break; + } + float2 uv_39 = _S2109 / make_float2 (_S2110); + FixedArray _S2123 = dist_coeffs_26; + float2 _S2124 = DistRational_distort_0(uv_39, &_S2123); + proj_points_3[int(6)] = make_float2 (fx_27 * _S2124.x + cx_18, fy_27 * _S2124.y + cy_18); + _S1995 = true; + break; + } + _S1992 = _S1990 & _S1995; + break; + } + if(!_S1992) + { + _S1995 = false; + break; + } + float2 _S2125 = *mean2d_27 + make_float2 (_S2006.w_mean_0[int(0)]) * *_S1983 + make_float2 (_S2006.w_mean_0[int(1)]) * *_S1984 + make_float2 (_S2006.w_mean_0[int(2)]) * *_S1985 + make_float2 (_S2006.w_mean_0[int(3)]) * *_S1987 + make_float2 (_S2006.w_mean_0[int(4)]) * *_S1988 + make_float2 (_S2006.w_mean_0[int(5)]) * *_S1989 + make_float2 (_S2006.w_mean_0[int(6)]) * *_S1991; + *mean2d_27 = _S2125; + float _S2126 = - _S2011; + float _S2127 = - _S2012; + float2 _S2128 = make_float2 (clamp_0(_S2125.x, _S2126, lim_x_pos_11), clamp_0(_S2125.y, _S2127, lim_y_pos_3)); + float2 d_21 = make_float2 (clamp_0((*_S1983).x, _S2126, lim_x_pos_11), clamp_0((*_S1983).y, _S2127, lim_y_pos_3)) - _S2128; + float _S2129 = d_21.x; + float _S2130 = d_21.y; + float _S2131 = _S2129 * _S2130; + float2 d_22 = make_float2 (clamp_0((*_S1984).x, _S2126, lim_x_pos_11), clamp_0((*_S1984).y, _S2127, lim_y_pos_3)) - _S2128; + float _S2132 = d_22.x; + float _S2133 = d_22.y; + float _S2134 = _S2132 * _S2133; + float2 d_23 = make_float2 (clamp_0((*_S1985).x, _S2126, lim_x_pos_11), clamp_0((*_S1985).y, _S2127, lim_y_pos_3)) - _S2128; + float _S2135 = d_23.x; + float _S2136 = d_23.y; + float _S2137 = _S2135 * _S2136; + float2 d_24 = make_float2 (clamp_0((*_S1987).x, _S2126, lim_x_pos_11), clamp_0((*_S1987).y, _S2127, lim_y_pos_3)) - _S2128; + float _S2138 = d_24.x; + float _S2139 = d_24.y; + float _S2140 = _S2138 * _S2139; + float2 d_25 = make_float2 (clamp_0((*_S1988).x, _S2126, lim_x_pos_11), clamp_0((*_S1988).y, _S2127, lim_y_pos_3)) - _S2128; + float _S2141 = d_25.x; + float _S2142 = d_25.y; + float _S2143 = _S2141 * _S2142; + float2 d_26 = make_float2 (clamp_0((*_S1989).x, _S2126, lim_x_pos_11), clamp_0((*_S1989).y, _S2127, lim_y_pos_3)) - _S2128; + float _S2144 = d_26.x; + float _S2145 = d_26.y; + float _S2146 = _S2144 * _S2145; + float2 d_27 = make_float2 (clamp_0((*_S1991).x, _S2126, lim_x_pos_11), clamp_0((*_S1991).y, _S2127, lim_y_pos_3)) - _S2128; + float _S2147 = d_27.x; + float _S2148 = d_27.y; + float _S2149 = _S2147 * _S2148; + covar2d_14 = covar2d_14 + makeMatrix (_S2006.w_cov_0[int(0)]) * makeMatrix (_S2129 * _S2129, _S2131, _S2131, _S2130 * _S2130) + makeMatrix (_S2006.w_cov_0[int(1)]) * makeMatrix (_S2132 * _S2132, _S2134, _S2134, _S2133 * _S2133) + makeMatrix (_S2006.w_cov_0[int(2)]) * makeMatrix (_S2135 * _S2135, _S2137, _S2137, _S2136 * _S2136) + makeMatrix (_S2006.w_cov_0[int(3)]) * makeMatrix (_S2138 * _S2138, _S2140, _S2140, _S2139 * _S2139) + makeMatrix (_S2006.w_cov_0[int(4)]) * makeMatrix (_S2141 * _S2141, _S2143, _S2143, _S2142 * _S2142) + makeMatrix (_S2006.w_cov_0[int(5)]) * makeMatrix (_S2144 * _S2144, _S2146, _S2146, _S2145 * _S2145) + makeMatrix (_S2006.w_cov_0[int(6)]) * makeMatrix (_S2147 * _S2147, _S2149, _S2149, _S2148 * _S2148); + _S1995 = true; break; } - float invdet_9 = 1.0f / (covar2d_7.rows[int(0)].x * covar2d_7.rows[int(1)].y - covar2d_7.rows[int(0)].y * covar2d_7.rows[int(1)].x); - Matrix _S1289 = makeMatrix (covar2d_7.rows[int(1)].y * invdet_9, - covar2d_7.rows[int(0)].y * invdet_9, - covar2d_7.rows[int(1)].x * invdet_9, covar2d_7.rows[int(0)].x * invdet_9); - if(antialiased_7) + if(!(true & _S1995)) { - *opacity_7 = *opacity_7 * compensation_7; - } - if((*opacity_7) < 0.00392156885936856f) - { - *aabb_xyxy_7 = make_float4 (0.0f); + *aabb_xyxy_14 = _S1993; break; } - float _S1290 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_7 / 0.00392156885936856f))))))))); - float radius_x_7 = _S1290 * (F32_sqrt((covar2d_7[int(0)].x))); - float radius_y_7 = _S1290 * (F32_sqrt((covar2d_7[int(1)].y))); - float _S1291 = (*mean2d_11).x - radius_x_7; - float _S1292 = (*mean2d_11).x + radius_x_7; - float _S1293 = (*mean2d_11).y - radius_y_7; - float _S1294 = (*mean2d_11).y + radius_y_7; - bool _S1295; - if(_S1292 <= 0.0f) + float eps2d_14; + if(antialiased_14) { - _S1295 = true; + eps2d_14 = 0.10000000149011612f; } else { - _S1295 = _S1291 >= float(image_width_7); + eps2d_14 = 0.30000001192092896f; } - if(_S1295) + float det_orig_14 = *&(((&covar2d_14)->rows + (int(0)))->x) * *&(((&covar2d_14)->rows + (int(1)))->y) - *&(((&covar2d_14)->rows + (int(0)))->y) * *&(((&covar2d_14)->rows + (int(1)))->x); + float _S2150 = *&(((&covar2d_14)->rows + (int(0)))->x) + eps2d_14; + *&(((&covar2d_14)->rows + (int(0)))->x) = _S2150; + float _S2151 = *&(((&covar2d_14)->rows + (int(1)))->y) + eps2d_14; + *&(((&covar2d_14)->rows + (int(1)))->y) = _S2151; + float det_blur_14 = _S2150 * _S2151 - *&(((&covar2d_14)->rows + (int(0)))->y) * *&(((&covar2d_14)->rows + (int(1)))->x); + float compensation_14 = (F32_sqrt(((F32_max((0.0f), (det_orig_14 / det_blur_14)))))); + if(det_blur_14 <= 0.0f) { - _S1295 = true; - } - else - { - _S1295 = _S1294 <= 0.0f; - } - if(_S1295) - { - _S1295 = true; - } - else - { - _S1295 = _S1293 >= float(image_height_7); - } - if(_S1295) - { - *aabb_xyxy_7 = make_float4 (0.0f); + *aabb_xyxy_14 = _S1993; break; } - *aabb_xyxy_7 = make_float4 (_S1291, _S1293, _S1292, _S1294); - *sorting_depth_7 = dot_1(mean_c_7, mean_c_7); - *conic_7 = make_float3 (_S1289.rows[int(0)].x, _S1289.rows[int(0)].y, _S1289.rows[int(1)].y); - *radius_8 = view_radius_3dgs_0(mean_8, scale_7, in_opacity_7, - mul_6(transpose_3(R_7), t_7)); + float invdet_20 = 1.0f / (covar2d_14.rows[int(0)].x * covar2d_14.rows[int(1)].y - covar2d_14.rows[int(0)].y * covar2d_14.rows[int(1)].x); + Matrix _S2152 = makeMatrix (covar2d_14.rows[int(1)].y * invdet_20, - covar2d_14.rows[int(0)].y * invdet_20, - covar2d_14.rows[int(1)].x * invdet_20, covar2d_14.rows[int(0)].x * invdet_20); + if(antialiased_14) + { + *opacity_14 = *opacity_14 * compensation_14; + } + if((*opacity_14) < 0.00392156885936856f) + { + *aabb_xyxy_14 = _S1993; + break; + } + float _S2153 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_14 / 0.00392156885936856f))))))))); + float radius_x_14 = _S2153 * (F32_sqrt((covar2d_14[int(0)].x))); + float radius_y_14 = _S2153 * (F32_sqrt((covar2d_14[int(1)].y))); + float _S2154 = (*mean2d_27).x - radius_x_14; + float _S2155 = (*mean2d_27).x + radius_x_14; + float _S2156 = (*mean2d_27).y - radius_y_14; + float _S2157 = (*mean2d_27).y + radius_y_14; + if(_S2155 <= 0.0f) + { + _S1995 = true; + } + else + { + _S1995 = _S2154 >= _S1981; + } + if(_S1995) + { + _S1995 = true; + } + else + { + _S1995 = _S2157 <= 0.0f; + } + if(_S1995) + { + _S1995 = true; + } + else + { + _S1995 = _S2156 >= _S1982; + } + if(_S1995) + { + *aabb_xyxy_14 = _S1993; + break; + } + *aabb_xyxy_14 = make_float4 (_S2154, _S2156, _S2155, _S2157); + *sorting_depth_14 = _S1994; + *conic_14 = make_float3 (_S2152.rows[int(0)].x, _S2152.rows[int(0)].y, _S2152.rows[int(1)].y); + *radius_15 = view_radius_3dgs_0(mean_15, scale_14, in_opacity_14, - mul_6(transpose_3(R_14), t_14)); break; } return; } -inline __device__ float3 s_primal_ctx_mul_0(Matrix _S1296, float3 _S1297) +inline __device__ void projection_3dgut_fisheye_none(bool antialiased_15, float3 mean_16, float4 quat_15, float3 scale_15, float in_opacity_15, Matrix R_15, float3 t_15, float fx_28, float fy_28, float cx_19, float cy_19, FixedArray dist_coeffs_27, uint image_width_15, uint image_height_15, float4 * aabb_xyxy_15, float * sorting_depth_15, float * radius_16, float2 * mean2d_28, float * depth_15, float3 * conic_15, float * opacity_15) { - return mul_6(_S1296, _S1297); + for(;;) + { + float4 _S2158 = make_float4 (0.0f); + *aabb_xyxy_15 = _S2158; + *sorting_depth_15 = 0.0f; + *radius_16 = 0.0f; + *mean2d_28 = make_float2 (0.0f); + *conic_15 = make_float3 (0.0f); + *opacity_15 = 0.0f; + float3 mean_c_15 = mul_6(R_15, mean_16) + t_15; + float _S2159 = length_1(mean_c_15); + *depth_15 = _S2159; + if(_S2159 <= 0.0f) + { + *aabb_xyxy_15 = _S2158; + break; + } + Matrix covar2d_15; + *opacity_15 = 1.0f / (1.0f + (F32_exp((- in_opacity_15)))); + bool _S2160; + float3 _S2161 = exp_0(scale_15); + float4 _S2162 = normalize_0(quat_15); + float x_36 = _S2162.y; + float x2_15 = x_36 * x_36; + float y2_15 = _S2162.z * _S2162.z; + float z2_15 = _S2162.w * _S2162.w; + float xy_15 = _S2162.y * _S2162.z; + float xz_15 = _S2162.y * _S2162.w; + float yz_15 = _S2162.z * _S2162.w; + float wx_15 = _S2162.x * _S2162.y; + float wy_15 = _S2162.x * _S2162.z; + float wz_15 = _S2162.x * _S2162.w; + Matrix _S2163 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_15 + z2_15), 2.0f * (xy_15 + wz_15), 2.0f * (xz_15 - wy_15), 2.0f * (xy_15 - wz_15), 1.0f - 2.0f * (x2_15 + z2_15), 2.0f * (yz_15 + wx_15), 2.0f * (xz_15 + wy_15), 2.0f * (yz_15 - wx_15), 1.0f - 2.0f * (x2_15 + y2_15)))); + SigmaPoints_0 ret_4; + (&ret_4)->p_0[int(0)] = mean_16; + (&ret_4)->w_mean_0[int(0)] = 0.0f; + (&ret_4)->w_cov_0[int(0)] = 2.0f; + float _S2164 = (F32_sqrt((3.0f))); + float3 delta_12 = make_float3 (_S2164 * _S2161.x) * _S2163.rows[0U]; + float3 _S2165 = mean_16 + delta_12; + float3 _S2166 = mean_16 - delta_12; + float3 delta_13 = make_float3 (_S2164 * _S2161.y) * _S2163.rows[1U]; + float3 _S2167 = mean_16 + delta_13; + float3 _S2168 = mean_16 - delta_13; + float3 delta_14 = make_float3 (_S2164 * _S2161.z) * _S2163.rows[2U]; + float3 _S2169 = mean_16 + delta_14; + float3 _S2170 = mean_16 - delta_14; + (&ret_4)->w_mean_0[1U] = 0.1666666716337204f; + (&ret_4)->w_cov_0[1U] = 0.1666666716337204f; + (&ret_4)->w_mean_0[2U] = 0.1666666716337204f; + (&ret_4)->w_cov_0[2U] = 0.1666666716337204f; + (&ret_4)->w_mean_0[3U] = 0.1666666716337204f; + (&ret_4)->w_cov_0[3U] = 0.1666666716337204f; + (&ret_4)->w_mean_0[4U] = 0.1666666716337204f; + (&ret_4)->w_cov_0[4U] = 0.1666666716337204f; + (&ret_4)->w_mean_0[5U] = 0.1666666716337204f; + (&ret_4)->w_cov_0[5U] = 0.1666666716337204f; + (&ret_4)->w_mean_0[6U] = 0.1666666716337204f; + (&ret_4)->w_cov_0[6U] = 0.1666666716337204f; + (&ret_4)->p_0[0U] = mul_6(R_15, (&ret_4)->p_0[0U]) + t_15; + (&ret_4)->p_0[1U] = mul_6(R_15, _S2165) + t_15; + (&ret_4)->p_0[2U] = mul_6(R_15, _S2167) + t_15; + (&ret_4)->p_0[3U] = mul_6(R_15, _S2169) + t_15; + (&ret_4)->p_0[4U] = mul_6(R_15, _S2166) + t_15; + (&ret_4)->p_0[5U] = mul_6(R_15, _S2168) + t_15; + (&ret_4)->p_0[6U] = mul_6(R_15, _S2170) + t_15; + SigmaPoints_0 _S2171 = ret_4; + for(;;) + { + int2 _S2172 = make_int2 (int(0)); + float2 _S2173 = make_float2 ((float)_S2172.x, (float)_S2172.y); + *mean2d_28 = _S2173; + covar2d_15 = makeMatrix (0.0f); + FixedArray proj_points_4; + float2 _S2174 = float2 {_S2171.p_0[int(0)].x, _S2171.p_0[int(0)].y}; + float r_21 = length_0(_S2174); + float _S2175 = _S2171.p_0[int(0)].z; + float theta_14 = (F32_atan2((r_21), (_S2175))); + float k_14; + if(theta_14 < 0.00100000004749745f) + { + k_14 = (1.0f - theta_14 * theta_14 / 3.0f) / _S2175; + } + else + { + k_14 = theta_14 / r_21; + } + float2 _S2176 = _S2174 * make_float2 (k_14); + FixedArray _S2177 = dist_coeffs_27; + float2 _S2178 = DistNone_distort_0(_S2176, &_S2177); + proj_points_4[int(0)] = make_float2 (fx_28 * _S2178.x + cx_19, fy_28 * _S2178.y + cy_19); + float2 _S2179 = float2 {_S2171.p_0[int(1)].x, _S2171.p_0[int(1)].y}; + float r_22 = length_0(_S2179); + float _S2180 = _S2171.p_0[int(1)].z; + float theta_15 = (F32_atan2((r_22), (_S2180))); + if(theta_15 < 0.00100000004749745f) + { + k_14 = (1.0f - theta_15 * theta_15 / 3.0f) / _S2180; + } + else + { + k_14 = theta_15 / r_22; + } + float2 _S2181 = _S2179 * make_float2 (k_14); + FixedArray _S2182 = dist_coeffs_27; + float2 _S2183 = DistNone_distort_0(_S2181, &_S2182); + proj_points_4[int(1)] = make_float2 (fx_28 * _S2183.x + cx_19, fy_28 * _S2183.y + cy_19); + float2 _S2184 = float2 {_S2171.p_0[int(2)].x, _S2171.p_0[int(2)].y}; + float r_23 = length_0(_S2184); + float _S2185 = _S2171.p_0[int(2)].z; + float theta_16 = (F32_atan2((r_23), (_S2185))); + if(theta_16 < 0.00100000004749745f) + { + k_14 = (1.0f - theta_16 * theta_16 / 3.0f) / _S2185; + } + else + { + k_14 = theta_16 / r_23; + } + float2 _S2186 = _S2184 * make_float2 (k_14); + FixedArray _S2187 = dist_coeffs_27; + float2 _S2188 = DistNone_distort_0(_S2186, &_S2187); + proj_points_4[int(2)] = make_float2 (fx_28 * _S2188.x + cx_19, fy_28 * _S2188.y + cy_19); + float2 _S2189 = float2 {_S2171.p_0[int(3)].x, _S2171.p_0[int(3)].y}; + float r_24 = length_0(_S2189); + float _S2190 = _S2171.p_0[int(3)].z; + float theta_17 = (F32_atan2((r_24), (_S2190))); + if(theta_17 < 0.00100000004749745f) + { + k_14 = (1.0f - theta_17 * theta_17 / 3.0f) / _S2190; + } + else + { + k_14 = theta_17 / r_24; + } + float2 _S2191 = _S2189 * make_float2 (k_14); + FixedArray _S2192 = dist_coeffs_27; + float2 _S2193 = DistNone_distort_0(_S2191, &_S2192); + proj_points_4[int(3)] = make_float2 (fx_28 * _S2193.x + cx_19, fy_28 * _S2193.y + cy_19); + float2 _S2194 = float2 {_S2171.p_0[int(4)].x, _S2171.p_0[int(4)].y}; + float r_25 = length_0(_S2194); + float _S2195 = _S2171.p_0[int(4)].z; + float theta_18 = (F32_atan2((r_25), (_S2195))); + if(theta_18 < 0.00100000004749745f) + { + k_14 = (1.0f - theta_18 * theta_18 / 3.0f) / _S2195; + } + else + { + k_14 = theta_18 / r_25; + } + float2 _S2196 = _S2194 * make_float2 (k_14); + FixedArray _S2197 = dist_coeffs_27; + float2 _S2198 = DistNone_distort_0(_S2196, &_S2197); + proj_points_4[int(4)] = make_float2 (fx_28 * _S2198.x + cx_19, fy_28 * _S2198.y + cy_19); + float2 _S2199 = float2 {_S2171.p_0[int(5)].x, _S2171.p_0[int(5)].y}; + float r_26 = length_0(_S2199); + float _S2200 = _S2171.p_0[int(5)].z; + float theta_19 = (F32_atan2((r_26), (_S2200))); + if(theta_19 < 0.00100000004749745f) + { + k_14 = (1.0f - theta_19 * theta_19 / 3.0f) / _S2200; + } + else + { + k_14 = theta_19 / r_26; + } + float2 _S2201 = _S2199 * make_float2 (k_14); + FixedArray _S2202 = dist_coeffs_27; + float2 _S2203 = DistNone_distort_0(_S2201, &_S2202); + proj_points_4[int(5)] = make_float2 (fx_28 * _S2203.x + cx_19, fy_28 * _S2203.y + cy_19); + float2 _S2204 = float2 {_S2171.p_0[int(6)].x, _S2171.p_0[int(6)].y}; + float r_27 = length_0(_S2204); + float _S2205 = _S2171.p_0[int(6)].z; + float theta_20 = (F32_atan2((r_27), (_S2205))); + if(theta_20 < 0.00100000004749745f) + { + k_14 = (1.0f - theta_20 * theta_20 / 3.0f) / _S2205; + } + else + { + k_14 = theta_20 / r_27; + } + float2 _S2206 = _S2204 * make_float2 (k_14); + FixedArray _S2207 = dist_coeffs_27; + float2 _S2208 = DistNone_distort_0(_S2206, &_S2207); + float2 _S2209 = make_float2 (fx_28 * _S2208.x + cx_19, fy_28 * _S2208.y + cy_19); + proj_points_4[int(6)] = _S2209; + float2 p_1 = proj_points_4[int(0)] + (proj_points_4[int(1)] - proj_points_4[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_2 = proj_points_4[int(0)] + (proj_points_4[int(2)] - proj_points_4[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_3 = proj_points_4[int(0)] + (proj_points_4[int(3)] - proj_points_4[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_4 = proj_points_4[int(0)] + (proj_points_4[int(4)] - proj_points_4[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_5 = proj_points_4[int(0)] + (proj_points_4[int(5)] - proj_points_4[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_6 = proj_points_4[int(0)] + (_S2209 - proj_points_4[int(0)]) * make_float2 (3.32899999618530273f); + float2 _S2210 = make_float2 (cx_19, cy_19); + float2 min_p_0 = min_0(min_0(min_0(min_0(min_0(min_0(proj_points_4[int(0)], p_1), p_2), p_3), p_4), p_5), p_6) - _S2210; + float2 max_p_0 = max_0(max_0(max_0(max_0(max_0(max_0(proj_points_4[int(0)], p_1), p_2), p_3), p_4), p_5), p_6) - _S2210; + if((F32_max(((F32_max(((F32_max(((F32_max(((F32_max(((F32_max((_S2175), (_S2180)))), (_S2185)))), (_S2190)))), (_S2195)))), (_S2200)))), (_S2205))) <= 0.0f) + { + _S2160 = (min_p_0.x * max_p_0.x) < 0.0f; + } + else + { + _S2160 = false; + } + if(_S2160) + { + _S2160 = (min_p_0.y * max_p_0.y) < 0.0f; + } + else + { + _S2160 = false; + } + if(_S2160) + { + _S2160 = false; + break; + } + float2 _S2211 = *mean2d_28 + make_float2 (_S2171.w_mean_0[int(0)]) * proj_points_4[int(0)] + make_float2 (_S2171.w_mean_0[int(1)]) * proj_points_4[int(1)] + make_float2 (_S2171.w_mean_0[int(2)]) * proj_points_4[int(2)] + make_float2 (_S2171.w_mean_0[int(3)]) * proj_points_4[int(3)] + make_float2 (_S2171.w_mean_0[int(4)]) * proj_points_4[int(4)] + make_float2 (_S2171.w_mean_0[int(5)]) * proj_points_4[int(5)] + make_float2 (_S2171.w_mean_0[int(6)]) * proj_points_4[int(6)]; + *mean2d_28 = _S2211; + float2 d_28 = proj_points_4[int(0)] - _S2211; + float _S2212 = d_28.x; + float _S2213 = d_28.y; + float _S2214 = _S2212 * _S2213; + float2 d_29 = proj_points_4[int(1)] - _S2211; + float _S2215 = d_29.x; + float _S2216 = d_29.y; + float _S2217 = _S2215 * _S2216; + float2 d_30 = proj_points_4[int(2)] - _S2211; + float _S2218 = d_30.x; + float _S2219 = d_30.y; + float _S2220 = _S2218 * _S2219; + float2 d_31 = proj_points_4[int(3)] - _S2211; + float _S2221 = d_31.x; + float _S2222 = d_31.y; + float _S2223 = _S2221 * _S2222; + float2 d_32 = proj_points_4[int(4)] - _S2211; + float _S2224 = d_32.x; + float _S2225 = d_32.y; + float _S2226 = _S2224 * _S2225; + float2 d_33 = proj_points_4[int(5)] - _S2211; + float _S2227 = d_33.x; + float _S2228 = d_33.y; + float _S2229 = _S2227 * _S2228; + float2 d_34 = proj_points_4[int(6)] - _S2211; + float _S2230 = d_34.x; + float _S2231 = d_34.y; + float _S2232 = _S2230 * _S2231; + covar2d_15 = covar2d_15 + makeMatrix (_S2171.w_cov_0[int(0)]) * makeMatrix (_S2212 * _S2212, _S2214, _S2214, _S2213 * _S2213) + makeMatrix (_S2171.w_cov_0[int(1)]) * makeMatrix (_S2215 * _S2215, _S2217, _S2217, _S2216 * _S2216) + makeMatrix (_S2171.w_cov_0[int(2)]) * makeMatrix (_S2218 * _S2218, _S2220, _S2220, _S2219 * _S2219) + makeMatrix (_S2171.w_cov_0[int(3)]) * makeMatrix (_S2221 * _S2221, _S2223, _S2223, _S2222 * _S2222) + makeMatrix (_S2171.w_cov_0[int(4)]) * makeMatrix (_S2224 * _S2224, _S2226, _S2226, _S2225 * _S2225) + makeMatrix (_S2171.w_cov_0[int(5)]) * makeMatrix (_S2227 * _S2227, _S2229, _S2229, _S2228 * _S2228) + makeMatrix (_S2171.w_cov_0[int(6)]) * makeMatrix (_S2230 * _S2230, _S2232, _S2232, _S2231 * _S2231); + _S2160 = true; + break; + } + if(!(true & _S2160)) + { + *aabb_xyxy_15 = _S2158; + break; + } + float eps2d_15; + if(antialiased_15) + { + eps2d_15 = 0.10000000149011612f; + } + else + { + eps2d_15 = 0.30000001192092896f; + } + float det_orig_15 = *&(((&covar2d_15)->rows + (int(0)))->x) * *&(((&covar2d_15)->rows + (int(1)))->y) - *&(((&covar2d_15)->rows + (int(0)))->y) * *&(((&covar2d_15)->rows + (int(1)))->x); + float _S2233 = *&(((&covar2d_15)->rows + (int(0)))->x) + eps2d_15; + *&(((&covar2d_15)->rows + (int(0)))->x) = _S2233; + float _S2234 = *&(((&covar2d_15)->rows + (int(1)))->y) + eps2d_15; + *&(((&covar2d_15)->rows + (int(1)))->y) = _S2234; + float det_blur_15 = _S2233 * _S2234 - *&(((&covar2d_15)->rows + (int(0)))->y) * *&(((&covar2d_15)->rows + (int(1)))->x); + float compensation_15 = (F32_sqrt(((F32_max((0.0f), (det_orig_15 / det_blur_15)))))); + if(det_blur_15 <= 0.0f) + { + *aabb_xyxy_15 = _S2158; + break; + } + float invdet_21 = 1.0f / (covar2d_15.rows[int(0)].x * covar2d_15.rows[int(1)].y - covar2d_15.rows[int(0)].y * covar2d_15.rows[int(1)].x); + Matrix _S2235 = makeMatrix (covar2d_15.rows[int(1)].y * invdet_21, - covar2d_15.rows[int(0)].y * invdet_21, - covar2d_15.rows[int(1)].x * invdet_21, covar2d_15.rows[int(0)].x * invdet_21); + if(antialiased_15) + { + *opacity_15 = *opacity_15 * compensation_15; + } + if((*opacity_15) < 0.00392156885936856f) + { + *aabb_xyxy_15 = _S2158; + break; + } + float _S2236 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_15 / 0.00392156885936856f))))))))); + float radius_x_15 = _S2236 * (F32_sqrt((covar2d_15[int(0)].x))); + float radius_y_15 = _S2236 * (F32_sqrt((covar2d_15[int(1)].y))); + float _S2237 = (*mean2d_28).x - radius_x_15; + float _S2238 = (*mean2d_28).x + radius_x_15; + float _S2239 = (*mean2d_28).y - radius_y_15; + float _S2240 = (*mean2d_28).y + radius_y_15; + if(_S2238 <= 0.0f) + { + _S2160 = true; + } + else + { + _S2160 = _S2237 >= float(image_width_15); + } + if(_S2160) + { + _S2160 = true; + } + else + { + _S2160 = _S2240 <= 0.0f; + } + if(_S2160) + { + _S2160 = true; + } + else + { + _S2160 = _S2239 >= float(image_height_15); + } + if(_S2160) + { + *aabb_xyxy_15 = _S2158; + break; + } + *aabb_xyxy_15 = make_float4 (_S2237, _S2239, _S2238, _S2240); + float x_37 = mean_c_15.x; + float y_11 = mean_c_15.y; + float z_0 = mean_c_15.z; + float _S2241 = x_37 * x_37 + y_11 * y_11; + *sorting_depth_15 = z_0 * z_0 * z_0 * z_0 + 0.001953125f * _S2241 * _S2241; + *conic_15 = make_float3 (_S2235.rows[int(0)].x, _S2235.rows[int(0)].y, _S2235.rows[int(1)].y); + *radius_16 = view_radius_3dgs_0(mean_16, scale_15, in_opacity_15, - mul_6(transpose_3(R_15), t_15)); + break; + } + return; } -inline __device__ float s_primal_ctx_exp_0(float _S1298) +inline __device__ void projection_3dgut_fisheye_opencv(bool antialiased_16, float3 mean_17, float4 quat_16, float3 scale_16, float in_opacity_16, Matrix R_16, float3 t_16, float fx_29, float fy_29, float cx_20, float cy_20, FixedArray dist_coeffs_28, uint image_width_16, uint image_height_16, float4 * aabb_xyxy_16, float * sorting_depth_16, float * radius_17, float2 * mean2d_29, float * depth_16, float3 * conic_16, float * opacity_16) { - return (F32_exp((_S1298))); + float2 * _S2242; + float _S2243; + float2 _S2244; + float2 _S2245; + float2 * _S2246; + float _S2247; + float2 * _S2248; + float _S2249; + bool _S2250; + float2 * _S2251; + float _S2252; + float2 * _S2253; + float _S2254; + float2 * _S2255; + float _S2256; + bool _S2257; + float2 * _S2258; + float _S2259; + bool _S2260; + for(;;) + { + float4 _S2261 = make_float4 (0.0f); + *aabb_xyxy_16 = _S2261; + *sorting_depth_16 = 0.0f; + *radius_17 = 0.0f; + *mean2d_29 = make_float2 (0.0f); + *conic_16 = make_float3 (0.0f); + *opacity_16 = 0.0f; + float3 mean_c_16 = mul_6(R_16, mean_17) + t_16; + float _S2262 = length_1(mean_c_16); + *depth_16 = _S2262; + if(_S2262 <= 0.0f) + { + *aabb_xyxy_16 = _S2261; + break; + } + Matrix covar2d_16; + *opacity_16 = 1.0f / (1.0f + (F32_exp((- in_opacity_16)))); + bool _S2263; + float3 _S2264 = exp_0(scale_16); + float4 _S2265 = normalize_0(quat_16); + float x_38 = _S2265.y; + float x2_16 = x_38 * x_38; + float y2_16 = _S2265.z * _S2265.z; + float z2_16 = _S2265.w * _S2265.w; + float xy_16 = _S2265.y * _S2265.z; + float xz_16 = _S2265.y * _S2265.w; + float yz_16 = _S2265.z * _S2265.w; + float wx_16 = _S2265.x * _S2265.y; + float wy_16 = _S2265.x * _S2265.z; + float wz_16 = _S2265.x * _S2265.w; + Matrix _S2266 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_16 + z2_16), 2.0f * (xy_16 + wz_16), 2.0f * (xz_16 - wy_16), 2.0f * (xy_16 - wz_16), 1.0f - 2.0f * (x2_16 + z2_16), 2.0f * (yz_16 + wx_16), 2.0f * (xz_16 + wy_16), 2.0f * (yz_16 - wx_16), 1.0f - 2.0f * (x2_16 + y2_16)))); + SigmaPoints_0 ret_5; + (&ret_5)->p_0[int(0)] = mean_17; + (&ret_5)->w_mean_0[int(0)] = 0.0f; + (&ret_5)->w_cov_0[int(0)] = 2.0f; + float _S2267 = (F32_sqrt((3.0f))); + float3 delta_15 = make_float3 (_S2267 * _S2264.x) * _S2266.rows[0U]; + float3 _S2268 = mean_17 + delta_15; + float3 _S2269 = mean_17 - delta_15; + float3 delta_16 = make_float3 (_S2267 * _S2264.y) * _S2266.rows[1U]; + float3 _S2270 = mean_17 + delta_16; + float3 _S2271 = mean_17 - delta_16; + float3 delta_17 = make_float3 (_S2267 * _S2264.z) * _S2266.rows[2U]; + float3 _S2272 = mean_17 + delta_17; + float3 _S2273 = mean_17 - delta_17; + (&ret_5)->w_mean_0[1U] = 0.1666666716337204f; + (&ret_5)->w_cov_0[1U] = 0.1666666716337204f; + (&ret_5)->w_mean_0[2U] = 0.1666666716337204f; + (&ret_5)->w_cov_0[2U] = 0.1666666716337204f; + (&ret_5)->w_mean_0[3U] = 0.1666666716337204f; + (&ret_5)->w_cov_0[3U] = 0.1666666716337204f; + (&ret_5)->w_mean_0[4U] = 0.1666666716337204f; + (&ret_5)->w_cov_0[4U] = 0.1666666716337204f; + (&ret_5)->w_mean_0[5U] = 0.1666666716337204f; + (&ret_5)->w_cov_0[5U] = 0.1666666716337204f; + (&ret_5)->w_mean_0[6U] = 0.1666666716337204f; + (&ret_5)->w_cov_0[6U] = 0.1666666716337204f; + (&ret_5)->p_0[0U] = mul_6(R_16, (&ret_5)->p_0[0U]) + t_16; + (&ret_5)->p_0[1U] = mul_6(R_16, _S2268) + t_16; + (&ret_5)->p_0[2U] = mul_6(R_16, _S2270) + t_16; + (&ret_5)->p_0[3U] = mul_6(R_16, _S2272) + t_16; + (&ret_5)->p_0[4U] = mul_6(R_16, _S2269) + t_16; + (&ret_5)->p_0[5U] = mul_6(R_16, _S2271) + t_16; + (&ret_5)->p_0[6U] = mul_6(R_16, _S2273) + t_16; + SigmaPoints_0 _S2274 = ret_5; + for(;;) + { + int2 _S2275 = make_int2 (int(0)); + float2 _S2276 = make_float2 ((float)_S2275.x, (float)_S2275.y); + *mean2d_29 = _S2276; + covar2d_16 = makeMatrix (0.0f); + FixedArray proj_points_5; + for(;;) + { + float k_15; + _S2242 = &proj_points_5[int(0)]; + for(;;) + { + float2 _S2277 = float2 {_S2274.p_0[int(0)].x, _S2274.p_0[int(0)].y}; + float r_28 = length_0(_S2277); + float _S2278 = _S2274.p_0[int(0)].z; + _S2243 = _S2278; + float theta_21 = (F32_atan2((r_28), (_S2278))); + bool _S2279 = theta_21 < 0.00100000004749745f; + if(_S2279) + { + k_15 = (1.0f - theta_21 * theta_21 / 3.0f) / _S2278; + } + else + { + k_15 = theta_21 / r_28; + } + float2 _S2280 = _S2277 * make_float2 (k_15); + float2 _S2281 = make_float2 (1.0f, 0.0f); + _S2244 = _S2281; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2282; + (&_S2282)->primal_0 = _S2280; + (&_S2282)->differential_0 = _S2281; + FixedArray _S2283 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2284 = s_fwd_DistOpenCV_distort_0(&_S2282, &_S2283); + float2 _S2285 = make_float2 (0.0f, 1.0f); + _S2245 = _S2285; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2286; + (&_S2286)->primal_0 = _S2280; + (&_S2286)->differential_0 = _S2285; + FixedArray _S2287 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2288 = s_fwd_DistOpenCV_distort_0(&_S2286, &_S2287); + Matrix _S2289 = transpose_0(makeMatrix (_S2284.differential_0, _S2288.differential_0)); + float _S2290 = (F32_min((determinant_0(_S2289)), ((F32_min((_S2289.rows[int(0)].x), (_S2289.rows[int(1)].y)))))); + if(_S2290 > 0.25f) + { + _S2263 = _S2290 < 4.0f; + } + else + { + _S2263 = false; + } + if(_S2263) + { + FixedArray _S2291 = dist_coeffs_28; + float2 _S2292 = DistOpenCV_distort_0(_S2280, &_S2291); + _S2263 = (dot_0(_S2280, _S2292)) >= 0.0f; + } + else + { + _S2263 = false; + } + if(!_S2263) + { + proj_points_5[int(0)] = _S2280; + _S2263 = false; + break; + } + if(_S2279) + { + k_15 = (1.0f - theta_21 * theta_21 / 3.0f) / _S2278; + } + else + { + k_15 = theta_21 / r_28; + } + float2 _S2293 = _S2277 * make_float2 (k_15); + FixedArray _S2294 = dist_coeffs_28; + float2 _S2295 = DistOpenCV_distort_0(_S2293, &_S2294); + proj_points_5[int(0)] = make_float2 (fx_29 * _S2295.x + cx_20, fy_29 * _S2295.y + cy_20); + _S2263 = true; + break; + } + bool all_valid_16 = true & _S2263; + _S2246 = &proj_points_5[int(1)]; + for(;;) + { + float2 _S2296 = float2 {_S2274.p_0[int(1)].x, _S2274.p_0[int(1)].y}; + float r_29 = length_0(_S2296); + float _S2297 = _S2274.p_0[int(1)].z; + _S2247 = _S2297; + float theta_22 = (F32_atan2((r_29), (_S2297))); + bool _S2298 = theta_22 < 0.00100000004749745f; + if(_S2298) + { + k_15 = (1.0f - theta_22 * theta_22 / 3.0f) / _S2297; + } + else + { + k_15 = theta_22 / r_29; + } + float2 _S2299 = _S2296 * make_float2 (k_15); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2300; + (&_S2300)->primal_0 = _S2299; + (&_S2300)->differential_0 = _S2244; + FixedArray _S2301 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2302 = s_fwd_DistOpenCV_distort_0(&_S2300, &_S2301); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2303; + (&_S2303)->primal_0 = _S2299; + (&_S2303)->differential_0 = _S2245; + FixedArray _S2304 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2305 = s_fwd_DistOpenCV_distort_0(&_S2303, &_S2304); + Matrix _S2306 = transpose_0(makeMatrix (_S2302.differential_0, _S2305.differential_0)); + float _S2307 = (F32_min((determinant_0(_S2306)), ((F32_min((_S2306.rows[int(0)].x), (_S2306.rows[int(1)].y)))))); + if(_S2307 > 0.25f) + { + _S2263 = _S2307 < 4.0f; + } + else + { + _S2263 = false; + } + if(_S2263) + { + FixedArray _S2308 = dist_coeffs_28; + float2 _S2309 = DistOpenCV_distort_0(_S2299, &_S2308); + _S2263 = (dot_0(_S2299, _S2309)) >= 0.0f; + } + else + { + _S2263 = false; + } + if(!_S2263) + { + proj_points_5[int(1)] = _S2299; + _S2263 = false; + break; + } + if(_S2298) + { + k_15 = (1.0f - theta_22 * theta_22 / 3.0f) / _S2297; + } + else + { + k_15 = theta_22 / r_29; + } + float2 _S2310 = _S2296 * make_float2 (k_15); + FixedArray _S2311 = dist_coeffs_28; + float2 _S2312 = DistOpenCV_distort_0(_S2310, &_S2311); + proj_points_5[int(1)] = make_float2 (fx_29 * _S2312.x + cx_20, fy_29 * _S2312.y + cy_20); + _S2263 = true; + break; + } + bool all_valid_17 = all_valid_16 & _S2263; + for(;;) + { + _S2248 = &proj_points_5[int(2)]; + for(;;) + { + float2 _S2313 = float2 {_S2274.p_0[int(2)].x, _S2274.p_0[int(2)].y}; + float r_30 = length_0(_S2313); + float _S2314 = _S2274.p_0[int(2)].z; + _S2249 = _S2314; + float theta_23 = (F32_atan2((r_30), (_S2314))); + bool _S2315 = theta_23 < 0.00100000004749745f; + if(_S2315) + { + k_15 = (1.0f - theta_23 * theta_23 / 3.0f) / _S2314; + } + else + { + k_15 = theta_23 / r_30; + } + float2 _S2316 = _S2313 * make_float2 (k_15); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2317; + (&_S2317)->primal_0 = _S2316; + (&_S2317)->differential_0 = _S2244; + FixedArray _S2318 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2319 = s_fwd_DistOpenCV_distort_0(&_S2317, &_S2318); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2320; + (&_S2320)->primal_0 = _S2316; + (&_S2320)->differential_0 = _S2245; + FixedArray _S2321 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2322 = s_fwd_DistOpenCV_distort_0(&_S2320, &_S2321); + Matrix _S2323 = transpose_0(makeMatrix (_S2319.differential_0, _S2322.differential_0)); + float _S2324 = (F32_min((determinant_0(_S2323)), ((F32_min((_S2323.rows[int(0)].x), (_S2323.rows[int(1)].y)))))); + if(_S2324 > 0.25f) + { + _S2263 = _S2324 < 4.0f; + } + else + { + _S2263 = false; + } + if(_S2263) + { + FixedArray _S2325 = dist_coeffs_28; + float2 _S2326 = DistOpenCV_distort_0(_S2316, &_S2325); + _S2263 = (dot_0(_S2316, _S2326)) >= 0.0f; + } + else + { + _S2263 = false; + } + if(!_S2263) + { + proj_points_5[int(2)] = _S2316; + _S2263 = false; + break; + } + if(_S2315) + { + k_15 = (1.0f - theta_23 * theta_23 / 3.0f) / _S2314; + } + else + { + k_15 = theta_23 / r_30; + } + float2 _S2327 = _S2313 * make_float2 (k_15); + FixedArray _S2328 = dist_coeffs_28; + float2 _S2329 = DistOpenCV_distort_0(_S2327, &_S2328); + proj_points_5[int(2)] = make_float2 (fx_29 * _S2329.x + cx_20, fy_29 * _S2329.y + cy_20); + _S2263 = true; + break; + } + _S2250 = all_valid_17 & _S2263; + break; + } + _S2251 = &proj_points_5[int(3)]; + for(;;) + { + float2 _S2330 = float2 {_S2274.p_0[int(3)].x, _S2274.p_0[int(3)].y}; + float r_31 = length_0(_S2330); + float _S2331 = _S2274.p_0[int(3)].z; + _S2252 = _S2331; + float theta_24 = (F32_atan2((r_31), (_S2331))); + bool _S2332 = theta_24 < 0.00100000004749745f; + if(_S2332) + { + k_15 = (1.0f - theta_24 * theta_24 / 3.0f) / _S2331; + } + else + { + k_15 = theta_24 / r_31; + } + float2 _S2333 = _S2330 * make_float2 (k_15); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2334; + (&_S2334)->primal_0 = _S2333; + (&_S2334)->differential_0 = _S2244; + FixedArray _S2335 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2336 = s_fwd_DistOpenCV_distort_0(&_S2334, &_S2335); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2337; + (&_S2337)->primal_0 = _S2333; + (&_S2337)->differential_0 = _S2245; + FixedArray _S2338 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2339 = s_fwd_DistOpenCV_distort_0(&_S2337, &_S2338); + Matrix _S2340 = transpose_0(makeMatrix (_S2336.differential_0, _S2339.differential_0)); + float _S2341 = (F32_min((determinant_0(_S2340)), ((F32_min((_S2340.rows[int(0)].x), (_S2340.rows[int(1)].y)))))); + if(_S2341 > 0.25f) + { + _S2263 = _S2341 < 4.0f; + } + else + { + _S2263 = false; + } + if(_S2263) + { + FixedArray _S2342 = dist_coeffs_28; + float2 _S2343 = DistOpenCV_distort_0(_S2333, &_S2342); + _S2263 = (dot_0(_S2333, _S2343)) >= 0.0f; + } + else + { + _S2263 = false; + } + if(!_S2263) + { + proj_points_5[int(3)] = _S2333; + _S2263 = false; + break; + } + if(_S2332) + { + k_15 = (1.0f - theta_24 * theta_24 / 3.0f) / _S2331; + } + else + { + k_15 = theta_24 / r_31; + } + float2 _S2344 = _S2330 * make_float2 (k_15); + FixedArray _S2345 = dist_coeffs_28; + float2 _S2346 = DistOpenCV_distort_0(_S2344, &_S2345); + proj_points_5[int(3)] = make_float2 (fx_29 * _S2346.x + cx_20, fy_29 * _S2346.y + cy_20); + _S2263 = true; + break; + } + bool all_valid_18 = _S2250 & _S2263; + _S2253 = &proj_points_5[int(4)]; + for(;;) + { + float2 _S2347 = float2 {_S2274.p_0[int(4)].x, _S2274.p_0[int(4)].y}; + float r_32 = length_0(_S2347); + float _S2348 = _S2274.p_0[int(4)].z; + _S2254 = _S2348; + float theta_25 = (F32_atan2((r_32), (_S2348))); + bool _S2349 = theta_25 < 0.00100000004749745f; + if(_S2349) + { + k_15 = (1.0f - theta_25 * theta_25 / 3.0f) / _S2348; + } + else + { + k_15 = theta_25 / r_32; + } + float2 _S2350 = _S2347 * make_float2 (k_15); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2351; + (&_S2351)->primal_0 = _S2350; + (&_S2351)->differential_0 = _S2244; + FixedArray _S2352 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2353 = s_fwd_DistOpenCV_distort_0(&_S2351, &_S2352); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2354; + (&_S2354)->primal_0 = _S2350; + (&_S2354)->differential_0 = _S2245; + FixedArray _S2355 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2356 = s_fwd_DistOpenCV_distort_0(&_S2354, &_S2355); + Matrix _S2357 = transpose_0(makeMatrix (_S2353.differential_0, _S2356.differential_0)); + float _S2358 = (F32_min((determinant_0(_S2357)), ((F32_min((_S2357.rows[int(0)].x), (_S2357.rows[int(1)].y)))))); + if(_S2358 > 0.25f) + { + _S2263 = _S2358 < 4.0f; + } + else + { + _S2263 = false; + } + if(_S2263) + { + FixedArray _S2359 = dist_coeffs_28; + float2 _S2360 = DistOpenCV_distort_0(_S2350, &_S2359); + _S2263 = (dot_0(_S2350, _S2360)) >= 0.0f; + } + else + { + _S2263 = false; + } + if(!_S2263) + { + proj_points_5[int(4)] = _S2350; + _S2263 = false; + break; + } + if(_S2349) + { + k_15 = (1.0f - theta_25 * theta_25 / 3.0f) / _S2348; + } + else + { + k_15 = theta_25 / r_32; + } + float2 _S2361 = _S2347 * make_float2 (k_15); + FixedArray _S2362 = dist_coeffs_28; + float2 _S2363 = DistOpenCV_distort_0(_S2361, &_S2362); + proj_points_5[int(4)] = make_float2 (fx_29 * _S2363.x + cx_20, fy_29 * _S2363.y + cy_20); + _S2263 = true; + break; + } + bool all_valid_19 = all_valid_18 & _S2263; + for(;;) + { + _S2255 = &proj_points_5[int(5)]; + for(;;) + { + float2 _S2364 = float2 {_S2274.p_0[int(5)].x, _S2274.p_0[int(5)].y}; + float r_33 = length_0(_S2364); + float _S2365 = _S2274.p_0[int(5)].z; + _S2256 = _S2365; + float theta_26 = (F32_atan2((r_33), (_S2365))); + bool _S2366 = theta_26 < 0.00100000004749745f; + if(_S2366) + { + k_15 = (1.0f - theta_26 * theta_26 / 3.0f) / _S2365; + } + else + { + k_15 = theta_26 / r_33; + } + float2 _S2367 = _S2364 * make_float2 (k_15); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2368; + (&_S2368)->primal_0 = _S2367; + (&_S2368)->differential_0 = _S2244; + FixedArray _S2369 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2370 = s_fwd_DistOpenCV_distort_0(&_S2368, &_S2369); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2371; + (&_S2371)->primal_0 = _S2367; + (&_S2371)->differential_0 = _S2245; + FixedArray _S2372 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2373 = s_fwd_DistOpenCV_distort_0(&_S2371, &_S2372); + Matrix _S2374 = transpose_0(makeMatrix (_S2370.differential_0, _S2373.differential_0)); + float _S2375 = (F32_min((determinant_0(_S2374)), ((F32_min((_S2374.rows[int(0)].x), (_S2374.rows[int(1)].y)))))); + if(_S2375 > 0.25f) + { + _S2263 = _S2375 < 4.0f; + } + else + { + _S2263 = false; + } + if(_S2263) + { + FixedArray _S2376 = dist_coeffs_28; + float2 _S2377 = DistOpenCV_distort_0(_S2367, &_S2376); + _S2263 = (dot_0(_S2367, _S2377)) >= 0.0f; + } + else + { + _S2263 = false; + } + if(!_S2263) + { + proj_points_5[int(5)] = _S2367; + _S2263 = false; + break; + } + if(_S2366) + { + k_15 = (1.0f - theta_26 * theta_26 / 3.0f) / _S2365; + } + else + { + k_15 = theta_26 / r_33; + } + float2 _S2378 = _S2364 * make_float2 (k_15); + FixedArray _S2379 = dist_coeffs_28; + float2 _S2380 = DistOpenCV_distort_0(_S2378, &_S2379); + proj_points_5[int(5)] = make_float2 (fx_29 * _S2380.x + cx_20, fy_29 * _S2380.y + cy_20); + _S2263 = true; + break; + } + _S2257 = all_valid_19 & _S2263; + break; + } + _S2258 = &proj_points_5[int(6)]; + for(;;) + { + float2 _S2381 = float2 {_S2274.p_0[int(6)].x, _S2274.p_0[int(6)].y}; + float r_34 = length_0(_S2381); + float _S2382 = _S2274.p_0[int(6)].z; + _S2259 = _S2382; + float theta_27 = (F32_atan2((r_34), (_S2382))); + bool _S2383 = theta_27 < 0.00100000004749745f; + if(_S2383) + { + k_15 = (1.0f - theta_27 * theta_27 / 3.0f) / _S2382; + } + else + { + k_15 = theta_27 / r_34; + } + float2 _S2384 = _S2381 * make_float2 (k_15); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2385; + (&_S2385)->primal_0 = _S2384; + (&_S2385)->differential_0 = _S2244; + FixedArray _S2386 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2387 = s_fwd_DistOpenCV_distort_0(&_S2385, &_S2386); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2388; + (&_S2388)->primal_0 = _S2384; + (&_S2388)->differential_0 = _S2245; + FixedArray _S2389 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2390 = s_fwd_DistOpenCV_distort_0(&_S2388, &_S2389); + Matrix _S2391 = transpose_0(makeMatrix (_S2387.differential_0, _S2390.differential_0)); + float _S2392 = (F32_min((determinant_0(_S2391)), ((F32_min((_S2391.rows[int(0)].x), (_S2391.rows[int(1)].y)))))); + if(_S2392 > 0.25f) + { + _S2263 = _S2392 < 4.0f; + } + else + { + _S2263 = false; + } + if(_S2263) + { + FixedArray _S2393 = dist_coeffs_28; + float2 _S2394 = DistOpenCV_distort_0(_S2384, &_S2393); + _S2263 = (dot_0(_S2384, _S2394)) >= 0.0f; + } + else + { + _S2263 = false; + } + if(!_S2263) + { + proj_points_5[int(6)] = _S2384; + _S2263 = false; + break; + } + if(_S2383) + { + k_15 = (1.0f - theta_27 * theta_27 / 3.0f) / _S2382; + } + else + { + k_15 = theta_27 / r_34; + } + float2 _S2395 = _S2381 * make_float2 (k_15); + FixedArray _S2396 = dist_coeffs_28; + float2 _S2397 = DistOpenCV_distort_0(_S2395, &_S2396); + proj_points_5[int(6)] = make_float2 (fx_29 * _S2397.x + cx_20, fy_29 * _S2397.y + cy_20); + _S2263 = true; + break; + } + _S2260 = _S2257 & _S2263; + break; + } + if(!_S2260) + { + _S2263 = false; + break; + } + float2 p_7 = *_S2242 + (*_S2246 - *_S2242) * make_float2 (3.32899999618530273f); + float2 p_8 = *_S2242 + (*_S2248 - *_S2242) * make_float2 (3.32899999618530273f); + float2 p_9 = *_S2242 + (*_S2251 - *_S2242) * make_float2 (3.32899999618530273f); + float2 p_10 = *_S2242 + (*_S2253 - *_S2242) * make_float2 (3.32899999618530273f); + float2 p_11 = *_S2242 + (*_S2255 - *_S2242) * make_float2 (3.32899999618530273f); + float2 p_12 = *_S2242 + (*_S2258 - *_S2242) * make_float2 (3.32899999618530273f); + float2 _S2398 = make_float2 (cx_20, cy_20); + float2 min_p_1 = min_0(min_0(min_0(min_0(min_0(min_0(*_S2242, p_7), p_8), p_9), p_10), p_11), p_12) - _S2398; + float2 max_p_1 = max_0(max_0(max_0(max_0(max_0(max_0(*_S2242, p_7), p_8), p_9), p_10), p_11), p_12) - _S2398; + if((F32_max(((F32_max(((F32_max(((F32_max(((F32_max(((F32_max((_S2243), (_S2247)))), (_S2249)))), (_S2252)))), (_S2254)))), (_S2256)))), (_S2259))) <= 0.0f) + { + _S2263 = (min_p_1.x * max_p_1.x) < 0.0f; + } + else + { + _S2263 = false; + } + if(_S2263) + { + _S2263 = (min_p_1.y * max_p_1.y) < 0.0f; + } + else + { + _S2263 = false; + } + if(_S2263) + { + _S2263 = false; + break; + } + float2 _S2399 = *mean2d_29 + make_float2 (_S2274.w_mean_0[int(0)]) * *_S2242 + make_float2 (_S2274.w_mean_0[int(1)]) * *_S2246 + make_float2 (_S2274.w_mean_0[int(2)]) * *_S2248 + make_float2 (_S2274.w_mean_0[int(3)]) * *_S2251 + make_float2 (_S2274.w_mean_0[int(4)]) * *_S2253 + make_float2 (_S2274.w_mean_0[int(5)]) * *_S2255 + make_float2 (_S2274.w_mean_0[int(6)]) * *_S2258; + *mean2d_29 = _S2399; + float2 d_35 = *_S2242 - _S2399; + float _S2400 = d_35.x; + float _S2401 = d_35.y; + float _S2402 = _S2400 * _S2401; + float2 d_36 = *_S2246 - _S2399; + float _S2403 = d_36.x; + float _S2404 = d_36.y; + float _S2405 = _S2403 * _S2404; + float2 d_37 = *_S2248 - _S2399; + float _S2406 = d_37.x; + float _S2407 = d_37.y; + float _S2408 = _S2406 * _S2407; + float2 d_38 = *_S2251 - _S2399; + float _S2409 = d_38.x; + float _S2410 = d_38.y; + float _S2411 = _S2409 * _S2410; + float2 d_39 = *_S2253 - _S2399; + float _S2412 = d_39.x; + float _S2413 = d_39.y; + float _S2414 = _S2412 * _S2413; + float2 d_40 = *_S2255 - _S2399; + float _S2415 = d_40.x; + float _S2416 = d_40.y; + float _S2417 = _S2415 * _S2416; + float2 d_41 = *_S2258 - _S2399; + float _S2418 = d_41.x; + float _S2419 = d_41.y; + float _S2420 = _S2418 * _S2419; + covar2d_16 = covar2d_16 + makeMatrix (_S2274.w_cov_0[int(0)]) * makeMatrix (_S2400 * _S2400, _S2402, _S2402, _S2401 * _S2401) + makeMatrix (_S2274.w_cov_0[int(1)]) * makeMatrix (_S2403 * _S2403, _S2405, _S2405, _S2404 * _S2404) + makeMatrix (_S2274.w_cov_0[int(2)]) * makeMatrix (_S2406 * _S2406, _S2408, _S2408, _S2407 * _S2407) + makeMatrix (_S2274.w_cov_0[int(3)]) * makeMatrix (_S2409 * _S2409, _S2411, _S2411, _S2410 * _S2410) + makeMatrix (_S2274.w_cov_0[int(4)]) * makeMatrix (_S2412 * _S2412, _S2414, _S2414, _S2413 * _S2413) + makeMatrix (_S2274.w_cov_0[int(5)]) * makeMatrix (_S2415 * _S2415, _S2417, _S2417, _S2416 * _S2416) + makeMatrix (_S2274.w_cov_0[int(6)]) * makeMatrix (_S2418 * _S2418, _S2420, _S2420, _S2419 * _S2419); + _S2263 = true; + break; + } + if(!(true & _S2263)) + { + *aabb_xyxy_16 = _S2261; + break; + } + float eps2d_16; + if(antialiased_16) + { + eps2d_16 = 0.10000000149011612f; + } + else + { + eps2d_16 = 0.30000001192092896f; + } + float det_orig_16 = *&(((&covar2d_16)->rows + (int(0)))->x) * *&(((&covar2d_16)->rows + (int(1)))->y) - *&(((&covar2d_16)->rows + (int(0)))->y) * *&(((&covar2d_16)->rows + (int(1)))->x); + float _S2421 = *&(((&covar2d_16)->rows + (int(0)))->x) + eps2d_16; + *&(((&covar2d_16)->rows + (int(0)))->x) = _S2421; + float _S2422 = *&(((&covar2d_16)->rows + (int(1)))->y) + eps2d_16; + *&(((&covar2d_16)->rows + (int(1)))->y) = _S2422; + float det_blur_16 = _S2421 * _S2422 - *&(((&covar2d_16)->rows + (int(0)))->y) * *&(((&covar2d_16)->rows + (int(1)))->x); + float compensation_16 = (F32_sqrt(((F32_max((0.0f), (det_orig_16 / det_blur_16)))))); + if(det_blur_16 <= 0.0f) + { + *aabb_xyxy_16 = _S2261; + break; + } + float invdet_22 = 1.0f / (covar2d_16.rows[int(0)].x * covar2d_16.rows[int(1)].y - covar2d_16.rows[int(0)].y * covar2d_16.rows[int(1)].x); + Matrix _S2423 = makeMatrix (covar2d_16.rows[int(1)].y * invdet_22, - covar2d_16.rows[int(0)].y * invdet_22, - covar2d_16.rows[int(1)].x * invdet_22, covar2d_16.rows[int(0)].x * invdet_22); + if(antialiased_16) + { + *opacity_16 = *opacity_16 * compensation_16; + } + if((*opacity_16) < 0.00392156885936856f) + { + *aabb_xyxy_16 = _S2261; + break; + } + float _S2424 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_16 / 0.00392156885936856f))))))))); + float radius_x_16 = _S2424 * (F32_sqrt((covar2d_16[int(0)].x))); + float radius_y_16 = _S2424 * (F32_sqrt((covar2d_16[int(1)].y))); + float _S2425 = (*mean2d_29).x - radius_x_16; + float _S2426 = (*mean2d_29).x + radius_x_16; + float _S2427 = (*mean2d_29).y - radius_y_16; + float _S2428 = (*mean2d_29).y + radius_y_16; + if(_S2426 <= 0.0f) + { + _S2263 = true; + } + else + { + _S2263 = _S2425 >= float(image_width_16); + } + if(_S2263) + { + _S2263 = true; + } + else + { + _S2263 = _S2428 <= 0.0f; + } + if(_S2263) + { + _S2263 = true; + } + else + { + _S2263 = _S2427 >= float(image_height_16); + } + if(_S2263) + { + *aabb_xyxy_16 = _S2261; + break; + } + *aabb_xyxy_16 = make_float4 (_S2425, _S2427, _S2426, _S2428); + float x_39 = mean_c_16.x; + float y_12 = mean_c_16.y; + float z_1 = mean_c_16.z; + float _S2429 = x_39 * x_39 + y_12 * y_12; + *sorting_depth_16 = z_1 * z_1 * z_1 * z_1 + 0.001953125f * _S2429 * _S2429; + *conic_16 = make_float3 (_S2423.rows[int(0)].x, _S2423.rows[int(0)].y, _S2423.rows[int(1)].y); + *radius_17 = view_radius_3dgs_0(mean_17, scale_16, in_opacity_16, - mul_6(transpose_3(R_16), t_16)); + break; + } + return; } -inline __device__ float3 s_primal_ctx_exp_1(float3 _S1299) +inline __device__ void projection_3dgut_fisheye_prism(bool antialiased_17, float3 mean_18, float4 quat_17, float3 scale_17, float in_opacity_17, Matrix R_17, float3 t_17, float fx_30, float fy_30, float cx_21, float cy_21, FixedArray dist_coeffs_29, uint image_width_17, uint image_height_17, float4 * aabb_xyxy_17, float * sorting_depth_17, float * radius_18, float2 * mean2d_30, float * depth_17, float3 * conic_17, float * opacity_17) { - return exp_0(_S1299); + float2 * _S2430; + float _S2431; + float2 _S2432; + float2 _S2433; + float2 * _S2434; + float _S2435; + float2 * _S2436; + float _S2437; + bool _S2438; + float2 * _S2439; + float _S2440; + float2 * _S2441; + float _S2442; + float2 * _S2443; + float _S2444; + bool _S2445; + float2 * _S2446; + float _S2447; + bool _S2448; + for(;;) + { + float4 _S2449 = make_float4 (0.0f); + *aabb_xyxy_17 = _S2449; + *sorting_depth_17 = 0.0f; + *radius_18 = 0.0f; + *mean2d_30 = make_float2 (0.0f); + *conic_17 = make_float3 (0.0f); + *opacity_17 = 0.0f; + float3 mean_c_17 = mul_6(R_17, mean_18) + t_17; + float _S2450 = length_1(mean_c_17); + *depth_17 = _S2450; + if(_S2450 <= 0.0f) + { + *aabb_xyxy_17 = _S2449; + break; + } + Matrix covar2d_17; + *opacity_17 = 1.0f / (1.0f + (F32_exp((- in_opacity_17)))); + bool _S2451; + float3 _S2452 = exp_0(scale_17); + float4 _S2453 = normalize_0(quat_17); + float x_40 = _S2453.y; + float x2_17 = x_40 * x_40; + float y2_17 = _S2453.z * _S2453.z; + float z2_17 = _S2453.w * _S2453.w; + float xy_17 = _S2453.y * _S2453.z; + float xz_17 = _S2453.y * _S2453.w; + float yz_17 = _S2453.z * _S2453.w; + float wx_17 = _S2453.x * _S2453.y; + float wy_17 = _S2453.x * _S2453.z; + float wz_17 = _S2453.x * _S2453.w; + Matrix _S2454 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_17 + z2_17), 2.0f * (xy_17 + wz_17), 2.0f * (xz_17 - wy_17), 2.0f * (xy_17 - wz_17), 1.0f - 2.0f * (x2_17 + z2_17), 2.0f * (yz_17 + wx_17), 2.0f * (xz_17 + wy_17), 2.0f * (yz_17 - wx_17), 1.0f - 2.0f * (x2_17 + y2_17)))); + SigmaPoints_0 ret_6; + (&ret_6)->p_0[int(0)] = mean_18; + (&ret_6)->w_mean_0[int(0)] = 0.0f; + (&ret_6)->w_cov_0[int(0)] = 2.0f; + float _S2455 = (F32_sqrt((3.0f))); + float3 delta_18 = make_float3 (_S2455 * _S2452.x) * _S2454.rows[0U]; + float3 _S2456 = mean_18 + delta_18; + float3 _S2457 = mean_18 - delta_18; + float3 delta_19 = make_float3 (_S2455 * _S2452.y) * _S2454.rows[1U]; + float3 _S2458 = mean_18 + delta_19; + float3 _S2459 = mean_18 - delta_19; + float3 delta_20 = make_float3 (_S2455 * _S2452.z) * _S2454.rows[2U]; + float3 _S2460 = mean_18 + delta_20; + float3 _S2461 = mean_18 - delta_20; + (&ret_6)->w_mean_0[1U] = 0.1666666716337204f; + (&ret_6)->w_cov_0[1U] = 0.1666666716337204f; + (&ret_6)->w_mean_0[2U] = 0.1666666716337204f; + (&ret_6)->w_cov_0[2U] = 0.1666666716337204f; + (&ret_6)->w_mean_0[3U] = 0.1666666716337204f; + (&ret_6)->w_cov_0[3U] = 0.1666666716337204f; + (&ret_6)->w_mean_0[4U] = 0.1666666716337204f; + (&ret_6)->w_cov_0[4U] = 0.1666666716337204f; + (&ret_6)->w_mean_0[5U] = 0.1666666716337204f; + (&ret_6)->w_cov_0[5U] = 0.1666666716337204f; + (&ret_6)->w_mean_0[6U] = 0.1666666716337204f; + (&ret_6)->w_cov_0[6U] = 0.1666666716337204f; + (&ret_6)->p_0[0U] = mul_6(R_17, (&ret_6)->p_0[0U]) + t_17; + (&ret_6)->p_0[1U] = mul_6(R_17, _S2456) + t_17; + (&ret_6)->p_0[2U] = mul_6(R_17, _S2458) + t_17; + (&ret_6)->p_0[3U] = mul_6(R_17, _S2460) + t_17; + (&ret_6)->p_0[4U] = mul_6(R_17, _S2457) + t_17; + (&ret_6)->p_0[5U] = mul_6(R_17, _S2459) + t_17; + (&ret_6)->p_0[6U] = mul_6(R_17, _S2461) + t_17; + SigmaPoints_0 _S2462 = ret_6; + for(;;) + { + int2 _S2463 = make_int2 (int(0)); + float2 _S2464 = make_float2 ((float)_S2463.x, (float)_S2463.y); + *mean2d_30 = _S2464; + covar2d_17 = makeMatrix (0.0f); + FixedArray proj_points_6; + for(;;) + { + float k_16; + _S2430 = &proj_points_6[int(0)]; + for(;;) + { + float2 _S2465 = float2 {_S2462.p_0[int(0)].x, _S2462.p_0[int(0)].y}; + float r_35 = length_0(_S2465); + float _S2466 = _S2462.p_0[int(0)].z; + _S2431 = _S2466; + float theta_28 = (F32_atan2((r_35), (_S2466))); + bool _S2467 = theta_28 < 0.00100000004749745f; + if(_S2467) + { + k_16 = (1.0f - theta_28 * theta_28 / 3.0f) / _S2466; + } + else + { + k_16 = theta_28 / r_35; + } + float2 _S2468 = _S2465 * make_float2 (k_16); + float2 _S2469 = make_float2 (1.0f, 0.0f); + _S2432 = _S2469; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2470; + (&_S2470)->primal_0 = _S2468; + (&_S2470)->differential_0 = _S2469; + FixedArray _S2471 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2472 = s_fwd_DistThinPrism_distort_0(&_S2470, &_S2471); + float2 _S2473 = make_float2 (0.0f, 1.0f); + _S2433 = _S2473; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2474; + (&_S2474)->primal_0 = _S2468; + (&_S2474)->differential_0 = _S2473; + FixedArray _S2475 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2476 = s_fwd_DistThinPrism_distort_0(&_S2474, &_S2475); + Matrix _S2477 = transpose_0(makeMatrix (_S2472.differential_0, _S2476.differential_0)); + float _S2478 = (F32_min((determinant_0(_S2477)), ((F32_min((_S2477.rows[int(0)].x), (_S2477.rows[int(1)].y)))))); + if(_S2478 > 0.25f) + { + _S2451 = _S2478 < 4.0f; + } + else + { + _S2451 = false; + } + if(_S2451) + { + FixedArray _S2479 = dist_coeffs_29; + float2 _S2480 = DistThinPrism_distort_0(_S2468, &_S2479); + _S2451 = (dot_0(_S2468, _S2480)) >= 0.0f; + } + else + { + _S2451 = false; + } + if(!_S2451) + { + proj_points_6[int(0)] = _S2468; + _S2451 = false; + break; + } + if(_S2467) + { + k_16 = (1.0f - theta_28 * theta_28 / 3.0f) / _S2466; + } + else + { + k_16 = theta_28 / r_35; + } + float2 _S2481 = _S2465 * make_float2 (k_16); + FixedArray _S2482 = dist_coeffs_29; + float2 _S2483 = DistThinPrism_distort_0(_S2481, &_S2482); + proj_points_6[int(0)] = make_float2 (fx_30 * _S2483.x + cx_21, fy_30 * _S2483.y + cy_21); + _S2451 = true; + break; + } + bool all_valid_20 = true & _S2451; + _S2434 = &proj_points_6[int(1)]; + for(;;) + { + float2 _S2484 = float2 {_S2462.p_0[int(1)].x, _S2462.p_0[int(1)].y}; + float r_36 = length_0(_S2484); + float _S2485 = _S2462.p_0[int(1)].z; + _S2435 = _S2485; + float theta_29 = (F32_atan2((r_36), (_S2485))); + bool _S2486 = theta_29 < 0.00100000004749745f; + if(_S2486) + { + k_16 = (1.0f - theta_29 * theta_29 / 3.0f) / _S2485; + } + else + { + k_16 = theta_29 / r_36; + } + float2 _S2487 = _S2484 * make_float2 (k_16); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2488; + (&_S2488)->primal_0 = _S2487; + (&_S2488)->differential_0 = _S2432; + FixedArray _S2489 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2490 = s_fwd_DistThinPrism_distort_0(&_S2488, &_S2489); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2491; + (&_S2491)->primal_0 = _S2487; + (&_S2491)->differential_0 = _S2433; + FixedArray _S2492 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2493 = s_fwd_DistThinPrism_distort_0(&_S2491, &_S2492); + Matrix _S2494 = transpose_0(makeMatrix (_S2490.differential_0, _S2493.differential_0)); + float _S2495 = (F32_min((determinant_0(_S2494)), ((F32_min((_S2494.rows[int(0)].x), (_S2494.rows[int(1)].y)))))); + if(_S2495 > 0.25f) + { + _S2451 = _S2495 < 4.0f; + } + else + { + _S2451 = false; + } + if(_S2451) + { + FixedArray _S2496 = dist_coeffs_29; + float2 _S2497 = DistThinPrism_distort_0(_S2487, &_S2496); + _S2451 = (dot_0(_S2487, _S2497)) >= 0.0f; + } + else + { + _S2451 = false; + } + if(!_S2451) + { + proj_points_6[int(1)] = _S2487; + _S2451 = false; + break; + } + if(_S2486) + { + k_16 = (1.0f - theta_29 * theta_29 / 3.0f) / _S2485; + } + else + { + k_16 = theta_29 / r_36; + } + float2 _S2498 = _S2484 * make_float2 (k_16); + FixedArray _S2499 = dist_coeffs_29; + float2 _S2500 = DistThinPrism_distort_0(_S2498, &_S2499); + proj_points_6[int(1)] = make_float2 (fx_30 * _S2500.x + cx_21, fy_30 * _S2500.y + cy_21); + _S2451 = true; + break; + } + bool all_valid_21 = all_valid_20 & _S2451; + for(;;) + { + _S2436 = &proj_points_6[int(2)]; + for(;;) + { + float2 _S2501 = float2 {_S2462.p_0[int(2)].x, _S2462.p_0[int(2)].y}; + float r_37 = length_0(_S2501); + float _S2502 = _S2462.p_0[int(2)].z; + _S2437 = _S2502; + float theta_30 = (F32_atan2((r_37), (_S2502))); + bool _S2503 = theta_30 < 0.00100000004749745f; + if(_S2503) + { + k_16 = (1.0f - theta_30 * theta_30 / 3.0f) / _S2502; + } + else + { + k_16 = theta_30 / r_37; + } + float2 _S2504 = _S2501 * make_float2 (k_16); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2505; + (&_S2505)->primal_0 = _S2504; + (&_S2505)->differential_0 = _S2432; + FixedArray _S2506 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2507 = s_fwd_DistThinPrism_distort_0(&_S2505, &_S2506); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2508; + (&_S2508)->primal_0 = _S2504; + (&_S2508)->differential_0 = _S2433; + FixedArray _S2509 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2510 = s_fwd_DistThinPrism_distort_0(&_S2508, &_S2509); + Matrix _S2511 = transpose_0(makeMatrix (_S2507.differential_0, _S2510.differential_0)); + float _S2512 = (F32_min((determinant_0(_S2511)), ((F32_min((_S2511.rows[int(0)].x), (_S2511.rows[int(1)].y)))))); + if(_S2512 > 0.25f) + { + _S2451 = _S2512 < 4.0f; + } + else + { + _S2451 = false; + } + if(_S2451) + { + FixedArray _S2513 = dist_coeffs_29; + float2 _S2514 = DistThinPrism_distort_0(_S2504, &_S2513); + _S2451 = (dot_0(_S2504, _S2514)) >= 0.0f; + } + else + { + _S2451 = false; + } + if(!_S2451) + { + proj_points_6[int(2)] = _S2504; + _S2451 = false; + break; + } + if(_S2503) + { + k_16 = (1.0f - theta_30 * theta_30 / 3.0f) / _S2502; + } + else + { + k_16 = theta_30 / r_37; + } + float2 _S2515 = _S2501 * make_float2 (k_16); + FixedArray _S2516 = dist_coeffs_29; + float2 _S2517 = DistThinPrism_distort_0(_S2515, &_S2516); + proj_points_6[int(2)] = make_float2 (fx_30 * _S2517.x + cx_21, fy_30 * _S2517.y + cy_21); + _S2451 = true; + break; + } + _S2438 = all_valid_21 & _S2451; + break; + } + _S2439 = &proj_points_6[int(3)]; + for(;;) + { + float2 _S2518 = float2 {_S2462.p_0[int(3)].x, _S2462.p_0[int(3)].y}; + float r_38 = length_0(_S2518); + float _S2519 = _S2462.p_0[int(3)].z; + _S2440 = _S2519; + float theta_31 = (F32_atan2((r_38), (_S2519))); + bool _S2520 = theta_31 < 0.00100000004749745f; + if(_S2520) + { + k_16 = (1.0f - theta_31 * theta_31 / 3.0f) / _S2519; + } + else + { + k_16 = theta_31 / r_38; + } + float2 _S2521 = _S2518 * make_float2 (k_16); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2522; + (&_S2522)->primal_0 = _S2521; + (&_S2522)->differential_0 = _S2432; + FixedArray _S2523 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2524 = s_fwd_DistThinPrism_distort_0(&_S2522, &_S2523); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2525; + (&_S2525)->primal_0 = _S2521; + (&_S2525)->differential_0 = _S2433; + FixedArray _S2526 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2527 = s_fwd_DistThinPrism_distort_0(&_S2525, &_S2526); + Matrix _S2528 = transpose_0(makeMatrix (_S2524.differential_0, _S2527.differential_0)); + float _S2529 = (F32_min((determinant_0(_S2528)), ((F32_min((_S2528.rows[int(0)].x), (_S2528.rows[int(1)].y)))))); + if(_S2529 > 0.25f) + { + _S2451 = _S2529 < 4.0f; + } + else + { + _S2451 = false; + } + if(_S2451) + { + FixedArray _S2530 = dist_coeffs_29; + float2 _S2531 = DistThinPrism_distort_0(_S2521, &_S2530); + _S2451 = (dot_0(_S2521, _S2531)) >= 0.0f; + } + else + { + _S2451 = false; + } + if(!_S2451) + { + proj_points_6[int(3)] = _S2521; + _S2451 = false; + break; + } + if(_S2520) + { + k_16 = (1.0f - theta_31 * theta_31 / 3.0f) / _S2519; + } + else + { + k_16 = theta_31 / r_38; + } + float2 _S2532 = _S2518 * make_float2 (k_16); + FixedArray _S2533 = dist_coeffs_29; + float2 _S2534 = DistThinPrism_distort_0(_S2532, &_S2533); + proj_points_6[int(3)] = make_float2 (fx_30 * _S2534.x + cx_21, fy_30 * _S2534.y + cy_21); + _S2451 = true; + break; + } + bool all_valid_22 = _S2438 & _S2451; + _S2441 = &proj_points_6[int(4)]; + for(;;) + { + float2 _S2535 = float2 {_S2462.p_0[int(4)].x, _S2462.p_0[int(4)].y}; + float r_39 = length_0(_S2535); + float _S2536 = _S2462.p_0[int(4)].z; + _S2442 = _S2536; + float theta_32 = (F32_atan2((r_39), (_S2536))); + bool _S2537 = theta_32 < 0.00100000004749745f; + if(_S2537) + { + k_16 = (1.0f - theta_32 * theta_32 / 3.0f) / _S2536; + } + else + { + k_16 = theta_32 / r_39; + } + float2 _S2538 = _S2535 * make_float2 (k_16); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2539; + (&_S2539)->primal_0 = _S2538; + (&_S2539)->differential_0 = _S2432; + FixedArray _S2540 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2541 = s_fwd_DistThinPrism_distort_0(&_S2539, &_S2540); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2542; + (&_S2542)->primal_0 = _S2538; + (&_S2542)->differential_0 = _S2433; + FixedArray _S2543 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2544 = s_fwd_DistThinPrism_distort_0(&_S2542, &_S2543); + Matrix _S2545 = transpose_0(makeMatrix (_S2541.differential_0, _S2544.differential_0)); + float _S2546 = (F32_min((determinant_0(_S2545)), ((F32_min((_S2545.rows[int(0)].x), (_S2545.rows[int(1)].y)))))); + if(_S2546 > 0.25f) + { + _S2451 = _S2546 < 4.0f; + } + else + { + _S2451 = false; + } + if(_S2451) + { + FixedArray _S2547 = dist_coeffs_29; + float2 _S2548 = DistThinPrism_distort_0(_S2538, &_S2547); + _S2451 = (dot_0(_S2538, _S2548)) >= 0.0f; + } + else + { + _S2451 = false; + } + if(!_S2451) + { + proj_points_6[int(4)] = _S2538; + _S2451 = false; + break; + } + if(_S2537) + { + k_16 = (1.0f - theta_32 * theta_32 / 3.0f) / _S2536; + } + else + { + k_16 = theta_32 / r_39; + } + float2 _S2549 = _S2535 * make_float2 (k_16); + FixedArray _S2550 = dist_coeffs_29; + float2 _S2551 = DistThinPrism_distort_0(_S2549, &_S2550); + proj_points_6[int(4)] = make_float2 (fx_30 * _S2551.x + cx_21, fy_30 * _S2551.y + cy_21); + _S2451 = true; + break; + } + bool all_valid_23 = all_valid_22 & _S2451; + for(;;) + { + _S2443 = &proj_points_6[int(5)]; + for(;;) + { + float2 _S2552 = float2 {_S2462.p_0[int(5)].x, _S2462.p_0[int(5)].y}; + float r_40 = length_0(_S2552); + float _S2553 = _S2462.p_0[int(5)].z; + _S2444 = _S2553; + float theta_33 = (F32_atan2((r_40), (_S2553))); + bool _S2554 = theta_33 < 0.00100000004749745f; + if(_S2554) + { + k_16 = (1.0f - theta_33 * theta_33 / 3.0f) / _S2553; + } + else + { + k_16 = theta_33 / r_40; + } + float2 _S2555 = _S2552 * make_float2 (k_16); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2556; + (&_S2556)->primal_0 = _S2555; + (&_S2556)->differential_0 = _S2432; + FixedArray _S2557 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2558 = s_fwd_DistThinPrism_distort_0(&_S2556, &_S2557); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2559; + (&_S2559)->primal_0 = _S2555; + (&_S2559)->differential_0 = _S2433; + FixedArray _S2560 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2561 = s_fwd_DistThinPrism_distort_0(&_S2559, &_S2560); + Matrix _S2562 = transpose_0(makeMatrix (_S2558.differential_0, _S2561.differential_0)); + float _S2563 = (F32_min((determinant_0(_S2562)), ((F32_min((_S2562.rows[int(0)].x), (_S2562.rows[int(1)].y)))))); + if(_S2563 > 0.25f) + { + _S2451 = _S2563 < 4.0f; + } + else + { + _S2451 = false; + } + if(_S2451) + { + FixedArray _S2564 = dist_coeffs_29; + float2 _S2565 = DistThinPrism_distort_0(_S2555, &_S2564); + _S2451 = (dot_0(_S2555, _S2565)) >= 0.0f; + } + else + { + _S2451 = false; + } + if(!_S2451) + { + proj_points_6[int(5)] = _S2555; + _S2451 = false; + break; + } + if(_S2554) + { + k_16 = (1.0f - theta_33 * theta_33 / 3.0f) / _S2553; + } + else + { + k_16 = theta_33 / r_40; + } + float2 _S2566 = _S2552 * make_float2 (k_16); + FixedArray _S2567 = dist_coeffs_29; + float2 _S2568 = DistThinPrism_distort_0(_S2566, &_S2567); + proj_points_6[int(5)] = make_float2 (fx_30 * _S2568.x + cx_21, fy_30 * _S2568.y + cy_21); + _S2451 = true; + break; + } + _S2445 = all_valid_23 & _S2451; + break; + } + _S2446 = &proj_points_6[int(6)]; + for(;;) + { + float2 _S2569 = float2 {_S2462.p_0[int(6)].x, _S2462.p_0[int(6)].y}; + float r_41 = length_0(_S2569); + float _S2570 = _S2462.p_0[int(6)].z; + _S2447 = _S2570; + float theta_34 = (F32_atan2((r_41), (_S2570))); + bool _S2571 = theta_34 < 0.00100000004749745f; + if(_S2571) + { + k_16 = (1.0f - theta_34 * theta_34 / 3.0f) / _S2570; + } + else + { + k_16 = theta_34 / r_41; + } + float2 _S2572 = _S2569 * make_float2 (k_16); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2573; + (&_S2573)->primal_0 = _S2572; + (&_S2573)->differential_0 = _S2432; + FixedArray _S2574 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2575 = s_fwd_DistThinPrism_distort_0(&_S2573, &_S2574); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2576; + (&_S2576)->primal_0 = _S2572; + (&_S2576)->differential_0 = _S2433; + FixedArray _S2577 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2578 = s_fwd_DistThinPrism_distort_0(&_S2576, &_S2577); + Matrix _S2579 = transpose_0(makeMatrix (_S2575.differential_0, _S2578.differential_0)); + float _S2580 = (F32_min((determinant_0(_S2579)), ((F32_min((_S2579.rows[int(0)].x), (_S2579.rows[int(1)].y)))))); + if(_S2580 > 0.25f) + { + _S2451 = _S2580 < 4.0f; + } + else + { + _S2451 = false; + } + if(_S2451) + { + FixedArray _S2581 = dist_coeffs_29; + float2 _S2582 = DistThinPrism_distort_0(_S2572, &_S2581); + _S2451 = (dot_0(_S2572, _S2582)) >= 0.0f; + } + else + { + _S2451 = false; + } + if(!_S2451) + { + proj_points_6[int(6)] = _S2572; + _S2451 = false; + break; + } + if(_S2571) + { + k_16 = (1.0f - theta_34 * theta_34 / 3.0f) / _S2570; + } + else + { + k_16 = theta_34 / r_41; + } + float2 _S2583 = _S2569 * make_float2 (k_16); + FixedArray _S2584 = dist_coeffs_29; + float2 _S2585 = DistThinPrism_distort_0(_S2583, &_S2584); + proj_points_6[int(6)] = make_float2 (fx_30 * _S2585.x + cx_21, fy_30 * _S2585.y + cy_21); + _S2451 = true; + break; + } + _S2448 = _S2445 & _S2451; + break; + } + if(!_S2448) + { + _S2451 = false; + break; + } + float2 p_13 = *_S2430 + (*_S2434 - *_S2430) * make_float2 (3.32899999618530273f); + float2 p_14 = *_S2430 + (*_S2436 - *_S2430) * make_float2 (3.32899999618530273f); + float2 p_15 = *_S2430 + (*_S2439 - *_S2430) * make_float2 (3.32899999618530273f); + float2 p_16 = *_S2430 + (*_S2441 - *_S2430) * make_float2 (3.32899999618530273f); + float2 p_17 = *_S2430 + (*_S2443 - *_S2430) * make_float2 (3.32899999618530273f); + float2 p_18 = *_S2430 + (*_S2446 - *_S2430) * make_float2 (3.32899999618530273f); + float2 _S2586 = make_float2 (cx_21, cy_21); + float2 min_p_2 = min_0(min_0(min_0(min_0(min_0(min_0(*_S2430, p_13), p_14), p_15), p_16), p_17), p_18) - _S2586; + float2 max_p_2 = max_0(max_0(max_0(max_0(max_0(max_0(*_S2430, p_13), p_14), p_15), p_16), p_17), p_18) - _S2586; + if((F32_max(((F32_max(((F32_max(((F32_max(((F32_max(((F32_max((_S2431), (_S2435)))), (_S2437)))), (_S2440)))), (_S2442)))), (_S2444)))), (_S2447))) <= 0.0f) + { + _S2451 = (min_p_2.x * max_p_2.x) < 0.0f; + } + else + { + _S2451 = false; + } + if(_S2451) + { + _S2451 = (min_p_2.y * max_p_2.y) < 0.0f; + } + else + { + _S2451 = false; + } + if(_S2451) + { + _S2451 = false; + break; + } + float2 _S2587 = *mean2d_30 + make_float2 (_S2462.w_mean_0[int(0)]) * *_S2430 + make_float2 (_S2462.w_mean_0[int(1)]) * *_S2434 + make_float2 (_S2462.w_mean_0[int(2)]) * *_S2436 + make_float2 (_S2462.w_mean_0[int(3)]) * *_S2439 + make_float2 (_S2462.w_mean_0[int(4)]) * *_S2441 + make_float2 (_S2462.w_mean_0[int(5)]) * *_S2443 + make_float2 (_S2462.w_mean_0[int(6)]) * *_S2446; + *mean2d_30 = _S2587; + float2 d_42 = *_S2430 - _S2587; + float _S2588 = d_42.x; + float _S2589 = d_42.y; + float _S2590 = _S2588 * _S2589; + float2 d_43 = *_S2434 - _S2587; + float _S2591 = d_43.x; + float _S2592 = d_43.y; + float _S2593 = _S2591 * _S2592; + float2 d_44 = *_S2436 - _S2587; + float _S2594 = d_44.x; + float _S2595 = d_44.y; + float _S2596 = _S2594 * _S2595; + float2 d_45 = *_S2439 - _S2587; + float _S2597 = d_45.x; + float _S2598 = d_45.y; + float _S2599 = _S2597 * _S2598; + float2 d_46 = *_S2441 - _S2587; + float _S2600 = d_46.x; + float _S2601 = d_46.y; + float _S2602 = _S2600 * _S2601; + float2 d_47 = *_S2443 - _S2587; + float _S2603 = d_47.x; + float _S2604 = d_47.y; + float _S2605 = _S2603 * _S2604; + float2 d_48 = *_S2446 - _S2587; + float _S2606 = d_48.x; + float _S2607 = d_48.y; + float _S2608 = _S2606 * _S2607; + covar2d_17 = covar2d_17 + makeMatrix (_S2462.w_cov_0[int(0)]) * makeMatrix (_S2588 * _S2588, _S2590, _S2590, _S2589 * _S2589) + makeMatrix (_S2462.w_cov_0[int(1)]) * makeMatrix (_S2591 * _S2591, _S2593, _S2593, _S2592 * _S2592) + makeMatrix (_S2462.w_cov_0[int(2)]) * makeMatrix (_S2594 * _S2594, _S2596, _S2596, _S2595 * _S2595) + makeMatrix (_S2462.w_cov_0[int(3)]) * makeMatrix (_S2597 * _S2597, _S2599, _S2599, _S2598 * _S2598) + makeMatrix (_S2462.w_cov_0[int(4)]) * makeMatrix (_S2600 * _S2600, _S2602, _S2602, _S2601 * _S2601) + makeMatrix (_S2462.w_cov_0[int(5)]) * makeMatrix (_S2603 * _S2603, _S2605, _S2605, _S2604 * _S2604) + makeMatrix (_S2462.w_cov_0[int(6)]) * makeMatrix (_S2606 * _S2606, _S2608, _S2608, _S2607 * _S2607); + _S2451 = true; + break; + } + if(!(true & _S2451)) + { + *aabb_xyxy_17 = _S2449; + break; + } + float eps2d_17; + if(antialiased_17) + { + eps2d_17 = 0.10000000149011612f; + } + else + { + eps2d_17 = 0.30000001192092896f; + } + float det_orig_17 = *&(((&covar2d_17)->rows + (int(0)))->x) * *&(((&covar2d_17)->rows + (int(1)))->y) - *&(((&covar2d_17)->rows + (int(0)))->y) * *&(((&covar2d_17)->rows + (int(1)))->x); + float _S2609 = *&(((&covar2d_17)->rows + (int(0)))->x) + eps2d_17; + *&(((&covar2d_17)->rows + (int(0)))->x) = _S2609; + float _S2610 = *&(((&covar2d_17)->rows + (int(1)))->y) + eps2d_17; + *&(((&covar2d_17)->rows + (int(1)))->y) = _S2610; + float det_blur_17 = _S2609 * _S2610 - *&(((&covar2d_17)->rows + (int(0)))->y) * *&(((&covar2d_17)->rows + (int(1)))->x); + float compensation_17 = (F32_sqrt(((F32_max((0.0f), (det_orig_17 / det_blur_17)))))); + if(det_blur_17 <= 0.0f) + { + *aabb_xyxy_17 = _S2449; + break; + } + float invdet_23 = 1.0f / (covar2d_17.rows[int(0)].x * covar2d_17.rows[int(1)].y - covar2d_17.rows[int(0)].y * covar2d_17.rows[int(1)].x); + Matrix _S2611 = makeMatrix (covar2d_17.rows[int(1)].y * invdet_23, - covar2d_17.rows[int(0)].y * invdet_23, - covar2d_17.rows[int(1)].x * invdet_23, covar2d_17.rows[int(0)].x * invdet_23); + if(antialiased_17) + { + *opacity_17 = *opacity_17 * compensation_17; + } + if((*opacity_17) < 0.00392156885936856f) + { + *aabb_xyxy_17 = _S2449; + break; + } + float _S2612 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_17 / 0.00392156885936856f))))))))); + float radius_x_17 = _S2612 * (F32_sqrt((covar2d_17[int(0)].x))); + float radius_y_17 = _S2612 * (F32_sqrt((covar2d_17[int(1)].y))); + float _S2613 = (*mean2d_30).x - radius_x_17; + float _S2614 = (*mean2d_30).x + radius_x_17; + float _S2615 = (*mean2d_30).y - radius_y_17; + float _S2616 = (*mean2d_30).y + radius_y_17; + if(_S2614 <= 0.0f) + { + _S2451 = true; + } + else + { + _S2451 = _S2613 >= float(image_width_17); + } + if(_S2451) + { + _S2451 = true; + } + else + { + _S2451 = _S2616 <= 0.0f; + } + if(_S2451) + { + _S2451 = true; + } + else + { + _S2451 = _S2615 >= float(image_height_17); + } + if(_S2451) + { + *aabb_xyxy_17 = _S2449; + break; + } + *aabb_xyxy_17 = make_float4 (_S2613, _S2615, _S2614, _S2616); + float x_41 = mean_c_17.x; + float y_13 = mean_c_17.y; + float z_2 = mean_c_17.z; + float _S2617 = x_41 * x_41 + y_13 * y_13; + *sorting_depth_17 = z_2 * z_2 * z_2 * z_2 + 0.001953125f * _S2617 * _S2617; + *conic_17 = make_float3 (_S2611.rows[int(0)].x, _S2611.rows[int(0)].y, _S2611.rows[int(1)].y); + *radius_18 = view_radius_3dgs_0(mean_18, scale_17, in_opacity_17, - mul_6(transpose_3(R_17), t_17)); + break; + } + return; } -inline __device__ Matrix s_primal_ctx_mul_1(Matrix _S1300, Matrix _S1301) +inline __device__ void projection_3dgut_equisolid_none(bool antialiased_18, float3 mean_19, float4 quat_18, float3 scale_18, float in_opacity_18, Matrix R_18, float3 t_18, float fx_31, float fy_31, float cx_22, float cy_22, FixedArray dist_coeffs_30, uint image_width_18, uint image_height_18, float4 * aabb_xyxy_18, float * sorting_depth_18, float * radius_19, float2 * mean2d_31, float * depth_18, float3 * conic_18, float * opacity_18) { - return mul_5(_S1300, _S1301); + for(;;) + { + float4 _S2618 = make_float4 (0.0f); + *aabb_xyxy_18 = _S2618; + *sorting_depth_18 = 0.0f; + *radius_19 = 0.0f; + *mean2d_31 = make_float2 (0.0f); + *conic_18 = make_float3 (0.0f); + *opacity_18 = 0.0f; + float3 mean_c_18 = mul_6(R_18, mean_19) + t_18; + float _S2619 = length_1(mean_c_18); + *depth_18 = _S2619; + if(_S2619 <= 0.0f) + { + *aabb_xyxy_18 = _S2618; + break; + } + Matrix covar2d_18; + *opacity_18 = 1.0f / (1.0f + (F32_exp((- in_opacity_18)))); + bool _S2620; + float3 _S2621 = exp_0(scale_18); + float4 _S2622 = normalize_0(quat_18); + float x_42 = _S2622.y; + float x2_18 = x_42 * x_42; + float y2_18 = _S2622.z * _S2622.z; + float z2_18 = _S2622.w * _S2622.w; + float xy_18 = _S2622.y * _S2622.z; + float xz_18 = _S2622.y * _S2622.w; + float yz_18 = _S2622.z * _S2622.w; + float wx_18 = _S2622.x * _S2622.y; + float wy_18 = _S2622.x * _S2622.z; + float wz_18 = _S2622.x * _S2622.w; + Matrix _S2623 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_18 + z2_18), 2.0f * (xy_18 + wz_18), 2.0f * (xz_18 - wy_18), 2.0f * (xy_18 - wz_18), 1.0f - 2.0f * (x2_18 + z2_18), 2.0f * (yz_18 + wx_18), 2.0f * (xz_18 + wy_18), 2.0f * (yz_18 - wx_18), 1.0f - 2.0f * (x2_18 + y2_18)))); + SigmaPoints_0 ret_7; + (&ret_7)->p_0[int(0)] = mean_19; + (&ret_7)->w_mean_0[int(0)] = 0.0f; + (&ret_7)->w_cov_0[int(0)] = 2.0f; + float _S2624 = (F32_sqrt((3.0f))); + float3 delta_21 = make_float3 (_S2624 * _S2621.x) * _S2623.rows[0U]; + float3 _S2625 = mean_19 + delta_21; + float3 _S2626 = mean_19 - delta_21; + float3 delta_22 = make_float3 (_S2624 * _S2621.y) * _S2623.rows[1U]; + float3 _S2627 = mean_19 + delta_22; + float3 _S2628 = mean_19 - delta_22; + float3 delta_23 = make_float3 (_S2624 * _S2621.z) * _S2623.rows[2U]; + float3 _S2629 = mean_19 + delta_23; + float3 _S2630 = mean_19 - delta_23; + (&ret_7)->w_mean_0[1U] = 0.1666666716337204f; + (&ret_7)->w_cov_0[1U] = 0.1666666716337204f; + (&ret_7)->w_mean_0[2U] = 0.1666666716337204f; + (&ret_7)->w_cov_0[2U] = 0.1666666716337204f; + (&ret_7)->w_mean_0[3U] = 0.1666666716337204f; + (&ret_7)->w_cov_0[3U] = 0.1666666716337204f; + (&ret_7)->w_mean_0[4U] = 0.1666666716337204f; + (&ret_7)->w_cov_0[4U] = 0.1666666716337204f; + (&ret_7)->w_mean_0[5U] = 0.1666666716337204f; + (&ret_7)->w_cov_0[5U] = 0.1666666716337204f; + (&ret_7)->w_mean_0[6U] = 0.1666666716337204f; + (&ret_7)->w_cov_0[6U] = 0.1666666716337204f; + (&ret_7)->p_0[0U] = mul_6(R_18, (&ret_7)->p_0[0U]) + t_18; + (&ret_7)->p_0[1U] = mul_6(R_18, _S2625) + t_18; + (&ret_7)->p_0[2U] = mul_6(R_18, _S2627) + t_18; + (&ret_7)->p_0[3U] = mul_6(R_18, _S2629) + t_18; + (&ret_7)->p_0[4U] = mul_6(R_18, _S2626) + t_18; + (&ret_7)->p_0[5U] = mul_6(R_18, _S2628) + t_18; + (&ret_7)->p_0[6U] = mul_6(R_18, _S2630) + t_18; + SigmaPoints_0 _S2631 = ret_7; + for(;;) + { + int2 _S2632 = make_int2 (int(0)); + float2 _S2633 = make_float2 ((float)_S2632.x, (float)_S2632.y); + *mean2d_31 = _S2633; + covar2d_18 = makeMatrix (0.0f); + FixedArray proj_points_7; + float2 _S2634 = float2 {_S2631.p_0[int(0)].x, _S2631.p_0[int(0)].y}; + float r_42 = length_0(_S2634); + float _S2635 = _S2631.p_0[int(0)].z; + float theta_35 = (F32_atan2((r_42), (_S2635))); + float k_17; + if(r_42 < 9.99999997475242708e-07f) + { + k_17 = (1.0f - theta_35 * theta_35 / 24.0f) / _S2635; + } + else + { + k_17 = 2.0f * (F32_sin((0.5f * theta_35))) / r_42; + } + float2 _S2636 = _S2634 * make_float2 (k_17); + FixedArray _S2637 = dist_coeffs_30; + float2 _S2638 = DistNone_distort_0(_S2636, &_S2637); + proj_points_7[int(0)] = make_float2 (fx_31 * _S2638.x + cx_22, fy_31 * _S2638.y + cy_22); + float2 _S2639 = float2 {_S2631.p_0[int(1)].x, _S2631.p_0[int(1)].y}; + float r_43 = length_0(_S2639); + float _S2640 = _S2631.p_0[int(1)].z; + float theta_36 = (F32_atan2((r_43), (_S2640))); + if(r_43 < 9.99999997475242708e-07f) + { + k_17 = (1.0f - theta_36 * theta_36 / 24.0f) / _S2640; + } + else + { + k_17 = 2.0f * (F32_sin((0.5f * theta_36))) / r_43; + } + float2 _S2641 = _S2639 * make_float2 (k_17); + FixedArray _S2642 = dist_coeffs_30; + float2 _S2643 = DistNone_distort_0(_S2641, &_S2642); + proj_points_7[int(1)] = make_float2 (fx_31 * _S2643.x + cx_22, fy_31 * _S2643.y + cy_22); + float2 _S2644 = float2 {_S2631.p_0[int(2)].x, _S2631.p_0[int(2)].y}; + float r_44 = length_0(_S2644); + float _S2645 = _S2631.p_0[int(2)].z; + float theta_37 = (F32_atan2((r_44), (_S2645))); + if(r_44 < 9.99999997475242708e-07f) + { + k_17 = (1.0f - theta_37 * theta_37 / 24.0f) / _S2645; + } + else + { + k_17 = 2.0f * (F32_sin((0.5f * theta_37))) / r_44; + } + float2 _S2646 = _S2644 * make_float2 (k_17); + FixedArray _S2647 = dist_coeffs_30; + float2 _S2648 = DistNone_distort_0(_S2646, &_S2647); + proj_points_7[int(2)] = make_float2 (fx_31 * _S2648.x + cx_22, fy_31 * _S2648.y + cy_22); + float2 _S2649 = float2 {_S2631.p_0[int(3)].x, _S2631.p_0[int(3)].y}; + float r_45 = length_0(_S2649); + float _S2650 = _S2631.p_0[int(3)].z; + float theta_38 = (F32_atan2((r_45), (_S2650))); + if(r_45 < 9.99999997475242708e-07f) + { + k_17 = (1.0f - theta_38 * theta_38 / 24.0f) / _S2650; + } + else + { + k_17 = 2.0f * (F32_sin((0.5f * theta_38))) / r_45; + } + float2 _S2651 = _S2649 * make_float2 (k_17); + FixedArray _S2652 = dist_coeffs_30; + float2 _S2653 = DistNone_distort_0(_S2651, &_S2652); + proj_points_7[int(3)] = make_float2 (fx_31 * _S2653.x + cx_22, fy_31 * _S2653.y + cy_22); + float2 _S2654 = float2 {_S2631.p_0[int(4)].x, _S2631.p_0[int(4)].y}; + float r_46 = length_0(_S2654); + float _S2655 = _S2631.p_0[int(4)].z; + float theta_39 = (F32_atan2((r_46), (_S2655))); + if(r_46 < 9.99999997475242708e-07f) + { + k_17 = (1.0f - theta_39 * theta_39 / 24.0f) / _S2655; + } + else + { + k_17 = 2.0f * (F32_sin((0.5f * theta_39))) / r_46; + } + float2 _S2656 = _S2654 * make_float2 (k_17); + FixedArray _S2657 = dist_coeffs_30; + float2 _S2658 = DistNone_distort_0(_S2656, &_S2657); + proj_points_7[int(4)] = make_float2 (fx_31 * _S2658.x + cx_22, fy_31 * _S2658.y + cy_22); + float2 _S2659 = float2 {_S2631.p_0[int(5)].x, _S2631.p_0[int(5)].y}; + float r_47 = length_0(_S2659); + float _S2660 = _S2631.p_0[int(5)].z; + float theta_40 = (F32_atan2((r_47), (_S2660))); + if(r_47 < 9.99999997475242708e-07f) + { + k_17 = (1.0f - theta_40 * theta_40 / 24.0f) / _S2660; + } + else + { + k_17 = 2.0f * (F32_sin((0.5f * theta_40))) / r_47; + } + float2 _S2661 = _S2659 * make_float2 (k_17); + FixedArray _S2662 = dist_coeffs_30; + float2 _S2663 = DistNone_distort_0(_S2661, &_S2662); + proj_points_7[int(5)] = make_float2 (fx_31 * _S2663.x + cx_22, fy_31 * _S2663.y + cy_22); + float2 _S2664 = float2 {_S2631.p_0[int(6)].x, _S2631.p_0[int(6)].y}; + float r_48 = length_0(_S2664); + float _S2665 = _S2631.p_0[int(6)].z; + float theta_41 = (F32_atan2((r_48), (_S2665))); + if(r_48 < 9.99999997475242708e-07f) + { + k_17 = (1.0f - theta_41 * theta_41 / 24.0f) / _S2665; + } + else + { + k_17 = 2.0f * (F32_sin((0.5f * theta_41))) / r_48; + } + float2 _S2666 = _S2664 * make_float2 (k_17); + FixedArray _S2667 = dist_coeffs_30; + float2 _S2668 = DistNone_distort_0(_S2666, &_S2667); + float2 _S2669 = make_float2 (fx_31 * _S2668.x + cx_22, fy_31 * _S2668.y + cy_22); + proj_points_7[int(6)] = _S2669; + float2 p_19 = proj_points_7[int(0)] + (proj_points_7[int(1)] - proj_points_7[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_20 = proj_points_7[int(0)] + (proj_points_7[int(2)] - proj_points_7[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_21 = proj_points_7[int(0)] + (proj_points_7[int(3)] - proj_points_7[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_22 = proj_points_7[int(0)] + (proj_points_7[int(4)] - proj_points_7[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_23 = proj_points_7[int(0)] + (proj_points_7[int(5)] - proj_points_7[int(0)]) * make_float2 (3.32899999618530273f); + float2 p_24 = proj_points_7[int(0)] + (_S2669 - proj_points_7[int(0)]) * make_float2 (3.32899999618530273f); + float2 _S2670 = make_float2 (cx_22, cy_22); + float2 min_p_3 = min_0(min_0(min_0(min_0(min_0(min_0(proj_points_7[int(0)], p_19), p_20), p_21), p_22), p_23), p_24) - _S2670; + float2 max_p_3 = max_0(max_0(max_0(max_0(max_0(max_0(proj_points_7[int(0)], p_19), p_20), p_21), p_22), p_23), p_24) - _S2670; + if((F32_max(((F32_max(((F32_max(((F32_max(((F32_max(((F32_max((_S2635), (_S2640)))), (_S2645)))), (_S2650)))), (_S2655)))), (_S2660)))), (_S2665))) <= 0.0f) + { + _S2620 = (min_p_3.x * max_p_3.x) < 0.0f; + } + else + { + _S2620 = false; + } + if(_S2620) + { + _S2620 = (min_p_3.y * max_p_3.y) < 0.0f; + } + else + { + _S2620 = false; + } + if(_S2620) + { + _S2620 = false; + break; + } + float2 _S2671 = *mean2d_31 + make_float2 (_S2631.w_mean_0[int(0)]) * proj_points_7[int(0)] + make_float2 (_S2631.w_mean_0[int(1)]) * proj_points_7[int(1)] + make_float2 (_S2631.w_mean_0[int(2)]) * proj_points_7[int(2)] + make_float2 (_S2631.w_mean_0[int(3)]) * proj_points_7[int(3)] + make_float2 (_S2631.w_mean_0[int(4)]) * proj_points_7[int(4)] + make_float2 (_S2631.w_mean_0[int(5)]) * proj_points_7[int(5)] + make_float2 (_S2631.w_mean_0[int(6)]) * proj_points_7[int(6)]; + *mean2d_31 = _S2671; + float2 d_49 = proj_points_7[int(0)] - _S2671; + float _S2672 = d_49.x; + float _S2673 = d_49.y; + float _S2674 = _S2672 * _S2673; + float2 d_50 = proj_points_7[int(1)] - _S2671; + float _S2675 = d_50.x; + float _S2676 = d_50.y; + float _S2677 = _S2675 * _S2676; + float2 d_51 = proj_points_7[int(2)] - _S2671; + float _S2678 = d_51.x; + float _S2679 = d_51.y; + float _S2680 = _S2678 * _S2679; + float2 d_52 = proj_points_7[int(3)] - _S2671; + float _S2681 = d_52.x; + float _S2682 = d_52.y; + float _S2683 = _S2681 * _S2682; + float2 d_53 = proj_points_7[int(4)] - _S2671; + float _S2684 = d_53.x; + float _S2685 = d_53.y; + float _S2686 = _S2684 * _S2685; + float2 d_54 = proj_points_7[int(5)] - _S2671; + float _S2687 = d_54.x; + float _S2688 = d_54.y; + float _S2689 = _S2687 * _S2688; + float2 d_55 = proj_points_7[int(6)] - _S2671; + float _S2690 = d_55.x; + float _S2691 = d_55.y; + float _S2692 = _S2690 * _S2691; + covar2d_18 = covar2d_18 + makeMatrix (_S2631.w_cov_0[int(0)]) * makeMatrix (_S2672 * _S2672, _S2674, _S2674, _S2673 * _S2673) + makeMatrix (_S2631.w_cov_0[int(1)]) * makeMatrix (_S2675 * _S2675, _S2677, _S2677, _S2676 * _S2676) + makeMatrix (_S2631.w_cov_0[int(2)]) * makeMatrix (_S2678 * _S2678, _S2680, _S2680, _S2679 * _S2679) + makeMatrix (_S2631.w_cov_0[int(3)]) * makeMatrix (_S2681 * _S2681, _S2683, _S2683, _S2682 * _S2682) + makeMatrix (_S2631.w_cov_0[int(4)]) * makeMatrix (_S2684 * _S2684, _S2686, _S2686, _S2685 * _S2685) + makeMatrix (_S2631.w_cov_0[int(5)]) * makeMatrix (_S2687 * _S2687, _S2689, _S2689, _S2688 * _S2688) + makeMatrix (_S2631.w_cov_0[int(6)]) * makeMatrix (_S2690 * _S2690, _S2692, _S2692, _S2691 * _S2691); + _S2620 = true; + break; + } + if(!(true & _S2620)) + { + *aabb_xyxy_18 = _S2618; + break; + } + float eps2d_18; + if(antialiased_18) + { + eps2d_18 = 0.10000000149011612f; + } + else + { + eps2d_18 = 0.30000001192092896f; + } + float det_orig_18 = *&(((&covar2d_18)->rows + (int(0)))->x) * *&(((&covar2d_18)->rows + (int(1)))->y) - *&(((&covar2d_18)->rows + (int(0)))->y) * *&(((&covar2d_18)->rows + (int(1)))->x); + float _S2693 = *&(((&covar2d_18)->rows + (int(0)))->x) + eps2d_18; + *&(((&covar2d_18)->rows + (int(0)))->x) = _S2693; + float _S2694 = *&(((&covar2d_18)->rows + (int(1)))->y) + eps2d_18; + *&(((&covar2d_18)->rows + (int(1)))->y) = _S2694; + float det_blur_18 = _S2693 * _S2694 - *&(((&covar2d_18)->rows + (int(0)))->y) * *&(((&covar2d_18)->rows + (int(1)))->x); + float compensation_18 = (F32_sqrt(((F32_max((0.0f), (det_orig_18 / det_blur_18)))))); + if(det_blur_18 <= 0.0f) + { + *aabb_xyxy_18 = _S2618; + break; + } + float invdet_24 = 1.0f / (covar2d_18.rows[int(0)].x * covar2d_18.rows[int(1)].y - covar2d_18.rows[int(0)].y * covar2d_18.rows[int(1)].x); + Matrix _S2695 = makeMatrix (covar2d_18.rows[int(1)].y * invdet_24, - covar2d_18.rows[int(0)].y * invdet_24, - covar2d_18.rows[int(1)].x * invdet_24, covar2d_18.rows[int(0)].x * invdet_24); + if(antialiased_18) + { + *opacity_18 = *opacity_18 * compensation_18; + } + if((*opacity_18) < 0.00392156885936856f) + { + *aabb_xyxy_18 = _S2618; + break; + } + float _S2696 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_18 / 0.00392156885936856f))))))))); + float radius_x_18 = _S2696 * (F32_sqrt((covar2d_18[int(0)].x))); + float radius_y_18 = _S2696 * (F32_sqrt((covar2d_18[int(1)].y))); + float _S2697 = (*mean2d_31).x - radius_x_18; + float _S2698 = (*mean2d_31).x + radius_x_18; + float _S2699 = (*mean2d_31).y - radius_y_18; + float _S2700 = (*mean2d_31).y + radius_y_18; + if(_S2698 <= 0.0f) + { + _S2620 = true; + } + else + { + _S2620 = _S2697 >= float(image_width_18); + } + if(_S2620) + { + _S2620 = true; + } + else + { + _S2620 = _S2700 <= 0.0f; + } + if(_S2620) + { + _S2620 = true; + } + else + { + _S2620 = _S2699 >= float(image_height_18); + } + if(_S2620) + { + *aabb_xyxy_18 = _S2618; + break; + } + *aabb_xyxy_18 = make_float4 (_S2697, _S2699, _S2698, _S2700); + float x_43 = mean_c_18.x; + float y_14 = mean_c_18.y; + float z_3 = mean_c_18.z; + float _S2701 = x_43 * x_43 + y_14 * y_14; + *sorting_depth_18 = z_3 * z_3 * z_3 * z_3 + 0.001953125f * _S2701 * _S2701; + *conic_18 = make_float3 (_S2695.rows[int(0)].x, _S2695.rows[int(0)].y, _S2695.rows[int(1)].y); + *radius_19 = view_radius_3dgs_0(mean_19, scale_18, in_opacity_18, - mul_6(transpose_3(R_18), t_18)); + break; + } + return; } -inline __device__ float s_primal_ctx_clamp_0(float _S1302, float _S1303, float _S1304) +inline __device__ void projection_3dgut_equisolid_opencv(bool antialiased_19, float3 mean_20, float4 quat_19, float3 scale_19, float in_opacity_19, Matrix R_19, float3 t_19, float fx_32, float fy_32, float cx_23, float cy_23, FixedArray dist_coeffs_31, uint image_width_19, uint image_height_19, float4 * aabb_xyxy_19, float * sorting_depth_19, float * radius_20, float2 * mean2d_32, float * depth_19, float3 * conic_19, float * opacity_19) { - return clamp_0(_S1302, _S1303, _S1304); + float2 * _S2702; + float _S2703; + float2 _S2704; + float2 _S2705; + float2 * _S2706; + float _S2707; + float2 * _S2708; + float _S2709; + bool _S2710; + float2 * _S2711; + float _S2712; + float2 * _S2713; + float _S2714; + float2 * _S2715; + float _S2716; + bool _S2717; + float2 * _S2718; + float _S2719; + bool _S2720; + for(;;) + { + float4 _S2721 = make_float4 (0.0f); + *aabb_xyxy_19 = _S2721; + *sorting_depth_19 = 0.0f; + *radius_20 = 0.0f; + *mean2d_32 = make_float2 (0.0f); + *conic_19 = make_float3 (0.0f); + *opacity_19 = 0.0f; + float3 mean_c_19 = mul_6(R_19, mean_20) + t_19; + float _S2722 = length_1(mean_c_19); + *depth_19 = _S2722; + if(_S2722 <= 0.0f) + { + *aabb_xyxy_19 = _S2721; + break; + } + Matrix covar2d_19; + *opacity_19 = 1.0f / (1.0f + (F32_exp((- in_opacity_19)))); + bool _S2723; + float3 _S2724 = exp_0(scale_19); + float4 _S2725 = normalize_0(quat_19); + float x_44 = _S2725.y; + float x2_19 = x_44 * x_44; + float y2_19 = _S2725.z * _S2725.z; + float z2_19 = _S2725.w * _S2725.w; + float xy_19 = _S2725.y * _S2725.z; + float xz_19 = _S2725.y * _S2725.w; + float yz_19 = _S2725.z * _S2725.w; + float wx_19 = _S2725.x * _S2725.y; + float wy_19 = _S2725.x * _S2725.z; + float wz_19 = _S2725.x * _S2725.w; + Matrix _S2726 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_19 + z2_19), 2.0f * (xy_19 + wz_19), 2.0f * (xz_19 - wy_19), 2.0f * (xy_19 - wz_19), 1.0f - 2.0f * (x2_19 + z2_19), 2.0f * (yz_19 + wx_19), 2.0f * (xz_19 + wy_19), 2.0f * (yz_19 - wx_19), 1.0f - 2.0f * (x2_19 + y2_19)))); + SigmaPoints_0 ret_8; + (&ret_8)->p_0[int(0)] = mean_20; + (&ret_8)->w_mean_0[int(0)] = 0.0f; + (&ret_8)->w_cov_0[int(0)] = 2.0f; + float _S2727 = (F32_sqrt((3.0f))); + float3 delta_24 = make_float3 (_S2727 * _S2724.x) * _S2726.rows[0U]; + float3 _S2728 = mean_20 + delta_24; + float3 _S2729 = mean_20 - delta_24; + float3 delta_25 = make_float3 (_S2727 * _S2724.y) * _S2726.rows[1U]; + float3 _S2730 = mean_20 + delta_25; + float3 _S2731 = mean_20 - delta_25; + float3 delta_26 = make_float3 (_S2727 * _S2724.z) * _S2726.rows[2U]; + float3 _S2732 = mean_20 + delta_26; + float3 _S2733 = mean_20 - delta_26; + (&ret_8)->w_mean_0[1U] = 0.1666666716337204f; + (&ret_8)->w_cov_0[1U] = 0.1666666716337204f; + (&ret_8)->w_mean_0[2U] = 0.1666666716337204f; + (&ret_8)->w_cov_0[2U] = 0.1666666716337204f; + (&ret_8)->w_mean_0[3U] = 0.1666666716337204f; + (&ret_8)->w_cov_0[3U] = 0.1666666716337204f; + (&ret_8)->w_mean_0[4U] = 0.1666666716337204f; + (&ret_8)->w_cov_0[4U] = 0.1666666716337204f; + (&ret_8)->w_mean_0[5U] = 0.1666666716337204f; + (&ret_8)->w_cov_0[5U] = 0.1666666716337204f; + (&ret_8)->w_mean_0[6U] = 0.1666666716337204f; + (&ret_8)->w_cov_0[6U] = 0.1666666716337204f; + (&ret_8)->p_0[0U] = mul_6(R_19, (&ret_8)->p_0[0U]) + t_19; + (&ret_8)->p_0[1U] = mul_6(R_19, _S2728) + t_19; + (&ret_8)->p_0[2U] = mul_6(R_19, _S2730) + t_19; + (&ret_8)->p_0[3U] = mul_6(R_19, _S2732) + t_19; + (&ret_8)->p_0[4U] = mul_6(R_19, _S2729) + t_19; + (&ret_8)->p_0[5U] = mul_6(R_19, _S2731) + t_19; + (&ret_8)->p_0[6U] = mul_6(R_19, _S2733) + t_19; + SigmaPoints_0 _S2734 = ret_8; + for(;;) + { + int2 _S2735 = make_int2 (int(0)); + float2 _S2736 = make_float2 ((float)_S2735.x, (float)_S2735.y); + *mean2d_32 = _S2736; + covar2d_19 = makeMatrix (0.0f); + FixedArray proj_points_8; + for(;;) + { + float k_18; + _S2702 = &proj_points_8[int(0)]; + for(;;) + { + float2 _S2737 = float2 {_S2734.p_0[int(0)].x, _S2734.p_0[int(0)].y}; + float r_49 = length_0(_S2737); + float _S2738 = _S2734.p_0[int(0)].z; + _S2703 = _S2738; + float theta_42 = (F32_atan2((r_49), (_S2738))); + bool _S2739 = r_49 < 9.99999997475242708e-07f; + if(_S2739) + { + k_18 = (1.0f - theta_42 * theta_42 / 24.0f) / _S2738; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_42))) / r_49; + } + float2 _S2740 = _S2737 * make_float2 (k_18); + float2 _S2741 = make_float2 (1.0f, 0.0f); + _S2704 = _S2741; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2742; + (&_S2742)->primal_0 = _S2740; + (&_S2742)->differential_0 = _S2741; + FixedArray _S2743 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2744 = s_fwd_DistOpenCV_distort_0(&_S2742, &_S2743); + float2 _S2745 = make_float2 (0.0f, 1.0f); + _S2705 = _S2745; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2746; + (&_S2746)->primal_0 = _S2740; + (&_S2746)->differential_0 = _S2745; + FixedArray _S2747 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2748 = s_fwd_DistOpenCV_distort_0(&_S2746, &_S2747); + Matrix _S2749 = transpose_0(makeMatrix (_S2744.differential_0, _S2748.differential_0)); + float _S2750 = (F32_min((determinant_0(_S2749)), ((F32_min((_S2749.rows[int(0)].x), (_S2749.rows[int(1)].y)))))); + if(_S2750 > 0.25f) + { + _S2723 = _S2750 < 4.0f; + } + else + { + _S2723 = false; + } + if(_S2723) + { + FixedArray _S2751 = dist_coeffs_31; + float2 _S2752 = DistOpenCV_distort_0(_S2740, &_S2751); + _S2723 = (dot_0(_S2740, _S2752)) >= 0.0f; + } + else + { + _S2723 = false; + } + if(!_S2723) + { + proj_points_8[int(0)] = _S2740; + _S2723 = false; + break; + } + if(_S2739) + { + k_18 = (1.0f - theta_42 * theta_42 / 24.0f) / _S2738; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_42))) / r_49; + } + float2 _S2753 = _S2737 * make_float2 (k_18); + FixedArray _S2754 = dist_coeffs_31; + float2 _S2755 = DistOpenCV_distort_0(_S2753, &_S2754); + proj_points_8[int(0)] = make_float2 (fx_32 * _S2755.x + cx_23, fy_32 * _S2755.y + cy_23); + _S2723 = true; + break; + } + bool all_valid_24 = true & _S2723; + _S2706 = &proj_points_8[int(1)]; + for(;;) + { + float2 _S2756 = float2 {_S2734.p_0[int(1)].x, _S2734.p_0[int(1)].y}; + float r_50 = length_0(_S2756); + float _S2757 = _S2734.p_0[int(1)].z; + _S2707 = _S2757; + float theta_43 = (F32_atan2((r_50), (_S2757))); + bool _S2758 = r_50 < 9.99999997475242708e-07f; + if(_S2758) + { + k_18 = (1.0f - theta_43 * theta_43 / 24.0f) / _S2757; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_43))) / r_50; + } + float2 _S2759 = _S2756 * make_float2 (k_18); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2760; + (&_S2760)->primal_0 = _S2759; + (&_S2760)->differential_0 = _S2704; + FixedArray _S2761 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2762 = s_fwd_DistOpenCV_distort_0(&_S2760, &_S2761); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2763; + (&_S2763)->primal_0 = _S2759; + (&_S2763)->differential_0 = _S2705; + FixedArray _S2764 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2765 = s_fwd_DistOpenCV_distort_0(&_S2763, &_S2764); + Matrix _S2766 = transpose_0(makeMatrix (_S2762.differential_0, _S2765.differential_0)); + float _S2767 = (F32_min((determinant_0(_S2766)), ((F32_min((_S2766.rows[int(0)].x), (_S2766.rows[int(1)].y)))))); + if(_S2767 > 0.25f) + { + _S2723 = _S2767 < 4.0f; + } + else + { + _S2723 = false; + } + if(_S2723) + { + FixedArray _S2768 = dist_coeffs_31; + float2 _S2769 = DistOpenCV_distort_0(_S2759, &_S2768); + _S2723 = (dot_0(_S2759, _S2769)) >= 0.0f; + } + else + { + _S2723 = false; + } + if(!_S2723) + { + proj_points_8[int(1)] = _S2759; + _S2723 = false; + break; + } + if(_S2758) + { + k_18 = (1.0f - theta_43 * theta_43 / 24.0f) / _S2757; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_43))) / r_50; + } + float2 _S2770 = _S2756 * make_float2 (k_18); + FixedArray _S2771 = dist_coeffs_31; + float2 _S2772 = DistOpenCV_distort_0(_S2770, &_S2771); + proj_points_8[int(1)] = make_float2 (fx_32 * _S2772.x + cx_23, fy_32 * _S2772.y + cy_23); + _S2723 = true; + break; + } + bool all_valid_25 = all_valid_24 & _S2723; + for(;;) + { + _S2708 = &proj_points_8[int(2)]; + for(;;) + { + float2 _S2773 = float2 {_S2734.p_0[int(2)].x, _S2734.p_0[int(2)].y}; + float r_51 = length_0(_S2773); + float _S2774 = _S2734.p_0[int(2)].z; + _S2709 = _S2774; + float theta_44 = (F32_atan2((r_51), (_S2774))); + bool _S2775 = r_51 < 9.99999997475242708e-07f; + if(_S2775) + { + k_18 = (1.0f - theta_44 * theta_44 / 24.0f) / _S2774; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_44))) / r_51; + } + float2 _S2776 = _S2773 * make_float2 (k_18); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2777; + (&_S2777)->primal_0 = _S2776; + (&_S2777)->differential_0 = _S2704; + FixedArray _S2778 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2779 = s_fwd_DistOpenCV_distort_0(&_S2777, &_S2778); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2780; + (&_S2780)->primal_0 = _S2776; + (&_S2780)->differential_0 = _S2705; + FixedArray _S2781 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2782 = s_fwd_DistOpenCV_distort_0(&_S2780, &_S2781); + Matrix _S2783 = transpose_0(makeMatrix (_S2779.differential_0, _S2782.differential_0)); + float _S2784 = (F32_min((determinant_0(_S2783)), ((F32_min((_S2783.rows[int(0)].x), (_S2783.rows[int(1)].y)))))); + if(_S2784 > 0.25f) + { + _S2723 = _S2784 < 4.0f; + } + else + { + _S2723 = false; + } + if(_S2723) + { + FixedArray _S2785 = dist_coeffs_31; + float2 _S2786 = DistOpenCV_distort_0(_S2776, &_S2785); + _S2723 = (dot_0(_S2776, _S2786)) >= 0.0f; + } + else + { + _S2723 = false; + } + if(!_S2723) + { + proj_points_8[int(2)] = _S2776; + _S2723 = false; + break; + } + if(_S2775) + { + k_18 = (1.0f - theta_44 * theta_44 / 24.0f) / _S2774; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_44))) / r_51; + } + float2 _S2787 = _S2773 * make_float2 (k_18); + FixedArray _S2788 = dist_coeffs_31; + float2 _S2789 = DistOpenCV_distort_0(_S2787, &_S2788); + proj_points_8[int(2)] = make_float2 (fx_32 * _S2789.x + cx_23, fy_32 * _S2789.y + cy_23); + _S2723 = true; + break; + } + _S2710 = all_valid_25 & _S2723; + break; + } + _S2711 = &proj_points_8[int(3)]; + for(;;) + { + float2 _S2790 = float2 {_S2734.p_0[int(3)].x, _S2734.p_0[int(3)].y}; + float r_52 = length_0(_S2790); + float _S2791 = _S2734.p_0[int(3)].z; + _S2712 = _S2791; + float theta_45 = (F32_atan2((r_52), (_S2791))); + bool _S2792 = r_52 < 9.99999997475242708e-07f; + if(_S2792) + { + k_18 = (1.0f - theta_45 * theta_45 / 24.0f) / _S2791; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_45))) / r_52; + } + float2 _S2793 = _S2790 * make_float2 (k_18); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2794; + (&_S2794)->primal_0 = _S2793; + (&_S2794)->differential_0 = _S2704; + FixedArray _S2795 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2796 = s_fwd_DistOpenCV_distort_0(&_S2794, &_S2795); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2797; + (&_S2797)->primal_0 = _S2793; + (&_S2797)->differential_0 = _S2705; + FixedArray _S2798 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2799 = s_fwd_DistOpenCV_distort_0(&_S2797, &_S2798); + Matrix _S2800 = transpose_0(makeMatrix (_S2796.differential_0, _S2799.differential_0)); + float _S2801 = (F32_min((determinant_0(_S2800)), ((F32_min((_S2800.rows[int(0)].x), (_S2800.rows[int(1)].y)))))); + if(_S2801 > 0.25f) + { + _S2723 = _S2801 < 4.0f; + } + else + { + _S2723 = false; + } + if(_S2723) + { + FixedArray _S2802 = dist_coeffs_31; + float2 _S2803 = DistOpenCV_distort_0(_S2793, &_S2802); + _S2723 = (dot_0(_S2793, _S2803)) >= 0.0f; + } + else + { + _S2723 = false; + } + if(!_S2723) + { + proj_points_8[int(3)] = _S2793; + _S2723 = false; + break; + } + if(_S2792) + { + k_18 = (1.0f - theta_45 * theta_45 / 24.0f) / _S2791; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_45))) / r_52; + } + float2 _S2804 = _S2790 * make_float2 (k_18); + FixedArray _S2805 = dist_coeffs_31; + float2 _S2806 = DistOpenCV_distort_0(_S2804, &_S2805); + proj_points_8[int(3)] = make_float2 (fx_32 * _S2806.x + cx_23, fy_32 * _S2806.y + cy_23); + _S2723 = true; + break; + } + bool all_valid_26 = _S2710 & _S2723; + _S2713 = &proj_points_8[int(4)]; + for(;;) + { + float2 _S2807 = float2 {_S2734.p_0[int(4)].x, _S2734.p_0[int(4)].y}; + float r_53 = length_0(_S2807); + float _S2808 = _S2734.p_0[int(4)].z; + _S2714 = _S2808; + float theta_46 = (F32_atan2((r_53), (_S2808))); + bool _S2809 = r_53 < 9.99999997475242708e-07f; + if(_S2809) + { + k_18 = (1.0f - theta_46 * theta_46 / 24.0f) / _S2808; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_46))) / r_53; + } + float2 _S2810 = _S2807 * make_float2 (k_18); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2811; + (&_S2811)->primal_0 = _S2810; + (&_S2811)->differential_0 = _S2704; + FixedArray _S2812 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2813 = s_fwd_DistOpenCV_distort_0(&_S2811, &_S2812); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2814; + (&_S2814)->primal_0 = _S2810; + (&_S2814)->differential_0 = _S2705; + FixedArray _S2815 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2816 = s_fwd_DistOpenCV_distort_0(&_S2814, &_S2815); + Matrix _S2817 = transpose_0(makeMatrix (_S2813.differential_0, _S2816.differential_0)); + float _S2818 = (F32_min((determinant_0(_S2817)), ((F32_min((_S2817.rows[int(0)].x), (_S2817.rows[int(1)].y)))))); + if(_S2818 > 0.25f) + { + _S2723 = _S2818 < 4.0f; + } + else + { + _S2723 = false; + } + if(_S2723) + { + FixedArray _S2819 = dist_coeffs_31; + float2 _S2820 = DistOpenCV_distort_0(_S2810, &_S2819); + _S2723 = (dot_0(_S2810, _S2820)) >= 0.0f; + } + else + { + _S2723 = false; + } + if(!_S2723) + { + proj_points_8[int(4)] = _S2810; + _S2723 = false; + break; + } + if(_S2809) + { + k_18 = (1.0f - theta_46 * theta_46 / 24.0f) / _S2808; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_46))) / r_53; + } + float2 _S2821 = _S2807 * make_float2 (k_18); + FixedArray _S2822 = dist_coeffs_31; + float2 _S2823 = DistOpenCV_distort_0(_S2821, &_S2822); + proj_points_8[int(4)] = make_float2 (fx_32 * _S2823.x + cx_23, fy_32 * _S2823.y + cy_23); + _S2723 = true; + break; + } + bool all_valid_27 = all_valid_26 & _S2723; + for(;;) + { + _S2715 = &proj_points_8[int(5)]; + for(;;) + { + float2 _S2824 = float2 {_S2734.p_0[int(5)].x, _S2734.p_0[int(5)].y}; + float r_54 = length_0(_S2824); + float _S2825 = _S2734.p_0[int(5)].z; + _S2716 = _S2825; + float theta_47 = (F32_atan2((r_54), (_S2825))); + bool _S2826 = r_54 < 9.99999997475242708e-07f; + if(_S2826) + { + k_18 = (1.0f - theta_47 * theta_47 / 24.0f) / _S2825; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_47))) / r_54; + } + float2 _S2827 = _S2824 * make_float2 (k_18); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2828; + (&_S2828)->primal_0 = _S2827; + (&_S2828)->differential_0 = _S2704; + FixedArray _S2829 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2830 = s_fwd_DistOpenCV_distort_0(&_S2828, &_S2829); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2831; + (&_S2831)->primal_0 = _S2827; + (&_S2831)->differential_0 = _S2705; + FixedArray _S2832 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2833 = s_fwd_DistOpenCV_distort_0(&_S2831, &_S2832); + Matrix _S2834 = transpose_0(makeMatrix (_S2830.differential_0, _S2833.differential_0)); + float _S2835 = (F32_min((determinant_0(_S2834)), ((F32_min((_S2834.rows[int(0)].x), (_S2834.rows[int(1)].y)))))); + if(_S2835 > 0.25f) + { + _S2723 = _S2835 < 4.0f; + } + else + { + _S2723 = false; + } + if(_S2723) + { + FixedArray _S2836 = dist_coeffs_31; + float2 _S2837 = DistOpenCV_distort_0(_S2827, &_S2836); + _S2723 = (dot_0(_S2827, _S2837)) >= 0.0f; + } + else + { + _S2723 = false; + } + if(!_S2723) + { + proj_points_8[int(5)] = _S2827; + _S2723 = false; + break; + } + if(_S2826) + { + k_18 = (1.0f - theta_47 * theta_47 / 24.0f) / _S2825; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_47))) / r_54; + } + float2 _S2838 = _S2824 * make_float2 (k_18); + FixedArray _S2839 = dist_coeffs_31; + float2 _S2840 = DistOpenCV_distort_0(_S2838, &_S2839); + proj_points_8[int(5)] = make_float2 (fx_32 * _S2840.x + cx_23, fy_32 * _S2840.y + cy_23); + _S2723 = true; + break; + } + _S2717 = all_valid_27 & _S2723; + break; + } + _S2718 = &proj_points_8[int(6)]; + for(;;) + { + float2 _S2841 = float2 {_S2734.p_0[int(6)].x, _S2734.p_0[int(6)].y}; + float r_55 = length_0(_S2841); + float _S2842 = _S2734.p_0[int(6)].z; + _S2719 = _S2842; + float theta_48 = (F32_atan2((r_55), (_S2842))); + bool _S2843 = r_55 < 9.99999997475242708e-07f; + if(_S2843) + { + k_18 = (1.0f - theta_48 * theta_48 / 24.0f) / _S2842; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_48))) / r_55; + } + float2 _S2844 = _S2841 * make_float2 (k_18); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2845; + (&_S2845)->primal_0 = _S2844; + (&_S2845)->differential_0 = _S2704; + FixedArray _S2846 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2847 = s_fwd_DistOpenCV_distort_0(&_S2845, &_S2846); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2848; + (&_S2848)->primal_0 = _S2844; + (&_S2848)->differential_0 = _S2705; + FixedArray _S2849 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2850 = s_fwd_DistOpenCV_distort_0(&_S2848, &_S2849); + Matrix _S2851 = transpose_0(makeMatrix (_S2847.differential_0, _S2850.differential_0)); + float _S2852 = (F32_min((determinant_0(_S2851)), ((F32_min((_S2851.rows[int(0)].x), (_S2851.rows[int(1)].y)))))); + if(_S2852 > 0.25f) + { + _S2723 = _S2852 < 4.0f; + } + else + { + _S2723 = false; + } + if(_S2723) + { + FixedArray _S2853 = dist_coeffs_31; + float2 _S2854 = DistOpenCV_distort_0(_S2844, &_S2853); + _S2723 = (dot_0(_S2844, _S2854)) >= 0.0f; + } + else + { + _S2723 = false; + } + if(!_S2723) + { + proj_points_8[int(6)] = _S2844; + _S2723 = false; + break; + } + if(_S2843) + { + k_18 = (1.0f - theta_48 * theta_48 / 24.0f) / _S2842; + } + else + { + k_18 = 2.0f * (F32_sin((0.5f * theta_48))) / r_55; + } + float2 _S2855 = _S2841 * make_float2 (k_18); + FixedArray _S2856 = dist_coeffs_31; + float2 _S2857 = DistOpenCV_distort_0(_S2855, &_S2856); + proj_points_8[int(6)] = make_float2 (fx_32 * _S2857.x + cx_23, fy_32 * _S2857.y + cy_23); + _S2723 = true; + break; + } + _S2720 = _S2717 & _S2723; + break; + } + if(!_S2720) + { + _S2723 = false; + break; + } + float2 p_25 = *_S2702 + (*_S2706 - *_S2702) * make_float2 (3.32899999618530273f); + float2 p_26 = *_S2702 + (*_S2708 - *_S2702) * make_float2 (3.32899999618530273f); + float2 p_27 = *_S2702 + (*_S2711 - *_S2702) * make_float2 (3.32899999618530273f); + float2 p_28 = *_S2702 + (*_S2713 - *_S2702) * make_float2 (3.32899999618530273f); + float2 p_29 = *_S2702 + (*_S2715 - *_S2702) * make_float2 (3.32899999618530273f); + float2 p_30 = *_S2702 + (*_S2718 - *_S2702) * make_float2 (3.32899999618530273f); + float2 _S2858 = make_float2 (cx_23, cy_23); + float2 min_p_4 = min_0(min_0(min_0(min_0(min_0(min_0(*_S2702, p_25), p_26), p_27), p_28), p_29), p_30) - _S2858; + float2 max_p_4 = max_0(max_0(max_0(max_0(max_0(max_0(*_S2702, p_25), p_26), p_27), p_28), p_29), p_30) - _S2858; + if((F32_max(((F32_max(((F32_max(((F32_max(((F32_max(((F32_max((_S2703), (_S2707)))), (_S2709)))), (_S2712)))), (_S2714)))), (_S2716)))), (_S2719))) <= 0.0f) + { + _S2723 = (min_p_4.x * max_p_4.x) < 0.0f; + } + else + { + _S2723 = false; + } + if(_S2723) + { + _S2723 = (min_p_4.y * max_p_4.y) < 0.0f; + } + else + { + _S2723 = false; + } + if(_S2723) + { + _S2723 = false; + break; + } + float2 _S2859 = *mean2d_32 + make_float2 (_S2734.w_mean_0[int(0)]) * *_S2702 + make_float2 (_S2734.w_mean_0[int(1)]) * *_S2706 + make_float2 (_S2734.w_mean_0[int(2)]) * *_S2708 + make_float2 (_S2734.w_mean_0[int(3)]) * *_S2711 + make_float2 (_S2734.w_mean_0[int(4)]) * *_S2713 + make_float2 (_S2734.w_mean_0[int(5)]) * *_S2715 + make_float2 (_S2734.w_mean_0[int(6)]) * *_S2718; + *mean2d_32 = _S2859; + float2 d_56 = *_S2702 - _S2859; + float _S2860 = d_56.x; + float _S2861 = d_56.y; + float _S2862 = _S2860 * _S2861; + float2 d_57 = *_S2706 - _S2859; + float _S2863 = d_57.x; + float _S2864 = d_57.y; + float _S2865 = _S2863 * _S2864; + float2 d_58 = *_S2708 - _S2859; + float _S2866 = d_58.x; + float _S2867 = d_58.y; + float _S2868 = _S2866 * _S2867; + float2 d_59 = *_S2711 - _S2859; + float _S2869 = d_59.x; + float _S2870 = d_59.y; + float _S2871 = _S2869 * _S2870; + float2 d_60 = *_S2713 - _S2859; + float _S2872 = d_60.x; + float _S2873 = d_60.y; + float _S2874 = _S2872 * _S2873; + float2 d_61 = *_S2715 - _S2859; + float _S2875 = d_61.x; + float _S2876 = d_61.y; + float _S2877 = _S2875 * _S2876; + float2 d_62 = *_S2718 - _S2859; + float _S2878 = d_62.x; + float _S2879 = d_62.y; + float _S2880 = _S2878 * _S2879; + covar2d_19 = covar2d_19 + makeMatrix (_S2734.w_cov_0[int(0)]) * makeMatrix (_S2860 * _S2860, _S2862, _S2862, _S2861 * _S2861) + makeMatrix (_S2734.w_cov_0[int(1)]) * makeMatrix (_S2863 * _S2863, _S2865, _S2865, _S2864 * _S2864) + makeMatrix (_S2734.w_cov_0[int(2)]) * makeMatrix (_S2866 * _S2866, _S2868, _S2868, _S2867 * _S2867) + makeMatrix (_S2734.w_cov_0[int(3)]) * makeMatrix (_S2869 * _S2869, _S2871, _S2871, _S2870 * _S2870) + makeMatrix (_S2734.w_cov_0[int(4)]) * makeMatrix (_S2872 * _S2872, _S2874, _S2874, _S2873 * _S2873) + makeMatrix (_S2734.w_cov_0[int(5)]) * makeMatrix (_S2875 * _S2875, _S2877, _S2877, _S2876 * _S2876) + makeMatrix (_S2734.w_cov_0[int(6)]) * makeMatrix (_S2878 * _S2878, _S2880, _S2880, _S2879 * _S2879); + _S2723 = true; + break; + } + if(!(true & _S2723)) + { + *aabb_xyxy_19 = _S2721; + break; + } + float eps2d_19; + if(antialiased_19) + { + eps2d_19 = 0.10000000149011612f; + } + else + { + eps2d_19 = 0.30000001192092896f; + } + float det_orig_19 = *&(((&covar2d_19)->rows + (int(0)))->x) * *&(((&covar2d_19)->rows + (int(1)))->y) - *&(((&covar2d_19)->rows + (int(0)))->y) * *&(((&covar2d_19)->rows + (int(1)))->x); + float _S2881 = *&(((&covar2d_19)->rows + (int(0)))->x) + eps2d_19; + *&(((&covar2d_19)->rows + (int(0)))->x) = _S2881; + float _S2882 = *&(((&covar2d_19)->rows + (int(1)))->y) + eps2d_19; + *&(((&covar2d_19)->rows + (int(1)))->y) = _S2882; + float det_blur_19 = _S2881 * _S2882 - *&(((&covar2d_19)->rows + (int(0)))->y) * *&(((&covar2d_19)->rows + (int(1)))->x); + float compensation_19 = (F32_sqrt(((F32_max((0.0f), (det_orig_19 / det_blur_19)))))); + if(det_blur_19 <= 0.0f) + { + *aabb_xyxy_19 = _S2721; + break; + } + float invdet_25 = 1.0f / (covar2d_19.rows[int(0)].x * covar2d_19.rows[int(1)].y - covar2d_19.rows[int(0)].y * covar2d_19.rows[int(1)].x); + Matrix _S2883 = makeMatrix (covar2d_19.rows[int(1)].y * invdet_25, - covar2d_19.rows[int(0)].y * invdet_25, - covar2d_19.rows[int(1)].x * invdet_25, covar2d_19.rows[int(0)].x * invdet_25); + if(antialiased_19) + { + *opacity_19 = *opacity_19 * compensation_19; + } + if((*opacity_19) < 0.00392156885936856f) + { + *aabb_xyxy_19 = _S2721; + break; + } + float _S2884 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_19 / 0.00392156885936856f))))))))); + float radius_x_19 = _S2884 * (F32_sqrt((covar2d_19[int(0)].x))); + float radius_y_19 = _S2884 * (F32_sqrt((covar2d_19[int(1)].y))); + float _S2885 = (*mean2d_32).x - radius_x_19; + float _S2886 = (*mean2d_32).x + radius_x_19; + float _S2887 = (*mean2d_32).y - radius_y_19; + float _S2888 = (*mean2d_32).y + radius_y_19; + if(_S2886 <= 0.0f) + { + _S2723 = true; + } + else + { + _S2723 = _S2885 >= float(image_width_19); + } + if(_S2723) + { + _S2723 = true; + } + else + { + _S2723 = _S2888 <= 0.0f; + } + if(_S2723) + { + _S2723 = true; + } + else + { + _S2723 = _S2887 >= float(image_height_19); + } + if(_S2723) + { + *aabb_xyxy_19 = _S2721; + break; + } + *aabb_xyxy_19 = make_float4 (_S2885, _S2887, _S2886, _S2888); + float x_45 = mean_c_19.x; + float y_15 = mean_c_19.y; + float z_4 = mean_c_19.z; + float _S2889 = x_45 * x_45 + y_15 * y_15; + *sorting_depth_19 = z_4 * z_4 * z_4 * z_4 + 0.001953125f * _S2889 * _S2889; + *conic_19 = make_float3 (_S2883.rows[int(0)].x, _S2883.rows[int(0)].y, _S2883.rows[int(1)].y); + *radius_20 = view_radius_3dgs_0(mean_20, scale_19, in_opacity_19, - mul_6(transpose_3(R_19), t_19)); + break; + } + return; } -inline __device__ Matrix s_primal_ctx_mul_2(Matrix _S1305, Matrix _S1306) +inline __device__ void projection_3dgut_equisolid_prism(bool antialiased_20, float3 mean_21, float4 quat_20, float3 scale_20, float in_opacity_20, Matrix R_20, float3 t_20, float fx_33, float fy_33, float cx_24, float cy_24, FixedArray dist_coeffs_32, uint image_width_20, uint image_height_20, float4 * aabb_xyxy_20, float * sorting_depth_20, float * radius_21, float2 * mean2d_33, float * depth_20, float3 * conic_20, float * opacity_20) { - return mul_3(_S1305, _S1306); + float2 * _S2890; + float _S2891; + float2 _S2892; + float2 _S2893; + float2 * _S2894; + float _S2895; + float2 * _S2896; + float _S2897; + bool _S2898; + float2 * _S2899; + float _S2900; + float2 * _S2901; + float _S2902; + float2 * _S2903; + float _S2904; + bool _S2905; + float2 * _S2906; + float _S2907; + bool _S2908; + for(;;) + { + float4 _S2909 = make_float4 (0.0f); + *aabb_xyxy_20 = _S2909; + *sorting_depth_20 = 0.0f; + *radius_21 = 0.0f; + *mean2d_33 = make_float2 (0.0f); + *conic_20 = make_float3 (0.0f); + *opacity_20 = 0.0f; + float3 mean_c_20 = mul_6(R_20, mean_21) + t_20; + float _S2910 = length_1(mean_c_20); + *depth_20 = _S2910; + if(_S2910 <= 0.0f) + { + *aabb_xyxy_20 = _S2909; + break; + } + Matrix covar2d_20; + *opacity_20 = 1.0f / (1.0f + (F32_exp((- in_opacity_20)))); + bool _S2911; + float3 _S2912 = exp_0(scale_20); + float4 _S2913 = normalize_0(quat_20); + float x_46 = _S2913.y; + float x2_20 = x_46 * x_46; + float y2_20 = _S2913.z * _S2913.z; + float z2_20 = _S2913.w * _S2913.w; + float xy_20 = _S2913.y * _S2913.z; + float xz_20 = _S2913.y * _S2913.w; + float yz_20 = _S2913.z * _S2913.w; + float wx_20 = _S2913.x * _S2913.y; + float wy_20 = _S2913.x * _S2913.z; + float wz_20 = _S2913.x * _S2913.w; + Matrix _S2914 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_20 + z2_20), 2.0f * (xy_20 + wz_20), 2.0f * (xz_20 - wy_20), 2.0f * (xy_20 - wz_20), 1.0f - 2.0f * (x2_20 + z2_20), 2.0f * (yz_20 + wx_20), 2.0f * (xz_20 + wy_20), 2.0f * (yz_20 - wx_20), 1.0f - 2.0f * (x2_20 + y2_20)))); + SigmaPoints_0 ret_9; + (&ret_9)->p_0[int(0)] = mean_21; + (&ret_9)->w_mean_0[int(0)] = 0.0f; + (&ret_9)->w_cov_0[int(0)] = 2.0f; + float _S2915 = (F32_sqrt((3.0f))); + float3 delta_27 = make_float3 (_S2915 * _S2912.x) * _S2914.rows[0U]; + float3 _S2916 = mean_21 + delta_27; + float3 _S2917 = mean_21 - delta_27; + float3 delta_28 = make_float3 (_S2915 * _S2912.y) * _S2914.rows[1U]; + float3 _S2918 = mean_21 + delta_28; + float3 _S2919 = mean_21 - delta_28; + float3 delta_29 = make_float3 (_S2915 * _S2912.z) * _S2914.rows[2U]; + float3 _S2920 = mean_21 + delta_29; + float3 _S2921 = mean_21 - delta_29; + (&ret_9)->w_mean_0[1U] = 0.1666666716337204f; + (&ret_9)->w_cov_0[1U] = 0.1666666716337204f; + (&ret_9)->w_mean_0[2U] = 0.1666666716337204f; + (&ret_9)->w_cov_0[2U] = 0.1666666716337204f; + (&ret_9)->w_mean_0[3U] = 0.1666666716337204f; + (&ret_9)->w_cov_0[3U] = 0.1666666716337204f; + (&ret_9)->w_mean_0[4U] = 0.1666666716337204f; + (&ret_9)->w_cov_0[4U] = 0.1666666716337204f; + (&ret_9)->w_mean_0[5U] = 0.1666666716337204f; + (&ret_9)->w_cov_0[5U] = 0.1666666716337204f; + (&ret_9)->w_mean_0[6U] = 0.1666666716337204f; + (&ret_9)->w_cov_0[6U] = 0.1666666716337204f; + (&ret_9)->p_0[0U] = mul_6(R_20, (&ret_9)->p_0[0U]) + t_20; + (&ret_9)->p_0[1U] = mul_6(R_20, _S2916) + t_20; + (&ret_9)->p_0[2U] = mul_6(R_20, _S2918) + t_20; + (&ret_9)->p_0[3U] = mul_6(R_20, _S2920) + t_20; + (&ret_9)->p_0[4U] = mul_6(R_20, _S2917) + t_20; + (&ret_9)->p_0[5U] = mul_6(R_20, _S2919) + t_20; + (&ret_9)->p_0[6U] = mul_6(R_20, _S2921) + t_20; + SigmaPoints_0 _S2922 = ret_9; + for(;;) + { + int2 _S2923 = make_int2 (int(0)); + float2 _S2924 = make_float2 ((float)_S2923.x, (float)_S2923.y); + *mean2d_33 = _S2924; + covar2d_20 = makeMatrix (0.0f); + FixedArray proj_points_9; + for(;;) + { + float k_19; + _S2890 = &proj_points_9[int(0)]; + for(;;) + { + float2 _S2925 = float2 {_S2922.p_0[int(0)].x, _S2922.p_0[int(0)].y}; + float r_56 = length_0(_S2925); + float _S2926 = _S2922.p_0[int(0)].z; + _S2891 = _S2926; + float theta_49 = (F32_atan2((r_56), (_S2926))); + bool _S2927 = r_56 < 9.99999997475242708e-07f; + if(_S2927) + { + k_19 = (1.0f - theta_49 * theta_49 / 24.0f) / _S2926; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_49))) / r_56; + } + float2 _S2928 = _S2925 * make_float2 (k_19); + float2 _S2929 = make_float2 (1.0f, 0.0f); + _S2892 = _S2929; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2930; + (&_S2930)->primal_0 = _S2928; + (&_S2930)->differential_0 = _S2929; + FixedArray _S2931 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2932 = s_fwd_DistThinPrism_distort_0(&_S2930, &_S2931); + float2 _S2933 = make_float2 (0.0f, 1.0f); + _S2893 = _S2933; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2934; + (&_S2934)->primal_0 = _S2928; + (&_S2934)->differential_0 = _S2933; + FixedArray _S2935 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2936 = s_fwd_DistThinPrism_distort_0(&_S2934, &_S2935); + Matrix _S2937 = transpose_0(makeMatrix (_S2932.differential_0, _S2936.differential_0)); + float _S2938 = (F32_min((determinant_0(_S2937)), ((F32_min((_S2937.rows[int(0)].x), (_S2937.rows[int(1)].y)))))); + if(_S2938 > 0.25f) + { + _S2911 = _S2938 < 4.0f; + } + else + { + _S2911 = false; + } + if(_S2911) + { + FixedArray _S2939 = dist_coeffs_32; + float2 _S2940 = DistThinPrism_distort_0(_S2928, &_S2939); + _S2911 = (dot_0(_S2928, _S2940)) >= 0.0f; + } + else + { + _S2911 = false; + } + if(!_S2911) + { + proj_points_9[int(0)] = _S2928; + _S2911 = false; + break; + } + if(_S2927) + { + k_19 = (1.0f - theta_49 * theta_49 / 24.0f) / _S2926; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_49))) / r_56; + } + float2 _S2941 = _S2925 * make_float2 (k_19); + FixedArray _S2942 = dist_coeffs_32; + float2 _S2943 = DistThinPrism_distort_0(_S2941, &_S2942); + proj_points_9[int(0)] = make_float2 (fx_33 * _S2943.x + cx_24, fy_33 * _S2943.y + cy_24); + _S2911 = true; + break; + } + bool all_valid_28 = true & _S2911; + _S2894 = &proj_points_9[int(1)]; + for(;;) + { + float2 _S2944 = float2 {_S2922.p_0[int(1)].x, _S2922.p_0[int(1)].y}; + float r_57 = length_0(_S2944); + float _S2945 = _S2922.p_0[int(1)].z; + _S2895 = _S2945; + float theta_50 = (F32_atan2((r_57), (_S2945))); + bool _S2946 = r_57 < 9.99999997475242708e-07f; + if(_S2946) + { + k_19 = (1.0f - theta_50 * theta_50 / 24.0f) / _S2945; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_50))) / r_57; + } + float2 _S2947 = _S2944 * make_float2 (k_19); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2948; + (&_S2948)->primal_0 = _S2947; + (&_S2948)->differential_0 = _S2892; + FixedArray _S2949 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2950 = s_fwd_DistThinPrism_distort_0(&_S2948, &_S2949); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2951; + (&_S2951)->primal_0 = _S2947; + (&_S2951)->differential_0 = _S2893; + FixedArray _S2952 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2953 = s_fwd_DistThinPrism_distort_0(&_S2951, &_S2952); + Matrix _S2954 = transpose_0(makeMatrix (_S2950.differential_0, _S2953.differential_0)); + float _S2955 = (F32_min((determinant_0(_S2954)), ((F32_min((_S2954.rows[int(0)].x), (_S2954.rows[int(1)].y)))))); + if(_S2955 > 0.25f) + { + _S2911 = _S2955 < 4.0f; + } + else + { + _S2911 = false; + } + if(_S2911) + { + FixedArray _S2956 = dist_coeffs_32; + float2 _S2957 = DistThinPrism_distort_0(_S2947, &_S2956); + _S2911 = (dot_0(_S2947, _S2957)) >= 0.0f; + } + else + { + _S2911 = false; + } + if(!_S2911) + { + proj_points_9[int(1)] = _S2947; + _S2911 = false; + break; + } + if(_S2946) + { + k_19 = (1.0f - theta_50 * theta_50 / 24.0f) / _S2945; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_50))) / r_57; + } + float2 _S2958 = _S2944 * make_float2 (k_19); + FixedArray _S2959 = dist_coeffs_32; + float2 _S2960 = DistThinPrism_distort_0(_S2958, &_S2959); + proj_points_9[int(1)] = make_float2 (fx_33 * _S2960.x + cx_24, fy_33 * _S2960.y + cy_24); + _S2911 = true; + break; + } + bool all_valid_29 = all_valid_28 & _S2911; + for(;;) + { + _S2896 = &proj_points_9[int(2)]; + for(;;) + { + float2 _S2961 = float2 {_S2922.p_0[int(2)].x, _S2922.p_0[int(2)].y}; + float r_58 = length_0(_S2961); + float _S2962 = _S2922.p_0[int(2)].z; + _S2897 = _S2962; + float theta_51 = (F32_atan2((r_58), (_S2962))); + bool _S2963 = r_58 < 9.99999997475242708e-07f; + if(_S2963) + { + k_19 = (1.0f - theta_51 * theta_51 / 24.0f) / _S2962; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_51))) / r_58; + } + float2 _S2964 = _S2961 * make_float2 (k_19); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2965; + (&_S2965)->primal_0 = _S2964; + (&_S2965)->differential_0 = _S2892; + FixedArray _S2966 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2967 = s_fwd_DistThinPrism_distort_0(&_S2965, &_S2966); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2968; + (&_S2968)->primal_0 = _S2964; + (&_S2968)->differential_0 = _S2893; + FixedArray _S2969 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2970 = s_fwd_DistThinPrism_distort_0(&_S2968, &_S2969); + Matrix _S2971 = transpose_0(makeMatrix (_S2967.differential_0, _S2970.differential_0)); + float _S2972 = (F32_min((determinant_0(_S2971)), ((F32_min((_S2971.rows[int(0)].x), (_S2971.rows[int(1)].y)))))); + if(_S2972 > 0.25f) + { + _S2911 = _S2972 < 4.0f; + } + else + { + _S2911 = false; + } + if(_S2911) + { + FixedArray _S2973 = dist_coeffs_32; + float2 _S2974 = DistThinPrism_distort_0(_S2964, &_S2973); + _S2911 = (dot_0(_S2964, _S2974)) >= 0.0f; + } + else + { + _S2911 = false; + } + if(!_S2911) + { + proj_points_9[int(2)] = _S2964; + _S2911 = false; + break; + } + if(_S2963) + { + k_19 = (1.0f - theta_51 * theta_51 / 24.0f) / _S2962; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_51))) / r_58; + } + float2 _S2975 = _S2961 * make_float2 (k_19); + FixedArray _S2976 = dist_coeffs_32; + float2 _S2977 = DistThinPrism_distort_0(_S2975, &_S2976); + proj_points_9[int(2)] = make_float2 (fx_33 * _S2977.x + cx_24, fy_33 * _S2977.y + cy_24); + _S2911 = true; + break; + } + _S2898 = all_valid_29 & _S2911; + break; + } + _S2899 = &proj_points_9[int(3)]; + for(;;) + { + float2 _S2978 = float2 {_S2922.p_0[int(3)].x, _S2922.p_0[int(3)].y}; + float r_59 = length_0(_S2978); + float _S2979 = _S2922.p_0[int(3)].z; + _S2900 = _S2979; + float theta_52 = (F32_atan2((r_59), (_S2979))); + bool _S2980 = r_59 < 9.99999997475242708e-07f; + if(_S2980) + { + k_19 = (1.0f - theta_52 * theta_52 / 24.0f) / _S2979; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_52))) / r_59; + } + float2 _S2981 = _S2978 * make_float2 (k_19); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2982; + (&_S2982)->primal_0 = _S2981; + (&_S2982)->differential_0 = _S2892; + FixedArray _S2983 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2984 = s_fwd_DistThinPrism_distort_0(&_S2982, &_S2983); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2985; + (&_S2985)->primal_0 = _S2981; + (&_S2985)->differential_0 = _S2893; + FixedArray _S2986 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2987 = s_fwd_DistThinPrism_distort_0(&_S2985, &_S2986); + Matrix _S2988 = transpose_0(makeMatrix (_S2984.differential_0, _S2987.differential_0)); + float _S2989 = (F32_min((determinant_0(_S2988)), ((F32_min((_S2988.rows[int(0)].x), (_S2988.rows[int(1)].y)))))); + if(_S2989 > 0.25f) + { + _S2911 = _S2989 < 4.0f; + } + else + { + _S2911 = false; + } + if(_S2911) + { + FixedArray _S2990 = dist_coeffs_32; + float2 _S2991 = DistThinPrism_distort_0(_S2981, &_S2990); + _S2911 = (dot_0(_S2981, _S2991)) >= 0.0f; + } + else + { + _S2911 = false; + } + if(!_S2911) + { + proj_points_9[int(3)] = _S2981; + _S2911 = false; + break; + } + if(_S2980) + { + k_19 = (1.0f - theta_52 * theta_52 / 24.0f) / _S2979; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_52))) / r_59; + } + float2 _S2992 = _S2978 * make_float2 (k_19); + FixedArray _S2993 = dist_coeffs_32; + float2 _S2994 = DistThinPrism_distort_0(_S2992, &_S2993); + proj_points_9[int(3)] = make_float2 (fx_33 * _S2994.x + cx_24, fy_33 * _S2994.y + cy_24); + _S2911 = true; + break; + } + bool all_valid_30 = _S2898 & _S2911; + _S2901 = &proj_points_9[int(4)]; + for(;;) + { + float2 _S2995 = float2 {_S2922.p_0[int(4)].x, _S2922.p_0[int(4)].y}; + float r_60 = length_0(_S2995); + float _S2996 = _S2922.p_0[int(4)].z; + _S2902 = _S2996; + float theta_53 = (F32_atan2((r_60), (_S2996))); + bool _S2997 = r_60 < 9.99999997475242708e-07f; + if(_S2997) + { + k_19 = (1.0f - theta_53 * theta_53 / 24.0f) / _S2996; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_53))) / r_60; + } + float2 _S2998 = _S2995 * make_float2 (k_19); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S2999; + (&_S2999)->primal_0 = _S2998; + (&_S2999)->differential_0 = _S2892; + FixedArray _S3000 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3001 = s_fwd_DistThinPrism_distort_0(&_S2999, &_S3000); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3002; + (&_S3002)->primal_0 = _S2998; + (&_S3002)->differential_0 = _S2893; + FixedArray _S3003 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3004 = s_fwd_DistThinPrism_distort_0(&_S3002, &_S3003); + Matrix _S3005 = transpose_0(makeMatrix (_S3001.differential_0, _S3004.differential_0)); + float _S3006 = (F32_min((determinant_0(_S3005)), ((F32_min((_S3005.rows[int(0)].x), (_S3005.rows[int(1)].y)))))); + if(_S3006 > 0.25f) + { + _S2911 = _S3006 < 4.0f; + } + else + { + _S2911 = false; + } + if(_S2911) + { + FixedArray _S3007 = dist_coeffs_32; + float2 _S3008 = DistThinPrism_distort_0(_S2998, &_S3007); + _S2911 = (dot_0(_S2998, _S3008)) >= 0.0f; + } + else + { + _S2911 = false; + } + if(!_S2911) + { + proj_points_9[int(4)] = _S2998; + _S2911 = false; + break; + } + if(_S2997) + { + k_19 = (1.0f - theta_53 * theta_53 / 24.0f) / _S2996; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_53))) / r_60; + } + float2 _S3009 = _S2995 * make_float2 (k_19); + FixedArray _S3010 = dist_coeffs_32; + float2 _S3011 = DistThinPrism_distort_0(_S3009, &_S3010); + proj_points_9[int(4)] = make_float2 (fx_33 * _S3011.x + cx_24, fy_33 * _S3011.y + cy_24); + _S2911 = true; + break; + } + bool all_valid_31 = all_valid_30 & _S2911; + for(;;) + { + _S2903 = &proj_points_9[int(5)]; + for(;;) + { + float2 _S3012 = float2 {_S2922.p_0[int(5)].x, _S2922.p_0[int(5)].y}; + float r_61 = length_0(_S3012); + float _S3013 = _S2922.p_0[int(5)].z; + _S2904 = _S3013; + float theta_54 = (F32_atan2((r_61), (_S3013))); + bool _S3014 = r_61 < 9.99999997475242708e-07f; + if(_S3014) + { + k_19 = (1.0f - theta_54 * theta_54 / 24.0f) / _S3013; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_54))) / r_61; + } + float2 _S3015 = _S3012 * make_float2 (k_19); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3016; + (&_S3016)->primal_0 = _S3015; + (&_S3016)->differential_0 = _S2892; + FixedArray _S3017 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3018 = s_fwd_DistThinPrism_distort_0(&_S3016, &_S3017); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3019; + (&_S3019)->primal_0 = _S3015; + (&_S3019)->differential_0 = _S2893; + FixedArray _S3020 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3021 = s_fwd_DistThinPrism_distort_0(&_S3019, &_S3020); + Matrix _S3022 = transpose_0(makeMatrix (_S3018.differential_0, _S3021.differential_0)); + float _S3023 = (F32_min((determinant_0(_S3022)), ((F32_min((_S3022.rows[int(0)].x), (_S3022.rows[int(1)].y)))))); + if(_S3023 > 0.25f) + { + _S2911 = _S3023 < 4.0f; + } + else + { + _S2911 = false; + } + if(_S2911) + { + FixedArray _S3024 = dist_coeffs_32; + float2 _S3025 = DistThinPrism_distort_0(_S3015, &_S3024); + _S2911 = (dot_0(_S3015, _S3025)) >= 0.0f; + } + else + { + _S2911 = false; + } + if(!_S2911) + { + proj_points_9[int(5)] = _S3015; + _S2911 = false; + break; + } + if(_S3014) + { + k_19 = (1.0f - theta_54 * theta_54 / 24.0f) / _S3013; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_54))) / r_61; + } + float2 _S3026 = _S3012 * make_float2 (k_19); + FixedArray _S3027 = dist_coeffs_32; + float2 _S3028 = DistThinPrism_distort_0(_S3026, &_S3027); + proj_points_9[int(5)] = make_float2 (fx_33 * _S3028.x + cx_24, fy_33 * _S3028.y + cy_24); + _S2911 = true; + break; + } + _S2905 = all_valid_31 & _S2911; + break; + } + _S2906 = &proj_points_9[int(6)]; + for(;;) + { + float2 _S3029 = float2 {_S2922.p_0[int(6)].x, _S2922.p_0[int(6)].y}; + float r_62 = length_0(_S3029); + float _S3030 = _S2922.p_0[int(6)].z; + _S2907 = _S3030; + float theta_55 = (F32_atan2((r_62), (_S3030))); + bool _S3031 = r_62 < 9.99999997475242708e-07f; + if(_S3031) + { + k_19 = (1.0f - theta_55 * theta_55 / 24.0f) / _S3030; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_55))) / r_62; + } + float2 _S3032 = _S3029 * make_float2 (k_19); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3033; + (&_S3033)->primal_0 = _S3032; + (&_S3033)->differential_0 = _S2892; + FixedArray _S3034 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3035 = s_fwd_DistThinPrism_distort_0(&_S3033, &_S3034); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3036; + (&_S3036)->primal_0 = _S3032; + (&_S3036)->differential_0 = _S2893; + FixedArray _S3037 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3038 = s_fwd_DistThinPrism_distort_0(&_S3036, &_S3037); + Matrix _S3039 = transpose_0(makeMatrix (_S3035.differential_0, _S3038.differential_0)); + float _S3040 = (F32_min((determinant_0(_S3039)), ((F32_min((_S3039.rows[int(0)].x), (_S3039.rows[int(1)].y)))))); + if(_S3040 > 0.25f) + { + _S2911 = _S3040 < 4.0f; + } + else + { + _S2911 = false; + } + if(_S2911) + { + FixedArray _S3041 = dist_coeffs_32; + float2 _S3042 = DistThinPrism_distort_0(_S3032, &_S3041); + _S2911 = (dot_0(_S3032, _S3042)) >= 0.0f; + } + else + { + _S2911 = false; + } + if(!_S2911) + { + proj_points_9[int(6)] = _S3032; + _S2911 = false; + break; + } + if(_S3031) + { + k_19 = (1.0f - theta_55 * theta_55 / 24.0f) / _S3030; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_55))) / r_62; + } + float2 _S3043 = _S3029 * make_float2 (k_19); + FixedArray _S3044 = dist_coeffs_32; + float2 _S3045 = DistThinPrism_distort_0(_S3043, &_S3044); + proj_points_9[int(6)] = make_float2 (fx_33 * _S3045.x + cx_24, fy_33 * _S3045.y + cy_24); + _S2911 = true; + break; + } + _S2908 = _S2905 & _S2911; + break; + } + if(!_S2908) + { + _S2911 = false; + break; + } + float2 p_31 = *_S2890 + (*_S2894 - *_S2890) * make_float2 (3.32899999618530273f); + float2 p_32 = *_S2890 + (*_S2896 - *_S2890) * make_float2 (3.32899999618530273f); + float2 p_33 = *_S2890 + (*_S2899 - *_S2890) * make_float2 (3.32899999618530273f); + float2 p_34 = *_S2890 + (*_S2901 - *_S2890) * make_float2 (3.32899999618530273f); + float2 p_35 = *_S2890 + (*_S2903 - *_S2890) * make_float2 (3.32899999618530273f); + float2 p_36 = *_S2890 + (*_S2906 - *_S2890) * make_float2 (3.32899999618530273f); + float2 _S3046 = make_float2 (cx_24, cy_24); + float2 min_p_5 = min_0(min_0(min_0(min_0(min_0(min_0(*_S2890, p_31), p_32), p_33), p_34), p_35), p_36) - _S3046; + float2 max_p_5 = max_0(max_0(max_0(max_0(max_0(max_0(*_S2890, p_31), p_32), p_33), p_34), p_35), p_36) - _S3046; + if((F32_max(((F32_max(((F32_max(((F32_max(((F32_max(((F32_max((_S2891), (_S2895)))), (_S2897)))), (_S2900)))), (_S2902)))), (_S2904)))), (_S2907))) <= 0.0f) + { + _S2911 = (min_p_5.x * max_p_5.x) < 0.0f; + } + else + { + _S2911 = false; + } + if(_S2911) + { + _S2911 = (min_p_5.y * max_p_5.y) < 0.0f; + } + else + { + _S2911 = false; + } + if(_S2911) + { + _S2911 = false; + break; + } + float2 _S3047 = *mean2d_33 + make_float2 (_S2922.w_mean_0[int(0)]) * *_S2890 + make_float2 (_S2922.w_mean_0[int(1)]) * *_S2894 + make_float2 (_S2922.w_mean_0[int(2)]) * *_S2896 + make_float2 (_S2922.w_mean_0[int(3)]) * *_S2899 + make_float2 (_S2922.w_mean_0[int(4)]) * *_S2901 + make_float2 (_S2922.w_mean_0[int(5)]) * *_S2903 + make_float2 (_S2922.w_mean_0[int(6)]) * *_S2906; + *mean2d_33 = _S3047; + float2 d_63 = *_S2890 - _S3047; + float _S3048 = d_63.x; + float _S3049 = d_63.y; + float _S3050 = _S3048 * _S3049; + float2 d_64 = *_S2894 - _S3047; + float _S3051 = d_64.x; + float _S3052 = d_64.y; + float _S3053 = _S3051 * _S3052; + float2 d_65 = *_S2896 - _S3047; + float _S3054 = d_65.x; + float _S3055 = d_65.y; + float _S3056 = _S3054 * _S3055; + float2 d_66 = *_S2899 - _S3047; + float _S3057 = d_66.x; + float _S3058 = d_66.y; + float _S3059 = _S3057 * _S3058; + float2 d_67 = *_S2901 - _S3047; + float _S3060 = d_67.x; + float _S3061 = d_67.y; + float _S3062 = _S3060 * _S3061; + float2 d_68 = *_S2903 - _S3047; + float _S3063 = d_68.x; + float _S3064 = d_68.y; + float _S3065 = _S3063 * _S3064; + float2 d_69 = *_S2906 - _S3047; + float _S3066 = d_69.x; + float _S3067 = d_69.y; + float _S3068 = _S3066 * _S3067; + covar2d_20 = covar2d_20 + makeMatrix (_S2922.w_cov_0[int(0)]) * makeMatrix (_S3048 * _S3048, _S3050, _S3050, _S3049 * _S3049) + makeMatrix (_S2922.w_cov_0[int(1)]) * makeMatrix (_S3051 * _S3051, _S3053, _S3053, _S3052 * _S3052) + makeMatrix (_S2922.w_cov_0[int(2)]) * makeMatrix (_S3054 * _S3054, _S3056, _S3056, _S3055 * _S3055) + makeMatrix (_S2922.w_cov_0[int(3)]) * makeMatrix (_S3057 * _S3057, _S3059, _S3059, _S3058 * _S3058) + makeMatrix (_S2922.w_cov_0[int(4)]) * makeMatrix (_S3060 * _S3060, _S3062, _S3062, _S3061 * _S3061) + makeMatrix (_S2922.w_cov_0[int(5)]) * makeMatrix (_S3063 * _S3063, _S3065, _S3065, _S3064 * _S3064) + makeMatrix (_S2922.w_cov_0[int(6)]) * makeMatrix (_S3066 * _S3066, _S3068, _S3068, _S3067 * _S3067); + _S2911 = true; + break; + } + if(!(true & _S2911)) + { + *aabb_xyxy_20 = _S2909; + break; + } + float eps2d_20; + if(antialiased_20) + { + eps2d_20 = 0.10000000149011612f; + } + else + { + eps2d_20 = 0.30000001192092896f; + } + float det_orig_20 = *&(((&covar2d_20)->rows + (int(0)))->x) * *&(((&covar2d_20)->rows + (int(1)))->y) - *&(((&covar2d_20)->rows + (int(0)))->y) * *&(((&covar2d_20)->rows + (int(1)))->x); + float _S3069 = *&(((&covar2d_20)->rows + (int(0)))->x) + eps2d_20; + *&(((&covar2d_20)->rows + (int(0)))->x) = _S3069; + float _S3070 = *&(((&covar2d_20)->rows + (int(1)))->y) + eps2d_20; + *&(((&covar2d_20)->rows + (int(1)))->y) = _S3070; + float det_blur_20 = _S3069 * _S3070 - *&(((&covar2d_20)->rows + (int(0)))->y) * *&(((&covar2d_20)->rows + (int(1)))->x); + float compensation_20 = (F32_sqrt(((F32_max((0.0f), (det_orig_20 / det_blur_20)))))); + if(det_blur_20 <= 0.0f) + { + *aabb_xyxy_20 = _S2909; + break; + } + float invdet_26 = 1.0f / (covar2d_20.rows[int(0)].x * covar2d_20.rows[int(1)].y - covar2d_20.rows[int(0)].y * covar2d_20.rows[int(1)].x); + Matrix _S3071 = makeMatrix (covar2d_20.rows[int(1)].y * invdet_26, - covar2d_20.rows[int(0)].y * invdet_26, - covar2d_20.rows[int(1)].x * invdet_26, covar2d_20.rows[int(0)].x * invdet_26); + if(antialiased_20) + { + *opacity_20 = *opacity_20 * compensation_20; + } + if((*opacity_20) < 0.00392156885936856f) + { + *aabb_xyxy_20 = _S2909; + break; + } + float _S3072 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_20 / 0.00392156885936856f))))))))); + float radius_x_20 = _S3072 * (F32_sqrt((covar2d_20[int(0)].x))); + float radius_y_20 = _S3072 * (F32_sqrt((covar2d_20[int(1)].y))); + float _S3073 = (*mean2d_33).x - radius_x_20; + float _S3074 = (*mean2d_33).x + radius_x_20; + float _S3075 = (*mean2d_33).y - radius_y_20; + float _S3076 = (*mean2d_33).y + radius_y_20; + if(_S3074 <= 0.0f) + { + _S2911 = true; + } + else + { + _S2911 = _S3073 >= float(image_width_20); + } + if(_S2911) + { + _S2911 = true; + } + else + { + _S2911 = _S3076 <= 0.0f; + } + if(_S2911) + { + _S2911 = true; + } + else + { + _S2911 = _S3075 >= float(image_height_20); + } + if(_S2911) + { + *aabb_xyxy_20 = _S2909; + break; + } + *aabb_xyxy_20 = make_float4 (_S3073, _S3075, _S3074, _S3076); + float x_47 = mean_c_20.x; + float y_16 = mean_c_20.y; + float z_5 = mean_c_20.z; + float _S3077 = x_47 * x_47 + y_16 * y_16; + *sorting_depth_20 = z_5 * z_5 * z_5 * z_5 + 0.001953125f * _S3077 * _S3077; + *conic_20 = make_float3 (_S3071.rows[int(0)].x, _S3071.rows[int(0)].y, _S3071.rows[int(1)].y); + *radius_21 = view_radius_3dgs_0(mean_21, scale_20, in_opacity_20, - mul_6(transpose_3(R_20), t_20)); + break; + } + return; } -inline __device__ Matrix s_primal_ctx_mul_3(Matrix _S1307, Matrix _S1308) +inline __device__ void projection_3dgut_equirect_none(bool antialiased_21, float3 mean_22, float4 quat_21, float3 scale_21, float in_opacity_21, Matrix R_21, float3 t_21, float fx_34, float fy_34, float cx_25, float cy_25, FixedArray dist_coeffs_33, uint image_width_21, uint image_height_21, float4 * aabb_xyxy_21, float * sorting_depth_21, float * radius_22, float2 * mean2d_34, float * depth_21, float3 * conic_21, float * opacity_21) { - return mul_4(_S1307, _S1308); + for(;;) + { + float4 _S3078 = make_float4 (0.0f); + *aabb_xyxy_21 = _S3078; + *sorting_depth_21 = 0.0f; + *radius_22 = 0.0f; + *mean2d_34 = make_float2 (0.0f); + *conic_21 = make_float3 (0.0f); + *opacity_21 = 0.0f; + float3 mean_c_21 = mul_6(R_21, mean_22) + t_21; + float _S3079 = length_1(mean_c_21); + *depth_21 = _S3079; + if(_S3079 <= 0.0f) + { + *aabb_xyxy_21 = _S3078; + break; + } + Matrix covar2d_21; + *opacity_21 = 1.0f / (1.0f + (F32_exp((- in_opacity_21)))); + float3 _S3080 = exp_0(scale_21); + float4 _S3081 = normalize_0(quat_21); + float x_48 = _S3081.y; + float x2_21 = x_48 * x_48; + float y2_21 = _S3081.z * _S3081.z; + float z2_21 = _S3081.w * _S3081.w; + float xy_21 = _S3081.y * _S3081.z; + float xz_21 = _S3081.y * _S3081.w; + float yz_21 = _S3081.z * _S3081.w; + float wx_21 = _S3081.x * _S3081.y; + float wy_21 = _S3081.x * _S3081.z; + float wz_21 = _S3081.x * _S3081.w; + Matrix _S3082 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_21 + z2_21), 2.0f * (xy_21 + wz_21), 2.0f * (xz_21 - wy_21), 2.0f * (xy_21 - wz_21), 1.0f - 2.0f * (x2_21 + z2_21), 2.0f * (yz_21 + wx_21), 2.0f * (xz_21 + wy_21), 2.0f * (yz_21 - wx_21), 1.0f - 2.0f * (x2_21 + y2_21)))); + SigmaPoints_0 ret_10; + (&ret_10)->p_0[int(0)] = mean_22; + (&ret_10)->w_mean_0[int(0)] = 0.0f; + (&ret_10)->w_cov_0[int(0)] = 2.0f; + float _S3083 = (F32_sqrt((3.0f))); + float3 delta_30 = make_float3 (_S3083 * _S3080.x) * _S3082.rows[0U]; + float3 _S3084 = mean_22 + delta_30; + float3 _S3085 = mean_22 - delta_30; + float3 delta_31 = make_float3 (_S3083 * _S3080.y) * _S3082.rows[1U]; + float3 _S3086 = mean_22 + delta_31; + float3 _S3087 = mean_22 - delta_31; + float3 delta_32 = make_float3 (_S3083 * _S3080.z) * _S3082.rows[2U]; + float3 _S3088 = mean_22 + delta_32; + float3 _S3089 = mean_22 - delta_32; + (&ret_10)->w_mean_0[1U] = 0.1666666716337204f; + (&ret_10)->w_cov_0[1U] = 0.1666666716337204f; + (&ret_10)->w_mean_0[2U] = 0.1666666716337204f; + (&ret_10)->w_cov_0[2U] = 0.1666666716337204f; + (&ret_10)->w_mean_0[3U] = 0.1666666716337204f; + (&ret_10)->w_cov_0[3U] = 0.1666666716337204f; + (&ret_10)->w_mean_0[4U] = 0.1666666716337204f; + (&ret_10)->w_cov_0[4U] = 0.1666666716337204f; + (&ret_10)->w_mean_0[5U] = 0.1666666716337204f; + (&ret_10)->w_cov_0[5U] = 0.1666666716337204f; + (&ret_10)->w_mean_0[6U] = 0.1666666716337204f; + (&ret_10)->w_cov_0[6U] = 0.1666666716337204f; + (&ret_10)->p_0[0U] = mul_6(R_21, (&ret_10)->p_0[0U]) + t_21; + (&ret_10)->p_0[1U] = mul_6(R_21, _S3084) + t_21; + (&ret_10)->p_0[2U] = mul_6(R_21, _S3086) + t_21; + (&ret_10)->p_0[3U] = mul_6(R_21, _S3088) + t_21; + (&ret_10)->p_0[4U] = mul_6(R_21, _S3085) + t_21; + (&ret_10)->p_0[5U] = mul_6(R_21, _S3087) + t_21; + (&ret_10)->p_0[6U] = mul_6(R_21, _S3089) + t_21; + FixedArray proj_points_10; + float _S3090 = fx_34 * (F32_atan2((ret_10.p_0[int(0)].x), (ret_10.p_0[int(0)].z))) + cx_25; + float2 _S3091 = make_float2 (_S3090, fy_34 * (F32_atan2((ret_10.p_0[int(0)].y), (length_0(float2 {ret_10.p_0[int(0)].x, ret_10.p_0[int(0)].z})))) + cy_25); + proj_points_10[int(0)] = _S3091; + float _S3092 = fx_34 * (F32_atan2((ret_10.p_0[int(1)].x), (ret_10.p_0[int(1)].z))) + cx_25; + proj_points_10[int(1)] = make_float2 (_S3092, fy_34 * (F32_atan2((ret_10.p_0[int(1)].y), (length_0(float2 {ret_10.p_0[int(1)].x, ret_10.p_0[int(1)].z})))) + cy_25); + float _S3093 = fx_34 * (F32_atan2((ret_10.p_0[int(2)].x), (ret_10.p_0[int(2)].z))) + cx_25; + proj_points_10[int(2)] = make_float2 (_S3093, fy_34 * (F32_atan2((ret_10.p_0[int(2)].y), (length_0(float2 {ret_10.p_0[int(2)].x, ret_10.p_0[int(2)].z})))) + cy_25); + float _S3094 = fx_34 * (F32_atan2((ret_10.p_0[int(3)].x), (ret_10.p_0[int(3)].z))) + cx_25; + proj_points_10[int(3)] = make_float2 (_S3094, fy_34 * (F32_atan2((ret_10.p_0[int(3)].y), (length_0(float2 {ret_10.p_0[int(3)].x, ret_10.p_0[int(3)].z})))) + cy_25); + float _S3095 = fx_34 * (F32_atan2((ret_10.p_0[int(4)].x), (ret_10.p_0[int(4)].z))) + cx_25; + proj_points_10[int(4)] = make_float2 (_S3095, fy_34 * (F32_atan2((ret_10.p_0[int(4)].y), (length_0(float2 {ret_10.p_0[int(4)].x, ret_10.p_0[int(4)].z})))) + cy_25); + float _S3096 = fx_34 * (F32_atan2((ret_10.p_0[int(5)].x), (ret_10.p_0[int(5)].z))) + cx_25; + proj_points_10[int(5)] = make_float2 (_S3096, fy_34 * (F32_atan2((ret_10.p_0[int(5)].y), (length_0(float2 {ret_10.p_0[int(5)].x, ret_10.p_0[int(5)].z})))) + cy_25); + float _S3097 = fx_34 * (F32_atan2((ret_10.p_0[int(6)].x), (ret_10.p_0[int(6)].z))) + cx_25; + proj_points_10[int(6)] = make_float2 (_S3097, fy_34 * (F32_atan2((ret_10.p_0[int(6)].y), (length_0(float2 {ret_10.p_0[int(6)].x, ret_10.p_0[int(6)].z})))) + cy_25); + float _S3098 = fx_34 * 6.28318548202514648f; + float du_0 = _S3092 - _S3090; + *&((&proj_points_10[int(1)])->x) = _S3090 + (du_0 - _S3098 * (F32_round((du_0 / _S3098)))); + float du_1 = _S3093 - _S3090; + *&((&proj_points_10[int(2)])->x) = _S3090 + (du_1 - _S3098 * (F32_round((du_1 / _S3098)))); + float du_2 = _S3094 - _S3090; + *&((&proj_points_10[int(3)])->x) = _S3090 + (du_2 - _S3098 * (F32_round((du_2 / _S3098)))); + float du_3 = _S3095 - _S3090; + *&((&proj_points_10[int(4)])->x) = _S3090 + (du_3 - _S3098 * (F32_round((du_3 / _S3098)))); + float du_4 = _S3096 - _S3090; + *&((&proj_points_10[int(5)])->x) = _S3090 + (du_4 - _S3098 * (F32_round((du_4 / _S3098)))); + float du_5 = _S3097 - _S3090; + *&((&proj_points_10[int(6)])->x) = _S3090 + (du_5 - _S3098 * (F32_round((du_5 / _S3098)))); + float2 _S3099 = make_float2 (ret_10.w_mean_0[int(0)]) * _S3091 + make_float2 (ret_10.w_mean_0[int(1)]) * proj_points_10[int(1)] + make_float2 (ret_10.w_mean_0[int(2)]) * proj_points_10[int(2)] + make_float2 (ret_10.w_mean_0[int(3)]) * proj_points_10[int(3)] + make_float2 (ret_10.w_mean_0[int(4)]) * proj_points_10[int(4)] + make_float2 (ret_10.w_mean_0[int(5)]) * proj_points_10[int(5)] + make_float2 (ret_10.w_mean_0[int(6)]) * proj_points_10[int(6)]; + *mean2d_34 = _S3099; + float2 d_70 = _S3091 - _S3099; + float _S3100 = d_70.x; + float _S3101 = d_70.y; + float _S3102 = _S3100 * _S3101; + float2 d_71 = proj_points_10[int(1)] - _S3099; + float _S3103 = d_71.x; + float _S3104 = d_71.y; + float _S3105 = _S3103 * _S3104; + float2 d_72 = proj_points_10[int(2)] - _S3099; + float _S3106 = d_72.x; + float _S3107 = d_72.y; + float _S3108 = _S3106 * _S3107; + float2 d_73 = proj_points_10[int(3)] - _S3099; + float _S3109 = d_73.x; + float _S3110 = d_73.y; + float _S3111 = _S3109 * _S3110; + float2 d_74 = proj_points_10[int(4)] - _S3099; + float _S3112 = d_74.x; + float _S3113 = d_74.y; + float _S3114 = _S3112 * _S3113; + float2 d_75 = proj_points_10[int(5)] - _S3099; + float _S3115 = d_75.x; + float _S3116 = d_75.y; + float _S3117 = _S3115 * _S3116; + float2 d_76 = proj_points_10[int(6)] - _S3099; + float _S3118 = d_76.x; + float _S3119 = d_76.y; + float _S3120 = _S3118 * _S3119; + covar2d_21 = makeMatrix (ret_10.w_cov_0[int(0)]) * makeMatrix (_S3100 * _S3100, _S3102, _S3102, _S3101 * _S3101) + makeMatrix (ret_10.w_cov_0[int(1)]) * makeMatrix (_S3103 * _S3103, _S3105, _S3105, _S3104 * _S3104) + makeMatrix (ret_10.w_cov_0[int(2)]) * makeMatrix (_S3106 * _S3106, _S3108, _S3108, _S3107 * _S3107) + makeMatrix (ret_10.w_cov_0[int(3)]) * makeMatrix (_S3109 * _S3109, _S3111, _S3111, _S3110 * _S3110) + makeMatrix (ret_10.w_cov_0[int(4)]) * makeMatrix (_S3112 * _S3112, _S3114, _S3114, _S3113 * _S3113) + makeMatrix (ret_10.w_cov_0[int(5)]) * makeMatrix (_S3115 * _S3115, _S3117, _S3117, _S3116 * _S3116) + makeMatrix (ret_10.w_cov_0[int(6)]) * makeMatrix (_S3118 * _S3118, _S3120, _S3120, _S3119 * _S3119); + float eps2d_21; + if(antialiased_21) + { + eps2d_21 = 0.10000000149011612f; + } + else + { + eps2d_21 = 0.30000001192092896f; + } + float det_orig_21 = *&(((&covar2d_21)->rows + (int(0)))->x) * *&(((&covar2d_21)->rows + (int(1)))->y) - *&(((&covar2d_21)->rows + (int(0)))->y) * *&(((&covar2d_21)->rows + (int(1)))->x); + float _S3121 = *&(((&covar2d_21)->rows + (int(0)))->x) + eps2d_21; + *&(((&covar2d_21)->rows + (int(0)))->x) = _S3121; + float _S3122 = *&(((&covar2d_21)->rows + (int(1)))->y) + eps2d_21; + *&(((&covar2d_21)->rows + (int(1)))->y) = _S3122; + float det_blur_21 = _S3121 * _S3122 - *&(((&covar2d_21)->rows + (int(0)))->y) * *&(((&covar2d_21)->rows + (int(1)))->x); + float compensation_21 = (F32_sqrt(((F32_max((0.0f), (det_orig_21 / det_blur_21)))))); + if(det_blur_21 <= 0.0f) + { + *aabb_xyxy_21 = _S3078; + break; + } + float invdet_27 = 1.0f / (covar2d_21.rows[int(0)].x * covar2d_21.rows[int(1)].y - covar2d_21.rows[int(0)].y * covar2d_21.rows[int(1)].x); + Matrix _S3123 = makeMatrix (covar2d_21.rows[int(1)].y * invdet_27, - covar2d_21.rows[int(0)].y * invdet_27, - covar2d_21.rows[int(1)].x * invdet_27, covar2d_21.rows[int(0)].x * invdet_27); + if(antialiased_21) + { + *opacity_21 = *opacity_21 * compensation_21; + } + if((*opacity_21) < 0.00392156885936856f) + { + *aabb_xyxy_21 = _S3078; + break; + } + float _S3124 = (F32_min((3.32999992370605469f), ((F32_sqrt((2.0f * (F32_log((*opacity_21 / 0.00392156885936856f))))))))); + float radius_x_21 = _S3124 * (F32_sqrt((covar2d_21[int(0)].x))); + float radius_y_21 = _S3124 * (F32_sqrt((covar2d_21[int(1)].y))); + float _S3125 = (*mean2d_34).x - radius_x_21; + float _S3126 = (*mean2d_34).x + radius_x_21; + float _S3127 = (*mean2d_34).y - radius_y_21; + float _S3128 = (*mean2d_34).y + radius_y_21; + bool _S3129; + if(_S3126 <= 0.0f) + { + _S3129 = true; + } + else + { + _S3129 = _S3125 >= float(image_width_21); + } + if(_S3129) + { + _S3129 = true; + } + else + { + _S3129 = _S3128 <= 0.0f; + } + if(_S3129) + { + _S3129 = true; + } + else + { + _S3129 = _S3127 >= float(image_height_21); + } + if(_S3129) + { + *aabb_xyxy_21 = _S3078; + break; + } + *aabb_xyxy_21 = make_float4 (_S3125, _S3127, _S3126, _S3128); + *sorting_depth_21 = dot_1(mean_c_21, mean_c_21); + *conic_21 = make_float3 (_S3123.rows[int(0)].x, _S3123.rows[int(0)].y, _S3123.rows[int(1)].y); + *radius_22 = view_radius_3dgs_0(mean_22, scale_21, in_opacity_21, - mul_6(transpose_3(R_21), t_21)); + break; + } + return; } -inline __device__ float s_primal_ctx_sqrt_0(float _S1309) +struct s_bwd_prop_DiffProjection3DGS_3dgs_persp_none_projection_Intermediates_0 { - return (F32_sqrt((_S1309))); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3130; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3131; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3132; +}; + +inline __device__ float3 s_primal_ctx_mul_0(Matrix _S3133, float3 _S3134) +{ + return mul_6(_S3133, _S3134); } -inline __device__ float s_primal_ctx_log_0(float _S1310) +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_primal_ctx_s_fwd_DistNone_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpdpuv_0, FixedArray * coeffs_8) { - return (F32_log((_S1310))); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3135 = { dpdpuv_0->primal_0, dpdpuv_0->differential_0 }; + return _S3135; } -inline __device__ void s_bwd_prop_sqrt_0(DiffPair_float_0 * _S1311, float _S1312) +inline __device__ float s_primal_ctx_exp_0(float _S3136) { - _d_sqrt_0(_S1311, _S1312); + return (F32_exp((_S3136))); +} + +inline __device__ float3 s_primal_ctx_exp_1(float3 _S3137) +{ + return exp_0(_S3137); +} + +inline __device__ Matrix s_primal_ctx_mul_1(Matrix _S3138, Matrix _S3139) +{ + return mul_5(_S3138, _S3139); +} + +inline __device__ float s_primal_ctx_clamp_0(float _S3140, float _S3141, float _S3142) +{ + return clamp_0(_S3140, _S3141, _S3142); +} + +inline __device__ Matrix s_primal_ctx_mul_2(Matrix _S3143, Matrix _S3144) +{ + return mul_3(_S3143, _S3144); +} + +inline __device__ Matrix s_primal_ctx_mul_3(Matrix _S3145, Matrix _S3146) +{ + return mul_4(_S3145, _S3146); +} + +inline __device__ float s_primal_ctx_sqrt_0(float _S3147) +{ + return (F32_sqrt((_S3147))); +} + +inline __device__ float s_primal_ctx_log_0(float _S3148) +{ + return (F32_log((_S3148))); +} + +inline __device__ void s_bwd_prop_sqrt_0(DiffPair_float_0 * _S3149, float _S3150) +{ + _d_sqrt_0(_S3149, _S3150); return; } inline __device__ void s_bwd_prop_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_15, float _s_dOut_0) { - float _S1313 = (*dpx_15).primal_0.x; - float _S1314 = (*dpx_15).primal_0.y; - float _S1315 = (*dpx_15).primal_0.z; - DiffPair_float_0 _S1316; - (&_S1316)->primal_0 = _S1313 * _S1313 + _S1314 * _S1314 + _S1315 * _S1315; - (&_S1316)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1316, _s_dOut_0); - float _S1317 = (*dpx_15).primal_0.z * _S1316.differential_0; - float _S1318 = _S1317 + _S1317; - float _S1319 = (*dpx_15).primal_0.y * _S1316.differential_0; - float _S1320 = _S1319 + _S1319; - float _S1321 = (*dpx_15).primal_0.x * _S1316.differential_0; - float _S1322 = _S1321 + _S1321; - float3 _S1323 = make_float3 (0.0f); - *&((&_S1323)->z) = _S1318; - *&((&_S1323)->y) = _S1320; - *&((&_S1323)->x) = _S1322; + float _S3151 = (*dpx_15).primal_0.x; + float _S3152 = (*dpx_15).primal_0.y; + float _S3153 = (*dpx_15).primal_0.z; + DiffPair_float_0 _S3154; + (&_S3154)->primal_0 = _S3151 * _S3151 + _S3152 * _S3152 + _S3153 * _S3153; + (&_S3154)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3154, _s_dOut_0); + float _S3155 = (*dpx_15).primal_0.z * _S3154.differential_0; + float _S3156 = _S3155 + _S3155; + float _S3157 = (*dpx_15).primal_0.y * _S3154.differential_0; + float _S3158 = _S3157 + _S3157; + float _S3159 = (*dpx_15).primal_0.x * _S3154.differential_0; + float _S3160 = _S3159 + _S3159; + float3 _S3161 = make_float3 (0.0f); + *&((&_S3161)->z) = _S3156; + *&((&_S3161)->y) = _S3158; + *&((&_S3161)->x) = _S3160; dpx_15->primal_0 = (*dpx_15).primal_0; - dpx_15->differential_0 = _S1323; + dpx_15->differential_0 = _S3161; return; } -inline __device__ void s_bwd_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1324, float _S1325) +inline __device__ void s_bwd_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S3162, float _S3163) { - s_bwd_prop_length_impl_0(_S1324, _S1325); + s_bwd_prop_length_impl_0(_S3162, _S3163); return; } -inline __device__ void s_bwd_prop_exp_0(DiffPair_float_0 * _S1326, float _S1327) +inline __device__ void s_bwd_prop_exp_0(DiffPair_float_0 * _S3164, float _S3165) { - _d_exp_0(_S1326, _S1327); + _d_exp_0(_S3164, _S3165); return; } -inline __device__ void s_bwd_prop_log_0(DiffPair_float_0 * _S1328, float _S1329) +inline __device__ void s_bwd_prop_log_0(DiffPair_float_0 * _S3166, float _S3167) { - _d_log_0(_S1328, _S1329); + _d_log_0(_S3166, _S3167); return; } inline __device__ void s_bwd_prop_view_radius_3dgs_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpmean_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * dplog_scale_0, DiffPair_float_0 * dplogit_opacity_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpcampos_0, float _s_dOut_1) { - float _S1330 = - (*dplogit_opacity_0).primal_0; - float _S1331 = 1.0f + s_primal_ctx_exp_0(_S1330); - float _S1332 = 255.0f / _S1331; - float _S1333 = _S1331 * _S1331; - float _S1334 = (F32_max((_S1332), (1.0f))); - float _S1335 = 2.0f * s_primal_ctx_log_0(_S1334); - float _S1336 = s_primal_ctx_sqrt_0(_S1335); - float _S1337 = (*dplog_scale_0).primal_0.x; - float _S1338 = (*dplog_scale_0).primal_0.y; - float _S1339 = (*dplog_scale_0).primal_0.z; - float _S1340 = (F32_max((_S1338), (_S1339))); - float _S1341 = (F32_max((_S1337), (_S1340))); - float _S1342 = s_primal_ctx_exp_0(_S1341); - float radius_9 = _S1342 * _S1336; - float3 _S1343 = (*dpmean_0).primal_0 - (*dpcampos_0).primal_0; - float _S1344 = length_1(_S1343); - float _S1345 = _S1344 * _S1344 - radius_9 * radius_9; - float _S1346 = (F32_max((_S1345), (0.0f))); - float _S1347 = (F32_max((_S1344), (radius_9))) + s_primal_ctx_sqrt_0(_S1346); - float _S1348 = _s_dOut_1 / (_S1347 * _S1347); - float _S1349 = radius_9 * - _S1348; - float _S1350 = _S1347 * _S1348; - DiffPair_float_0 _S1351; - (&_S1351)->primal_0 = _S1346; - (&_S1351)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1351, _S1349); - DiffPair_float_0 _S1352; - (&_S1352)->primal_0 = _S1345; - (&_S1352)->differential_0 = 0.0f; - DiffPair_float_0 _S1353; - (&_S1353)->primal_0 = 0.0f; - (&_S1353)->differential_0 = 0.0f; - _d_max_0(&_S1352, &_S1353, _S1351.differential_0); - float _S1354 = radius_9 * - _S1352.differential_0; - float _S1355 = _S1344 * _S1352.differential_0; - DiffPair_float_0 _S1356; - (&_S1356)->primal_0 = _S1344; - (&_S1356)->differential_0 = 0.0f; - DiffPair_float_0 _S1357; - (&_S1357)->primal_0 = radius_9; - (&_S1357)->differential_0 = 0.0f; - _d_max_0(&_S1356, &_S1357, _S1349); - float _S1358 = _S1355 + _S1355 + _S1356.differential_0; - float3 _S1359 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1360; - (&_S1360)->primal_0 = _S1343; - (&_S1360)->differential_0 = _S1359; - s_bwd_length_impl_0(&_S1360, _S1358); - float3 _S1361 = - _S1360.differential_0; - float _S1362 = _S1350 + _S1354 + _S1354 + _S1357.differential_0; - float _S1363 = _S1342 * _S1362; - float _S1364 = _S1336 * _S1362; - DiffPair_float_0 _S1365; - (&_S1365)->primal_0 = _S1341; - (&_S1365)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S1365, _S1364); - DiffPair_float_0 _S1366; - (&_S1366)->primal_0 = _S1337; - (&_S1366)->differential_0 = 0.0f; - DiffPair_float_0 _S1367; - (&_S1367)->primal_0 = _S1340; - (&_S1367)->differential_0 = 0.0f; - _d_max_0(&_S1366, &_S1367, _S1365.differential_0); - DiffPair_float_0 _S1368; - (&_S1368)->primal_0 = _S1338; - (&_S1368)->differential_0 = 0.0f; - DiffPair_float_0 _S1369; - (&_S1369)->primal_0 = _S1339; - (&_S1369)->differential_0 = 0.0f; - _d_max_0(&_S1368, &_S1369, _S1367.differential_0); - DiffPair_float_0 _S1370; - (&_S1370)->primal_0 = _S1335; - (&_S1370)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1370, _S1363); - float _S1371 = 2.0f * _S1370.differential_0; - DiffPair_float_0 _S1372; - (&_S1372)->primal_0 = _S1334; - (&_S1372)->differential_0 = 0.0f; - s_bwd_prop_log_0(&_S1372, _S1371); - DiffPair_float_0 _S1373; - (&_S1373)->primal_0 = _S1332; - (&_S1373)->differential_0 = 0.0f; - DiffPair_float_0 _S1374; - (&_S1374)->primal_0 = 1.0f; - (&_S1374)->differential_0 = 0.0f; - _d_max_0(&_S1373, &_S1374, _S1372.differential_0); - float _S1375 = 255.0f * - (_S1373.differential_0 / _S1333); - DiffPair_float_0 _S1376; - (&_S1376)->primal_0 = _S1330; - (&_S1376)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S1376, _S1375); - float _S1377 = - _S1376.differential_0; + float _S3168 = - (*dplogit_opacity_0).primal_0; + float _S3169 = 1.0f + s_primal_ctx_exp_0(_S3168); + float _S3170 = 255.0f / _S3169; + float _S3171 = _S3169 * _S3169; + float _S3172 = (F32_max((_S3170), (1.0f))); + float _S3173 = 2.0f * s_primal_ctx_log_0(_S3172); + float _S3174 = s_primal_ctx_sqrt_0(_S3173); + float _S3175 = (*dplog_scale_0).primal_0.x; + float _S3176 = (*dplog_scale_0).primal_0.y; + float _S3177 = (*dplog_scale_0).primal_0.z; + float _S3178 = (F32_max((_S3176), (_S3177))); + float _S3179 = (F32_max((_S3175), (_S3178))); + float _S3180 = s_primal_ctx_exp_0(_S3179); + float radius_23 = _S3180 * _S3174; + float3 _S3181 = (*dpmean_0).primal_0 - (*dpcampos_0).primal_0; + float _S3182 = length_1(_S3181); + float _S3183 = _S3182 * _S3182 - radius_23 * radius_23; + float _S3184 = (F32_max((_S3183), (0.0f))); + float _S3185 = (F32_max((_S3182), (radius_23))) + s_primal_ctx_sqrt_0(_S3184); + float _S3186 = _s_dOut_1 / (_S3185 * _S3185); + float _S3187 = radius_23 * - _S3186; + float _S3188 = _S3185 * _S3186; + DiffPair_float_0 _S3189; + (&_S3189)->primal_0 = _S3184; + (&_S3189)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3189, _S3187); + DiffPair_float_0 _S3190; + (&_S3190)->primal_0 = _S3183; + (&_S3190)->differential_0 = 0.0f; + DiffPair_float_0 _S3191; + (&_S3191)->primal_0 = 0.0f; + (&_S3191)->differential_0 = 0.0f; + _d_max_0(&_S3190, &_S3191, _S3189.differential_0); + float _S3192 = radius_23 * - _S3190.differential_0; + float _S3193 = _S3182 * _S3190.differential_0; + DiffPair_float_0 _S3194; + (&_S3194)->primal_0 = _S3182; + (&_S3194)->differential_0 = 0.0f; + DiffPair_float_0 _S3195; + (&_S3195)->primal_0 = radius_23; + (&_S3195)->differential_0 = 0.0f; + _d_max_0(&_S3194, &_S3195, _S3187); + float _S3196 = _S3193 + _S3193 + _S3194.differential_0; + float3 _S3197 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3198; + (&_S3198)->primal_0 = _S3181; + (&_S3198)->differential_0 = _S3197; + s_bwd_length_impl_0(&_S3198, _S3196); + float3 _S3199 = - _S3198.differential_0; + float _S3200 = _S3188 + _S3192 + _S3192 + _S3195.differential_0; + float _S3201 = _S3180 * _S3200; + float _S3202 = _S3174 * _S3200; + DiffPair_float_0 _S3203; + (&_S3203)->primal_0 = _S3179; + (&_S3203)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S3203, _S3202); + DiffPair_float_0 _S3204; + (&_S3204)->primal_0 = _S3175; + (&_S3204)->differential_0 = 0.0f; + DiffPair_float_0 _S3205; + (&_S3205)->primal_0 = _S3178; + (&_S3205)->differential_0 = 0.0f; + _d_max_0(&_S3204, &_S3205, _S3203.differential_0); + DiffPair_float_0 _S3206; + (&_S3206)->primal_0 = _S3176; + (&_S3206)->differential_0 = 0.0f; + DiffPair_float_0 _S3207; + (&_S3207)->primal_0 = _S3177; + (&_S3207)->differential_0 = 0.0f; + _d_max_0(&_S3206, &_S3207, _S3205.differential_0); + DiffPair_float_0 _S3208; + (&_S3208)->primal_0 = _S3173; + (&_S3208)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3208, _S3201); + float _S3209 = 2.0f * _S3208.differential_0; + DiffPair_float_0 _S3210; + (&_S3210)->primal_0 = _S3172; + (&_S3210)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S3210, _S3209); + DiffPair_float_0 _S3211; + (&_S3211)->primal_0 = _S3170; + (&_S3211)->differential_0 = 0.0f; + DiffPair_float_0 _S3212; + (&_S3212)->primal_0 = 1.0f; + (&_S3212)->differential_0 = 0.0f; + _d_max_0(&_S3211, &_S3212, _S3210.differential_0); + float _S3213 = 255.0f * - (_S3211.differential_0 / _S3171); + DiffPair_float_0 _S3214; + (&_S3214)->primal_0 = _S3168; + (&_S3214)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S3214, _S3213); + float _S3215 = - _S3214.differential_0; dpcampos_0->primal_0 = (*dpcampos_0).primal_0; - dpcampos_0->differential_0 = _S1361; + dpcampos_0->differential_0 = _S3199; dplogit_opacity_0->primal_0 = (*dplogit_opacity_0).primal_0; - dplogit_opacity_0->differential_0 = _S1377; - float3 _S1378 = make_float3 (_S1366.differential_0, _S1368.differential_0, _S1369.differential_0); + dplogit_opacity_0->differential_0 = _S3215; + float3 _S3216 = make_float3 (_S3204.differential_0, _S3206.differential_0, _S3207.differential_0); dplog_scale_0->primal_0 = (*dplog_scale_0).primal_0; - dplog_scale_0->differential_0 = _S1378; + dplog_scale_0->differential_0 = _S3216; dpmean_0->primal_0 = (*dpmean_0).primal_0; - dpmean_0->differential_0 = _S1360.differential_0; + dpmean_0->differential_0 = _S3198.differential_0; return; } -inline __device__ void s_bwd_prop_mul_0(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * _S1379, DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 * _S1380, Matrix _S1381) +inline __device__ void s_bwd_prop_mul_0(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * _S3217, DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 * _S3218, Matrix _S3219) { - mul_1(_S1379, _S1380, _S1381); + mul_1(_S3217, _S3218, _S3219); return; } -inline __device__ void s_bwd_prop_mul_1(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * _S1382, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1383, Matrix _S1384) +inline __device__ void s_bwd_prop_mul_1(DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 * _S3220, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S3221, Matrix _S3222) { - mul_0(_S1382, _S1383, _S1384); + mul_0(_S3220, _S3221, _S3222); return; } -inline __device__ void s_bwd_prop_clamp_0(DiffPair_float_0 * _S1385, DiffPair_float_0 * _S1386, DiffPair_float_0 * _S1387, float _S1388) +inline __device__ void s_bwd_prop_clamp_0(DiffPair_float_0 * _S3223, DiffPair_float_0 * _S3224, DiffPair_float_0 * _S3225, float _S3226) { - _d_clamp_0(_S1385, _S1386, _S1387, _S1388); + _d_clamp_0(_S3223, _S3224, _S3225, _S3226); return; } -inline __device__ void s_bwd_prop_mul_2(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1389, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1390, Matrix _S1391) +struct DiffPair_0 { - mul_2(_S1389, _S1390, _S1391); + DiffPair_vectorx3Cfloatx2C2x3E_0 primal_0; + DiffPair_vectorx3Cfloatx2C2x3E_0 differential_0; +}; + +inline __device__ void s_bwd_prop_s_fwd_DistNone_distort_0(DiffPair_0 * dpdpuv_1, FixedArray * coeffs_9, DiffPair_vectorx3Cfloatx2C2x3E_0 * _s_dOut_2) +{ + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3227 = { _s_dOut_2->primal_0, _s_dOut_2->differential_0 }; + dpdpuv_1->primal_0 = (*dpdpuv_1).primal_0; + dpdpuv_1->differential_0 = _S3227; return; } -inline __device__ void s_bwd_prop_exp_1(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1392, float3 _S1393) +inline __device__ void s_bwd_prop_DistNone_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_4, FixedArray * coeffs_10, float2 _s_dOut_3) { - _d_exp_vector_0(_S1392, _S1393); + dpuv_4->primal_0 = (*dpuv_4).primal_0; + dpuv_4->differential_0 = _s_dOut_3; + return; +} + +inline __device__ void s_bwd_prop_mul_2(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S3228, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S3229, Matrix _S3230) +{ + mul_2(_S3228, _S3229, _S3230); + return; +} + +inline __device__ void s_bwd_prop_exp_1(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S3231, float3 _S3232) +{ + _d_exp_vector_0(_S3231, _S3232); return; } @@ -5046,5490 +12716,14261 @@ struct DiffPair_vectorx3Cfloatx2C4x3E_0 float4 differential_0; }; -inline __device__ void s_bwd_prop_length_impl_1(DiffPair_vectorx3Cfloatx2C4x3E_0 * dpx_16, float _s_dOut_2) +inline __device__ void s_bwd_prop_length_impl_1(DiffPair_vectorx3Cfloatx2C4x3E_0 * dpx_16, float _s_dOut_4) { - float _S1394 = (*dpx_16).primal_0.x; - float _S1395 = (*dpx_16).primal_0.y; - float _S1396 = (*dpx_16).primal_0.z; - float _S1397 = (*dpx_16).primal_0.w; - DiffPair_float_0 _S1398; - (&_S1398)->primal_0 = _S1394 * _S1394 + _S1395 * _S1395 + _S1396 * _S1396 + _S1397 * _S1397; - (&_S1398)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1398, _s_dOut_2); - float _S1399 = (*dpx_16).primal_0.w * _S1398.differential_0; - float _S1400 = _S1399 + _S1399; - float _S1401 = (*dpx_16).primal_0.z * _S1398.differential_0; - float _S1402 = _S1401 + _S1401; - float _S1403 = (*dpx_16).primal_0.y * _S1398.differential_0; - float _S1404 = _S1403 + _S1403; - float _S1405 = (*dpx_16).primal_0.x * _S1398.differential_0; - float _S1406 = _S1405 + _S1405; - float4 _S1407 = make_float4 (0.0f); - *&((&_S1407)->w) = _S1400; - *&((&_S1407)->z) = _S1402; - *&((&_S1407)->y) = _S1404; - *&((&_S1407)->x) = _S1406; + float _S3233 = (*dpx_16).primal_0.x; + float _S3234 = (*dpx_16).primal_0.y; + float _S3235 = (*dpx_16).primal_0.z; + float _S3236 = (*dpx_16).primal_0.w; + DiffPair_float_0 _S3237; + (&_S3237)->primal_0 = _S3233 * _S3233 + _S3234 * _S3234 + _S3235 * _S3235 + _S3236 * _S3236; + (&_S3237)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3237, _s_dOut_4); + float _S3238 = (*dpx_16).primal_0.w * _S3237.differential_0; + float _S3239 = _S3238 + _S3238; + float _S3240 = (*dpx_16).primal_0.z * _S3237.differential_0; + float _S3241 = _S3240 + _S3240; + float _S3242 = (*dpx_16).primal_0.y * _S3237.differential_0; + float _S3243 = _S3242 + _S3242; + float _S3244 = (*dpx_16).primal_0.x * _S3237.differential_0; + float _S3245 = _S3244 + _S3244; + float4 _S3246 = make_float4 (0.0f); + *&((&_S3246)->w) = _S3239; + *&((&_S3246)->z) = _S3241; + *&((&_S3246)->y) = _S3243; + *&((&_S3246)->x) = _S3245; dpx_16->primal_0 = (*dpx_16).primal_0; - dpx_16->differential_0 = _S1407; + dpx_16->differential_0 = _S3246; return; } -inline __device__ void s_bwd_length_impl_1(DiffPair_vectorx3Cfloatx2C4x3E_0 * _S1408, float _S1409) +inline __device__ void s_bwd_length_impl_1(DiffPair_vectorx3Cfloatx2C4x3E_0 * _S3247, float _S3248) { - s_bwd_prop_length_impl_1(_S1408, _S1409); + s_bwd_prop_length_impl_1(_S3247, _S3248); return; } -inline __device__ void s_bwd_prop_normalize_impl_0(DiffPair_vectorx3Cfloatx2C4x3E_0 * dpx_17, float4 _s_dOut_3) +inline __device__ void s_bwd_prop_normalize_impl_0(DiffPair_vectorx3Cfloatx2C4x3E_0 * dpx_17, float4 _s_dOut_5) { - float _S1410 = length_2((*dpx_17).primal_0); - float4 _S1411 = (*dpx_17).primal_0 * _s_dOut_3; - float4 _S1412 = make_float4 (1.0f / _S1410) * _s_dOut_3; - float _S1413 = - ((_S1411.x + _S1411.y + _S1411.z + _S1411.w) / (_S1410 * _S1410)); - float4 _S1414 = make_float4 (0.0f); - DiffPair_vectorx3Cfloatx2C4x3E_0 _S1415; - (&_S1415)->primal_0 = (*dpx_17).primal_0; - (&_S1415)->differential_0 = _S1414; - s_bwd_length_impl_1(&_S1415, _S1413); - float4 _S1416 = _S1412 + _S1415.differential_0; + float _S3249 = length_2((*dpx_17).primal_0); + float4 _S3250 = (*dpx_17).primal_0 * _s_dOut_5; + float4 _S3251 = make_float4 (1.0f / _S3249) * _s_dOut_5; + float _S3252 = - ((_S3250.x + _S3250.y + _S3250.z + _S3250.w) / (_S3249 * _S3249)); + float4 _S3253 = make_float4 (0.0f); + DiffPair_vectorx3Cfloatx2C4x3E_0 _S3254; + (&_S3254)->primal_0 = (*dpx_17).primal_0; + (&_S3254)->differential_0 = _S3253; + s_bwd_length_impl_1(&_S3254, _S3252); + float4 _S3255 = _S3251 + _S3254.differential_0; dpx_17->primal_0 = (*dpx_17).primal_0; - dpx_17->differential_0 = _S1416; + dpx_17->differential_0 = _S3255; return; } -inline __device__ void s_bwd_normalize_impl_0(DiffPair_vectorx3Cfloatx2C4x3E_0 * _S1417, float4 _S1418) +inline __device__ void s_bwd_normalize_impl_0(DiffPair_vectorx3Cfloatx2C4x3E_0 * _S3256, float4 _S3257) { - s_bwd_prop_normalize_impl_0(_S1417, _S1418); + s_bwd_prop_normalize_impl_0(_S3256, _S3257); return; } -inline __device__ void s_bwd_prop_mul_3(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1419, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1420, float3 _S1421) +inline __device__ void s_bwd_prop_mul_3(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S3258, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S3259, float3 _S3260) { - _d_mul_0(_S1419, _S1420, _S1421); + _d_mul_0(_S3258, _S3259, _S3260); return; } -inline __device__ void projection_3dgs_persp_vjp(bool antialiased_8, float3 mean_9, float4 quat_8, float3 scale_8, float in_opacity_8, Matrix R_8, float3 t_8, float fx_12, float fy_12, float cx_9, float cy_9, FixedArray dist_coeffs_12, uint image_width_8, uint image_height_8, float2 v_mean2d_0, float v_depth_0, float3 v_conic_0, float v_opacity_0, float3 * v_mean_0, float4 * v_quat_0, float3 * v_scale_0, float * v_in_opacity_0, Matrix * v_R_0, float3 * v_t_0) +inline __device__ void projection_3dgs_persp_none_vjp(bool antialiased_22, float3 mean_23, float4 quat_22, float3 scale_22, float in_opacity_22, Matrix R_22, float3 t_22, float fx_35, float fy_35, float cx_26, float cy_26, FixedArray dist_coeffs_34, uint image_width_22, uint image_height_22, float2 v_mean2d_0, float v_depth_0, float3 v_conic_0, float v_opacity_0, float3 * v_mean_0, float4 * v_quat_0, float3 * v_scale_0, float * v_in_opacity_0, Matrix * v_R_0, float3 * v_t_0) { - float3 mean_c_8 = s_primal_ctx_mul_0(R_8, mean_9) + t_8; - float _S1422 = - in_opacity_8; - float _S1423 = 1.0f + s_primal_ctx_exp_0(_S1422); - float _S1424 = 1.0f / _S1423; - float _S1425 = _S1423 * _S1423; - float4 _S1426 = normalize_0(quat_8); - float3 _S1427 = s_primal_ctx_exp_1(scale_8); - float _S1428 = _S1426.y; - float x2_8 = _S1428 * _S1428; - float y2_8 = _S1426.z * _S1426.z; - float z2_8 = _S1426.w * _S1426.w; - float xy_8 = _S1426.y * _S1426.z; - float xz_8 = _S1426.y * _S1426.w; - float yz_8 = _S1426.z * _S1426.w; - float wx_8 = _S1426.x * _S1426.y; - float wy_8 = _S1426.x * _S1426.z; - float wz_8 = _S1426.x * _S1426.w; - Matrix _S1429 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_8 + z2_8), 2.0f * (xy_8 + wz_8), 2.0f * (xz_8 - wy_8), 2.0f * (xy_8 - wz_8), 1.0f - 2.0f * (x2_8 + z2_8), 2.0f * (yz_8 + wx_8), 2.0f * (xz_8 + wy_8), 2.0f * (yz_8 - wx_8), 1.0f - 2.0f * (x2_8 + y2_8))); - Matrix S_0 = makeMatrix (_S1427.x, 0.0f, 0.0f, 0.0f, _S1427.y, 0.0f, 0.0f, 0.0f, _S1427.z); - Matrix _S1430 = s_primal_ctx_mul_1(_S1429, S_0); - Matrix _S1431 = transpose_3(_S1430); - Matrix _S1432 = s_primal_ctx_mul_1(_S1430, _S1431); - Matrix _S1433 = s_primal_ctx_mul_1(R_8, _S1432); - Matrix _S1434 = transpose_3(R_8); - Matrix _S1435 = s_primal_ctx_mul_1(_S1433, _S1434); - Matrix J_10 = makeMatrix (0.0f); - float2 _S1436 = float2 {mean_c_8.x, mean_c_8.y}; - float2 _S1437 = make_float2 (1.0f, 0.0f); - float _S1438 = mean_c_8.z; - float2 _S1439 = make_float2 (_S1438); - float2 _S1440 = _S1436 / make_float2 (_S1438); - float _S1441 = _S1438 * _S1438; - float2 _S1442 = make_float2 (_S1441); - float2 _S1443 = _S1437 * make_float2 (_S1438); - float2 _S1444 = _S1443 / make_float2 (_S1441); - float2 _S1445 = make_float2 (_S1441 * _S1441); - float u_72 = _S1440.x; - float s_diff_u_18 = _S1444.x; - float v_72 = _S1440.y; - float s_diff_v_18 = _S1444.y; - float _S1446 = s_diff_u_18 * u_72; - float _S1447 = s_diff_v_18 * v_72; - float r2_72 = u_72 * u_72 + v_72 * v_72; - float s_diff_r2_18 = _S1446 + _S1446 + (_S1447 + _S1447); - float _S1448 = s_diff_r2_18 * dist_coeffs_12[int(3)]; - float _S1449 = dist_coeffs_12[int(2)] + r2_72 * dist_coeffs_12[int(3)]; - float _S1450 = s_diff_r2_18 * _S1449 + _S1448 * r2_72; - float _S1451 = dist_coeffs_12[int(1)] + r2_72 * _S1449; - float _S1452 = s_diff_r2_18 * _S1451 + _S1450 * r2_72; - float _S1453 = dist_coeffs_12[int(0)] + r2_72 * _S1451; - float _S1454 = s_diff_r2_18 * _S1453 + _S1452 * r2_72; - float2 _S1455 = make_float2 (_S1454); - float radial_27 = 1.0f + r2_72 * _S1453; - float2 _S1456 = make_float2 (radial_27); - float _S1457 = 2.0f * dist_coeffs_12[int(4)]; - float _S1458 = _S1457 * u_72; - float _S1459 = s_diff_u_18 * _S1457; - float _S1460 = 2.0f * u_72; - float _S1461 = s_diff_u_18 * 2.0f; - float _S1462 = 2.0f * dist_coeffs_12[int(5)]; - float _S1463 = _S1462 * u_72; - float _S1464 = s_diff_u_18 * _S1462; - float _S1465 = 2.0f * v_72; - float _S1466 = s_diff_v_18 * 2.0f; - float2 _S1467 = _S1444 * make_float2 (radial_27) + make_float2 (_S1454) * _S1440 + make_float2 (_S1459 * v_72 + s_diff_v_18 * _S1458 + (s_diff_r2_18 + (_S1461 * u_72 + s_diff_u_18 * _S1460)) * dist_coeffs_12[int(5)] + s_diff_r2_18 * dist_coeffs_12[int(6)], _S1464 * v_72 + s_diff_v_18 * _S1463 + (s_diff_r2_18 + (_S1466 * v_72 + s_diff_v_18 * _S1465)) * dist_coeffs_12[int(4)] + s_diff_r2_18 * dist_coeffs_12[int(7)]); - float2 _S1468 = _S1467 + make_float2 (_S1467.x * dist_coeffs_12[int(8)] + _S1467.y * dist_coeffs_12[int(9)], 0.0f); - float _S1469 = _S1468.x * fx_12; - float _S1470 = _S1468.y * fy_12; - Matrix _S1471 = J_10; - *&(((&_S1471)->rows + (int(0)))->x) = _S1469; - *&(((&_S1471)->rows + (int(1)))->x) = _S1470; - float2 _S1472 = make_float2 (0.0f, 1.0f); - float2 _S1473 = _S1436 / make_float2 (_S1438); - float2 _S1474 = _S1472 * make_float2 (_S1438); - float2 _S1475 = _S1474 / make_float2 (_S1441); - float u_73 = _S1473.x; - float s_diff_u_19 = _S1475.x; - float v_73 = _S1473.y; - float s_diff_v_19 = _S1475.y; - float _S1476 = s_diff_u_19 * u_73; - float _S1477 = s_diff_v_19 * v_73; - float r2_73 = u_73 * u_73 + v_73 * v_73; - float s_diff_r2_19 = _S1476 + _S1476 + (_S1477 + _S1477); - float _S1478 = s_diff_r2_19 * dist_coeffs_12[int(3)]; - float _S1479 = dist_coeffs_12[int(2)] + r2_73 * dist_coeffs_12[int(3)]; - float _S1480 = s_diff_r2_19 * _S1479 + _S1478 * r2_73; - float _S1481 = dist_coeffs_12[int(1)] + r2_73 * _S1479; - float _S1482 = s_diff_r2_19 * _S1481 + _S1480 * r2_73; - float _S1483 = dist_coeffs_12[int(0)] + r2_73 * _S1481; - float _S1484 = s_diff_r2_19 * _S1483 + _S1482 * r2_73; - float2 _S1485 = make_float2 (_S1484); - float radial_28 = 1.0f + r2_73 * _S1483; - float2 _S1486 = make_float2 (radial_28); - float _S1487 = _S1457 * u_73; - float _S1488 = s_diff_u_19 * _S1457; - float _S1489 = 2.0f * u_73; - float _S1490 = s_diff_u_19 * 2.0f; - float _S1491 = _S1462 * u_73; - float _S1492 = s_diff_u_19 * _S1462; - float _S1493 = 2.0f * v_73; - float _S1494 = s_diff_v_19 * 2.0f; - float2 _S1495 = _S1475 * make_float2 (radial_28) + make_float2 (_S1484) * _S1473 + make_float2 (_S1488 * v_73 + s_diff_v_19 * _S1487 + (s_diff_r2_19 + (_S1490 * u_73 + s_diff_u_19 * _S1489)) * dist_coeffs_12[int(5)] + s_diff_r2_19 * dist_coeffs_12[int(6)], _S1492 * v_73 + s_diff_v_19 * _S1491 + (s_diff_r2_19 + (_S1494 * v_73 + s_diff_v_19 * _S1493)) * dist_coeffs_12[int(4)] + s_diff_r2_19 * dist_coeffs_12[int(7)]); - float2 _S1496 = _S1495 + make_float2 (_S1495.x * dist_coeffs_12[int(8)] + _S1495.y * dist_coeffs_12[int(9)], 0.0f); - float _S1497 = _S1496.y * fy_12; - *&(((&_S1471)->rows + (int(0)))->y) = _S1496.x * fx_12; - *&(((&_S1471)->rows + (int(1)))->y) = _S1497; - float2 _S1498 = _S1436 / make_float2 (_S1438); - float2 _S1499 = make_float2 (0.0f, 0.0f) - _S1436; - float2 _S1500 = _S1499 / make_float2 (_S1441); - float u_74 = _S1498.x; - float s_diff_u_20 = _S1500.x; - float v_74 = _S1498.y; - float s_diff_v_20 = _S1500.y; - float _S1501 = s_diff_u_20 * u_74; - float _S1502 = s_diff_v_20 * v_74; - float r2_74 = u_74 * u_74 + v_74 * v_74; - float s_diff_r2_20 = _S1501 + _S1501 + (_S1502 + _S1502); - float _S1503 = s_diff_r2_20 * dist_coeffs_12[int(3)]; - float _S1504 = dist_coeffs_12[int(2)] + r2_74 * dist_coeffs_12[int(3)]; - float _S1505 = s_diff_r2_20 * _S1504 + _S1503 * r2_74; - float _S1506 = dist_coeffs_12[int(1)] + r2_74 * _S1504; - float _S1507 = s_diff_r2_20 * _S1506 + _S1505 * r2_74; - float _S1508 = dist_coeffs_12[int(0)] + r2_74 * _S1506; - float _S1509 = s_diff_r2_20 * _S1508 + _S1507 * r2_74; - float2 _S1510 = make_float2 (_S1509); - float radial_29 = 1.0f + r2_74 * _S1508; - float2 _S1511 = make_float2 (radial_29); - float _S1512 = _S1457 * u_74; - float _S1513 = s_diff_u_20 * _S1457; - float _S1514 = 2.0f * u_74; - float _S1515 = s_diff_u_20 * 2.0f; - float _S1516 = _S1462 * u_74; - float _S1517 = s_diff_u_20 * _S1462; - float _S1518 = 2.0f * v_74; - float _S1519 = s_diff_v_20 * 2.0f; - float2 _S1520 = _S1500 * make_float2 (radial_29) + make_float2 (_S1509) * _S1498 + make_float2 (_S1513 * v_74 + s_diff_v_20 * _S1512 + (s_diff_r2_20 + (_S1515 * u_74 + s_diff_u_20 * _S1514)) * dist_coeffs_12[int(5)] + s_diff_r2_20 * dist_coeffs_12[int(6)], _S1517 * v_74 + s_diff_v_20 * _S1516 + (s_diff_r2_20 + (_S1519 * v_74 + s_diff_v_20 * _S1518)) * dist_coeffs_12[int(4)] + s_diff_r2_20 * dist_coeffs_12[int(7)]); - float2 _S1521 = _S1520 + make_float2 (_S1520.x * dist_coeffs_12[int(8)] + _S1520.y * dist_coeffs_12[int(9)], 0.0f); - float _S1522 = _S1521.x * fx_12; - float _S1523 = _S1521.y * fy_12; - float _S1524 = float(image_width_8); - float _S1525 = 0.30000001192092896f * (0.5f * _S1524); - float lim_x_pos_3 = _S1524 + _S1525; - float rz_2 = 1.0f / _S1438; - float _S1526 = - _S1525; - float _S1527 = - (_S1526 - cx_9); - float max_Jxz_0 = _S1527 * rz_2; - float _S1528 = - (lim_x_pos_3 - cx_9); - float min_Jxz_0 = _S1528 * rz_2; - float _S1529 = - (_S1526 - cy_9); - float max_Jyz_2 = _S1529 * rz_2; - float _S1530 = - (lim_x_pos_3 - cy_9); - float min_Jyz_2 = _S1530 * rz_2; - *&(((&_S1471)->rows + (int(0)))->z) = s_primal_ctx_clamp_0(_S1522, min_Jxz_0, max_Jxz_0); - *&(((&_S1471)->rows + (int(1)))->z) = s_primal_ctx_clamp_0(_S1523, min_Jyz_2, max_Jyz_2); - Matrix _S1531 = s_primal_ctx_mul_2(_S1471, _S1435); - Matrix _S1532 = transpose_1(_S1471); - Matrix _S1533 = s_primal_ctx_mul_3(_S1531, _S1532); - float eps2d_8; - if(antialiased_8) + float2 _S3261 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3262 = { _S3261, _S3261 }; + s_bwd_prop_DiffProjection3DGS_3dgs_persp_none_projection_Intermediates_0 _S3263; + (&_S3263)->_S3130 = _S3262; + (&_S3263)->_S3131 = _S3262; + (&_S3263)->_S3132 = _S3262; + float3 mean_c_22 = s_primal_ctx_mul_0(R_22, mean_23) + t_22; + float2 _S3264 = float2 {mean_c_22.x, mean_c_22.y}; + float2 _S3265 = make_float2 (1.0f, 0.0f); + float _S3266 = mean_c_22.z; + float2 _S3267 = _S3265 * make_float2 (_S3266); + float _S3268 = _S3266 * _S3266; + float2 s_diff_uv_24 = _S3267 / make_float2 (_S3268); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3269; + (&_S3269)->primal_0 = _S3264 / make_float2 (_S3266); + (&_S3269)->differential_0 = s_diff_uv_24; + FixedArray _S3270 = dist_coeffs_34; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3271 = s_primal_ctx_s_fwd_DistNone_distort_0(&_S3269, &_S3270); + (&_S3263)->_S3130 = _S3271; + float2 _S3272 = make_float2 (0.0f, 1.0f); + float2 _S3273 = _S3272 * make_float2 (_S3266); + float2 s_diff_uv_25 = _S3273 / make_float2 (_S3268); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3274; + (&_S3274)->primal_0 = _S3264 / make_float2 (_S3266); + (&_S3274)->differential_0 = s_diff_uv_25; + FixedArray _S3275 = dist_coeffs_34; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3276 = s_primal_ctx_s_fwd_DistNone_distort_0(&_S3274, &_S3275); + (&_S3263)->_S3131 = _S3276; + float2 _S3277 = make_float2 (0.0f, 0.0f); + float2 _S3278 = _S3277 - _S3264; + float2 s_diff_uv_26 = _S3278 / make_float2 (_S3268); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3279; + (&_S3279)->primal_0 = _S3264 / make_float2 (_S3266); + (&_S3279)->differential_0 = s_diff_uv_26; + FixedArray _S3280 = dist_coeffs_34; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3281 = s_primal_ctx_s_fwd_DistNone_distort_0(&_S3279, &_S3280); + (&_S3263)->_S3132 = _S3281; + float _S3282 = - in_opacity_22; + float _S3283 = 1.0f + s_primal_ctx_exp_0(_S3282); + float _S3284 = 1.0f / _S3283; + float _S3285 = _S3283 * _S3283; + float4 _S3286 = normalize_0(quat_22); + float3 _S3287 = s_primal_ctx_exp_1(scale_22); + float _S3288 = _S3286.y; + float x2_22 = _S3288 * _S3288; + float y2_22 = _S3286.z * _S3286.z; + float z2_22 = _S3286.w * _S3286.w; + float xy_22 = _S3286.y * _S3286.z; + float xz_22 = _S3286.y * _S3286.w; + float yz_22 = _S3286.z * _S3286.w; + float wx_22 = _S3286.x * _S3286.y; + float wy_22 = _S3286.x * _S3286.z; + float wz_22 = _S3286.x * _S3286.w; + Matrix _S3289 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_22 + z2_22), 2.0f * (xy_22 + wz_22), 2.0f * (xz_22 - wy_22), 2.0f * (xy_22 - wz_22), 1.0f - 2.0f * (x2_22 + z2_22), 2.0f * (yz_22 + wx_22), 2.0f * (xz_22 + wy_22), 2.0f * (yz_22 - wx_22), 1.0f - 2.0f * (x2_22 + y2_22))); + Matrix S_0 = makeMatrix (_S3287.x, 0.0f, 0.0f, 0.0f, _S3287.y, 0.0f, 0.0f, 0.0f, _S3287.z); + Matrix _S3290 = s_primal_ctx_mul_1(_S3289, S_0); + Matrix _S3291 = transpose_3(_S3290); + Matrix _S3292 = s_primal_ctx_mul_1(_S3290, _S3291); + Matrix _S3293 = s_primal_ctx_mul_1(R_22, _S3292); + Matrix _S3294 = transpose_3(R_22); + Matrix _S3295 = s_primal_ctx_mul_1(_S3293, _S3294); + Matrix J_32 = makeMatrix (0.0f); + float2 _S3296 = make_float2 (_S3266); + float2 _S3297 = make_float2 (_S3268); + float2 _S3298 = make_float2 (_S3268 * _S3268); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3299 = { _S3264 / make_float2 (_S3266), _S3267 / make_float2 (_S3268) }; + float _S3300 = _S3263._S3130.differential_0.x * fx_35; + float _S3301 = _S3263._S3130.differential_0.y * fy_35; + Matrix _S3302 = J_32; + *&(((&_S3302)->rows + (int(0)))->x) = _S3300; + *&(((&_S3302)->rows + (int(1)))->x) = _S3301; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3303 = { _S3264 / make_float2 (_S3266), _S3273 / make_float2 (_S3268) }; + float _S3304 = _S3263._S3131.differential_0.y * fy_35; + *&(((&_S3302)->rows + (int(0)))->y) = _S3263._S3131.differential_0.x * fx_35; + *&(((&_S3302)->rows + (int(1)))->y) = _S3304; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3305 = { _S3264 / make_float2 (_S3266), _S3278 / make_float2 (_S3268) }; + float _S3306 = _S3263._S3132.differential_0.x * fx_35; + float _S3307 = _S3263._S3132.differential_0.y * fy_35; + float _S3308 = float(image_width_22); + float _S3309 = 0.30000001192092896f * (0.5f * _S3308); + float lim_x_pos_12 = _S3308 + _S3309; + float rz_8 = 1.0f / _S3266; + float _S3310 = - _S3309; + float _S3311 = - (_S3310 - cx_26); + float max_Jxz_0 = _S3311 * rz_8; + float _S3312 = - (lim_x_pos_12 - cx_26); + float min_Jxz_0 = _S3312 * rz_8; + float _S3313 = - (_S3310 - cy_26); + float max_Jyz_8 = _S3313 * rz_8; + float _S3314 = - (lim_x_pos_12 - cy_26); + float min_Jyz_8 = _S3314 * rz_8; + *&(((&_S3302)->rows + (int(0)))->z) = s_primal_ctx_clamp_0(_S3306, min_Jxz_0, max_Jxz_0); + *&(((&_S3302)->rows + (int(1)))->z) = s_primal_ctx_clamp_0(_S3307, min_Jyz_8, max_Jyz_8); + Matrix _S3315 = s_primal_ctx_mul_2(_S3302, _S3295); + Matrix _S3316 = transpose_1(_S3302); + Matrix _S3317 = s_primal_ctx_mul_3(_S3315, _S3316); + float eps2d_22; + if(antialiased_22) { - eps2d_8 = 0.10000000149011612f; + eps2d_22 = 0.10000000149011612f; } else { - eps2d_8 = 0.30000001192092896f; + eps2d_22 = 0.30000001192092896f; } - float _S1534 = _S1533.rows[int(0)].y * _S1533.rows[int(1)].x; - float det_orig_8 = _S1533.rows[int(0)].x * _S1533.rows[int(1)].y - _S1534; - float _S1535 = _S1533.rows[int(0)].x + eps2d_8; - Matrix _S1536 = _S1533; - *&(((&_S1536)->rows + (int(0)))->x) = _S1535; - float _S1537 = _S1533.rows[int(1)].y + eps2d_8; - *&(((&_S1536)->rows + (int(1)))->y) = _S1537; - Matrix _S1538 = _S1536; - Matrix _S1539 = _S1536; - float det_blur_8 = _S1535 * _S1537 - _S1534; - float _S1540 = det_orig_8 / det_blur_8; - float _S1541 = det_blur_8 * det_blur_8; - float _S1542 = (F32_max((0.0f), (_S1540))); - float _S1543 = s_primal_ctx_sqrt_0(_S1542); - float invdet_10 = 1.0f / det_blur_8; - float _S1544 = - _S1533.rows[int(0)].y; - float _S1545 = - _S1533.rows[int(1)].x; - if(antialiased_8) + float _S3318 = _S3317.rows[int(0)].y * _S3317.rows[int(1)].x; + float det_orig_22 = _S3317.rows[int(0)].x * _S3317.rows[int(1)].y - _S3318; + float _S3319 = _S3317.rows[int(0)].x + eps2d_22; + Matrix _S3320 = _S3317; + *&(((&_S3320)->rows + (int(0)))->x) = _S3319; + float _S3321 = _S3317.rows[int(1)].y + eps2d_22; + *&(((&_S3320)->rows + (int(1)))->y) = _S3321; + Matrix _S3322 = _S3320; + Matrix _S3323 = _S3320; + float det_blur_22 = _S3319 * _S3321 - _S3318; + float _S3324 = det_orig_22 / det_blur_22; + float _S3325 = det_blur_22 * det_blur_22; + float _S3326 = (F32_max((0.0f), (_S3324))); + float _S3327 = s_primal_ctx_sqrt_0(_S3326); + float invdet_28 = 1.0f / det_blur_22; + float _S3328 = - _S3317.rows[int(0)].y; + float _S3329 = - _S3317.rows[int(1)].x; + if(antialiased_22) { - eps2d_8 = _S1424 * _S1543; + eps2d_22 = _S3284 * _S3327; } else { - eps2d_8 = _S1424; + eps2d_22 = _S3284; } - float _S1546 = eps2d_8 / 0.00392156885936856f; - float _S1547 = 2.0f * s_primal_ctx_log_0(_S1546); - float _S1548 = s_primal_ctx_sqrt_0(_S1547); - float _S1549 = _S1538.rows[int(0)].x; - float _S1550 = _S1539.rows[int(1)].y; - float3 campos_1 = - s_primal_ctx_mul_0(_S1434, t_8); - float3 _S1551 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1552; - (&_S1552)->primal_0 = mean_9; - (&_S1552)->differential_0 = _S1551; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1553; - (&_S1553)->primal_0 = scale_8; - (&_S1553)->differential_0 = _S1551; - DiffPair_float_0 _S1554; - (&_S1554)->primal_0 = in_opacity_8; - (&_S1554)->differential_0 = 0.0f; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1555; - (&_S1555)->primal_0 = campos_1; - (&_S1555)->differential_0 = _S1551; - s_bwd_prop_view_radius_3dgs_0(&_S1552, &_S1553, &_S1554, &_S1555, 0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1556 = _S1552; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1557 = _S1553; - DiffPair_float_0 _S1558 = _S1554; - float2 _S1559 = make_float2 (0.0f); - float2 _S1560 = _S1559; - *&((&_S1560)->y) = v_conic_0.z; - float2 _S1561 = _S1559; - *&((&_S1561)->y) = v_conic_0.y; - *&((&_S1561)->x) = v_conic_0.x; - DiffPair_float_0 _S1562; - (&_S1562)->primal_0 = _S1550; - (&_S1562)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1562, 0.0f); - DiffPair_float_0 _S1563; - (&_S1563)->primal_0 = _S1549; - (&_S1563)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1563, 0.0f); - DiffPair_float_0 _S1564; - (&_S1564)->primal_0 = 3.32999992370605469f; - (&_S1564)->differential_0 = 0.0f; - DiffPair_float_0 _S1565; - (&_S1565)->primal_0 = _S1548; - (&_S1565)->differential_0 = 0.0f; - _d_min_0(&_S1564, &_S1565, 0.0f); - DiffPair_float_0 _S1566; - (&_S1566)->primal_0 = _S1547; - (&_S1566)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1566, _S1565.differential_0); - float _S1567 = 2.0f * _S1566.differential_0; - DiffPair_float_0 _S1568; - (&_S1568)->primal_0 = _S1546; - (&_S1568)->differential_0 = 0.0f; - s_bwd_prop_log_0(&_S1568, _S1567); - float _S1569 = v_opacity_0 + 254.9999847412109375f * _S1568.differential_0; - float2 _S1570 = make_float2 (_S1563.differential_0, 0.0f); - Matrix _S1571 = makeMatrix (0.0f); - Matrix _S1572 = _S1571; - _S1572[int(1)] = _S1560; - _S1572[int(0)] = _S1561; - Matrix _S1573 = _S1572; - float2 _S1574 = make_float2 (0.0f, _S1562.differential_0); - float _S1575; - if(antialiased_8) + float _S3330 = eps2d_22 / 0.00392156885936856f; + float _S3331 = 2.0f * s_primal_ctx_log_0(_S3330); + float _S3332 = s_primal_ctx_sqrt_0(_S3331); + float _S3333 = _S3322.rows[int(0)].x; + float _S3334 = _S3323.rows[int(1)].y; + float3 campos_1 = - s_primal_ctx_mul_0(_S3294, t_22); + float3 _S3335 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3336; + (&_S3336)->primal_0 = mean_23; + (&_S3336)->differential_0 = _S3335; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3337; + (&_S3337)->primal_0 = scale_22; + (&_S3337)->differential_0 = _S3335; + DiffPair_float_0 _S3338; + (&_S3338)->primal_0 = in_opacity_22; + (&_S3338)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3339; + (&_S3339)->primal_0 = campos_1; + (&_S3339)->differential_0 = _S3335; + s_bwd_prop_view_radius_3dgs_0(&_S3336, &_S3337, &_S3338, &_S3339, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3340 = _S3336; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3341 = _S3337; + DiffPair_float_0 _S3342 = _S3338; + float2 _S3343 = _S3261; + *&((&_S3343)->y) = v_conic_0.z; + float2 _S3344 = _S3261; + *&((&_S3344)->y) = v_conic_0.y; + *&((&_S3344)->x) = v_conic_0.x; + DiffPair_float_0 _S3345; + (&_S3345)->primal_0 = _S3334; + (&_S3345)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3345, 0.0f); + DiffPair_float_0 _S3346; + (&_S3346)->primal_0 = _S3333; + (&_S3346)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3346, 0.0f); + DiffPair_float_0 _S3347; + (&_S3347)->primal_0 = 3.32999992370605469f; + (&_S3347)->differential_0 = 0.0f; + DiffPair_float_0 _S3348; + (&_S3348)->primal_0 = _S3332; + (&_S3348)->differential_0 = 0.0f; + _d_min_0(&_S3347, &_S3348, 0.0f); + DiffPair_float_0 _S3349; + (&_S3349)->primal_0 = _S3331; + (&_S3349)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3349, _S3348.differential_0); + float _S3350 = 2.0f * _S3349.differential_0; + DiffPair_float_0 _S3351; + (&_S3351)->primal_0 = _S3330; + (&_S3351)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S3351, _S3350); + float _S3352 = v_opacity_0 + 254.9999847412109375f * _S3351.differential_0; + Matrix _S3353 = makeMatrix (0.0f); + Matrix _S3354 = _S3353; + _S3354[int(1)] = _S3343; + _S3354[int(0)] = _S3344; + Matrix _S3355 = _S3354; + float2 _S3356 = make_float2 (0.0f, _S3345.differential_0); + float2 _S3357 = make_float2 (_S3346.differential_0, 0.0f); + float _S3358; + if(antialiased_22) { - float _S1576 = _S1543 * _S1569; - eps2d_8 = _S1424 * _S1569; - _S1575 = _S1576; + float _S3359 = _S3327 * _S3352; + eps2d_22 = _S3284 * _S3352; + _S3358 = _S3359; } else { - eps2d_8 = 0.0f; - _S1575 = _S1569; + eps2d_22 = 0.0f; + _S3358 = _S3352; } - float _S1577 = invdet_10 * _S1573.rows[int(1)].y; - float _S1578 = - (invdet_10 * _S1573.rows[int(1)].x); - float _S1579 = - (invdet_10 * _S1573.rows[int(0)].y); - float _S1580 = invdet_10 * _S1573.rows[int(0)].x; - float _S1581 = - ((_S1535 * _S1573.rows[int(1)].y + _S1545 * _S1573.rows[int(1)].x + _S1544 * _S1573.rows[int(0)].y + _S1537 * _S1573.rows[int(0)].x) / _S1541); - DiffPair_float_0 _S1582; - (&_S1582)->primal_0 = _S1542; - (&_S1582)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1582, eps2d_8); - DiffPair_float_0 _S1583; - (&_S1583)->primal_0 = 0.0f; - (&_S1583)->differential_0 = 0.0f; - DiffPair_float_0 _S1584; - (&_S1584)->primal_0 = _S1540; - (&_S1584)->differential_0 = 0.0f; - _d_max_0(&_S1583, &_S1584, _S1582.differential_0); - float _S1585 = _S1584.differential_0 / _S1541; - float s_diff_det_orig_T_0 = det_blur_8 * _S1585; - float _S1586 = det_orig_8 * - _S1585 + _S1581; - float _S1587 = - _S1586; - float _S1588 = _S1535 * _S1586; - float _S1589 = _S1537 * _S1586; - Matrix _S1590 = _S1571; - _S1590[int(1)] = _S1574; - _S1590[int(0)] = _S1570; - _S1536 = _S1590; - *&(((&_S1536)->rows + (int(1)))->y) = 0.0f; - float _S1591 = _S1588 + _S1590.rows[int(1)].y + _S1580; - *&(((&_S1536)->rows + (int(0)))->x) = 0.0f; - float _S1592 = _S1589 + _S1590.rows[int(0)].x + _S1577; - float _S1593 = _S1587 + - s_diff_det_orig_T_0; - float _S1594 = _S1533.rows[int(0)].y * _S1593 + _S1578; - float _S1595 = _S1533.rows[int(1)].x * _S1593 + _S1579; - float _S1596 = _S1533.rows[int(1)].y * s_diff_det_orig_T_0; - float _S1597 = _S1591 + _S1533.rows[int(0)].x * s_diff_det_orig_T_0; - float2 _S1598 = _S1559; - *&((&_S1598)->x) = _S1594; - *&((&_S1598)->y) = _S1597; - float _S1599 = _S1592 + _S1596; - float2 _S1600 = _S1559; - *&((&_S1600)->y) = _S1595; - *&((&_S1600)->x) = _S1599; - Matrix _S1601 = _S1571; - _S1601[int(1)] = _S1598; - _S1601[int(0)] = _S1600; - Matrix _S1602 = _S1536 + _S1601; - DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S1603; - (&_S1603)->primal_0 = _S1531; - (&_S1603)->differential_0 = J_10; - Matrix _S1604 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S1605; - (&_S1605)->primal_0 = _S1532; - (&_S1605)->differential_0 = _S1604; - s_bwd_prop_mul_0(&_S1603, &_S1605, _S1602); - Matrix _S1606 = transpose_2(_S1605.differential_0); - DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S1607; - (&_S1607)->primal_0 = _S1471; - (&_S1607)->differential_0 = J_10; - Matrix _S1608 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1609; - (&_S1609)->primal_0 = _S1435; - (&_S1609)->differential_0 = _S1608; - s_bwd_prop_mul_1(&_S1607, &_S1609, _S1603.differential_0); - Matrix _S1610 = _S1606 + _S1607.differential_0; - DiffPair_float_0 _S1611; - (&_S1611)->primal_0 = _S1523; - (&_S1611)->differential_0 = 0.0f; - DiffPair_float_0 _S1612; - (&_S1612)->primal_0 = min_Jyz_2; - (&_S1612)->differential_0 = 0.0f; - DiffPair_float_0 _S1613; - (&_S1613)->primal_0 = max_Jyz_2; - (&_S1613)->differential_0 = 0.0f; - s_bwd_prop_clamp_0(&_S1611, &_S1612, &_S1613, _S1610.rows[int(1)].z); - DiffPair_float_0 _S1614; - (&_S1614)->primal_0 = _S1522; - (&_S1614)->differential_0 = 0.0f; - DiffPair_float_0 _S1615; - (&_S1615)->primal_0 = min_Jxz_0; - (&_S1615)->differential_0 = 0.0f; - DiffPair_float_0 _S1616; - (&_S1616)->primal_0 = max_Jxz_0; - (&_S1616)->differential_0 = 0.0f; - s_bwd_prop_clamp_0(&_S1614, &_S1615, &_S1616, _S1610.rows[int(0)].z); - float _S1617 = - ((_S1530 * _S1612.differential_0 + _S1529 * _S1613.differential_0 + _S1528 * _S1615.differential_0 + _S1527 * _S1616.differential_0) / _S1441); - float2 _S1618 = make_float2 (0.0f, _S1611.differential_0) + make_float2 (_S1614.differential_0, 0.0f); - float _S1619 = fx_12 * _S1618.x; - float2 _S1620 = make_float2 (_S1619, fy_12 * _S1618.y) + make_float2 (dist_coeffs_12[int(8)] * _S1619, dist_coeffs_12[int(9)] * _S1619); - float2 _S1621 = _S1498 * _S1620; - float2 _S1622 = _S1500 * _S1620; - float _S1623 = dist_coeffs_12[int(4)] * _S1620.y; - float _S1624 = dist_coeffs_12[int(5)] * _S1620.x; - float _S1625 = _S1622.x + _S1622.y; - float _S1626 = _S1621.x + _S1621.y; - float _S1627 = r2_74 * _S1626; - float _S1628 = s_diff_r2_20 * _S1626 + r2_74 * _S1625; - float _S1629 = r2_74 * _S1627; - float _S1630 = s_diff_r2_20 * _S1627 + r2_74 * _S1628; - float _S1631 = dist_coeffs_12[int(7)] * _S1620.y + _S1623 + dist_coeffs_12[int(6)] * _S1620.x + _S1624 + _S1508 * _S1626 + _S1506 * _S1627 + _S1504 * _S1629 + dist_coeffs_12[int(3)] * (r2_74 * _S1629); - float _S1632 = _S1507 * _S1626 + _S1508 * _S1625 + _S1505 * _S1627 + _S1506 * _S1628 + _S1503 * _S1629 + _S1504 * _S1630 + dist_coeffs_12[int(3)] * (s_diff_r2_20 * _S1629 + r2_74 * _S1630); - float _S1633 = _S1631 + _S1631; - float _S1634 = v_74 * _S1632; - float _S1635 = u_74 * _S1632; - float2 _S1636 = (_S1511 * _S1620 + make_float2 (_S1462 * (v_74 * _S1620.y) + _S1514 * _S1624 + 2.0f * (u_74 * _S1624) + _S1457 * (v_74 * _S1620.x) + u_74 * _S1633, _S1518 * _S1623 + 2.0f * (v_74 * _S1623) + _S1516 * _S1620.y + _S1512 * _S1620.x + v_74 * _S1633)) / _S1445; - float2 _S1637 = _S1499 * - _S1636; - float _S1638 = _S1438 * (_S1637.x + _S1637.y); - float2 _S1639 = (_S1510 * _S1620 + make_float2 (_S1462 * (s_diff_v_20 * _S1620.y) + _S1515 * _S1624 + 2.0f * (s_diff_u_20 * _S1624) + _S1457 * (s_diff_v_20 * _S1620.x) + s_diff_u_20 * _S1633 + _S1635 + _S1635, _S1519 * _S1623 + 2.0f * (s_diff_v_20 * _S1623) + _S1517 * _S1620.y + _S1513 * _S1620.x + s_diff_v_20 * _S1633 + _S1634 + _S1634)) / _S1442; - float2 _S1640 = _S1436 * - _S1639; - float2 _S1641 = - (_S1442 * _S1636) + _S1439 * _S1639; - float3 _S1642 = make_float3 (_S1641.x, _S1641.y, _S1638 + _S1638 + _S1640.x + _S1640.y); - float2 _S1643 = make_float2 (0.0f, _S1610.rows[int(1)].y) + make_float2 (_S1610.rows[int(0)].y, 0.0f); - float _S1644 = fx_12 * _S1643.x; - float2 _S1645 = make_float2 (_S1644, fy_12 * _S1643.y) + make_float2 (dist_coeffs_12[int(8)] * _S1644, dist_coeffs_12[int(9)] * _S1644); - float2 _S1646 = _S1473 * _S1645; - float2 _S1647 = _S1475 * _S1645; - float _S1648 = dist_coeffs_12[int(4)] * _S1645.y; - float _S1649 = dist_coeffs_12[int(5)] * _S1645.x; - float _S1650 = _S1647.x + _S1647.y; - float _S1651 = _S1646.x + _S1646.y; - float _S1652 = r2_73 * _S1651; - float _S1653 = s_diff_r2_19 * _S1651 + r2_73 * _S1650; - float _S1654 = r2_73 * _S1652; - float _S1655 = s_diff_r2_19 * _S1652 + r2_73 * _S1653; - float _S1656 = dist_coeffs_12[int(7)] * _S1645.y + _S1648 + dist_coeffs_12[int(6)] * _S1645.x + _S1649 + _S1483 * _S1651 + _S1481 * _S1652 + _S1479 * _S1654 + dist_coeffs_12[int(3)] * (r2_73 * _S1654); - float _S1657 = _S1482 * _S1651 + _S1483 * _S1650 + _S1480 * _S1652 + _S1481 * _S1653 + _S1478 * _S1654 + _S1479 * _S1655 + dist_coeffs_12[int(3)] * (s_diff_r2_19 * _S1654 + r2_73 * _S1655); - float _S1658 = _S1656 + _S1656; - float _S1659 = v_73 * _S1657; - float _S1660 = u_73 * _S1657; - float2 _S1661 = (_S1486 * _S1645 + make_float2 (_S1462 * (v_73 * _S1645.y) + _S1489 * _S1649 + 2.0f * (u_73 * _S1649) + _S1457 * (v_73 * _S1645.x) + u_73 * _S1658, _S1493 * _S1648 + 2.0f * (v_73 * _S1648) + _S1491 * _S1645.y + _S1487 * _S1645.x + v_73 * _S1658)) / _S1445; - float2 _S1662 = _S1474 * - _S1661; - float _S1663 = _S1438 * (_S1662.x + _S1662.y); - float2 _S1664 = _S1472 * (_S1442 * _S1661); - float2 _S1665 = (_S1485 * _S1645 + make_float2 (_S1462 * (s_diff_v_19 * _S1645.y) + _S1490 * _S1649 + 2.0f * (s_diff_u_19 * _S1649) + _S1457 * (s_diff_v_19 * _S1645.x) + s_diff_u_19 * _S1658 + _S1660 + _S1660, _S1494 * _S1648 + 2.0f * (s_diff_v_19 * _S1648) + _S1492 * _S1645.y + _S1488 * _S1645.x + s_diff_v_19 * _S1658 + _S1659 + _S1659)) / _S1442; - float2 _S1666 = _S1436 * - _S1665; - float2 _S1667 = _S1439 * _S1665; - float3 _S1668 = make_float3 (_S1667.x, _S1667.y, _S1663 + _S1663 + _S1664.x + _S1664.y + _S1666.x + _S1666.y); - float2 _S1669 = make_float2 (0.0f, _S1610.rows[int(1)].x) + make_float2 (_S1610.rows[int(0)].x, 0.0f); - float _S1670 = fx_12 * _S1669.x; - float2 _S1671 = make_float2 (_S1670, fy_12 * _S1669.y) + make_float2 (dist_coeffs_12[int(8)] * _S1670, dist_coeffs_12[int(9)] * _S1670); - float2 _S1672 = _S1440 * _S1671; - float2 _S1673 = _S1444 * _S1671; - float _S1674 = dist_coeffs_12[int(4)] * _S1671.y; - float _S1675 = dist_coeffs_12[int(5)] * _S1671.x; - float _S1676 = _S1673.x + _S1673.y; - float _S1677 = _S1672.x + _S1672.y; - float _S1678 = r2_72 * _S1677; - float _S1679 = s_diff_r2_18 * _S1677 + r2_72 * _S1676; - float _S1680 = r2_72 * _S1678; - float _S1681 = s_diff_r2_18 * _S1678 + r2_72 * _S1679; - float _S1682 = dist_coeffs_12[int(7)] * _S1671.y + _S1674 + dist_coeffs_12[int(6)] * _S1671.x + _S1675 + _S1453 * _S1677 + _S1451 * _S1678 + _S1449 * _S1680 + dist_coeffs_12[int(3)] * (r2_72 * _S1680); - float _S1683 = _S1452 * _S1677 + _S1453 * _S1676 + _S1450 * _S1678 + _S1451 * _S1679 + _S1448 * _S1680 + _S1449 * _S1681 + dist_coeffs_12[int(3)] * (s_diff_r2_18 * _S1680 + r2_72 * _S1681); - float _S1684 = _S1682 + _S1682; - float _S1685 = v_72 * _S1683; - float _S1686 = u_72 * _S1683; - float2 _S1687 = (_S1456 * _S1671 + make_float2 (_S1462 * (v_72 * _S1671.y) + _S1460 * _S1675 + 2.0f * (u_72 * _S1675) + _S1457 * (v_72 * _S1671.x) + u_72 * _S1684, _S1465 * _S1674 + 2.0f * (v_72 * _S1674) + _S1463 * _S1671.y + _S1458 * _S1671.x + v_72 * _S1684)) / _S1445; - float2 _S1688 = _S1443 * - _S1687; - float _S1689 = _S1438 * (_S1688.x + _S1688.y); - float2 _S1690 = _S1437 * (_S1442 * _S1687); - float2 _S1691 = (_S1455 * _S1671 + make_float2 (_S1462 * (s_diff_v_18 * _S1671.y) + _S1461 * _S1675 + 2.0f * (s_diff_u_18 * _S1675) + _S1457 * (s_diff_v_18 * _S1671.x) + s_diff_u_18 * _S1684 + _S1686 + _S1686, _S1466 * _S1674 + 2.0f * (s_diff_v_18 * _S1674) + _S1464 * _S1671.y + _S1459 * _S1671.x + s_diff_v_18 * _S1684 + _S1685 + _S1685)) / _S1442; - float2 _S1692 = _S1436 * - _S1691; - float2 _S1693 = _S1439 * _S1691; - float3 _S1694 = make_float3 (_S1693.x, _S1693.y, _S1689 + _S1689 + _S1690.x + _S1690.y + _S1692.x + _S1692.y); - float2 _S1695 = _S1436 / make_float2 (_S1438); - float _S1696 = fx_12 * v_mean2d_0.x; - float u_75 = _S1695.x; - float v_75 = _S1695.y; - float r2_75 = u_75 * u_75 + v_75 * v_75; - float _S1697 = dist_coeffs_12[int(2)] + r2_75 * dist_coeffs_12[int(3)]; - float _S1698 = dist_coeffs_12[int(1)] + r2_75 * _S1697; - float _S1699 = dist_coeffs_12[int(0)] + r2_75 * _S1698; - float2 _S1700 = make_float2 (_S1696, fy_12 * v_mean2d_0.y) + make_float2 (dist_coeffs_12[int(8)] * _S1696, dist_coeffs_12[int(9)] * _S1696); - float2 _S1701 = _S1695 * _S1700; - float _S1702 = dist_coeffs_12[int(4)] * _S1700.y; - float _S1703 = dist_coeffs_12[int(5)] * _S1700.x; - float _S1704 = _S1701.x + _S1701.y; - float _S1705 = r2_75 * _S1704; - float _S1706 = r2_75 * _S1705; - float _S1707 = dist_coeffs_12[int(7)] * _S1700.y + _S1702 + dist_coeffs_12[int(6)] * _S1700.x + _S1703 + _S1699 * _S1704 + _S1698 * _S1705 + _S1697 * _S1706 + dist_coeffs_12[int(3)] * (r2_75 * _S1706); - float _S1708 = v_75 * _S1707; - float _S1709 = u_75 * _S1707; - float2 _S1710 = (make_float2 (1.0f + r2_75 * _S1699) * _S1700 + make_float2 (_S1462 * (v_75 * _S1700.y) + 2.0f * u_75 * _S1703 + 2.0f * (u_75 * _S1703) + _S1457 * (v_75 * _S1700.x) + _S1709 + _S1709, 2.0f * v_75 * _S1702 + 2.0f * (v_75 * _S1702) + _S1462 * u_75 * _S1700.y + _S1457 * u_75 * _S1700.x + _S1708 + _S1708)) / _S1442; - float2 _S1711 = _S1436 * - _S1710; - float2 _S1712 = _S1439 * _S1710; - float3 _S1713 = make_float3 (_S1712.x, _S1712.y, _S1711.x + _S1711.y); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1714; - (&_S1714)->primal_0 = _S1433; - (&_S1714)->differential_0 = _S1608; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1715; - (&_S1715)->primal_0 = _S1434; - (&_S1715)->differential_0 = _S1608; - s_bwd_prop_mul_2(&_S1714, &_S1715, _S1609.differential_0); - Matrix _S1716 = transpose_3(_S1715.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1717; - (&_S1717)->primal_0 = R_8; - (&_S1717)->differential_0 = _S1608; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1718; - (&_S1718)->primal_0 = _S1432; - (&_S1718)->differential_0 = _S1608; - s_bwd_prop_mul_2(&_S1717, &_S1718, _S1714.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1719; - (&_S1719)->primal_0 = _S1430; - (&_S1719)->differential_0 = _S1608; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1720; - (&_S1720)->primal_0 = _S1431; - (&_S1720)->differential_0 = _S1608; - s_bwd_prop_mul_2(&_S1719, &_S1720, _S1718.differential_0); - Matrix _S1721 = _S1719.differential_0 + transpose_3(_S1720.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1722; - (&_S1722)->primal_0 = _S1429; - (&_S1722)->differential_0 = _S1608; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1723; - (&_S1723)->primal_0 = S_0; - (&_S1723)->differential_0 = _S1608; - s_bwd_prop_mul_2(&_S1722, &_S1723, _S1721); - Matrix _S1724 = transpose_3(_S1722.differential_0); - float _S1725 = 2.0f * - _S1724.rows[int(2)].z; - float _S1726 = 2.0f * _S1724.rows[int(2)].y; - float _S1727 = 2.0f * _S1724.rows[int(2)].x; - float _S1728 = 2.0f * _S1724.rows[int(1)].z; - float _S1729 = 2.0f * - _S1724.rows[int(1)].y; - float _S1730 = 2.0f * _S1724.rows[int(1)].x; - float _S1731 = 2.0f * _S1724.rows[int(0)].z; - float _S1732 = 2.0f * _S1724.rows[int(0)].y; - float _S1733 = 2.0f * - _S1724.rows[int(0)].x; - float _S1734 = - _S1730 + _S1732; - float _S1735 = _S1727 + - _S1731; - float _S1736 = - _S1726 + _S1728; - float _S1737 = _S1726 + _S1728; - float _S1738 = _S1727 + _S1731; - float _S1739 = _S1730 + _S1732; - float _S1740 = _S1426.w * (_S1729 + _S1733); - float _S1741 = _S1426.z * (_S1725 + _S1733); - float _S1742 = _S1426.y * (_S1725 + _S1729); - float _S1743 = _S1426.x * _S1734 + _S1426.z * _S1737 + _S1426.y * _S1738 + _S1740 + _S1740; - float _S1744 = _S1426.x * _S1735 + _S1426.w * _S1737 + _S1426.y * _S1739 + _S1741 + _S1741; - float _S1745 = _S1426.x * _S1736 + _S1426.w * _S1738 + _S1426.z * _S1739 + _S1742 + _S1742; - float _S1746 = _S1426.w * _S1734 + _S1426.z * _S1735 + _S1426.y * _S1736; - float3 _S1747 = _S1551; - *&((&_S1747)->z) = _S1723.differential_0.rows[int(2)].z; - *&((&_S1747)->y) = _S1723.differential_0.rows[int(1)].y; - *&((&_S1747)->x) = _S1723.differential_0.rows[int(0)].x; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1748; - (&_S1748)->primal_0 = scale_8; - (&_S1748)->differential_0 = _S1551; - s_bwd_prop_exp_1(&_S1748, _S1747); - float4 _S1749 = make_float4 (0.0f); - float4 _S1750 = _S1749; - *&((&_S1750)->w) = _S1743; - *&((&_S1750)->z) = _S1744; - *&((&_S1750)->y) = _S1745; - *&((&_S1750)->x) = _S1746; - DiffPair_vectorx3Cfloatx2C4x3E_0 _S1751; - (&_S1751)->primal_0 = quat_8; - (&_S1751)->differential_0 = _S1749; - s_bwd_normalize_impl_0(&_S1751, _S1750); - float _S1752 = - (_S1575 / _S1425); - DiffPair_float_0 _S1753; - (&_S1753)->primal_0 = _S1422; - (&_S1753)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S1753, _S1752); - float _S1754 = - _S1753.differential_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1755; - (&_S1755)->primal_0 = mean_c_8; - (&_S1755)->differential_0 = _S1551; - s_bwd_length_impl_0(&_S1755, v_depth_0); - float3 _S1756 = _S1642 + _S1668 + _S1694 + _S1713 + _S1755.differential_0 + make_float3 (0.0f, 0.0f, _S1617); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1757; - (&_S1757)->primal_0 = R_8; - (&_S1757)->differential_0 = _S1608; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1758; - (&_S1758)->primal_0 = mean_9; - (&_S1758)->differential_0 = _S1551; - s_bwd_prop_mul_3(&_S1757, &_S1758, _S1756); - Matrix _S1759 = _S1716 + _S1717.differential_0 + _S1757.differential_0; - float _S1760 = _S1754 + _S1558.differential_0; - float3 _S1761 = _S1748.differential_0 + _S1557.differential_0; - *v_mean_0 = *v_mean_0 + (_S1758.differential_0 + _S1556.differential_0); - *v_quat_0 = *v_quat_0 + _S1751.differential_0; - *v_scale_0 = *v_scale_0 + _S1761; - *v_in_opacity_0 = *v_in_opacity_0 + _S1760; - *v_R_0 = *v_R_0 + _S1759; - *v_t_0 = *v_t_0 + _S1756; + float _S3360 = invdet_28 * _S3355.rows[int(1)].y; + float _S3361 = - (invdet_28 * _S3355.rows[int(1)].x); + float _S3362 = - (invdet_28 * _S3355.rows[int(0)].y); + float _S3363 = invdet_28 * _S3355.rows[int(0)].x; + float _S3364 = - ((_S3319 * _S3355.rows[int(1)].y + _S3329 * _S3355.rows[int(1)].x + _S3328 * _S3355.rows[int(0)].y + _S3321 * _S3355.rows[int(0)].x) / _S3325); + DiffPair_float_0 _S3365; + (&_S3365)->primal_0 = _S3326; + (&_S3365)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3365, eps2d_22); + DiffPair_float_0 _S3366; + (&_S3366)->primal_0 = 0.0f; + (&_S3366)->differential_0 = 0.0f; + DiffPair_float_0 _S3367; + (&_S3367)->primal_0 = _S3324; + (&_S3367)->differential_0 = 0.0f; + _d_max_0(&_S3366, &_S3367, _S3365.differential_0); + float _S3368 = _S3367.differential_0 / _S3325; + float s_diff_det_orig_T_0 = det_blur_22 * _S3368; + float _S3369 = det_orig_22 * - _S3368 + _S3364; + float _S3370 = - _S3369; + float _S3371 = _S3319 * _S3369; + float _S3372 = _S3321 * _S3369; + Matrix _S3373 = _S3353; + _S3373[int(1)] = _S3356; + _S3373[int(0)] = _S3357; + _S3320 = _S3373; + *&(((&_S3320)->rows + (int(1)))->y) = 0.0f; + float _S3374 = _S3371 + _S3373.rows[int(1)].y + _S3363; + *&(((&_S3320)->rows + (int(0)))->x) = 0.0f; + float _S3375 = _S3372 + _S3373.rows[int(0)].x + _S3360; + float _S3376 = _S3370 + - s_diff_det_orig_T_0; + float _S3377 = _S3317.rows[int(0)].y * _S3376 + _S3361; + float _S3378 = _S3317.rows[int(1)].x * _S3376 + _S3362; + float _S3379 = _S3317.rows[int(1)].y * s_diff_det_orig_T_0; + float _S3380 = _S3374 + _S3317.rows[int(0)].x * s_diff_det_orig_T_0; + float2 _S3381 = _S3261; + *&((&_S3381)->x) = _S3377; + *&((&_S3381)->y) = _S3380; + float _S3382 = _S3375 + _S3379; + float2 _S3383 = _S3261; + *&((&_S3383)->y) = _S3378; + *&((&_S3383)->x) = _S3382; + Matrix _S3384 = _S3353; + _S3384[int(1)] = _S3381; + _S3384[int(0)] = _S3383; + Matrix _S3385 = _S3320 + _S3384; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S3386; + (&_S3386)->primal_0 = _S3315; + (&_S3386)->differential_0 = J_32; + Matrix _S3387 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S3388; + (&_S3388)->primal_0 = _S3316; + (&_S3388)->differential_0 = _S3387; + s_bwd_prop_mul_0(&_S3386, &_S3388, _S3385); + Matrix _S3389 = transpose_2(_S3388.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S3390; + (&_S3390)->primal_0 = _S3302; + (&_S3390)->differential_0 = J_32; + Matrix _S3391 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3392; + (&_S3392)->primal_0 = _S3295; + (&_S3392)->differential_0 = _S3391; + s_bwd_prop_mul_1(&_S3390, &_S3392, _S3386.differential_0); + Matrix _S3393 = _S3389 + _S3390.differential_0; + DiffPair_float_0 _S3394; + (&_S3394)->primal_0 = _S3307; + (&_S3394)->differential_0 = 0.0f; + DiffPair_float_0 _S3395; + (&_S3395)->primal_0 = min_Jyz_8; + (&_S3395)->differential_0 = 0.0f; + DiffPair_float_0 _S3396; + (&_S3396)->primal_0 = max_Jyz_8; + (&_S3396)->differential_0 = 0.0f; + s_bwd_prop_clamp_0(&_S3394, &_S3395, &_S3396, _S3393.rows[int(1)].z); + DiffPair_float_0 _S3397; + (&_S3397)->primal_0 = _S3306; + (&_S3397)->differential_0 = 0.0f; + DiffPair_float_0 _S3398; + (&_S3398)->primal_0 = min_Jxz_0; + (&_S3398)->differential_0 = 0.0f; + DiffPair_float_0 _S3399; + (&_S3399)->primal_0 = max_Jxz_0; + (&_S3399)->differential_0 = 0.0f; + s_bwd_prop_clamp_0(&_S3397, &_S3398, &_S3399, _S3393.rows[int(0)].z); + float _S3400 = - ((_S3314 * _S3395.differential_0 + _S3313 * _S3396.differential_0 + _S3312 * _S3398.differential_0 + _S3311 * _S3399.differential_0) / _S3268); + float2 _S3401 = make_float2 (fx_35 * _S3397.differential_0, fy_35 * _S3394.differential_0); + DiffPair_0 _S3402; + (&_S3402)->primal_0 = _S3305; + (&_S3402)->differential_0 = _S3262; + FixedArray _S3403 = dist_coeffs_34; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3404; + (&_S3404)->primal_0 = _S3277; + (&_S3404)->differential_0 = _S3401; + s_bwd_prop_s_fwd_DistNone_distort_0(&_S3402, &_S3403, &_S3404); + float2 _S3405 = _S3402.differential_0.differential_0 / _S3298; + float2 _S3406 = _S3278 * - _S3405; + float _S3407 = _S3266 * (_S3406.x + _S3406.y); + float2 _S3408 = _S3402.differential_0.primal_0 / _S3297; + float2 _S3409 = _S3264 * - _S3408; + float2 _S3410 = - (_S3297 * _S3405) + _S3296 * _S3408; + float3 _S3411 = make_float3 (_S3410.x, _S3410.y, _S3407 + _S3407 + _S3409.x + _S3409.y); + float2 _S3412 = make_float2 (fx_35 * _S3393.rows[int(0)].y, fy_35 * _S3393.rows[int(1)].y); + DiffPair_0 _S3413; + (&_S3413)->primal_0 = _S3303; + (&_S3413)->differential_0 = _S3262; + FixedArray _S3414 = dist_coeffs_34; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3415; + (&_S3415)->primal_0 = _S3277; + (&_S3415)->differential_0 = _S3412; + s_bwd_prop_s_fwd_DistNone_distort_0(&_S3413, &_S3414, &_S3415); + float2 _S3416 = _S3413.differential_0.differential_0 / _S3298; + float2 _S3417 = _S3273 * - _S3416; + float _S3418 = _S3266 * (_S3417.x + _S3417.y); + float2 _S3419 = _S3272 * (_S3297 * _S3416); + float2 _S3420 = _S3413.differential_0.primal_0 / _S3297; + float2 _S3421 = _S3264 * - _S3420; + float2 _S3422 = _S3296 * _S3420; + float3 _S3423 = make_float3 (_S3422.x, _S3422.y, _S3418 + _S3418 + _S3419.x + _S3419.y + _S3421.x + _S3421.y); + float2 _S3424 = make_float2 (fx_35 * _S3393.rows[int(0)].x, fy_35 * _S3393.rows[int(1)].x); + DiffPair_0 _S3425; + (&_S3425)->primal_0 = _S3299; + (&_S3425)->differential_0 = _S3262; + FixedArray _S3426 = dist_coeffs_34; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3427; + (&_S3427)->primal_0 = _S3277; + (&_S3427)->differential_0 = _S3424; + s_bwd_prop_s_fwd_DistNone_distort_0(&_S3425, &_S3426, &_S3427); + float2 _S3428 = _S3425.differential_0.differential_0 / _S3298; + float2 _S3429 = _S3267 * - _S3428; + float _S3430 = _S3266 * (_S3429.x + _S3429.y); + float2 _S3431 = _S3265 * (_S3297 * _S3428); + float2 _S3432 = _S3425.differential_0.primal_0 / _S3297; + float2 _S3433 = _S3264 * - _S3432; + float2 _S3434 = _S3296 * _S3432; + float3 _S3435 = make_float3 (_S3434.x, _S3434.y, _S3430 + _S3430 + _S3431.x + _S3431.y + _S3433.x + _S3433.y); + float2 _S3436 = make_float2 (fx_35 * v_mean2d_0.x, fy_35 * v_mean2d_0.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3437; + (&_S3437)->primal_0 = _S3264 / make_float2 (_S3266); + (&_S3437)->differential_0 = _S3261; + FixedArray _S3438 = dist_coeffs_34; + s_bwd_prop_DistNone_distort_0(&_S3437, &_S3438, _S3436); + float2 _S3439 = _S3437.differential_0 / _S3297; + float2 _S3440 = _S3264 * - _S3439; + float2 _S3441 = _S3296 * _S3439; + float3 _S3442 = make_float3 (_S3441.x, _S3441.y, _S3440.x + _S3440.y); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3443; + (&_S3443)->primal_0 = _S3293; + (&_S3443)->differential_0 = _S3391; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3444; + (&_S3444)->primal_0 = _S3294; + (&_S3444)->differential_0 = _S3391; + s_bwd_prop_mul_2(&_S3443, &_S3444, _S3392.differential_0); + Matrix _S3445 = transpose_3(_S3444.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3446; + (&_S3446)->primal_0 = R_22; + (&_S3446)->differential_0 = _S3391; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3447; + (&_S3447)->primal_0 = _S3292; + (&_S3447)->differential_0 = _S3391; + s_bwd_prop_mul_2(&_S3446, &_S3447, _S3443.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3448; + (&_S3448)->primal_0 = _S3290; + (&_S3448)->differential_0 = _S3391; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3449; + (&_S3449)->primal_0 = _S3291; + (&_S3449)->differential_0 = _S3391; + s_bwd_prop_mul_2(&_S3448, &_S3449, _S3447.differential_0); + Matrix _S3450 = _S3448.differential_0 + transpose_3(_S3449.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3451; + (&_S3451)->primal_0 = _S3289; + (&_S3451)->differential_0 = _S3391; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3452; + (&_S3452)->primal_0 = S_0; + (&_S3452)->differential_0 = _S3391; + s_bwd_prop_mul_2(&_S3451, &_S3452, _S3450); + Matrix _S3453 = transpose_3(_S3451.differential_0); + float _S3454 = 2.0f * - _S3453.rows[int(2)].z; + float _S3455 = 2.0f * _S3453.rows[int(2)].y; + float _S3456 = 2.0f * _S3453.rows[int(2)].x; + float _S3457 = 2.0f * _S3453.rows[int(1)].z; + float _S3458 = 2.0f * - _S3453.rows[int(1)].y; + float _S3459 = 2.0f * _S3453.rows[int(1)].x; + float _S3460 = 2.0f * _S3453.rows[int(0)].z; + float _S3461 = 2.0f * _S3453.rows[int(0)].y; + float _S3462 = 2.0f * - _S3453.rows[int(0)].x; + float _S3463 = - _S3459 + _S3461; + float _S3464 = _S3456 + - _S3460; + float _S3465 = - _S3455 + _S3457; + float _S3466 = _S3455 + _S3457; + float _S3467 = _S3456 + _S3460; + float _S3468 = _S3459 + _S3461; + float _S3469 = _S3286.w * (_S3458 + _S3462); + float _S3470 = _S3286.z * (_S3454 + _S3462); + float _S3471 = _S3286.y * (_S3454 + _S3458); + float _S3472 = _S3286.x * _S3463 + _S3286.z * _S3466 + _S3286.y * _S3467 + _S3469 + _S3469; + float _S3473 = _S3286.x * _S3464 + _S3286.w * _S3466 + _S3286.y * _S3468 + _S3470 + _S3470; + float _S3474 = _S3286.x * _S3465 + _S3286.w * _S3467 + _S3286.z * _S3468 + _S3471 + _S3471; + float _S3475 = _S3286.w * _S3463 + _S3286.z * _S3464 + _S3286.y * _S3465; + float3 _S3476 = _S3335; + *&((&_S3476)->z) = _S3452.differential_0.rows[int(2)].z; + *&((&_S3476)->y) = _S3452.differential_0.rows[int(1)].y; + *&((&_S3476)->x) = _S3452.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3477; + (&_S3477)->primal_0 = scale_22; + (&_S3477)->differential_0 = _S3335; + s_bwd_prop_exp_1(&_S3477, _S3476); + float4 _S3478 = make_float4 (0.0f); + float4 _S3479 = _S3478; + *&((&_S3479)->w) = _S3472; + *&((&_S3479)->z) = _S3473; + *&((&_S3479)->y) = _S3474; + *&((&_S3479)->x) = _S3475; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S3480; + (&_S3480)->primal_0 = quat_22; + (&_S3480)->differential_0 = _S3478; + s_bwd_normalize_impl_0(&_S3480, _S3479); + float _S3481 = - (_S3358 / _S3285); + DiffPair_float_0 _S3482; + (&_S3482)->primal_0 = _S3282; + (&_S3482)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S3482, _S3481); + float _S3483 = - _S3482.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3484; + (&_S3484)->primal_0 = mean_c_22; + (&_S3484)->differential_0 = _S3335; + s_bwd_length_impl_0(&_S3484, v_depth_0); + float3 _S3485 = _S3411 + _S3423 + _S3435 + _S3442 + _S3484.differential_0 + make_float3 (0.0f, 0.0f, _S3400); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3486; + (&_S3486)->primal_0 = R_22; + (&_S3486)->differential_0 = _S3391; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3487; + (&_S3487)->primal_0 = mean_23; + (&_S3487)->differential_0 = _S3335; + s_bwd_prop_mul_3(&_S3486, &_S3487, _S3485); + Matrix _S3488 = _S3445 + _S3446.differential_0 + _S3486.differential_0; + float _S3489 = _S3483 + _S3342.differential_0; + float3 _S3490 = _S3477.differential_0 + _S3341.differential_0; + *v_mean_0 = *v_mean_0 + (_S3487.differential_0 + _S3340.differential_0); + *v_quat_0 = *v_quat_0 + _S3480.differential_0; + *v_scale_0 = *v_scale_0 + _S3490; + *v_in_opacity_0 = *v_in_opacity_0 + _S3489; + *v_R_0 = *v_R_0 + _S3488; + *v_t_0 = *v_t_0 + _S3485; return; } +struct s_bwd_prop_DiffProjection3DGS_3dgs_persp_opencv_projection_Intermediates_0 +{ + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3491; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3492; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3493; +}; + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_primal_ctx_s_fwd_DistOpenCV_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpdpuv_2, FixedArray * coeffs_11) +{ + float u_6 = dpdpuv_2->primal_0.x; + float s_diff_u_3 = dpdpuv_2->differential_0.x; + float v_6 = dpdpuv_2->primal_0.y; + float s_diff_v_3 = dpdpuv_2->differential_0.y; + float _S3494 = s_diff_u_3 * u_6; + float _S3495 = s_diff_v_3 * v_6; + float r2_6 = u_6 * u_6 + v_6 * v_6; + float s_diff_r2_3 = _S3494 + _S3494 + (_S3495 + _S3495); + float _S3496 = (*coeffs_11)[int(0)] + r2_6 * (*coeffs_11)[int(1)]; + float radial_3 = 1.0f + r2_6 * _S3496; + float _S3497 = 2.0f * (*coeffs_11)[int(2)]; + float _S3498 = _S3497 * u_6; + float _S3499 = 2.0f * u_6; + float _S3500 = 2.0f * (*coeffs_11)[int(3)]; + float _S3501 = _S3500 * u_6; + float _S3502 = 2.0f * v_6; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3503 = { dpdpuv_2->primal_0 * make_float2 (radial_3) + make_float2 (_S3498 * v_6 + (*coeffs_11)[int(3)] * (r2_6 + _S3499 * u_6), _S3501 * v_6 + (*coeffs_11)[int(2)] * (r2_6 + _S3502 * v_6)), dpdpuv_2->differential_0 * make_float2 (radial_3) + make_float2 (s_diff_r2_3 * _S3496 + s_diff_r2_3 * (*coeffs_11)[int(1)] * r2_6) * dpdpuv_2->primal_0 + make_float2 (s_diff_u_3 * _S3497 * v_6 + s_diff_v_3 * _S3498 + (s_diff_r2_3 + (s_diff_u_3 * 2.0f * u_6 + s_diff_u_3 * _S3499)) * (*coeffs_11)[int(3)], s_diff_u_3 * _S3500 * v_6 + s_diff_v_3 * _S3501 + (s_diff_r2_3 + (s_diff_v_3 * 2.0f * v_6 + s_diff_v_3 * _S3502)) * (*coeffs_11)[int(2)]) }; + return _S3503; +} + +inline __device__ void s_bwd_prop_s_fwd_DistOpenCV_distort_0(DiffPair_0 * dpdpuv_3, FixedArray * coeffs_12, DiffPair_vectorx3Cfloatx2C2x3E_0 * _s_dOut_6) +{ + float u_7 = (*dpdpuv_3).primal_0.primal_0.x; + float s_diff_u_4 = (*dpdpuv_3).primal_0.differential_0.x; + float v_7 = (*dpdpuv_3).primal_0.primal_0.y; + float s_diff_v_4 = (*dpdpuv_3).primal_0.differential_0.y; + float _S3504 = s_diff_u_4 * u_7; + float _S3505 = s_diff_v_4 * v_7; + float r2_7 = u_7 * u_7 + v_7 * v_7; + float s_diff_r2_4 = _S3504 + _S3504 + (_S3505 + _S3505); + float _S3506 = s_diff_r2_4 * (*coeffs_12)[int(1)]; + float _S3507 = (*coeffs_12)[int(0)] + r2_7 * (*coeffs_12)[int(1)]; + float2 _S3508 = make_float2 (1.0f + r2_7 * _S3507); + float _S3509 = 2.0f * (*coeffs_12)[int(2)]; + float _S3510 = _S3509 * u_7; + float _S3511 = 2.0f * u_7; + float _S3512 = 2.0f * (*coeffs_12)[int(3)]; + float _S3513 = _S3512 * u_7; + float _S3514 = 2.0f * v_7; + float _S3515 = (*coeffs_12)[int(2)] * *&((&_s_dOut_6->differential_0)->y); + float _S3516 = (*coeffs_12)[int(2)] * *&((&_s_dOut_6->primal_0)->y); + float _S3517 = (*coeffs_12)[int(3)] * *&((&_s_dOut_6->differential_0)->x); + float _S3518 = (*coeffs_12)[int(3)] * *&((&_s_dOut_6->primal_0)->x); + float2 _S3519 = (*dpdpuv_3).primal_0.primal_0 * _s_dOut_6->differential_0; + float2 _S3520 = (*dpdpuv_3).primal_0.differential_0 * _s_dOut_6->differential_0; + float2 _S3521 = (*dpdpuv_3).primal_0.primal_0 * _s_dOut_6->primal_0; + float _S3522 = _S3520.x + _S3520.y + _S3521.x + _S3521.y; + float _S3523 = _S3519.x + _S3519.y; + float _S3524 = _S3515 + _S3517 + _S3507 * _S3523 + (*coeffs_12)[int(1)] * (r2_7 * _S3523); + float _S3525 = _S3516 + _S3518 + _S3506 * _S3523 + _S3507 * _S3522 + (*coeffs_12)[int(1)] * (s_diff_r2_4 * _S3523 + r2_7 * _S3522); + float _S3526 = _S3524 + _S3524; + float _S3527 = v_7 * _S3525; + float _S3528 = u_7 * _S3525; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3529 = { make_float2 (s_diff_r2_4 * _S3507 + _S3506 * r2_7) * _s_dOut_6->differential_0 + _S3508 * _s_dOut_6->primal_0 + make_float2 (_S3512 * (s_diff_v_4 * *&((&_s_dOut_6->differential_0)->y) + v_7 * *&((&_s_dOut_6->primal_0)->y)) + s_diff_u_4 * 2.0f * _S3517 + _S3511 * _S3518 + 2.0f * (s_diff_u_4 * _S3517 + u_7 * _S3518) + _S3509 * (s_diff_v_4 * *&((&_s_dOut_6->differential_0)->x) + v_7 * *&((&_s_dOut_6->primal_0)->x)) + s_diff_u_4 * _S3526 + _S3528 + _S3528, s_diff_v_4 * 2.0f * _S3515 + _S3514 * _S3516 + 2.0f * (s_diff_v_4 * _S3515 + v_7 * _S3516) + s_diff_u_4 * _S3512 * *&((&_s_dOut_6->differential_0)->y) + _S3513 * *&((&_s_dOut_6->primal_0)->y) + s_diff_u_4 * _S3509 * *&((&_s_dOut_6->differential_0)->x) + _S3510 * *&((&_s_dOut_6->primal_0)->x) + s_diff_v_4 * _S3526 + _S3527 + _S3527), _S3508 * _s_dOut_6->differential_0 + make_float2 (_S3512 * (v_7 * *&((&_s_dOut_6->differential_0)->y)) + _S3511 * _S3517 + 2.0f * (u_7 * _S3517) + _S3509 * (v_7 * *&((&_s_dOut_6->differential_0)->x)) + u_7 * _S3526, _S3514 * _S3515 + 2.0f * (v_7 * _S3515) + _S3513 * *&((&_s_dOut_6->differential_0)->y) + _S3510 * *&((&_s_dOut_6->differential_0)->x) + v_7 * _S3526) }; + dpdpuv_3->primal_0 = (*dpdpuv_3).primal_0; + dpdpuv_3->differential_0 = _S3529; + return; +} + +inline __device__ void s_bwd_prop_DistOpenCV_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_5, FixedArray * coeffs_13, float2 _s_dOut_7) +{ + float u_8 = (*dpuv_5).primal_0.x; + float v_8 = (*dpuv_5).primal_0.y; + float r2_8 = u_8 * u_8 + v_8 * v_8; + float _S3530 = (*coeffs_13)[int(0)] + r2_8 * (*coeffs_13)[int(1)]; + float _S3531 = 2.0f * (*coeffs_13)[int(2)]; + float _S3532 = 2.0f * (*coeffs_13)[int(3)]; + float _S3533 = (*coeffs_13)[int(2)] * _s_dOut_7.y; + float _S3534 = (*coeffs_13)[int(3)] * _s_dOut_7.x; + float2 _S3535 = (*dpuv_5).primal_0 * _s_dOut_7; + float _S3536 = _S3535.x + _S3535.y; + float _S3537 = _S3533 + _S3534 + _S3530 * _S3536 + (*coeffs_13)[int(1)] * (r2_8 * _S3536); + float _S3538 = v_8 * _S3537; + float _S3539 = u_8 * _S3537; + float2 _S3540 = make_float2 (1.0f + r2_8 * _S3530) * _s_dOut_7 + make_float2 (_S3532 * (v_8 * _s_dOut_7.y) + 2.0f * u_8 * _S3534 + 2.0f * (u_8 * _S3534) + _S3531 * (v_8 * _s_dOut_7.x) + _S3539 + _S3539, 2.0f * v_8 * _S3533 + 2.0f * (v_8 * _S3533) + _S3532 * u_8 * _s_dOut_7.y + _S3531 * u_8 * _s_dOut_7.x + _S3538 + _S3538); + dpuv_5->primal_0 = (*dpuv_5).primal_0; + dpuv_5->differential_0 = _S3540; + return; +} + +inline __device__ void projection_3dgs_persp_opencv_vjp(bool antialiased_23, float3 mean_24, float4 quat_23, float3 scale_23, float in_opacity_23, Matrix R_23, float3 t_23, float fx_36, float fy_36, float cx_27, float cy_27, FixedArray dist_coeffs_35, uint image_width_23, uint image_height_23, float2 v_mean2d_1, float v_depth_1, float3 v_conic_1, float v_opacity_1, float3 * v_mean_1, float4 * v_quat_1, float3 * v_scale_1, float * v_in_opacity_1, Matrix * v_R_1, float3 * v_t_1) +{ + float2 _S3541 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3542 = { _S3541, _S3541 }; + s_bwd_prop_DiffProjection3DGS_3dgs_persp_opencv_projection_Intermediates_0 _S3543; + (&_S3543)->_S3491 = _S3542; + (&_S3543)->_S3492 = _S3542; + (&_S3543)->_S3493 = _S3542; + float3 mean_c_23 = s_primal_ctx_mul_0(R_23, mean_24) + t_23; + float2 _S3544 = float2 {mean_c_23.x, mean_c_23.y}; + float2 _S3545 = make_float2 (1.0f, 0.0f); + float _S3546 = mean_c_23.z; + float2 _S3547 = _S3545 * make_float2 (_S3546); + float _S3548 = _S3546 * _S3546; + float2 s_diff_uv_27 = _S3547 / make_float2 (_S3548); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3549; + (&_S3549)->primal_0 = _S3544 / make_float2 (_S3546); + (&_S3549)->differential_0 = s_diff_uv_27; + FixedArray _S3550 = dist_coeffs_35; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3551 = s_primal_ctx_s_fwd_DistOpenCV_distort_0(&_S3549, &_S3550); + (&_S3543)->_S3491 = _S3551; + float2 _S3552 = make_float2 (0.0f, 1.0f); + float2 _S3553 = _S3552 * make_float2 (_S3546); + float2 s_diff_uv_28 = _S3553 / make_float2 (_S3548); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3554; + (&_S3554)->primal_0 = _S3544 / make_float2 (_S3546); + (&_S3554)->differential_0 = s_diff_uv_28; + FixedArray _S3555 = dist_coeffs_35; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3556 = s_primal_ctx_s_fwd_DistOpenCV_distort_0(&_S3554, &_S3555); + (&_S3543)->_S3492 = _S3556; + float2 _S3557 = make_float2 (0.0f, 0.0f); + float2 _S3558 = _S3557 - _S3544; + float2 s_diff_uv_29 = _S3558 / make_float2 (_S3548); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3559; + (&_S3559)->primal_0 = _S3544 / make_float2 (_S3546); + (&_S3559)->differential_0 = s_diff_uv_29; + FixedArray _S3560 = dist_coeffs_35; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3561 = s_primal_ctx_s_fwd_DistOpenCV_distort_0(&_S3559, &_S3560); + (&_S3543)->_S3493 = _S3561; + float _S3562 = - in_opacity_23; + float _S3563 = 1.0f + s_primal_ctx_exp_0(_S3562); + float _S3564 = 1.0f / _S3563; + float _S3565 = _S3563 * _S3563; + float4 _S3566 = normalize_0(quat_23); + float3 _S3567 = s_primal_ctx_exp_1(scale_23); + float _S3568 = _S3566.y; + float x2_23 = _S3568 * _S3568; + float y2_23 = _S3566.z * _S3566.z; + float z2_23 = _S3566.w * _S3566.w; + float xy_23 = _S3566.y * _S3566.z; + float xz_23 = _S3566.y * _S3566.w; + float yz_23 = _S3566.z * _S3566.w; + float wx_23 = _S3566.x * _S3566.y; + float wy_23 = _S3566.x * _S3566.z; + float wz_23 = _S3566.x * _S3566.w; + Matrix _S3569 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_23 + z2_23), 2.0f * (xy_23 + wz_23), 2.0f * (xz_23 - wy_23), 2.0f * (xy_23 - wz_23), 1.0f - 2.0f * (x2_23 + z2_23), 2.0f * (yz_23 + wx_23), 2.0f * (xz_23 + wy_23), 2.0f * (yz_23 - wx_23), 1.0f - 2.0f * (x2_23 + y2_23))); + Matrix S_1 = makeMatrix (_S3567.x, 0.0f, 0.0f, 0.0f, _S3567.y, 0.0f, 0.0f, 0.0f, _S3567.z); + Matrix _S3570 = s_primal_ctx_mul_1(_S3569, S_1); + Matrix _S3571 = transpose_3(_S3570); + Matrix _S3572 = s_primal_ctx_mul_1(_S3570, _S3571); + Matrix _S3573 = s_primal_ctx_mul_1(R_23, _S3572); + Matrix _S3574 = transpose_3(R_23); + Matrix _S3575 = s_primal_ctx_mul_1(_S3573, _S3574); + Matrix J_33 = makeMatrix (0.0f); + float2 _S3576 = make_float2 (_S3546); + float2 _S3577 = make_float2 (_S3548); + float2 _S3578 = make_float2 (_S3548 * _S3548); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3579 = { _S3544 / make_float2 (_S3546), _S3547 / make_float2 (_S3548) }; + float _S3580 = _S3543._S3491.differential_0.x * fx_36; + float _S3581 = _S3543._S3491.differential_0.y * fy_36; + Matrix _S3582 = J_33; + *&(((&_S3582)->rows + (int(0)))->x) = _S3580; + *&(((&_S3582)->rows + (int(1)))->x) = _S3581; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3583 = { _S3544 / make_float2 (_S3546), _S3553 / make_float2 (_S3548) }; + float _S3584 = _S3543._S3492.differential_0.y * fy_36; + *&(((&_S3582)->rows + (int(0)))->y) = _S3543._S3492.differential_0.x * fx_36; + *&(((&_S3582)->rows + (int(1)))->y) = _S3584; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3585 = { _S3544 / make_float2 (_S3546), _S3558 / make_float2 (_S3548) }; + float _S3586 = _S3543._S3493.differential_0.x * fx_36; + float _S3587 = _S3543._S3493.differential_0.y * fy_36; + float _S3588 = float(image_width_23); + float _S3589 = 0.30000001192092896f * (0.5f * _S3588); + float lim_x_pos_13 = _S3588 + _S3589; + float rz_9 = 1.0f / _S3546; + float _S3590 = - _S3589; + float _S3591 = - (_S3590 - cx_27); + float max_Jxz_1 = _S3591 * rz_9; + float _S3592 = - (lim_x_pos_13 - cx_27); + float min_Jxz_1 = _S3592 * rz_9; + float _S3593 = - (_S3590 - cy_27); + float max_Jyz_9 = _S3593 * rz_9; + float _S3594 = - (lim_x_pos_13 - cy_27); + float min_Jyz_9 = _S3594 * rz_9; + *&(((&_S3582)->rows + (int(0)))->z) = s_primal_ctx_clamp_0(_S3586, min_Jxz_1, max_Jxz_1); + *&(((&_S3582)->rows + (int(1)))->z) = s_primal_ctx_clamp_0(_S3587, min_Jyz_9, max_Jyz_9); + Matrix _S3595 = s_primal_ctx_mul_2(_S3582, _S3575); + Matrix _S3596 = transpose_1(_S3582); + Matrix _S3597 = s_primal_ctx_mul_3(_S3595, _S3596); + float eps2d_23; + if(antialiased_23) + { + eps2d_23 = 0.10000000149011612f; + } + else + { + eps2d_23 = 0.30000001192092896f; + } + float _S3598 = _S3597.rows[int(0)].y * _S3597.rows[int(1)].x; + float det_orig_23 = _S3597.rows[int(0)].x * _S3597.rows[int(1)].y - _S3598; + float _S3599 = _S3597.rows[int(0)].x + eps2d_23; + Matrix _S3600 = _S3597; + *&(((&_S3600)->rows + (int(0)))->x) = _S3599; + float _S3601 = _S3597.rows[int(1)].y + eps2d_23; + *&(((&_S3600)->rows + (int(1)))->y) = _S3601; + Matrix _S3602 = _S3600; + Matrix _S3603 = _S3600; + float det_blur_23 = _S3599 * _S3601 - _S3598; + float _S3604 = det_orig_23 / det_blur_23; + float _S3605 = det_blur_23 * det_blur_23; + float _S3606 = (F32_max((0.0f), (_S3604))); + float _S3607 = s_primal_ctx_sqrt_0(_S3606); + float invdet_29 = 1.0f / det_blur_23; + float _S3608 = - _S3597.rows[int(0)].y; + float _S3609 = - _S3597.rows[int(1)].x; + if(antialiased_23) + { + eps2d_23 = _S3564 * _S3607; + } + else + { + eps2d_23 = _S3564; + } + float _S3610 = eps2d_23 / 0.00392156885936856f; + float _S3611 = 2.0f * s_primal_ctx_log_0(_S3610); + float _S3612 = s_primal_ctx_sqrt_0(_S3611); + float _S3613 = _S3602.rows[int(0)].x; + float _S3614 = _S3603.rows[int(1)].y; + float3 campos_2 = - s_primal_ctx_mul_0(_S3574, t_23); + float3 _S3615 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3616; + (&_S3616)->primal_0 = mean_24; + (&_S3616)->differential_0 = _S3615; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3617; + (&_S3617)->primal_0 = scale_23; + (&_S3617)->differential_0 = _S3615; + DiffPair_float_0 _S3618; + (&_S3618)->primal_0 = in_opacity_23; + (&_S3618)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3619; + (&_S3619)->primal_0 = campos_2; + (&_S3619)->differential_0 = _S3615; + s_bwd_prop_view_radius_3dgs_0(&_S3616, &_S3617, &_S3618, &_S3619, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3620 = _S3616; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3621 = _S3617; + DiffPair_float_0 _S3622 = _S3618; + float2 _S3623 = _S3541; + *&((&_S3623)->y) = v_conic_1.z; + float2 _S3624 = _S3541; + *&((&_S3624)->y) = v_conic_1.y; + *&((&_S3624)->x) = v_conic_1.x; + DiffPair_float_0 _S3625; + (&_S3625)->primal_0 = _S3614; + (&_S3625)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3625, 0.0f); + DiffPair_float_0 _S3626; + (&_S3626)->primal_0 = _S3613; + (&_S3626)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3626, 0.0f); + DiffPair_float_0 _S3627; + (&_S3627)->primal_0 = 3.32999992370605469f; + (&_S3627)->differential_0 = 0.0f; + DiffPair_float_0 _S3628; + (&_S3628)->primal_0 = _S3612; + (&_S3628)->differential_0 = 0.0f; + _d_min_0(&_S3627, &_S3628, 0.0f); + DiffPair_float_0 _S3629; + (&_S3629)->primal_0 = _S3611; + (&_S3629)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3629, _S3628.differential_0); + float _S3630 = 2.0f * _S3629.differential_0; + DiffPair_float_0 _S3631; + (&_S3631)->primal_0 = _S3610; + (&_S3631)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S3631, _S3630); + float _S3632 = v_opacity_1 + 254.9999847412109375f * _S3631.differential_0; + Matrix _S3633 = makeMatrix (0.0f); + Matrix _S3634 = _S3633; + _S3634[int(1)] = _S3623; + _S3634[int(0)] = _S3624; + Matrix _S3635 = _S3634; + float2 _S3636 = make_float2 (0.0f, _S3625.differential_0); + float2 _S3637 = make_float2 (_S3626.differential_0, 0.0f); + float _S3638; + if(antialiased_23) + { + float _S3639 = _S3607 * _S3632; + eps2d_23 = _S3564 * _S3632; + _S3638 = _S3639; + } + else + { + eps2d_23 = 0.0f; + _S3638 = _S3632; + } + float _S3640 = invdet_29 * _S3635.rows[int(1)].y; + float _S3641 = - (invdet_29 * _S3635.rows[int(1)].x); + float _S3642 = - (invdet_29 * _S3635.rows[int(0)].y); + float _S3643 = invdet_29 * _S3635.rows[int(0)].x; + float _S3644 = - ((_S3599 * _S3635.rows[int(1)].y + _S3609 * _S3635.rows[int(1)].x + _S3608 * _S3635.rows[int(0)].y + _S3601 * _S3635.rows[int(0)].x) / _S3605); + DiffPair_float_0 _S3645; + (&_S3645)->primal_0 = _S3606; + (&_S3645)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3645, eps2d_23); + DiffPair_float_0 _S3646; + (&_S3646)->primal_0 = 0.0f; + (&_S3646)->differential_0 = 0.0f; + DiffPair_float_0 _S3647; + (&_S3647)->primal_0 = _S3604; + (&_S3647)->differential_0 = 0.0f; + _d_max_0(&_S3646, &_S3647, _S3645.differential_0); + float _S3648 = _S3647.differential_0 / _S3605; + float s_diff_det_orig_T_1 = det_blur_23 * _S3648; + float _S3649 = det_orig_23 * - _S3648 + _S3644; + float _S3650 = - _S3649; + float _S3651 = _S3599 * _S3649; + float _S3652 = _S3601 * _S3649; + Matrix _S3653 = _S3633; + _S3653[int(1)] = _S3636; + _S3653[int(0)] = _S3637; + _S3600 = _S3653; + *&(((&_S3600)->rows + (int(1)))->y) = 0.0f; + float _S3654 = _S3651 + _S3653.rows[int(1)].y + _S3643; + *&(((&_S3600)->rows + (int(0)))->x) = 0.0f; + float _S3655 = _S3652 + _S3653.rows[int(0)].x + _S3640; + float _S3656 = _S3650 + - s_diff_det_orig_T_1; + float _S3657 = _S3597.rows[int(0)].y * _S3656 + _S3641; + float _S3658 = _S3597.rows[int(1)].x * _S3656 + _S3642; + float _S3659 = _S3597.rows[int(1)].y * s_diff_det_orig_T_1; + float _S3660 = _S3654 + _S3597.rows[int(0)].x * s_diff_det_orig_T_1; + float2 _S3661 = _S3541; + *&((&_S3661)->x) = _S3657; + *&((&_S3661)->y) = _S3660; + float _S3662 = _S3655 + _S3659; + float2 _S3663 = _S3541; + *&((&_S3663)->y) = _S3658; + *&((&_S3663)->x) = _S3662; + Matrix _S3664 = _S3633; + _S3664[int(1)] = _S3661; + _S3664[int(0)] = _S3663; + Matrix _S3665 = _S3600 + _S3664; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S3666; + (&_S3666)->primal_0 = _S3595; + (&_S3666)->differential_0 = J_33; + Matrix _S3667 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S3668; + (&_S3668)->primal_0 = _S3596; + (&_S3668)->differential_0 = _S3667; + s_bwd_prop_mul_0(&_S3666, &_S3668, _S3665); + Matrix _S3669 = transpose_2(_S3668.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S3670; + (&_S3670)->primal_0 = _S3582; + (&_S3670)->differential_0 = J_33; + Matrix _S3671 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3672; + (&_S3672)->primal_0 = _S3575; + (&_S3672)->differential_0 = _S3671; + s_bwd_prop_mul_1(&_S3670, &_S3672, _S3666.differential_0); + Matrix _S3673 = _S3669 + _S3670.differential_0; + DiffPair_float_0 _S3674; + (&_S3674)->primal_0 = _S3587; + (&_S3674)->differential_0 = 0.0f; + DiffPair_float_0 _S3675; + (&_S3675)->primal_0 = min_Jyz_9; + (&_S3675)->differential_0 = 0.0f; + DiffPair_float_0 _S3676; + (&_S3676)->primal_0 = max_Jyz_9; + (&_S3676)->differential_0 = 0.0f; + s_bwd_prop_clamp_0(&_S3674, &_S3675, &_S3676, _S3673.rows[int(1)].z); + DiffPair_float_0 _S3677; + (&_S3677)->primal_0 = _S3586; + (&_S3677)->differential_0 = 0.0f; + DiffPair_float_0 _S3678; + (&_S3678)->primal_0 = min_Jxz_1; + (&_S3678)->differential_0 = 0.0f; + DiffPair_float_0 _S3679; + (&_S3679)->primal_0 = max_Jxz_1; + (&_S3679)->differential_0 = 0.0f; + s_bwd_prop_clamp_0(&_S3677, &_S3678, &_S3679, _S3673.rows[int(0)].z); + float _S3680 = - ((_S3594 * _S3675.differential_0 + _S3593 * _S3676.differential_0 + _S3592 * _S3678.differential_0 + _S3591 * _S3679.differential_0) / _S3548); + float2 _S3681 = make_float2 (fx_36 * _S3677.differential_0, fy_36 * _S3674.differential_0); + DiffPair_0 _S3682; + (&_S3682)->primal_0 = _S3585; + (&_S3682)->differential_0 = _S3542; + FixedArray _S3683 = dist_coeffs_35; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3684; + (&_S3684)->primal_0 = _S3557; + (&_S3684)->differential_0 = _S3681; + s_bwd_prop_s_fwd_DistOpenCV_distort_0(&_S3682, &_S3683, &_S3684); + float2 _S3685 = _S3682.differential_0.differential_0 / _S3578; + float2 _S3686 = _S3558 * - _S3685; + float _S3687 = _S3546 * (_S3686.x + _S3686.y); + float2 _S3688 = _S3682.differential_0.primal_0 / _S3577; + float2 _S3689 = _S3544 * - _S3688; + float2 _S3690 = - (_S3577 * _S3685) + _S3576 * _S3688; + float3 _S3691 = make_float3 (_S3690.x, _S3690.y, _S3687 + _S3687 + _S3689.x + _S3689.y); + float2 _S3692 = make_float2 (fx_36 * _S3673.rows[int(0)].y, fy_36 * _S3673.rows[int(1)].y); + DiffPair_0 _S3693; + (&_S3693)->primal_0 = _S3583; + (&_S3693)->differential_0 = _S3542; + FixedArray _S3694 = dist_coeffs_35; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3695; + (&_S3695)->primal_0 = _S3557; + (&_S3695)->differential_0 = _S3692; + s_bwd_prop_s_fwd_DistOpenCV_distort_0(&_S3693, &_S3694, &_S3695); + float2 _S3696 = _S3693.differential_0.differential_0 / _S3578; + float2 _S3697 = _S3553 * - _S3696; + float _S3698 = _S3546 * (_S3697.x + _S3697.y); + float2 _S3699 = _S3552 * (_S3577 * _S3696); + float2 _S3700 = _S3693.differential_0.primal_0 / _S3577; + float2 _S3701 = _S3544 * - _S3700; + float2 _S3702 = _S3576 * _S3700; + float3 _S3703 = make_float3 (_S3702.x, _S3702.y, _S3698 + _S3698 + _S3699.x + _S3699.y + _S3701.x + _S3701.y); + float2 _S3704 = make_float2 (fx_36 * _S3673.rows[int(0)].x, fy_36 * _S3673.rows[int(1)].x); + DiffPair_0 _S3705; + (&_S3705)->primal_0 = _S3579; + (&_S3705)->differential_0 = _S3542; + FixedArray _S3706 = dist_coeffs_35; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3707; + (&_S3707)->primal_0 = _S3557; + (&_S3707)->differential_0 = _S3704; + s_bwd_prop_s_fwd_DistOpenCV_distort_0(&_S3705, &_S3706, &_S3707); + float2 _S3708 = _S3705.differential_0.differential_0 / _S3578; + float2 _S3709 = _S3547 * - _S3708; + float _S3710 = _S3546 * (_S3709.x + _S3709.y); + float2 _S3711 = _S3545 * (_S3577 * _S3708); + float2 _S3712 = _S3705.differential_0.primal_0 / _S3577; + float2 _S3713 = _S3544 * - _S3712; + float2 _S3714 = _S3576 * _S3712; + float3 _S3715 = make_float3 (_S3714.x, _S3714.y, _S3710 + _S3710 + _S3711.x + _S3711.y + _S3713.x + _S3713.y); + float2 _S3716 = make_float2 (fx_36 * v_mean2d_1.x, fy_36 * v_mean2d_1.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3717; + (&_S3717)->primal_0 = _S3544 / make_float2 (_S3546); + (&_S3717)->differential_0 = _S3541; + FixedArray _S3718 = dist_coeffs_35; + s_bwd_prop_DistOpenCV_distort_0(&_S3717, &_S3718, _S3716); + float2 _S3719 = _S3717.differential_0 / _S3577; + float2 _S3720 = _S3544 * - _S3719; + float2 _S3721 = _S3576 * _S3719; + float3 _S3722 = make_float3 (_S3721.x, _S3721.y, _S3720.x + _S3720.y); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3723; + (&_S3723)->primal_0 = _S3573; + (&_S3723)->differential_0 = _S3671; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3724; + (&_S3724)->primal_0 = _S3574; + (&_S3724)->differential_0 = _S3671; + s_bwd_prop_mul_2(&_S3723, &_S3724, _S3672.differential_0); + Matrix _S3725 = transpose_3(_S3724.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3726; + (&_S3726)->primal_0 = R_23; + (&_S3726)->differential_0 = _S3671; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3727; + (&_S3727)->primal_0 = _S3572; + (&_S3727)->differential_0 = _S3671; + s_bwd_prop_mul_2(&_S3726, &_S3727, _S3723.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3728; + (&_S3728)->primal_0 = _S3570; + (&_S3728)->differential_0 = _S3671; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3729; + (&_S3729)->primal_0 = _S3571; + (&_S3729)->differential_0 = _S3671; + s_bwd_prop_mul_2(&_S3728, &_S3729, _S3727.differential_0); + Matrix _S3730 = _S3728.differential_0 + transpose_3(_S3729.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3731; + (&_S3731)->primal_0 = _S3569; + (&_S3731)->differential_0 = _S3671; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3732; + (&_S3732)->primal_0 = S_1; + (&_S3732)->differential_0 = _S3671; + s_bwd_prop_mul_2(&_S3731, &_S3732, _S3730); + Matrix _S3733 = transpose_3(_S3731.differential_0); + float _S3734 = 2.0f * - _S3733.rows[int(2)].z; + float _S3735 = 2.0f * _S3733.rows[int(2)].y; + float _S3736 = 2.0f * _S3733.rows[int(2)].x; + float _S3737 = 2.0f * _S3733.rows[int(1)].z; + float _S3738 = 2.0f * - _S3733.rows[int(1)].y; + float _S3739 = 2.0f * _S3733.rows[int(1)].x; + float _S3740 = 2.0f * _S3733.rows[int(0)].z; + float _S3741 = 2.0f * _S3733.rows[int(0)].y; + float _S3742 = 2.0f * - _S3733.rows[int(0)].x; + float _S3743 = - _S3739 + _S3741; + float _S3744 = _S3736 + - _S3740; + float _S3745 = - _S3735 + _S3737; + float _S3746 = _S3735 + _S3737; + float _S3747 = _S3736 + _S3740; + float _S3748 = _S3739 + _S3741; + float _S3749 = _S3566.w * (_S3738 + _S3742); + float _S3750 = _S3566.z * (_S3734 + _S3742); + float _S3751 = _S3566.y * (_S3734 + _S3738); + float _S3752 = _S3566.x * _S3743 + _S3566.z * _S3746 + _S3566.y * _S3747 + _S3749 + _S3749; + float _S3753 = _S3566.x * _S3744 + _S3566.w * _S3746 + _S3566.y * _S3748 + _S3750 + _S3750; + float _S3754 = _S3566.x * _S3745 + _S3566.w * _S3747 + _S3566.z * _S3748 + _S3751 + _S3751; + float _S3755 = _S3566.w * _S3743 + _S3566.z * _S3744 + _S3566.y * _S3745; + float3 _S3756 = _S3615; + *&((&_S3756)->z) = _S3732.differential_0.rows[int(2)].z; + *&((&_S3756)->y) = _S3732.differential_0.rows[int(1)].y; + *&((&_S3756)->x) = _S3732.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3757; + (&_S3757)->primal_0 = scale_23; + (&_S3757)->differential_0 = _S3615; + s_bwd_prop_exp_1(&_S3757, _S3756); + float4 _S3758 = make_float4 (0.0f); + float4 _S3759 = _S3758; + *&((&_S3759)->w) = _S3752; + *&((&_S3759)->z) = _S3753; + *&((&_S3759)->y) = _S3754; + *&((&_S3759)->x) = _S3755; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S3760; + (&_S3760)->primal_0 = quat_23; + (&_S3760)->differential_0 = _S3758; + s_bwd_normalize_impl_0(&_S3760, _S3759); + float _S3761 = - (_S3638 / _S3565); + DiffPair_float_0 _S3762; + (&_S3762)->primal_0 = _S3562; + (&_S3762)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S3762, _S3761); + float _S3763 = - _S3762.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3764; + (&_S3764)->primal_0 = mean_c_23; + (&_S3764)->differential_0 = _S3615; + s_bwd_length_impl_0(&_S3764, v_depth_1); + float3 _S3765 = _S3691 + _S3703 + _S3715 + _S3722 + _S3764.differential_0 + make_float3 (0.0f, 0.0f, _S3680); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3766; + (&_S3766)->primal_0 = R_23; + (&_S3766)->differential_0 = _S3671; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3767; + (&_S3767)->primal_0 = mean_24; + (&_S3767)->differential_0 = _S3615; + s_bwd_prop_mul_3(&_S3766, &_S3767, _S3765); + Matrix _S3768 = _S3725 + _S3726.differential_0 + _S3766.differential_0; + float _S3769 = _S3763 + _S3622.differential_0; + float3 _S3770 = _S3757.differential_0 + _S3621.differential_0; + *v_mean_1 = *v_mean_1 + (_S3767.differential_0 + _S3620.differential_0); + *v_quat_1 = *v_quat_1 + _S3760.differential_0; + *v_scale_1 = *v_scale_1 + _S3770; + *v_in_opacity_1 = *v_in_opacity_1 + _S3769; + *v_R_1 = *v_R_1 + _S3768; + *v_t_1 = *v_t_1 + _S3765; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgs_persp_prism_projection_Intermediates_0 +{ + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3771; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3772; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3773; +}; + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_primal_ctx_s_fwd_DistThinPrism_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpdpuv_4, FixedArray * coeffs_14) +{ + float u_9 = dpdpuv_4->primal_0.x; + float s_diff_u_5 = dpdpuv_4->differential_0.x; + float v_9 = dpdpuv_4->primal_0.y; + float s_diff_v_5 = dpdpuv_4->differential_0.y; + float _S3774 = s_diff_u_5 * u_9; + float _S3775 = s_diff_v_5 * v_9; + float r2_9 = u_9 * u_9 + v_9 * v_9; + float s_diff_r2_5 = _S3774 + _S3774 + (_S3775 + _S3775); + float _S3776 = (*coeffs_14)[int(2)] + r2_9 * (*coeffs_14)[int(3)]; + float _S3777 = (*coeffs_14)[int(1)] + r2_9 * _S3776; + float _S3778 = (*coeffs_14)[int(0)] + r2_9 * _S3777; + float radial_4 = 1.0f + r2_9 * _S3778; + float _S3779 = 2.0f * (*coeffs_14)[int(4)]; + float _S3780 = _S3779 * u_9; + float _S3781 = 2.0f * u_9; + float _S3782 = 2.0f * (*coeffs_14)[int(5)]; + float _S3783 = _S3782 * u_9; + float _S3784 = 2.0f * v_9; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3785 = { dpdpuv_4->primal_0 * make_float2 (radial_4) + make_float2 (_S3780 * v_9 + (*coeffs_14)[int(5)] * (r2_9 + _S3781 * u_9) + (*coeffs_14)[int(6)] * r2_9, _S3783 * v_9 + (*coeffs_14)[int(4)] * (r2_9 + _S3784 * v_9) + (*coeffs_14)[int(7)] * r2_9), dpdpuv_4->differential_0 * make_float2 (radial_4) + make_float2 (s_diff_r2_5 * _S3778 + (s_diff_r2_5 * _S3777 + (s_diff_r2_5 * _S3776 + s_diff_r2_5 * (*coeffs_14)[int(3)] * r2_9) * r2_9) * r2_9) * dpdpuv_4->primal_0 + make_float2 (s_diff_u_5 * _S3779 * v_9 + s_diff_v_5 * _S3780 + (s_diff_r2_5 + (s_diff_u_5 * 2.0f * u_9 + s_diff_u_5 * _S3781)) * (*coeffs_14)[int(5)] + s_diff_r2_5 * (*coeffs_14)[int(6)], s_diff_u_5 * _S3782 * v_9 + s_diff_v_5 * _S3783 + (s_diff_r2_5 + (s_diff_v_5 * 2.0f * v_9 + s_diff_v_5 * _S3784)) * (*coeffs_14)[int(4)] + s_diff_r2_5 * (*coeffs_14)[int(7)]) }; + return _S3785; +} + +inline __device__ void s_bwd_prop_s_fwd_DistThinPrism_distort_0(DiffPair_0 * dpdpuv_5, FixedArray * coeffs_15, DiffPair_vectorx3Cfloatx2C2x3E_0 * _s_dOut_8) +{ + float u_10 = (*dpdpuv_5).primal_0.primal_0.x; + float s_diff_u_6 = (*dpdpuv_5).primal_0.differential_0.x; + float v_10 = (*dpdpuv_5).primal_0.primal_0.y; + float s_diff_v_6 = (*dpdpuv_5).primal_0.differential_0.y; + float _S3786 = s_diff_u_6 * u_10; + float _S3787 = s_diff_v_6 * v_10; + float r2_10 = u_10 * u_10 + v_10 * v_10; + float s_diff_r2_6 = _S3786 + _S3786 + (_S3787 + _S3787); + float _S3788 = s_diff_r2_6 * (*coeffs_15)[int(3)]; + float _S3789 = (*coeffs_15)[int(2)] + r2_10 * (*coeffs_15)[int(3)]; + float _S3790 = s_diff_r2_6 * _S3789 + _S3788 * r2_10; + float _S3791 = (*coeffs_15)[int(1)] + r2_10 * _S3789; + float _S3792 = s_diff_r2_6 * _S3791 + _S3790 * r2_10; + float _S3793 = (*coeffs_15)[int(0)] + r2_10 * _S3791; + float2 _S3794 = make_float2 (1.0f + r2_10 * _S3793); + float _S3795 = 2.0f * (*coeffs_15)[int(4)]; + float _S3796 = _S3795 * u_10; + float _S3797 = 2.0f * u_10; + float _S3798 = 2.0f * (*coeffs_15)[int(5)]; + float _S3799 = _S3798 * u_10; + float _S3800 = 2.0f * v_10; + float _S3801 = (*coeffs_15)[int(4)] * *&((&_s_dOut_8->differential_0)->y); + float _S3802 = (*coeffs_15)[int(4)] * *&((&_s_dOut_8->primal_0)->y); + float _S3803 = (*coeffs_15)[int(5)] * *&((&_s_dOut_8->differential_0)->x); + float _S3804 = (*coeffs_15)[int(5)] * *&((&_s_dOut_8->primal_0)->x); + float2 _S3805 = (*dpdpuv_5).primal_0.primal_0 * _s_dOut_8->differential_0; + float2 _S3806 = (*dpdpuv_5).primal_0.differential_0 * _s_dOut_8->differential_0; + float2 _S3807 = (*dpdpuv_5).primal_0.primal_0 * _s_dOut_8->primal_0; + float _S3808 = _S3806.x + _S3806.y + _S3807.x + _S3807.y; + float _S3809 = _S3805.x + _S3805.y; + float _S3810 = r2_10 * _S3809; + float _S3811 = s_diff_r2_6 * _S3809 + r2_10 * _S3808; + float _S3812 = r2_10 * _S3810; + float _S3813 = s_diff_r2_6 * _S3810 + r2_10 * _S3811; + float _S3814 = (*coeffs_15)[int(7)] * *&((&_s_dOut_8->differential_0)->y) + _S3801 + (*coeffs_15)[int(6)] * *&((&_s_dOut_8->differential_0)->x) + _S3803 + _S3793 * _S3809 + _S3791 * _S3810 + _S3789 * _S3812 + (*coeffs_15)[int(3)] * (r2_10 * _S3812); + float _S3815 = (*coeffs_15)[int(7)] * *&((&_s_dOut_8->primal_0)->y) + _S3802 + (*coeffs_15)[int(6)] * *&((&_s_dOut_8->primal_0)->x) + _S3804 + _S3792 * _S3809 + _S3793 * _S3808 + _S3790 * _S3810 + _S3791 * _S3811 + _S3788 * _S3812 + _S3789 * _S3813 + (*coeffs_15)[int(3)] * (s_diff_r2_6 * _S3812 + r2_10 * _S3813); + float _S3816 = _S3814 + _S3814; + float _S3817 = v_10 * _S3815; + float _S3818 = u_10 * _S3815; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3819 = { make_float2 (s_diff_r2_6 * _S3793 + _S3792 * r2_10) * _s_dOut_8->differential_0 + _S3794 * _s_dOut_8->primal_0 + make_float2 (_S3798 * (s_diff_v_6 * *&((&_s_dOut_8->differential_0)->y) + v_10 * *&((&_s_dOut_8->primal_0)->y)) + s_diff_u_6 * 2.0f * _S3803 + _S3797 * _S3804 + 2.0f * (s_diff_u_6 * _S3803 + u_10 * _S3804) + _S3795 * (s_diff_v_6 * *&((&_s_dOut_8->differential_0)->x) + v_10 * *&((&_s_dOut_8->primal_0)->x)) + s_diff_u_6 * _S3816 + _S3818 + _S3818, s_diff_v_6 * 2.0f * _S3801 + _S3800 * _S3802 + 2.0f * (s_diff_v_6 * _S3801 + v_10 * _S3802) + s_diff_u_6 * _S3798 * *&((&_s_dOut_8->differential_0)->y) + _S3799 * *&((&_s_dOut_8->primal_0)->y) + s_diff_u_6 * _S3795 * *&((&_s_dOut_8->differential_0)->x) + _S3796 * *&((&_s_dOut_8->primal_0)->x) + s_diff_v_6 * _S3816 + _S3817 + _S3817), _S3794 * _s_dOut_8->differential_0 + make_float2 (_S3798 * (v_10 * *&((&_s_dOut_8->differential_0)->y)) + _S3797 * _S3803 + 2.0f * (u_10 * _S3803) + _S3795 * (v_10 * *&((&_s_dOut_8->differential_0)->x)) + u_10 * _S3816, _S3800 * _S3801 + 2.0f * (v_10 * _S3801) + _S3799 * *&((&_s_dOut_8->differential_0)->y) + _S3796 * *&((&_s_dOut_8->differential_0)->x) + v_10 * _S3816) }; + dpdpuv_5->primal_0 = (*dpdpuv_5).primal_0; + dpdpuv_5->differential_0 = _S3819; + return; +} + +inline __device__ void s_bwd_prop_DistThinPrism_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_6, FixedArray * coeffs_16, float2 _s_dOut_9) +{ + float u_11 = (*dpuv_6).primal_0.x; + float v_11 = (*dpuv_6).primal_0.y; + float r2_11 = u_11 * u_11 + v_11 * v_11; + float _S3820 = (*coeffs_16)[int(2)] + r2_11 * (*coeffs_16)[int(3)]; + float _S3821 = (*coeffs_16)[int(1)] + r2_11 * _S3820; + float _S3822 = (*coeffs_16)[int(0)] + r2_11 * _S3821; + float _S3823 = 2.0f * (*coeffs_16)[int(4)]; + float _S3824 = 2.0f * (*coeffs_16)[int(5)]; + float _S3825 = (*coeffs_16)[int(4)] * _s_dOut_9.y; + float _S3826 = (*coeffs_16)[int(5)] * _s_dOut_9.x; + float2 _S3827 = (*dpuv_6).primal_0 * _s_dOut_9; + float _S3828 = _S3827.x + _S3827.y; + float _S3829 = r2_11 * _S3828; + float _S3830 = r2_11 * _S3829; + float _S3831 = (*coeffs_16)[int(7)] * _s_dOut_9.y + _S3825 + (*coeffs_16)[int(6)] * _s_dOut_9.x + _S3826 + _S3822 * _S3828 + _S3821 * _S3829 + _S3820 * _S3830 + (*coeffs_16)[int(3)] * (r2_11 * _S3830); + float _S3832 = v_11 * _S3831; + float _S3833 = u_11 * _S3831; + float2 _S3834 = make_float2 (1.0f + r2_11 * _S3822) * _s_dOut_9 + make_float2 (_S3824 * (v_11 * _s_dOut_9.y) + 2.0f * u_11 * _S3826 + 2.0f * (u_11 * _S3826) + _S3823 * (v_11 * _s_dOut_9.x) + _S3833 + _S3833, 2.0f * v_11 * _S3825 + 2.0f * (v_11 * _S3825) + _S3824 * u_11 * _s_dOut_9.y + _S3823 * u_11 * _s_dOut_9.x + _S3832 + _S3832); + dpuv_6->primal_0 = (*dpuv_6).primal_0; + dpuv_6->differential_0 = _S3834; + return; +} + +inline __device__ void projection_3dgs_persp_prism_vjp(bool antialiased_24, float3 mean_25, float4 quat_24, float3 scale_24, float in_opacity_24, Matrix R_24, float3 t_24, float fx_37, float fy_37, float cx_28, float cy_28, FixedArray dist_coeffs_36, uint image_width_24, uint image_height_24, float2 v_mean2d_2, float v_depth_2, float3 v_conic_2, float v_opacity_2, float3 * v_mean_2, float4 * v_quat_2, float3 * v_scale_2, float * v_in_opacity_2, Matrix * v_R_2, float3 * v_t_2) +{ + float2 _S3835 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3836 = { _S3835, _S3835 }; + s_bwd_prop_DiffProjection3DGS_3dgs_persp_prism_projection_Intermediates_0 _S3837; + (&_S3837)->_S3771 = _S3836; + (&_S3837)->_S3772 = _S3836; + (&_S3837)->_S3773 = _S3836; + float3 mean_c_24 = s_primal_ctx_mul_0(R_24, mean_25) + t_24; + float2 _S3838 = float2 {mean_c_24.x, mean_c_24.y}; + float2 _S3839 = make_float2 (1.0f, 0.0f); + float _S3840 = mean_c_24.z; + float2 _S3841 = _S3839 * make_float2 (_S3840); + float _S3842 = _S3840 * _S3840; + float2 s_diff_uv_30 = _S3841 / make_float2 (_S3842); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3843; + (&_S3843)->primal_0 = _S3838 / make_float2 (_S3840); + (&_S3843)->differential_0 = s_diff_uv_30; + FixedArray _S3844 = dist_coeffs_36; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3845 = s_primal_ctx_s_fwd_DistThinPrism_distort_0(&_S3843, &_S3844); + (&_S3837)->_S3771 = _S3845; + float2 _S3846 = make_float2 (0.0f, 1.0f); + float2 _S3847 = _S3846 * make_float2 (_S3840); + float2 s_diff_uv_31 = _S3847 / make_float2 (_S3842); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3848; + (&_S3848)->primal_0 = _S3838 / make_float2 (_S3840); + (&_S3848)->differential_0 = s_diff_uv_31; + FixedArray _S3849 = dist_coeffs_36; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3850 = s_primal_ctx_s_fwd_DistThinPrism_distort_0(&_S3848, &_S3849); + (&_S3837)->_S3772 = _S3850; + float2 _S3851 = make_float2 (0.0f, 0.0f); + float2 _S3852 = _S3851 - _S3838; + float2 s_diff_uv_32 = _S3852 / make_float2 (_S3842); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3853; + (&_S3853)->primal_0 = _S3838 / make_float2 (_S3840); + (&_S3853)->differential_0 = s_diff_uv_32; + FixedArray _S3854 = dist_coeffs_36; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3855 = s_primal_ctx_s_fwd_DistThinPrism_distort_0(&_S3853, &_S3854); + (&_S3837)->_S3773 = _S3855; + float _S3856 = - in_opacity_24; + float _S3857 = 1.0f + s_primal_ctx_exp_0(_S3856); + float _S3858 = 1.0f / _S3857; + float _S3859 = _S3857 * _S3857; + float4 _S3860 = normalize_0(quat_24); + float3 _S3861 = s_primal_ctx_exp_1(scale_24); + float _S3862 = _S3860.y; + float x2_24 = _S3862 * _S3862; + float y2_24 = _S3860.z * _S3860.z; + float z2_24 = _S3860.w * _S3860.w; + float xy_24 = _S3860.y * _S3860.z; + float xz_24 = _S3860.y * _S3860.w; + float yz_24 = _S3860.z * _S3860.w; + float wx_24 = _S3860.x * _S3860.y; + float wy_24 = _S3860.x * _S3860.z; + float wz_24 = _S3860.x * _S3860.w; + Matrix _S3863 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_24 + z2_24), 2.0f * (xy_24 + wz_24), 2.0f * (xz_24 - wy_24), 2.0f * (xy_24 - wz_24), 1.0f - 2.0f * (x2_24 + z2_24), 2.0f * (yz_24 + wx_24), 2.0f * (xz_24 + wy_24), 2.0f * (yz_24 - wx_24), 1.0f - 2.0f * (x2_24 + y2_24))); + Matrix S_2 = makeMatrix (_S3861.x, 0.0f, 0.0f, 0.0f, _S3861.y, 0.0f, 0.0f, 0.0f, _S3861.z); + Matrix _S3864 = s_primal_ctx_mul_1(_S3863, S_2); + Matrix _S3865 = transpose_3(_S3864); + Matrix _S3866 = s_primal_ctx_mul_1(_S3864, _S3865); + Matrix _S3867 = s_primal_ctx_mul_1(R_24, _S3866); + Matrix _S3868 = transpose_3(R_24); + Matrix _S3869 = s_primal_ctx_mul_1(_S3867, _S3868); + Matrix J_34 = makeMatrix (0.0f); + float2 _S3870 = make_float2 (_S3840); + float2 _S3871 = make_float2 (_S3842); + float2 _S3872 = make_float2 (_S3842 * _S3842); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3873 = { _S3838 / make_float2 (_S3840), _S3841 / make_float2 (_S3842) }; + float _S3874 = _S3837._S3771.differential_0.x * fx_37; + float _S3875 = _S3837._S3771.differential_0.y * fy_37; + Matrix _S3876 = J_34; + *&(((&_S3876)->rows + (int(0)))->x) = _S3874; + *&(((&_S3876)->rows + (int(1)))->x) = _S3875; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3877 = { _S3838 / make_float2 (_S3840), _S3847 / make_float2 (_S3842) }; + float _S3878 = _S3837._S3772.differential_0.y * fy_37; + *&(((&_S3876)->rows + (int(0)))->y) = _S3837._S3772.differential_0.x * fx_37; + *&(((&_S3876)->rows + (int(1)))->y) = _S3878; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3879 = { _S3838 / make_float2 (_S3840), _S3852 / make_float2 (_S3842) }; + float _S3880 = _S3837._S3773.differential_0.x * fx_37; + float _S3881 = _S3837._S3773.differential_0.y * fy_37; + float _S3882 = float(image_width_24); + float _S3883 = 0.30000001192092896f * (0.5f * _S3882); + float lim_x_pos_14 = _S3882 + _S3883; + float rz_10 = 1.0f / _S3840; + float _S3884 = - _S3883; + float _S3885 = - (_S3884 - cx_28); + float max_Jxz_2 = _S3885 * rz_10; + float _S3886 = - (lim_x_pos_14 - cx_28); + float min_Jxz_2 = _S3886 * rz_10; + float _S3887 = - (_S3884 - cy_28); + float max_Jyz_10 = _S3887 * rz_10; + float _S3888 = - (lim_x_pos_14 - cy_28); + float min_Jyz_10 = _S3888 * rz_10; + *&(((&_S3876)->rows + (int(0)))->z) = s_primal_ctx_clamp_0(_S3880, min_Jxz_2, max_Jxz_2); + *&(((&_S3876)->rows + (int(1)))->z) = s_primal_ctx_clamp_0(_S3881, min_Jyz_10, max_Jyz_10); + Matrix _S3889 = s_primal_ctx_mul_2(_S3876, _S3869); + Matrix _S3890 = transpose_1(_S3876); + Matrix _S3891 = s_primal_ctx_mul_3(_S3889, _S3890); + float eps2d_24; + if(antialiased_24) + { + eps2d_24 = 0.10000000149011612f; + } + else + { + eps2d_24 = 0.30000001192092896f; + } + float _S3892 = _S3891.rows[int(0)].y * _S3891.rows[int(1)].x; + float det_orig_24 = _S3891.rows[int(0)].x * _S3891.rows[int(1)].y - _S3892; + float _S3893 = _S3891.rows[int(0)].x + eps2d_24; + Matrix _S3894 = _S3891; + *&(((&_S3894)->rows + (int(0)))->x) = _S3893; + float _S3895 = _S3891.rows[int(1)].y + eps2d_24; + *&(((&_S3894)->rows + (int(1)))->y) = _S3895; + Matrix _S3896 = _S3894; + Matrix _S3897 = _S3894; + float det_blur_24 = _S3893 * _S3895 - _S3892; + float _S3898 = det_orig_24 / det_blur_24; + float _S3899 = det_blur_24 * det_blur_24; + float _S3900 = (F32_max((0.0f), (_S3898))); + float _S3901 = s_primal_ctx_sqrt_0(_S3900); + float invdet_30 = 1.0f / det_blur_24; + float _S3902 = - _S3891.rows[int(0)].y; + float _S3903 = - _S3891.rows[int(1)].x; + if(antialiased_24) + { + eps2d_24 = _S3858 * _S3901; + } + else + { + eps2d_24 = _S3858; + } + float _S3904 = eps2d_24 / 0.00392156885936856f; + float _S3905 = 2.0f * s_primal_ctx_log_0(_S3904); + float _S3906 = s_primal_ctx_sqrt_0(_S3905); + float _S3907 = _S3896.rows[int(0)].x; + float _S3908 = _S3897.rows[int(1)].y; + float3 campos_3 = - s_primal_ctx_mul_0(_S3868, t_24); + float3 _S3909 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3910; + (&_S3910)->primal_0 = mean_25; + (&_S3910)->differential_0 = _S3909; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3911; + (&_S3911)->primal_0 = scale_24; + (&_S3911)->differential_0 = _S3909; + DiffPair_float_0 _S3912; + (&_S3912)->primal_0 = in_opacity_24; + (&_S3912)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3913; + (&_S3913)->primal_0 = campos_3; + (&_S3913)->differential_0 = _S3909; + s_bwd_prop_view_radius_3dgs_0(&_S3910, &_S3911, &_S3912, &_S3913, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3914 = _S3910; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S3915 = _S3911; + DiffPair_float_0 _S3916 = _S3912; + float2 _S3917 = _S3835; + *&((&_S3917)->y) = v_conic_2.z; + float2 _S3918 = _S3835; + *&((&_S3918)->y) = v_conic_2.y; + *&((&_S3918)->x) = v_conic_2.x; + DiffPair_float_0 _S3919; + (&_S3919)->primal_0 = _S3908; + (&_S3919)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3919, 0.0f); + DiffPair_float_0 _S3920; + (&_S3920)->primal_0 = _S3907; + (&_S3920)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3920, 0.0f); + DiffPair_float_0 _S3921; + (&_S3921)->primal_0 = 3.32999992370605469f; + (&_S3921)->differential_0 = 0.0f; + DiffPair_float_0 _S3922; + (&_S3922)->primal_0 = _S3906; + (&_S3922)->differential_0 = 0.0f; + _d_min_0(&_S3921, &_S3922, 0.0f); + DiffPair_float_0 _S3923; + (&_S3923)->primal_0 = _S3905; + (&_S3923)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3923, _S3922.differential_0); + float _S3924 = 2.0f * _S3923.differential_0; + DiffPair_float_0 _S3925; + (&_S3925)->primal_0 = _S3904; + (&_S3925)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S3925, _S3924); + float _S3926 = v_opacity_2 + 254.9999847412109375f * _S3925.differential_0; + Matrix _S3927 = makeMatrix (0.0f); + Matrix _S3928 = _S3927; + _S3928[int(1)] = _S3917; + _S3928[int(0)] = _S3918; + Matrix _S3929 = _S3928; + float2 _S3930 = make_float2 (0.0f, _S3919.differential_0); + float2 _S3931 = make_float2 (_S3920.differential_0, 0.0f); + float _S3932; + if(antialiased_24) + { + float _S3933 = _S3901 * _S3926; + eps2d_24 = _S3858 * _S3926; + _S3932 = _S3933; + } + else + { + eps2d_24 = 0.0f; + _S3932 = _S3926; + } + float _S3934 = invdet_30 * _S3929.rows[int(1)].y; + float _S3935 = - (invdet_30 * _S3929.rows[int(1)].x); + float _S3936 = - (invdet_30 * _S3929.rows[int(0)].y); + float _S3937 = invdet_30 * _S3929.rows[int(0)].x; + float _S3938 = - ((_S3893 * _S3929.rows[int(1)].y + _S3903 * _S3929.rows[int(1)].x + _S3902 * _S3929.rows[int(0)].y + _S3895 * _S3929.rows[int(0)].x) / _S3899); + DiffPair_float_0 _S3939; + (&_S3939)->primal_0 = _S3900; + (&_S3939)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S3939, eps2d_24); + DiffPair_float_0 _S3940; + (&_S3940)->primal_0 = 0.0f; + (&_S3940)->differential_0 = 0.0f; + DiffPair_float_0 _S3941; + (&_S3941)->primal_0 = _S3898; + (&_S3941)->differential_0 = 0.0f; + _d_max_0(&_S3940, &_S3941, _S3939.differential_0); + float _S3942 = _S3941.differential_0 / _S3899; + float s_diff_det_orig_T_2 = det_blur_24 * _S3942; + float _S3943 = det_orig_24 * - _S3942 + _S3938; + float _S3944 = - _S3943; + float _S3945 = _S3893 * _S3943; + float _S3946 = _S3895 * _S3943; + Matrix _S3947 = _S3927; + _S3947[int(1)] = _S3930; + _S3947[int(0)] = _S3931; + _S3894 = _S3947; + *&(((&_S3894)->rows + (int(1)))->y) = 0.0f; + float _S3948 = _S3945 + _S3947.rows[int(1)].y + _S3937; + *&(((&_S3894)->rows + (int(0)))->x) = 0.0f; + float _S3949 = _S3946 + _S3947.rows[int(0)].x + _S3934; + float _S3950 = _S3944 + - s_diff_det_orig_T_2; + float _S3951 = _S3891.rows[int(0)].y * _S3950 + _S3935; + float _S3952 = _S3891.rows[int(1)].x * _S3950 + _S3936; + float _S3953 = _S3891.rows[int(1)].y * s_diff_det_orig_T_2; + float _S3954 = _S3948 + _S3891.rows[int(0)].x * s_diff_det_orig_T_2; + float2 _S3955 = _S3835; + *&((&_S3955)->x) = _S3951; + *&((&_S3955)->y) = _S3954; + float _S3956 = _S3949 + _S3953; + float2 _S3957 = _S3835; + *&((&_S3957)->y) = _S3952; + *&((&_S3957)->x) = _S3956; + Matrix _S3958 = _S3927; + _S3958[int(1)] = _S3955; + _S3958[int(0)] = _S3957; + Matrix _S3959 = _S3894 + _S3958; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S3960; + (&_S3960)->primal_0 = _S3889; + (&_S3960)->differential_0 = J_34; + Matrix _S3961 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S3962; + (&_S3962)->primal_0 = _S3890; + (&_S3962)->differential_0 = _S3961; + s_bwd_prop_mul_0(&_S3960, &_S3962, _S3959); + Matrix _S3963 = transpose_2(_S3962.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S3964; + (&_S3964)->primal_0 = _S3876; + (&_S3964)->differential_0 = J_34; + Matrix _S3965 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3966; + (&_S3966)->primal_0 = _S3869; + (&_S3966)->differential_0 = _S3965; + s_bwd_prop_mul_1(&_S3964, &_S3966, _S3960.differential_0); + Matrix _S3967 = _S3963 + _S3964.differential_0; + DiffPair_float_0 _S3968; + (&_S3968)->primal_0 = _S3881; + (&_S3968)->differential_0 = 0.0f; + DiffPair_float_0 _S3969; + (&_S3969)->primal_0 = min_Jyz_10; + (&_S3969)->differential_0 = 0.0f; + DiffPair_float_0 _S3970; + (&_S3970)->primal_0 = max_Jyz_10; + (&_S3970)->differential_0 = 0.0f; + s_bwd_prop_clamp_0(&_S3968, &_S3969, &_S3970, _S3967.rows[int(1)].z); + DiffPair_float_0 _S3971; + (&_S3971)->primal_0 = _S3880; + (&_S3971)->differential_0 = 0.0f; + DiffPair_float_0 _S3972; + (&_S3972)->primal_0 = min_Jxz_2; + (&_S3972)->differential_0 = 0.0f; + DiffPair_float_0 _S3973; + (&_S3973)->primal_0 = max_Jxz_2; + (&_S3973)->differential_0 = 0.0f; + s_bwd_prop_clamp_0(&_S3971, &_S3972, &_S3973, _S3967.rows[int(0)].z); + float _S3974 = - ((_S3888 * _S3969.differential_0 + _S3887 * _S3970.differential_0 + _S3886 * _S3972.differential_0 + _S3885 * _S3973.differential_0) / _S3842); + float2 _S3975 = make_float2 (fx_37 * _S3971.differential_0, fy_37 * _S3968.differential_0); + DiffPair_0 _S3976; + (&_S3976)->primal_0 = _S3879; + (&_S3976)->differential_0 = _S3836; + FixedArray _S3977 = dist_coeffs_36; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3978; + (&_S3978)->primal_0 = _S3851; + (&_S3978)->differential_0 = _S3975; + s_bwd_prop_s_fwd_DistThinPrism_distort_0(&_S3976, &_S3977, &_S3978); + float2 _S3979 = _S3976.differential_0.differential_0 / _S3872; + float2 _S3980 = _S3852 * - _S3979; + float _S3981 = _S3840 * (_S3980.x + _S3980.y); + float2 _S3982 = _S3976.differential_0.primal_0 / _S3871; + float2 _S3983 = _S3838 * - _S3982; + float2 _S3984 = - (_S3871 * _S3979) + _S3870 * _S3982; + float3 _S3985 = make_float3 (_S3984.x, _S3984.y, _S3981 + _S3981 + _S3983.x + _S3983.y); + float2 _S3986 = make_float2 (fx_37 * _S3967.rows[int(0)].y, fy_37 * _S3967.rows[int(1)].y); + DiffPair_0 _S3987; + (&_S3987)->primal_0 = _S3877; + (&_S3987)->differential_0 = _S3836; + FixedArray _S3988 = dist_coeffs_36; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S3989; + (&_S3989)->primal_0 = _S3851; + (&_S3989)->differential_0 = _S3986; + s_bwd_prop_s_fwd_DistThinPrism_distort_0(&_S3987, &_S3988, &_S3989); + float2 _S3990 = _S3987.differential_0.differential_0 / _S3872; + float2 _S3991 = _S3847 * - _S3990; + float _S3992 = _S3840 * (_S3991.x + _S3991.y); + float2 _S3993 = _S3846 * (_S3871 * _S3990); + float2 _S3994 = _S3987.differential_0.primal_0 / _S3871; + float2 _S3995 = _S3838 * - _S3994; + float2 _S3996 = _S3870 * _S3994; + float3 _S3997 = make_float3 (_S3996.x, _S3996.y, _S3992 + _S3992 + _S3993.x + _S3993.y + _S3995.x + _S3995.y); + float2 _S3998 = make_float2 (fx_37 * _S3967.rows[int(0)].x, fy_37 * _S3967.rows[int(1)].x); + DiffPair_0 _S3999; + (&_S3999)->primal_0 = _S3873; + (&_S3999)->differential_0 = _S3836; + FixedArray _S4000 = dist_coeffs_36; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4001; + (&_S4001)->primal_0 = _S3851; + (&_S4001)->differential_0 = _S3998; + s_bwd_prop_s_fwd_DistThinPrism_distort_0(&_S3999, &_S4000, &_S4001); + float2 _S4002 = _S3999.differential_0.differential_0 / _S3872; + float2 _S4003 = _S3841 * - _S4002; + float _S4004 = _S3840 * (_S4003.x + _S4003.y); + float2 _S4005 = _S3839 * (_S3871 * _S4002); + float2 _S4006 = _S3999.differential_0.primal_0 / _S3871; + float2 _S4007 = _S3838 * - _S4006; + float2 _S4008 = _S3870 * _S4006; + float3 _S4009 = make_float3 (_S4008.x, _S4008.y, _S4004 + _S4004 + _S4005.x + _S4005.y + _S4007.x + _S4007.y); + float2 _S4010 = make_float2 (fx_37 * v_mean2d_2.x, fy_37 * v_mean2d_2.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4011; + (&_S4011)->primal_0 = _S3838 / make_float2 (_S3840); + (&_S4011)->differential_0 = _S3835; + FixedArray _S4012 = dist_coeffs_36; + s_bwd_prop_DistThinPrism_distort_0(&_S4011, &_S4012, _S4010); + float2 _S4013 = _S4011.differential_0 / _S3871; + float2 _S4014 = _S3838 * - _S4013; + float2 _S4015 = _S3870 * _S4013; + float3 _S4016 = make_float3 (_S4015.x, _S4015.y, _S4014.x + _S4014.y); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4017; + (&_S4017)->primal_0 = _S3867; + (&_S4017)->differential_0 = _S3965; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4018; + (&_S4018)->primal_0 = _S3868; + (&_S4018)->differential_0 = _S3965; + s_bwd_prop_mul_2(&_S4017, &_S4018, _S3966.differential_0); + Matrix _S4019 = transpose_3(_S4018.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4020; + (&_S4020)->primal_0 = R_24; + (&_S4020)->differential_0 = _S3965; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4021; + (&_S4021)->primal_0 = _S3866; + (&_S4021)->differential_0 = _S3965; + s_bwd_prop_mul_2(&_S4020, &_S4021, _S4017.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4022; + (&_S4022)->primal_0 = _S3864; + (&_S4022)->differential_0 = _S3965; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4023; + (&_S4023)->primal_0 = _S3865; + (&_S4023)->differential_0 = _S3965; + s_bwd_prop_mul_2(&_S4022, &_S4023, _S4021.differential_0); + Matrix _S4024 = _S4022.differential_0 + transpose_3(_S4023.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4025; + (&_S4025)->primal_0 = _S3863; + (&_S4025)->differential_0 = _S3965; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4026; + (&_S4026)->primal_0 = S_2; + (&_S4026)->differential_0 = _S3965; + s_bwd_prop_mul_2(&_S4025, &_S4026, _S4024); + Matrix _S4027 = transpose_3(_S4025.differential_0); + float _S4028 = 2.0f * - _S4027.rows[int(2)].z; + float _S4029 = 2.0f * _S4027.rows[int(2)].y; + float _S4030 = 2.0f * _S4027.rows[int(2)].x; + float _S4031 = 2.0f * _S4027.rows[int(1)].z; + float _S4032 = 2.0f * - _S4027.rows[int(1)].y; + float _S4033 = 2.0f * _S4027.rows[int(1)].x; + float _S4034 = 2.0f * _S4027.rows[int(0)].z; + float _S4035 = 2.0f * _S4027.rows[int(0)].y; + float _S4036 = 2.0f * - _S4027.rows[int(0)].x; + float _S4037 = - _S4033 + _S4035; + float _S4038 = _S4030 + - _S4034; + float _S4039 = - _S4029 + _S4031; + float _S4040 = _S4029 + _S4031; + float _S4041 = _S4030 + _S4034; + float _S4042 = _S4033 + _S4035; + float _S4043 = _S3860.w * (_S4032 + _S4036); + float _S4044 = _S3860.z * (_S4028 + _S4036); + float _S4045 = _S3860.y * (_S4028 + _S4032); + float _S4046 = _S3860.x * _S4037 + _S3860.z * _S4040 + _S3860.y * _S4041 + _S4043 + _S4043; + float _S4047 = _S3860.x * _S4038 + _S3860.w * _S4040 + _S3860.y * _S4042 + _S4044 + _S4044; + float _S4048 = _S3860.x * _S4039 + _S3860.w * _S4041 + _S3860.z * _S4042 + _S4045 + _S4045; + float _S4049 = _S3860.w * _S4037 + _S3860.z * _S4038 + _S3860.y * _S4039; + float3 _S4050 = _S3909; + *&((&_S4050)->z) = _S4026.differential_0.rows[int(2)].z; + *&((&_S4050)->y) = _S4026.differential_0.rows[int(1)].y; + *&((&_S4050)->x) = _S4026.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4051; + (&_S4051)->primal_0 = scale_24; + (&_S4051)->differential_0 = _S3909; + s_bwd_prop_exp_1(&_S4051, _S4050); + float4 _S4052 = make_float4 (0.0f); + float4 _S4053 = _S4052; + *&((&_S4053)->w) = _S4046; + *&((&_S4053)->z) = _S4047; + *&((&_S4053)->y) = _S4048; + *&((&_S4053)->x) = _S4049; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S4054; + (&_S4054)->primal_0 = quat_24; + (&_S4054)->differential_0 = _S4052; + s_bwd_normalize_impl_0(&_S4054, _S4053); + float _S4055 = - (_S3932 / _S3859); + DiffPair_float_0 _S4056; + (&_S4056)->primal_0 = _S3856; + (&_S4056)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S4056, _S4055); + float _S4057 = - _S4056.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4058; + (&_S4058)->primal_0 = mean_c_24; + (&_S4058)->differential_0 = _S3909; + s_bwd_length_impl_0(&_S4058, v_depth_2); + float3 _S4059 = _S3985 + _S3997 + _S4009 + _S4016 + _S4058.differential_0 + make_float3 (0.0f, 0.0f, _S3974); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4060; + (&_S4060)->primal_0 = R_24; + (&_S4060)->differential_0 = _S3965; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4061; + (&_S4061)->primal_0 = mean_25; + (&_S4061)->differential_0 = _S3909; + s_bwd_prop_mul_3(&_S4060, &_S4061, _S4059); + Matrix _S4062 = _S4019 + _S4020.differential_0 + _S4060.differential_0; + float _S4063 = _S4057 + _S3916.differential_0; + float3 _S4064 = _S4051.differential_0 + _S3915.differential_0; + *v_mean_2 = *v_mean_2 + (_S4061.differential_0 + _S3914.differential_0); + *v_quat_2 = *v_quat_2 + _S4054.differential_0; + *v_scale_2 = *v_scale_2 + _S4064; + *v_in_opacity_2 = *v_in_opacity_2 + _S4063; + *v_R_2 = *v_R_2 + _S4062; + *v_t_2 = *v_t_2 + _S4059; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgs_persp_rational_projection_Intermediates_0 +{ + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4065; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4066; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4067; +}; + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_primal_ctx_s_fwd_DistRational_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpdpuv_6, FixedArray * coeffs_17) +{ + float u_12 = dpdpuv_6->primal_0.x; + float s_diff_u_7 = dpdpuv_6->differential_0.x; + float v_12 = dpdpuv_6->primal_0.y; + float s_diff_v_7 = dpdpuv_6->differential_0.y; + float _S4068 = s_diff_u_7 * u_12; + float _S4069 = s_diff_v_7 * v_12; + float r2_12 = u_12 * u_12 + v_12 * v_12; + float s_diff_r2_7 = _S4068 + _S4068 + (_S4069 + _S4069); + float _S4070 = (*coeffs_17)[int(1)] + r2_12 * (*coeffs_17)[int(2)]; + float _S4071 = (*coeffs_17)[int(0)] + r2_12 * _S4070; + float _S4072 = 1.0f + r2_12 * _S4071; + float _S4073 = (*coeffs_17)[int(4)] + r2_12 * (*coeffs_17)[int(5)]; + float _S4074 = (*coeffs_17)[int(3)] + r2_12 * _S4073; + float _S4075 = 1.0f + r2_12 * _S4074; + float radial_5 = _S4072 / _S4075; + float _S4076 = 2.0f * (*coeffs_17)[int(6)]; + float _S4077 = _S4076 * u_12; + float _S4078 = 2.0f * u_12; + float _S4079 = 2.0f * (*coeffs_17)[int(7)]; + float _S4080 = _S4079 * u_12; + float _S4081 = 2.0f * v_12; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4082 = { dpdpuv_6->primal_0 * make_float2 (radial_5) + make_float2 (_S4077 * v_12 + (*coeffs_17)[int(7)] * (r2_12 + _S4078 * u_12), _S4080 * v_12 + (*coeffs_17)[int(6)] * (r2_12 + _S4081 * v_12)), dpdpuv_6->differential_0 * make_float2 (radial_5) + make_float2 (((s_diff_r2_7 * _S4071 + (s_diff_r2_7 * _S4070 + s_diff_r2_7 * (*coeffs_17)[int(2)] * r2_12) * r2_12) * _S4075 - _S4072 * (s_diff_r2_7 * _S4074 + (s_diff_r2_7 * _S4073 + s_diff_r2_7 * (*coeffs_17)[int(5)] * r2_12) * r2_12)) / (_S4075 * _S4075)) * dpdpuv_6->primal_0 + make_float2 (s_diff_u_7 * _S4076 * v_12 + s_diff_v_7 * _S4077 + (s_diff_r2_7 + (s_diff_u_7 * 2.0f * u_12 + s_diff_u_7 * _S4078)) * (*coeffs_17)[int(7)], s_diff_u_7 * _S4079 * v_12 + s_diff_v_7 * _S4080 + (s_diff_r2_7 + (s_diff_v_7 * 2.0f * v_12 + s_diff_v_7 * _S4081)) * (*coeffs_17)[int(6)]) }; + return _S4082; +} + +inline __device__ void s_bwd_prop_s_fwd_DistRational_distort_0(DiffPair_0 * dpdpuv_7, FixedArray * coeffs_18, DiffPair_vectorx3Cfloatx2C2x3E_0 * _s_dOut_10) +{ + float u_13 = (*dpdpuv_7).primal_0.primal_0.x; + float s_diff_u_8 = (*dpdpuv_7).primal_0.differential_0.x; + float v_13 = (*dpdpuv_7).primal_0.primal_0.y; + float s_diff_v_8 = (*dpdpuv_7).primal_0.differential_0.y; + float _S4083 = s_diff_u_8 * u_13; + float _S4084 = s_diff_v_8 * v_13; + float r2_13 = u_13 * u_13 + v_13 * v_13; + float s_diff_r2_8 = _S4083 + _S4083 + (_S4084 + _S4084); + float _S4085 = s_diff_r2_8 * (*coeffs_18)[int(2)]; + float _S4086 = (*coeffs_18)[int(1)] + r2_13 * (*coeffs_18)[int(2)]; + float _S4087 = s_diff_r2_8 * _S4086 + _S4085 * r2_13; + float _S4088 = (*coeffs_18)[int(0)] + r2_13 * _S4086; + float _S4089 = s_diff_r2_8 * _S4088 + _S4087 * r2_13; + float _S4090 = 1.0f + r2_13 * _S4088; + float _S4091 = s_diff_r2_8 * (*coeffs_18)[int(5)]; + float _S4092 = (*coeffs_18)[int(4)] + r2_13 * (*coeffs_18)[int(5)]; + float _S4093 = s_diff_r2_8 * _S4092 + _S4091 * r2_13; + float _S4094 = (*coeffs_18)[int(3)] + r2_13 * _S4092; + float _S4095 = s_diff_r2_8 * _S4094 + _S4093 * r2_13; + float _S4096 = 1.0f + r2_13 * _S4094; + float2 _S4097 = make_float2 (_S4090 / _S4096); + float _S4098 = _S4096 * _S4096; + float _S4099 = _S4089 * _S4096 - _S4090 * _S4095; + float _S4100 = 2.0f * (*coeffs_18)[int(6)]; + float _S4101 = _S4100 * u_13; + float _S4102 = 2.0f * u_13; + float _S4103 = 2.0f * (*coeffs_18)[int(7)]; + float _S4104 = _S4103 * u_13; + float _S4105 = 2.0f * v_13; + float _S4106 = (*coeffs_18)[int(6)] * *&((&_s_dOut_10->differential_0)->y); + float _S4107 = (*coeffs_18)[int(6)] * *&((&_s_dOut_10->primal_0)->y); + float _S4108 = (*coeffs_18)[int(7)] * *&((&_s_dOut_10->differential_0)->x); + float _S4109 = (*coeffs_18)[int(7)] * *&((&_s_dOut_10->primal_0)->x); + float2 _S4110 = (*dpdpuv_7).primal_0.primal_0 * _s_dOut_10->differential_0; + float2 _S4111 = (*dpdpuv_7).primal_0.differential_0 * _s_dOut_10->differential_0; + float2 _S4112 = (*dpdpuv_7).primal_0.primal_0 * _s_dOut_10->primal_0; + float _S4113 = (_S4110.x + _S4110.y) / (_S4098 * _S4098); + float _S4114 = _S4098 * _S4113; + float _S4115 = _S4096 * (_S4099 * - _S4113); + float _S4116 = - _S4114; + float _S4117 = _S4090 * _S4116; + float _S4118 = _S4096 * _S4114; + float _S4119 = (_S4111.x + _S4111.y + _S4112.x + _S4112.y) / _S4098; + float _S4120 = _S4115 + _S4115 + _S4089 * _S4114 + _S4090 * - _S4119; + float _S4121 = r2_13 * _S4117; + float _S4122 = s_diff_r2_8 * _S4117 + r2_13 * _S4120; + float _S4123 = _S4095 * _S4116 + _S4096 * _S4119; + float _S4124 = r2_13 * _S4118; + float _S4125 = s_diff_r2_8 * _S4118 + r2_13 * _S4123; + float _S4126 = _S4106 + _S4108 + _S4094 * _S4117 + _S4092 * _S4121 + (*coeffs_18)[int(5)] * (r2_13 * _S4121) + _S4088 * _S4118 + _S4086 * _S4124 + (*coeffs_18)[int(2)] * (r2_13 * _S4124); + float _S4127 = _S4107 + _S4109 + _S4093 * _S4117 + _S4094 * _S4120 + _S4091 * _S4121 + _S4092 * _S4122 + (*coeffs_18)[int(5)] * (s_diff_r2_8 * _S4121 + r2_13 * _S4122) + _S4087 * _S4118 + _S4088 * _S4123 + _S4085 * _S4124 + _S4086 * _S4125 + (*coeffs_18)[int(2)] * (s_diff_r2_8 * _S4124 + r2_13 * _S4125); + float _S4128 = _S4126 + _S4126; + float _S4129 = v_13 * _S4127; + float _S4130 = u_13 * _S4127; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4131 = { make_float2 (_S4099 / _S4098) * _s_dOut_10->differential_0 + _S4097 * _s_dOut_10->primal_0 + make_float2 (_S4103 * (s_diff_v_8 * *&((&_s_dOut_10->differential_0)->y) + v_13 * *&((&_s_dOut_10->primal_0)->y)) + s_diff_u_8 * 2.0f * _S4108 + _S4102 * _S4109 + 2.0f * (s_diff_u_8 * _S4108 + u_13 * _S4109) + _S4100 * (s_diff_v_8 * *&((&_s_dOut_10->differential_0)->x) + v_13 * *&((&_s_dOut_10->primal_0)->x)) + s_diff_u_8 * _S4128 + _S4130 + _S4130, s_diff_v_8 * 2.0f * _S4106 + _S4105 * _S4107 + 2.0f * (s_diff_v_8 * _S4106 + v_13 * _S4107) + s_diff_u_8 * _S4103 * *&((&_s_dOut_10->differential_0)->y) + _S4104 * *&((&_s_dOut_10->primal_0)->y) + s_diff_u_8 * _S4100 * *&((&_s_dOut_10->differential_0)->x) + _S4101 * *&((&_s_dOut_10->primal_0)->x) + s_diff_v_8 * _S4128 + _S4129 + _S4129), _S4097 * _s_dOut_10->differential_0 + make_float2 (_S4103 * (v_13 * *&((&_s_dOut_10->differential_0)->y)) + _S4102 * _S4108 + 2.0f * (u_13 * _S4108) + _S4100 * (v_13 * *&((&_s_dOut_10->differential_0)->x)) + u_13 * _S4128, _S4105 * _S4106 + 2.0f * (v_13 * _S4106) + _S4104 * *&((&_s_dOut_10->differential_0)->y) + _S4101 * *&((&_s_dOut_10->differential_0)->x) + v_13 * _S4128) }; + dpdpuv_7->primal_0 = (*dpdpuv_7).primal_0; + dpdpuv_7->differential_0 = _S4131; + return; +} + +inline __device__ void s_bwd_prop_DistRational_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_7, FixedArray * coeffs_19, float2 _s_dOut_11) +{ + float u_14 = (*dpuv_7).primal_0.x; + float v_14 = (*dpuv_7).primal_0.y; + float r2_14 = u_14 * u_14 + v_14 * v_14; + float _S4132 = (*coeffs_19)[int(1)] + r2_14 * (*coeffs_19)[int(2)]; + float _S4133 = (*coeffs_19)[int(0)] + r2_14 * _S4132; + float _S4134 = 1.0f + r2_14 * _S4133; + float _S4135 = (*coeffs_19)[int(4)] + r2_14 * (*coeffs_19)[int(5)]; + float _S4136 = (*coeffs_19)[int(3)] + r2_14 * _S4135; + float _S4137 = 1.0f + r2_14 * _S4136; + float _S4138 = 2.0f * (*coeffs_19)[int(6)]; + float _S4139 = 2.0f * (*coeffs_19)[int(7)]; + float _S4140 = (*coeffs_19)[int(6)] * _s_dOut_11.y; + float _S4141 = (*coeffs_19)[int(7)] * _s_dOut_11.x; + float2 _S4142 = (*dpuv_7).primal_0 * _s_dOut_11; + float _S4143 = (_S4142.x + _S4142.y) / (_S4137 * _S4137); + float _S4144 = _S4134 * - _S4143; + float _S4145 = _S4137 * _S4143; + float _S4146 = r2_14 * _S4144; + float _S4147 = r2_14 * _S4145; + float _S4148 = _S4140 + _S4141 + _S4136 * _S4144 + _S4135 * _S4146 + (*coeffs_19)[int(5)] * (r2_14 * _S4146) + _S4133 * _S4145 + _S4132 * _S4147 + (*coeffs_19)[int(2)] * (r2_14 * _S4147); + float _S4149 = v_14 * _S4148; + float _S4150 = u_14 * _S4148; + float2 _S4151 = make_float2 (_S4134 / _S4137) * _s_dOut_11 + make_float2 (_S4139 * (v_14 * _s_dOut_11.y) + 2.0f * u_14 * _S4141 + 2.0f * (u_14 * _S4141) + _S4138 * (v_14 * _s_dOut_11.x) + _S4150 + _S4150, 2.0f * v_14 * _S4140 + 2.0f * (v_14 * _S4140) + _S4139 * u_14 * _s_dOut_11.y + _S4138 * u_14 * _s_dOut_11.x + _S4149 + _S4149); + dpuv_7->primal_0 = (*dpuv_7).primal_0; + dpuv_7->differential_0 = _S4151; + return; +} + +inline __device__ void projection_3dgs_persp_rational_vjp(bool antialiased_25, float3 mean_26, float4 quat_25, float3 scale_25, float in_opacity_25, Matrix R_25, float3 t_25, float fx_38, float fy_38, float cx_29, float cy_29, FixedArray dist_coeffs_37, uint image_width_25, uint image_height_25, float2 v_mean2d_3, float v_depth_3, float3 v_conic_3, float v_opacity_3, float3 * v_mean_3, float4 * v_quat_3, float3 * v_scale_3, float * v_in_opacity_3, Matrix * v_R_3, float3 * v_t_3) +{ + float2 _S4152 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4153 = { _S4152, _S4152 }; + s_bwd_prop_DiffProjection3DGS_3dgs_persp_rational_projection_Intermediates_0 _S4154; + (&_S4154)->_S4065 = _S4153; + (&_S4154)->_S4066 = _S4153; + (&_S4154)->_S4067 = _S4153; + float3 mean_c_25 = s_primal_ctx_mul_0(R_25, mean_26) + t_25; + float2 _S4155 = float2 {mean_c_25.x, mean_c_25.y}; + float2 _S4156 = make_float2 (1.0f, 0.0f); + float _S4157 = mean_c_25.z; + float2 _S4158 = _S4156 * make_float2 (_S4157); + float _S4159 = _S4157 * _S4157; + float2 s_diff_uv_33 = _S4158 / make_float2 (_S4159); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4160; + (&_S4160)->primal_0 = _S4155 / make_float2 (_S4157); + (&_S4160)->differential_0 = s_diff_uv_33; + FixedArray _S4161 = dist_coeffs_37; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4162 = s_primal_ctx_s_fwd_DistRational_distort_0(&_S4160, &_S4161); + (&_S4154)->_S4065 = _S4162; + float2 _S4163 = make_float2 (0.0f, 1.0f); + float2 _S4164 = _S4163 * make_float2 (_S4157); + float2 s_diff_uv_34 = _S4164 / make_float2 (_S4159); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4165; + (&_S4165)->primal_0 = _S4155 / make_float2 (_S4157); + (&_S4165)->differential_0 = s_diff_uv_34; + FixedArray _S4166 = dist_coeffs_37; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4167 = s_primal_ctx_s_fwd_DistRational_distort_0(&_S4165, &_S4166); + (&_S4154)->_S4066 = _S4167; + float2 _S4168 = make_float2 (0.0f, 0.0f); + float2 _S4169 = _S4168 - _S4155; + float2 s_diff_uv_35 = _S4169 / make_float2 (_S4159); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4170; + (&_S4170)->primal_0 = _S4155 / make_float2 (_S4157); + (&_S4170)->differential_0 = s_diff_uv_35; + FixedArray _S4171 = dist_coeffs_37; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4172 = s_primal_ctx_s_fwd_DistRational_distort_0(&_S4170, &_S4171); + (&_S4154)->_S4067 = _S4172; + float _S4173 = - in_opacity_25; + float _S4174 = 1.0f + s_primal_ctx_exp_0(_S4173); + float _S4175 = 1.0f / _S4174; + float _S4176 = _S4174 * _S4174; + float4 _S4177 = normalize_0(quat_25); + float3 _S4178 = s_primal_ctx_exp_1(scale_25); + float _S4179 = _S4177.y; + float x2_25 = _S4179 * _S4179; + float y2_25 = _S4177.z * _S4177.z; + float z2_25 = _S4177.w * _S4177.w; + float xy_25 = _S4177.y * _S4177.z; + float xz_25 = _S4177.y * _S4177.w; + float yz_25 = _S4177.z * _S4177.w; + float wx_25 = _S4177.x * _S4177.y; + float wy_25 = _S4177.x * _S4177.z; + float wz_25 = _S4177.x * _S4177.w; + Matrix _S4180 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_25 + z2_25), 2.0f * (xy_25 + wz_25), 2.0f * (xz_25 - wy_25), 2.0f * (xy_25 - wz_25), 1.0f - 2.0f * (x2_25 + z2_25), 2.0f * (yz_25 + wx_25), 2.0f * (xz_25 + wy_25), 2.0f * (yz_25 - wx_25), 1.0f - 2.0f * (x2_25 + y2_25))); + Matrix S_3 = makeMatrix (_S4178.x, 0.0f, 0.0f, 0.0f, _S4178.y, 0.0f, 0.0f, 0.0f, _S4178.z); + Matrix _S4181 = s_primal_ctx_mul_1(_S4180, S_3); + Matrix _S4182 = transpose_3(_S4181); + Matrix _S4183 = s_primal_ctx_mul_1(_S4181, _S4182); + Matrix _S4184 = s_primal_ctx_mul_1(R_25, _S4183); + Matrix _S4185 = transpose_3(R_25); + Matrix _S4186 = s_primal_ctx_mul_1(_S4184, _S4185); + Matrix J_35 = makeMatrix (0.0f); + float2 _S4187 = make_float2 (_S4157); + float2 _S4188 = make_float2 (_S4159); + float2 _S4189 = make_float2 (_S4159 * _S4159); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4190 = { _S4155 / make_float2 (_S4157), _S4158 / make_float2 (_S4159) }; + float _S4191 = _S4154._S4065.differential_0.x * fx_38; + float _S4192 = _S4154._S4065.differential_0.y * fy_38; + Matrix _S4193 = J_35; + *&(((&_S4193)->rows + (int(0)))->x) = _S4191; + *&(((&_S4193)->rows + (int(1)))->x) = _S4192; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4194 = { _S4155 / make_float2 (_S4157), _S4164 / make_float2 (_S4159) }; + float _S4195 = _S4154._S4066.differential_0.y * fy_38; + *&(((&_S4193)->rows + (int(0)))->y) = _S4154._S4066.differential_0.x * fx_38; + *&(((&_S4193)->rows + (int(1)))->y) = _S4195; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4196 = { _S4155 / make_float2 (_S4157), _S4169 / make_float2 (_S4159) }; + float _S4197 = _S4154._S4067.differential_0.x * fx_38; + float _S4198 = _S4154._S4067.differential_0.y * fy_38; + float _S4199 = float(image_width_25); + float _S4200 = 0.30000001192092896f * (0.5f * _S4199); + float lim_x_pos_15 = _S4199 + _S4200; + float rz_11 = 1.0f / _S4157; + float _S4201 = - _S4200; + float _S4202 = - (_S4201 - cx_29); + float max_Jxz_3 = _S4202 * rz_11; + float _S4203 = - (lim_x_pos_15 - cx_29); + float min_Jxz_3 = _S4203 * rz_11; + float _S4204 = - (_S4201 - cy_29); + float max_Jyz_11 = _S4204 * rz_11; + float _S4205 = - (lim_x_pos_15 - cy_29); + float min_Jyz_11 = _S4205 * rz_11; + *&(((&_S4193)->rows + (int(0)))->z) = s_primal_ctx_clamp_0(_S4197, min_Jxz_3, max_Jxz_3); + *&(((&_S4193)->rows + (int(1)))->z) = s_primal_ctx_clamp_0(_S4198, min_Jyz_11, max_Jyz_11); + Matrix _S4206 = s_primal_ctx_mul_2(_S4193, _S4186); + Matrix _S4207 = transpose_1(_S4193); + Matrix _S4208 = s_primal_ctx_mul_3(_S4206, _S4207); + float eps2d_25; + if(antialiased_25) + { + eps2d_25 = 0.10000000149011612f; + } + else + { + eps2d_25 = 0.30000001192092896f; + } + float _S4209 = _S4208.rows[int(0)].y * _S4208.rows[int(1)].x; + float det_orig_25 = _S4208.rows[int(0)].x * _S4208.rows[int(1)].y - _S4209; + float _S4210 = _S4208.rows[int(0)].x + eps2d_25; + Matrix _S4211 = _S4208; + *&(((&_S4211)->rows + (int(0)))->x) = _S4210; + float _S4212 = _S4208.rows[int(1)].y + eps2d_25; + *&(((&_S4211)->rows + (int(1)))->y) = _S4212; + Matrix _S4213 = _S4211; + Matrix _S4214 = _S4211; + float det_blur_25 = _S4210 * _S4212 - _S4209; + float _S4215 = det_orig_25 / det_blur_25; + float _S4216 = det_blur_25 * det_blur_25; + float _S4217 = (F32_max((0.0f), (_S4215))); + float _S4218 = s_primal_ctx_sqrt_0(_S4217); + float invdet_31 = 1.0f / det_blur_25; + float _S4219 = - _S4208.rows[int(0)].y; + float _S4220 = - _S4208.rows[int(1)].x; + if(antialiased_25) + { + eps2d_25 = _S4175 * _S4218; + } + else + { + eps2d_25 = _S4175; + } + float _S4221 = eps2d_25 / 0.00392156885936856f; + float _S4222 = 2.0f * s_primal_ctx_log_0(_S4221); + float _S4223 = s_primal_ctx_sqrt_0(_S4222); + float _S4224 = _S4213.rows[int(0)].x; + float _S4225 = _S4214.rows[int(1)].y; + float3 campos_4 = - s_primal_ctx_mul_0(_S4185, t_25); + float3 _S4226 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4227; + (&_S4227)->primal_0 = mean_26; + (&_S4227)->differential_0 = _S4226; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4228; + (&_S4228)->primal_0 = scale_25; + (&_S4228)->differential_0 = _S4226; + DiffPair_float_0 _S4229; + (&_S4229)->primal_0 = in_opacity_25; + (&_S4229)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4230; + (&_S4230)->primal_0 = campos_4; + (&_S4230)->differential_0 = _S4226; + s_bwd_prop_view_radius_3dgs_0(&_S4227, &_S4228, &_S4229, &_S4230, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4231 = _S4227; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4232 = _S4228; + DiffPair_float_0 _S4233 = _S4229; + float2 _S4234 = _S4152; + *&((&_S4234)->y) = v_conic_3.z; + float2 _S4235 = _S4152; + *&((&_S4235)->y) = v_conic_3.y; + *&((&_S4235)->x) = v_conic_3.x; + DiffPair_float_0 _S4236; + (&_S4236)->primal_0 = _S4225; + (&_S4236)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4236, 0.0f); + DiffPair_float_0 _S4237; + (&_S4237)->primal_0 = _S4224; + (&_S4237)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4237, 0.0f); + DiffPair_float_0 _S4238; + (&_S4238)->primal_0 = 3.32999992370605469f; + (&_S4238)->differential_0 = 0.0f; + DiffPair_float_0 _S4239; + (&_S4239)->primal_0 = _S4223; + (&_S4239)->differential_0 = 0.0f; + _d_min_0(&_S4238, &_S4239, 0.0f); + DiffPair_float_0 _S4240; + (&_S4240)->primal_0 = _S4222; + (&_S4240)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4240, _S4239.differential_0); + float _S4241 = 2.0f * _S4240.differential_0; + DiffPair_float_0 _S4242; + (&_S4242)->primal_0 = _S4221; + (&_S4242)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S4242, _S4241); + float _S4243 = v_opacity_3 + 254.9999847412109375f * _S4242.differential_0; + Matrix _S4244 = makeMatrix (0.0f); + Matrix _S4245 = _S4244; + _S4245[int(1)] = _S4234; + _S4245[int(0)] = _S4235; + Matrix _S4246 = _S4245; + float2 _S4247 = make_float2 (0.0f, _S4236.differential_0); + float2 _S4248 = make_float2 (_S4237.differential_0, 0.0f); + float _S4249; + if(antialiased_25) + { + float _S4250 = _S4218 * _S4243; + eps2d_25 = _S4175 * _S4243; + _S4249 = _S4250; + } + else + { + eps2d_25 = 0.0f; + _S4249 = _S4243; + } + float _S4251 = invdet_31 * _S4246.rows[int(1)].y; + float _S4252 = - (invdet_31 * _S4246.rows[int(1)].x); + float _S4253 = - (invdet_31 * _S4246.rows[int(0)].y); + float _S4254 = invdet_31 * _S4246.rows[int(0)].x; + float _S4255 = - ((_S4210 * _S4246.rows[int(1)].y + _S4220 * _S4246.rows[int(1)].x + _S4219 * _S4246.rows[int(0)].y + _S4212 * _S4246.rows[int(0)].x) / _S4216); + DiffPair_float_0 _S4256; + (&_S4256)->primal_0 = _S4217; + (&_S4256)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4256, eps2d_25); + DiffPair_float_0 _S4257; + (&_S4257)->primal_0 = 0.0f; + (&_S4257)->differential_0 = 0.0f; + DiffPair_float_0 _S4258; + (&_S4258)->primal_0 = _S4215; + (&_S4258)->differential_0 = 0.0f; + _d_max_0(&_S4257, &_S4258, _S4256.differential_0); + float _S4259 = _S4258.differential_0 / _S4216; + float s_diff_det_orig_T_3 = det_blur_25 * _S4259; + float _S4260 = det_orig_25 * - _S4259 + _S4255; + float _S4261 = - _S4260; + float _S4262 = _S4210 * _S4260; + float _S4263 = _S4212 * _S4260; + Matrix _S4264 = _S4244; + _S4264[int(1)] = _S4247; + _S4264[int(0)] = _S4248; + _S4211 = _S4264; + *&(((&_S4211)->rows + (int(1)))->y) = 0.0f; + float _S4265 = _S4262 + _S4264.rows[int(1)].y + _S4254; + *&(((&_S4211)->rows + (int(0)))->x) = 0.0f; + float _S4266 = _S4263 + _S4264.rows[int(0)].x + _S4251; + float _S4267 = _S4261 + - s_diff_det_orig_T_3; + float _S4268 = _S4208.rows[int(0)].y * _S4267 + _S4252; + float _S4269 = _S4208.rows[int(1)].x * _S4267 + _S4253; + float _S4270 = _S4208.rows[int(1)].y * s_diff_det_orig_T_3; + float _S4271 = _S4265 + _S4208.rows[int(0)].x * s_diff_det_orig_T_3; + float2 _S4272 = _S4152; + *&((&_S4272)->x) = _S4268; + *&((&_S4272)->y) = _S4271; + float _S4273 = _S4266 + _S4270; + float2 _S4274 = _S4152; + *&((&_S4274)->y) = _S4269; + *&((&_S4274)->x) = _S4273; + Matrix _S4275 = _S4244; + _S4275[int(1)] = _S4272; + _S4275[int(0)] = _S4274; + Matrix _S4276 = _S4211 + _S4275; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S4277; + (&_S4277)->primal_0 = _S4206; + (&_S4277)->differential_0 = J_35; + Matrix _S4278 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S4279; + (&_S4279)->primal_0 = _S4207; + (&_S4279)->differential_0 = _S4278; + s_bwd_prop_mul_0(&_S4277, &_S4279, _S4276); + Matrix _S4280 = transpose_2(_S4279.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S4281; + (&_S4281)->primal_0 = _S4193; + (&_S4281)->differential_0 = J_35; + Matrix _S4282 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4283; + (&_S4283)->primal_0 = _S4186; + (&_S4283)->differential_0 = _S4282; + s_bwd_prop_mul_1(&_S4281, &_S4283, _S4277.differential_0); + Matrix _S4284 = _S4280 + _S4281.differential_0; + DiffPair_float_0 _S4285; + (&_S4285)->primal_0 = _S4198; + (&_S4285)->differential_0 = 0.0f; + DiffPair_float_0 _S4286; + (&_S4286)->primal_0 = min_Jyz_11; + (&_S4286)->differential_0 = 0.0f; + DiffPair_float_0 _S4287; + (&_S4287)->primal_0 = max_Jyz_11; + (&_S4287)->differential_0 = 0.0f; + s_bwd_prop_clamp_0(&_S4285, &_S4286, &_S4287, _S4284.rows[int(1)].z); + DiffPair_float_0 _S4288; + (&_S4288)->primal_0 = _S4197; + (&_S4288)->differential_0 = 0.0f; + DiffPair_float_0 _S4289; + (&_S4289)->primal_0 = min_Jxz_3; + (&_S4289)->differential_0 = 0.0f; + DiffPair_float_0 _S4290; + (&_S4290)->primal_0 = max_Jxz_3; + (&_S4290)->differential_0 = 0.0f; + s_bwd_prop_clamp_0(&_S4288, &_S4289, &_S4290, _S4284.rows[int(0)].z); + float _S4291 = - ((_S4205 * _S4286.differential_0 + _S4204 * _S4287.differential_0 + _S4203 * _S4289.differential_0 + _S4202 * _S4290.differential_0) / _S4159); + float2 _S4292 = make_float2 (fx_38 * _S4288.differential_0, fy_38 * _S4285.differential_0); + DiffPair_0 _S4293; + (&_S4293)->primal_0 = _S4196; + (&_S4293)->differential_0 = _S4153; + FixedArray _S4294 = dist_coeffs_37; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4295; + (&_S4295)->primal_0 = _S4168; + (&_S4295)->differential_0 = _S4292; + s_bwd_prop_s_fwd_DistRational_distort_0(&_S4293, &_S4294, &_S4295); + float2 _S4296 = _S4293.differential_0.differential_0 / _S4189; + float2 _S4297 = _S4169 * - _S4296; + float _S4298 = _S4157 * (_S4297.x + _S4297.y); + float2 _S4299 = _S4293.differential_0.primal_0 / _S4188; + float2 _S4300 = _S4155 * - _S4299; + float2 _S4301 = - (_S4188 * _S4296) + _S4187 * _S4299; + float3 _S4302 = make_float3 (_S4301.x, _S4301.y, _S4298 + _S4298 + _S4300.x + _S4300.y); + float2 _S4303 = make_float2 (fx_38 * _S4284.rows[int(0)].y, fy_38 * _S4284.rows[int(1)].y); + DiffPair_0 _S4304; + (&_S4304)->primal_0 = _S4194; + (&_S4304)->differential_0 = _S4153; + FixedArray _S4305 = dist_coeffs_37; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4306; + (&_S4306)->primal_0 = _S4168; + (&_S4306)->differential_0 = _S4303; + s_bwd_prop_s_fwd_DistRational_distort_0(&_S4304, &_S4305, &_S4306); + float2 _S4307 = _S4304.differential_0.differential_0 / _S4189; + float2 _S4308 = _S4164 * - _S4307; + float _S4309 = _S4157 * (_S4308.x + _S4308.y); + float2 _S4310 = _S4163 * (_S4188 * _S4307); + float2 _S4311 = _S4304.differential_0.primal_0 / _S4188; + float2 _S4312 = _S4155 * - _S4311; + float2 _S4313 = _S4187 * _S4311; + float3 _S4314 = make_float3 (_S4313.x, _S4313.y, _S4309 + _S4309 + _S4310.x + _S4310.y + _S4312.x + _S4312.y); + float2 _S4315 = make_float2 (fx_38 * _S4284.rows[int(0)].x, fy_38 * _S4284.rows[int(1)].x); + DiffPair_0 _S4316; + (&_S4316)->primal_0 = _S4190; + (&_S4316)->differential_0 = _S4153; + FixedArray _S4317 = dist_coeffs_37; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4318; + (&_S4318)->primal_0 = _S4168; + (&_S4318)->differential_0 = _S4315; + s_bwd_prop_s_fwd_DistRational_distort_0(&_S4316, &_S4317, &_S4318); + float2 _S4319 = _S4316.differential_0.differential_0 / _S4189; + float2 _S4320 = _S4158 * - _S4319; + float _S4321 = _S4157 * (_S4320.x + _S4320.y); + float2 _S4322 = _S4156 * (_S4188 * _S4319); + float2 _S4323 = _S4316.differential_0.primal_0 / _S4188; + float2 _S4324 = _S4155 * - _S4323; + float2 _S4325 = _S4187 * _S4323; + float3 _S4326 = make_float3 (_S4325.x, _S4325.y, _S4321 + _S4321 + _S4322.x + _S4322.y + _S4324.x + _S4324.y); + float2 _S4327 = make_float2 (fx_38 * v_mean2d_3.x, fy_38 * v_mean2d_3.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4328; + (&_S4328)->primal_0 = _S4155 / make_float2 (_S4157); + (&_S4328)->differential_0 = _S4152; + FixedArray _S4329 = dist_coeffs_37; + s_bwd_prop_DistRational_distort_0(&_S4328, &_S4329, _S4327); + float2 _S4330 = _S4328.differential_0 / _S4188; + float2 _S4331 = _S4155 * - _S4330; + float2 _S4332 = _S4187 * _S4330; + float3 _S4333 = make_float3 (_S4332.x, _S4332.y, _S4331.x + _S4331.y); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4334; + (&_S4334)->primal_0 = _S4184; + (&_S4334)->differential_0 = _S4282; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4335; + (&_S4335)->primal_0 = _S4185; + (&_S4335)->differential_0 = _S4282; + s_bwd_prop_mul_2(&_S4334, &_S4335, _S4283.differential_0); + Matrix _S4336 = transpose_3(_S4335.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4337; + (&_S4337)->primal_0 = R_25; + (&_S4337)->differential_0 = _S4282; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4338; + (&_S4338)->primal_0 = _S4183; + (&_S4338)->differential_0 = _S4282; + s_bwd_prop_mul_2(&_S4337, &_S4338, _S4334.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4339; + (&_S4339)->primal_0 = _S4181; + (&_S4339)->differential_0 = _S4282; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4340; + (&_S4340)->primal_0 = _S4182; + (&_S4340)->differential_0 = _S4282; + s_bwd_prop_mul_2(&_S4339, &_S4340, _S4338.differential_0); + Matrix _S4341 = _S4339.differential_0 + transpose_3(_S4340.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4342; + (&_S4342)->primal_0 = _S4180; + (&_S4342)->differential_0 = _S4282; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4343; + (&_S4343)->primal_0 = S_3; + (&_S4343)->differential_0 = _S4282; + s_bwd_prop_mul_2(&_S4342, &_S4343, _S4341); + Matrix _S4344 = transpose_3(_S4342.differential_0); + float _S4345 = 2.0f * - _S4344.rows[int(2)].z; + float _S4346 = 2.0f * _S4344.rows[int(2)].y; + float _S4347 = 2.0f * _S4344.rows[int(2)].x; + float _S4348 = 2.0f * _S4344.rows[int(1)].z; + float _S4349 = 2.0f * - _S4344.rows[int(1)].y; + float _S4350 = 2.0f * _S4344.rows[int(1)].x; + float _S4351 = 2.0f * _S4344.rows[int(0)].z; + float _S4352 = 2.0f * _S4344.rows[int(0)].y; + float _S4353 = 2.0f * - _S4344.rows[int(0)].x; + float _S4354 = - _S4350 + _S4352; + float _S4355 = _S4347 + - _S4351; + float _S4356 = - _S4346 + _S4348; + float _S4357 = _S4346 + _S4348; + float _S4358 = _S4347 + _S4351; + float _S4359 = _S4350 + _S4352; + float _S4360 = _S4177.w * (_S4349 + _S4353); + float _S4361 = _S4177.z * (_S4345 + _S4353); + float _S4362 = _S4177.y * (_S4345 + _S4349); + float _S4363 = _S4177.x * _S4354 + _S4177.z * _S4357 + _S4177.y * _S4358 + _S4360 + _S4360; + float _S4364 = _S4177.x * _S4355 + _S4177.w * _S4357 + _S4177.y * _S4359 + _S4361 + _S4361; + float _S4365 = _S4177.x * _S4356 + _S4177.w * _S4358 + _S4177.z * _S4359 + _S4362 + _S4362; + float _S4366 = _S4177.w * _S4354 + _S4177.z * _S4355 + _S4177.y * _S4356; + float3 _S4367 = _S4226; + *&((&_S4367)->z) = _S4343.differential_0.rows[int(2)].z; + *&((&_S4367)->y) = _S4343.differential_0.rows[int(1)].y; + *&((&_S4367)->x) = _S4343.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4368; + (&_S4368)->primal_0 = scale_25; + (&_S4368)->differential_0 = _S4226; + s_bwd_prop_exp_1(&_S4368, _S4367); + float4 _S4369 = make_float4 (0.0f); + float4 _S4370 = _S4369; + *&((&_S4370)->w) = _S4363; + *&((&_S4370)->z) = _S4364; + *&((&_S4370)->y) = _S4365; + *&((&_S4370)->x) = _S4366; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S4371; + (&_S4371)->primal_0 = quat_25; + (&_S4371)->differential_0 = _S4369; + s_bwd_normalize_impl_0(&_S4371, _S4370); + float _S4372 = - (_S4249 / _S4176); + DiffPair_float_0 _S4373; + (&_S4373)->primal_0 = _S4173; + (&_S4373)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S4373, _S4372); + float _S4374 = - _S4373.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4375; + (&_S4375)->primal_0 = mean_c_25; + (&_S4375)->differential_0 = _S4226; + s_bwd_length_impl_0(&_S4375, v_depth_3); + float3 _S4376 = _S4302 + _S4314 + _S4326 + _S4333 + _S4375.differential_0 + make_float3 (0.0f, 0.0f, _S4291); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4377; + (&_S4377)->primal_0 = R_25; + (&_S4377)->differential_0 = _S4282; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4378; + (&_S4378)->primal_0 = mean_26; + (&_S4378)->differential_0 = _S4226; + s_bwd_prop_mul_3(&_S4377, &_S4378, _S4376); + Matrix _S4379 = _S4336 + _S4337.differential_0 + _S4377.differential_0; + float _S4380 = _S4374 + _S4233.differential_0; + float3 _S4381 = _S4368.differential_0 + _S4232.differential_0; + *v_mean_3 = *v_mean_3 + (_S4378.differential_0 + _S4231.differential_0); + *v_quat_3 = *v_quat_3 + _S4371.differential_0; + *v_scale_3 = *v_scale_3 + _S4381; + *v_in_opacity_3 = *v_in_opacity_3 + _S4380; + *v_R_3 = *v_R_3 + _S4379; + *v_t_3 = *v_t_3 + _S4376; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgs_fisheye_none_projection_Intermediates_0 +{ + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4382; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4383; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4384; +}; + inline __device__ DiffPair_float_0 s_primal_ctx_d_sqrt_0(DiffPair_float_0 * dpdpx_0) { - DiffPair_float_0 _S1762 = { s_primal_ctx_sqrt_0(dpdpx_0->primal_0), 0.5f / s_primal_ctx_sqrt_0((F32_max((1.00000001168609742e-07f), (dpdpx_0->primal_0)))) * dpdpx_0->differential_0 }; - return _S1762; + DiffPair_float_0 _S4385 = { s_primal_ctx_sqrt_0(dpdpx_0->primal_0), 0.5f / s_primal_ctx_sqrt_0((F32_max((1.00000001168609742e-07f), (dpdpx_0->primal_0)))) * dpdpx_0->differential_0 }; + return _S4385; } inline __device__ DiffPair_float_0 s_primal_ctx_s_fwd_length_impl_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpdpx_1) { - float _S1763 = *&((&dpdpx_1->differential_0)->x) * *&((&dpdpx_1->primal_0)->x); - float _S1764 = *&((&dpdpx_1->differential_0)->y) * *&((&dpdpx_1->primal_0)->y); - float s_diff_len_1 = _S1763 + _S1763 + (_S1764 + _S1764); - DiffPair_float_0 _S1765; - (&_S1765)->primal_0 = *&((&dpdpx_1->primal_0)->x) * *&((&dpdpx_1->primal_0)->x) + *&((&dpdpx_1->primal_0)->y) * *&((&dpdpx_1->primal_0)->y); - (&_S1765)->differential_0 = s_diff_len_1; - DiffPair_float_0 _S1766 = s_primal_ctx_d_sqrt_0(&_S1765); - DiffPair_float_0 _S1767 = { _S1766.primal_0, _S1766.differential_0 }; - return _S1767; + float _S4386 = *&((&dpdpx_1->differential_0)->x) * *&((&dpdpx_1->primal_0)->x); + float _S4387 = *&((&dpdpx_1->differential_0)->y) * *&((&dpdpx_1->primal_0)->y); + float s_diff_len_1 = _S4386 + _S4386 + (_S4387 + _S4387); + DiffPair_float_0 _S4388; + (&_S4388)->primal_0 = *&((&dpdpx_1->primal_0)->x) * *&((&dpdpx_1->primal_0)->x) + *&((&dpdpx_1->primal_0)->y) * *&((&dpdpx_1->primal_0)->y); + (&_S4388)->differential_0 = s_diff_len_1; + DiffPair_float_0 _S4389 = s_primal_ctx_d_sqrt_0(&_S4388); + DiffPair_float_0 _S4390 = { _S4389.primal_0, _S4389.differential_0 }; + return _S4390; } -inline __device__ float s_primal_ctx_atan2_0(float _S1768, float _S1769) +inline __device__ float s_primal_ctx_atan2_0(float _S4391, float _S4392) { - return (F32_atan2((_S1768), (_S1769))); + return (F32_atan2((_S4391), (_S4392))); } inline __device__ DiffPair_float_0 s_primal_ctx_d_atan2_0(DiffPair_float_0 * dpdpy_0, DiffPair_float_0 * dpdpx_2) { - float _S1770 = dpdpx_2->primal_0 * dpdpx_2->primal_0 + dpdpy_0->primal_0 * dpdpy_0->primal_0; - DiffPair_float_0 _S1771 = { s_primal_ctx_atan2_0(dpdpy_0->primal_0, dpdpx_2->primal_0), - dpdpy_0->primal_0 / _S1770 * dpdpx_2->differential_0 + dpdpx_2->primal_0 / _S1770 * dpdpy_0->differential_0 }; - return _S1771; + float _S4393 = dpdpx_2->primal_0 * dpdpx_2->primal_0 + dpdpy_0->primal_0 * dpdpy_0->primal_0; + DiffPair_float_0 _S4394 = { s_primal_ctx_atan2_0(dpdpy_0->primal_0, dpdpx_2->primal_0), - dpdpy_0->primal_0 / _S4393 * dpdpx_2->differential_0 + dpdpx_2->primal_0 / _S4393 * dpdpy_0->differential_0 }; + return _S4394; } -struct DiffPair_0 +struct DiffPair_1 { DiffPair_float_0 primal_0; DiffPair_float_0 differential_0; }; -inline __device__ void s_bwd_prop_atan2_0(DiffPair_float_0 * _S1772, DiffPair_float_0 * _S1773, float _S1774) +inline __device__ void s_bwd_prop_atan2_0(DiffPair_float_0 * _S4395, DiffPair_float_0 * _S4396, float _S4397) { - _d_atan2_0(_S1772, _S1773, _S1774); + _d_atan2_0(_S4395, _S4396, _S4397); return; } -inline __device__ void s_bwd_prop_d_atan2_0(DiffPair_0 * dpdpy_1, DiffPair_0 * dpdpx_3, DiffPair_float_0 * _s_dOut_4) +inline __device__ void s_bwd_prop_d_atan2_0(DiffPair_1 * dpdpy_1, DiffPair_1 * dpdpx_3, DiffPair_float_0 * _s_dOut_12) { - float _S1775 = - (*dpdpy_1).primal_0.primal_0; - float _S1776 = (*dpdpx_3).primal_0.primal_0; - float _S1777 = _S1776 * _S1776 + (*dpdpy_1).primal_0.primal_0 * (*dpdpy_1).primal_0.primal_0; - float _S1778 = _S1775 / _S1777; - float _S1779 = _S1777 * _S1777; - float _S1780 = (*dpdpx_3).primal_0.primal_0 / _S1777; - DiffPair_float_0 _S1781; - (&_S1781)->primal_0 = (*dpdpy_1).primal_0.primal_0; - (&_S1781)->differential_0 = 0.0f; - DiffPair_float_0 _S1782; - (&_S1782)->primal_0 = (*dpdpx_3).primal_0.primal_0; - (&_S1782)->differential_0 = 0.0f; - s_bwd_prop_atan2_0(&_S1781, &_S1782, _s_dOut_4->primal_0); - float _S1783 = _S1780 * _s_dOut_4->differential_0; - float _S1784 = (*dpdpy_1).primal_0.differential_0 * _s_dOut_4->differential_0 / _S1779; - float _S1785 = (*dpdpx_3).primal_0.primal_0 * - _S1784; - float _S1786 = (*dpdpy_1).primal_0.primal_0 * _S1785; - float _S1787 = (*dpdpx_3).primal_0.primal_0 * _S1785; - float _S1788 = (*dpdpx_3).primal_0.differential_0 * _s_dOut_4->differential_0 / _S1779; - float _S1789 = _S1775 * - _S1788; - float _S1790 = (*dpdpy_1).primal_0.primal_0 * _S1789; - float _S1791 = (*dpdpx_3).primal_0.primal_0 * _S1789; - float _S1792 = - (_S1777 * _S1788); - DiffPair_float_0 _S1793 = { _S1782.differential_0 + _S1787 + _S1787 + _S1777 * _S1784 + _S1791 + _S1791, _S1778 * _s_dOut_4->differential_0 }; + float _S4398 = - (*dpdpy_1).primal_0.primal_0; + float _S4399 = (*dpdpx_3).primal_0.primal_0; + float _S4400 = _S4399 * _S4399 + (*dpdpy_1).primal_0.primal_0 * (*dpdpy_1).primal_0.primal_0; + float _S4401 = _S4398 / _S4400; + float _S4402 = _S4400 * _S4400; + float _S4403 = (*dpdpx_3).primal_0.primal_0 / _S4400; + DiffPair_float_0 _S4404; + (&_S4404)->primal_0 = (*dpdpy_1).primal_0.primal_0; + (&_S4404)->differential_0 = 0.0f; + DiffPair_float_0 _S4405; + (&_S4405)->primal_0 = (*dpdpx_3).primal_0.primal_0; + (&_S4405)->differential_0 = 0.0f; + s_bwd_prop_atan2_0(&_S4404, &_S4405, _s_dOut_12->primal_0); + float _S4406 = _S4403 * _s_dOut_12->differential_0; + float _S4407 = (*dpdpy_1).primal_0.differential_0 * _s_dOut_12->differential_0 / _S4402; + float _S4408 = (*dpdpx_3).primal_0.primal_0 * - _S4407; + float _S4409 = (*dpdpy_1).primal_0.primal_0 * _S4408; + float _S4410 = (*dpdpx_3).primal_0.primal_0 * _S4408; + float _S4411 = (*dpdpx_3).primal_0.differential_0 * _s_dOut_12->differential_0 / _S4402; + float _S4412 = _S4398 * - _S4411; + float _S4413 = (*dpdpy_1).primal_0.primal_0 * _S4412; + float _S4414 = (*dpdpx_3).primal_0.primal_0 * _S4412; + float _S4415 = - (_S4400 * _S4411); + DiffPair_float_0 _S4416 = { _S4405.differential_0 + _S4410 + _S4410 + _S4400 * _S4407 + _S4414 + _S4414, _S4401 * _s_dOut_12->differential_0 }; dpdpx_3->primal_0 = (*dpdpx_3).primal_0; - dpdpx_3->differential_0 = _S1793; - DiffPair_float_0 _S1794 = { _S1781.differential_0 + _S1786 + _S1786 + _S1790 + _S1790 + _S1792, _S1783 }; + dpdpx_3->differential_0 = _S4416; + DiffPair_float_0 _S4417 = { _S4404.differential_0 + _S4409 + _S4409 + _S4413 + _S4413 + _S4415, _S4406 }; dpdpy_1->primal_0 = (*dpdpy_1).primal_0; - dpdpy_1->differential_0 = _S1794; + dpdpy_1->differential_0 = _S4417; return; } -struct DiffPair_1 +inline __device__ void s_bwd_prop_d_sqrt_0(DiffPair_1 * dpdpx_4, DiffPair_float_0 * _s_dOut_13) { - DiffPair_vectorx3Cfloatx2C2x3E_0 primal_0; - DiffPair_vectorx3Cfloatx2C2x3E_0 differential_0; + float _S4418 = (F32_max((1.00000001168609742e-07f), ((*dpdpx_4).primal_0.primal_0))); + float _S4419 = s_primal_ctx_sqrt_0(_S4418); + float _S4420 = 0.5f / _S4419 * _s_dOut_13->differential_0; + float _S4421 = 0.5f * - ((*dpdpx_4).primal_0.differential_0 * _s_dOut_13->differential_0 / (_S4419 * _S4419)); + DiffPair_float_0 _S4422; + (&_S4422)->primal_0 = _S4418; + (&_S4422)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4422, _S4421); + DiffPair_float_0 _S4423; + (&_S4423)->primal_0 = 1.00000001168609742e-07f; + (&_S4423)->differential_0 = 0.0f; + DiffPair_float_0 _S4424; + (&_S4424)->primal_0 = (*dpdpx_4).primal_0.primal_0; + (&_S4424)->differential_0 = 0.0f; + _d_max_0(&_S4423, &_S4424, _S4422.differential_0); + DiffPair_float_0 _S4425; + (&_S4425)->primal_0 = (*dpdpx_4).primal_0.primal_0; + (&_S4425)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4425, _s_dOut_13->primal_0); + DiffPair_float_0 _S4426 = { _S4424.differential_0 + _S4425.differential_0, _S4420 }; + dpdpx_4->primal_0 = (*dpdpx_4).primal_0; + dpdpx_4->differential_0 = _S4426; + return; +} + +inline __device__ void s_bwd_prop_s_fwd_length_impl_0(DiffPair_0 * dpdpx_5, DiffPair_float_0 * _s_dOut_14) +{ + float _S4427 = (*dpdpx_5).primal_0.primal_0.x; + float _S4428 = (*dpdpx_5).primal_0.differential_0.x * (*dpdpx_5).primal_0.primal_0.x; + float _S4429 = (*dpdpx_5).primal_0.primal_0.y; + float _S4430 = (*dpdpx_5).primal_0.differential_0.y * (*dpdpx_5).primal_0.primal_0.y; + DiffPair_float_0 _S4431 = { _S4427 * _S4427 + _S4429 * _S4429, _S4428 + _S4428 + (_S4430 + _S4430) }; + DiffPair_float_0 _S4432 = { 0.0f, 0.0f }; + DiffPair_1 _S4433; + (&_S4433)->primal_0 = _S4431; + (&_S4433)->differential_0 = _S4432; + DiffPair_float_0 _S4434; + (&_S4434)->primal_0 = _s_dOut_14->primal_0; + (&_S4434)->differential_0 = _s_dOut_14->differential_0; + s_bwd_prop_d_sqrt_0(&_S4433, &_S4434); + float _S4435 = _S4433.differential_0.differential_0; + float _S4436 = _S4435 + _S4435; + float _S4437 = (*dpdpx_5).primal_0.primal_0.y * _S4436; + float _S4438 = (*dpdpx_5).primal_0.primal_0.y * _S4433.differential_0.primal_0; + float _S4439 = (*dpdpx_5).primal_0.differential_0.y * _S4436 + _S4438 + _S4438; + float _S4440 = (*dpdpx_5).primal_0.primal_0.x * _S4436; + float _S4441 = (*dpdpx_5).primal_0.primal_0.x * _S4433.differential_0.primal_0; + float _S4442 = (*dpdpx_5).primal_0.differential_0.x * _S4436 + _S4441 + _S4441; + float2 _S4443 = make_float2 (0.0f); + float2 _S4444 = _S4443; + *&((&_S4444)->y) = _S4439; + *&((&_S4444)->x) = _S4442; + float2 _S4445 = _S4443; + *&((&_S4445)->y) = _S4437; + *&((&_S4445)->x) = _S4440; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4446 = { _S4444, _S4445 }; + dpdpx_5->primal_0 = (*dpdpx_5).primal_0; + dpdpx_5->differential_0 = _S4446; + return; +} + +inline __device__ void s_bwd_prop_length_impl_2(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpx_18, float _s_dOut_15) +{ + float _S4447 = (*dpx_18).primal_0.x; + float _S4448 = (*dpx_18).primal_0.y; + DiffPair_float_0 _S4449; + (&_S4449)->primal_0 = _S4447 * _S4447 + _S4448 * _S4448; + (&_S4449)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4449, _s_dOut_15); + float _S4450 = (*dpx_18).primal_0.y * _S4449.differential_0; + float _S4451 = _S4450 + _S4450; + float _S4452 = (*dpx_18).primal_0.x * _S4449.differential_0; + float _S4453 = _S4452 + _S4452; + float2 _S4454 = make_float2 (0.0f); + *&((&_S4454)->y) = _S4451; + *&((&_S4454)->x) = _S4453; + dpx_18->primal_0 = (*dpx_18).primal_0; + dpx_18->differential_0 = _S4454; + return; +} + +inline __device__ void s_bwd_length_impl_2(DiffPair_vectorx3Cfloatx2C2x3E_0 * _S4455, float _S4456) +{ + s_bwd_prop_length_impl_2(_S4455, _S4456); + return; +} + +inline __device__ void projection_3dgs_fisheye_none_vjp(bool antialiased_26, float3 mean_27, float4 quat_26, float3 scale_26, float in_opacity_26, Matrix R_26, float3 t_26, float fx_39, float fy_39, float cx_30, float cy_30, FixedArray dist_coeffs_38, uint image_width_26, uint image_height_26, float2 v_mean2d_4, float v_depth_4, float3 v_conic_4, float v_opacity_4, float3 * v_mean_4, float4 * v_quat_4, float3 * v_scale_4, float * v_in_opacity_4, Matrix * v_R_4, float3 * v_t_4) +{ + float2 _S4457 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4458 = { _S4457, _S4457 }; + s_bwd_prop_DiffProjection3DGS_3dgs_fisheye_none_projection_Intermediates_0 _S4459; + (&_S4459)->_S4382 = _S4458; + (&_S4459)->_S4383 = _S4458; + (&_S4459)->_S4384 = _S4458; + (&(&_S4459)->_S4382)->primal_0 = _S4457; + (&(&_S4459)->_S4382)->differential_0 = _S4457; + (&(&_S4459)->_S4383)->primal_0 = _S4457; + (&(&_S4459)->_S4383)->differential_0 = _S4457; + (&(&_S4459)->_S4384)->primal_0 = _S4457; + (&(&_S4459)->_S4384)->differential_0 = _S4457; + float3 mean_c_26 = s_primal_ctx_mul_0(R_26, mean_27) + t_26; + float2 _S4460 = float2 {mean_c_26.x, mean_c_26.y}; + float2 _S4461 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4462 = { _S4460, _S4461 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4463; + (&_S4463)->primal_0 = _S4460; + (&_S4463)->differential_0 = _S4461; + DiffPair_float_0 _S4464 = s_primal_ctx_s_fwd_length_impl_0(&_S4463); + float _S4465 = mean_c_26.z; + DiffPair_float_0 _S4466 = { _S4464.primal_0, _S4464.differential_0 }; + DiffPair_float_0 _S4467 = { _S4465, 0.0f }; + DiffPair_float_0 _S4468; + (&_S4468)->primal_0 = _S4464.primal_0; + (&_S4468)->differential_0 = _S4464.differential_0; + DiffPair_float_0 _S4469; + (&_S4469)->primal_0 = _S4465; + (&_S4469)->differential_0 = 0.0f; + DiffPair_float_0 _S4470 = s_primal_ctx_d_atan2_0(&_S4468, &_S4469); + bool _S4471 = (_S4470.primal_0) < 0.00100000004749745f; + float k_20; + float s_diff_k_10; + if(_S4471) + { + float _S4472 = _S4470.differential_0 * _S4470.primal_0; + float _S4473 = (0.0f - (_S4472 + _S4472) * 0.3333333432674408f) * _S4465 / (_S4465 * _S4465); + k_20 = (1.0f - _S4470.primal_0 * _S4470.primal_0 / 3.0f) / _S4465; + s_diff_k_10 = _S4473; + } + else + { + float _S4474 = (_S4470.differential_0 * _S4464.primal_0 - _S4470.primal_0 * _S4464.differential_0) / (_S4464.primal_0 * _S4464.primal_0); + k_20 = _S4470.primal_0 / _S4464.primal_0; + s_diff_k_10 = _S4474; + } + float2 _S4475 = _S4460 * make_float2 (k_20); + float2 _S4476 = _S4461 * make_float2 (k_20) + make_float2 (s_diff_k_10) * _S4460; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4477; + (&_S4477)->primal_0 = _S4475; + (&_S4477)->differential_0 = _S4476; + FixedArray _S4478 = dist_coeffs_38; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4479 = s_primal_ctx_s_fwd_DistNone_distort_0(&_S4477, &_S4478); + (&_S4459)->_S4382 = _S4479; + float2 _S4480 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4481 = { _S4460, _S4480 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4482; + (&_S4482)->primal_0 = _S4460; + (&_S4482)->differential_0 = _S4480; + DiffPair_float_0 _S4483 = s_primal_ctx_s_fwd_length_impl_0(&_S4482); + DiffPair_float_0 _S4484 = { _S4483.primal_0, _S4483.differential_0 }; + DiffPair_float_0 _S4485; + (&_S4485)->primal_0 = _S4483.primal_0; + (&_S4485)->differential_0 = _S4483.differential_0; + DiffPair_float_0 _S4486; + (&_S4486)->primal_0 = _S4465; + (&_S4486)->differential_0 = 0.0f; + DiffPair_float_0 _S4487 = s_primal_ctx_d_atan2_0(&_S4485, &_S4486); + bool _S4488 = (_S4487.primal_0) < 0.00100000004749745f; + if(_S4488) + { + float _S4489 = _S4487.differential_0 * _S4487.primal_0; + float _S4490 = (0.0f - (_S4489 + _S4489) * 0.3333333432674408f) * _S4465 / (_S4465 * _S4465); + k_20 = (1.0f - _S4487.primal_0 * _S4487.primal_0 / 3.0f) / _S4465; + s_diff_k_10 = _S4490; + } + else + { + float _S4491 = (_S4487.differential_0 * _S4483.primal_0 - _S4487.primal_0 * _S4483.differential_0) / (_S4483.primal_0 * _S4483.primal_0); + k_20 = _S4487.primal_0 / _S4483.primal_0; + s_diff_k_10 = _S4491; + } + float2 _S4492 = _S4460 * make_float2 (k_20); + float2 _S4493 = _S4480 * make_float2 (k_20) + make_float2 (s_diff_k_10) * _S4460; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4494; + (&_S4494)->primal_0 = _S4492; + (&_S4494)->differential_0 = _S4493; + FixedArray _S4495 = dist_coeffs_38; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4496 = s_primal_ctx_s_fwd_DistNone_distort_0(&_S4494, &_S4495); + (&_S4459)->_S4383 = _S4496; + float2 _S4497 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4498 = { _S4460, _S4497 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4499; + (&_S4499)->primal_0 = _S4460; + (&_S4499)->differential_0 = _S4497; + DiffPair_float_0 _S4500 = s_primal_ctx_s_fwd_length_impl_0(&_S4499); + DiffPair_float_0 _S4501 = { _S4500.primal_0, _S4500.differential_0 }; + DiffPair_float_0 _S4502 = { _S4465, 1.0f }; + DiffPair_float_0 _S4503; + (&_S4503)->primal_0 = _S4500.primal_0; + (&_S4503)->differential_0 = _S4500.differential_0; + DiffPair_float_0 _S4504; + (&_S4504)->primal_0 = _S4465; + (&_S4504)->differential_0 = 1.0f; + DiffPair_float_0 _S4505 = s_primal_ctx_d_atan2_0(&_S4503, &_S4504); + bool _S4506 = (_S4505.primal_0) < 0.00100000004749745f; + if(_S4506) + { + float _S4507 = _S4505.differential_0 * _S4505.primal_0; + float _S4508 = 1.0f - _S4505.primal_0 * _S4505.primal_0 / 3.0f; + float _S4509 = ((0.0f - (_S4507 + _S4507) * 0.3333333432674408f) * _S4465 - _S4508) / (_S4465 * _S4465); + k_20 = _S4508 / _S4465; + s_diff_k_10 = _S4509; + } + else + { + float _S4510 = (_S4505.differential_0 * _S4500.primal_0 - _S4505.primal_0 * _S4500.differential_0) / (_S4500.primal_0 * _S4500.primal_0); + k_20 = _S4505.primal_0 / _S4500.primal_0; + s_diff_k_10 = _S4510; + } + float2 _S4511 = _S4460 * make_float2 (k_20); + float2 _S4512 = make_float2 (s_diff_k_10) * _S4460; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4513; + (&_S4513)->primal_0 = _S4511; + (&_S4513)->differential_0 = _S4512; + FixedArray _S4514 = dist_coeffs_38; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4515 = s_primal_ctx_s_fwd_DistNone_distort_0(&_S4513, &_S4514); + (&_S4459)->_S4384 = _S4515; + s_bwd_prop_DiffProjection3DGS_3dgs_fisheye_none_projection_Intermediates_0 _S4516 = _S4459; + float _S4517 = - in_opacity_26; + float _S4518 = 1.0f + s_primal_ctx_exp_0(_S4517); + float _S4519 = 1.0f / _S4518; + float _S4520 = _S4518 * _S4518; + float4 _S4521 = normalize_0(quat_26); + float3 _S4522 = s_primal_ctx_exp_1(scale_26); + float _S4523 = _S4521.y; + float x2_26 = _S4523 * _S4523; + float y2_26 = _S4521.z * _S4521.z; + float z2_26 = _S4521.w * _S4521.w; + float xy_26 = _S4521.y * _S4521.z; + float xz_26 = _S4521.y * _S4521.w; + float yz_26 = _S4521.z * _S4521.w; + float wx_26 = _S4521.x * _S4521.y; + float wy_26 = _S4521.x * _S4521.z; + float wz_26 = _S4521.x * _S4521.w; + Matrix _S4524 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_26 + z2_26), 2.0f * (xy_26 + wz_26), 2.0f * (xz_26 - wy_26), 2.0f * (xy_26 - wz_26), 1.0f - 2.0f * (x2_26 + z2_26), 2.0f * (yz_26 + wx_26), 2.0f * (xz_26 + wy_26), 2.0f * (yz_26 - wx_26), 1.0f - 2.0f * (x2_26 + y2_26))); + Matrix S_4 = makeMatrix (_S4522.x, 0.0f, 0.0f, 0.0f, _S4522.y, 0.0f, 0.0f, 0.0f, _S4522.z); + Matrix _S4525 = s_primal_ctx_mul_1(_S4524, S_4); + Matrix _S4526 = transpose_3(_S4525); + Matrix _S4527 = s_primal_ctx_mul_1(_S4525, _S4526); + Matrix _S4528 = s_primal_ctx_mul_1(R_26, _S4527); + Matrix _S4529 = transpose_3(R_26); + Matrix _S4530 = s_primal_ctx_mul_1(_S4528, _S4529); + Matrix J_36 = makeMatrix (0.0f); + float _S4531; + float _S4532; + float _S4533; + float _S4534; + float _S4535; + float _S4536; + float _S4537; + float _S4538; + if(_S4471) + { + float _S4539 = _S4470.differential_0 * _S4470.primal_0; + float _S4540 = 1.0f - _S4470.primal_0 * _S4470.primal_0 / 3.0f; + float _S4541 = 0.0f - (_S4539 + _S4539) * 0.3333333432674408f; + float _S4542 = _S4465 * _S4465; + float _S4543 = _S4541 * _S4465; + float _S4544 = _S4543 / _S4542; + float _S4545 = _S4542 * _S4542; + k_20 = _S4540 / _S4465; + s_diff_k_10 = _S4544; + _S4531 = _S4545; + _S4532 = _S4543; + _S4533 = _S4542; + _S4534 = _S4540; + _S4535 = _S4541; + _S4536 = 0.0f; + _S4537 = 0.0f; + _S4538 = 0.0f; + } + else + { + float _S4546 = _S4464.primal_0 * _S4464.primal_0; + float _S4547 = _S4470.differential_0 * _S4464.primal_0 - _S4470.primal_0 * _S4464.differential_0; + float _S4548 = _S4547 / _S4546; + float _S4549 = _S4546 * _S4546; + k_20 = _S4470.primal_0 / _S4464.primal_0; + s_diff_k_10 = _S4548; + _S4531 = 0.0f; + _S4532 = 0.0f; + _S4533 = 0.0f; + _S4534 = 0.0f; + _S4535 = 0.0f; + _S4536 = _S4549; + _S4537 = _S4547; + _S4538 = _S4546; + } + float2 _S4550 = make_float2 (k_20); + float2 _S4551 = make_float2 (s_diff_k_10); + float2 _S4552 = _S4460 * make_float2 (k_20); + float2 _S4553 = _S4461 * make_float2 (k_20) + make_float2 (s_diff_k_10) * _S4460; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4554 = { _S4552, _S4553 }; + float _S4555 = _S4516._S4382.differential_0.x * fx_39; + float _S4556 = _S4516._S4382.differential_0.y * fy_39; + Matrix _S4557 = J_36; + *&(((&_S4557)->rows + (int(0)))->x) = _S4555; + *&(((&_S4557)->rows + (int(1)))->x) = _S4556; + float _S4558; + float _S4559; + float _S4560; + float _S4561; + float _S4562; + float _S4563; + float _S4564; + float _S4565; + if(_S4488) + { + float _S4566 = _S4487.differential_0 * _S4487.primal_0; + float _S4567 = 1.0f - _S4487.primal_0 * _S4487.primal_0 / 3.0f; + float _S4568 = 0.0f - (_S4566 + _S4566) * 0.3333333432674408f; + float _S4569 = _S4465 * _S4465; + float _S4570 = _S4568 * _S4465; + float _S4571 = _S4570 / _S4569; + float _S4572 = _S4569 * _S4569; + k_20 = _S4567 / _S4465; + s_diff_k_10 = _S4571; + _S4558 = _S4572; + _S4559 = _S4570; + _S4560 = _S4569; + _S4561 = _S4567; + _S4562 = _S4568; + _S4563 = 0.0f; + _S4564 = 0.0f; + _S4565 = 0.0f; + } + else + { + float _S4573 = _S4483.primal_0 * _S4483.primal_0; + float _S4574 = _S4487.differential_0 * _S4483.primal_0 - _S4487.primal_0 * _S4483.differential_0; + float _S4575 = _S4574 / _S4573; + float _S4576 = _S4573 * _S4573; + k_20 = _S4487.primal_0 / _S4483.primal_0; + s_diff_k_10 = _S4575; + _S4558 = 0.0f; + _S4559 = 0.0f; + _S4560 = 0.0f; + _S4561 = 0.0f; + _S4562 = 0.0f; + _S4563 = _S4576; + _S4564 = _S4574; + _S4565 = _S4573; + } + float2 _S4577 = make_float2 (k_20); + float2 _S4578 = make_float2 (s_diff_k_10); + float2 _S4579 = _S4460 * make_float2 (k_20); + float2 _S4580 = _S4480 * make_float2 (k_20) + make_float2 (s_diff_k_10) * _S4460; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4581 = { _S4579, _S4580 }; + float _S4582 = _S4516._S4383.differential_0.y * fy_39; + *&(((&_S4557)->rows + (int(0)))->y) = _S4516._S4383.differential_0.x * fx_39; + *&(((&_S4557)->rows + (int(1)))->y) = _S4582; + float _S4583; + float _S4584; + float _S4585; + float _S4586; + float _S4587; + float _S4588; + float _S4589; + float _S4590; + if(_S4506) + { + float _S4591 = _S4505.differential_0 * _S4505.primal_0; + float _S4592 = 1.0f - _S4505.primal_0 * _S4505.primal_0 / 3.0f; + float _S4593 = 0.0f - (_S4591 + _S4591) * 0.3333333432674408f; + float _S4594 = _S4465 * _S4465; + float _S4595 = _S4593 * _S4465 - _S4592; + float _S4596 = _S4595 / _S4594; + float _S4597 = _S4594 * _S4594; + k_20 = _S4592 / _S4465; + s_diff_k_10 = _S4596; + _S4583 = _S4597; + _S4584 = _S4595; + _S4585 = _S4594; + _S4586 = _S4592; + _S4587 = _S4593; + _S4588 = 0.0f; + _S4589 = 0.0f; + _S4590 = 0.0f; + } + else + { + float _S4598 = _S4500.primal_0 * _S4500.primal_0; + float _S4599 = _S4505.differential_0 * _S4500.primal_0 - _S4505.primal_0 * _S4500.differential_0; + float _S4600 = _S4599 / _S4598; + float _S4601 = _S4598 * _S4598; + k_20 = _S4505.primal_0 / _S4500.primal_0; + s_diff_k_10 = _S4600; + _S4583 = 0.0f; + _S4584 = 0.0f; + _S4585 = 0.0f; + _S4586 = 0.0f; + _S4587 = 0.0f; + _S4588 = _S4601; + _S4589 = _S4599; + _S4590 = _S4598; + } + float2 _S4602 = make_float2 (k_20); + float2 _S4603 = make_float2 (s_diff_k_10); + float2 _S4604 = _S4460 * make_float2 (k_20); + float2 _S4605 = make_float2 (s_diff_k_10) * _S4460; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4606 = { _S4604, _S4605 }; + float _S4607 = _S4516._S4384.differential_0.y * fy_39; + *&(((&_S4557)->rows + (int(0)))->z) = _S4516._S4384.differential_0.x * fx_39; + *&(((&_S4557)->rows + (int(1)))->z) = _S4607; + Matrix _S4608 = s_primal_ctx_mul_2(_S4557, _S4530); + Matrix _S4609 = transpose_1(_S4557); + Matrix _S4610 = s_primal_ctx_mul_3(_S4608, _S4609); + float eps2d_26; + if(antialiased_26) + { + eps2d_26 = 0.10000000149011612f; + } + else + { + eps2d_26 = 0.30000001192092896f; + } + float _S4611 = _S4610.rows[int(0)].y * _S4610.rows[int(1)].x; + float det_orig_26 = _S4610.rows[int(0)].x * _S4610.rows[int(1)].y - _S4611; + float _S4612 = _S4610.rows[int(0)].x + eps2d_26; + Matrix _S4613 = _S4610; + *&(((&_S4613)->rows + (int(0)))->x) = _S4612; + float _S4614 = _S4610.rows[int(1)].y + eps2d_26; + *&(((&_S4613)->rows + (int(1)))->y) = _S4614; + Matrix _S4615 = _S4613; + Matrix _S4616 = _S4613; + float det_blur_26 = _S4612 * _S4614 - _S4611; + float _S4617 = det_orig_26 / det_blur_26; + float _S4618 = det_blur_26 * det_blur_26; + float _S4619 = (F32_max((0.0f), (_S4617))); + float _S4620 = s_primal_ctx_sqrt_0(_S4619); + float invdet_32 = 1.0f / det_blur_26; + float _S4621 = - _S4610.rows[int(0)].y; + float _S4622 = - _S4610.rows[int(1)].x; + if(antialiased_26) + { + k_20 = _S4519 * _S4620; + } + else + { + k_20 = _S4519; + } + float _S4623 = k_20 / 0.00392156885936856f; + float _S4624 = 2.0f * s_primal_ctx_log_0(_S4623); + float _S4625 = s_primal_ctx_sqrt_0(_S4624); + float _S4626 = _S4615.rows[int(0)].x; + float _S4627 = _S4616.rows[int(1)].y; + float3 campos_5 = - s_primal_ctx_mul_0(_S4529, t_26); + float3 _S4628 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4629; + (&_S4629)->primal_0 = mean_27; + (&_S4629)->differential_0 = _S4628; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4630; + (&_S4630)->primal_0 = scale_26; + (&_S4630)->differential_0 = _S4628; + DiffPair_float_0 _S4631; + (&_S4631)->primal_0 = in_opacity_26; + (&_S4631)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4632; + (&_S4632)->primal_0 = campos_5; + (&_S4632)->differential_0 = _S4628; + s_bwd_prop_view_radius_3dgs_0(&_S4629, &_S4630, &_S4631, &_S4632, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4633 = _S4629; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4634 = _S4630; + DiffPair_float_0 _S4635 = _S4631; + float2 _S4636 = _S4457; + *&((&_S4636)->y) = v_conic_4.z; + float2 _S4637 = _S4457; + *&((&_S4637)->y) = v_conic_4.y; + *&((&_S4637)->x) = v_conic_4.x; + DiffPair_float_0 _S4638; + (&_S4638)->primal_0 = _S4627; + (&_S4638)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4638, 0.0f); + DiffPair_float_0 _S4639; + (&_S4639)->primal_0 = _S4626; + (&_S4639)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4639, 0.0f); + DiffPair_float_0 _S4640; + (&_S4640)->primal_0 = 3.32999992370605469f; + (&_S4640)->differential_0 = 0.0f; + DiffPair_float_0 _S4641; + (&_S4641)->primal_0 = _S4625; + (&_S4641)->differential_0 = 0.0f; + _d_min_0(&_S4640, &_S4641, 0.0f); + DiffPair_float_0 _S4642; + (&_S4642)->primal_0 = _S4624; + (&_S4642)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4642, _S4641.differential_0); + float _S4643 = 2.0f * _S4642.differential_0; + DiffPair_float_0 _S4644; + (&_S4644)->primal_0 = _S4623; + (&_S4644)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S4644, _S4643); + float _S4645 = v_opacity_4 + 254.9999847412109375f * _S4644.differential_0; + Matrix _S4646 = makeMatrix (0.0f); + Matrix _S4647 = _S4646; + _S4647[int(1)] = _S4636; + _S4647[int(0)] = _S4637; + Matrix _S4648 = _S4647; + float2 _S4649 = make_float2 (0.0f, _S4638.differential_0); + float2 _S4650 = make_float2 (_S4639.differential_0, 0.0f); + if(antialiased_26) + { + float _S4651 = _S4620 * _S4645; + k_20 = _S4519 * _S4645; + s_diff_k_10 = _S4651; + } + else + { + k_20 = 0.0f; + s_diff_k_10 = _S4645; + } + float _S4652 = invdet_32 * _S4648.rows[int(1)].y; + float _S4653 = - (invdet_32 * _S4648.rows[int(1)].x); + float _S4654 = - (invdet_32 * _S4648.rows[int(0)].y); + float _S4655 = invdet_32 * _S4648.rows[int(0)].x; + float _S4656 = - ((_S4612 * _S4648.rows[int(1)].y + _S4622 * _S4648.rows[int(1)].x + _S4621 * _S4648.rows[int(0)].y + _S4614 * _S4648.rows[int(0)].x) / _S4618); + DiffPair_float_0 _S4657; + (&_S4657)->primal_0 = _S4619; + (&_S4657)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S4657, k_20); + DiffPair_float_0 _S4658 = { 0.0f, 0.0f }; + DiffPair_float_0 _S4659; + (&_S4659)->primal_0 = 0.0f; + (&_S4659)->differential_0 = 0.0f; + DiffPair_float_0 _S4660; + (&_S4660)->primal_0 = _S4617; + (&_S4660)->differential_0 = 0.0f; + _d_max_0(&_S4659, &_S4660, _S4657.differential_0); + float _S4661 = _S4660.differential_0 / _S4618; + float s_diff_det_orig_T_4 = det_blur_26 * _S4661; + float _S4662 = det_orig_26 * - _S4661 + _S4656; + float _S4663 = - _S4662; + float _S4664 = _S4612 * _S4662; + float _S4665 = _S4614 * _S4662; + Matrix _S4666 = _S4646; + _S4666[int(1)] = _S4649; + _S4666[int(0)] = _S4650; + _S4613 = _S4666; + *&(((&_S4613)->rows + (int(1)))->y) = 0.0f; + float _S4667 = _S4664 + _S4666.rows[int(1)].y + _S4655; + *&(((&_S4613)->rows + (int(0)))->x) = 0.0f; + float _S4668 = _S4665 + _S4666.rows[int(0)].x + _S4652; + float _S4669 = _S4663 + - s_diff_det_orig_T_4; + float _S4670 = _S4610.rows[int(0)].y * _S4669 + _S4653; + float _S4671 = _S4610.rows[int(1)].x * _S4669 + _S4654; + float _S4672 = _S4610.rows[int(1)].y * s_diff_det_orig_T_4; + float _S4673 = _S4667 + _S4610.rows[int(0)].x * s_diff_det_orig_T_4; + float2 _S4674 = _S4457; + *&((&_S4674)->x) = _S4670; + *&((&_S4674)->y) = _S4673; + float _S4675 = _S4668 + _S4672; + float2 _S4676 = _S4457; + *&((&_S4676)->y) = _S4671; + *&((&_S4676)->x) = _S4675; + Matrix _S4677 = _S4646; + _S4677[int(1)] = _S4674; + _S4677[int(0)] = _S4676; + Matrix _S4678 = _S4613 + _S4677; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S4679; + (&_S4679)->primal_0 = _S4608; + (&_S4679)->differential_0 = J_36; + Matrix _S4680 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S4681; + (&_S4681)->primal_0 = _S4609; + (&_S4681)->differential_0 = _S4680; + s_bwd_prop_mul_0(&_S4679, &_S4681, _S4678); + Matrix _S4682 = transpose_2(_S4681.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S4683; + (&_S4683)->primal_0 = _S4557; + (&_S4683)->differential_0 = J_36; + Matrix _S4684 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4685; + (&_S4685)->primal_0 = _S4530; + (&_S4685)->differential_0 = _S4684; + s_bwd_prop_mul_1(&_S4683, &_S4685, _S4679.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4686 = _S4685; + Matrix _S4687 = _S4682 + _S4683.differential_0; + float2 _S4688 = make_float2 (fx_39 * _S4687.rows[int(0)].z, fy_39 * _S4687.rows[int(1)].z); + DiffPair_0 _S4689; + (&_S4689)->primal_0 = _S4606; + (&_S4689)->differential_0 = _S4458; + FixedArray _S4690 = dist_coeffs_38; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4691; + (&_S4691)->primal_0 = _S4497; + (&_S4691)->differential_0 = _S4688; + s_bwd_prop_s_fwd_DistNone_distort_0(&_S4689, &_S4690, &_S4691); + float2 _S4692 = _S4460 * _S4689.differential_0.differential_0; + float2 _S4693 = _S4460 * _S4689.differential_0.primal_0; + float _S4694 = _S4693.x + _S4693.y; + float _S4695 = _S4692.x + _S4692.y; + float2 _S4696 = _S4603 * _S4689.differential_0.differential_0 + _S4602 * _S4689.differential_0.primal_0; + if(_S4506) + { + float _S4697 = _S4695 / _S4583; + float _S4698 = _S4585 * _S4697; + float _S4699 = _S4465 * (_S4584 * - _S4697); + float _S4700 = _S4694 / _S4585; + float _S4701 = 0.3333333432674408f * - (_S4465 * _S4698); + float _S4702 = _S4701 + _S4701; + float _S4703 = _S4505.primal_0 * (0.3333333432674408f * - (- _S4698 + _S4465 * _S4700)); + float _S4704 = _S4699 + _S4699 + _S4587 * _S4698 + _S4586 * - _S4700; + float _S4705 = _S4505.differential_0 * _S4702 + _S4703 + _S4703; + k_20 = _S4505.primal_0 * _S4702; + _S4583 = _S4705; + _S4584 = _S4704; + _S4585 = 0.0f; + _S4586 = 0.0f; + } + else + { + float _S4706 = _S4695 / _S4588; + float _S4707 = _S4590 * _S4706; + float _S4708 = _S4500.primal_0 * (_S4589 * - _S4706); + float _S4709 = - _S4707; + float _S4710 = _S4505.primal_0 * _S4709; + float _S4711 = _S4694 / _S4590; + float _S4712 = _S4708 + _S4708 + _S4505.differential_0 * _S4707 + _S4505.primal_0 * - _S4711; + float _S4713 = _S4500.differential_0 * _S4709 + _S4500.primal_0 * _S4711; + k_20 = _S4500.primal_0 * _S4707; + _S4583 = _S4713; + _S4584 = 0.0f; + _S4585 = _S4710; + _S4586 = _S4712; + } + DiffPair_1 _S4714; + (&_S4714)->primal_0 = _S4501; + (&_S4714)->differential_0 = _S4658; + DiffPair_1 _S4715; + (&_S4715)->primal_0 = _S4502; + (&_S4715)->differential_0 = _S4658; + DiffPair_float_0 _S4716; + (&_S4716)->primal_0 = _S4583; + (&_S4716)->differential_0 = k_20; + s_bwd_prop_d_atan2_0(&_S4714, &_S4715, &_S4716); + float _S4717 = _S4715.differential_0.primal_0 + _S4584; + float _S4718 = _S4714.differential_0.differential_0 + _S4585; + float _S4719 = _S4714.differential_0.primal_0 + _S4586; + DiffPair_0 _S4720; + (&_S4720)->primal_0 = _S4498; + (&_S4720)->differential_0 = _S4458; + DiffPair_float_0 _S4721; + (&_S4721)->primal_0 = _S4719; + (&_S4721)->differential_0 = _S4718; + s_bwd_prop_s_fwd_length_impl_0(&_S4720, &_S4721); + float2 _S4722 = _S4720.differential_0.primal_0 + _S4696; + float3 _S4723 = make_float3 (_S4722.x, _S4722.y, _S4717); + float2 _S4724 = make_float2 (fx_39 * _S4687.rows[int(0)].y, fy_39 * _S4687.rows[int(1)].y); + DiffPair_0 _S4725; + (&_S4725)->primal_0 = _S4581; + (&_S4725)->differential_0 = _S4458; + FixedArray _S4726 = dist_coeffs_38; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4727; + (&_S4727)->primal_0 = _S4497; + (&_S4727)->differential_0 = _S4724; + s_bwd_prop_s_fwd_DistNone_distort_0(&_S4725, &_S4726, &_S4727); + DiffPair_0 _S4728 = _S4725; + float2 _S4729 = _S4460 * _S4728.differential_0.differential_0; + float2 _S4730 = _S4480 * _S4728.differential_0.differential_0; + float2 _S4731 = _S4460 * _S4728.differential_0.primal_0; + float _S4732 = _S4730.x + _S4730.y + _S4731.x + _S4731.y; + float _S4733 = _S4729.x + _S4729.y; + float2 _S4734 = _S4578 * _S4728.differential_0.differential_0 + _S4577 * _S4728.differential_0.primal_0; + if(_S4488) + { + float _S4735 = _S4733 / _S4558; + float _S4736 = _S4560 * _S4735; + float _S4737 = _S4465 * (_S4559 * - _S4735); + float _S4738 = _S4732 / _S4560; + float _S4739 = 0.3333333432674408f * - (_S4465 * _S4736); + float _S4740 = _S4739 + _S4739; + float _S4741 = _S4487.primal_0 * (0.3333333432674408f * - (_S4465 * _S4738)); + float _S4742 = _S4737 + _S4737 + _S4562 * _S4736 + _S4561 * - _S4738; + float _S4743 = _S4487.differential_0 * _S4740 + _S4741 + _S4741; + k_20 = _S4487.primal_0 * _S4740; + _S4558 = _S4743; + _S4559 = _S4742; + _S4560 = 0.0f; + _S4561 = 0.0f; + } + else + { + float _S4744 = _S4733 / _S4563; + float _S4745 = _S4565 * _S4744; + float _S4746 = _S4483.primal_0 * (_S4564 * - _S4744); + float _S4747 = - _S4745; + float _S4748 = _S4487.primal_0 * _S4747; + float _S4749 = _S4732 / _S4565; + float _S4750 = _S4746 + _S4746 + _S4487.differential_0 * _S4745 + _S4487.primal_0 * - _S4749; + float _S4751 = _S4483.differential_0 * _S4747 + _S4483.primal_0 * _S4749; + k_20 = _S4483.primal_0 * _S4745; + _S4558 = _S4751; + _S4559 = 0.0f; + _S4560 = _S4748; + _S4561 = _S4750; + } + DiffPair_1 _S4752; + (&_S4752)->primal_0 = _S4484; + (&_S4752)->differential_0 = _S4658; + DiffPair_1 _S4753; + (&_S4753)->primal_0 = _S4467; + (&_S4753)->differential_0 = _S4658; + DiffPair_float_0 _S4754; + (&_S4754)->primal_0 = _S4558; + (&_S4754)->differential_0 = k_20; + s_bwd_prop_d_atan2_0(&_S4752, &_S4753, &_S4754); + float _S4755 = _S4753.differential_0.primal_0 + _S4559; + float _S4756 = _S4752.differential_0.differential_0 + _S4560; + float _S4757 = _S4752.differential_0.primal_0 + _S4561; + DiffPair_0 _S4758; + (&_S4758)->primal_0 = _S4481; + (&_S4758)->differential_0 = _S4458; + DiffPair_float_0 _S4759; + (&_S4759)->primal_0 = _S4757; + (&_S4759)->differential_0 = _S4756; + s_bwd_prop_s_fwd_length_impl_0(&_S4758, &_S4759); + float2 _S4760 = _S4758.differential_0.primal_0 + _S4734; + float3 _S4761 = make_float3 (_S4760.x, _S4760.y, _S4755); + float2 _S4762 = make_float2 (fx_39 * _S4687.rows[int(0)].x, fy_39 * _S4687.rows[int(1)].x); + DiffPair_0 _S4763; + (&_S4763)->primal_0 = _S4554; + (&_S4763)->differential_0 = _S4458; + FixedArray _S4764 = dist_coeffs_38; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4765; + (&_S4765)->primal_0 = _S4497; + (&_S4765)->differential_0 = _S4762; + s_bwd_prop_s_fwd_DistNone_distort_0(&_S4763, &_S4764, &_S4765); + DiffPair_0 _S4766 = _S4763; + float3 _S4767 = _S4761 + _S4723; + float2 _S4768 = _S4460 * _S4766.differential_0.differential_0; + float2 _S4769 = _S4461 * _S4766.differential_0.differential_0; + float2 _S4770 = _S4460 * _S4766.differential_0.primal_0; + float _S4771 = _S4769.x + _S4769.y + _S4770.x + _S4770.y; + float _S4772 = _S4768.x + _S4768.y; + float2 _S4773 = _S4551 * _S4766.differential_0.differential_0 + _S4550 * _S4766.differential_0.primal_0; + if(_S4471) + { + float _S4774 = _S4772 / _S4531; + float _S4775 = _S4533 * _S4774; + float _S4776 = _S4465 * (_S4532 * - _S4774); + float _S4777 = _S4771 / _S4533; + float _S4778 = 0.3333333432674408f * - (_S4465 * _S4775); + float _S4779 = _S4778 + _S4778; + float _S4780 = _S4470.primal_0 * (0.3333333432674408f * - (_S4465 * _S4777)); + float _S4781 = _S4776 + _S4776 + _S4535 * _S4775 + _S4534 * - _S4777; + float _S4782 = _S4470.differential_0 * _S4779 + _S4780 + _S4780; + k_20 = _S4470.primal_0 * _S4779; + _S4531 = _S4782; + _S4532 = _S4781; + _S4533 = 0.0f; + _S4534 = 0.0f; + } + else + { + float _S4783 = _S4772 / _S4536; + float _S4784 = _S4538 * _S4783; + float _S4785 = _S4464.primal_0 * (_S4537 * - _S4783); + float _S4786 = - _S4784; + float _S4787 = _S4470.primal_0 * _S4786; + float _S4788 = _S4771 / _S4538; + float _S4789 = _S4785 + _S4785 + _S4470.differential_0 * _S4784 + _S4470.primal_0 * - _S4788; + float _S4790 = _S4464.differential_0 * _S4786 + _S4464.primal_0 * _S4788; + k_20 = _S4464.primal_0 * _S4784; + _S4531 = _S4790; + _S4532 = 0.0f; + _S4533 = _S4787; + _S4534 = _S4789; + } + DiffPair_1 _S4791; + (&_S4791)->primal_0 = _S4466; + (&_S4791)->differential_0 = _S4658; + DiffPair_1 _S4792; + (&_S4792)->primal_0 = _S4467; + (&_S4792)->differential_0 = _S4658; + DiffPair_float_0 _S4793; + (&_S4793)->primal_0 = _S4531; + (&_S4793)->differential_0 = k_20; + s_bwd_prop_d_atan2_0(&_S4791, &_S4792, &_S4793); + float _S4794 = _S4792.differential_0.primal_0 + _S4532; + float _S4795 = _S4791.differential_0.differential_0 + _S4533; + float _S4796 = _S4791.differential_0.primal_0 + _S4534; + DiffPair_0 _S4797; + (&_S4797)->primal_0 = _S4462; + (&_S4797)->differential_0 = _S4458; + DiffPair_float_0 _S4798; + (&_S4798)->primal_0 = _S4796; + (&_S4798)->differential_0 = _S4795; + s_bwd_prop_s_fwd_length_impl_0(&_S4797, &_S4798); + float2 _S4799 = _S4797.differential_0.primal_0 + _S4773; + float3 _S4800 = make_float3 (_S4799.x, _S4799.y, _S4794); + float _S4801 = length_0(_S4460); + float _S4802 = s_primal_ctx_atan2_0(_S4801, _S4465); + bool _S4803 = _S4802 < 0.00100000004749745f; + if(_S4803) + { + float _S4804 = 1.0f - _S4802 * _S4802 / 3.0f; + float _S4805 = _S4465 * _S4465; + k_20 = _S4804 / _S4465; + _S4531 = _S4805; + _S4532 = _S4804; + _S4533 = 0.0f; + } + else + { + float _S4806 = _S4801 * _S4801; + k_20 = _S4802 / _S4801; + _S4531 = 0.0f; + _S4532 = 0.0f; + _S4533 = _S4806; + } + float2 _S4807 = make_float2 (k_20); + float2 _S4808 = _S4460 * make_float2 (k_20); + float2 _S4809 = make_float2 (fx_39 * v_mean2d_4.x, fy_39 * v_mean2d_4.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4810; + (&_S4810)->primal_0 = _S4808; + (&_S4810)->differential_0 = _S4457; + FixedArray _S4811 = dist_coeffs_38; + s_bwd_prop_DistNone_distort_0(&_S4810, &_S4811, _S4809); + float2 _S4812 = _S4460 * _S4810.differential_0; + float2 _S4813 = _S4807 * _S4810.differential_0; + float _S4814 = _S4812.x + _S4812.y; + if(_S4803) + { + float _S4815 = _S4814 / _S4531; + float _S4816 = _S4532 * - _S4815; + float _S4817 = _S4802 * (0.3333333432674408f * - (_S4465 * _S4815)); + k_20 = _S4817 + _S4817; + _S4531 = _S4816; + _S4532 = 0.0f; + } + else + { + float _S4818 = _S4814 / _S4533; + float _S4819 = _S4802 * - _S4818; + k_20 = _S4801 * _S4818; + _S4531 = 0.0f; + _S4532 = _S4819; + } + DiffPair_float_0 _S4820; + (&_S4820)->primal_0 = _S4801; + (&_S4820)->differential_0 = 0.0f; + DiffPair_float_0 _S4821; + (&_S4821)->primal_0 = _S4465; + (&_S4821)->differential_0 = 0.0f; + s_bwd_prop_atan2_0(&_S4820, &_S4821, k_20); + float _S4822 = _S4821.differential_0 + _S4531; + float _S4823 = _S4820.differential_0 + _S4532; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4824; + (&_S4824)->primal_0 = _S4460; + (&_S4824)->differential_0 = _S4457; + s_bwd_length_impl_2(&_S4824, _S4823); + float2 _S4825 = _S4824.differential_0 + _S4813; + float3 _S4826 = make_float3 (_S4825.x, _S4825.y, _S4822); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4827; + (&_S4827)->primal_0 = _S4528; + (&_S4827)->differential_0 = _S4684; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4828; + (&_S4828)->primal_0 = _S4529; + (&_S4828)->differential_0 = _S4684; + s_bwd_prop_mul_2(&_S4827, &_S4828, _S4686.differential_0); + Matrix _S4829 = transpose_3(_S4828.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4830; + (&_S4830)->primal_0 = R_26; + (&_S4830)->differential_0 = _S4684; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4831; + (&_S4831)->primal_0 = _S4527; + (&_S4831)->differential_0 = _S4684; + s_bwd_prop_mul_2(&_S4830, &_S4831, _S4827.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4832; + (&_S4832)->primal_0 = _S4525; + (&_S4832)->differential_0 = _S4684; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4833; + (&_S4833)->primal_0 = _S4526; + (&_S4833)->differential_0 = _S4684; + s_bwd_prop_mul_2(&_S4832, &_S4833, _S4831.differential_0); + Matrix _S4834 = _S4832.differential_0 + transpose_3(_S4833.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4835; + (&_S4835)->primal_0 = _S4524; + (&_S4835)->differential_0 = _S4684; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4836; + (&_S4836)->primal_0 = S_4; + (&_S4836)->differential_0 = _S4684; + s_bwd_prop_mul_2(&_S4835, &_S4836, _S4834); + Matrix _S4837 = transpose_3(_S4835.differential_0); + float _S4838 = 2.0f * - _S4837.rows[int(2)].z; + float _S4839 = 2.0f * _S4837.rows[int(2)].y; + float _S4840 = 2.0f * _S4837.rows[int(2)].x; + float _S4841 = 2.0f * _S4837.rows[int(1)].z; + float _S4842 = 2.0f * - _S4837.rows[int(1)].y; + float _S4843 = 2.0f * _S4837.rows[int(1)].x; + float _S4844 = 2.0f * _S4837.rows[int(0)].z; + float _S4845 = 2.0f * _S4837.rows[int(0)].y; + float _S4846 = 2.0f * - _S4837.rows[int(0)].x; + float _S4847 = - _S4843 + _S4845; + float _S4848 = _S4840 + - _S4844; + float _S4849 = - _S4839 + _S4841; + float _S4850 = _S4839 + _S4841; + float _S4851 = _S4840 + _S4844; + float _S4852 = _S4843 + _S4845; + float _S4853 = _S4521.w * (_S4842 + _S4846); + float _S4854 = _S4521.z * (_S4838 + _S4846); + float _S4855 = _S4521.y * (_S4838 + _S4842); + float _S4856 = _S4521.x * _S4847 + _S4521.z * _S4850 + _S4521.y * _S4851 + _S4853 + _S4853; + float _S4857 = _S4521.x * _S4848 + _S4521.w * _S4850 + _S4521.y * _S4852 + _S4854 + _S4854; + float _S4858 = _S4521.x * _S4849 + _S4521.w * _S4851 + _S4521.z * _S4852 + _S4855 + _S4855; + float _S4859 = _S4521.w * _S4847 + _S4521.z * _S4848 + _S4521.y * _S4849; + float3 _S4860 = _S4628; + *&((&_S4860)->z) = _S4836.differential_0.rows[int(2)].z; + *&((&_S4860)->y) = _S4836.differential_0.rows[int(1)].y; + *&((&_S4860)->x) = _S4836.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4861; + (&_S4861)->primal_0 = scale_26; + (&_S4861)->differential_0 = _S4628; + s_bwd_prop_exp_1(&_S4861, _S4860); + float4 _S4862 = make_float4 (0.0f); + float4 _S4863 = _S4862; + *&((&_S4863)->w) = _S4856; + *&((&_S4863)->z) = _S4857; + *&((&_S4863)->y) = _S4858; + *&((&_S4863)->x) = _S4859; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S4864; + (&_S4864)->primal_0 = quat_26; + (&_S4864)->differential_0 = _S4862; + s_bwd_normalize_impl_0(&_S4864, _S4863); + float _S4865 = - (s_diff_k_10 / _S4520); + DiffPair_float_0 _S4866; + (&_S4866)->primal_0 = _S4517; + (&_S4866)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S4866, _S4865); + float _S4867 = - _S4866.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4868; + (&_S4868)->primal_0 = mean_c_26; + (&_S4868)->differential_0 = _S4628; + s_bwd_length_impl_0(&_S4868, v_depth_4); + float3 _S4869 = _S4800 + _S4826 + _S4868.differential_0 + _S4767; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4870; + (&_S4870)->primal_0 = R_26; + (&_S4870)->differential_0 = _S4684; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S4871; + (&_S4871)->primal_0 = mean_27; + (&_S4871)->differential_0 = _S4628; + s_bwd_prop_mul_3(&_S4870, &_S4871, _S4869); + Matrix _S4872 = _S4829 + _S4830.differential_0 + _S4870.differential_0; + float _S4873 = _S4867 + _S4635.differential_0; + float3 _S4874 = _S4861.differential_0 + _S4634.differential_0; + *v_mean_4 = *v_mean_4 + (_S4871.differential_0 + _S4633.differential_0); + *v_quat_4 = *v_quat_4 + _S4864.differential_0; + *v_scale_4 = *v_scale_4 + _S4874; + *v_in_opacity_4 = *v_in_opacity_4 + _S4873; + *v_R_4 = *v_R_4 + _S4872; + *v_t_4 = *v_t_4 + _S4869; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgs_fisheye_opencv_projection_Intermediates_0 +{ + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4875; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4876; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4877; }; -inline __device__ void s_bwd_prop_d_sqrt_0(DiffPair_0 * dpdpx_4, DiffPair_float_0 * _s_dOut_5) +inline __device__ void projection_3dgs_fisheye_opencv_vjp(bool antialiased_27, float3 mean_28, float4 quat_27, float3 scale_27, float in_opacity_27, Matrix R_27, float3 t_27, float fx_40, float fy_40, float cx_31, float cy_31, FixedArray dist_coeffs_39, uint image_width_27, uint image_height_27, float2 v_mean2d_5, float v_depth_5, float3 v_conic_5, float v_opacity_5, float3 * v_mean_5, float4 * v_quat_5, float3 * v_scale_5, float * v_in_opacity_5, Matrix * v_R_5, float3 * v_t_5) { - float _S1795 = (F32_max((1.00000001168609742e-07f), ((*dpdpx_4).primal_0.primal_0))); - float _S1796 = s_primal_ctx_sqrt_0(_S1795); - float _S1797 = 0.5f / _S1796 * _s_dOut_5->differential_0; - float _S1798 = 0.5f * - ((*dpdpx_4).primal_0.differential_0 * _s_dOut_5->differential_0 / (_S1796 * _S1796)); - DiffPair_float_0 _S1799; - (&_S1799)->primal_0 = _S1795; - (&_S1799)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1799, _S1798); - DiffPair_float_0 _S1800; - (&_S1800)->primal_0 = 1.00000001168609742e-07f; - (&_S1800)->differential_0 = 0.0f; - DiffPair_float_0 _S1801; - (&_S1801)->primal_0 = (*dpdpx_4).primal_0.primal_0; - (&_S1801)->differential_0 = 0.0f; - _d_max_0(&_S1800, &_S1801, _S1799.differential_0); - DiffPair_float_0 _S1802; - (&_S1802)->primal_0 = (*dpdpx_4).primal_0.primal_0; - (&_S1802)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1802, _s_dOut_5->primal_0); - DiffPair_float_0 _S1803 = { _S1801.differential_0 + _S1802.differential_0, _S1797 }; - dpdpx_4->primal_0 = (*dpdpx_4).primal_0; - dpdpx_4->differential_0 = _S1803; + float2 _S4878 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4879 = { _S4878, _S4878 }; + s_bwd_prop_DiffProjection3DGS_3dgs_fisheye_opencv_projection_Intermediates_0 _S4880; + (&_S4880)->_S4875 = _S4879; + (&_S4880)->_S4876 = _S4879; + (&_S4880)->_S4877 = _S4879; + (&(&_S4880)->_S4875)->primal_0 = _S4878; + (&(&_S4880)->_S4875)->differential_0 = _S4878; + (&(&_S4880)->_S4876)->primal_0 = _S4878; + (&(&_S4880)->_S4876)->differential_0 = _S4878; + (&(&_S4880)->_S4877)->primal_0 = _S4878; + (&(&_S4880)->_S4877)->differential_0 = _S4878; + float3 mean_c_27 = s_primal_ctx_mul_0(R_27, mean_28) + t_27; + float2 _S4881 = float2 {mean_c_27.x, mean_c_27.y}; + float2 _S4882 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4883 = { _S4881, _S4882 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4884; + (&_S4884)->primal_0 = _S4881; + (&_S4884)->differential_0 = _S4882; + DiffPair_float_0 _S4885 = s_primal_ctx_s_fwd_length_impl_0(&_S4884); + float _S4886 = mean_c_27.z; + DiffPair_float_0 _S4887 = { _S4885.primal_0, _S4885.differential_0 }; + DiffPair_float_0 _S4888 = { _S4886, 0.0f }; + DiffPair_float_0 _S4889; + (&_S4889)->primal_0 = _S4885.primal_0; + (&_S4889)->differential_0 = _S4885.differential_0; + DiffPair_float_0 _S4890; + (&_S4890)->primal_0 = _S4886; + (&_S4890)->differential_0 = 0.0f; + DiffPair_float_0 _S4891 = s_primal_ctx_d_atan2_0(&_S4889, &_S4890); + bool _S4892 = (_S4891.primal_0) < 0.00100000004749745f; + float k_21; + float s_diff_k_11; + if(_S4892) + { + float _S4893 = _S4891.differential_0 * _S4891.primal_0; + float _S4894 = (0.0f - (_S4893 + _S4893) * 0.3333333432674408f) * _S4886 / (_S4886 * _S4886); + k_21 = (1.0f - _S4891.primal_0 * _S4891.primal_0 / 3.0f) / _S4886; + s_diff_k_11 = _S4894; + } + else + { + float _S4895 = (_S4891.differential_0 * _S4885.primal_0 - _S4891.primal_0 * _S4885.differential_0) / (_S4885.primal_0 * _S4885.primal_0); + k_21 = _S4891.primal_0 / _S4885.primal_0; + s_diff_k_11 = _S4895; + } + float2 _S4896 = _S4881 * make_float2 (k_21); + float2 _S4897 = _S4882 * make_float2 (k_21) + make_float2 (s_diff_k_11) * _S4881; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4898; + (&_S4898)->primal_0 = _S4896; + (&_S4898)->differential_0 = _S4897; + FixedArray _S4899 = dist_coeffs_39; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4900 = s_primal_ctx_s_fwd_DistOpenCV_distort_0(&_S4898, &_S4899); + (&_S4880)->_S4875 = _S4900; + float2 _S4901 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4902 = { _S4881, _S4901 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4903; + (&_S4903)->primal_0 = _S4881; + (&_S4903)->differential_0 = _S4901; + DiffPair_float_0 _S4904 = s_primal_ctx_s_fwd_length_impl_0(&_S4903); + DiffPair_float_0 _S4905 = { _S4904.primal_0, _S4904.differential_0 }; + DiffPair_float_0 _S4906; + (&_S4906)->primal_0 = _S4904.primal_0; + (&_S4906)->differential_0 = _S4904.differential_0; + DiffPair_float_0 _S4907; + (&_S4907)->primal_0 = _S4886; + (&_S4907)->differential_0 = 0.0f; + DiffPair_float_0 _S4908 = s_primal_ctx_d_atan2_0(&_S4906, &_S4907); + bool _S4909 = (_S4908.primal_0) < 0.00100000004749745f; + if(_S4909) + { + float _S4910 = _S4908.differential_0 * _S4908.primal_0; + float _S4911 = (0.0f - (_S4910 + _S4910) * 0.3333333432674408f) * _S4886 / (_S4886 * _S4886); + k_21 = (1.0f - _S4908.primal_0 * _S4908.primal_0 / 3.0f) / _S4886; + s_diff_k_11 = _S4911; + } + else + { + float _S4912 = (_S4908.differential_0 * _S4904.primal_0 - _S4908.primal_0 * _S4904.differential_0) / (_S4904.primal_0 * _S4904.primal_0); + k_21 = _S4908.primal_0 / _S4904.primal_0; + s_diff_k_11 = _S4912; + } + float2 _S4913 = _S4881 * make_float2 (k_21); + float2 _S4914 = _S4901 * make_float2 (k_21) + make_float2 (s_diff_k_11) * _S4881; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4915; + (&_S4915)->primal_0 = _S4913; + (&_S4915)->differential_0 = _S4914; + FixedArray _S4916 = dist_coeffs_39; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4917 = s_primal_ctx_s_fwd_DistOpenCV_distort_0(&_S4915, &_S4916); + (&_S4880)->_S4876 = _S4917; + float2 _S4918 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4919 = { _S4881, _S4918 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4920; + (&_S4920)->primal_0 = _S4881; + (&_S4920)->differential_0 = _S4918; + DiffPair_float_0 _S4921 = s_primal_ctx_s_fwd_length_impl_0(&_S4920); + DiffPair_float_0 _S4922 = { _S4921.primal_0, _S4921.differential_0 }; + DiffPair_float_0 _S4923 = { _S4886, 1.0f }; + DiffPair_float_0 _S4924; + (&_S4924)->primal_0 = _S4921.primal_0; + (&_S4924)->differential_0 = _S4921.differential_0; + DiffPair_float_0 _S4925; + (&_S4925)->primal_0 = _S4886; + (&_S4925)->differential_0 = 1.0f; + DiffPair_float_0 _S4926 = s_primal_ctx_d_atan2_0(&_S4924, &_S4925); + bool _S4927 = (_S4926.primal_0) < 0.00100000004749745f; + if(_S4927) + { + float _S4928 = _S4926.differential_0 * _S4926.primal_0; + float _S4929 = 1.0f - _S4926.primal_0 * _S4926.primal_0 / 3.0f; + float _S4930 = ((0.0f - (_S4928 + _S4928) * 0.3333333432674408f) * _S4886 - _S4929) / (_S4886 * _S4886); + k_21 = _S4929 / _S4886; + s_diff_k_11 = _S4930; + } + else + { + float _S4931 = (_S4926.differential_0 * _S4921.primal_0 - _S4926.primal_0 * _S4921.differential_0) / (_S4921.primal_0 * _S4921.primal_0); + k_21 = _S4926.primal_0 / _S4921.primal_0; + s_diff_k_11 = _S4931; + } + float2 _S4932 = _S4881 * make_float2 (k_21); + float2 _S4933 = make_float2 (s_diff_k_11) * _S4881; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4934; + (&_S4934)->primal_0 = _S4932; + (&_S4934)->differential_0 = _S4933; + FixedArray _S4935 = dist_coeffs_39; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4936 = s_primal_ctx_s_fwd_DistOpenCV_distort_0(&_S4934, &_S4935); + (&_S4880)->_S4877 = _S4936; + s_bwd_prop_DiffProjection3DGS_3dgs_fisheye_opencv_projection_Intermediates_0 _S4937 = _S4880; + float _S4938 = - in_opacity_27; + float _S4939 = 1.0f + s_primal_ctx_exp_0(_S4938); + float _S4940 = 1.0f / _S4939; + float _S4941 = _S4939 * _S4939; + float4 _S4942 = normalize_0(quat_27); + float3 _S4943 = s_primal_ctx_exp_1(scale_27); + float _S4944 = _S4942.y; + float x2_27 = _S4944 * _S4944; + float y2_27 = _S4942.z * _S4942.z; + float z2_27 = _S4942.w * _S4942.w; + float xy_27 = _S4942.y * _S4942.z; + float xz_27 = _S4942.y * _S4942.w; + float yz_27 = _S4942.z * _S4942.w; + float wx_27 = _S4942.x * _S4942.y; + float wy_27 = _S4942.x * _S4942.z; + float wz_27 = _S4942.x * _S4942.w; + Matrix _S4945 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_27 + z2_27), 2.0f * (xy_27 + wz_27), 2.0f * (xz_27 - wy_27), 2.0f * (xy_27 - wz_27), 1.0f - 2.0f * (x2_27 + z2_27), 2.0f * (yz_27 + wx_27), 2.0f * (xz_27 + wy_27), 2.0f * (yz_27 - wx_27), 1.0f - 2.0f * (x2_27 + y2_27))); + Matrix S_5 = makeMatrix (_S4943.x, 0.0f, 0.0f, 0.0f, _S4943.y, 0.0f, 0.0f, 0.0f, _S4943.z); + Matrix _S4946 = s_primal_ctx_mul_1(_S4945, S_5); + Matrix _S4947 = transpose_3(_S4946); + Matrix _S4948 = s_primal_ctx_mul_1(_S4946, _S4947); + Matrix _S4949 = s_primal_ctx_mul_1(R_27, _S4948); + Matrix _S4950 = transpose_3(R_27); + Matrix _S4951 = s_primal_ctx_mul_1(_S4949, _S4950); + Matrix J_37 = makeMatrix (0.0f); + float _S4952; + float _S4953; + float _S4954; + float _S4955; + float _S4956; + float _S4957; + float _S4958; + float _S4959; + if(_S4892) + { + float _S4960 = _S4891.differential_0 * _S4891.primal_0; + float _S4961 = 1.0f - _S4891.primal_0 * _S4891.primal_0 / 3.0f; + float _S4962 = 0.0f - (_S4960 + _S4960) * 0.3333333432674408f; + float _S4963 = _S4886 * _S4886; + float _S4964 = _S4962 * _S4886; + float _S4965 = _S4964 / _S4963; + float _S4966 = _S4963 * _S4963; + k_21 = _S4961 / _S4886; + s_diff_k_11 = _S4965; + _S4952 = _S4966; + _S4953 = _S4964; + _S4954 = _S4963; + _S4955 = _S4961; + _S4956 = _S4962; + _S4957 = 0.0f; + _S4958 = 0.0f; + _S4959 = 0.0f; + } + else + { + float _S4967 = _S4885.primal_0 * _S4885.primal_0; + float _S4968 = _S4891.differential_0 * _S4885.primal_0 - _S4891.primal_0 * _S4885.differential_0; + float _S4969 = _S4968 / _S4967; + float _S4970 = _S4967 * _S4967; + k_21 = _S4891.primal_0 / _S4885.primal_0; + s_diff_k_11 = _S4969; + _S4952 = 0.0f; + _S4953 = 0.0f; + _S4954 = 0.0f; + _S4955 = 0.0f; + _S4956 = 0.0f; + _S4957 = _S4970; + _S4958 = _S4968; + _S4959 = _S4967; + } + float2 _S4971 = make_float2 (k_21); + float2 _S4972 = make_float2 (s_diff_k_11); + float2 _S4973 = _S4881 * make_float2 (k_21); + float2 _S4974 = _S4882 * make_float2 (k_21) + make_float2 (s_diff_k_11) * _S4881; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S4975 = { _S4973, _S4974 }; + float _S4976 = _S4937._S4875.differential_0.x * fx_40; + float _S4977 = _S4937._S4875.differential_0.y * fy_40; + Matrix _S4978 = J_37; + *&(((&_S4978)->rows + (int(0)))->x) = _S4976; + *&(((&_S4978)->rows + (int(1)))->x) = _S4977; + float _S4979; + float _S4980; + float _S4981; + float _S4982; + float _S4983; + float _S4984; + float _S4985; + float _S4986; + if(_S4909) + { + float _S4987 = _S4908.differential_0 * _S4908.primal_0; + float _S4988 = 1.0f - _S4908.primal_0 * _S4908.primal_0 / 3.0f; + float _S4989 = 0.0f - (_S4987 + _S4987) * 0.3333333432674408f; + float _S4990 = _S4886 * _S4886; + float _S4991 = _S4989 * _S4886; + float _S4992 = _S4991 / _S4990; + float _S4993 = _S4990 * _S4990; + k_21 = _S4988 / _S4886; + s_diff_k_11 = _S4992; + _S4979 = _S4993; + _S4980 = _S4991; + _S4981 = _S4990; + _S4982 = _S4988; + _S4983 = _S4989; + _S4984 = 0.0f; + _S4985 = 0.0f; + _S4986 = 0.0f; + } + else + { + float _S4994 = _S4904.primal_0 * _S4904.primal_0; + float _S4995 = _S4908.differential_0 * _S4904.primal_0 - _S4908.primal_0 * _S4904.differential_0; + float _S4996 = _S4995 / _S4994; + float _S4997 = _S4994 * _S4994; + k_21 = _S4908.primal_0 / _S4904.primal_0; + s_diff_k_11 = _S4996; + _S4979 = 0.0f; + _S4980 = 0.0f; + _S4981 = 0.0f; + _S4982 = 0.0f; + _S4983 = 0.0f; + _S4984 = _S4997; + _S4985 = _S4995; + _S4986 = _S4994; + } + float2 _S4998 = make_float2 (k_21); + float2 _S4999 = make_float2 (s_diff_k_11); + float2 _S5000 = _S4881 * make_float2 (k_21); + float2 _S5001 = _S4901 * make_float2 (k_21) + make_float2 (s_diff_k_11) * _S4881; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5002 = { _S5000, _S5001 }; + float _S5003 = _S4937._S4876.differential_0.y * fy_40; + *&(((&_S4978)->rows + (int(0)))->y) = _S4937._S4876.differential_0.x * fx_40; + *&(((&_S4978)->rows + (int(1)))->y) = _S5003; + float _S5004; + float _S5005; + float _S5006; + float _S5007; + float _S5008; + float _S5009; + float _S5010; + float _S5011; + if(_S4927) + { + float _S5012 = _S4926.differential_0 * _S4926.primal_0; + float _S5013 = 1.0f - _S4926.primal_0 * _S4926.primal_0 / 3.0f; + float _S5014 = 0.0f - (_S5012 + _S5012) * 0.3333333432674408f; + float _S5015 = _S4886 * _S4886; + float _S5016 = _S5014 * _S4886 - _S5013; + float _S5017 = _S5016 / _S5015; + float _S5018 = _S5015 * _S5015; + k_21 = _S5013 / _S4886; + s_diff_k_11 = _S5017; + _S5004 = _S5018; + _S5005 = _S5016; + _S5006 = _S5015; + _S5007 = _S5013; + _S5008 = _S5014; + _S5009 = 0.0f; + _S5010 = 0.0f; + _S5011 = 0.0f; + } + else + { + float _S5019 = _S4921.primal_0 * _S4921.primal_0; + float _S5020 = _S4926.differential_0 * _S4921.primal_0 - _S4926.primal_0 * _S4921.differential_0; + float _S5021 = _S5020 / _S5019; + float _S5022 = _S5019 * _S5019; + k_21 = _S4926.primal_0 / _S4921.primal_0; + s_diff_k_11 = _S5021; + _S5004 = 0.0f; + _S5005 = 0.0f; + _S5006 = 0.0f; + _S5007 = 0.0f; + _S5008 = 0.0f; + _S5009 = _S5022; + _S5010 = _S5020; + _S5011 = _S5019; + } + float2 _S5023 = make_float2 (k_21); + float2 _S5024 = make_float2 (s_diff_k_11); + float2 _S5025 = _S4881 * make_float2 (k_21); + float2 _S5026 = make_float2 (s_diff_k_11) * _S4881; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5027 = { _S5025, _S5026 }; + float _S5028 = _S4937._S4877.differential_0.y * fy_40; + *&(((&_S4978)->rows + (int(0)))->z) = _S4937._S4877.differential_0.x * fx_40; + *&(((&_S4978)->rows + (int(1)))->z) = _S5028; + Matrix _S5029 = s_primal_ctx_mul_2(_S4978, _S4951); + Matrix _S5030 = transpose_1(_S4978); + Matrix _S5031 = s_primal_ctx_mul_3(_S5029, _S5030); + float eps2d_27; + if(antialiased_27) + { + eps2d_27 = 0.10000000149011612f; + } + else + { + eps2d_27 = 0.30000001192092896f; + } + float _S5032 = _S5031.rows[int(0)].y * _S5031.rows[int(1)].x; + float det_orig_27 = _S5031.rows[int(0)].x * _S5031.rows[int(1)].y - _S5032; + float _S5033 = _S5031.rows[int(0)].x + eps2d_27; + Matrix _S5034 = _S5031; + *&(((&_S5034)->rows + (int(0)))->x) = _S5033; + float _S5035 = _S5031.rows[int(1)].y + eps2d_27; + *&(((&_S5034)->rows + (int(1)))->y) = _S5035; + Matrix _S5036 = _S5034; + Matrix _S5037 = _S5034; + float det_blur_27 = _S5033 * _S5035 - _S5032; + float _S5038 = det_orig_27 / det_blur_27; + float _S5039 = det_blur_27 * det_blur_27; + float _S5040 = (F32_max((0.0f), (_S5038))); + float _S5041 = s_primal_ctx_sqrt_0(_S5040); + float invdet_33 = 1.0f / det_blur_27; + float _S5042 = - _S5031.rows[int(0)].y; + float _S5043 = - _S5031.rows[int(1)].x; + if(antialiased_27) + { + k_21 = _S4940 * _S5041; + } + else + { + k_21 = _S4940; + } + float _S5044 = k_21 / 0.00392156885936856f; + float _S5045 = 2.0f * s_primal_ctx_log_0(_S5044); + float _S5046 = s_primal_ctx_sqrt_0(_S5045); + float _S5047 = _S5036.rows[int(0)].x; + float _S5048 = _S5037.rows[int(1)].y; + float3 campos_6 = - s_primal_ctx_mul_0(_S4950, t_27); + float3 _S5049 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5050; + (&_S5050)->primal_0 = mean_28; + (&_S5050)->differential_0 = _S5049; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5051; + (&_S5051)->primal_0 = scale_27; + (&_S5051)->differential_0 = _S5049; + DiffPair_float_0 _S5052; + (&_S5052)->primal_0 = in_opacity_27; + (&_S5052)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5053; + (&_S5053)->primal_0 = campos_6; + (&_S5053)->differential_0 = _S5049; + s_bwd_prop_view_radius_3dgs_0(&_S5050, &_S5051, &_S5052, &_S5053, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5054 = _S5050; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5055 = _S5051; + DiffPair_float_0 _S5056 = _S5052; + float2 _S5057 = _S4878; + *&((&_S5057)->y) = v_conic_5.z; + float2 _S5058 = _S4878; + *&((&_S5058)->y) = v_conic_5.y; + *&((&_S5058)->x) = v_conic_5.x; + DiffPair_float_0 _S5059; + (&_S5059)->primal_0 = _S5048; + (&_S5059)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5059, 0.0f); + DiffPair_float_0 _S5060; + (&_S5060)->primal_0 = _S5047; + (&_S5060)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5060, 0.0f); + DiffPair_float_0 _S5061; + (&_S5061)->primal_0 = 3.32999992370605469f; + (&_S5061)->differential_0 = 0.0f; + DiffPair_float_0 _S5062; + (&_S5062)->primal_0 = _S5046; + (&_S5062)->differential_0 = 0.0f; + _d_min_0(&_S5061, &_S5062, 0.0f); + DiffPair_float_0 _S5063; + (&_S5063)->primal_0 = _S5045; + (&_S5063)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5063, _S5062.differential_0); + float _S5064 = 2.0f * _S5063.differential_0; + DiffPair_float_0 _S5065; + (&_S5065)->primal_0 = _S5044; + (&_S5065)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S5065, _S5064); + float _S5066 = v_opacity_5 + 254.9999847412109375f * _S5065.differential_0; + Matrix _S5067 = makeMatrix (0.0f); + Matrix _S5068 = _S5067; + _S5068[int(1)] = _S5057; + _S5068[int(0)] = _S5058; + Matrix _S5069 = _S5068; + float2 _S5070 = make_float2 (0.0f, _S5059.differential_0); + float2 _S5071 = make_float2 (_S5060.differential_0, 0.0f); + if(antialiased_27) + { + float _S5072 = _S5041 * _S5066; + k_21 = _S4940 * _S5066; + s_diff_k_11 = _S5072; + } + else + { + k_21 = 0.0f; + s_diff_k_11 = _S5066; + } + float _S5073 = invdet_33 * _S5069.rows[int(1)].y; + float _S5074 = - (invdet_33 * _S5069.rows[int(1)].x); + float _S5075 = - (invdet_33 * _S5069.rows[int(0)].y); + float _S5076 = invdet_33 * _S5069.rows[int(0)].x; + float _S5077 = - ((_S5033 * _S5069.rows[int(1)].y + _S5043 * _S5069.rows[int(1)].x + _S5042 * _S5069.rows[int(0)].y + _S5035 * _S5069.rows[int(0)].x) / _S5039); + DiffPair_float_0 _S5078; + (&_S5078)->primal_0 = _S5040; + (&_S5078)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5078, k_21); + DiffPair_float_0 _S5079 = { 0.0f, 0.0f }; + DiffPair_float_0 _S5080; + (&_S5080)->primal_0 = 0.0f; + (&_S5080)->differential_0 = 0.0f; + DiffPair_float_0 _S5081; + (&_S5081)->primal_0 = _S5038; + (&_S5081)->differential_0 = 0.0f; + _d_max_0(&_S5080, &_S5081, _S5078.differential_0); + float _S5082 = _S5081.differential_0 / _S5039; + float s_diff_det_orig_T_5 = det_blur_27 * _S5082; + float _S5083 = det_orig_27 * - _S5082 + _S5077; + float _S5084 = - _S5083; + float _S5085 = _S5033 * _S5083; + float _S5086 = _S5035 * _S5083; + Matrix _S5087 = _S5067; + _S5087[int(1)] = _S5070; + _S5087[int(0)] = _S5071; + _S5034 = _S5087; + *&(((&_S5034)->rows + (int(1)))->y) = 0.0f; + float _S5088 = _S5085 + _S5087.rows[int(1)].y + _S5076; + *&(((&_S5034)->rows + (int(0)))->x) = 0.0f; + float _S5089 = _S5086 + _S5087.rows[int(0)].x + _S5073; + float _S5090 = _S5084 + - s_diff_det_orig_T_5; + float _S5091 = _S5031.rows[int(0)].y * _S5090 + _S5074; + float _S5092 = _S5031.rows[int(1)].x * _S5090 + _S5075; + float _S5093 = _S5031.rows[int(1)].y * s_diff_det_orig_T_5; + float _S5094 = _S5088 + _S5031.rows[int(0)].x * s_diff_det_orig_T_5; + float2 _S5095 = _S4878; + *&((&_S5095)->x) = _S5091; + *&((&_S5095)->y) = _S5094; + float _S5096 = _S5089 + _S5093; + float2 _S5097 = _S4878; + *&((&_S5097)->y) = _S5092; + *&((&_S5097)->x) = _S5096; + Matrix _S5098 = _S5067; + _S5098[int(1)] = _S5095; + _S5098[int(0)] = _S5097; + Matrix _S5099 = _S5034 + _S5098; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S5100; + (&_S5100)->primal_0 = _S5029; + (&_S5100)->differential_0 = J_37; + Matrix _S5101 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S5102; + (&_S5102)->primal_0 = _S5030; + (&_S5102)->differential_0 = _S5101; + s_bwd_prop_mul_0(&_S5100, &_S5102, _S5099); + Matrix _S5103 = transpose_2(_S5102.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S5104; + (&_S5104)->primal_0 = _S4978; + (&_S5104)->differential_0 = J_37; + Matrix _S5105 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5106; + (&_S5106)->primal_0 = _S4951; + (&_S5106)->differential_0 = _S5105; + s_bwd_prop_mul_1(&_S5104, &_S5106, _S5100.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5107 = _S5106; + Matrix _S5108 = _S5103 + _S5104.differential_0; + float2 _S5109 = make_float2 (fx_40 * _S5108.rows[int(0)].z, fy_40 * _S5108.rows[int(1)].z); + DiffPair_0 _S5110; + (&_S5110)->primal_0 = _S5027; + (&_S5110)->differential_0 = _S4879; + FixedArray _S5111 = dist_coeffs_39; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5112; + (&_S5112)->primal_0 = _S4918; + (&_S5112)->differential_0 = _S5109; + s_bwd_prop_s_fwd_DistOpenCV_distort_0(&_S5110, &_S5111, &_S5112); + float2 _S5113 = _S4881 * _S5110.differential_0.differential_0; + float2 _S5114 = _S4881 * _S5110.differential_0.primal_0; + float _S5115 = _S5114.x + _S5114.y; + float _S5116 = _S5113.x + _S5113.y; + float2 _S5117 = _S5024 * _S5110.differential_0.differential_0 + _S5023 * _S5110.differential_0.primal_0; + if(_S4927) + { + float _S5118 = _S5116 / _S5004; + float _S5119 = _S5006 * _S5118; + float _S5120 = _S4886 * (_S5005 * - _S5118); + float _S5121 = _S5115 / _S5006; + float _S5122 = 0.3333333432674408f * - (_S4886 * _S5119); + float _S5123 = _S5122 + _S5122; + float _S5124 = _S4926.primal_0 * (0.3333333432674408f * - (- _S5119 + _S4886 * _S5121)); + float _S5125 = _S5120 + _S5120 + _S5008 * _S5119 + _S5007 * - _S5121; + float _S5126 = _S4926.differential_0 * _S5123 + _S5124 + _S5124; + k_21 = _S4926.primal_0 * _S5123; + _S5004 = _S5126; + _S5005 = _S5125; + _S5006 = 0.0f; + _S5007 = 0.0f; + } + else + { + float _S5127 = _S5116 / _S5009; + float _S5128 = _S5011 * _S5127; + float _S5129 = _S4921.primal_0 * (_S5010 * - _S5127); + float _S5130 = - _S5128; + float _S5131 = _S4926.primal_0 * _S5130; + float _S5132 = _S5115 / _S5011; + float _S5133 = _S5129 + _S5129 + _S4926.differential_0 * _S5128 + _S4926.primal_0 * - _S5132; + float _S5134 = _S4921.differential_0 * _S5130 + _S4921.primal_0 * _S5132; + k_21 = _S4921.primal_0 * _S5128; + _S5004 = _S5134; + _S5005 = 0.0f; + _S5006 = _S5131; + _S5007 = _S5133; + } + DiffPair_1 _S5135; + (&_S5135)->primal_0 = _S4922; + (&_S5135)->differential_0 = _S5079; + DiffPair_1 _S5136; + (&_S5136)->primal_0 = _S4923; + (&_S5136)->differential_0 = _S5079; + DiffPair_float_0 _S5137; + (&_S5137)->primal_0 = _S5004; + (&_S5137)->differential_0 = k_21; + s_bwd_prop_d_atan2_0(&_S5135, &_S5136, &_S5137); + float _S5138 = _S5136.differential_0.primal_0 + _S5005; + float _S5139 = _S5135.differential_0.differential_0 + _S5006; + float _S5140 = _S5135.differential_0.primal_0 + _S5007; + DiffPair_0 _S5141; + (&_S5141)->primal_0 = _S4919; + (&_S5141)->differential_0 = _S4879; + DiffPair_float_0 _S5142; + (&_S5142)->primal_0 = _S5140; + (&_S5142)->differential_0 = _S5139; + s_bwd_prop_s_fwd_length_impl_0(&_S5141, &_S5142); + float2 _S5143 = _S5141.differential_0.primal_0 + _S5117; + float3 _S5144 = make_float3 (_S5143.x, _S5143.y, _S5138); + float2 _S5145 = make_float2 (fx_40 * _S5108.rows[int(0)].y, fy_40 * _S5108.rows[int(1)].y); + DiffPair_0 _S5146; + (&_S5146)->primal_0 = _S5002; + (&_S5146)->differential_0 = _S4879; + FixedArray _S5147 = dist_coeffs_39; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5148; + (&_S5148)->primal_0 = _S4918; + (&_S5148)->differential_0 = _S5145; + s_bwd_prop_s_fwd_DistOpenCV_distort_0(&_S5146, &_S5147, &_S5148); + DiffPair_0 _S5149 = _S5146; + float2 _S5150 = _S4881 * _S5149.differential_0.differential_0; + float2 _S5151 = _S4901 * _S5149.differential_0.differential_0; + float2 _S5152 = _S4881 * _S5149.differential_0.primal_0; + float _S5153 = _S5151.x + _S5151.y + _S5152.x + _S5152.y; + float _S5154 = _S5150.x + _S5150.y; + float2 _S5155 = _S4999 * _S5149.differential_0.differential_0 + _S4998 * _S5149.differential_0.primal_0; + if(_S4909) + { + float _S5156 = _S5154 / _S4979; + float _S5157 = _S4981 * _S5156; + float _S5158 = _S4886 * (_S4980 * - _S5156); + float _S5159 = _S5153 / _S4981; + float _S5160 = 0.3333333432674408f * - (_S4886 * _S5157); + float _S5161 = _S5160 + _S5160; + float _S5162 = _S4908.primal_0 * (0.3333333432674408f * - (_S4886 * _S5159)); + float _S5163 = _S5158 + _S5158 + _S4983 * _S5157 + _S4982 * - _S5159; + float _S5164 = _S4908.differential_0 * _S5161 + _S5162 + _S5162; + k_21 = _S4908.primal_0 * _S5161; + _S4979 = _S5164; + _S4980 = _S5163; + _S4981 = 0.0f; + _S4982 = 0.0f; + } + else + { + float _S5165 = _S5154 / _S4984; + float _S5166 = _S4986 * _S5165; + float _S5167 = _S4904.primal_0 * (_S4985 * - _S5165); + float _S5168 = - _S5166; + float _S5169 = _S4908.primal_0 * _S5168; + float _S5170 = _S5153 / _S4986; + float _S5171 = _S5167 + _S5167 + _S4908.differential_0 * _S5166 + _S4908.primal_0 * - _S5170; + float _S5172 = _S4904.differential_0 * _S5168 + _S4904.primal_0 * _S5170; + k_21 = _S4904.primal_0 * _S5166; + _S4979 = _S5172; + _S4980 = 0.0f; + _S4981 = _S5169; + _S4982 = _S5171; + } + DiffPair_1 _S5173; + (&_S5173)->primal_0 = _S4905; + (&_S5173)->differential_0 = _S5079; + DiffPair_1 _S5174; + (&_S5174)->primal_0 = _S4888; + (&_S5174)->differential_0 = _S5079; + DiffPair_float_0 _S5175; + (&_S5175)->primal_0 = _S4979; + (&_S5175)->differential_0 = k_21; + s_bwd_prop_d_atan2_0(&_S5173, &_S5174, &_S5175); + float _S5176 = _S5174.differential_0.primal_0 + _S4980; + float _S5177 = _S5173.differential_0.differential_0 + _S4981; + float _S5178 = _S5173.differential_0.primal_0 + _S4982; + DiffPair_0 _S5179; + (&_S5179)->primal_0 = _S4902; + (&_S5179)->differential_0 = _S4879; + DiffPair_float_0 _S5180; + (&_S5180)->primal_0 = _S5178; + (&_S5180)->differential_0 = _S5177; + s_bwd_prop_s_fwd_length_impl_0(&_S5179, &_S5180); + float2 _S5181 = _S5179.differential_0.primal_0 + _S5155; + float3 _S5182 = make_float3 (_S5181.x, _S5181.y, _S5176); + float2 _S5183 = make_float2 (fx_40 * _S5108.rows[int(0)].x, fy_40 * _S5108.rows[int(1)].x); + DiffPair_0 _S5184; + (&_S5184)->primal_0 = _S4975; + (&_S5184)->differential_0 = _S4879; + FixedArray _S5185 = dist_coeffs_39; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5186; + (&_S5186)->primal_0 = _S4918; + (&_S5186)->differential_0 = _S5183; + s_bwd_prop_s_fwd_DistOpenCV_distort_0(&_S5184, &_S5185, &_S5186); + DiffPair_0 _S5187 = _S5184; + float3 _S5188 = _S5182 + _S5144; + float2 _S5189 = _S4881 * _S5187.differential_0.differential_0; + float2 _S5190 = _S4882 * _S5187.differential_0.differential_0; + float2 _S5191 = _S4881 * _S5187.differential_0.primal_0; + float _S5192 = _S5190.x + _S5190.y + _S5191.x + _S5191.y; + float _S5193 = _S5189.x + _S5189.y; + float2 _S5194 = _S4972 * _S5187.differential_0.differential_0 + _S4971 * _S5187.differential_0.primal_0; + if(_S4892) + { + float _S5195 = _S5193 / _S4952; + float _S5196 = _S4954 * _S5195; + float _S5197 = _S4886 * (_S4953 * - _S5195); + float _S5198 = _S5192 / _S4954; + float _S5199 = 0.3333333432674408f * - (_S4886 * _S5196); + float _S5200 = _S5199 + _S5199; + float _S5201 = _S4891.primal_0 * (0.3333333432674408f * - (_S4886 * _S5198)); + float _S5202 = _S5197 + _S5197 + _S4956 * _S5196 + _S4955 * - _S5198; + float _S5203 = _S4891.differential_0 * _S5200 + _S5201 + _S5201; + k_21 = _S4891.primal_0 * _S5200; + _S4952 = _S5203; + _S4953 = _S5202; + _S4954 = 0.0f; + _S4955 = 0.0f; + } + else + { + float _S5204 = _S5193 / _S4957; + float _S5205 = _S4959 * _S5204; + float _S5206 = _S4885.primal_0 * (_S4958 * - _S5204); + float _S5207 = - _S5205; + float _S5208 = _S4891.primal_0 * _S5207; + float _S5209 = _S5192 / _S4959; + float _S5210 = _S5206 + _S5206 + _S4891.differential_0 * _S5205 + _S4891.primal_0 * - _S5209; + float _S5211 = _S4885.differential_0 * _S5207 + _S4885.primal_0 * _S5209; + k_21 = _S4885.primal_0 * _S5205; + _S4952 = _S5211; + _S4953 = 0.0f; + _S4954 = _S5208; + _S4955 = _S5210; + } + DiffPair_1 _S5212; + (&_S5212)->primal_0 = _S4887; + (&_S5212)->differential_0 = _S5079; + DiffPair_1 _S5213; + (&_S5213)->primal_0 = _S4888; + (&_S5213)->differential_0 = _S5079; + DiffPair_float_0 _S5214; + (&_S5214)->primal_0 = _S4952; + (&_S5214)->differential_0 = k_21; + s_bwd_prop_d_atan2_0(&_S5212, &_S5213, &_S5214); + float _S5215 = _S5213.differential_0.primal_0 + _S4953; + float _S5216 = _S5212.differential_0.differential_0 + _S4954; + float _S5217 = _S5212.differential_0.primal_0 + _S4955; + DiffPair_0 _S5218; + (&_S5218)->primal_0 = _S4883; + (&_S5218)->differential_0 = _S4879; + DiffPair_float_0 _S5219; + (&_S5219)->primal_0 = _S5217; + (&_S5219)->differential_0 = _S5216; + s_bwd_prop_s_fwd_length_impl_0(&_S5218, &_S5219); + float2 _S5220 = _S5218.differential_0.primal_0 + _S5194; + float3 _S5221 = make_float3 (_S5220.x, _S5220.y, _S5215); + float _S5222 = length_0(_S4881); + float _S5223 = s_primal_ctx_atan2_0(_S5222, _S4886); + bool _S5224 = _S5223 < 0.00100000004749745f; + if(_S5224) + { + float _S5225 = 1.0f - _S5223 * _S5223 / 3.0f; + float _S5226 = _S4886 * _S4886; + k_21 = _S5225 / _S4886; + _S4952 = _S5226; + _S4953 = _S5225; + _S4954 = 0.0f; + } + else + { + float _S5227 = _S5222 * _S5222; + k_21 = _S5223 / _S5222; + _S4952 = 0.0f; + _S4953 = 0.0f; + _S4954 = _S5227; + } + float2 _S5228 = make_float2 (k_21); + float2 _S5229 = _S4881 * make_float2 (k_21); + float2 _S5230 = make_float2 (fx_40 * v_mean2d_5.x, fy_40 * v_mean2d_5.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5231; + (&_S5231)->primal_0 = _S5229; + (&_S5231)->differential_0 = _S4878; + FixedArray _S5232 = dist_coeffs_39; + s_bwd_prop_DistOpenCV_distort_0(&_S5231, &_S5232, _S5230); + float2 _S5233 = _S4881 * _S5231.differential_0; + float2 _S5234 = _S5228 * _S5231.differential_0; + float _S5235 = _S5233.x + _S5233.y; + if(_S5224) + { + float _S5236 = _S5235 / _S4952; + float _S5237 = _S4953 * - _S5236; + float _S5238 = _S5223 * (0.3333333432674408f * - (_S4886 * _S5236)); + k_21 = _S5238 + _S5238; + _S4952 = _S5237; + _S4953 = 0.0f; + } + else + { + float _S5239 = _S5235 / _S4954; + float _S5240 = _S5223 * - _S5239; + k_21 = _S5222 * _S5239; + _S4952 = 0.0f; + _S4953 = _S5240; + } + DiffPair_float_0 _S5241; + (&_S5241)->primal_0 = _S5222; + (&_S5241)->differential_0 = 0.0f; + DiffPair_float_0 _S5242; + (&_S5242)->primal_0 = _S4886; + (&_S5242)->differential_0 = 0.0f; + s_bwd_prop_atan2_0(&_S5241, &_S5242, k_21); + float _S5243 = _S5242.differential_0 + _S4952; + float _S5244 = _S5241.differential_0 + _S4953; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5245; + (&_S5245)->primal_0 = _S4881; + (&_S5245)->differential_0 = _S4878; + s_bwd_length_impl_2(&_S5245, _S5244); + float2 _S5246 = _S5245.differential_0 + _S5234; + float3 _S5247 = make_float3 (_S5246.x, _S5246.y, _S5243); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5248; + (&_S5248)->primal_0 = _S4949; + (&_S5248)->differential_0 = _S5105; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5249; + (&_S5249)->primal_0 = _S4950; + (&_S5249)->differential_0 = _S5105; + s_bwd_prop_mul_2(&_S5248, &_S5249, _S5107.differential_0); + Matrix _S5250 = transpose_3(_S5249.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5251; + (&_S5251)->primal_0 = R_27; + (&_S5251)->differential_0 = _S5105; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5252; + (&_S5252)->primal_0 = _S4948; + (&_S5252)->differential_0 = _S5105; + s_bwd_prop_mul_2(&_S5251, &_S5252, _S5248.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5253; + (&_S5253)->primal_0 = _S4946; + (&_S5253)->differential_0 = _S5105; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5254; + (&_S5254)->primal_0 = _S4947; + (&_S5254)->differential_0 = _S5105; + s_bwd_prop_mul_2(&_S5253, &_S5254, _S5252.differential_0); + Matrix _S5255 = _S5253.differential_0 + transpose_3(_S5254.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5256; + (&_S5256)->primal_0 = _S4945; + (&_S5256)->differential_0 = _S5105; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5257; + (&_S5257)->primal_0 = S_5; + (&_S5257)->differential_0 = _S5105; + s_bwd_prop_mul_2(&_S5256, &_S5257, _S5255); + Matrix _S5258 = transpose_3(_S5256.differential_0); + float _S5259 = 2.0f * - _S5258.rows[int(2)].z; + float _S5260 = 2.0f * _S5258.rows[int(2)].y; + float _S5261 = 2.0f * _S5258.rows[int(2)].x; + float _S5262 = 2.0f * _S5258.rows[int(1)].z; + float _S5263 = 2.0f * - _S5258.rows[int(1)].y; + float _S5264 = 2.0f * _S5258.rows[int(1)].x; + float _S5265 = 2.0f * _S5258.rows[int(0)].z; + float _S5266 = 2.0f * _S5258.rows[int(0)].y; + float _S5267 = 2.0f * - _S5258.rows[int(0)].x; + float _S5268 = - _S5264 + _S5266; + float _S5269 = _S5261 + - _S5265; + float _S5270 = - _S5260 + _S5262; + float _S5271 = _S5260 + _S5262; + float _S5272 = _S5261 + _S5265; + float _S5273 = _S5264 + _S5266; + float _S5274 = _S4942.w * (_S5263 + _S5267); + float _S5275 = _S4942.z * (_S5259 + _S5267); + float _S5276 = _S4942.y * (_S5259 + _S5263); + float _S5277 = _S4942.x * _S5268 + _S4942.z * _S5271 + _S4942.y * _S5272 + _S5274 + _S5274; + float _S5278 = _S4942.x * _S5269 + _S4942.w * _S5271 + _S4942.y * _S5273 + _S5275 + _S5275; + float _S5279 = _S4942.x * _S5270 + _S4942.w * _S5272 + _S4942.z * _S5273 + _S5276 + _S5276; + float _S5280 = _S4942.w * _S5268 + _S4942.z * _S5269 + _S4942.y * _S5270; + float3 _S5281 = _S5049; + *&((&_S5281)->z) = _S5257.differential_0.rows[int(2)].z; + *&((&_S5281)->y) = _S5257.differential_0.rows[int(1)].y; + *&((&_S5281)->x) = _S5257.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5282; + (&_S5282)->primal_0 = scale_27; + (&_S5282)->differential_0 = _S5049; + s_bwd_prop_exp_1(&_S5282, _S5281); + float4 _S5283 = make_float4 (0.0f); + float4 _S5284 = _S5283; + *&((&_S5284)->w) = _S5277; + *&((&_S5284)->z) = _S5278; + *&((&_S5284)->y) = _S5279; + *&((&_S5284)->x) = _S5280; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S5285; + (&_S5285)->primal_0 = quat_27; + (&_S5285)->differential_0 = _S5283; + s_bwd_normalize_impl_0(&_S5285, _S5284); + float _S5286 = - (s_diff_k_11 / _S4941); + DiffPair_float_0 _S5287; + (&_S5287)->primal_0 = _S4938; + (&_S5287)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S5287, _S5286); + float _S5288 = - _S5287.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5289; + (&_S5289)->primal_0 = mean_c_27; + (&_S5289)->differential_0 = _S5049; + s_bwd_length_impl_0(&_S5289, v_depth_5); + float3 _S5290 = _S5221 + _S5247 + _S5289.differential_0 + _S5188; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5291; + (&_S5291)->primal_0 = R_27; + (&_S5291)->differential_0 = _S5105; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5292; + (&_S5292)->primal_0 = mean_28; + (&_S5292)->differential_0 = _S5049; + s_bwd_prop_mul_3(&_S5291, &_S5292, _S5290); + Matrix _S5293 = _S5250 + _S5251.differential_0 + _S5291.differential_0; + float _S5294 = _S5288 + _S5056.differential_0; + float3 _S5295 = _S5282.differential_0 + _S5055.differential_0; + *v_mean_5 = *v_mean_5 + (_S5292.differential_0 + _S5054.differential_0); + *v_quat_5 = *v_quat_5 + _S5285.differential_0; + *v_scale_5 = *v_scale_5 + _S5295; + *v_in_opacity_5 = *v_in_opacity_5 + _S5294; + *v_R_5 = *v_R_5 + _S5293; + *v_t_5 = *v_t_5 + _S5290; return; } -inline __device__ void s_bwd_prop_s_fwd_length_impl_0(DiffPair_1 * dpdpx_5, DiffPair_float_0 * _s_dOut_6) +struct s_bwd_prop_DiffProjection3DGS_3dgs_fisheye_prism_projection_Intermediates_0 { - float _S1804 = (*dpdpx_5).primal_0.primal_0.x; - float _S1805 = (*dpdpx_5).primal_0.differential_0.x * (*dpdpx_5).primal_0.primal_0.x; - float _S1806 = (*dpdpx_5).primal_0.primal_0.y; - float _S1807 = (*dpdpx_5).primal_0.differential_0.y * (*dpdpx_5).primal_0.primal_0.y; - DiffPair_float_0 _S1808 = { _S1804 * _S1804 + _S1806 * _S1806, _S1805 + _S1805 + (_S1807 + _S1807) }; - DiffPair_float_0 _S1809 = { 0.0f, 0.0f }; - DiffPair_0 _S1810; - (&_S1810)->primal_0 = _S1808; - (&_S1810)->differential_0 = _S1809; - DiffPair_float_0 _S1811; - (&_S1811)->primal_0 = _s_dOut_6->primal_0; - (&_S1811)->differential_0 = _s_dOut_6->differential_0; - s_bwd_prop_d_sqrt_0(&_S1810, &_S1811); - float _S1812 = _S1810.differential_0.differential_0; - float _S1813 = _S1812 + _S1812; - float _S1814 = (*dpdpx_5).primal_0.primal_0.y * _S1813; - float _S1815 = (*dpdpx_5).primal_0.primal_0.y * _S1810.differential_0.primal_0; - float _S1816 = (*dpdpx_5).primal_0.differential_0.y * _S1813 + _S1815 + _S1815; - float _S1817 = (*dpdpx_5).primal_0.primal_0.x * _S1813; - float _S1818 = (*dpdpx_5).primal_0.primal_0.x * _S1810.differential_0.primal_0; - float _S1819 = (*dpdpx_5).primal_0.differential_0.x * _S1813 + _S1818 + _S1818; - float2 _S1820 = make_float2 (0.0f); - float2 _S1821 = _S1820; - *&((&_S1821)->y) = _S1816; - *&((&_S1821)->x) = _S1819; - float2 _S1822 = _S1820; - *&((&_S1822)->y) = _S1814; - *&((&_S1822)->x) = _S1817; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S1823 = { _S1821, _S1822 }; - dpdpx_5->primal_0 = (*dpdpx_5).primal_0; - dpdpx_5->differential_0 = _S1823; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5296; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5297; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5298; +}; + +inline __device__ void projection_3dgs_fisheye_prism_vjp(bool antialiased_28, float3 mean_29, float4 quat_28, float3 scale_28, float in_opacity_28, Matrix R_28, float3 t_28, float fx_41, float fy_41, float cx_32, float cy_32, FixedArray dist_coeffs_40, uint image_width_28, uint image_height_28, float2 v_mean2d_6, float v_depth_6, float3 v_conic_6, float v_opacity_6, float3 * v_mean_6, float4 * v_quat_6, float3 * v_scale_6, float * v_in_opacity_6, Matrix * v_R_6, float3 * v_t_6) +{ + float2 _S5299 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5300 = { _S5299, _S5299 }; + s_bwd_prop_DiffProjection3DGS_3dgs_fisheye_prism_projection_Intermediates_0 _S5301; + (&_S5301)->_S5296 = _S5300; + (&_S5301)->_S5297 = _S5300; + (&_S5301)->_S5298 = _S5300; + (&(&_S5301)->_S5296)->primal_0 = _S5299; + (&(&_S5301)->_S5296)->differential_0 = _S5299; + (&(&_S5301)->_S5297)->primal_0 = _S5299; + (&(&_S5301)->_S5297)->differential_0 = _S5299; + (&(&_S5301)->_S5298)->primal_0 = _S5299; + (&(&_S5301)->_S5298)->differential_0 = _S5299; + float3 mean_c_28 = s_primal_ctx_mul_0(R_28, mean_29) + t_28; + float2 _S5302 = float2 {mean_c_28.x, mean_c_28.y}; + float2 _S5303 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5304 = { _S5302, _S5303 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5305; + (&_S5305)->primal_0 = _S5302; + (&_S5305)->differential_0 = _S5303; + DiffPair_float_0 _S5306 = s_primal_ctx_s_fwd_length_impl_0(&_S5305); + float _S5307 = mean_c_28.z; + DiffPair_float_0 _S5308 = { _S5306.primal_0, _S5306.differential_0 }; + DiffPair_float_0 _S5309 = { _S5307, 0.0f }; + DiffPair_float_0 _S5310; + (&_S5310)->primal_0 = _S5306.primal_0; + (&_S5310)->differential_0 = _S5306.differential_0; + DiffPair_float_0 _S5311; + (&_S5311)->primal_0 = _S5307; + (&_S5311)->differential_0 = 0.0f; + DiffPair_float_0 _S5312 = s_primal_ctx_d_atan2_0(&_S5310, &_S5311); + bool _S5313 = (_S5312.primal_0) < 0.00100000004749745f; + float k_22; + float s_diff_k_12; + if(_S5313) + { + float _S5314 = _S5312.differential_0 * _S5312.primal_0; + float _S5315 = (0.0f - (_S5314 + _S5314) * 0.3333333432674408f) * _S5307 / (_S5307 * _S5307); + k_22 = (1.0f - _S5312.primal_0 * _S5312.primal_0 / 3.0f) / _S5307; + s_diff_k_12 = _S5315; + } + else + { + float _S5316 = (_S5312.differential_0 * _S5306.primal_0 - _S5312.primal_0 * _S5306.differential_0) / (_S5306.primal_0 * _S5306.primal_0); + k_22 = _S5312.primal_0 / _S5306.primal_0; + s_diff_k_12 = _S5316; + } + float2 _S5317 = _S5302 * make_float2 (k_22); + float2 _S5318 = _S5303 * make_float2 (k_22) + make_float2 (s_diff_k_12) * _S5302; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5319; + (&_S5319)->primal_0 = _S5317; + (&_S5319)->differential_0 = _S5318; + FixedArray _S5320 = dist_coeffs_40; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5321 = s_primal_ctx_s_fwd_DistThinPrism_distort_0(&_S5319, &_S5320); + (&_S5301)->_S5296 = _S5321; + float2 _S5322 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5323 = { _S5302, _S5322 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5324; + (&_S5324)->primal_0 = _S5302; + (&_S5324)->differential_0 = _S5322; + DiffPair_float_0 _S5325 = s_primal_ctx_s_fwd_length_impl_0(&_S5324); + DiffPair_float_0 _S5326 = { _S5325.primal_0, _S5325.differential_0 }; + DiffPair_float_0 _S5327; + (&_S5327)->primal_0 = _S5325.primal_0; + (&_S5327)->differential_0 = _S5325.differential_0; + DiffPair_float_0 _S5328; + (&_S5328)->primal_0 = _S5307; + (&_S5328)->differential_0 = 0.0f; + DiffPair_float_0 _S5329 = s_primal_ctx_d_atan2_0(&_S5327, &_S5328); + bool _S5330 = (_S5329.primal_0) < 0.00100000004749745f; + if(_S5330) + { + float _S5331 = _S5329.differential_0 * _S5329.primal_0; + float _S5332 = (0.0f - (_S5331 + _S5331) * 0.3333333432674408f) * _S5307 / (_S5307 * _S5307); + k_22 = (1.0f - _S5329.primal_0 * _S5329.primal_0 / 3.0f) / _S5307; + s_diff_k_12 = _S5332; + } + else + { + float _S5333 = (_S5329.differential_0 * _S5325.primal_0 - _S5329.primal_0 * _S5325.differential_0) / (_S5325.primal_0 * _S5325.primal_0); + k_22 = _S5329.primal_0 / _S5325.primal_0; + s_diff_k_12 = _S5333; + } + float2 _S5334 = _S5302 * make_float2 (k_22); + float2 _S5335 = _S5322 * make_float2 (k_22) + make_float2 (s_diff_k_12) * _S5302; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5336; + (&_S5336)->primal_0 = _S5334; + (&_S5336)->differential_0 = _S5335; + FixedArray _S5337 = dist_coeffs_40; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5338 = s_primal_ctx_s_fwd_DistThinPrism_distort_0(&_S5336, &_S5337); + (&_S5301)->_S5297 = _S5338; + float2 _S5339 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5340 = { _S5302, _S5339 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5341; + (&_S5341)->primal_0 = _S5302; + (&_S5341)->differential_0 = _S5339; + DiffPair_float_0 _S5342 = s_primal_ctx_s_fwd_length_impl_0(&_S5341); + DiffPair_float_0 _S5343 = { _S5342.primal_0, _S5342.differential_0 }; + DiffPair_float_0 _S5344 = { _S5307, 1.0f }; + DiffPair_float_0 _S5345; + (&_S5345)->primal_0 = _S5342.primal_0; + (&_S5345)->differential_0 = _S5342.differential_0; + DiffPair_float_0 _S5346; + (&_S5346)->primal_0 = _S5307; + (&_S5346)->differential_0 = 1.0f; + DiffPair_float_0 _S5347 = s_primal_ctx_d_atan2_0(&_S5345, &_S5346); + bool _S5348 = (_S5347.primal_0) < 0.00100000004749745f; + if(_S5348) + { + float _S5349 = _S5347.differential_0 * _S5347.primal_0; + float _S5350 = 1.0f - _S5347.primal_0 * _S5347.primal_0 / 3.0f; + float _S5351 = ((0.0f - (_S5349 + _S5349) * 0.3333333432674408f) * _S5307 - _S5350) / (_S5307 * _S5307); + k_22 = _S5350 / _S5307; + s_diff_k_12 = _S5351; + } + else + { + float _S5352 = (_S5347.differential_0 * _S5342.primal_0 - _S5347.primal_0 * _S5342.differential_0) / (_S5342.primal_0 * _S5342.primal_0); + k_22 = _S5347.primal_0 / _S5342.primal_0; + s_diff_k_12 = _S5352; + } + float2 _S5353 = _S5302 * make_float2 (k_22); + float2 _S5354 = make_float2 (s_diff_k_12) * _S5302; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5355; + (&_S5355)->primal_0 = _S5353; + (&_S5355)->differential_0 = _S5354; + FixedArray _S5356 = dist_coeffs_40; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5357 = s_primal_ctx_s_fwd_DistThinPrism_distort_0(&_S5355, &_S5356); + (&_S5301)->_S5298 = _S5357; + s_bwd_prop_DiffProjection3DGS_3dgs_fisheye_prism_projection_Intermediates_0 _S5358 = _S5301; + float _S5359 = - in_opacity_28; + float _S5360 = 1.0f + s_primal_ctx_exp_0(_S5359); + float _S5361 = 1.0f / _S5360; + float _S5362 = _S5360 * _S5360; + float4 _S5363 = normalize_0(quat_28); + float3 _S5364 = s_primal_ctx_exp_1(scale_28); + float _S5365 = _S5363.y; + float x2_28 = _S5365 * _S5365; + float y2_28 = _S5363.z * _S5363.z; + float z2_28 = _S5363.w * _S5363.w; + float xy_28 = _S5363.y * _S5363.z; + float xz_28 = _S5363.y * _S5363.w; + float yz_28 = _S5363.z * _S5363.w; + float wx_28 = _S5363.x * _S5363.y; + float wy_28 = _S5363.x * _S5363.z; + float wz_28 = _S5363.x * _S5363.w; + Matrix _S5366 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_28 + z2_28), 2.0f * (xy_28 + wz_28), 2.0f * (xz_28 - wy_28), 2.0f * (xy_28 - wz_28), 1.0f - 2.0f * (x2_28 + z2_28), 2.0f * (yz_28 + wx_28), 2.0f * (xz_28 + wy_28), 2.0f * (yz_28 - wx_28), 1.0f - 2.0f * (x2_28 + y2_28))); + Matrix S_6 = makeMatrix (_S5364.x, 0.0f, 0.0f, 0.0f, _S5364.y, 0.0f, 0.0f, 0.0f, _S5364.z); + Matrix _S5367 = s_primal_ctx_mul_1(_S5366, S_6); + Matrix _S5368 = transpose_3(_S5367); + Matrix _S5369 = s_primal_ctx_mul_1(_S5367, _S5368); + Matrix _S5370 = s_primal_ctx_mul_1(R_28, _S5369); + Matrix _S5371 = transpose_3(R_28); + Matrix _S5372 = s_primal_ctx_mul_1(_S5370, _S5371); + Matrix J_38 = makeMatrix (0.0f); + float _S5373; + float _S5374; + float _S5375; + float _S5376; + float _S5377; + float _S5378; + float _S5379; + float _S5380; + if(_S5313) + { + float _S5381 = _S5312.differential_0 * _S5312.primal_0; + float _S5382 = 1.0f - _S5312.primal_0 * _S5312.primal_0 / 3.0f; + float _S5383 = 0.0f - (_S5381 + _S5381) * 0.3333333432674408f; + float _S5384 = _S5307 * _S5307; + float _S5385 = _S5383 * _S5307; + float _S5386 = _S5385 / _S5384; + float _S5387 = _S5384 * _S5384; + k_22 = _S5382 / _S5307; + s_diff_k_12 = _S5386; + _S5373 = _S5387; + _S5374 = _S5385; + _S5375 = _S5384; + _S5376 = _S5382; + _S5377 = _S5383; + _S5378 = 0.0f; + _S5379 = 0.0f; + _S5380 = 0.0f; + } + else + { + float _S5388 = _S5306.primal_0 * _S5306.primal_0; + float _S5389 = _S5312.differential_0 * _S5306.primal_0 - _S5312.primal_0 * _S5306.differential_0; + float _S5390 = _S5389 / _S5388; + float _S5391 = _S5388 * _S5388; + k_22 = _S5312.primal_0 / _S5306.primal_0; + s_diff_k_12 = _S5390; + _S5373 = 0.0f; + _S5374 = 0.0f; + _S5375 = 0.0f; + _S5376 = 0.0f; + _S5377 = 0.0f; + _S5378 = _S5391; + _S5379 = _S5389; + _S5380 = _S5388; + } + float2 _S5392 = make_float2 (k_22); + float2 _S5393 = make_float2 (s_diff_k_12); + float2 _S5394 = _S5302 * make_float2 (k_22); + float2 _S5395 = _S5303 * make_float2 (k_22) + make_float2 (s_diff_k_12) * _S5302; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5396 = { _S5394, _S5395 }; + float _S5397 = _S5358._S5296.differential_0.x * fx_41; + float _S5398 = _S5358._S5296.differential_0.y * fy_41; + Matrix _S5399 = J_38; + *&(((&_S5399)->rows + (int(0)))->x) = _S5397; + *&(((&_S5399)->rows + (int(1)))->x) = _S5398; + float _S5400; + float _S5401; + float _S5402; + float _S5403; + float _S5404; + float _S5405; + float _S5406; + float _S5407; + if(_S5330) + { + float _S5408 = _S5329.differential_0 * _S5329.primal_0; + float _S5409 = 1.0f - _S5329.primal_0 * _S5329.primal_0 / 3.0f; + float _S5410 = 0.0f - (_S5408 + _S5408) * 0.3333333432674408f; + float _S5411 = _S5307 * _S5307; + float _S5412 = _S5410 * _S5307; + float _S5413 = _S5412 / _S5411; + float _S5414 = _S5411 * _S5411; + k_22 = _S5409 / _S5307; + s_diff_k_12 = _S5413; + _S5400 = _S5414; + _S5401 = _S5412; + _S5402 = _S5411; + _S5403 = _S5409; + _S5404 = _S5410; + _S5405 = 0.0f; + _S5406 = 0.0f; + _S5407 = 0.0f; + } + else + { + float _S5415 = _S5325.primal_0 * _S5325.primal_0; + float _S5416 = _S5329.differential_0 * _S5325.primal_0 - _S5329.primal_0 * _S5325.differential_0; + float _S5417 = _S5416 / _S5415; + float _S5418 = _S5415 * _S5415; + k_22 = _S5329.primal_0 / _S5325.primal_0; + s_diff_k_12 = _S5417; + _S5400 = 0.0f; + _S5401 = 0.0f; + _S5402 = 0.0f; + _S5403 = 0.0f; + _S5404 = 0.0f; + _S5405 = _S5418; + _S5406 = _S5416; + _S5407 = _S5415; + } + float2 _S5419 = make_float2 (k_22); + float2 _S5420 = make_float2 (s_diff_k_12); + float2 _S5421 = _S5302 * make_float2 (k_22); + float2 _S5422 = _S5322 * make_float2 (k_22) + make_float2 (s_diff_k_12) * _S5302; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5423 = { _S5421, _S5422 }; + float _S5424 = _S5358._S5297.differential_0.y * fy_41; + *&(((&_S5399)->rows + (int(0)))->y) = _S5358._S5297.differential_0.x * fx_41; + *&(((&_S5399)->rows + (int(1)))->y) = _S5424; + float _S5425; + float _S5426; + float _S5427; + float _S5428; + float _S5429; + float _S5430; + float _S5431; + float _S5432; + if(_S5348) + { + float _S5433 = _S5347.differential_0 * _S5347.primal_0; + float _S5434 = 1.0f - _S5347.primal_0 * _S5347.primal_0 / 3.0f; + float _S5435 = 0.0f - (_S5433 + _S5433) * 0.3333333432674408f; + float _S5436 = _S5307 * _S5307; + float _S5437 = _S5435 * _S5307 - _S5434; + float _S5438 = _S5437 / _S5436; + float _S5439 = _S5436 * _S5436; + k_22 = _S5434 / _S5307; + s_diff_k_12 = _S5438; + _S5425 = _S5439; + _S5426 = _S5437; + _S5427 = _S5436; + _S5428 = _S5434; + _S5429 = _S5435; + _S5430 = 0.0f; + _S5431 = 0.0f; + _S5432 = 0.0f; + } + else + { + float _S5440 = _S5342.primal_0 * _S5342.primal_0; + float _S5441 = _S5347.differential_0 * _S5342.primal_0 - _S5347.primal_0 * _S5342.differential_0; + float _S5442 = _S5441 / _S5440; + float _S5443 = _S5440 * _S5440; + k_22 = _S5347.primal_0 / _S5342.primal_0; + s_diff_k_12 = _S5442; + _S5425 = 0.0f; + _S5426 = 0.0f; + _S5427 = 0.0f; + _S5428 = 0.0f; + _S5429 = 0.0f; + _S5430 = _S5443; + _S5431 = _S5441; + _S5432 = _S5440; + } + float2 _S5444 = make_float2 (k_22); + float2 _S5445 = make_float2 (s_diff_k_12); + float2 _S5446 = _S5302 * make_float2 (k_22); + float2 _S5447 = make_float2 (s_diff_k_12) * _S5302; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5448 = { _S5446, _S5447 }; + float _S5449 = _S5358._S5298.differential_0.y * fy_41; + *&(((&_S5399)->rows + (int(0)))->z) = _S5358._S5298.differential_0.x * fx_41; + *&(((&_S5399)->rows + (int(1)))->z) = _S5449; + Matrix _S5450 = s_primal_ctx_mul_2(_S5399, _S5372); + Matrix _S5451 = transpose_1(_S5399); + Matrix _S5452 = s_primal_ctx_mul_3(_S5450, _S5451); + float eps2d_28; + if(antialiased_28) + { + eps2d_28 = 0.10000000149011612f; + } + else + { + eps2d_28 = 0.30000001192092896f; + } + float _S5453 = _S5452.rows[int(0)].y * _S5452.rows[int(1)].x; + float det_orig_28 = _S5452.rows[int(0)].x * _S5452.rows[int(1)].y - _S5453; + float _S5454 = _S5452.rows[int(0)].x + eps2d_28; + Matrix _S5455 = _S5452; + *&(((&_S5455)->rows + (int(0)))->x) = _S5454; + float _S5456 = _S5452.rows[int(1)].y + eps2d_28; + *&(((&_S5455)->rows + (int(1)))->y) = _S5456; + Matrix _S5457 = _S5455; + Matrix _S5458 = _S5455; + float det_blur_28 = _S5454 * _S5456 - _S5453; + float _S5459 = det_orig_28 / det_blur_28; + float _S5460 = det_blur_28 * det_blur_28; + float _S5461 = (F32_max((0.0f), (_S5459))); + float _S5462 = s_primal_ctx_sqrt_0(_S5461); + float invdet_34 = 1.0f / det_blur_28; + float _S5463 = - _S5452.rows[int(0)].y; + float _S5464 = - _S5452.rows[int(1)].x; + if(antialiased_28) + { + k_22 = _S5361 * _S5462; + } + else + { + k_22 = _S5361; + } + float _S5465 = k_22 / 0.00392156885936856f; + float _S5466 = 2.0f * s_primal_ctx_log_0(_S5465); + float _S5467 = s_primal_ctx_sqrt_0(_S5466); + float _S5468 = _S5457.rows[int(0)].x; + float _S5469 = _S5458.rows[int(1)].y; + float3 campos_7 = - s_primal_ctx_mul_0(_S5371, t_28); + float3 _S5470 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5471; + (&_S5471)->primal_0 = mean_29; + (&_S5471)->differential_0 = _S5470; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5472; + (&_S5472)->primal_0 = scale_28; + (&_S5472)->differential_0 = _S5470; + DiffPair_float_0 _S5473; + (&_S5473)->primal_0 = in_opacity_28; + (&_S5473)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5474; + (&_S5474)->primal_0 = campos_7; + (&_S5474)->differential_0 = _S5470; + s_bwd_prop_view_radius_3dgs_0(&_S5471, &_S5472, &_S5473, &_S5474, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5475 = _S5471; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5476 = _S5472; + DiffPair_float_0 _S5477 = _S5473; + float2 _S5478 = _S5299; + *&((&_S5478)->y) = v_conic_6.z; + float2 _S5479 = _S5299; + *&((&_S5479)->y) = v_conic_6.y; + *&((&_S5479)->x) = v_conic_6.x; + DiffPair_float_0 _S5480; + (&_S5480)->primal_0 = _S5469; + (&_S5480)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5480, 0.0f); + DiffPair_float_0 _S5481; + (&_S5481)->primal_0 = _S5468; + (&_S5481)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5481, 0.0f); + DiffPair_float_0 _S5482; + (&_S5482)->primal_0 = 3.32999992370605469f; + (&_S5482)->differential_0 = 0.0f; + DiffPair_float_0 _S5483; + (&_S5483)->primal_0 = _S5467; + (&_S5483)->differential_0 = 0.0f; + _d_min_0(&_S5482, &_S5483, 0.0f); + DiffPair_float_0 _S5484; + (&_S5484)->primal_0 = _S5466; + (&_S5484)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5484, _S5483.differential_0); + float _S5485 = 2.0f * _S5484.differential_0; + DiffPair_float_0 _S5486; + (&_S5486)->primal_0 = _S5465; + (&_S5486)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S5486, _S5485); + float _S5487 = v_opacity_6 + 254.9999847412109375f * _S5486.differential_0; + Matrix _S5488 = makeMatrix (0.0f); + Matrix _S5489 = _S5488; + _S5489[int(1)] = _S5478; + _S5489[int(0)] = _S5479; + Matrix _S5490 = _S5489; + float2 _S5491 = make_float2 (0.0f, _S5480.differential_0); + float2 _S5492 = make_float2 (_S5481.differential_0, 0.0f); + if(antialiased_28) + { + float _S5493 = _S5462 * _S5487; + k_22 = _S5361 * _S5487; + s_diff_k_12 = _S5493; + } + else + { + k_22 = 0.0f; + s_diff_k_12 = _S5487; + } + float _S5494 = invdet_34 * _S5490.rows[int(1)].y; + float _S5495 = - (invdet_34 * _S5490.rows[int(1)].x); + float _S5496 = - (invdet_34 * _S5490.rows[int(0)].y); + float _S5497 = invdet_34 * _S5490.rows[int(0)].x; + float _S5498 = - ((_S5454 * _S5490.rows[int(1)].y + _S5464 * _S5490.rows[int(1)].x + _S5463 * _S5490.rows[int(0)].y + _S5456 * _S5490.rows[int(0)].x) / _S5460); + DiffPair_float_0 _S5499; + (&_S5499)->primal_0 = _S5461; + (&_S5499)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5499, k_22); + DiffPair_float_0 _S5500 = { 0.0f, 0.0f }; + DiffPair_float_0 _S5501; + (&_S5501)->primal_0 = 0.0f; + (&_S5501)->differential_0 = 0.0f; + DiffPair_float_0 _S5502; + (&_S5502)->primal_0 = _S5459; + (&_S5502)->differential_0 = 0.0f; + _d_max_0(&_S5501, &_S5502, _S5499.differential_0); + float _S5503 = _S5502.differential_0 / _S5460; + float s_diff_det_orig_T_6 = det_blur_28 * _S5503; + float _S5504 = det_orig_28 * - _S5503 + _S5498; + float _S5505 = - _S5504; + float _S5506 = _S5454 * _S5504; + float _S5507 = _S5456 * _S5504; + Matrix _S5508 = _S5488; + _S5508[int(1)] = _S5491; + _S5508[int(0)] = _S5492; + _S5455 = _S5508; + *&(((&_S5455)->rows + (int(1)))->y) = 0.0f; + float _S5509 = _S5506 + _S5508.rows[int(1)].y + _S5497; + *&(((&_S5455)->rows + (int(0)))->x) = 0.0f; + float _S5510 = _S5507 + _S5508.rows[int(0)].x + _S5494; + float _S5511 = _S5505 + - s_diff_det_orig_T_6; + float _S5512 = _S5452.rows[int(0)].y * _S5511 + _S5495; + float _S5513 = _S5452.rows[int(1)].x * _S5511 + _S5496; + float _S5514 = _S5452.rows[int(1)].y * s_diff_det_orig_T_6; + float _S5515 = _S5509 + _S5452.rows[int(0)].x * s_diff_det_orig_T_6; + float2 _S5516 = _S5299; + *&((&_S5516)->x) = _S5512; + *&((&_S5516)->y) = _S5515; + float _S5517 = _S5510 + _S5514; + float2 _S5518 = _S5299; + *&((&_S5518)->y) = _S5513; + *&((&_S5518)->x) = _S5517; + Matrix _S5519 = _S5488; + _S5519[int(1)] = _S5516; + _S5519[int(0)] = _S5518; + Matrix _S5520 = _S5455 + _S5519; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S5521; + (&_S5521)->primal_0 = _S5450; + (&_S5521)->differential_0 = J_38; + Matrix _S5522 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S5523; + (&_S5523)->primal_0 = _S5451; + (&_S5523)->differential_0 = _S5522; + s_bwd_prop_mul_0(&_S5521, &_S5523, _S5520); + Matrix _S5524 = transpose_2(_S5523.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S5525; + (&_S5525)->primal_0 = _S5399; + (&_S5525)->differential_0 = J_38; + Matrix _S5526 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5527; + (&_S5527)->primal_0 = _S5372; + (&_S5527)->differential_0 = _S5526; + s_bwd_prop_mul_1(&_S5525, &_S5527, _S5521.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5528 = _S5527; + Matrix _S5529 = _S5524 + _S5525.differential_0; + float2 _S5530 = make_float2 (fx_41 * _S5529.rows[int(0)].z, fy_41 * _S5529.rows[int(1)].z); + DiffPair_0 _S5531; + (&_S5531)->primal_0 = _S5448; + (&_S5531)->differential_0 = _S5300; + FixedArray _S5532 = dist_coeffs_40; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5533; + (&_S5533)->primal_0 = _S5339; + (&_S5533)->differential_0 = _S5530; + s_bwd_prop_s_fwd_DistThinPrism_distort_0(&_S5531, &_S5532, &_S5533); + float2 _S5534 = _S5302 * _S5531.differential_0.differential_0; + float2 _S5535 = _S5302 * _S5531.differential_0.primal_0; + float _S5536 = _S5535.x + _S5535.y; + float _S5537 = _S5534.x + _S5534.y; + float2 _S5538 = _S5445 * _S5531.differential_0.differential_0 + _S5444 * _S5531.differential_0.primal_0; + if(_S5348) + { + float _S5539 = _S5537 / _S5425; + float _S5540 = _S5427 * _S5539; + float _S5541 = _S5307 * (_S5426 * - _S5539); + float _S5542 = _S5536 / _S5427; + float _S5543 = 0.3333333432674408f * - (_S5307 * _S5540); + float _S5544 = _S5543 + _S5543; + float _S5545 = _S5347.primal_0 * (0.3333333432674408f * - (- _S5540 + _S5307 * _S5542)); + float _S5546 = _S5541 + _S5541 + _S5429 * _S5540 + _S5428 * - _S5542; + float _S5547 = _S5347.differential_0 * _S5544 + _S5545 + _S5545; + k_22 = _S5347.primal_0 * _S5544; + _S5425 = _S5547; + _S5426 = _S5546; + _S5427 = 0.0f; + _S5428 = 0.0f; + } + else + { + float _S5548 = _S5537 / _S5430; + float _S5549 = _S5432 * _S5548; + float _S5550 = _S5342.primal_0 * (_S5431 * - _S5548); + float _S5551 = - _S5549; + float _S5552 = _S5347.primal_0 * _S5551; + float _S5553 = _S5536 / _S5432; + float _S5554 = _S5550 + _S5550 + _S5347.differential_0 * _S5549 + _S5347.primal_0 * - _S5553; + float _S5555 = _S5342.differential_0 * _S5551 + _S5342.primal_0 * _S5553; + k_22 = _S5342.primal_0 * _S5549; + _S5425 = _S5555; + _S5426 = 0.0f; + _S5427 = _S5552; + _S5428 = _S5554; + } + DiffPair_1 _S5556; + (&_S5556)->primal_0 = _S5343; + (&_S5556)->differential_0 = _S5500; + DiffPair_1 _S5557; + (&_S5557)->primal_0 = _S5344; + (&_S5557)->differential_0 = _S5500; + DiffPair_float_0 _S5558; + (&_S5558)->primal_0 = _S5425; + (&_S5558)->differential_0 = k_22; + s_bwd_prop_d_atan2_0(&_S5556, &_S5557, &_S5558); + float _S5559 = _S5557.differential_0.primal_0 + _S5426; + float _S5560 = _S5556.differential_0.differential_0 + _S5427; + float _S5561 = _S5556.differential_0.primal_0 + _S5428; + DiffPair_0 _S5562; + (&_S5562)->primal_0 = _S5340; + (&_S5562)->differential_0 = _S5300; + DiffPair_float_0 _S5563; + (&_S5563)->primal_0 = _S5561; + (&_S5563)->differential_0 = _S5560; + s_bwd_prop_s_fwd_length_impl_0(&_S5562, &_S5563); + float2 _S5564 = _S5562.differential_0.primal_0 + _S5538; + float3 _S5565 = make_float3 (_S5564.x, _S5564.y, _S5559); + float2 _S5566 = make_float2 (fx_41 * _S5529.rows[int(0)].y, fy_41 * _S5529.rows[int(1)].y); + DiffPair_0 _S5567; + (&_S5567)->primal_0 = _S5423; + (&_S5567)->differential_0 = _S5300; + FixedArray _S5568 = dist_coeffs_40; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5569; + (&_S5569)->primal_0 = _S5339; + (&_S5569)->differential_0 = _S5566; + s_bwd_prop_s_fwd_DistThinPrism_distort_0(&_S5567, &_S5568, &_S5569); + DiffPair_0 _S5570 = _S5567; + float2 _S5571 = _S5302 * _S5570.differential_0.differential_0; + float2 _S5572 = _S5322 * _S5570.differential_0.differential_0; + float2 _S5573 = _S5302 * _S5570.differential_0.primal_0; + float _S5574 = _S5572.x + _S5572.y + _S5573.x + _S5573.y; + float _S5575 = _S5571.x + _S5571.y; + float2 _S5576 = _S5420 * _S5570.differential_0.differential_0 + _S5419 * _S5570.differential_0.primal_0; + if(_S5330) + { + float _S5577 = _S5575 / _S5400; + float _S5578 = _S5402 * _S5577; + float _S5579 = _S5307 * (_S5401 * - _S5577); + float _S5580 = _S5574 / _S5402; + float _S5581 = 0.3333333432674408f * - (_S5307 * _S5578); + float _S5582 = _S5581 + _S5581; + float _S5583 = _S5329.primal_0 * (0.3333333432674408f * - (_S5307 * _S5580)); + float _S5584 = _S5579 + _S5579 + _S5404 * _S5578 + _S5403 * - _S5580; + float _S5585 = _S5329.differential_0 * _S5582 + _S5583 + _S5583; + k_22 = _S5329.primal_0 * _S5582; + _S5400 = _S5585; + _S5401 = _S5584; + _S5402 = 0.0f; + _S5403 = 0.0f; + } + else + { + float _S5586 = _S5575 / _S5405; + float _S5587 = _S5407 * _S5586; + float _S5588 = _S5325.primal_0 * (_S5406 * - _S5586); + float _S5589 = - _S5587; + float _S5590 = _S5329.primal_0 * _S5589; + float _S5591 = _S5574 / _S5407; + float _S5592 = _S5588 + _S5588 + _S5329.differential_0 * _S5587 + _S5329.primal_0 * - _S5591; + float _S5593 = _S5325.differential_0 * _S5589 + _S5325.primal_0 * _S5591; + k_22 = _S5325.primal_0 * _S5587; + _S5400 = _S5593; + _S5401 = 0.0f; + _S5402 = _S5590; + _S5403 = _S5592; + } + DiffPair_1 _S5594; + (&_S5594)->primal_0 = _S5326; + (&_S5594)->differential_0 = _S5500; + DiffPair_1 _S5595; + (&_S5595)->primal_0 = _S5309; + (&_S5595)->differential_0 = _S5500; + DiffPair_float_0 _S5596; + (&_S5596)->primal_0 = _S5400; + (&_S5596)->differential_0 = k_22; + s_bwd_prop_d_atan2_0(&_S5594, &_S5595, &_S5596); + float _S5597 = _S5595.differential_0.primal_0 + _S5401; + float _S5598 = _S5594.differential_0.differential_0 + _S5402; + float _S5599 = _S5594.differential_0.primal_0 + _S5403; + DiffPair_0 _S5600; + (&_S5600)->primal_0 = _S5323; + (&_S5600)->differential_0 = _S5300; + DiffPair_float_0 _S5601; + (&_S5601)->primal_0 = _S5599; + (&_S5601)->differential_0 = _S5598; + s_bwd_prop_s_fwd_length_impl_0(&_S5600, &_S5601); + float2 _S5602 = _S5600.differential_0.primal_0 + _S5576; + float3 _S5603 = make_float3 (_S5602.x, _S5602.y, _S5597); + float2 _S5604 = make_float2 (fx_41 * _S5529.rows[int(0)].x, fy_41 * _S5529.rows[int(1)].x); + DiffPair_0 _S5605; + (&_S5605)->primal_0 = _S5396; + (&_S5605)->differential_0 = _S5300; + FixedArray _S5606 = dist_coeffs_40; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5607; + (&_S5607)->primal_0 = _S5339; + (&_S5607)->differential_0 = _S5604; + s_bwd_prop_s_fwd_DistThinPrism_distort_0(&_S5605, &_S5606, &_S5607); + DiffPair_0 _S5608 = _S5605; + float3 _S5609 = _S5603 + _S5565; + float2 _S5610 = _S5302 * _S5608.differential_0.differential_0; + float2 _S5611 = _S5303 * _S5608.differential_0.differential_0; + float2 _S5612 = _S5302 * _S5608.differential_0.primal_0; + float _S5613 = _S5611.x + _S5611.y + _S5612.x + _S5612.y; + float _S5614 = _S5610.x + _S5610.y; + float2 _S5615 = _S5393 * _S5608.differential_0.differential_0 + _S5392 * _S5608.differential_0.primal_0; + if(_S5313) + { + float _S5616 = _S5614 / _S5373; + float _S5617 = _S5375 * _S5616; + float _S5618 = _S5307 * (_S5374 * - _S5616); + float _S5619 = _S5613 / _S5375; + float _S5620 = 0.3333333432674408f * - (_S5307 * _S5617); + float _S5621 = _S5620 + _S5620; + float _S5622 = _S5312.primal_0 * (0.3333333432674408f * - (_S5307 * _S5619)); + float _S5623 = _S5618 + _S5618 + _S5377 * _S5617 + _S5376 * - _S5619; + float _S5624 = _S5312.differential_0 * _S5621 + _S5622 + _S5622; + k_22 = _S5312.primal_0 * _S5621; + _S5373 = _S5624; + _S5374 = _S5623; + _S5375 = 0.0f; + _S5376 = 0.0f; + } + else + { + float _S5625 = _S5614 / _S5378; + float _S5626 = _S5380 * _S5625; + float _S5627 = _S5306.primal_0 * (_S5379 * - _S5625); + float _S5628 = - _S5626; + float _S5629 = _S5312.primal_0 * _S5628; + float _S5630 = _S5613 / _S5380; + float _S5631 = _S5627 + _S5627 + _S5312.differential_0 * _S5626 + _S5312.primal_0 * - _S5630; + float _S5632 = _S5306.differential_0 * _S5628 + _S5306.primal_0 * _S5630; + k_22 = _S5306.primal_0 * _S5626; + _S5373 = _S5632; + _S5374 = 0.0f; + _S5375 = _S5629; + _S5376 = _S5631; + } + DiffPair_1 _S5633; + (&_S5633)->primal_0 = _S5308; + (&_S5633)->differential_0 = _S5500; + DiffPair_1 _S5634; + (&_S5634)->primal_0 = _S5309; + (&_S5634)->differential_0 = _S5500; + DiffPair_float_0 _S5635; + (&_S5635)->primal_0 = _S5373; + (&_S5635)->differential_0 = k_22; + s_bwd_prop_d_atan2_0(&_S5633, &_S5634, &_S5635); + float _S5636 = _S5634.differential_0.primal_0 + _S5374; + float _S5637 = _S5633.differential_0.differential_0 + _S5375; + float _S5638 = _S5633.differential_0.primal_0 + _S5376; + DiffPair_0 _S5639; + (&_S5639)->primal_0 = _S5304; + (&_S5639)->differential_0 = _S5300; + DiffPair_float_0 _S5640; + (&_S5640)->primal_0 = _S5638; + (&_S5640)->differential_0 = _S5637; + s_bwd_prop_s_fwd_length_impl_0(&_S5639, &_S5640); + float2 _S5641 = _S5639.differential_0.primal_0 + _S5615; + float3 _S5642 = make_float3 (_S5641.x, _S5641.y, _S5636); + float _S5643 = length_0(_S5302); + float _S5644 = s_primal_ctx_atan2_0(_S5643, _S5307); + bool _S5645 = _S5644 < 0.00100000004749745f; + if(_S5645) + { + float _S5646 = 1.0f - _S5644 * _S5644 / 3.0f; + float _S5647 = _S5307 * _S5307; + k_22 = _S5646 / _S5307; + _S5373 = _S5647; + _S5374 = _S5646; + _S5375 = 0.0f; + } + else + { + float _S5648 = _S5643 * _S5643; + k_22 = _S5644 / _S5643; + _S5373 = 0.0f; + _S5374 = 0.0f; + _S5375 = _S5648; + } + float2 _S5649 = make_float2 (k_22); + float2 _S5650 = _S5302 * make_float2 (k_22); + float2 _S5651 = make_float2 (fx_41 * v_mean2d_6.x, fy_41 * v_mean2d_6.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5652; + (&_S5652)->primal_0 = _S5650; + (&_S5652)->differential_0 = _S5299; + FixedArray _S5653 = dist_coeffs_40; + s_bwd_prop_DistThinPrism_distort_0(&_S5652, &_S5653, _S5651); + float2 _S5654 = _S5302 * _S5652.differential_0; + float2 _S5655 = _S5649 * _S5652.differential_0; + float _S5656 = _S5654.x + _S5654.y; + if(_S5645) + { + float _S5657 = _S5656 / _S5373; + float _S5658 = _S5374 * - _S5657; + float _S5659 = _S5644 * (0.3333333432674408f * - (_S5307 * _S5657)); + k_22 = _S5659 + _S5659; + _S5373 = _S5658; + _S5374 = 0.0f; + } + else + { + float _S5660 = _S5656 / _S5375; + float _S5661 = _S5644 * - _S5660; + k_22 = _S5643 * _S5660; + _S5373 = 0.0f; + _S5374 = _S5661; + } + DiffPair_float_0 _S5662; + (&_S5662)->primal_0 = _S5643; + (&_S5662)->differential_0 = 0.0f; + DiffPair_float_0 _S5663; + (&_S5663)->primal_0 = _S5307; + (&_S5663)->differential_0 = 0.0f; + s_bwd_prop_atan2_0(&_S5662, &_S5663, k_22); + float _S5664 = _S5663.differential_0 + _S5373; + float _S5665 = _S5662.differential_0 + _S5374; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5666; + (&_S5666)->primal_0 = _S5302; + (&_S5666)->differential_0 = _S5299; + s_bwd_length_impl_2(&_S5666, _S5665); + float2 _S5667 = _S5666.differential_0 + _S5655; + float3 _S5668 = make_float3 (_S5667.x, _S5667.y, _S5664); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5669; + (&_S5669)->primal_0 = _S5370; + (&_S5669)->differential_0 = _S5526; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5670; + (&_S5670)->primal_0 = _S5371; + (&_S5670)->differential_0 = _S5526; + s_bwd_prop_mul_2(&_S5669, &_S5670, _S5528.differential_0); + Matrix _S5671 = transpose_3(_S5670.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5672; + (&_S5672)->primal_0 = R_28; + (&_S5672)->differential_0 = _S5526; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5673; + (&_S5673)->primal_0 = _S5369; + (&_S5673)->differential_0 = _S5526; + s_bwd_prop_mul_2(&_S5672, &_S5673, _S5669.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5674; + (&_S5674)->primal_0 = _S5367; + (&_S5674)->differential_0 = _S5526; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5675; + (&_S5675)->primal_0 = _S5368; + (&_S5675)->differential_0 = _S5526; + s_bwd_prop_mul_2(&_S5674, &_S5675, _S5673.differential_0); + Matrix _S5676 = _S5674.differential_0 + transpose_3(_S5675.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5677; + (&_S5677)->primal_0 = _S5366; + (&_S5677)->differential_0 = _S5526; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5678; + (&_S5678)->primal_0 = S_6; + (&_S5678)->differential_0 = _S5526; + s_bwd_prop_mul_2(&_S5677, &_S5678, _S5676); + Matrix _S5679 = transpose_3(_S5677.differential_0); + float _S5680 = 2.0f * - _S5679.rows[int(2)].z; + float _S5681 = 2.0f * _S5679.rows[int(2)].y; + float _S5682 = 2.0f * _S5679.rows[int(2)].x; + float _S5683 = 2.0f * _S5679.rows[int(1)].z; + float _S5684 = 2.0f * - _S5679.rows[int(1)].y; + float _S5685 = 2.0f * _S5679.rows[int(1)].x; + float _S5686 = 2.0f * _S5679.rows[int(0)].z; + float _S5687 = 2.0f * _S5679.rows[int(0)].y; + float _S5688 = 2.0f * - _S5679.rows[int(0)].x; + float _S5689 = - _S5685 + _S5687; + float _S5690 = _S5682 + - _S5686; + float _S5691 = - _S5681 + _S5683; + float _S5692 = _S5681 + _S5683; + float _S5693 = _S5682 + _S5686; + float _S5694 = _S5685 + _S5687; + float _S5695 = _S5363.w * (_S5684 + _S5688); + float _S5696 = _S5363.z * (_S5680 + _S5688); + float _S5697 = _S5363.y * (_S5680 + _S5684); + float _S5698 = _S5363.x * _S5689 + _S5363.z * _S5692 + _S5363.y * _S5693 + _S5695 + _S5695; + float _S5699 = _S5363.x * _S5690 + _S5363.w * _S5692 + _S5363.y * _S5694 + _S5696 + _S5696; + float _S5700 = _S5363.x * _S5691 + _S5363.w * _S5693 + _S5363.z * _S5694 + _S5697 + _S5697; + float _S5701 = _S5363.w * _S5689 + _S5363.z * _S5690 + _S5363.y * _S5691; + float3 _S5702 = _S5470; + *&((&_S5702)->z) = _S5678.differential_0.rows[int(2)].z; + *&((&_S5702)->y) = _S5678.differential_0.rows[int(1)].y; + *&((&_S5702)->x) = _S5678.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5703; + (&_S5703)->primal_0 = scale_28; + (&_S5703)->differential_0 = _S5470; + s_bwd_prop_exp_1(&_S5703, _S5702); + float4 _S5704 = make_float4 (0.0f); + float4 _S5705 = _S5704; + *&((&_S5705)->w) = _S5698; + *&((&_S5705)->z) = _S5699; + *&((&_S5705)->y) = _S5700; + *&((&_S5705)->x) = _S5701; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S5706; + (&_S5706)->primal_0 = quat_28; + (&_S5706)->differential_0 = _S5704; + s_bwd_normalize_impl_0(&_S5706, _S5705); + float _S5707 = - (s_diff_k_12 / _S5362); + DiffPair_float_0 _S5708; + (&_S5708)->primal_0 = _S5359; + (&_S5708)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S5708, _S5707); + float _S5709 = - _S5708.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5710; + (&_S5710)->primal_0 = mean_c_28; + (&_S5710)->differential_0 = _S5470; + s_bwd_length_impl_0(&_S5710, v_depth_6); + float3 _S5711 = _S5642 + _S5668 + _S5710.differential_0 + _S5609; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5712; + (&_S5712)->primal_0 = R_28; + (&_S5712)->differential_0 = _S5526; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5713; + (&_S5713)->primal_0 = mean_29; + (&_S5713)->differential_0 = _S5470; + s_bwd_prop_mul_3(&_S5712, &_S5713, _S5711); + Matrix _S5714 = _S5671 + _S5672.differential_0 + _S5712.differential_0; + float _S5715 = _S5709 + _S5477.differential_0; + float3 _S5716 = _S5703.differential_0 + _S5476.differential_0; + *v_mean_6 = *v_mean_6 + (_S5713.differential_0 + _S5475.differential_0); + *v_quat_6 = *v_quat_6 + _S5706.differential_0; + *v_scale_6 = *v_scale_6 + _S5716; + *v_in_opacity_6 = *v_in_opacity_6 + _S5715; + *v_R_6 = *v_R_6 + _S5714; + *v_t_6 = *v_t_6 + _S5711; return; } -inline __device__ void s_bwd_prop_length_impl_2(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpx_18, float _s_dOut_7) +struct s_bwd_prop_DiffProjection3DGS_3dgs_equisolid_none_projection_Intermediates_0 { - float _S1824 = (*dpx_18).primal_0.x; - float _S1825 = (*dpx_18).primal_0.y; - DiffPair_float_0 _S1826; - (&_S1826)->primal_0 = _S1824 * _S1824 + _S1825 * _S1825; - (&_S1826)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S1826, _s_dOut_7); - float _S1827 = (*dpx_18).primal_0.y * _S1826.differential_0; - float _S1828 = _S1827 + _S1827; - float _S1829 = (*dpx_18).primal_0.x * _S1826.differential_0; - float _S1830 = _S1829 + _S1829; - float2 _S1831 = make_float2 (0.0f); - *&((&_S1831)->y) = _S1828; - *&((&_S1831)->x) = _S1830; - dpx_18->primal_0 = (*dpx_18).primal_0; - dpx_18->differential_0 = _S1831; - return; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5717; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5718; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5719; +}; + +inline __device__ float s_primal_ctx_sin_0(float _S5720) +{ + return (F32_sin((_S5720))); } -inline __device__ void s_bwd_length_impl_2(DiffPair_vectorx3Cfloatx2C2x3E_0 * _S1832, float _S1833) +inline __device__ float s_primal_ctx_cos_0(float _S5721) { - s_bwd_prop_length_impl_2(_S1832, _S1833); - return; -} - -inline __device__ void projection_3dgs_fisheye_vjp(bool antialiased_9, float3 mean_10, float4 quat_9, float3 scale_9, float in_opacity_9, Matrix R_9, float3 t_9, float fx_13, float fy_13, float cx_10, float cy_10, FixedArray dist_coeffs_13, uint image_width_9, uint image_height_9, float2 v_mean2d_1, float v_depth_1, float3 v_conic_1, float v_opacity_1, float3 * v_mean_1, float4 * v_quat_1, float3 * v_scale_1, float * v_in_opacity_1, Matrix * v_R_1, float3 * v_t_1) -{ - float3 mean_c_9 = s_primal_ctx_mul_0(R_9, mean_10) + t_9; - float _S1834 = - in_opacity_9; - float _S1835 = 1.0f + s_primal_ctx_exp_0(_S1834); - float _S1836 = 1.0f / _S1835; - float _S1837 = _S1835 * _S1835; - float4 _S1838 = normalize_0(quat_9); - float3 _S1839 = s_primal_ctx_exp_1(scale_9); - float _S1840 = _S1838.y; - float x2_9 = _S1840 * _S1840; - float y2_9 = _S1838.z * _S1838.z; - float z2_9 = _S1838.w * _S1838.w; - float xy_9 = _S1838.y * _S1838.z; - float xz_9 = _S1838.y * _S1838.w; - float yz_9 = _S1838.z * _S1838.w; - float wx_9 = _S1838.x * _S1838.y; - float wy_9 = _S1838.x * _S1838.z; - float wz_9 = _S1838.x * _S1838.w; - Matrix _S1841 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_9 + z2_9), 2.0f * (xy_9 + wz_9), 2.0f * (xz_9 - wy_9), 2.0f * (xy_9 - wz_9), 1.0f - 2.0f * (x2_9 + z2_9), 2.0f * (yz_9 + wx_9), 2.0f * (xz_9 + wy_9), 2.0f * (yz_9 - wx_9), 1.0f - 2.0f * (x2_9 + y2_9))); - Matrix S_1 = makeMatrix (_S1839.x, 0.0f, 0.0f, 0.0f, _S1839.y, 0.0f, 0.0f, 0.0f, _S1839.z); - Matrix _S1842 = s_primal_ctx_mul_1(_S1841, S_1); - Matrix _S1843 = transpose_3(_S1842); - Matrix _S1844 = s_primal_ctx_mul_1(_S1842, _S1843); - Matrix _S1845 = s_primal_ctx_mul_1(R_9, _S1844); - Matrix _S1846 = transpose_3(R_9); - Matrix _S1847 = s_primal_ctx_mul_1(_S1845, _S1846); - Matrix J_11 = makeMatrix (0.0f); - float2 _S1848 = float2 {mean_c_9.x, mean_c_9.y}; - float2 _S1849 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S1850 = { _S1848, _S1849 }; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S1851; - (&_S1851)->primal_0 = _S1848; - (&_S1851)->differential_0 = _S1849; - DiffPair_float_0 _S1852 = s_primal_ctx_s_fwd_length_impl_0(&_S1851); - float _S1853 = mean_c_9.z; - DiffPair_float_0 _S1854 = { _S1852.primal_0, _S1852.differential_0 }; - DiffPair_float_0 _S1855 = { _S1853, 0.0f }; - DiffPair_float_0 _S1856; - (&_S1856)->primal_0 = _S1852.primal_0; - (&_S1856)->differential_0 = _S1852.differential_0; - DiffPair_float_0 _S1857; - (&_S1857)->primal_0 = _S1853; - (&_S1857)->differential_0 = 0.0f; - DiffPair_float_0 _S1858 = s_primal_ctx_d_atan2_0(&_S1856, &_S1857); - bool _S1859 = (_S1858.primal_0) < 0.00100000004749745f; - float k_6; - float s_diff_k_2; - float _S1860; - float _S1861; - float _S1862; - float _S1863; - float _S1864; - float _S1865; - float _S1866; - float _S1867; - if(_S1859) - { - float _S1868 = _S1858.differential_0 * _S1858.primal_0; - float _S1869 = 1.0f - _S1858.primal_0 * _S1858.primal_0 / 3.0f; - float _S1870 = 0.0f - (_S1868 + _S1868) * 0.3333333432674408f; - float _S1871 = _S1853 * _S1853; - float _S1872 = _S1870 * _S1853; - float _S1873 = _S1872 / _S1871; - float _S1874 = _S1871 * _S1871; - k_6 = _S1869 / _S1853; - s_diff_k_2 = _S1873; - _S1860 = _S1874; - _S1861 = _S1872; - _S1862 = _S1871; - _S1863 = _S1869; - _S1864 = _S1870; - _S1865 = 0.0f; - _S1866 = 0.0f; - _S1867 = 0.0f; - } - else - { - float _S1875 = _S1852.primal_0 * _S1852.primal_0; - float _S1876 = _S1858.differential_0 * _S1852.primal_0 - _S1858.primal_0 * _S1852.differential_0; - float _S1877 = _S1876 / _S1875; - float _S1878 = _S1875 * _S1875; - k_6 = _S1858.primal_0 / _S1852.primal_0; - s_diff_k_2 = _S1877; - _S1860 = 0.0f; - _S1861 = 0.0f; - _S1862 = 0.0f; - _S1863 = 0.0f; - _S1864 = 0.0f; - _S1865 = _S1878; - _S1866 = _S1876; - _S1867 = _S1875; - } - float2 _S1879 = make_float2 (k_6); - float2 _S1880 = make_float2 (s_diff_k_2); - float2 _S1881 = _S1848 * make_float2 (k_6); - float2 _S1882 = _S1849 * make_float2 (k_6) + make_float2 (s_diff_k_2) * _S1848; - float u_76 = _S1881.x; - float s_diff_u_21 = _S1882.x; - float v_76 = _S1881.y; - float s_diff_v_21 = _S1882.y; - float _S1883 = s_diff_u_21 * u_76; - float _S1884 = s_diff_v_21 * v_76; - float r2_76 = u_76 * u_76 + v_76 * v_76; - float s_diff_r2_21 = _S1883 + _S1883 + (_S1884 + _S1884); - float _S1885 = s_diff_r2_21 * dist_coeffs_13[int(3)]; - float _S1886 = dist_coeffs_13[int(2)] + r2_76 * dist_coeffs_13[int(3)]; - float _S1887 = s_diff_r2_21 * _S1886 + _S1885 * r2_76; - float _S1888 = dist_coeffs_13[int(1)] + r2_76 * _S1886; - float _S1889 = s_diff_r2_21 * _S1888 + _S1887 * r2_76; - float _S1890 = dist_coeffs_13[int(0)] + r2_76 * _S1888; - float _S1891 = s_diff_r2_21 * _S1890 + _S1889 * r2_76; - float2 _S1892 = make_float2 (_S1891); - float radial_30 = 1.0f + r2_76 * _S1890; - float2 _S1893 = make_float2 (radial_30); - float _S1894 = 2.0f * dist_coeffs_13[int(4)]; - float _S1895 = _S1894 * u_76; - float _S1896 = s_diff_u_21 * _S1894; - float _S1897 = 2.0f * u_76; - float _S1898 = s_diff_u_21 * 2.0f; - float _S1899 = 2.0f * dist_coeffs_13[int(5)]; - float _S1900 = _S1899 * u_76; - float _S1901 = s_diff_u_21 * _S1899; - float _S1902 = 2.0f * v_76; - float _S1903 = s_diff_v_21 * 2.0f; - float2 _S1904 = _S1882 * make_float2 (radial_30) + make_float2 (_S1891) * _S1881 + make_float2 (_S1896 * v_76 + s_diff_v_21 * _S1895 + (s_diff_r2_21 + (_S1898 * u_76 + s_diff_u_21 * _S1897)) * dist_coeffs_13[int(5)] + s_diff_r2_21 * dist_coeffs_13[int(6)], _S1901 * v_76 + s_diff_v_21 * _S1900 + (s_diff_r2_21 + (_S1903 * v_76 + s_diff_v_21 * _S1902)) * dist_coeffs_13[int(4)] + s_diff_r2_21 * dist_coeffs_13[int(7)]); - float2 _S1905 = _S1904 + make_float2 (_S1904.x * dist_coeffs_13[int(8)] + _S1904.y * dist_coeffs_13[int(9)], 0.0f); - float _S1906 = _S1905.x * fx_13; - float _S1907 = _S1905.y * fy_13; - Matrix _S1908 = J_11; - *&(((&_S1908)->rows + (int(0)))->x) = _S1906; - *&(((&_S1908)->rows + (int(1)))->x) = _S1907; - float2 _S1909 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S1910 = { _S1848, _S1909 }; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S1911; - (&_S1911)->primal_0 = _S1848; - (&_S1911)->differential_0 = _S1909; - DiffPair_float_0 _S1912 = s_primal_ctx_s_fwd_length_impl_0(&_S1911); - DiffPair_float_0 _S1913 = { _S1912.primal_0, _S1912.differential_0 }; - DiffPair_float_0 _S1914; - (&_S1914)->primal_0 = _S1912.primal_0; - (&_S1914)->differential_0 = _S1912.differential_0; - DiffPair_float_0 _S1915; - (&_S1915)->primal_0 = _S1853; - (&_S1915)->differential_0 = 0.0f; - DiffPair_float_0 _S1916 = s_primal_ctx_d_atan2_0(&_S1914, &_S1915); - bool _S1917 = (_S1916.primal_0) < 0.00100000004749745f; - float _S1918; - float _S1919; - float _S1920; - float _S1921; - float _S1922; - float _S1923; - float _S1924; - float _S1925; - if(_S1917) - { - float _S1926 = _S1916.differential_0 * _S1916.primal_0; - float _S1927 = 1.0f - _S1916.primal_0 * _S1916.primal_0 / 3.0f; - float _S1928 = 0.0f - (_S1926 + _S1926) * 0.3333333432674408f; - float _S1929 = _S1853 * _S1853; - float _S1930 = _S1928 * _S1853; - float _S1931 = _S1930 / _S1929; - float _S1932 = _S1929 * _S1929; - k_6 = _S1927 / _S1853; - s_diff_k_2 = _S1931; - _S1918 = _S1932; - _S1919 = _S1930; - _S1920 = _S1929; - _S1921 = _S1927; - _S1922 = _S1928; - _S1923 = 0.0f; - _S1924 = 0.0f; - _S1925 = 0.0f; - } - else - { - float _S1933 = _S1912.primal_0 * _S1912.primal_0; - float _S1934 = _S1916.differential_0 * _S1912.primal_0 - _S1916.primal_0 * _S1912.differential_0; - float _S1935 = _S1934 / _S1933; - float _S1936 = _S1933 * _S1933; - k_6 = _S1916.primal_0 / _S1912.primal_0; - s_diff_k_2 = _S1935; - _S1918 = 0.0f; - _S1919 = 0.0f; - _S1920 = 0.0f; - _S1921 = 0.0f; - _S1922 = 0.0f; - _S1923 = _S1936; - _S1924 = _S1934; - _S1925 = _S1933; - } - float2 _S1937 = make_float2 (k_6); - float2 _S1938 = make_float2 (s_diff_k_2); - float2 _S1939 = _S1848 * make_float2 (k_6); - float2 _S1940 = _S1909 * make_float2 (k_6) + make_float2 (s_diff_k_2) * _S1848; - float u_77 = _S1939.x; - float s_diff_u_22 = _S1940.x; - float v_77 = _S1939.y; - float s_diff_v_22 = _S1940.y; - float _S1941 = s_diff_u_22 * u_77; - float _S1942 = s_diff_v_22 * v_77; - float r2_77 = u_77 * u_77 + v_77 * v_77; - float s_diff_r2_22 = _S1941 + _S1941 + (_S1942 + _S1942); - float _S1943 = s_diff_r2_22 * dist_coeffs_13[int(3)]; - float _S1944 = dist_coeffs_13[int(2)] + r2_77 * dist_coeffs_13[int(3)]; - float _S1945 = s_diff_r2_22 * _S1944 + _S1943 * r2_77; - float _S1946 = dist_coeffs_13[int(1)] + r2_77 * _S1944; - float _S1947 = s_diff_r2_22 * _S1946 + _S1945 * r2_77; - float _S1948 = dist_coeffs_13[int(0)] + r2_77 * _S1946; - float _S1949 = s_diff_r2_22 * _S1948 + _S1947 * r2_77; - float2 _S1950 = make_float2 (_S1949); - float radial_31 = 1.0f + r2_77 * _S1948; - float2 _S1951 = make_float2 (radial_31); - float _S1952 = _S1894 * u_77; - float _S1953 = s_diff_u_22 * _S1894; - float _S1954 = 2.0f * u_77; - float _S1955 = s_diff_u_22 * 2.0f; - float _S1956 = _S1899 * u_77; - float _S1957 = s_diff_u_22 * _S1899; - float _S1958 = 2.0f * v_77; - float _S1959 = s_diff_v_22 * 2.0f; - float2 _S1960 = _S1940 * make_float2 (radial_31) + make_float2 (_S1949) * _S1939 + make_float2 (_S1953 * v_77 + s_diff_v_22 * _S1952 + (s_diff_r2_22 + (_S1955 * u_77 + s_diff_u_22 * _S1954)) * dist_coeffs_13[int(5)] + s_diff_r2_22 * dist_coeffs_13[int(6)], _S1957 * v_77 + s_diff_v_22 * _S1956 + (s_diff_r2_22 + (_S1959 * v_77 + s_diff_v_22 * _S1958)) * dist_coeffs_13[int(4)] + s_diff_r2_22 * dist_coeffs_13[int(7)]); - float2 _S1961 = _S1960 + make_float2 (_S1960.x * dist_coeffs_13[int(8)] + _S1960.y * dist_coeffs_13[int(9)], 0.0f); - float _S1962 = _S1961.y * fy_13; - *&(((&_S1908)->rows + (int(0)))->y) = _S1961.x * fx_13; - *&(((&_S1908)->rows + (int(1)))->y) = _S1962; - float2 _S1963 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S1964 = { _S1848, _S1963 }; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S1965; - (&_S1965)->primal_0 = _S1848; - (&_S1965)->differential_0 = _S1963; - DiffPair_float_0 _S1966 = s_primal_ctx_s_fwd_length_impl_0(&_S1965); - DiffPair_float_0 _S1967 = { _S1966.primal_0, _S1966.differential_0 }; - DiffPair_float_0 _S1968 = { _S1853, 1.0f }; - DiffPair_float_0 _S1969; - (&_S1969)->primal_0 = _S1966.primal_0; - (&_S1969)->differential_0 = _S1966.differential_0; - DiffPair_float_0 _S1970; - (&_S1970)->primal_0 = _S1853; - (&_S1970)->differential_0 = 1.0f; - DiffPair_float_0 _S1971 = s_primal_ctx_d_atan2_0(&_S1969, &_S1970); - bool _S1972 = (_S1971.primal_0) < 0.00100000004749745f; - float _S1973; - float _S1974; - float _S1975; - float _S1976; - float _S1977; - float _S1978; - float _S1979; - float _S1980; - if(_S1972) - { - float _S1981 = _S1971.differential_0 * _S1971.primal_0; - float _S1982 = 1.0f - _S1971.primal_0 * _S1971.primal_0 / 3.0f; - float _S1983 = 0.0f - (_S1981 + _S1981) * 0.3333333432674408f; - float _S1984 = _S1853 * _S1853; - float _S1985 = _S1983 * _S1853 - _S1982; - float _S1986 = _S1985 / _S1984; - float _S1987 = _S1984 * _S1984; - k_6 = _S1982 / _S1853; - s_diff_k_2 = _S1986; - _S1973 = _S1987; - _S1974 = _S1985; - _S1975 = _S1984; - _S1976 = _S1982; - _S1977 = _S1983; - _S1978 = 0.0f; - _S1979 = 0.0f; - _S1980 = 0.0f; - } - else - { - float _S1988 = _S1966.primal_0 * _S1966.primal_0; - float _S1989 = _S1971.differential_0 * _S1966.primal_0 - _S1971.primal_0 * _S1966.differential_0; - float _S1990 = _S1989 / _S1988; - float _S1991 = _S1988 * _S1988; - k_6 = _S1971.primal_0 / _S1966.primal_0; - s_diff_k_2 = _S1990; - _S1973 = 0.0f; - _S1974 = 0.0f; - _S1975 = 0.0f; - _S1976 = 0.0f; - _S1977 = 0.0f; - _S1978 = _S1991; - _S1979 = _S1989; - _S1980 = _S1988; - } - float2 _S1992 = make_float2 (k_6); - float2 _S1993 = make_float2 (s_diff_k_2); - float2 _S1994 = _S1848 * make_float2 (k_6); - float2 _S1995 = make_float2 (s_diff_k_2) * _S1848; - float u_78 = _S1994.x; - float s_diff_u_23 = _S1995.x; - float v_78 = _S1994.y; - float s_diff_v_23 = _S1995.y; - float _S1996 = s_diff_u_23 * u_78; - float _S1997 = s_diff_v_23 * v_78; - float r2_78 = u_78 * u_78 + v_78 * v_78; - float s_diff_r2_23 = _S1996 + _S1996 + (_S1997 + _S1997); - float _S1998 = s_diff_r2_23 * dist_coeffs_13[int(3)]; - float _S1999 = dist_coeffs_13[int(2)] + r2_78 * dist_coeffs_13[int(3)]; - float _S2000 = s_diff_r2_23 * _S1999 + _S1998 * r2_78; - float _S2001 = dist_coeffs_13[int(1)] + r2_78 * _S1999; - float _S2002 = s_diff_r2_23 * _S2001 + _S2000 * r2_78; - float _S2003 = dist_coeffs_13[int(0)] + r2_78 * _S2001; - float _S2004 = s_diff_r2_23 * _S2003 + _S2002 * r2_78; - float2 _S2005 = make_float2 (_S2004); - float radial_32 = 1.0f + r2_78 * _S2003; - float2 _S2006 = make_float2 (radial_32); - float _S2007 = _S1894 * u_78; - float _S2008 = s_diff_u_23 * _S1894; - float _S2009 = 2.0f * u_78; - float _S2010 = s_diff_u_23 * 2.0f; - float _S2011 = _S1899 * u_78; - float _S2012 = s_diff_u_23 * _S1899; - float _S2013 = 2.0f * v_78; - float _S2014 = s_diff_v_23 * 2.0f; - float2 _S2015 = _S1995 * make_float2 (radial_32) + make_float2 (_S2004) * _S1994 + make_float2 (_S2008 * v_78 + s_diff_v_23 * _S2007 + (s_diff_r2_23 + (_S2010 * u_78 + s_diff_u_23 * _S2009)) * dist_coeffs_13[int(5)] + s_diff_r2_23 * dist_coeffs_13[int(6)], _S2012 * v_78 + s_diff_v_23 * _S2011 + (s_diff_r2_23 + (_S2014 * v_78 + s_diff_v_23 * _S2013)) * dist_coeffs_13[int(4)] + s_diff_r2_23 * dist_coeffs_13[int(7)]); - float2 _S2016 = _S2015 + make_float2 (_S2015.x * dist_coeffs_13[int(8)] + _S2015.y * dist_coeffs_13[int(9)], 0.0f); - float _S2017 = _S2016.y * fy_13; - *&(((&_S1908)->rows + (int(0)))->z) = _S2016.x * fx_13; - *&(((&_S1908)->rows + (int(1)))->z) = _S2017; - Matrix _S2018 = s_primal_ctx_mul_2(_S1908, _S1847); - Matrix _S2019 = transpose_1(_S1908); - Matrix _S2020 = s_primal_ctx_mul_3(_S2018, _S2019); - float eps2d_9; - if(antialiased_9) - { - eps2d_9 = 0.10000000149011612f; - } - else - { - eps2d_9 = 0.30000001192092896f; - } - float _S2021 = _S2020.rows[int(0)].y * _S2020.rows[int(1)].x; - float det_orig_9 = _S2020.rows[int(0)].x * _S2020.rows[int(1)].y - _S2021; - float _S2022 = _S2020.rows[int(0)].x + eps2d_9; - Matrix _S2023 = _S2020; - *&(((&_S2023)->rows + (int(0)))->x) = _S2022; - float _S2024 = _S2020.rows[int(1)].y + eps2d_9; - *&(((&_S2023)->rows + (int(1)))->y) = _S2024; - Matrix _S2025 = _S2023; - Matrix _S2026 = _S2023; - float det_blur_9 = _S2022 * _S2024 - _S2021; - float _S2027 = det_orig_9 / det_blur_9; - float _S2028 = det_blur_9 * det_blur_9; - float _S2029 = (F32_max((0.0f), (_S2027))); - float _S2030 = s_primal_ctx_sqrt_0(_S2029); - float invdet_11 = 1.0f / det_blur_9; - float _S2031 = - _S2020.rows[int(0)].y; - float _S2032 = - _S2020.rows[int(1)].x; - if(antialiased_9) - { - k_6 = _S1836 * _S2030; - } - else - { - k_6 = _S1836; - } - float _S2033 = k_6 / 0.00392156885936856f; - float _S2034 = 2.0f * s_primal_ctx_log_0(_S2033); - float _S2035 = s_primal_ctx_sqrt_0(_S2034); - float _S2036 = _S2025.rows[int(0)].x; - float _S2037 = _S2026.rows[int(1)].y; - float3 campos_2 = - s_primal_ctx_mul_0(_S1846, t_9); - float3 _S2038 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2039; - (&_S2039)->primal_0 = mean_10; - (&_S2039)->differential_0 = _S2038; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2040; - (&_S2040)->primal_0 = scale_9; - (&_S2040)->differential_0 = _S2038; - DiffPair_float_0 _S2041; - (&_S2041)->primal_0 = in_opacity_9; - (&_S2041)->differential_0 = 0.0f; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2042; - (&_S2042)->primal_0 = campos_2; - (&_S2042)->differential_0 = _S2038; - s_bwd_prop_view_radius_3dgs_0(&_S2039, &_S2040, &_S2041, &_S2042, 0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2043 = _S2039; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2044 = _S2040; - DiffPair_float_0 _S2045 = _S2041; - float2 _S2046 = make_float2 (0.0f); - float2 _S2047 = _S2046; - *&((&_S2047)->y) = v_conic_1.z; - float2 _S2048 = _S2046; - *&((&_S2048)->y) = v_conic_1.y; - *&((&_S2048)->x) = v_conic_1.x; - DiffPair_float_0 _S2049; - (&_S2049)->primal_0 = _S2037; - (&_S2049)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S2049, 0.0f); - DiffPair_float_0 _S2050; - (&_S2050)->primal_0 = _S2036; - (&_S2050)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S2050, 0.0f); - DiffPair_float_0 _S2051; - (&_S2051)->primal_0 = 3.32999992370605469f; - (&_S2051)->differential_0 = 0.0f; - DiffPair_float_0 _S2052; - (&_S2052)->primal_0 = _S2035; - (&_S2052)->differential_0 = 0.0f; - _d_min_0(&_S2051, &_S2052, 0.0f); - DiffPair_float_0 _S2053; - (&_S2053)->primal_0 = _S2034; - (&_S2053)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S2053, _S2052.differential_0); - float _S2054 = 2.0f * _S2053.differential_0; - DiffPair_float_0 _S2055; - (&_S2055)->primal_0 = _S2033; - (&_S2055)->differential_0 = 0.0f; - s_bwd_prop_log_0(&_S2055, _S2054); - float _S2056 = v_opacity_1 + 254.9999847412109375f * _S2055.differential_0; - float2 _S2057 = make_float2 (_S2050.differential_0, 0.0f); - Matrix _S2058 = makeMatrix (0.0f); - Matrix _S2059 = _S2058; - _S2059[int(1)] = _S2047; - _S2059[int(0)] = _S2048; - Matrix _S2060 = _S2059; - float2 _S2061 = make_float2 (0.0f, _S2049.differential_0); - if(antialiased_9) - { - float _S2062 = _S2030 * _S2056; - k_6 = _S1836 * _S2056; - s_diff_k_2 = _S2062; - } - else - { - k_6 = 0.0f; - s_diff_k_2 = _S2056; - } - float _S2063 = invdet_11 * _S2060.rows[int(1)].y; - float _S2064 = - (invdet_11 * _S2060.rows[int(1)].x); - float _S2065 = - (invdet_11 * _S2060.rows[int(0)].y); - float _S2066 = invdet_11 * _S2060.rows[int(0)].x; - float _S2067 = - ((_S2022 * _S2060.rows[int(1)].y + _S2032 * _S2060.rows[int(1)].x + _S2031 * _S2060.rows[int(0)].y + _S2024 * _S2060.rows[int(0)].x) / _S2028); - DiffPair_float_0 _S2068; - (&_S2068)->primal_0 = _S2029; - (&_S2068)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S2068, k_6); - DiffPair_float_0 _S2069 = { 0.0f, 0.0f }; - DiffPair_float_0 _S2070; - (&_S2070)->primal_0 = 0.0f; - (&_S2070)->differential_0 = 0.0f; - DiffPair_float_0 _S2071; - (&_S2071)->primal_0 = _S2027; - (&_S2071)->differential_0 = 0.0f; - _d_max_0(&_S2070, &_S2071, _S2068.differential_0); - float _S2072 = _S2071.differential_0 / _S2028; - float s_diff_det_orig_T_1 = det_blur_9 * _S2072; - float _S2073 = det_orig_9 * - _S2072 + _S2067; - float _S2074 = - _S2073; - float _S2075 = _S2022 * _S2073; - float _S2076 = _S2024 * _S2073; - Matrix _S2077 = _S2058; - _S2077[int(1)] = _S2061; - _S2077[int(0)] = _S2057; - _S2023 = _S2077; - *&(((&_S2023)->rows + (int(1)))->y) = 0.0f; - float _S2078 = _S2075 + _S2077.rows[int(1)].y + _S2066; - *&(((&_S2023)->rows + (int(0)))->x) = 0.0f; - float _S2079 = _S2076 + _S2077.rows[int(0)].x + _S2063; - float _S2080 = _S2074 + - s_diff_det_orig_T_1; - float _S2081 = _S2020.rows[int(0)].y * _S2080 + _S2064; - float _S2082 = _S2020.rows[int(1)].x * _S2080 + _S2065; - float _S2083 = _S2020.rows[int(1)].y * s_diff_det_orig_T_1; - float _S2084 = _S2078 + _S2020.rows[int(0)].x * s_diff_det_orig_T_1; - float2 _S2085 = _S2046; - *&((&_S2085)->x) = _S2081; - *&((&_S2085)->y) = _S2084; - float _S2086 = _S2079 + _S2083; - float2 _S2087 = _S2046; - *&((&_S2087)->y) = _S2082; - *&((&_S2087)->x) = _S2086; - Matrix _S2088 = _S2058; - _S2088[int(1)] = _S2085; - _S2088[int(0)] = _S2087; - Matrix _S2089 = _S2023 + _S2088; - DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S2090; - (&_S2090)->primal_0 = _S2018; - (&_S2090)->differential_0 = J_11; - Matrix _S2091 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S2092; - (&_S2092)->primal_0 = _S2019; - (&_S2092)->differential_0 = _S2091; - s_bwd_prop_mul_0(&_S2090, &_S2092, _S2089); - Matrix _S2093 = transpose_2(_S2092.differential_0); - DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S2094; - (&_S2094)->primal_0 = _S1908; - (&_S2094)->differential_0 = J_11; - Matrix _S2095 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2096; - (&_S2096)->primal_0 = _S1847; - (&_S2096)->differential_0 = _S2095; - s_bwd_prop_mul_1(&_S2094, &_S2096, _S2090.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2097 = _S2096; - Matrix _S2098 = _S2093 + _S2094.differential_0; - float2 _S2099 = make_float2 (0.0f, _S2098.rows[int(1)].z) + make_float2 (_S2098.rows[int(0)].z, 0.0f); - float _S2100 = fx_13 * _S2099.x; - float2 _S2101 = make_float2 (_S2100, fy_13 * _S2099.y) + make_float2 (dist_coeffs_13[int(8)] * _S2100, dist_coeffs_13[int(9)] * _S2100); - float2 _S2102 = _S1994 * _S2101; - float2 _S2103 = _S1995 * _S2101; - float _S2104 = dist_coeffs_13[int(4)] * _S2101.y; - float _S2105 = dist_coeffs_13[int(5)] * _S2101.x; - float _S2106 = _S2103.x + _S2103.y; - float _S2107 = _S2102.x + _S2102.y; - float _S2108 = r2_78 * _S2107; - float _S2109 = s_diff_r2_23 * _S2107 + r2_78 * _S2106; - float _S2110 = r2_78 * _S2108; - float _S2111 = s_diff_r2_23 * _S2108 + r2_78 * _S2109; - float _S2112 = dist_coeffs_13[int(7)] * _S2101.y + _S2104 + dist_coeffs_13[int(6)] * _S2101.x + _S2105 + _S2003 * _S2107 + _S2001 * _S2108 + _S1999 * _S2110 + dist_coeffs_13[int(3)] * (r2_78 * _S2110); - float _S2113 = _S2002 * _S2107 + _S2003 * _S2106 + _S2000 * _S2108 + _S2001 * _S2109 + _S1998 * _S2110 + _S1999 * _S2111 + dist_coeffs_13[int(3)] * (s_diff_r2_23 * _S2110 + r2_78 * _S2111); - float _S2114 = _S2112 + _S2112; - float _S2115 = v_78 * _S2113; - float _S2116 = u_78 * _S2113; - float2 _S2117 = _S2005 * _S2101 + make_float2 (_S1899 * (s_diff_v_23 * _S2101.y) + _S2010 * _S2105 + 2.0f * (s_diff_u_23 * _S2105) + _S1894 * (s_diff_v_23 * _S2101.x) + s_diff_u_23 * _S2114 + _S2116 + _S2116, _S2014 * _S2104 + 2.0f * (s_diff_v_23 * _S2104) + _S2012 * _S2101.y + _S2008 * _S2101.x + s_diff_v_23 * _S2114 + _S2115 + _S2115); - float2 _S2118 = _S2006 * _S2101 + make_float2 (_S1899 * (v_78 * _S2101.y) + _S2009 * _S2105 + 2.0f * (u_78 * _S2105) + _S1894 * (v_78 * _S2101.x) + u_78 * _S2114, _S2013 * _S2104 + 2.0f * (v_78 * _S2104) + _S2011 * _S2101.y + _S2007 * _S2101.x + v_78 * _S2114); - float2 _S2119 = _S1848 * _S2118; - float2 _S2120 = _S1848 * _S2117; - float _S2121 = _S2120.x + _S2120.y; - float _S2122 = _S2119.x + _S2119.y; - float2 _S2123 = _S1993 * _S2118 + _S1992 * _S2117; - if(_S1972) - { - float _S2124 = _S2122 / _S1973; - float _S2125 = _S1975 * _S2124; - float _S2126 = _S1853 * (_S1974 * - _S2124); - float _S2127 = _S2121 / _S1975; - float _S2128 = 0.3333333432674408f * - (_S1853 * _S2125); - float _S2129 = _S2128 + _S2128; - float _S2130 = _S1971.primal_0 * (0.3333333432674408f * - (- _S2125 + _S1853 * _S2127)); - float _S2131 = _S2126 + _S2126 + _S1977 * _S2125 + _S1976 * - _S2127; - float _S2132 = _S1971.differential_0 * _S2129 + _S2130 + _S2130; - k_6 = _S1971.primal_0 * _S2129; - _S1973 = _S2132; - _S1974 = _S2131; - _S1975 = 0.0f; - _S1976 = 0.0f; - } - else - { - float _S2133 = _S2122 / _S1978; - float _S2134 = _S1980 * _S2133; - float _S2135 = _S1966.primal_0 * (_S1979 * - _S2133); - float _S2136 = - _S2134; - float _S2137 = _S1971.primal_0 * _S2136; - float _S2138 = _S2121 / _S1980; - float _S2139 = _S2135 + _S2135 + _S1971.differential_0 * _S2134 + _S1971.primal_0 * - _S2138; - float _S2140 = _S1966.differential_0 * _S2136 + _S1966.primal_0 * _S2138; - k_6 = _S1966.primal_0 * _S2134; - _S1973 = _S2140; - _S1974 = 0.0f; - _S1975 = _S2137; - _S1976 = _S2139; - } - DiffPair_0 _S2141; - (&_S2141)->primal_0 = _S1967; - (&_S2141)->differential_0 = _S2069; - DiffPair_0 _S2142; - (&_S2142)->primal_0 = _S1968; - (&_S2142)->differential_0 = _S2069; - DiffPair_float_0 _S2143; - (&_S2143)->primal_0 = _S1973; - (&_S2143)->differential_0 = k_6; - s_bwd_prop_d_atan2_0(&_S2141, &_S2142, &_S2143); - float _S2144 = _S2142.differential_0.primal_0 + _S1974; - float _S2145 = _S2141.differential_0.differential_0 + _S1975; - float _S2146 = _S2141.differential_0.primal_0 + _S1976; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2147 = { _S2046, _S2046 }; - DiffPair_1 _S2148; - (&_S2148)->primal_0 = _S1964; - (&_S2148)->differential_0 = _S2147; - DiffPair_float_0 _S2149; - (&_S2149)->primal_0 = _S2146; - (&_S2149)->differential_0 = _S2145; - s_bwd_prop_s_fwd_length_impl_0(&_S2148, &_S2149); - float2 _S2150 = _S2148.differential_0.primal_0 + _S2123; - float3 _S2151 = make_float3 (_S2150.x, _S2150.y, _S2144); - float2 _S2152 = make_float2 (0.0f, _S2098.rows[int(1)].y) + make_float2 (_S2098.rows[int(0)].y, 0.0f); - float _S2153 = fx_13 * _S2152.x; - float2 _S2154 = make_float2 (_S2153, fy_13 * _S2152.y) + make_float2 (dist_coeffs_13[int(8)] * _S2153, dist_coeffs_13[int(9)] * _S2153); - float2 _S2155 = _S1939 * _S2154; - float2 _S2156 = _S1940 * _S2154; - float _S2157 = dist_coeffs_13[int(4)] * _S2154.y; - float _S2158 = dist_coeffs_13[int(5)] * _S2154.x; - float _S2159 = _S2156.x + _S2156.y; - float _S2160 = _S2155.x + _S2155.y; - float _S2161 = r2_77 * _S2160; - float _S2162 = s_diff_r2_22 * _S2160 + r2_77 * _S2159; - float _S2163 = r2_77 * _S2161; - float _S2164 = s_diff_r2_22 * _S2161 + r2_77 * _S2162; - float _S2165 = dist_coeffs_13[int(7)] * _S2154.y + _S2157 + dist_coeffs_13[int(6)] * _S2154.x + _S2158 + _S1948 * _S2160 + _S1946 * _S2161 + _S1944 * _S2163 + dist_coeffs_13[int(3)] * (r2_77 * _S2163); - float _S2166 = _S1947 * _S2160 + _S1948 * _S2159 + _S1945 * _S2161 + _S1946 * _S2162 + _S1943 * _S2163 + _S1944 * _S2164 + dist_coeffs_13[int(3)] * (s_diff_r2_22 * _S2163 + r2_77 * _S2164); - float _S2167 = _S2165 + _S2165; - float _S2168 = v_77 * _S2166; - float _S2169 = u_77 * _S2166; - float2 _S2170 = _S1950 * _S2154 + make_float2 (_S1899 * (s_diff_v_22 * _S2154.y) + _S1955 * _S2158 + 2.0f * (s_diff_u_22 * _S2158) + _S1894 * (s_diff_v_22 * _S2154.x) + s_diff_u_22 * _S2167 + _S2169 + _S2169, _S1959 * _S2157 + 2.0f * (s_diff_v_22 * _S2157) + _S1957 * _S2154.y + _S1953 * _S2154.x + s_diff_v_22 * _S2167 + _S2168 + _S2168); - float2 _S2171 = _S1951 * _S2154 + make_float2 (_S1899 * (v_77 * _S2154.y) + _S1954 * _S2158 + 2.0f * (u_77 * _S2158) + _S1894 * (v_77 * _S2154.x) + u_77 * _S2167, _S1958 * _S2157 + 2.0f * (v_77 * _S2157) + _S1956 * _S2154.y + _S1952 * _S2154.x + v_77 * _S2167); - float2 _S2172 = _S1848 * _S2171; - float2 _S2173 = _S1909 * _S2171; - float2 _S2174 = _S1848 * _S2170; - float _S2175 = _S2173.x + _S2173.y + _S2174.x + _S2174.y; - float _S2176 = _S2172.x + _S2172.y; - float2 _S2177 = _S1938 * _S2171 + _S1937 * _S2170; - if(_S1917) - { - float _S2178 = _S2176 / _S1918; - float _S2179 = _S1920 * _S2178; - float _S2180 = _S1853 * (_S1919 * - _S2178); - float _S2181 = _S2175 / _S1920; - float _S2182 = 0.3333333432674408f * - (_S1853 * _S2179); - float _S2183 = _S2182 + _S2182; - float _S2184 = _S1916.primal_0 * (0.3333333432674408f * - (_S1853 * _S2181)); - float _S2185 = _S2180 + _S2180 + _S1922 * _S2179 + _S1921 * - _S2181; - float _S2186 = _S1916.differential_0 * _S2183 + _S2184 + _S2184; - k_6 = _S1916.primal_0 * _S2183; - _S1918 = _S2186; - _S1919 = _S2185; - _S1920 = 0.0f; - _S1921 = 0.0f; - } - else - { - float _S2187 = _S2176 / _S1923; - float _S2188 = _S1925 * _S2187; - float _S2189 = _S1912.primal_0 * (_S1924 * - _S2187); - float _S2190 = - _S2188; - float _S2191 = _S1916.primal_0 * _S2190; - float _S2192 = _S2175 / _S1925; - float _S2193 = _S2189 + _S2189 + _S1916.differential_0 * _S2188 + _S1916.primal_0 * - _S2192; - float _S2194 = _S1912.differential_0 * _S2190 + _S1912.primal_0 * _S2192; - k_6 = _S1912.primal_0 * _S2188; - _S1918 = _S2194; - _S1919 = 0.0f; - _S1920 = _S2191; - _S1921 = _S2193; - } - DiffPair_0 _S2195; - (&_S2195)->primal_0 = _S1913; - (&_S2195)->differential_0 = _S2069; - DiffPair_0 _S2196; - (&_S2196)->primal_0 = _S1855; - (&_S2196)->differential_0 = _S2069; - DiffPair_float_0 _S2197; - (&_S2197)->primal_0 = _S1918; - (&_S2197)->differential_0 = k_6; - s_bwd_prop_d_atan2_0(&_S2195, &_S2196, &_S2197); - float _S2198 = _S2196.differential_0.primal_0 + _S1919; - float _S2199 = _S2195.differential_0.differential_0 + _S1920; - float _S2200 = _S2195.differential_0.primal_0 + _S1921; - DiffPair_1 _S2201; - (&_S2201)->primal_0 = _S1910; - (&_S2201)->differential_0 = _S2147; - DiffPair_float_0 _S2202; - (&_S2202)->primal_0 = _S2200; - (&_S2202)->differential_0 = _S2199; - s_bwd_prop_s_fwd_length_impl_0(&_S2201, &_S2202); - float2 _S2203 = _S2201.differential_0.primal_0 + _S2177; - float2 _S2204 = make_float2 (0.0f, _S2098.rows[int(1)].x) + make_float2 (_S2098.rows[int(0)].x, 0.0f); - float _S2205 = fx_13 * _S2204.x; - float2 _S2206 = make_float2 (_S2205, fy_13 * _S2204.y) + make_float2 (dist_coeffs_13[int(8)] * _S2205, dist_coeffs_13[int(9)] * _S2205); - float2 _S2207 = _S1881 * _S2206; - float2 _S2208 = _S1882 * _S2206; - float _S2209 = dist_coeffs_13[int(4)] * _S2206.y; - float _S2210 = dist_coeffs_13[int(5)] * _S2206.x; - float _S2211 = _S2208.x + _S2208.y; - float _S2212 = _S2207.x + _S2207.y; - float _S2213 = r2_76 * _S2212; - float _S2214 = s_diff_r2_21 * _S2212 + r2_76 * _S2211; - float _S2215 = r2_76 * _S2213; - float _S2216 = s_diff_r2_21 * _S2213 + r2_76 * _S2214; - float _S2217 = dist_coeffs_13[int(7)] * _S2206.y + _S2209 + dist_coeffs_13[int(6)] * _S2206.x + _S2210 + _S1890 * _S2212 + _S1888 * _S2213 + _S1886 * _S2215 + dist_coeffs_13[int(3)] * (r2_76 * _S2215); - float _S2218 = _S1889 * _S2212 + _S1890 * _S2211 + _S1887 * _S2213 + _S1888 * _S2214 + _S1885 * _S2215 + _S1886 * _S2216 + dist_coeffs_13[int(3)] * (s_diff_r2_21 * _S2215 + r2_76 * _S2216); - float _S2219 = _S2217 + _S2217; - float _S2220 = v_76 * _S2218; - float _S2221 = u_76 * _S2218; - float2 _S2222 = _S1892 * _S2206 + make_float2 (_S1899 * (s_diff_v_21 * _S2206.y) + _S1898 * _S2210 + 2.0f * (s_diff_u_21 * _S2210) + _S1894 * (s_diff_v_21 * _S2206.x) + s_diff_u_21 * _S2219 + _S2221 + _S2221, _S1903 * _S2209 + 2.0f * (s_diff_v_21 * _S2209) + _S1901 * _S2206.y + _S1896 * _S2206.x + s_diff_v_21 * _S2219 + _S2220 + _S2220); - float2 _S2223 = _S1893 * _S2206 + make_float2 (_S1899 * (v_76 * _S2206.y) + _S1897 * _S2210 + 2.0f * (u_76 * _S2210) + _S1894 * (v_76 * _S2206.x) + u_76 * _S2219, _S1902 * _S2209 + 2.0f * (v_76 * _S2209) + _S1900 * _S2206.y + _S1895 * _S2206.x + v_76 * _S2219); - float3 _S2224 = make_float3 (_S2203.x, _S2203.y, _S2198) + _S2151; - float2 _S2225 = _S1848 * _S2223; - float2 _S2226 = _S1849 * _S2223; - float2 _S2227 = _S1848 * _S2222; - float _S2228 = _S2226.x + _S2226.y + _S2227.x + _S2227.y; - float _S2229 = _S2225.x + _S2225.y; - float2 _S2230 = _S1880 * _S2223 + _S1879 * _S2222; - if(_S1859) - { - float _S2231 = _S2229 / _S1860; - float _S2232 = _S1862 * _S2231; - float _S2233 = _S1853 * (_S1861 * - _S2231); - float _S2234 = _S2228 / _S1862; - float _S2235 = 0.3333333432674408f * - (_S1853 * _S2232); - float _S2236 = _S2235 + _S2235; - float _S2237 = _S1858.primal_0 * (0.3333333432674408f * - (_S1853 * _S2234)); - float _S2238 = _S2233 + _S2233 + _S1864 * _S2232 + _S1863 * - _S2234; - float _S2239 = _S1858.differential_0 * _S2236 + _S2237 + _S2237; - k_6 = _S1858.primal_0 * _S2236; - _S1860 = _S2239; - _S1861 = _S2238; - _S1862 = 0.0f; - _S1863 = 0.0f; - } - else - { - float _S2240 = _S2229 / _S1865; - float _S2241 = _S1867 * _S2240; - float _S2242 = _S1852.primal_0 * (_S1866 * - _S2240); - float _S2243 = - _S2241; - float _S2244 = _S1858.primal_0 * _S2243; - float _S2245 = _S2228 / _S1867; - float _S2246 = _S2242 + _S2242 + _S1858.differential_0 * _S2241 + _S1858.primal_0 * - _S2245; - float _S2247 = _S1852.differential_0 * _S2243 + _S1852.primal_0 * _S2245; - k_6 = _S1852.primal_0 * _S2241; - _S1860 = _S2247; - _S1861 = 0.0f; - _S1862 = _S2244; - _S1863 = _S2246; - } - DiffPair_0 _S2248; - (&_S2248)->primal_0 = _S1854; - (&_S2248)->differential_0 = _S2069; - DiffPair_0 _S2249; - (&_S2249)->primal_0 = _S1855; - (&_S2249)->differential_0 = _S2069; - DiffPair_float_0 _S2250; - (&_S2250)->primal_0 = _S1860; - (&_S2250)->differential_0 = k_6; - s_bwd_prop_d_atan2_0(&_S2248, &_S2249, &_S2250); - float _S2251 = _S2249.differential_0.primal_0 + _S1861; - float _S2252 = _S2248.differential_0.differential_0 + _S1862; - float _S2253 = _S2248.differential_0.primal_0 + _S1863; - DiffPair_1 _S2254; - (&_S2254)->primal_0 = _S1850; - (&_S2254)->differential_0 = _S2147; - DiffPair_float_0 _S2255; - (&_S2255)->primal_0 = _S2253; - (&_S2255)->differential_0 = _S2252; - s_bwd_prop_s_fwd_length_impl_0(&_S2254, &_S2255); - float2 _S2256 = _S2254.differential_0.primal_0 + _S2230; - float3 _S2257 = make_float3 (_S2256.x, _S2256.y, _S2251); - float _S2258 = length_0(_S1848); - float _S2259 = s_primal_ctx_atan2_0(_S2258, _S1853); - bool _S2260 = _S2259 < 0.00100000004749745f; - if(_S2260) - { - float _S2261 = 1.0f - _S2259 * _S2259 / 3.0f; - float _S2262 = _S1853 * _S1853; - k_6 = _S2261 / _S1853; - _S1860 = _S2262; - _S1861 = _S2261; - _S1862 = 0.0f; - } - else - { - float _S2263 = _S2258 * _S2258; - k_6 = _S2259 / _S2258; - _S1860 = 0.0f; - _S1861 = 0.0f; - _S1862 = _S2263; - } - float2 _S2264 = make_float2 (k_6); - float2 _S2265 = _S1848 * make_float2 (k_6); - float _S2266 = fx_13 * v_mean2d_1.x; - float u_79 = _S2265.x; - float v_79 = _S2265.y; - float r2_79 = u_79 * u_79 + v_79 * v_79; - float _S2267 = dist_coeffs_13[int(2)] + r2_79 * dist_coeffs_13[int(3)]; - float _S2268 = dist_coeffs_13[int(1)] + r2_79 * _S2267; - float _S2269 = dist_coeffs_13[int(0)] + r2_79 * _S2268; - float2 _S2270 = make_float2 (_S2266, fy_13 * v_mean2d_1.y) + make_float2 (dist_coeffs_13[int(8)] * _S2266, dist_coeffs_13[int(9)] * _S2266); - float2 _S2271 = _S2265 * _S2270; - float _S2272 = dist_coeffs_13[int(4)] * _S2270.y; - float _S2273 = dist_coeffs_13[int(5)] * _S2270.x; - float _S2274 = _S2271.x + _S2271.y; - float _S2275 = r2_79 * _S2274; - float _S2276 = r2_79 * _S2275; - float _S2277 = dist_coeffs_13[int(7)] * _S2270.y + _S2272 + dist_coeffs_13[int(6)] * _S2270.x + _S2273 + _S2269 * _S2274 + _S2268 * _S2275 + _S2267 * _S2276 + dist_coeffs_13[int(3)] * (r2_79 * _S2276); - float _S2278 = v_79 * _S2277; - float _S2279 = u_79 * _S2277; - float2 _S2280 = make_float2 (1.0f + r2_79 * _S2269) * _S2270 + make_float2 (_S1899 * (v_79 * _S2270.y) + 2.0f * u_79 * _S2273 + 2.0f * (u_79 * _S2273) + _S1894 * (v_79 * _S2270.x) + _S2279 + _S2279, 2.0f * v_79 * _S2272 + 2.0f * (v_79 * _S2272) + _S1899 * u_79 * _S2270.y + _S1894 * u_79 * _S2270.x + _S2278 + _S2278); - float2 _S2281 = _S1848 * _S2280; - float2 _S2282 = _S2264 * _S2280; - float _S2283 = _S2281.x + _S2281.y; - if(_S2260) - { - float _S2284 = _S2283 / _S1860; - float _S2285 = _S1861 * - _S2284; - float _S2286 = _S2259 * (0.3333333432674408f * - (_S1853 * _S2284)); - k_6 = _S2286 + _S2286; - _S1860 = _S2285; - _S1861 = 0.0f; - } - else - { - float _S2287 = _S2283 / _S1862; - float _S2288 = _S2259 * - _S2287; - k_6 = _S2258 * _S2287; - _S1860 = 0.0f; - _S1861 = _S2288; - } - DiffPair_float_0 _S2289; - (&_S2289)->primal_0 = _S2258; - (&_S2289)->differential_0 = 0.0f; - DiffPair_float_0 _S2290; - (&_S2290)->primal_0 = _S1853; - (&_S2290)->differential_0 = 0.0f; - s_bwd_prop_atan2_0(&_S2289, &_S2290, k_6); - float _S2291 = _S2290.differential_0 + _S1860; - float _S2292 = _S2289.differential_0 + _S1861; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2293; - (&_S2293)->primal_0 = _S1848; - (&_S2293)->differential_0 = _S2046; - s_bwd_length_impl_2(&_S2293, _S2292); - float2 _S2294 = _S2293.differential_0 + _S2282; - float3 _S2295 = make_float3 (_S2294.x, _S2294.y, _S2291); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2296; - (&_S2296)->primal_0 = _S1845; - (&_S2296)->differential_0 = _S2095; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2297; - (&_S2297)->primal_0 = _S1846; - (&_S2297)->differential_0 = _S2095; - s_bwd_prop_mul_2(&_S2296, &_S2297, _S2097.differential_0); - Matrix _S2298 = transpose_3(_S2297.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2299; - (&_S2299)->primal_0 = R_9; - (&_S2299)->differential_0 = _S2095; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2300; - (&_S2300)->primal_0 = _S1844; - (&_S2300)->differential_0 = _S2095; - s_bwd_prop_mul_2(&_S2299, &_S2300, _S2296.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2301; - (&_S2301)->primal_0 = _S1842; - (&_S2301)->differential_0 = _S2095; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2302; - (&_S2302)->primal_0 = _S1843; - (&_S2302)->differential_0 = _S2095; - s_bwd_prop_mul_2(&_S2301, &_S2302, _S2300.differential_0); - Matrix _S2303 = _S2301.differential_0 + transpose_3(_S2302.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2304; - (&_S2304)->primal_0 = _S1841; - (&_S2304)->differential_0 = _S2095; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2305; - (&_S2305)->primal_0 = S_1; - (&_S2305)->differential_0 = _S2095; - s_bwd_prop_mul_2(&_S2304, &_S2305, _S2303); - Matrix _S2306 = transpose_3(_S2304.differential_0); - float _S2307 = 2.0f * - _S2306.rows[int(2)].z; - float _S2308 = 2.0f * _S2306.rows[int(2)].y; - float _S2309 = 2.0f * _S2306.rows[int(2)].x; - float _S2310 = 2.0f * _S2306.rows[int(1)].z; - float _S2311 = 2.0f * - _S2306.rows[int(1)].y; - float _S2312 = 2.0f * _S2306.rows[int(1)].x; - float _S2313 = 2.0f * _S2306.rows[int(0)].z; - float _S2314 = 2.0f * _S2306.rows[int(0)].y; - float _S2315 = 2.0f * - _S2306.rows[int(0)].x; - float _S2316 = - _S2312 + _S2314; - float _S2317 = _S2309 + - _S2313; - float _S2318 = - _S2308 + _S2310; - float _S2319 = _S2308 + _S2310; - float _S2320 = _S2309 + _S2313; - float _S2321 = _S2312 + _S2314; - float _S2322 = _S1838.w * (_S2311 + _S2315); - float _S2323 = _S1838.z * (_S2307 + _S2315); - float _S2324 = _S1838.y * (_S2307 + _S2311); - float _S2325 = _S1838.x * _S2316 + _S1838.z * _S2319 + _S1838.y * _S2320 + _S2322 + _S2322; - float _S2326 = _S1838.x * _S2317 + _S1838.w * _S2319 + _S1838.y * _S2321 + _S2323 + _S2323; - float _S2327 = _S1838.x * _S2318 + _S1838.w * _S2320 + _S1838.z * _S2321 + _S2324 + _S2324; - float _S2328 = _S1838.w * _S2316 + _S1838.z * _S2317 + _S1838.y * _S2318; - float3 _S2329 = _S2038; - *&((&_S2329)->z) = _S2305.differential_0.rows[int(2)].z; - *&((&_S2329)->y) = _S2305.differential_0.rows[int(1)].y; - *&((&_S2329)->x) = _S2305.differential_0.rows[int(0)].x; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2330; - (&_S2330)->primal_0 = scale_9; - (&_S2330)->differential_0 = _S2038; - s_bwd_prop_exp_1(&_S2330, _S2329); - float4 _S2331 = make_float4 (0.0f); - float4 _S2332 = _S2331; - *&((&_S2332)->w) = _S2325; - *&((&_S2332)->z) = _S2326; - *&((&_S2332)->y) = _S2327; - *&((&_S2332)->x) = _S2328; - DiffPair_vectorx3Cfloatx2C4x3E_0 _S2333; - (&_S2333)->primal_0 = quat_9; - (&_S2333)->differential_0 = _S2331; - s_bwd_normalize_impl_0(&_S2333, _S2332); - float _S2334 = - (s_diff_k_2 / _S1837); - DiffPair_float_0 _S2335; - (&_S2335)->primal_0 = _S1834; - (&_S2335)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S2335, _S2334); - float _S2336 = - _S2335.differential_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2337; - (&_S2337)->primal_0 = mean_c_9; - (&_S2337)->differential_0 = _S2038; - s_bwd_length_impl_0(&_S2337, v_depth_1); - float3 _S2338 = _S2257 + _S2295 + _S2337.differential_0 + _S2224; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2339; - (&_S2339)->primal_0 = R_9; - (&_S2339)->differential_0 = _S2095; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2340; - (&_S2340)->primal_0 = mean_10; - (&_S2340)->differential_0 = _S2038; - s_bwd_prop_mul_3(&_S2339, &_S2340, _S2338); - Matrix _S2341 = _S2298 + _S2299.differential_0 + _S2339.differential_0; - float _S2342 = _S2336 + _S2045.differential_0; - float3 _S2343 = _S2330.differential_0 + _S2044.differential_0; - *v_mean_1 = *v_mean_1 + (_S2340.differential_0 + _S2043.differential_0); - *v_quat_1 = *v_quat_1 + _S2333.differential_0; - *v_scale_1 = *v_scale_1 + _S2343; - *v_in_opacity_1 = *v_in_opacity_1 + _S2342; - *v_R_1 = *v_R_1 + _S2341; - *v_t_1 = *v_t_1 + _S2338; - return; -} - -inline __device__ float s_primal_ctx_sin_0(float _S2344) -{ - return (F32_sin((_S2344))); -} - -inline __device__ float s_primal_ctx_cos_0(float _S2345) -{ - return (F32_cos((_S2345))); + return (F32_cos((_S5721))); } inline __device__ DiffPair_float_0 s_primal_ctx_d_sin_0(DiffPair_float_0 * dpdpx_6) { - DiffPair_float_0 _S2346 = { s_primal_ctx_sin_0(dpdpx_6->primal_0), s_primal_ctx_cos_0(dpdpx_6->primal_0) * dpdpx_6->differential_0 }; - return _S2346; + DiffPair_float_0 _S5722 = { s_primal_ctx_sin_0(dpdpx_6->primal_0), s_primal_ctx_cos_0(dpdpx_6->primal_0) * dpdpx_6->differential_0 }; + return _S5722; } -inline __device__ void s_bwd_prop_cos_0(DiffPair_float_0 * _S2347, float _S2348) +inline __device__ void s_bwd_prop_cos_0(DiffPair_float_0 * _S5723, float _S5724) { - _d_cos_0(_S2347, _S2348); + _d_cos_0(_S5723, _S5724); return; } -inline __device__ void s_bwd_prop_sin_0(DiffPair_float_0 * _S2349, float _S2350) +inline __device__ void s_bwd_prop_sin_0(DiffPair_float_0 * _S5725, float _S5726) { - _d_sin_0(_S2349, _S2350); + _d_sin_0(_S5725, _S5726); return; } -inline __device__ void s_bwd_prop_d_sin_0(DiffPair_0 * dpdpx_7, DiffPair_float_0 * _s_dOut_8) +inline __device__ void s_bwd_prop_d_sin_0(DiffPair_1 * dpdpx_7, DiffPair_float_0 * _s_dOut_16) { - float _S2351 = s_primal_ctx_cos_0((*dpdpx_7).primal_0.primal_0) * _s_dOut_8->differential_0; - float _S2352 = (*dpdpx_7).primal_0.differential_0 * _s_dOut_8->differential_0; - DiffPair_float_0 _S2353; - (&_S2353)->primal_0 = (*dpdpx_7).primal_0.primal_0; - (&_S2353)->differential_0 = 0.0f; - s_bwd_prop_cos_0(&_S2353, _S2352); - DiffPair_float_0 _S2354; - (&_S2354)->primal_0 = (*dpdpx_7).primal_0.primal_0; - (&_S2354)->differential_0 = 0.0f; - s_bwd_prop_sin_0(&_S2354, _s_dOut_8->primal_0); - DiffPair_float_0 _S2355 = { _S2353.differential_0 + _S2354.differential_0, _S2351 }; + float _S5727 = s_primal_ctx_cos_0((*dpdpx_7).primal_0.primal_0) * _s_dOut_16->differential_0; + float _S5728 = (*dpdpx_7).primal_0.differential_0 * _s_dOut_16->differential_0; + DiffPair_float_0 _S5729; + (&_S5729)->primal_0 = (*dpdpx_7).primal_0.primal_0; + (&_S5729)->differential_0 = 0.0f; + s_bwd_prop_cos_0(&_S5729, _S5728); + DiffPair_float_0 _S5730; + (&_S5730)->primal_0 = (*dpdpx_7).primal_0.primal_0; + (&_S5730)->differential_0 = 0.0f; + s_bwd_prop_sin_0(&_S5730, _s_dOut_16->primal_0); + DiffPair_float_0 _S5731 = { _S5729.differential_0 + _S5730.differential_0, _S5727 }; dpdpx_7->primal_0 = (*dpdpx_7).primal_0; - dpdpx_7->differential_0 = _S2355; + dpdpx_7->differential_0 = _S5731; return; } -inline __device__ void projection_3dgs_equisolid_vjp(bool antialiased_10, float3 mean_11, float4 quat_10, float3 scale_10, float in_opacity_10, Matrix R_10, float3 t_10, float fx_14, float fy_14, float cx_11, float cy_11, FixedArray dist_coeffs_14, uint image_width_10, uint image_height_10, float2 v_mean2d_2, float v_depth_2, float3 v_conic_2, float v_opacity_2, float3 * v_mean_2, float4 * v_quat_2, float3 * v_scale_2, float * v_in_opacity_2, Matrix * v_R_2, float3 * v_t_2) +inline __device__ void projection_3dgs_equisolid_none_vjp(bool antialiased_29, float3 mean_30, float4 quat_29, float3 scale_29, float in_opacity_29, Matrix R_29, float3 t_29, float fx_42, float fy_42, float cx_33, float cy_33, FixedArray dist_coeffs_41, uint image_width_29, uint image_height_29, float2 v_mean2d_7, float v_depth_7, float3 v_conic_7, float v_opacity_7, float3 * v_mean_7, float4 * v_quat_7, float3 * v_scale_7, float * v_in_opacity_7, Matrix * v_R_7, float3 * v_t_7) { - DiffPair_float_0 _S2356 = { 0.0f, 0.0f }; - float3 mean_c_10 = s_primal_ctx_mul_0(R_10, mean_11) + t_10; - float _S2357 = - in_opacity_10; - float _S2358 = 1.0f + s_primal_ctx_exp_0(_S2357); - float _S2359 = 1.0f / _S2358; - float _S2360 = _S2358 * _S2358; - float4 _S2361 = normalize_0(quat_10); - float3 _S2362 = s_primal_ctx_exp_1(scale_10); - float _S2363 = _S2361.y; - float x2_10 = _S2363 * _S2363; - float y2_10 = _S2361.z * _S2361.z; - float z2_10 = _S2361.w * _S2361.w; - float xy_10 = _S2361.y * _S2361.z; - float xz_10 = _S2361.y * _S2361.w; - float yz_10 = _S2361.z * _S2361.w; - float wx_10 = _S2361.x * _S2361.y; - float wy_10 = _S2361.x * _S2361.z; - float wz_10 = _S2361.x * _S2361.w; - Matrix _S2364 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_10 + z2_10), 2.0f * (xy_10 + wz_10), 2.0f * (xz_10 - wy_10), 2.0f * (xy_10 - wz_10), 1.0f - 2.0f * (x2_10 + z2_10), 2.0f * (yz_10 + wx_10), 2.0f * (xz_10 + wy_10), 2.0f * (yz_10 - wx_10), 1.0f - 2.0f * (x2_10 + y2_10))); - Matrix S_2 = makeMatrix (_S2362.x, 0.0f, 0.0f, 0.0f, _S2362.y, 0.0f, 0.0f, 0.0f, _S2362.z); - Matrix _S2365 = s_primal_ctx_mul_1(_S2364, S_2); - Matrix _S2366 = transpose_3(_S2365); - Matrix _S2367 = s_primal_ctx_mul_1(_S2365, _S2366); - Matrix _S2368 = s_primal_ctx_mul_1(R_10, _S2367); - Matrix _S2369 = transpose_3(R_10); - Matrix _S2370 = s_primal_ctx_mul_1(_S2368, _S2369); - Matrix J_12 = makeMatrix (0.0f); - float2 _S2371 = float2 {mean_c_10.x, mean_c_10.y}; - float2 _S2372 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2373 = { _S2371, _S2372 }; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2374; - (&_S2374)->primal_0 = _S2371; - (&_S2374)->differential_0 = _S2372; - DiffPair_float_0 _S2375 = s_primal_ctx_s_fwd_length_impl_0(&_S2374); - float _S2376 = mean_c_10.z; - DiffPair_float_0 _S2377 = { _S2375.primal_0, _S2375.differential_0 }; - DiffPair_float_0 _S2378 = { _S2376, 0.0f }; - DiffPair_float_0 _S2379; - (&_S2379)->primal_0 = _S2375.primal_0; - (&_S2379)->differential_0 = _S2375.differential_0; - DiffPair_float_0 _S2380; - (&_S2380)->primal_0 = _S2376; - (&_S2380)->differential_0 = 0.0f; - DiffPair_float_0 _S2381 = s_primal_ctx_d_atan2_0(&_S2379, &_S2380); - bool _S2382 = (_S2375.primal_0) < 9.99999997475242708e-07f; - float k_7; - float s_diff_k_3; - float _S2383; - float _S2384; - float _S2385; - float _S2386; - float _S2387; - float _S2388; - float _S2389; - float _S2390; - float _S2391; - float _S2392; - DiffPair_float_0 _S2393; - if(_S2382) + float2 _S5732 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5733 = { _S5732, _S5732 }; + s_bwd_prop_DiffProjection3DGS_3dgs_equisolid_none_projection_Intermediates_0 _S5734; + (&_S5734)->_S5717 = _S5733; + (&_S5734)->_S5718 = _S5733; + (&_S5734)->_S5719 = _S5733; + (&(&_S5734)->_S5717)->primal_0 = _S5732; + (&(&_S5734)->_S5717)->differential_0 = _S5732; + (&(&_S5734)->_S5718)->primal_0 = _S5732; + (&(&_S5734)->_S5718)->differential_0 = _S5732; + (&(&_S5734)->_S5719)->primal_0 = _S5732; + (&(&_S5734)->_S5719)->differential_0 = _S5732; + float3 mean_c_29 = s_primal_ctx_mul_0(R_29, mean_30) + t_29; + float2 _S5735 = float2 {mean_c_29.x, mean_c_29.y}; + float2 _S5736 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5737 = { _S5735, _S5736 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5738; + (&_S5738)->primal_0 = _S5735; + (&_S5738)->differential_0 = _S5736; + DiffPair_float_0 _S5739 = s_primal_ctx_s_fwd_length_impl_0(&_S5738); + float _S5740 = mean_c_29.z; + DiffPair_float_0 _S5741 = { _S5739.primal_0, _S5739.differential_0 }; + DiffPair_float_0 _S5742 = { _S5740, 0.0f }; + DiffPair_float_0 _S5743; + (&_S5743)->primal_0 = _S5739.primal_0; + (&_S5743)->differential_0 = _S5739.differential_0; + DiffPair_float_0 _S5744; + (&_S5744)->primal_0 = _S5740; + (&_S5744)->differential_0 = 0.0f; + DiffPair_float_0 _S5745 = s_primal_ctx_d_atan2_0(&_S5743, &_S5744); + bool _S5746 = (_S5739.primal_0) < 9.99999997475242708e-07f; + float k_23; + float s_diff_k_13; + if(_S5746) { - float _S2394 = _S2381.differential_0 * _S2381.primal_0; - float _S2395 = 1.0f - _S2381.primal_0 * _S2381.primal_0 / 24.0f; - float _S2396 = 0.0f - (_S2394 + _S2394) * 0.0416666679084301f; - float _S2397 = _S2376 * _S2376; - float _S2398 = _S2396 * _S2376; - float _S2399 = _S2398 / _S2397; - float _S2400 = _S2397 * _S2397; - k_7 = _S2395 / _S2376; - s_diff_k_3 = _S2399; - _S2383 = _S2400; - _S2384 = _S2398; - _S2385 = _S2397; - _S2386 = _S2395; - _S2387 = _S2396; - _S2388 = 0.0f; - _S2389 = 0.0f; - _S2390 = 0.0f; - _S2391 = 0.0f; - _S2392 = 0.0f; - (&_S2393)->primal_0 = 0.0f; - (&_S2393)->differential_0 = 0.0f; + float _S5747 = _S5745.differential_0 * _S5745.primal_0; + float _S5748 = (0.0f - (_S5747 + _S5747) * 0.0416666679084301f) * _S5740 / (_S5740 * _S5740); + k_23 = (1.0f - _S5745.primal_0 * _S5745.primal_0 / 24.0f) / _S5740; + s_diff_k_13 = _S5748; } else { - float _S2401 = 0.5f * _S2381.primal_0; - float _S2402 = _S2381.differential_0 * 0.5f; - DiffPair_float_0 _S2403; - (&_S2403)->primal_0 = _S2401; - (&_S2403)->differential_0 = _S2402; - DiffPair_float_0 _S2404 = s_primal_ctx_d_sin_0(&_S2403); - float _S2405 = 2.0f * _S2404.primal_0; - float _S2406 = _S2404.differential_0 * 2.0f; - float _S2407 = _S2375.primal_0 * _S2375.primal_0; - float _S2408 = _S2406 * _S2375.primal_0 - _S2405 * _S2375.differential_0; - float _S2409 = _S2408 / _S2407; - float _S2410 = _S2407 * _S2407; - k_7 = _S2405 / _S2375.primal_0; - s_diff_k_3 = _S2409; - _S2383 = 0.0f; - _S2384 = 0.0f; - _S2385 = 0.0f; - _S2386 = 0.0f; - _S2387 = 0.0f; - _S2388 = _S2410; - _S2389 = _S2408; - _S2390 = _S2407; - _S2391 = _S2405; - _S2392 = _S2406; - (&_S2393)->primal_0 = _S2401; - (&_S2393)->differential_0 = _S2402; + float _S5749 = _S5745.differential_0 * 0.5f; + DiffPair_float_0 _S5750; + (&_S5750)->primal_0 = 0.5f * _S5745.primal_0; + (&_S5750)->differential_0 = _S5749; + DiffPair_float_0 _S5751 = s_primal_ctx_d_sin_0(&_S5750); + float _S5752 = 2.0f * _S5751.primal_0; + float _S5753 = (_S5751.differential_0 * 2.0f * _S5739.primal_0 - _S5752 * _S5739.differential_0) / (_S5739.primal_0 * _S5739.primal_0); + k_23 = _S5752 / _S5739.primal_0; + s_diff_k_13 = _S5753; } - float2 _S2411 = make_float2 (k_7); - float2 _S2412 = make_float2 (s_diff_k_3); - float2 _S2413 = _S2371 * make_float2 (k_7); - float2 _S2414 = _S2372 * make_float2 (k_7) + make_float2 (s_diff_k_3) * _S2371; - float u_80 = _S2413.x; - float s_diff_u_24 = _S2414.x; - float v_80 = _S2413.y; - float s_diff_v_24 = _S2414.y; - float _S2415 = s_diff_u_24 * u_80; - float _S2416 = s_diff_v_24 * v_80; - float r2_80 = u_80 * u_80 + v_80 * v_80; - float s_diff_r2_24 = _S2415 + _S2415 + (_S2416 + _S2416); - float _S2417 = s_diff_r2_24 * dist_coeffs_14[int(3)]; - float _S2418 = dist_coeffs_14[int(2)] + r2_80 * dist_coeffs_14[int(3)]; - float _S2419 = s_diff_r2_24 * _S2418 + _S2417 * r2_80; - float _S2420 = dist_coeffs_14[int(1)] + r2_80 * _S2418; - float _S2421 = s_diff_r2_24 * _S2420 + _S2419 * r2_80; - float _S2422 = dist_coeffs_14[int(0)] + r2_80 * _S2420; - float _S2423 = s_diff_r2_24 * _S2422 + _S2421 * r2_80; - float2 _S2424 = make_float2 (_S2423); - float radial_33 = 1.0f + r2_80 * _S2422; - float2 _S2425 = make_float2 (radial_33); - float _S2426 = 2.0f * dist_coeffs_14[int(4)]; - float _S2427 = _S2426 * u_80; - float _S2428 = s_diff_u_24 * _S2426; - float _S2429 = 2.0f * u_80; - float _S2430 = s_diff_u_24 * 2.0f; - float _S2431 = 2.0f * dist_coeffs_14[int(5)]; - float _S2432 = _S2431 * u_80; - float _S2433 = s_diff_u_24 * _S2431; - float _S2434 = 2.0f * v_80; - float _S2435 = s_diff_v_24 * 2.0f; - float2 _S2436 = _S2414 * make_float2 (radial_33) + make_float2 (_S2423) * _S2413 + make_float2 (_S2428 * v_80 + s_diff_v_24 * _S2427 + (s_diff_r2_24 + (_S2430 * u_80 + s_diff_u_24 * _S2429)) * dist_coeffs_14[int(5)] + s_diff_r2_24 * dist_coeffs_14[int(6)], _S2433 * v_80 + s_diff_v_24 * _S2432 + (s_diff_r2_24 + (_S2435 * v_80 + s_diff_v_24 * _S2434)) * dist_coeffs_14[int(4)] + s_diff_r2_24 * dist_coeffs_14[int(7)]); - float2 _S2437 = _S2436 + make_float2 (_S2436.x * dist_coeffs_14[int(8)] + _S2436.y * dist_coeffs_14[int(9)], 0.0f); - float _S2438 = _S2437.x * fx_14; - float _S2439 = _S2437.y * fy_14; - Matrix _S2440 = J_12; - *&(((&_S2440)->rows + (int(0)))->x) = _S2438; - *&(((&_S2440)->rows + (int(1)))->x) = _S2439; - float2 _S2441 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2442 = { _S2371, _S2441 }; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2443; - (&_S2443)->primal_0 = _S2371; - (&_S2443)->differential_0 = _S2441; - DiffPair_float_0 _S2444 = s_primal_ctx_s_fwd_length_impl_0(&_S2443); - DiffPair_float_0 _S2445 = { _S2444.primal_0, _S2444.differential_0 }; - DiffPair_float_0 _S2446; - (&_S2446)->primal_0 = _S2444.primal_0; - (&_S2446)->differential_0 = _S2444.differential_0; - DiffPair_float_0 _S2447; - (&_S2447)->primal_0 = _S2376; - (&_S2447)->differential_0 = 0.0f; - DiffPair_float_0 _S2448 = s_primal_ctx_d_atan2_0(&_S2446, &_S2447); - bool _S2449 = (_S2444.primal_0) < 9.99999997475242708e-07f; - float _S2450; - float _S2451; - float _S2452; - float _S2453; - float _S2454; - float _S2455; - float _S2456; - float _S2457; - float _S2458; - float _S2459; - DiffPair_float_0 _S2460; - if(_S2449) + float2 _S5754 = _S5735 * make_float2 (k_23); + float2 _S5755 = _S5736 * make_float2 (k_23) + make_float2 (s_diff_k_13) * _S5735; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5756; + (&_S5756)->primal_0 = _S5754; + (&_S5756)->differential_0 = _S5755; + FixedArray _S5757 = dist_coeffs_41; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5758 = s_primal_ctx_s_fwd_DistNone_distort_0(&_S5756, &_S5757); + (&_S5734)->_S5717 = _S5758; + float2 _S5759 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5760 = { _S5735, _S5759 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5761; + (&_S5761)->primal_0 = _S5735; + (&_S5761)->differential_0 = _S5759; + DiffPair_float_0 _S5762 = s_primal_ctx_s_fwd_length_impl_0(&_S5761); + DiffPair_float_0 _S5763 = { _S5762.primal_0, _S5762.differential_0 }; + DiffPair_float_0 _S5764; + (&_S5764)->primal_0 = _S5762.primal_0; + (&_S5764)->differential_0 = _S5762.differential_0; + DiffPair_float_0 _S5765; + (&_S5765)->primal_0 = _S5740; + (&_S5765)->differential_0 = 0.0f; + DiffPair_float_0 _S5766 = s_primal_ctx_d_atan2_0(&_S5764, &_S5765); + bool _S5767 = (_S5762.primal_0) < 9.99999997475242708e-07f; + if(_S5767) { - float _S2461 = _S2448.differential_0 * _S2448.primal_0; - float _S2462 = 1.0f - _S2448.primal_0 * _S2448.primal_0 / 24.0f; - float _S2463 = 0.0f - (_S2461 + _S2461) * 0.0416666679084301f; - float _S2464 = _S2376 * _S2376; - float _S2465 = _S2463 * _S2376; - float _S2466 = _S2465 / _S2464; - float _S2467 = _S2464 * _S2464; - k_7 = _S2462 / _S2376; - s_diff_k_3 = _S2466; - _S2450 = _S2467; - _S2451 = _S2465; - _S2452 = _S2464; - _S2453 = _S2462; - _S2454 = _S2463; - _S2455 = 0.0f; - _S2456 = 0.0f; - _S2457 = 0.0f; - _S2458 = 0.0f; - _S2459 = 0.0f; - (&_S2460)->primal_0 = 0.0f; - (&_S2460)->differential_0 = 0.0f; + float _S5768 = _S5766.differential_0 * _S5766.primal_0; + float _S5769 = (0.0f - (_S5768 + _S5768) * 0.0416666679084301f) * _S5740 / (_S5740 * _S5740); + k_23 = (1.0f - _S5766.primal_0 * _S5766.primal_0 / 24.0f) / _S5740; + s_diff_k_13 = _S5769; } else { - float _S2468 = 0.5f * _S2448.primal_0; - float _S2469 = _S2448.differential_0 * 0.5f; - DiffPair_float_0 _S2470; - (&_S2470)->primal_0 = _S2468; - (&_S2470)->differential_0 = _S2469; - DiffPair_float_0 _S2471 = s_primal_ctx_d_sin_0(&_S2470); - float _S2472 = 2.0f * _S2471.primal_0; - float _S2473 = _S2471.differential_0 * 2.0f; - float _S2474 = _S2444.primal_0 * _S2444.primal_0; - float _S2475 = _S2473 * _S2444.primal_0 - _S2472 * _S2444.differential_0; - float _S2476 = _S2475 / _S2474; - float _S2477 = _S2474 * _S2474; - k_7 = _S2472 / _S2444.primal_0; - s_diff_k_3 = _S2476; - _S2450 = 0.0f; - _S2451 = 0.0f; - _S2452 = 0.0f; - _S2453 = 0.0f; - _S2454 = 0.0f; - _S2455 = _S2477; - _S2456 = _S2475; - _S2457 = _S2474; - _S2458 = _S2472; - _S2459 = _S2473; - (&_S2460)->primal_0 = _S2468; - (&_S2460)->differential_0 = _S2469; + float _S5770 = _S5766.differential_0 * 0.5f; + DiffPair_float_0 _S5771; + (&_S5771)->primal_0 = 0.5f * _S5766.primal_0; + (&_S5771)->differential_0 = _S5770; + DiffPair_float_0 _S5772 = s_primal_ctx_d_sin_0(&_S5771); + float _S5773 = 2.0f * _S5772.primal_0; + float _S5774 = (_S5772.differential_0 * 2.0f * _S5762.primal_0 - _S5773 * _S5762.differential_0) / (_S5762.primal_0 * _S5762.primal_0); + k_23 = _S5773 / _S5762.primal_0; + s_diff_k_13 = _S5774; } - float2 _S2478 = make_float2 (k_7); - float2 _S2479 = make_float2 (s_diff_k_3); - float2 _S2480 = _S2371 * make_float2 (k_7); - float2 _S2481 = _S2441 * make_float2 (k_7) + make_float2 (s_diff_k_3) * _S2371; - float u_81 = _S2480.x; - float s_diff_u_25 = _S2481.x; - float v_81 = _S2480.y; - float s_diff_v_25 = _S2481.y; - float _S2482 = s_diff_u_25 * u_81; - float _S2483 = s_diff_v_25 * v_81; - float r2_81 = u_81 * u_81 + v_81 * v_81; - float s_diff_r2_25 = _S2482 + _S2482 + (_S2483 + _S2483); - float _S2484 = s_diff_r2_25 * dist_coeffs_14[int(3)]; - float _S2485 = dist_coeffs_14[int(2)] + r2_81 * dist_coeffs_14[int(3)]; - float _S2486 = s_diff_r2_25 * _S2485 + _S2484 * r2_81; - float _S2487 = dist_coeffs_14[int(1)] + r2_81 * _S2485; - float _S2488 = s_diff_r2_25 * _S2487 + _S2486 * r2_81; - float _S2489 = dist_coeffs_14[int(0)] + r2_81 * _S2487; - float _S2490 = s_diff_r2_25 * _S2489 + _S2488 * r2_81; - float2 _S2491 = make_float2 (_S2490); - float radial_34 = 1.0f + r2_81 * _S2489; - float2 _S2492 = make_float2 (radial_34); - float _S2493 = _S2426 * u_81; - float _S2494 = s_diff_u_25 * _S2426; - float _S2495 = 2.0f * u_81; - float _S2496 = s_diff_u_25 * 2.0f; - float _S2497 = _S2431 * u_81; - float _S2498 = s_diff_u_25 * _S2431; - float _S2499 = 2.0f * v_81; - float _S2500 = s_diff_v_25 * 2.0f; - float2 _S2501 = _S2481 * make_float2 (radial_34) + make_float2 (_S2490) * _S2480 + make_float2 (_S2494 * v_81 + s_diff_v_25 * _S2493 + (s_diff_r2_25 + (_S2496 * u_81 + s_diff_u_25 * _S2495)) * dist_coeffs_14[int(5)] + s_diff_r2_25 * dist_coeffs_14[int(6)], _S2498 * v_81 + s_diff_v_25 * _S2497 + (s_diff_r2_25 + (_S2500 * v_81 + s_diff_v_25 * _S2499)) * dist_coeffs_14[int(4)] + s_diff_r2_25 * dist_coeffs_14[int(7)]); - float2 _S2502 = _S2501 + make_float2 (_S2501.x * dist_coeffs_14[int(8)] + _S2501.y * dist_coeffs_14[int(9)], 0.0f); - float _S2503 = _S2502.y * fy_14; - *&(((&_S2440)->rows + (int(0)))->y) = _S2502.x * fx_14; - *&(((&_S2440)->rows + (int(1)))->y) = _S2503; - float2 _S2504 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2505 = { _S2371, _S2504 }; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2506; - (&_S2506)->primal_0 = _S2371; - (&_S2506)->differential_0 = _S2504; - DiffPair_float_0 _S2507 = s_primal_ctx_s_fwd_length_impl_0(&_S2506); - DiffPair_float_0 _S2508 = { _S2507.primal_0, _S2507.differential_0 }; - DiffPair_float_0 _S2509 = { _S2376, 1.0f }; - DiffPair_float_0 _S2510; - (&_S2510)->primal_0 = _S2507.primal_0; - (&_S2510)->differential_0 = _S2507.differential_0; - DiffPair_float_0 _S2511; - (&_S2511)->primal_0 = _S2376; - (&_S2511)->differential_0 = 1.0f; - DiffPair_float_0 _S2512 = s_primal_ctx_d_atan2_0(&_S2510, &_S2511); - bool _S2513 = (_S2507.primal_0) < 9.99999997475242708e-07f; - float _S2514; - float _S2515; - float _S2516; - float _S2517; - float _S2518; - float _S2519; - float _S2520; - float _S2521; - float _S2522; - float _S2523; - DiffPair_float_0 _S2524; - if(_S2513) + float2 _S5775 = _S5735 * make_float2 (k_23); + float2 _S5776 = _S5759 * make_float2 (k_23) + make_float2 (s_diff_k_13) * _S5735; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5777; + (&_S5777)->primal_0 = _S5775; + (&_S5777)->differential_0 = _S5776; + FixedArray _S5778 = dist_coeffs_41; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5779 = s_primal_ctx_s_fwd_DistNone_distort_0(&_S5777, &_S5778); + (&_S5734)->_S5718 = _S5779; + float2 _S5780 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5781 = { _S5735, _S5780 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5782; + (&_S5782)->primal_0 = _S5735; + (&_S5782)->differential_0 = _S5780; + DiffPair_float_0 _S5783 = s_primal_ctx_s_fwd_length_impl_0(&_S5782); + DiffPair_float_0 _S5784 = { _S5783.primal_0, _S5783.differential_0 }; + DiffPair_float_0 _S5785 = { _S5740, 1.0f }; + DiffPair_float_0 _S5786; + (&_S5786)->primal_0 = _S5783.primal_0; + (&_S5786)->differential_0 = _S5783.differential_0; + DiffPair_float_0 _S5787; + (&_S5787)->primal_0 = _S5740; + (&_S5787)->differential_0 = 1.0f; + DiffPair_float_0 _S5788 = s_primal_ctx_d_atan2_0(&_S5786, &_S5787); + bool _S5789 = (_S5783.primal_0) < 9.99999997475242708e-07f; + if(_S5789) { - float _S2525 = _S2512.differential_0 * _S2512.primal_0; - float _S2526 = 1.0f - _S2512.primal_0 * _S2512.primal_0 / 24.0f; - float _S2527 = 0.0f - (_S2525 + _S2525) * 0.0416666679084301f; - float _S2528 = _S2376 * _S2376; - float _S2529 = _S2527 * _S2376 - _S2526; - float _S2530 = _S2529 / _S2528; - float _S2531 = _S2528 * _S2528; - k_7 = _S2526 / _S2376; - s_diff_k_3 = _S2530; - _S2514 = _S2531; - _S2515 = _S2529; - _S2516 = _S2528; - _S2517 = _S2526; - _S2518 = _S2527; - _S2519 = 0.0f; - _S2520 = 0.0f; - _S2521 = 0.0f; - _S2522 = 0.0f; - _S2523 = 0.0f; - (&_S2524)->primal_0 = 0.0f; - (&_S2524)->differential_0 = 0.0f; + float _S5790 = _S5788.differential_0 * _S5788.primal_0; + float _S5791 = 1.0f - _S5788.primal_0 * _S5788.primal_0 / 24.0f; + float _S5792 = ((0.0f - (_S5790 + _S5790) * 0.0416666679084301f) * _S5740 - _S5791) / (_S5740 * _S5740); + k_23 = _S5791 / _S5740; + s_diff_k_13 = _S5792; } else { - float _S2532 = 0.5f * _S2512.primal_0; - float _S2533 = _S2512.differential_0 * 0.5f; - DiffPair_float_0 _S2534; - (&_S2534)->primal_0 = _S2532; - (&_S2534)->differential_0 = _S2533; - DiffPair_float_0 _S2535 = s_primal_ctx_d_sin_0(&_S2534); - float _S2536 = 2.0f * _S2535.primal_0; - float _S2537 = _S2535.differential_0 * 2.0f; - float _S2538 = _S2507.primal_0 * _S2507.primal_0; - float _S2539 = _S2537 * _S2507.primal_0 - _S2536 * _S2507.differential_0; - float _S2540 = _S2539 / _S2538; - float _S2541 = _S2538 * _S2538; - k_7 = _S2536 / _S2507.primal_0; - s_diff_k_3 = _S2540; - _S2514 = 0.0f; - _S2515 = 0.0f; - _S2516 = 0.0f; - _S2517 = 0.0f; - _S2518 = 0.0f; - _S2519 = _S2541; - _S2520 = _S2539; - _S2521 = _S2538; - _S2522 = _S2536; - _S2523 = _S2537; - (&_S2524)->primal_0 = _S2532; - (&_S2524)->differential_0 = _S2533; + float _S5793 = _S5788.differential_0 * 0.5f; + DiffPair_float_0 _S5794; + (&_S5794)->primal_0 = 0.5f * _S5788.primal_0; + (&_S5794)->differential_0 = _S5793; + DiffPair_float_0 _S5795 = s_primal_ctx_d_sin_0(&_S5794); + float _S5796 = 2.0f * _S5795.primal_0; + float _S5797 = (_S5795.differential_0 * 2.0f * _S5783.primal_0 - _S5796 * _S5783.differential_0) / (_S5783.primal_0 * _S5783.primal_0); + k_23 = _S5796 / _S5783.primal_0; + s_diff_k_13 = _S5797; } - float2 _S2542 = make_float2 (k_7); - float2 _S2543 = make_float2 (s_diff_k_3); - float2 _S2544 = _S2371 * make_float2 (k_7); - float2 _S2545 = make_float2 (s_diff_k_3) * _S2371; - float u_82 = _S2544.x; - float s_diff_u_26 = _S2545.x; - float v_82 = _S2544.y; - float s_diff_v_26 = _S2545.y; - float _S2546 = s_diff_u_26 * u_82; - float _S2547 = s_diff_v_26 * v_82; - float r2_82 = u_82 * u_82 + v_82 * v_82; - float s_diff_r2_26 = _S2546 + _S2546 + (_S2547 + _S2547); - float _S2548 = s_diff_r2_26 * dist_coeffs_14[int(3)]; - float _S2549 = dist_coeffs_14[int(2)] + r2_82 * dist_coeffs_14[int(3)]; - float _S2550 = s_diff_r2_26 * _S2549 + _S2548 * r2_82; - float _S2551 = dist_coeffs_14[int(1)] + r2_82 * _S2549; - float _S2552 = s_diff_r2_26 * _S2551 + _S2550 * r2_82; - float _S2553 = dist_coeffs_14[int(0)] + r2_82 * _S2551; - float _S2554 = s_diff_r2_26 * _S2553 + _S2552 * r2_82; - float2 _S2555 = make_float2 (_S2554); - float radial_35 = 1.0f + r2_82 * _S2553; - float2 _S2556 = make_float2 (radial_35); - float _S2557 = _S2426 * u_82; - float _S2558 = s_diff_u_26 * _S2426; - float _S2559 = 2.0f * u_82; - float _S2560 = s_diff_u_26 * 2.0f; - float _S2561 = _S2431 * u_82; - float _S2562 = s_diff_u_26 * _S2431; - float _S2563 = 2.0f * v_82; - float _S2564 = s_diff_v_26 * 2.0f; - float2 _S2565 = _S2545 * make_float2 (radial_35) + make_float2 (_S2554) * _S2544 + make_float2 (_S2558 * v_82 + s_diff_v_26 * _S2557 + (s_diff_r2_26 + (_S2560 * u_82 + s_diff_u_26 * _S2559)) * dist_coeffs_14[int(5)] + s_diff_r2_26 * dist_coeffs_14[int(6)], _S2562 * v_82 + s_diff_v_26 * _S2561 + (s_diff_r2_26 + (_S2564 * v_82 + s_diff_v_26 * _S2563)) * dist_coeffs_14[int(4)] + s_diff_r2_26 * dist_coeffs_14[int(7)]); - float2 _S2566 = _S2565 + make_float2 (_S2565.x * dist_coeffs_14[int(8)] + _S2565.y * dist_coeffs_14[int(9)], 0.0f); - float _S2567 = _S2566.y * fy_14; - *&(((&_S2440)->rows + (int(0)))->z) = _S2566.x * fx_14; - *&(((&_S2440)->rows + (int(1)))->z) = _S2567; - Matrix _S2568 = s_primal_ctx_mul_2(_S2440, _S2370); - Matrix _S2569 = transpose_1(_S2440); - Matrix _S2570 = s_primal_ctx_mul_3(_S2568, _S2569); - float eps2d_10; - if(antialiased_10) + float2 _S5798 = _S5735 * make_float2 (k_23); + float2 _S5799 = make_float2 (s_diff_k_13) * _S5735; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5800; + (&_S5800)->primal_0 = _S5798; + (&_S5800)->differential_0 = _S5799; + FixedArray _S5801 = dist_coeffs_41; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5802 = s_primal_ctx_s_fwd_DistNone_distort_0(&_S5800, &_S5801); + (&_S5734)->_S5719 = _S5802; + s_bwd_prop_DiffProjection3DGS_3dgs_equisolid_none_projection_Intermediates_0 _S5803 = _S5734; + DiffPair_float_0 _S5804 = { 0.0f, 0.0f }; + float _S5805 = - in_opacity_29; + float _S5806 = 1.0f + s_primal_ctx_exp_0(_S5805); + float _S5807 = 1.0f / _S5806; + float _S5808 = _S5806 * _S5806; + float4 _S5809 = normalize_0(quat_29); + float3 _S5810 = s_primal_ctx_exp_1(scale_29); + float _S5811 = _S5809.y; + float x2_29 = _S5811 * _S5811; + float y2_29 = _S5809.z * _S5809.z; + float z2_29 = _S5809.w * _S5809.w; + float xy_29 = _S5809.y * _S5809.z; + float xz_29 = _S5809.y * _S5809.w; + float yz_29 = _S5809.z * _S5809.w; + float wx_29 = _S5809.x * _S5809.y; + float wy_29 = _S5809.x * _S5809.z; + float wz_29 = _S5809.x * _S5809.w; + Matrix _S5812 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_29 + z2_29), 2.0f * (xy_29 + wz_29), 2.0f * (xz_29 - wy_29), 2.0f * (xy_29 - wz_29), 1.0f - 2.0f * (x2_29 + z2_29), 2.0f * (yz_29 + wx_29), 2.0f * (xz_29 + wy_29), 2.0f * (yz_29 - wx_29), 1.0f - 2.0f * (x2_29 + y2_29))); + Matrix S_7 = makeMatrix (_S5810.x, 0.0f, 0.0f, 0.0f, _S5810.y, 0.0f, 0.0f, 0.0f, _S5810.z); + Matrix _S5813 = s_primal_ctx_mul_1(_S5812, S_7); + Matrix _S5814 = transpose_3(_S5813); + Matrix _S5815 = s_primal_ctx_mul_1(_S5813, _S5814); + Matrix _S5816 = s_primal_ctx_mul_1(R_29, _S5815); + Matrix _S5817 = transpose_3(R_29); + Matrix _S5818 = s_primal_ctx_mul_1(_S5816, _S5817); + Matrix J_39 = makeMatrix (0.0f); + float _S5819; + float _S5820; + float _S5821; + float _S5822; + float _S5823; + float _S5824; + float _S5825; + float _S5826; + float _S5827; + float _S5828; + DiffPair_float_0 _S5829; + if(_S5746) { - eps2d_10 = 0.10000000149011612f; + float _S5830 = _S5745.differential_0 * _S5745.primal_0; + float _S5831 = 1.0f - _S5745.primal_0 * _S5745.primal_0 / 24.0f; + float _S5832 = 0.0f - (_S5830 + _S5830) * 0.0416666679084301f; + float _S5833 = _S5740 * _S5740; + float _S5834 = _S5832 * _S5740; + float _S5835 = _S5834 / _S5833; + float _S5836 = _S5833 * _S5833; + k_23 = _S5831 / _S5740; + s_diff_k_13 = _S5835; + _S5819 = _S5836; + _S5820 = _S5834; + _S5821 = _S5833; + _S5822 = _S5831; + _S5823 = _S5832; + _S5824 = 0.0f; + _S5825 = 0.0f; + _S5826 = 0.0f; + _S5827 = 0.0f; + _S5828 = 0.0f; + (&_S5829)->primal_0 = 0.0f; + (&_S5829)->differential_0 = 0.0f; } else { - eps2d_10 = 0.30000001192092896f; + float _S5837 = 0.5f * _S5745.primal_0; + float _S5838 = _S5745.differential_0 * 0.5f; + DiffPair_float_0 _S5839; + (&_S5839)->primal_0 = _S5837; + (&_S5839)->differential_0 = _S5838; + DiffPair_float_0 _S5840 = s_primal_ctx_d_sin_0(&_S5839); + float _S5841 = 2.0f * _S5840.primal_0; + float _S5842 = _S5840.differential_0 * 2.0f; + float _S5843 = _S5739.primal_0 * _S5739.primal_0; + float _S5844 = _S5842 * _S5739.primal_0 - _S5841 * _S5739.differential_0; + float _S5845 = _S5844 / _S5843; + float _S5846 = _S5843 * _S5843; + k_23 = _S5841 / _S5739.primal_0; + s_diff_k_13 = _S5845; + _S5819 = 0.0f; + _S5820 = 0.0f; + _S5821 = 0.0f; + _S5822 = 0.0f; + _S5823 = 0.0f; + _S5824 = _S5846; + _S5825 = _S5844; + _S5826 = _S5843; + _S5827 = _S5841; + _S5828 = _S5842; + (&_S5829)->primal_0 = _S5837; + (&_S5829)->differential_0 = _S5838; } - float _S2571 = _S2570.rows[int(0)].y * _S2570.rows[int(1)].x; - float det_orig_10 = _S2570.rows[int(0)].x * _S2570.rows[int(1)].y - _S2571; - float _S2572 = _S2570.rows[int(0)].x + eps2d_10; - Matrix _S2573 = _S2570; - *&(((&_S2573)->rows + (int(0)))->x) = _S2572; - float _S2574 = _S2570.rows[int(1)].y + eps2d_10; - *&(((&_S2573)->rows + (int(1)))->y) = _S2574; - Matrix _S2575 = _S2573; - Matrix _S2576 = _S2573; - float det_blur_10 = _S2572 * _S2574 - _S2571; - float _S2577 = det_orig_10 / det_blur_10; - float _S2578 = det_blur_10 * det_blur_10; - float _S2579 = (F32_max((0.0f), (_S2577))); - float _S2580 = s_primal_ctx_sqrt_0(_S2579); - float invdet_12 = 1.0f / det_blur_10; - float _S2581 = - _S2570.rows[int(0)].y; - float _S2582 = - _S2570.rows[int(1)].x; - if(antialiased_10) + float2 _S5847 = make_float2 (k_23); + float2 _S5848 = make_float2 (s_diff_k_13); + float2 _S5849 = _S5735 * make_float2 (k_23); + float2 _S5850 = _S5736 * make_float2 (k_23) + make_float2 (s_diff_k_13) * _S5735; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5851 = { _S5849, _S5850 }; + float _S5852 = _S5803._S5717.differential_0.x * fx_42; + float _S5853 = _S5803._S5717.differential_0.y * fy_42; + Matrix _S5854 = J_39; + *&(((&_S5854)->rows + (int(0)))->x) = _S5852; + *&(((&_S5854)->rows + (int(1)))->x) = _S5853; + float _S5855; + float _S5856; + float _S5857; + float _S5858; + float _S5859; + float _S5860; + float _S5861; + float _S5862; + float _S5863; + float _S5864; + DiffPair_float_0 _S5865; + if(_S5767) { - k_7 = _S2359 * _S2580; + float _S5866 = _S5766.differential_0 * _S5766.primal_0; + float _S5867 = 1.0f - _S5766.primal_0 * _S5766.primal_0 / 24.0f; + float _S5868 = 0.0f - (_S5866 + _S5866) * 0.0416666679084301f; + float _S5869 = _S5740 * _S5740; + float _S5870 = _S5868 * _S5740; + float _S5871 = _S5870 / _S5869; + float _S5872 = _S5869 * _S5869; + k_23 = _S5867 / _S5740; + s_diff_k_13 = _S5871; + _S5855 = _S5872; + _S5856 = _S5870; + _S5857 = _S5869; + _S5858 = _S5867; + _S5859 = _S5868; + _S5860 = 0.0f; + _S5861 = 0.0f; + _S5862 = 0.0f; + _S5863 = 0.0f; + _S5864 = 0.0f; + (&_S5865)->primal_0 = 0.0f; + (&_S5865)->differential_0 = 0.0f; } else { - k_7 = _S2359; + float _S5873 = 0.5f * _S5766.primal_0; + float _S5874 = _S5766.differential_0 * 0.5f; + DiffPair_float_0 _S5875; + (&_S5875)->primal_0 = _S5873; + (&_S5875)->differential_0 = _S5874; + DiffPair_float_0 _S5876 = s_primal_ctx_d_sin_0(&_S5875); + float _S5877 = 2.0f * _S5876.primal_0; + float _S5878 = _S5876.differential_0 * 2.0f; + float _S5879 = _S5762.primal_0 * _S5762.primal_0; + float _S5880 = _S5878 * _S5762.primal_0 - _S5877 * _S5762.differential_0; + float _S5881 = _S5880 / _S5879; + float _S5882 = _S5879 * _S5879; + k_23 = _S5877 / _S5762.primal_0; + s_diff_k_13 = _S5881; + _S5855 = 0.0f; + _S5856 = 0.0f; + _S5857 = 0.0f; + _S5858 = 0.0f; + _S5859 = 0.0f; + _S5860 = _S5882; + _S5861 = _S5880; + _S5862 = _S5879; + _S5863 = _S5877; + _S5864 = _S5878; + (&_S5865)->primal_0 = _S5873; + (&_S5865)->differential_0 = _S5874; } - float _S2583 = k_7 / 0.00392156885936856f; - float _S2584 = 2.0f * s_primal_ctx_log_0(_S2583); - float _S2585 = s_primal_ctx_sqrt_0(_S2584); - float _S2586 = _S2575.rows[int(0)].x; - float _S2587 = _S2576.rows[int(1)].y; - float3 campos_3 = - s_primal_ctx_mul_0(_S2369, t_10); - float3 _S2588 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2589; - (&_S2589)->primal_0 = mean_11; - (&_S2589)->differential_0 = _S2588; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2590; - (&_S2590)->primal_0 = scale_10; - (&_S2590)->differential_0 = _S2588; - DiffPair_float_0 _S2591; - (&_S2591)->primal_0 = in_opacity_10; - (&_S2591)->differential_0 = 0.0f; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2592; - (&_S2592)->primal_0 = campos_3; - (&_S2592)->differential_0 = _S2588; - s_bwd_prop_view_radius_3dgs_0(&_S2589, &_S2590, &_S2591, &_S2592, 0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2593 = _S2589; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2594 = _S2590; - DiffPair_float_0 _S2595 = _S2591; - float2 _S2596 = make_float2 (0.0f); - float2 _S2597 = _S2596; - *&((&_S2597)->y) = v_conic_2.z; - float2 _S2598 = _S2596; - *&((&_S2598)->y) = v_conic_2.y; - *&((&_S2598)->x) = v_conic_2.x; - DiffPair_float_0 _S2599; - (&_S2599)->primal_0 = _S2587; - (&_S2599)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S2599, 0.0f); - DiffPair_float_0 _S2600; - (&_S2600)->primal_0 = _S2586; - (&_S2600)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S2600, 0.0f); - DiffPair_float_0 _S2601; - (&_S2601)->primal_0 = 3.32999992370605469f; - (&_S2601)->differential_0 = 0.0f; - DiffPair_float_0 _S2602; - (&_S2602)->primal_0 = _S2585; - (&_S2602)->differential_0 = 0.0f; - _d_min_0(&_S2601, &_S2602, 0.0f); - DiffPair_float_0 _S2603; - (&_S2603)->primal_0 = _S2584; - (&_S2603)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S2603, _S2602.differential_0); - float _S2604 = 2.0f * _S2603.differential_0; - DiffPair_float_0 _S2605; - (&_S2605)->primal_0 = _S2583; - (&_S2605)->differential_0 = 0.0f; - s_bwd_prop_log_0(&_S2605, _S2604); - float _S2606 = v_opacity_2 + 254.9999847412109375f * _S2605.differential_0; - float2 _S2607 = make_float2 (_S2600.differential_0, 0.0f); - Matrix _S2608 = makeMatrix (0.0f); - Matrix _S2609 = _S2608; - _S2609[int(1)] = _S2597; - _S2609[int(0)] = _S2598; - Matrix _S2610 = _S2609; - float2 _S2611 = make_float2 (0.0f, _S2599.differential_0); - if(antialiased_10) + float2 _S5883 = make_float2 (k_23); + float2 _S5884 = make_float2 (s_diff_k_13); + float2 _S5885 = _S5735 * make_float2 (k_23); + float2 _S5886 = _S5759 * make_float2 (k_23) + make_float2 (s_diff_k_13) * _S5735; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5887 = { _S5885, _S5886 }; + float _S5888 = _S5803._S5718.differential_0.y * fy_42; + *&(((&_S5854)->rows + (int(0)))->y) = _S5803._S5718.differential_0.x * fx_42; + *&(((&_S5854)->rows + (int(1)))->y) = _S5888; + float _S5889; + float _S5890; + float _S5891; + float _S5892; + float _S5893; + float _S5894; + float _S5895; + float _S5896; + float _S5897; + float _S5898; + DiffPair_float_0 _S5899; + if(_S5789) { - float _S2612 = _S2580 * _S2606; - k_7 = _S2359 * _S2606; - s_diff_k_3 = _S2612; + float _S5900 = _S5788.differential_0 * _S5788.primal_0; + float _S5901 = 1.0f - _S5788.primal_0 * _S5788.primal_0 / 24.0f; + float _S5902 = 0.0f - (_S5900 + _S5900) * 0.0416666679084301f; + float _S5903 = _S5740 * _S5740; + float _S5904 = _S5902 * _S5740 - _S5901; + float _S5905 = _S5904 / _S5903; + float _S5906 = _S5903 * _S5903; + k_23 = _S5901 / _S5740; + s_diff_k_13 = _S5905; + _S5889 = _S5906; + _S5890 = _S5904; + _S5891 = _S5903; + _S5892 = _S5901; + _S5893 = _S5902; + _S5894 = 0.0f; + _S5895 = 0.0f; + _S5896 = 0.0f; + _S5897 = 0.0f; + _S5898 = 0.0f; + (&_S5899)->primal_0 = 0.0f; + (&_S5899)->differential_0 = 0.0f; } else { - k_7 = 0.0f; - s_diff_k_3 = _S2606; + float _S5907 = 0.5f * _S5788.primal_0; + float _S5908 = _S5788.differential_0 * 0.5f; + DiffPair_float_0 _S5909; + (&_S5909)->primal_0 = _S5907; + (&_S5909)->differential_0 = _S5908; + DiffPair_float_0 _S5910 = s_primal_ctx_d_sin_0(&_S5909); + float _S5911 = 2.0f * _S5910.primal_0; + float _S5912 = _S5910.differential_0 * 2.0f; + float _S5913 = _S5783.primal_0 * _S5783.primal_0; + float _S5914 = _S5912 * _S5783.primal_0 - _S5911 * _S5783.differential_0; + float _S5915 = _S5914 / _S5913; + float _S5916 = _S5913 * _S5913; + k_23 = _S5911 / _S5783.primal_0; + s_diff_k_13 = _S5915; + _S5889 = 0.0f; + _S5890 = 0.0f; + _S5891 = 0.0f; + _S5892 = 0.0f; + _S5893 = 0.0f; + _S5894 = _S5916; + _S5895 = _S5914; + _S5896 = _S5913; + _S5897 = _S5911; + _S5898 = _S5912; + (&_S5899)->primal_0 = _S5907; + (&_S5899)->differential_0 = _S5908; } - float _S2613 = invdet_12 * _S2610.rows[int(1)].y; - float _S2614 = - (invdet_12 * _S2610.rows[int(1)].x); - float _S2615 = - (invdet_12 * _S2610.rows[int(0)].y); - float _S2616 = invdet_12 * _S2610.rows[int(0)].x; - float _S2617 = - ((_S2572 * _S2610.rows[int(1)].y + _S2582 * _S2610.rows[int(1)].x + _S2581 * _S2610.rows[int(0)].y + _S2574 * _S2610.rows[int(0)].x) / _S2578); - DiffPair_float_0 _S2618; - (&_S2618)->primal_0 = _S2579; - (&_S2618)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S2618, k_7); - DiffPair_float_0 _S2619; - (&_S2619)->primal_0 = 0.0f; - (&_S2619)->differential_0 = 0.0f; - DiffPair_float_0 _S2620; - (&_S2620)->primal_0 = _S2577; - (&_S2620)->differential_0 = 0.0f; - _d_max_0(&_S2619, &_S2620, _S2618.differential_0); - float _S2621 = _S2620.differential_0 / _S2578; - float s_diff_det_orig_T_2 = det_blur_10 * _S2621; - float _S2622 = det_orig_10 * - _S2621 + _S2617; - float _S2623 = - _S2622; - float _S2624 = _S2572 * _S2622; - float _S2625 = _S2574 * _S2622; - Matrix _S2626 = _S2608; - _S2626[int(1)] = _S2611; - _S2626[int(0)] = _S2607; - _S2573 = _S2626; - *&(((&_S2573)->rows + (int(1)))->y) = 0.0f; - float _S2627 = _S2624 + _S2626.rows[int(1)].y + _S2616; - *&(((&_S2573)->rows + (int(0)))->x) = 0.0f; - float _S2628 = _S2625 + _S2626.rows[int(0)].x + _S2613; - float _S2629 = _S2623 + - s_diff_det_orig_T_2; - float _S2630 = _S2570.rows[int(0)].y * _S2629 + _S2614; - float _S2631 = _S2570.rows[int(1)].x * _S2629 + _S2615; - float _S2632 = _S2570.rows[int(1)].y * s_diff_det_orig_T_2; - float _S2633 = _S2627 + _S2570.rows[int(0)].x * s_diff_det_orig_T_2; - float2 _S2634 = _S2596; - *&((&_S2634)->x) = _S2630; - *&((&_S2634)->y) = _S2633; - float _S2635 = _S2628 + _S2632; - float2 _S2636 = _S2596; - *&((&_S2636)->y) = _S2631; - *&((&_S2636)->x) = _S2635; - Matrix _S2637 = _S2608; - _S2637[int(1)] = _S2634; - _S2637[int(0)] = _S2636; - Matrix _S2638 = _S2573 + _S2637; - DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S2639; - (&_S2639)->primal_0 = _S2568; - (&_S2639)->differential_0 = J_12; - Matrix _S2640 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S2641; - (&_S2641)->primal_0 = _S2569; - (&_S2641)->differential_0 = _S2640; - s_bwd_prop_mul_0(&_S2639, &_S2641, _S2638); - Matrix _S2642 = transpose_2(_S2641.differential_0); - DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S2643; - (&_S2643)->primal_0 = _S2440; - (&_S2643)->differential_0 = J_12; - Matrix _S2644 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2645; - (&_S2645)->primal_0 = _S2370; - (&_S2645)->differential_0 = _S2644; - s_bwd_prop_mul_1(&_S2643, &_S2645, _S2639.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2646 = _S2645; - Matrix _S2647 = _S2642 + _S2643.differential_0; - float2 _S2648 = make_float2 (0.0f, _S2647.rows[int(1)].z) + make_float2 (_S2647.rows[int(0)].z, 0.0f); - float _S2649 = fx_14 * _S2648.x; - float2 _S2650 = make_float2 (_S2649, fy_14 * _S2648.y) + make_float2 (dist_coeffs_14[int(8)] * _S2649, dist_coeffs_14[int(9)] * _S2649); - float2 _S2651 = _S2544 * _S2650; - float2 _S2652 = _S2545 * _S2650; - float _S2653 = dist_coeffs_14[int(4)] * _S2650.y; - float _S2654 = dist_coeffs_14[int(5)] * _S2650.x; - float _S2655 = _S2652.x + _S2652.y; - float _S2656 = _S2651.x + _S2651.y; - float _S2657 = r2_82 * _S2656; - float _S2658 = s_diff_r2_26 * _S2656 + r2_82 * _S2655; - float _S2659 = r2_82 * _S2657; - float _S2660 = s_diff_r2_26 * _S2657 + r2_82 * _S2658; - float _S2661 = dist_coeffs_14[int(7)] * _S2650.y + _S2653 + dist_coeffs_14[int(6)] * _S2650.x + _S2654 + _S2553 * _S2656 + _S2551 * _S2657 + _S2549 * _S2659 + dist_coeffs_14[int(3)] * (r2_82 * _S2659); - float _S2662 = _S2552 * _S2656 + _S2553 * _S2655 + _S2550 * _S2657 + _S2551 * _S2658 + _S2548 * _S2659 + _S2549 * _S2660 + dist_coeffs_14[int(3)] * (s_diff_r2_26 * _S2659 + r2_82 * _S2660); - float _S2663 = _S2661 + _S2661; - float _S2664 = v_82 * _S2662; - float _S2665 = u_82 * _S2662; - float2 _S2666 = _S2555 * _S2650 + make_float2 (_S2431 * (s_diff_v_26 * _S2650.y) + _S2560 * _S2654 + 2.0f * (s_diff_u_26 * _S2654) + _S2426 * (s_diff_v_26 * _S2650.x) + s_diff_u_26 * _S2663 + _S2665 + _S2665, _S2564 * _S2653 + 2.0f * (s_diff_v_26 * _S2653) + _S2562 * _S2650.y + _S2558 * _S2650.x + s_diff_v_26 * _S2663 + _S2664 + _S2664); - float2 _S2667 = _S2556 * _S2650 + make_float2 (_S2431 * (v_82 * _S2650.y) + _S2559 * _S2654 + 2.0f * (u_82 * _S2654) + _S2426 * (v_82 * _S2650.x) + u_82 * _S2663, _S2563 * _S2653 + 2.0f * (v_82 * _S2653) + _S2561 * _S2650.y + _S2557 * _S2650.x + v_82 * _S2663); - float2 _S2668 = _S2371 * _S2667; - float2 _S2669 = _S2371 * _S2666; - float _S2670 = _S2669.x + _S2669.y; - float _S2671 = _S2668.x + _S2668.y; - float2 _S2672 = _S2543 * _S2667 + _S2542 * _S2666; - if(_S2513) + float2 _S5917 = make_float2 (k_23); + float2 _S5918 = make_float2 (s_diff_k_13); + float2 _S5919 = _S5735 * make_float2 (k_23); + float2 _S5920 = make_float2 (s_diff_k_13) * _S5735; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S5921 = { _S5919, _S5920 }; + float _S5922 = _S5803._S5719.differential_0.y * fy_42; + *&(((&_S5854)->rows + (int(0)))->z) = _S5803._S5719.differential_0.x * fx_42; + *&(((&_S5854)->rows + (int(1)))->z) = _S5922; + Matrix _S5923 = s_primal_ctx_mul_2(_S5854, _S5818); + Matrix _S5924 = transpose_1(_S5854); + Matrix _S5925 = s_primal_ctx_mul_3(_S5923, _S5924); + float eps2d_29; + if(antialiased_29) { - float _S2673 = _S2671 / _S2514; - float _S2674 = _S2516 * _S2673; - float _S2675 = _S2376 * (_S2515 * - _S2673); - float _S2676 = _S2670 / _S2516; - float _S2677 = 0.0416666679084301f * - (_S2376 * _S2674); - float _S2678 = _S2677 + _S2677; - float _S2679 = _S2512.primal_0 * (0.0416666679084301f * - (- _S2674 + _S2376 * _S2676)); - float _S2680 = _S2675 + _S2675 + _S2518 * _S2674 + _S2517 * - _S2676; - float _S2681 = _S2512.differential_0 * _S2678 + _S2679 + _S2679; - k_7 = _S2512.primal_0 * _S2678; - _S2514 = _S2681; - _S2515 = _S2680; - _S2516 = 0.0f; - _S2517 = 0.0f; + eps2d_29 = 0.10000000149011612f; } else { - float _S2682 = _S2671 / _S2519; - float _S2683 = _S2521 * _S2682; - float _S2684 = _S2507.primal_0 * (_S2520 * - _S2682); - float _S2685 = - _S2683; - float _S2686 = _S2522 * _S2685; - float _S2687 = _S2523 * _S2683; - float _S2688 = _S2670 / _S2521; - float _S2689 = _S2522 * - _S2688; - float _S2690 = 2.0f * (_S2507.primal_0 * _S2683); - float _S2691 = 2.0f * (_S2507.differential_0 * _S2685 + _S2507.primal_0 * _S2688); - DiffPair_0 _S2692; - (&_S2692)->primal_0 = _S2524; - (&_S2692)->differential_0 = _S2356; - DiffPair_float_0 _S2693; - (&_S2693)->primal_0 = _S2691; - (&_S2693)->differential_0 = _S2690; - s_bwd_prop_d_sin_0(&_S2692, &_S2693); - float _S2694 = 0.5f * _S2692.differential_0.primal_0; - float _S2695 = _S2684 + _S2684 + _S2687 + _S2689; - k_7 = 0.5f * _S2692.differential_0.differential_0; - _S2514 = _S2694; - _S2515 = 0.0f; - _S2516 = _S2686; - _S2517 = _S2695; + eps2d_29 = 0.30000001192092896f; } - DiffPair_0 _S2696; - (&_S2696)->primal_0 = _S2508; - (&_S2696)->differential_0 = _S2356; - DiffPair_0 _S2697; - (&_S2697)->primal_0 = _S2509; - (&_S2697)->differential_0 = _S2356; - DiffPair_float_0 _S2698; - (&_S2698)->primal_0 = _S2514; - (&_S2698)->differential_0 = k_7; - s_bwd_prop_d_atan2_0(&_S2696, &_S2697, &_S2698); - float _S2699 = _S2697.differential_0.primal_0 + _S2515; - float _S2700 = _S2696.differential_0.differential_0 + _S2516; - float _S2701 = _S2696.differential_0.primal_0 + _S2517; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2702 = { _S2596, _S2596 }; - DiffPair_1 _S2703; - (&_S2703)->primal_0 = _S2505; - (&_S2703)->differential_0 = _S2702; - DiffPair_float_0 _S2704; - (&_S2704)->primal_0 = _S2701; - (&_S2704)->differential_0 = _S2700; - s_bwd_prop_s_fwd_length_impl_0(&_S2703, &_S2704); - float2 _S2705 = _S2703.differential_0.primal_0 + _S2672; - float3 _S2706 = make_float3 (_S2705.x, _S2705.y, _S2699); - float2 _S2707 = make_float2 (0.0f, _S2647.rows[int(1)].y) + make_float2 (_S2647.rows[int(0)].y, 0.0f); - float _S2708 = fx_14 * _S2707.x; - float2 _S2709 = make_float2 (_S2708, fy_14 * _S2707.y) + make_float2 (dist_coeffs_14[int(8)] * _S2708, dist_coeffs_14[int(9)] * _S2708); - float2 _S2710 = _S2480 * _S2709; - float2 _S2711 = _S2481 * _S2709; - float _S2712 = dist_coeffs_14[int(4)] * _S2709.y; - float _S2713 = dist_coeffs_14[int(5)] * _S2709.x; - float _S2714 = _S2711.x + _S2711.y; - float _S2715 = _S2710.x + _S2710.y; - float _S2716 = r2_81 * _S2715; - float _S2717 = s_diff_r2_25 * _S2715 + r2_81 * _S2714; - float _S2718 = r2_81 * _S2716; - float _S2719 = s_diff_r2_25 * _S2716 + r2_81 * _S2717; - float _S2720 = dist_coeffs_14[int(7)] * _S2709.y + _S2712 + dist_coeffs_14[int(6)] * _S2709.x + _S2713 + _S2489 * _S2715 + _S2487 * _S2716 + _S2485 * _S2718 + dist_coeffs_14[int(3)] * (r2_81 * _S2718); - float _S2721 = _S2488 * _S2715 + _S2489 * _S2714 + _S2486 * _S2716 + _S2487 * _S2717 + _S2484 * _S2718 + _S2485 * _S2719 + dist_coeffs_14[int(3)] * (s_diff_r2_25 * _S2718 + r2_81 * _S2719); - float _S2722 = _S2720 + _S2720; - float _S2723 = v_81 * _S2721; - float _S2724 = u_81 * _S2721; - float2 _S2725 = _S2491 * _S2709 + make_float2 (_S2431 * (s_diff_v_25 * _S2709.y) + _S2496 * _S2713 + 2.0f * (s_diff_u_25 * _S2713) + _S2426 * (s_diff_v_25 * _S2709.x) + s_diff_u_25 * _S2722 + _S2724 + _S2724, _S2500 * _S2712 + 2.0f * (s_diff_v_25 * _S2712) + _S2498 * _S2709.y + _S2494 * _S2709.x + s_diff_v_25 * _S2722 + _S2723 + _S2723); - float2 _S2726 = _S2492 * _S2709 + make_float2 (_S2431 * (v_81 * _S2709.y) + _S2495 * _S2713 + 2.0f * (u_81 * _S2713) + _S2426 * (v_81 * _S2709.x) + u_81 * _S2722, _S2499 * _S2712 + 2.0f * (v_81 * _S2712) + _S2497 * _S2709.y + _S2493 * _S2709.x + v_81 * _S2722); - float2 _S2727 = _S2371 * _S2726; - float2 _S2728 = _S2441 * _S2726; - float2 _S2729 = _S2371 * _S2725; - float _S2730 = _S2728.x + _S2728.y + _S2729.x + _S2729.y; - float _S2731 = _S2727.x + _S2727.y; - float2 _S2732 = _S2479 * _S2726 + _S2478 * _S2725; - if(_S2449) + float _S5926 = _S5925.rows[int(0)].y * _S5925.rows[int(1)].x; + float det_orig_29 = _S5925.rows[int(0)].x * _S5925.rows[int(1)].y - _S5926; + float _S5927 = _S5925.rows[int(0)].x + eps2d_29; + Matrix _S5928 = _S5925; + *&(((&_S5928)->rows + (int(0)))->x) = _S5927; + float _S5929 = _S5925.rows[int(1)].y + eps2d_29; + *&(((&_S5928)->rows + (int(1)))->y) = _S5929; + Matrix _S5930 = _S5928; + Matrix _S5931 = _S5928; + float det_blur_29 = _S5927 * _S5929 - _S5926; + float _S5932 = det_orig_29 / det_blur_29; + float _S5933 = det_blur_29 * det_blur_29; + float _S5934 = (F32_max((0.0f), (_S5932))); + float _S5935 = s_primal_ctx_sqrt_0(_S5934); + float invdet_35 = 1.0f / det_blur_29; + float _S5936 = - _S5925.rows[int(0)].y; + float _S5937 = - _S5925.rows[int(1)].x; + if(antialiased_29) { - float _S2733 = _S2731 / _S2450; - float _S2734 = _S2452 * _S2733; - float _S2735 = _S2376 * (_S2451 * - _S2733); - float _S2736 = _S2730 / _S2452; - float _S2737 = 0.0416666679084301f * - (_S2376 * _S2734); - float _S2738 = _S2737 + _S2737; - float _S2739 = _S2448.primal_0 * (0.0416666679084301f * - (_S2376 * _S2736)); - float _S2740 = _S2735 + _S2735 + _S2454 * _S2734 + _S2453 * - _S2736; - float _S2741 = _S2448.differential_0 * _S2738 + _S2739 + _S2739; - k_7 = _S2448.primal_0 * _S2738; - _S2450 = _S2741; - _S2451 = _S2740; - _S2452 = 0.0f; - _S2453 = 0.0f; + k_23 = _S5807 * _S5935; } else { - float _S2742 = _S2731 / _S2455; - float _S2743 = _S2457 * _S2742; - float _S2744 = _S2444.primal_0 * (_S2456 * - _S2742); - float _S2745 = - _S2743; - float _S2746 = _S2458 * _S2745; - float _S2747 = _S2459 * _S2743; - float _S2748 = _S2730 / _S2457; - float _S2749 = _S2458 * - _S2748; - float _S2750 = 2.0f * (_S2444.primal_0 * _S2743); - float _S2751 = 2.0f * (_S2444.differential_0 * _S2745 + _S2444.primal_0 * _S2748); - DiffPair_0 _S2752; - (&_S2752)->primal_0 = _S2460; - (&_S2752)->differential_0 = _S2356; - DiffPair_float_0 _S2753; - (&_S2753)->primal_0 = _S2751; - (&_S2753)->differential_0 = _S2750; - s_bwd_prop_d_sin_0(&_S2752, &_S2753); - float _S2754 = 0.5f * _S2752.differential_0.primal_0; - float _S2755 = _S2744 + _S2744 + _S2747 + _S2749; - k_7 = 0.5f * _S2752.differential_0.differential_0; - _S2450 = _S2754; - _S2451 = 0.0f; - _S2452 = _S2746; - _S2453 = _S2755; + k_23 = _S5807; } - DiffPair_0 _S2756; - (&_S2756)->primal_0 = _S2445; - (&_S2756)->differential_0 = _S2356; - DiffPair_0 _S2757; - (&_S2757)->primal_0 = _S2378; - (&_S2757)->differential_0 = _S2356; - DiffPair_float_0 _S2758; - (&_S2758)->primal_0 = _S2450; - (&_S2758)->differential_0 = k_7; - s_bwd_prop_d_atan2_0(&_S2756, &_S2757, &_S2758); - float _S2759 = _S2757.differential_0.primal_0 + _S2451; - float _S2760 = _S2756.differential_0.differential_0 + _S2452; - float _S2761 = _S2756.differential_0.primal_0 + _S2453; - DiffPair_1 _S2762; - (&_S2762)->primal_0 = _S2442; - (&_S2762)->differential_0 = _S2702; - DiffPair_float_0 _S2763; - (&_S2763)->primal_0 = _S2761; - (&_S2763)->differential_0 = _S2760; - s_bwd_prop_s_fwd_length_impl_0(&_S2762, &_S2763); - float2 _S2764 = _S2762.differential_0.primal_0 + _S2732; - float2 _S2765 = make_float2 (0.0f, _S2647.rows[int(1)].x) + make_float2 (_S2647.rows[int(0)].x, 0.0f); - float _S2766 = fx_14 * _S2765.x; - float2 _S2767 = make_float2 (_S2766, fy_14 * _S2765.y) + make_float2 (dist_coeffs_14[int(8)] * _S2766, dist_coeffs_14[int(9)] * _S2766); - float2 _S2768 = _S2413 * _S2767; - float2 _S2769 = _S2414 * _S2767; - float _S2770 = dist_coeffs_14[int(4)] * _S2767.y; - float _S2771 = dist_coeffs_14[int(5)] * _S2767.x; - float _S2772 = _S2769.x + _S2769.y; - float _S2773 = _S2768.x + _S2768.y; - float _S2774 = r2_80 * _S2773; - float _S2775 = s_diff_r2_24 * _S2773 + r2_80 * _S2772; - float _S2776 = r2_80 * _S2774; - float _S2777 = s_diff_r2_24 * _S2774 + r2_80 * _S2775; - float _S2778 = dist_coeffs_14[int(7)] * _S2767.y + _S2770 + dist_coeffs_14[int(6)] * _S2767.x + _S2771 + _S2422 * _S2773 + _S2420 * _S2774 + _S2418 * _S2776 + dist_coeffs_14[int(3)] * (r2_80 * _S2776); - float _S2779 = _S2421 * _S2773 + _S2422 * _S2772 + _S2419 * _S2774 + _S2420 * _S2775 + _S2417 * _S2776 + _S2418 * _S2777 + dist_coeffs_14[int(3)] * (s_diff_r2_24 * _S2776 + r2_80 * _S2777); - float _S2780 = _S2778 + _S2778; - float _S2781 = v_80 * _S2779; - float _S2782 = u_80 * _S2779; - float2 _S2783 = _S2424 * _S2767 + make_float2 (_S2431 * (s_diff_v_24 * _S2767.y) + _S2430 * _S2771 + 2.0f * (s_diff_u_24 * _S2771) + _S2426 * (s_diff_v_24 * _S2767.x) + s_diff_u_24 * _S2780 + _S2782 + _S2782, _S2435 * _S2770 + 2.0f * (s_diff_v_24 * _S2770) + _S2433 * _S2767.y + _S2428 * _S2767.x + s_diff_v_24 * _S2780 + _S2781 + _S2781); - float2 _S2784 = _S2425 * _S2767 + make_float2 (_S2431 * (v_80 * _S2767.y) + _S2429 * _S2771 + 2.0f * (u_80 * _S2771) + _S2426 * (v_80 * _S2767.x) + u_80 * _S2780, _S2434 * _S2770 + 2.0f * (v_80 * _S2770) + _S2432 * _S2767.y + _S2427 * _S2767.x + v_80 * _S2780); - float3 _S2785 = make_float3 (_S2764.x, _S2764.y, _S2759) + _S2706; - float2 _S2786 = _S2371 * _S2784; - float2 _S2787 = _S2372 * _S2784; - float2 _S2788 = _S2371 * _S2783; - float _S2789 = _S2787.x + _S2787.y + _S2788.x + _S2788.y; - float _S2790 = _S2786.x + _S2786.y; - float2 _S2791 = _S2412 * _S2784 + _S2411 * _S2783; - if(_S2382) + float _S5938 = k_23 / 0.00392156885936856f; + float _S5939 = 2.0f * s_primal_ctx_log_0(_S5938); + float _S5940 = s_primal_ctx_sqrt_0(_S5939); + float _S5941 = _S5930.rows[int(0)].x; + float _S5942 = _S5931.rows[int(1)].y; + float3 campos_8 = - s_primal_ctx_mul_0(_S5817, t_29); + float3 _S5943 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5944; + (&_S5944)->primal_0 = mean_30; + (&_S5944)->differential_0 = _S5943; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5945; + (&_S5945)->primal_0 = scale_29; + (&_S5945)->differential_0 = _S5943; + DiffPair_float_0 _S5946; + (&_S5946)->primal_0 = in_opacity_29; + (&_S5946)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5947; + (&_S5947)->primal_0 = campos_8; + (&_S5947)->differential_0 = _S5943; + s_bwd_prop_view_radius_3dgs_0(&_S5944, &_S5945, &_S5946, &_S5947, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5948 = _S5944; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S5949 = _S5945; + DiffPair_float_0 _S5950 = _S5946; + float2 _S5951 = _S5732; + *&((&_S5951)->y) = v_conic_7.z; + float2 _S5952 = _S5732; + *&((&_S5952)->y) = v_conic_7.y; + *&((&_S5952)->x) = v_conic_7.x; + DiffPair_float_0 _S5953; + (&_S5953)->primal_0 = _S5942; + (&_S5953)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5953, 0.0f); + DiffPair_float_0 _S5954; + (&_S5954)->primal_0 = _S5941; + (&_S5954)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5954, 0.0f); + DiffPair_float_0 _S5955; + (&_S5955)->primal_0 = 3.32999992370605469f; + (&_S5955)->differential_0 = 0.0f; + DiffPair_float_0 _S5956; + (&_S5956)->primal_0 = _S5940; + (&_S5956)->differential_0 = 0.0f; + _d_min_0(&_S5955, &_S5956, 0.0f); + DiffPair_float_0 _S5957; + (&_S5957)->primal_0 = _S5939; + (&_S5957)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5957, _S5956.differential_0); + float _S5958 = 2.0f * _S5957.differential_0; + DiffPair_float_0 _S5959; + (&_S5959)->primal_0 = _S5938; + (&_S5959)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S5959, _S5958); + float _S5960 = v_opacity_7 + 254.9999847412109375f * _S5959.differential_0; + Matrix _S5961 = makeMatrix (0.0f); + Matrix _S5962 = _S5961; + _S5962[int(1)] = _S5951; + _S5962[int(0)] = _S5952; + Matrix _S5963 = _S5962; + float2 _S5964 = make_float2 (0.0f, _S5953.differential_0); + float2 _S5965 = make_float2 (_S5954.differential_0, 0.0f); + if(antialiased_29) { - float _S2792 = _S2790 / _S2383; - float _S2793 = _S2385 * _S2792; - float _S2794 = _S2376 * (_S2384 * - _S2792); - float _S2795 = _S2789 / _S2385; - float _S2796 = 0.0416666679084301f * - (_S2376 * _S2793); - float _S2797 = _S2796 + _S2796; - float _S2798 = _S2381.primal_0 * (0.0416666679084301f * - (_S2376 * _S2795)); - float _S2799 = _S2794 + _S2794 + _S2387 * _S2793 + _S2386 * - _S2795; - float _S2800 = _S2381.differential_0 * _S2797 + _S2798 + _S2798; - k_7 = _S2381.primal_0 * _S2797; - _S2383 = _S2800; - _S2384 = _S2799; - _S2385 = 0.0f; - _S2386 = 0.0f; + float _S5966 = _S5935 * _S5960; + k_23 = _S5807 * _S5960; + s_diff_k_13 = _S5966; } else { - float _S2801 = _S2790 / _S2388; - float _S2802 = _S2390 * _S2801; - float _S2803 = _S2375.primal_0 * (_S2389 * - _S2801); - float _S2804 = - _S2802; - float _S2805 = _S2391 * _S2804; - float _S2806 = _S2392 * _S2802; - float _S2807 = _S2789 / _S2390; - float _S2808 = _S2391 * - _S2807; - float _S2809 = 2.0f * (_S2375.primal_0 * _S2802); - float _S2810 = 2.0f * (_S2375.differential_0 * _S2804 + _S2375.primal_0 * _S2807); - DiffPair_0 _S2811; - (&_S2811)->primal_0 = _S2393; - (&_S2811)->differential_0 = _S2356; - DiffPair_float_0 _S2812; - (&_S2812)->primal_0 = _S2810; - (&_S2812)->differential_0 = _S2809; - s_bwd_prop_d_sin_0(&_S2811, &_S2812); - float _S2813 = 0.5f * _S2811.differential_0.primal_0; - float _S2814 = _S2803 + _S2803 + _S2806 + _S2808; - k_7 = 0.5f * _S2811.differential_0.differential_0; - _S2383 = _S2813; - _S2384 = 0.0f; - _S2385 = _S2805; - _S2386 = _S2814; + k_23 = 0.0f; + s_diff_k_13 = _S5960; } - DiffPair_0 _S2815; - (&_S2815)->primal_0 = _S2377; - (&_S2815)->differential_0 = _S2356; - DiffPair_0 _S2816; - (&_S2816)->primal_0 = _S2378; - (&_S2816)->differential_0 = _S2356; - DiffPair_float_0 _S2817; - (&_S2817)->primal_0 = _S2383; - (&_S2817)->differential_0 = k_7; - s_bwd_prop_d_atan2_0(&_S2815, &_S2816, &_S2817); - float _S2818 = _S2816.differential_0.primal_0 + _S2384; - float _S2819 = _S2815.differential_0.differential_0 + _S2385; - float _S2820 = _S2815.differential_0.primal_0 + _S2386; - DiffPair_1 _S2821; - (&_S2821)->primal_0 = _S2373; - (&_S2821)->differential_0 = _S2702; - DiffPair_float_0 _S2822; - (&_S2822)->primal_0 = _S2820; - (&_S2822)->differential_0 = _S2819; - s_bwd_prop_s_fwd_length_impl_0(&_S2821, &_S2822); - float2 _S2823 = _S2821.differential_0.primal_0 + _S2791; - float3 _S2824 = make_float3 (_S2823.x, _S2823.y, _S2818); - float _S2825 = length_0(_S2371); - float _S2826 = s_primal_ctx_atan2_0(_S2825, _S2376); - bool _S2827 = _S2825 < 9.99999997475242708e-07f; - if(_S2827) + float _S5967 = invdet_35 * _S5963.rows[int(1)].y; + float _S5968 = - (invdet_35 * _S5963.rows[int(1)].x); + float _S5969 = - (invdet_35 * _S5963.rows[int(0)].y); + float _S5970 = invdet_35 * _S5963.rows[int(0)].x; + float _S5971 = - ((_S5927 * _S5963.rows[int(1)].y + _S5937 * _S5963.rows[int(1)].x + _S5936 * _S5963.rows[int(0)].y + _S5929 * _S5963.rows[int(0)].x) / _S5933); + DiffPair_float_0 _S5972; + (&_S5972)->primal_0 = _S5934; + (&_S5972)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S5972, k_23); + DiffPair_float_0 _S5973; + (&_S5973)->primal_0 = 0.0f; + (&_S5973)->differential_0 = 0.0f; + DiffPair_float_0 _S5974; + (&_S5974)->primal_0 = _S5932; + (&_S5974)->differential_0 = 0.0f; + _d_max_0(&_S5973, &_S5974, _S5972.differential_0); + float _S5975 = _S5974.differential_0 / _S5933; + float s_diff_det_orig_T_7 = det_blur_29 * _S5975; + float _S5976 = det_orig_29 * - _S5975 + _S5971; + float _S5977 = - _S5976; + float _S5978 = _S5927 * _S5976; + float _S5979 = _S5929 * _S5976; + Matrix _S5980 = _S5961; + _S5980[int(1)] = _S5964; + _S5980[int(0)] = _S5965; + _S5928 = _S5980; + *&(((&_S5928)->rows + (int(1)))->y) = 0.0f; + float _S5981 = _S5978 + _S5980.rows[int(1)].y + _S5970; + *&(((&_S5928)->rows + (int(0)))->x) = 0.0f; + float _S5982 = _S5979 + _S5980.rows[int(0)].x + _S5967; + float _S5983 = _S5977 + - s_diff_det_orig_T_7; + float _S5984 = _S5925.rows[int(0)].y * _S5983 + _S5968; + float _S5985 = _S5925.rows[int(1)].x * _S5983 + _S5969; + float _S5986 = _S5925.rows[int(1)].y * s_diff_det_orig_T_7; + float _S5987 = _S5981 + _S5925.rows[int(0)].x * s_diff_det_orig_T_7; + float2 _S5988 = _S5732; + *&((&_S5988)->x) = _S5984; + *&((&_S5988)->y) = _S5987; + float _S5989 = _S5982 + _S5986; + float2 _S5990 = _S5732; + *&((&_S5990)->y) = _S5985; + *&((&_S5990)->x) = _S5989; + Matrix _S5991 = _S5961; + _S5991[int(1)] = _S5988; + _S5991[int(0)] = _S5990; + Matrix _S5992 = _S5928 + _S5991; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S5993; + (&_S5993)->primal_0 = _S5923; + (&_S5993)->differential_0 = J_39; + Matrix _S5994 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S5995; + (&_S5995)->primal_0 = _S5924; + (&_S5995)->differential_0 = _S5994; + s_bwd_prop_mul_0(&_S5993, &_S5995, _S5992); + Matrix _S5996 = transpose_2(_S5995.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S5997; + (&_S5997)->primal_0 = _S5854; + (&_S5997)->differential_0 = J_39; + Matrix _S5998 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S5999; + (&_S5999)->primal_0 = _S5818; + (&_S5999)->differential_0 = _S5998; + s_bwd_prop_mul_1(&_S5997, &_S5999, _S5993.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6000 = _S5999; + Matrix _S6001 = _S5996 + _S5997.differential_0; + float2 _S6002 = make_float2 (fx_42 * _S6001.rows[int(0)].z, fy_42 * _S6001.rows[int(1)].z); + DiffPair_0 _S6003; + (&_S6003)->primal_0 = _S5921; + (&_S6003)->differential_0 = _S5733; + FixedArray _S6004 = dist_coeffs_41; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6005; + (&_S6005)->primal_0 = _S5780; + (&_S6005)->differential_0 = _S6002; + s_bwd_prop_s_fwd_DistNone_distort_0(&_S6003, &_S6004, &_S6005); + float2 _S6006 = _S5735 * _S6003.differential_0.differential_0; + float2 _S6007 = _S5735 * _S6003.differential_0.primal_0; + float _S6008 = _S6007.x + _S6007.y; + float _S6009 = _S6006.x + _S6006.y; + float2 _S6010 = _S5918 * _S6003.differential_0.differential_0 + _S5917 * _S6003.differential_0.primal_0; + if(_S5789) { - float _S2828 = 1.0f - _S2826 * _S2826 / 24.0f; - float _S2829 = _S2376 * _S2376; - k_7 = _S2828 / _S2376; - _S2383 = _S2829; - _S2384 = _S2828; - _S2385 = 0.0f; - _S2386 = 0.0f; - _S2387 = 0.0f; + float _S6011 = _S6009 / _S5889; + float _S6012 = _S5891 * _S6011; + float _S6013 = _S5740 * (_S5890 * - _S6011); + float _S6014 = _S6008 / _S5891; + float _S6015 = 0.0416666679084301f * - (_S5740 * _S6012); + float _S6016 = _S6015 + _S6015; + float _S6017 = _S5788.primal_0 * (0.0416666679084301f * - (- _S6012 + _S5740 * _S6014)); + float _S6018 = _S6013 + _S6013 + _S5893 * _S6012 + _S5892 * - _S6014; + float _S6019 = _S5788.differential_0 * _S6016 + _S6017 + _S6017; + k_23 = _S5788.primal_0 * _S6016; + _S5889 = _S6019; + _S5890 = _S6018; + _S5891 = 0.0f; + _S5892 = 0.0f; } else { - float _S2830 = 0.5f * _S2826; - float _S2831 = 2.0f * s_primal_ctx_sin_0(_S2830); - float _S2832 = _S2825 * _S2825; - k_7 = _S2831 / _S2825; - _S2383 = 0.0f; - _S2384 = 0.0f; - _S2385 = _S2832; - _S2386 = _S2831; - _S2387 = _S2830; + float _S6020 = _S6009 / _S5894; + float _S6021 = _S5896 * _S6020; + float _S6022 = _S5783.primal_0 * (_S5895 * - _S6020); + float _S6023 = - _S6021; + float _S6024 = _S5897 * _S6023; + float _S6025 = _S5898 * _S6021; + float _S6026 = _S6008 / _S5896; + float _S6027 = _S5897 * - _S6026; + float _S6028 = 2.0f * (_S5783.primal_0 * _S6021); + float _S6029 = 2.0f * (_S5783.differential_0 * _S6023 + _S5783.primal_0 * _S6026); + DiffPair_1 _S6030; + (&_S6030)->primal_0 = _S5899; + (&_S6030)->differential_0 = _S5804; + DiffPair_float_0 _S6031; + (&_S6031)->primal_0 = _S6029; + (&_S6031)->differential_0 = _S6028; + s_bwd_prop_d_sin_0(&_S6030, &_S6031); + float _S6032 = 0.5f * _S6030.differential_0.primal_0; + float _S6033 = _S6022 + _S6022 + _S6025 + _S6027; + k_23 = 0.5f * _S6030.differential_0.differential_0; + _S5889 = _S6032; + _S5890 = 0.0f; + _S5891 = _S6024; + _S5892 = _S6033; } - float2 _S2833 = make_float2 (k_7); - float2 _S2834 = _S2371 * make_float2 (k_7); - float _S2835 = fx_14 * v_mean2d_2.x; - float u_83 = _S2834.x; - float v_83 = _S2834.y; - float r2_83 = u_83 * u_83 + v_83 * v_83; - float _S2836 = dist_coeffs_14[int(2)] + r2_83 * dist_coeffs_14[int(3)]; - float _S2837 = dist_coeffs_14[int(1)] + r2_83 * _S2836; - float _S2838 = dist_coeffs_14[int(0)] + r2_83 * _S2837; - float2 _S2839 = make_float2 (_S2835, fy_14 * v_mean2d_2.y) + make_float2 (dist_coeffs_14[int(8)] * _S2835, dist_coeffs_14[int(9)] * _S2835); - float2 _S2840 = _S2834 * _S2839; - float _S2841 = dist_coeffs_14[int(4)] * _S2839.y; - float _S2842 = dist_coeffs_14[int(5)] * _S2839.x; - float _S2843 = _S2840.x + _S2840.y; - float _S2844 = r2_83 * _S2843; - float _S2845 = r2_83 * _S2844; - float _S2846 = dist_coeffs_14[int(7)] * _S2839.y + _S2841 + dist_coeffs_14[int(6)] * _S2839.x + _S2842 + _S2838 * _S2843 + _S2837 * _S2844 + _S2836 * _S2845 + dist_coeffs_14[int(3)] * (r2_83 * _S2845); - float _S2847 = v_83 * _S2846; - float _S2848 = u_83 * _S2846; - float2 _S2849 = make_float2 (1.0f + r2_83 * _S2838) * _S2839 + make_float2 (_S2431 * (v_83 * _S2839.y) + 2.0f * u_83 * _S2842 + 2.0f * (u_83 * _S2842) + _S2426 * (v_83 * _S2839.x) + _S2848 + _S2848, 2.0f * v_83 * _S2841 + 2.0f * (v_83 * _S2841) + _S2431 * u_83 * _S2839.y + _S2426 * u_83 * _S2839.x + _S2847 + _S2847); - float2 _S2850 = _S2371 * _S2849; - float2 _S2851 = _S2833 * _S2849; - float _S2852 = _S2850.x + _S2850.y; - if(_S2827) + DiffPair_1 _S6034; + (&_S6034)->primal_0 = _S5784; + (&_S6034)->differential_0 = _S5804; + DiffPair_1 _S6035; + (&_S6035)->primal_0 = _S5785; + (&_S6035)->differential_0 = _S5804; + DiffPair_float_0 _S6036; + (&_S6036)->primal_0 = _S5889; + (&_S6036)->differential_0 = k_23; + s_bwd_prop_d_atan2_0(&_S6034, &_S6035, &_S6036); + float _S6037 = _S6035.differential_0.primal_0 + _S5890; + float _S6038 = _S6034.differential_0.differential_0 + _S5891; + float _S6039 = _S6034.differential_0.primal_0 + _S5892; + DiffPair_0 _S6040; + (&_S6040)->primal_0 = _S5781; + (&_S6040)->differential_0 = _S5733; + DiffPair_float_0 _S6041; + (&_S6041)->primal_0 = _S6039; + (&_S6041)->differential_0 = _S6038; + s_bwd_prop_s_fwd_length_impl_0(&_S6040, &_S6041); + float2 _S6042 = _S6040.differential_0.primal_0 + _S6010; + float3 _S6043 = make_float3 (_S6042.x, _S6042.y, _S6037); + float2 _S6044 = make_float2 (fx_42 * _S6001.rows[int(0)].y, fy_42 * _S6001.rows[int(1)].y); + DiffPair_0 _S6045; + (&_S6045)->primal_0 = _S5887; + (&_S6045)->differential_0 = _S5733; + FixedArray _S6046 = dist_coeffs_41; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6047; + (&_S6047)->primal_0 = _S5780; + (&_S6047)->differential_0 = _S6044; + s_bwd_prop_s_fwd_DistNone_distort_0(&_S6045, &_S6046, &_S6047); + DiffPair_0 _S6048 = _S6045; + float2 _S6049 = _S5735 * _S6048.differential_0.differential_0; + float2 _S6050 = _S5759 * _S6048.differential_0.differential_0; + float2 _S6051 = _S5735 * _S6048.differential_0.primal_0; + float _S6052 = _S6050.x + _S6050.y + _S6051.x + _S6051.y; + float _S6053 = _S6049.x + _S6049.y; + float2 _S6054 = _S5884 * _S6048.differential_0.differential_0 + _S5883 * _S6048.differential_0.primal_0; + if(_S5767) { - float _S2853 = _S2852 / _S2383; - float _S2854 = _S2384 * - _S2853; - float _S2855 = _S2826 * (0.0416666679084301f * - (_S2376 * _S2853)); - k_7 = _S2855 + _S2855; - _S2383 = _S2854; - _S2384 = 0.0f; + float _S6055 = _S6053 / _S5855; + float _S6056 = _S5857 * _S6055; + float _S6057 = _S5740 * (_S5856 * - _S6055); + float _S6058 = _S6052 / _S5857; + float _S6059 = 0.0416666679084301f * - (_S5740 * _S6056); + float _S6060 = _S6059 + _S6059; + float _S6061 = _S5766.primal_0 * (0.0416666679084301f * - (_S5740 * _S6058)); + float _S6062 = _S6057 + _S6057 + _S5859 * _S6056 + _S5858 * - _S6058; + float _S6063 = _S5766.differential_0 * _S6060 + _S6061 + _S6061; + k_23 = _S5766.primal_0 * _S6060; + _S5855 = _S6063; + _S5856 = _S6062; + _S5857 = 0.0f; + _S5858 = 0.0f; } else { - float _S2856 = _S2852 / _S2385; - float _S2857 = _S2386 * - _S2856; - float _S2858 = 2.0f * (_S2825 * _S2856); - DiffPair_float_0 _S2859; - (&_S2859)->primal_0 = _S2387; - (&_S2859)->differential_0 = 0.0f; - s_bwd_prop_sin_0(&_S2859, _S2858); - k_7 = 0.5f * _S2859.differential_0; - _S2383 = 0.0f; - _S2384 = _S2857; + float _S6064 = _S6053 / _S5860; + float _S6065 = _S5862 * _S6064; + float _S6066 = _S5762.primal_0 * (_S5861 * - _S6064); + float _S6067 = - _S6065; + float _S6068 = _S5863 * _S6067; + float _S6069 = _S5864 * _S6065; + float _S6070 = _S6052 / _S5862; + float _S6071 = _S5863 * - _S6070; + float _S6072 = 2.0f * (_S5762.primal_0 * _S6065); + float _S6073 = 2.0f * (_S5762.differential_0 * _S6067 + _S5762.primal_0 * _S6070); + DiffPair_1 _S6074; + (&_S6074)->primal_0 = _S5865; + (&_S6074)->differential_0 = _S5804; + DiffPair_float_0 _S6075; + (&_S6075)->primal_0 = _S6073; + (&_S6075)->differential_0 = _S6072; + s_bwd_prop_d_sin_0(&_S6074, &_S6075); + float _S6076 = 0.5f * _S6074.differential_0.primal_0; + float _S6077 = _S6066 + _S6066 + _S6069 + _S6071; + k_23 = 0.5f * _S6074.differential_0.differential_0; + _S5855 = _S6076; + _S5856 = 0.0f; + _S5857 = _S6068; + _S5858 = _S6077; } - DiffPair_float_0 _S2860; - (&_S2860)->primal_0 = _S2825; - (&_S2860)->differential_0 = 0.0f; - DiffPair_float_0 _S2861; - (&_S2861)->primal_0 = _S2376; - (&_S2861)->differential_0 = 0.0f; - s_bwd_prop_atan2_0(&_S2860, &_S2861, k_7); - float _S2862 = _S2861.differential_0 + _S2383; - float _S2863 = _S2860.differential_0 + _S2384; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2864; - (&_S2864)->primal_0 = _S2371; - (&_S2864)->differential_0 = _S2596; - s_bwd_length_impl_2(&_S2864, _S2863); - float2 _S2865 = _S2864.differential_0 + _S2851; - float3 _S2866 = make_float3 (_S2865.x, _S2865.y, _S2862); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2867; - (&_S2867)->primal_0 = _S2368; - (&_S2867)->differential_0 = _S2644; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2868; - (&_S2868)->primal_0 = _S2369; - (&_S2868)->differential_0 = _S2644; - s_bwd_prop_mul_2(&_S2867, &_S2868, _S2646.differential_0); - Matrix _S2869 = transpose_3(_S2868.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2870; - (&_S2870)->primal_0 = R_10; - (&_S2870)->differential_0 = _S2644; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2871; - (&_S2871)->primal_0 = _S2367; - (&_S2871)->differential_0 = _S2644; - s_bwd_prop_mul_2(&_S2870, &_S2871, _S2867.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2872; - (&_S2872)->primal_0 = _S2365; - (&_S2872)->differential_0 = _S2644; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2873; - (&_S2873)->primal_0 = _S2366; - (&_S2873)->differential_0 = _S2644; - s_bwd_prop_mul_2(&_S2872, &_S2873, _S2871.differential_0); - Matrix _S2874 = _S2872.differential_0 + transpose_3(_S2873.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2875; - (&_S2875)->primal_0 = _S2364; - (&_S2875)->differential_0 = _S2644; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2876; - (&_S2876)->primal_0 = S_2; - (&_S2876)->differential_0 = _S2644; - s_bwd_prop_mul_2(&_S2875, &_S2876, _S2874); - Matrix _S2877 = transpose_3(_S2875.differential_0); - float _S2878 = 2.0f * - _S2877.rows[int(2)].z; - float _S2879 = 2.0f * _S2877.rows[int(2)].y; - float _S2880 = 2.0f * _S2877.rows[int(2)].x; - float _S2881 = 2.0f * _S2877.rows[int(1)].z; - float _S2882 = 2.0f * - _S2877.rows[int(1)].y; - float _S2883 = 2.0f * _S2877.rows[int(1)].x; - float _S2884 = 2.0f * _S2877.rows[int(0)].z; - float _S2885 = 2.0f * _S2877.rows[int(0)].y; - float _S2886 = 2.0f * - _S2877.rows[int(0)].x; - float _S2887 = - _S2883 + _S2885; - float _S2888 = _S2880 + - _S2884; - float _S2889 = - _S2879 + _S2881; - float _S2890 = _S2879 + _S2881; - float _S2891 = _S2880 + _S2884; - float _S2892 = _S2883 + _S2885; - float _S2893 = _S2361.w * (_S2882 + _S2886); - float _S2894 = _S2361.z * (_S2878 + _S2886); - float _S2895 = _S2361.y * (_S2878 + _S2882); - float _S2896 = _S2361.x * _S2887 + _S2361.z * _S2890 + _S2361.y * _S2891 + _S2893 + _S2893; - float _S2897 = _S2361.x * _S2888 + _S2361.w * _S2890 + _S2361.y * _S2892 + _S2894 + _S2894; - float _S2898 = _S2361.x * _S2889 + _S2361.w * _S2891 + _S2361.z * _S2892 + _S2895 + _S2895; - float _S2899 = _S2361.w * _S2887 + _S2361.z * _S2888 + _S2361.y * _S2889; - float3 _S2900 = _S2588; - *&((&_S2900)->z) = _S2876.differential_0.rows[int(2)].z; - *&((&_S2900)->y) = _S2876.differential_0.rows[int(1)].y; - *&((&_S2900)->x) = _S2876.differential_0.rows[int(0)].x; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2901; - (&_S2901)->primal_0 = scale_10; - (&_S2901)->differential_0 = _S2588; - s_bwd_prop_exp_1(&_S2901, _S2900); - float4 _S2902 = make_float4 (0.0f); - float4 _S2903 = _S2902; - *&((&_S2903)->w) = _S2896; - *&((&_S2903)->z) = _S2897; - *&((&_S2903)->y) = _S2898; - *&((&_S2903)->x) = _S2899; - DiffPair_vectorx3Cfloatx2C4x3E_0 _S2904; - (&_S2904)->primal_0 = quat_10; - (&_S2904)->differential_0 = _S2902; - s_bwd_normalize_impl_0(&_S2904, _S2903); - float _S2905 = - (s_diff_k_3 / _S2360); - DiffPair_float_0 _S2906; - (&_S2906)->primal_0 = _S2357; - (&_S2906)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S2906, _S2905); - float _S2907 = - _S2906.differential_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2908; - (&_S2908)->primal_0 = mean_c_10; - (&_S2908)->differential_0 = _S2588; - s_bwd_length_impl_0(&_S2908, v_depth_2); - float3 _S2909 = _S2824 + _S2866 + _S2908.differential_0 + _S2785; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S2910; - (&_S2910)->primal_0 = R_10; - (&_S2910)->differential_0 = _S2644; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S2911; - (&_S2911)->primal_0 = mean_11; - (&_S2911)->differential_0 = _S2588; - s_bwd_prop_mul_3(&_S2910, &_S2911, _S2909); - Matrix _S2912 = _S2869 + _S2870.differential_0 + _S2910.differential_0; - float _S2913 = _S2907 + _S2595.differential_0; - float3 _S2914 = _S2901.differential_0 + _S2594.differential_0; - *v_mean_2 = *v_mean_2 + (_S2911.differential_0 + _S2593.differential_0); - *v_quat_2 = *v_quat_2 + _S2904.differential_0; - *v_scale_2 = *v_scale_2 + _S2914; - *v_in_opacity_2 = *v_in_opacity_2 + _S2913; - *v_R_2 = *v_R_2 + _S2912; - *v_t_2 = *v_t_2 + _S2909; + DiffPair_1 _S6078; + (&_S6078)->primal_0 = _S5763; + (&_S6078)->differential_0 = _S5804; + DiffPair_1 _S6079; + (&_S6079)->primal_0 = _S5742; + (&_S6079)->differential_0 = _S5804; + DiffPair_float_0 _S6080; + (&_S6080)->primal_0 = _S5855; + (&_S6080)->differential_0 = k_23; + s_bwd_prop_d_atan2_0(&_S6078, &_S6079, &_S6080); + float _S6081 = _S6079.differential_0.primal_0 + _S5856; + float _S6082 = _S6078.differential_0.differential_0 + _S5857; + float _S6083 = _S6078.differential_0.primal_0 + _S5858; + DiffPair_0 _S6084; + (&_S6084)->primal_0 = _S5760; + (&_S6084)->differential_0 = _S5733; + DiffPair_float_0 _S6085; + (&_S6085)->primal_0 = _S6083; + (&_S6085)->differential_0 = _S6082; + s_bwd_prop_s_fwd_length_impl_0(&_S6084, &_S6085); + float2 _S6086 = _S6084.differential_0.primal_0 + _S6054; + float3 _S6087 = make_float3 (_S6086.x, _S6086.y, _S6081); + float2 _S6088 = make_float2 (fx_42 * _S6001.rows[int(0)].x, fy_42 * _S6001.rows[int(1)].x); + DiffPair_0 _S6089; + (&_S6089)->primal_0 = _S5851; + (&_S6089)->differential_0 = _S5733; + FixedArray _S6090 = dist_coeffs_41; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6091; + (&_S6091)->primal_0 = _S5780; + (&_S6091)->differential_0 = _S6088; + s_bwd_prop_s_fwd_DistNone_distort_0(&_S6089, &_S6090, &_S6091); + DiffPair_0 _S6092 = _S6089; + float3 _S6093 = _S6087 + _S6043; + float2 _S6094 = _S5735 * _S6092.differential_0.differential_0; + float2 _S6095 = _S5736 * _S6092.differential_0.differential_0; + float2 _S6096 = _S5735 * _S6092.differential_0.primal_0; + float _S6097 = _S6095.x + _S6095.y + _S6096.x + _S6096.y; + float _S6098 = _S6094.x + _S6094.y; + float2 _S6099 = _S5848 * _S6092.differential_0.differential_0 + _S5847 * _S6092.differential_0.primal_0; + if(_S5746) + { + float _S6100 = _S6098 / _S5819; + float _S6101 = _S5821 * _S6100; + float _S6102 = _S5740 * (_S5820 * - _S6100); + float _S6103 = _S6097 / _S5821; + float _S6104 = 0.0416666679084301f * - (_S5740 * _S6101); + float _S6105 = _S6104 + _S6104; + float _S6106 = _S5745.primal_0 * (0.0416666679084301f * - (_S5740 * _S6103)); + float _S6107 = _S6102 + _S6102 + _S5823 * _S6101 + _S5822 * - _S6103; + float _S6108 = _S5745.differential_0 * _S6105 + _S6106 + _S6106; + k_23 = _S5745.primal_0 * _S6105; + _S5819 = _S6108; + _S5820 = _S6107; + _S5821 = 0.0f; + _S5822 = 0.0f; + } + else + { + float _S6109 = _S6098 / _S5824; + float _S6110 = _S5826 * _S6109; + float _S6111 = _S5739.primal_0 * (_S5825 * - _S6109); + float _S6112 = - _S6110; + float _S6113 = _S5827 * _S6112; + float _S6114 = _S5828 * _S6110; + float _S6115 = _S6097 / _S5826; + float _S6116 = _S5827 * - _S6115; + float _S6117 = 2.0f * (_S5739.primal_0 * _S6110); + float _S6118 = 2.0f * (_S5739.differential_0 * _S6112 + _S5739.primal_0 * _S6115); + DiffPair_1 _S6119; + (&_S6119)->primal_0 = _S5829; + (&_S6119)->differential_0 = _S5804; + DiffPair_float_0 _S6120; + (&_S6120)->primal_0 = _S6118; + (&_S6120)->differential_0 = _S6117; + s_bwd_prop_d_sin_0(&_S6119, &_S6120); + float _S6121 = 0.5f * _S6119.differential_0.primal_0; + float _S6122 = _S6111 + _S6111 + _S6114 + _S6116; + k_23 = 0.5f * _S6119.differential_0.differential_0; + _S5819 = _S6121; + _S5820 = 0.0f; + _S5821 = _S6113; + _S5822 = _S6122; + } + DiffPair_1 _S6123; + (&_S6123)->primal_0 = _S5741; + (&_S6123)->differential_0 = _S5804; + DiffPair_1 _S6124; + (&_S6124)->primal_0 = _S5742; + (&_S6124)->differential_0 = _S5804; + DiffPair_float_0 _S6125; + (&_S6125)->primal_0 = _S5819; + (&_S6125)->differential_0 = k_23; + s_bwd_prop_d_atan2_0(&_S6123, &_S6124, &_S6125); + float _S6126 = _S6124.differential_0.primal_0 + _S5820; + float _S6127 = _S6123.differential_0.differential_0 + _S5821; + float _S6128 = _S6123.differential_0.primal_0 + _S5822; + DiffPair_0 _S6129; + (&_S6129)->primal_0 = _S5737; + (&_S6129)->differential_0 = _S5733; + DiffPair_float_0 _S6130; + (&_S6130)->primal_0 = _S6128; + (&_S6130)->differential_0 = _S6127; + s_bwd_prop_s_fwd_length_impl_0(&_S6129, &_S6130); + float2 _S6131 = _S6129.differential_0.primal_0 + _S6099; + float3 _S6132 = make_float3 (_S6131.x, _S6131.y, _S6126); + float _S6133 = length_0(_S5735); + float _S6134 = s_primal_ctx_atan2_0(_S6133, _S5740); + bool _S6135 = _S6133 < 9.99999997475242708e-07f; + if(_S6135) + { + float _S6136 = 1.0f - _S6134 * _S6134 / 24.0f; + float _S6137 = _S5740 * _S5740; + k_23 = _S6136 / _S5740; + _S5819 = _S6137; + _S5820 = _S6136; + _S5821 = 0.0f; + _S5822 = 0.0f; + _S5823 = 0.0f; + } + else + { + float _S6138 = 0.5f * _S6134; + float _S6139 = 2.0f * s_primal_ctx_sin_0(_S6138); + float _S6140 = _S6133 * _S6133; + k_23 = _S6139 / _S6133; + _S5819 = 0.0f; + _S5820 = 0.0f; + _S5821 = _S6140; + _S5822 = _S6139; + _S5823 = _S6138; + } + float2 _S6141 = make_float2 (k_23); + float2 _S6142 = _S5735 * make_float2 (k_23); + float2 _S6143 = make_float2 (fx_42 * v_mean2d_7.x, fy_42 * v_mean2d_7.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6144; + (&_S6144)->primal_0 = _S6142; + (&_S6144)->differential_0 = _S5732; + FixedArray _S6145 = dist_coeffs_41; + s_bwd_prop_DistNone_distort_0(&_S6144, &_S6145, _S6143); + float2 _S6146 = _S5735 * _S6144.differential_0; + float2 _S6147 = _S6141 * _S6144.differential_0; + float _S6148 = _S6146.x + _S6146.y; + if(_S6135) + { + float _S6149 = _S6148 / _S5819; + float _S6150 = _S5820 * - _S6149; + float _S6151 = _S6134 * (0.0416666679084301f * - (_S5740 * _S6149)); + k_23 = _S6151 + _S6151; + _S5819 = _S6150; + _S5820 = 0.0f; + } + else + { + float _S6152 = _S6148 / _S5821; + float _S6153 = _S5822 * - _S6152; + float _S6154 = 2.0f * (_S6133 * _S6152); + DiffPair_float_0 _S6155; + (&_S6155)->primal_0 = _S5823; + (&_S6155)->differential_0 = 0.0f; + s_bwd_prop_sin_0(&_S6155, _S6154); + k_23 = 0.5f * _S6155.differential_0; + _S5819 = 0.0f; + _S5820 = _S6153; + } + DiffPair_float_0 _S6156; + (&_S6156)->primal_0 = _S6133; + (&_S6156)->differential_0 = 0.0f; + DiffPair_float_0 _S6157; + (&_S6157)->primal_0 = _S5740; + (&_S6157)->differential_0 = 0.0f; + s_bwd_prop_atan2_0(&_S6156, &_S6157, k_23); + float _S6158 = _S6157.differential_0 + _S5819; + float _S6159 = _S6156.differential_0 + _S5820; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6160; + (&_S6160)->primal_0 = _S5735; + (&_S6160)->differential_0 = _S5732; + s_bwd_length_impl_2(&_S6160, _S6159); + float2 _S6161 = _S6160.differential_0 + _S6147; + float3 _S6162 = make_float3 (_S6161.x, _S6161.y, _S6158); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6163; + (&_S6163)->primal_0 = _S5816; + (&_S6163)->differential_0 = _S5998; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6164; + (&_S6164)->primal_0 = _S5817; + (&_S6164)->differential_0 = _S5998; + s_bwd_prop_mul_2(&_S6163, &_S6164, _S6000.differential_0); + Matrix _S6165 = transpose_3(_S6164.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6166; + (&_S6166)->primal_0 = R_29; + (&_S6166)->differential_0 = _S5998; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6167; + (&_S6167)->primal_0 = _S5815; + (&_S6167)->differential_0 = _S5998; + s_bwd_prop_mul_2(&_S6166, &_S6167, _S6163.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6168; + (&_S6168)->primal_0 = _S5813; + (&_S6168)->differential_0 = _S5998; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6169; + (&_S6169)->primal_0 = _S5814; + (&_S6169)->differential_0 = _S5998; + s_bwd_prop_mul_2(&_S6168, &_S6169, _S6167.differential_0); + Matrix _S6170 = _S6168.differential_0 + transpose_3(_S6169.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6171; + (&_S6171)->primal_0 = _S5812; + (&_S6171)->differential_0 = _S5998; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6172; + (&_S6172)->primal_0 = S_7; + (&_S6172)->differential_0 = _S5998; + s_bwd_prop_mul_2(&_S6171, &_S6172, _S6170); + Matrix _S6173 = transpose_3(_S6171.differential_0); + float _S6174 = 2.0f * - _S6173.rows[int(2)].z; + float _S6175 = 2.0f * _S6173.rows[int(2)].y; + float _S6176 = 2.0f * _S6173.rows[int(2)].x; + float _S6177 = 2.0f * _S6173.rows[int(1)].z; + float _S6178 = 2.0f * - _S6173.rows[int(1)].y; + float _S6179 = 2.0f * _S6173.rows[int(1)].x; + float _S6180 = 2.0f * _S6173.rows[int(0)].z; + float _S6181 = 2.0f * _S6173.rows[int(0)].y; + float _S6182 = 2.0f * - _S6173.rows[int(0)].x; + float _S6183 = - _S6179 + _S6181; + float _S6184 = _S6176 + - _S6180; + float _S6185 = - _S6175 + _S6177; + float _S6186 = _S6175 + _S6177; + float _S6187 = _S6176 + _S6180; + float _S6188 = _S6179 + _S6181; + float _S6189 = _S5809.w * (_S6178 + _S6182); + float _S6190 = _S5809.z * (_S6174 + _S6182); + float _S6191 = _S5809.y * (_S6174 + _S6178); + float _S6192 = _S5809.x * _S6183 + _S5809.z * _S6186 + _S5809.y * _S6187 + _S6189 + _S6189; + float _S6193 = _S5809.x * _S6184 + _S5809.w * _S6186 + _S5809.y * _S6188 + _S6190 + _S6190; + float _S6194 = _S5809.x * _S6185 + _S5809.w * _S6187 + _S5809.z * _S6188 + _S6191 + _S6191; + float _S6195 = _S5809.w * _S6183 + _S5809.z * _S6184 + _S5809.y * _S6185; + float3 _S6196 = _S5943; + *&((&_S6196)->z) = _S6172.differential_0.rows[int(2)].z; + *&((&_S6196)->y) = _S6172.differential_0.rows[int(1)].y; + *&((&_S6196)->x) = _S6172.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6197; + (&_S6197)->primal_0 = scale_29; + (&_S6197)->differential_0 = _S5943; + s_bwd_prop_exp_1(&_S6197, _S6196); + float4 _S6198 = make_float4 (0.0f); + float4 _S6199 = _S6198; + *&((&_S6199)->w) = _S6192; + *&((&_S6199)->z) = _S6193; + *&((&_S6199)->y) = _S6194; + *&((&_S6199)->x) = _S6195; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S6200; + (&_S6200)->primal_0 = quat_29; + (&_S6200)->differential_0 = _S6198; + s_bwd_normalize_impl_0(&_S6200, _S6199); + float _S6201 = - (s_diff_k_13 / _S5808); + DiffPair_float_0 _S6202; + (&_S6202)->primal_0 = _S5805; + (&_S6202)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S6202, _S6201); + float _S6203 = - _S6202.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6204; + (&_S6204)->primal_0 = mean_c_29; + (&_S6204)->differential_0 = _S5943; + s_bwd_length_impl_0(&_S6204, v_depth_7); + float3 _S6205 = _S6132 + _S6162 + _S6204.differential_0 + _S6093; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6206; + (&_S6206)->primal_0 = R_29; + (&_S6206)->differential_0 = _S5998; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6207; + (&_S6207)->primal_0 = mean_30; + (&_S6207)->differential_0 = _S5943; + s_bwd_prop_mul_3(&_S6206, &_S6207, _S6205); + Matrix _S6208 = _S6165 + _S6166.differential_0 + _S6206.differential_0; + float _S6209 = _S6203 + _S5950.differential_0; + float3 _S6210 = _S6197.differential_0 + _S5949.differential_0; + *v_mean_7 = *v_mean_7 + (_S6207.differential_0 + _S5948.differential_0); + *v_quat_7 = *v_quat_7 + _S6200.differential_0; + *v_scale_7 = *v_scale_7 + _S6210; + *v_in_opacity_7 = *v_in_opacity_7 + _S6209; + *v_R_7 = *v_R_7 + _S6208; + *v_t_7 = *v_t_7 + _S6205; return; } -inline __device__ void s_bwd_prop_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S2915, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S2916, float _S2917) +struct s_bwd_prop_DiffProjection3DGS_3dgs_equisolid_opencv_projection_Intermediates_0 { - _d_dot_0(_S2915, _S2916, _S2917); - return; -} - -inline __device__ void projection_3dgs_equirect_vjp(bool antialiased_11, float3 mean_12, float4 quat_11, float3 scale_11, float in_opacity_11, Matrix R_11, float3 t_11, float fx_15, float fy_15, float cx_12, float cy_12, FixedArray dist_coeffs_15, uint image_width_11, uint image_height_11, float2 v_mean2d_3, float v_depth_3, float3 v_conic_3, float v_opacity_3, float3 * v_mean_3, float4 * v_quat_3, float3 * v_scale_3, float * v_in_opacity_3, Matrix * v_R_3, float3 * v_t_3) -{ - float3 mean_c_11 = s_primal_ctx_mul_0(R_11, mean_12) + t_11; - float _S2918 = - in_opacity_11; - float _S2919 = 1.0f + s_primal_ctx_exp_0(_S2918); - float _S2920 = 1.0f / _S2919; - float _S2921 = _S2919 * _S2919; - float4 _S2922 = normalize_0(quat_11); - float3 _S2923 = s_primal_ctx_exp_1(scale_11); - float _S2924 = _S2922.y; - float x2_11 = _S2924 * _S2924; - float y2_11 = _S2922.z * _S2922.z; - float z2_11 = _S2922.w * _S2922.w; - float xy_11 = _S2922.y * _S2922.z; - float xz_11 = _S2922.y * _S2922.w; - float yz_11 = _S2922.z * _S2922.w; - float wx_11 = _S2922.x * _S2922.y; - float wy_11 = _S2922.x * _S2922.z; - float wz_11 = _S2922.x * _S2922.w; - Matrix _S2925 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_11 + z2_11), 2.0f * (xy_11 + wz_11), 2.0f * (xz_11 - wy_11), 2.0f * (xy_11 - wz_11), 1.0f - 2.0f * (x2_11 + z2_11), 2.0f * (yz_11 + wx_11), 2.0f * (xz_11 + wy_11), 2.0f * (yz_11 - wx_11), 1.0f - 2.0f * (x2_11 + y2_11))); - Matrix S_3 = makeMatrix (_S2923.x, 0.0f, 0.0f, 0.0f, _S2923.y, 0.0f, 0.0f, 0.0f, _S2923.z); - Matrix _S2926 = s_primal_ctx_mul_1(_S2925, S_3); - Matrix _S2927 = transpose_3(_S2926); - Matrix _S2928 = s_primal_ctx_mul_1(_S2926, _S2927); - Matrix _S2929 = s_primal_ctx_mul_1(R_11, _S2928); - Matrix _S2930 = transpose_3(R_11); - Matrix _S2931 = s_primal_ctx_mul_1(_S2929, _S2930); - Matrix J_13 = makeMatrix (0.0f); - float _S2932 = mean_c_11.x; - float _S2933 = mean_c_11.z; - DiffPair_float_0 _S2934 = { _S2932, 1.0f }; - DiffPair_float_0 _S2935 = { _S2933, 0.0f }; - DiffPair_float_0 _S2936; - (&_S2936)->primal_0 = _S2932; - (&_S2936)->differential_0 = 1.0f; - DiffPair_float_0 _S2937; - (&_S2937)->primal_0 = _S2933; - (&_S2937)->differential_0 = 0.0f; - DiffPair_float_0 _S2938 = s_primal_ctx_d_atan2_0(&_S2936, &_S2937); - float _S2939 = mean_c_11.y; - float2 _S2940 = float2 {mean_c_11.x, mean_c_11.z}; - float2 _S2941 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2942 = { _S2940, _S2941 }; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2943; - (&_S2943)->primal_0 = _S2940; - (&_S2943)->differential_0 = _S2941; - DiffPair_float_0 _S2944 = s_primal_ctx_s_fwd_length_impl_0(&_S2943); - DiffPair_float_0 _S2945 = { _S2939, 0.0f }; - DiffPair_float_0 _S2946 = { _S2944.primal_0, _S2944.differential_0 }; - DiffPair_float_0 _S2947; - (&_S2947)->primal_0 = _S2939; - (&_S2947)->differential_0 = 0.0f; - DiffPair_float_0 _S2948; - (&_S2948)->primal_0 = _S2944.primal_0; - (&_S2948)->differential_0 = _S2944.differential_0; - DiffPair_float_0 _S2949 = s_primal_ctx_d_atan2_0(&_S2947, &_S2948); - float _S2950 = _S2938.differential_0 * fx_15; - float _S2951 = _S2949.differential_0 * fy_15; - Matrix _S2952 = J_13; - *&(((&_S2952)->rows + (int(0)))->x) = _S2950; - *&(((&_S2952)->rows + (int(1)))->x) = _S2951; - DiffPair_float_0 _S2953 = { _S2932, 0.0f }; - DiffPair_float_0 _S2954; - (&_S2954)->primal_0 = _S2932; - (&_S2954)->differential_0 = 0.0f; - DiffPair_float_0 _S2955; - (&_S2955)->primal_0 = _S2933; - (&_S2955)->differential_0 = 0.0f; - DiffPair_float_0 _S2956 = s_primal_ctx_d_atan2_0(&_S2954, &_S2955); - float2 _S2957 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2958 = { _S2940, _S2957 }; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2959; - (&_S2959)->primal_0 = _S2940; - (&_S2959)->differential_0 = _S2957; - DiffPair_float_0 _S2960 = s_primal_ctx_s_fwd_length_impl_0(&_S2959); - DiffPair_float_0 _S2961 = { _S2939, 1.0f }; - DiffPair_float_0 _S2962 = { _S2960.primal_0, _S2960.differential_0 }; - DiffPair_float_0 _S2963; - (&_S2963)->primal_0 = _S2939; - (&_S2963)->differential_0 = 1.0f; - DiffPair_float_0 _S2964; - (&_S2964)->primal_0 = _S2960.primal_0; - (&_S2964)->differential_0 = _S2960.differential_0; - DiffPair_float_0 _S2965 = s_primal_ctx_d_atan2_0(&_S2963, &_S2964); - float _S2966 = _S2965.differential_0 * fy_15; - *&(((&_S2952)->rows + (int(0)))->y) = _S2956.differential_0 * fx_15; - *&(((&_S2952)->rows + (int(1)))->y) = _S2966; - DiffPair_float_0 _S2967 = { _S2933, 1.0f }; - DiffPair_float_0 _S2968; - (&_S2968)->primal_0 = _S2932; - (&_S2968)->differential_0 = 0.0f; - DiffPair_float_0 _S2969; - (&_S2969)->primal_0 = _S2933; - (&_S2969)->differential_0 = 1.0f; - DiffPair_float_0 _S2970 = s_primal_ctx_d_atan2_0(&_S2968, &_S2969); - float2 _S2971 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2972 = { _S2940, _S2971 }; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S2973; - (&_S2973)->primal_0 = _S2940; - (&_S2973)->differential_0 = _S2971; - DiffPair_float_0 _S2974 = s_primal_ctx_s_fwd_length_impl_0(&_S2973); - DiffPair_float_0 _S2975 = { _S2974.primal_0, _S2974.differential_0 }; - DiffPair_float_0 _S2976; - (&_S2976)->primal_0 = _S2939; - (&_S2976)->differential_0 = 0.0f; - DiffPair_float_0 _S2977; - (&_S2977)->primal_0 = _S2974.primal_0; - (&_S2977)->differential_0 = _S2974.differential_0; - DiffPair_float_0 _S2978 = s_primal_ctx_d_atan2_0(&_S2976, &_S2977); - float _S2979 = _S2978.differential_0 * fy_15; - *&(((&_S2952)->rows + (int(0)))->z) = _S2970.differential_0 * fx_15; - *&(((&_S2952)->rows + (int(1)))->z) = _S2979; - Matrix _S2980 = s_primal_ctx_mul_2(_S2952, _S2931); - Matrix _S2981 = transpose_1(_S2952); - Matrix _S2982 = s_primal_ctx_mul_3(_S2980, _S2981); - float eps2d_11; - if(antialiased_11) - { - eps2d_11 = 0.10000000149011612f; - } - else - { - eps2d_11 = 0.30000001192092896f; - } - float _S2983 = _S2982.rows[int(0)].y * _S2982.rows[int(1)].x; - float det_orig_11 = _S2982.rows[int(0)].x * _S2982.rows[int(1)].y - _S2983; - float _S2984 = _S2982.rows[int(0)].x + eps2d_11; - Matrix _S2985 = _S2982; - *&(((&_S2985)->rows + (int(0)))->x) = _S2984; - float _S2986 = _S2982.rows[int(1)].y + eps2d_11; - *&(((&_S2985)->rows + (int(1)))->y) = _S2986; - Matrix _S2987 = _S2985; - Matrix _S2988 = _S2985; - float det_blur_11 = _S2984 * _S2986 - _S2983; - float _S2989 = det_orig_11 / det_blur_11; - float _S2990 = det_blur_11 * det_blur_11; - float _S2991 = (F32_max((0.0f), (_S2989))); - float _S2992 = s_primal_ctx_sqrt_0(_S2991); - float invdet_13 = 1.0f / det_blur_11; - float _S2993 = - _S2982.rows[int(0)].y; - float _S2994 = - _S2982.rows[int(1)].x; - if(antialiased_11) - { - eps2d_11 = _S2920 * _S2992; - } - else - { - eps2d_11 = _S2920; - } - float _S2995 = eps2d_11 / 0.00392156885936856f; - float _S2996 = 2.0f * s_primal_ctx_log_0(_S2995); - float _S2997 = s_primal_ctx_sqrt_0(_S2996); - float _S2998 = _S2987.rows[int(0)].x; - float _S2999 = _S2988.rows[int(1)].y; - float3 campos_4 = - s_primal_ctx_mul_0(_S2930, t_11); - float3 _S3000 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3001; - (&_S3001)->primal_0 = mean_12; - (&_S3001)->differential_0 = _S3000; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3002; - (&_S3002)->primal_0 = scale_11; - (&_S3002)->differential_0 = _S3000; - DiffPair_float_0 _S3003; - (&_S3003)->primal_0 = in_opacity_11; - (&_S3003)->differential_0 = 0.0f; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3004; - (&_S3004)->primal_0 = campos_4; - (&_S3004)->differential_0 = _S3000; - s_bwd_prop_view_radius_3dgs_0(&_S3001, &_S3002, &_S3003, &_S3004, 0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3005 = _S3001; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3006 = _S3002; - DiffPair_float_0 _S3007 = _S3003; - float2 _S3008 = make_float2 (0.0f); - float2 _S3009 = _S3008; - *&((&_S3009)->y) = v_conic_3.z; - float2 _S3010 = _S3008; - *&((&_S3010)->y) = v_conic_3.y; - *&((&_S3010)->x) = v_conic_3.x; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3011; - (&_S3011)->primal_0 = mean_c_11; - (&_S3011)->differential_0 = _S3000; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3012; - (&_S3012)->primal_0 = mean_c_11; - (&_S3012)->differential_0 = _S3000; - s_bwd_prop_dot_0(&_S3011, &_S3012, 0.0f); - DiffPair_float_0 _S3013; - (&_S3013)->primal_0 = _S2999; - (&_S3013)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3013, 0.0f); - DiffPair_float_0 _S3014; - (&_S3014)->primal_0 = _S2998; - (&_S3014)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3014, 0.0f); - DiffPair_float_0 _S3015; - (&_S3015)->primal_0 = 3.32999992370605469f; - (&_S3015)->differential_0 = 0.0f; - DiffPair_float_0 _S3016; - (&_S3016)->primal_0 = _S2997; - (&_S3016)->differential_0 = 0.0f; - _d_min_0(&_S3015, &_S3016, 0.0f); - DiffPair_float_0 _S3017; - (&_S3017)->primal_0 = _S2996; - (&_S3017)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3017, _S3016.differential_0); - float _S3018 = 2.0f * _S3017.differential_0; - DiffPair_float_0 _S3019; - (&_S3019)->primal_0 = _S2995; - (&_S3019)->differential_0 = 0.0f; - s_bwd_prop_log_0(&_S3019, _S3018); - float _S3020 = v_opacity_3 + 254.9999847412109375f * _S3019.differential_0; - float2 _S3021 = make_float2 (_S3014.differential_0, 0.0f); - Matrix _S3022 = makeMatrix (0.0f); - Matrix _S3023 = _S3022; - _S3023[int(1)] = _S3009; - _S3023[int(0)] = _S3010; - Matrix _S3024 = _S3023; - float3 _S3025 = _S3012.differential_0 + _S3011.differential_0; - float2 _S3026 = make_float2 (0.0f, _S3013.differential_0); - float _S3027; - if(antialiased_11) - { - float _S3028 = _S2992 * _S3020; - eps2d_11 = _S2920 * _S3020; - _S3027 = _S3028; - } - else - { - eps2d_11 = 0.0f; - _S3027 = _S3020; - } - float _S3029 = invdet_13 * _S3024.rows[int(1)].y; - float _S3030 = - (invdet_13 * _S3024.rows[int(1)].x); - float _S3031 = - (invdet_13 * _S3024.rows[int(0)].y); - float _S3032 = invdet_13 * _S3024.rows[int(0)].x; - float _S3033 = - ((_S2984 * _S3024.rows[int(1)].y + _S2994 * _S3024.rows[int(1)].x + _S2993 * _S3024.rows[int(0)].y + _S2986 * _S3024.rows[int(0)].x) / _S2990); - DiffPair_float_0 _S3034; - (&_S3034)->primal_0 = _S2991; - (&_S3034)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3034, eps2d_11); - DiffPair_float_0 _S3035 = { 0.0f, 0.0f }; - DiffPair_float_0 _S3036; - (&_S3036)->primal_0 = 0.0f; - (&_S3036)->differential_0 = 0.0f; - DiffPair_float_0 _S3037; - (&_S3037)->primal_0 = _S2989; - (&_S3037)->differential_0 = 0.0f; - _d_max_0(&_S3036, &_S3037, _S3034.differential_0); - float _S3038 = _S3037.differential_0 / _S2990; - float s_diff_det_orig_T_3 = det_blur_11 * _S3038; - float _S3039 = det_orig_11 * - _S3038 + _S3033; - float _S3040 = - _S3039; - float _S3041 = _S2984 * _S3039; - float _S3042 = _S2986 * _S3039; - Matrix _S3043 = _S3022; - _S3043[int(1)] = _S3026; - _S3043[int(0)] = _S3021; - _S2985 = _S3043; - *&(((&_S2985)->rows + (int(1)))->y) = 0.0f; - float _S3044 = _S3041 + _S3043.rows[int(1)].y + _S3032; - *&(((&_S2985)->rows + (int(0)))->x) = 0.0f; - float _S3045 = _S3042 + _S3043.rows[int(0)].x + _S3029; - float _S3046 = _S3040 + - s_diff_det_orig_T_3; - float _S3047 = _S2982.rows[int(0)].y * _S3046 + _S3030; - float _S3048 = _S2982.rows[int(1)].x * _S3046 + _S3031; - float _S3049 = _S2982.rows[int(1)].y * s_diff_det_orig_T_3; - float _S3050 = _S3044 + _S2982.rows[int(0)].x * s_diff_det_orig_T_3; - float2 _S3051 = _S3008; - *&((&_S3051)->x) = _S3047; - *&((&_S3051)->y) = _S3050; - float _S3052 = _S3045 + _S3049; - float2 _S3053 = _S3008; - *&((&_S3053)->y) = _S3048; - *&((&_S3053)->x) = _S3052; - Matrix _S3054 = _S3022; - _S3054[int(1)] = _S3051; - _S3054[int(0)] = _S3053; - Matrix _S3055 = _S2985 + _S3054; - DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S3056; - (&_S3056)->primal_0 = _S2980; - (&_S3056)->differential_0 = J_13; - Matrix _S3057 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S3058; - (&_S3058)->primal_0 = _S2981; - (&_S3058)->differential_0 = _S3057; - s_bwd_prop_mul_0(&_S3056, &_S3058, _S3055); - Matrix _S3059 = transpose_2(_S3058.differential_0); - DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S3060; - (&_S3060)->primal_0 = _S2952; - (&_S3060)->differential_0 = J_13; - Matrix _S3061 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3062; - (&_S3062)->primal_0 = _S2931; - (&_S3062)->differential_0 = _S3061; - s_bwd_prop_mul_1(&_S3060, &_S3062, _S3056.differential_0); - Matrix _S3063 = _S3059 + _S3060.differential_0; - float2 _S3064 = make_float2 (0.0f, _S3063.rows[int(1)].z) + make_float2 (_S3063.rows[int(0)].z, 0.0f); - float _S3065 = fy_15 * _S3064.y; - float _S3066 = fx_15 * _S3064.x; - DiffPair_0 _S3067; - (&_S3067)->primal_0 = _S2945; - (&_S3067)->differential_0 = _S3035; - DiffPair_0 _S3068; - (&_S3068)->primal_0 = _S2975; - (&_S3068)->differential_0 = _S3035; - DiffPair_float_0 _S3069; - (&_S3069)->primal_0 = 0.0f; - (&_S3069)->differential_0 = _S3065; - s_bwd_prop_d_atan2_0(&_S3067, &_S3068, &_S3069); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S3070 = { _S3008, _S3008 }; - DiffPair_1 _S3071; - (&_S3071)->primal_0 = _S2972; - (&_S3071)->differential_0 = _S3070; - DiffPair_float_0 _S3072; - (&_S3072)->primal_0 = _S3068.differential_0.primal_0; - (&_S3072)->differential_0 = _S3068.differential_0.differential_0; - s_bwd_prop_s_fwd_length_impl_0(&_S3071, &_S3072); - DiffPair_0 _S3073; - (&_S3073)->primal_0 = _S2953; - (&_S3073)->differential_0 = _S3035; - DiffPair_0 _S3074; - (&_S3074)->primal_0 = _S2967; - (&_S3074)->differential_0 = _S3035; - DiffPair_float_0 _S3075; - (&_S3075)->primal_0 = 0.0f; - (&_S3075)->differential_0 = _S3066; - s_bwd_prop_d_atan2_0(&_S3073, &_S3074, &_S3075); - float3 _S3076 = make_float3 (_S3071.differential_0.primal_0.x + _S3073.differential_0.primal_0, _S3067.differential_0.primal_0, _S3071.differential_0.primal_0.y + _S3074.differential_0.primal_0); - float2 _S3077 = make_float2 (0.0f, _S3063.rows[int(1)].y) + make_float2 (_S3063.rows[int(0)].y, 0.0f); - float _S3078 = fy_15 * _S3077.y; - float _S3079 = fx_15 * _S3077.x; - DiffPair_0 _S3080; - (&_S3080)->primal_0 = _S2961; - (&_S3080)->differential_0 = _S3035; - DiffPair_0 _S3081; - (&_S3081)->primal_0 = _S2962; - (&_S3081)->differential_0 = _S3035; - DiffPair_float_0 _S3082; - (&_S3082)->primal_0 = 0.0f; - (&_S3082)->differential_0 = _S3078; - s_bwd_prop_d_atan2_0(&_S3080, &_S3081, &_S3082); - DiffPair_1 _S3083; - (&_S3083)->primal_0 = _S2958; - (&_S3083)->differential_0 = _S3070; - DiffPair_float_0 _S3084; - (&_S3084)->primal_0 = _S3081.differential_0.primal_0; - (&_S3084)->differential_0 = _S3081.differential_0.differential_0; - s_bwd_prop_s_fwd_length_impl_0(&_S3083, &_S3084); - DiffPair_0 _S3085; - (&_S3085)->primal_0 = _S2953; - (&_S3085)->differential_0 = _S3035; - DiffPair_0 _S3086; - (&_S3086)->primal_0 = _S2935; - (&_S3086)->differential_0 = _S3035; - DiffPair_float_0 _S3087; - (&_S3087)->primal_0 = 0.0f; - (&_S3087)->differential_0 = _S3079; - s_bwd_prop_d_atan2_0(&_S3085, &_S3086, &_S3087); - float3 _S3088 = make_float3 (_S3083.differential_0.primal_0.x + _S3085.differential_0.primal_0, _S3080.differential_0.primal_0, _S3083.differential_0.primal_0.y + _S3086.differential_0.primal_0); - float2 _S3089 = make_float2 (0.0f, _S3063.rows[int(1)].x) + make_float2 (_S3063.rows[int(0)].x, 0.0f); - float _S3090 = fy_15 * _S3089.y; - float _S3091 = fx_15 * _S3089.x; - DiffPair_0 _S3092; - (&_S3092)->primal_0 = _S2945; - (&_S3092)->differential_0 = _S3035; - DiffPair_0 _S3093; - (&_S3093)->primal_0 = _S2946; - (&_S3093)->differential_0 = _S3035; - DiffPair_float_0 _S3094; - (&_S3094)->primal_0 = 0.0f; - (&_S3094)->differential_0 = _S3090; - s_bwd_prop_d_atan2_0(&_S3092, &_S3093, &_S3094); - DiffPair_1 _S3095; - (&_S3095)->primal_0 = _S2942; - (&_S3095)->differential_0 = _S3070; - DiffPair_float_0 _S3096; - (&_S3096)->primal_0 = _S3093.differential_0.primal_0; - (&_S3096)->differential_0 = _S3093.differential_0.differential_0; - s_bwd_prop_s_fwd_length_impl_0(&_S3095, &_S3096); - DiffPair_0 _S3097; - (&_S3097)->primal_0 = _S2934; - (&_S3097)->differential_0 = _S3035; - DiffPair_0 _S3098; - (&_S3098)->primal_0 = _S2935; - (&_S3098)->differential_0 = _S3035; - DiffPair_float_0 _S3099; - (&_S3099)->primal_0 = 0.0f; - (&_S3099)->differential_0 = _S3091; - s_bwd_prop_d_atan2_0(&_S3097, &_S3098, &_S3099); - float3 _S3100 = make_float3 (_S3095.differential_0.primal_0.x + _S3097.differential_0.primal_0, _S3092.differential_0.primal_0, _S3095.differential_0.primal_0.y + _S3098.differential_0.primal_0); - float _S3101 = length_0(_S2940); - float _S3102 = fy_15 * v_mean2d_3.y; - float _S3103 = fx_15 * v_mean2d_3.x; - DiffPair_float_0 _S3104; - (&_S3104)->primal_0 = _S2939; - (&_S3104)->differential_0 = 0.0f; - DiffPair_float_0 _S3105; - (&_S3105)->primal_0 = _S3101; - (&_S3105)->differential_0 = 0.0f; - s_bwd_prop_atan2_0(&_S3104, &_S3105, _S3102); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S3106; - (&_S3106)->primal_0 = _S2940; - (&_S3106)->differential_0 = _S3008; - s_bwd_length_impl_2(&_S3106, _S3105.differential_0); - DiffPair_float_0 _S3107; - (&_S3107)->primal_0 = _S2932; - (&_S3107)->differential_0 = 0.0f; - DiffPair_float_0 _S3108; - (&_S3108)->primal_0 = _S2933; - (&_S3108)->differential_0 = 0.0f; - s_bwd_prop_atan2_0(&_S3107, &_S3108, _S3103); - float3 _S3109 = make_float3 (_S3106.differential_0.x + _S3107.differential_0, _S3104.differential_0, _S3106.differential_0.y + _S3108.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3110; - (&_S3110)->primal_0 = _S2929; - (&_S3110)->differential_0 = _S3061; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3111; - (&_S3111)->primal_0 = _S2930; - (&_S3111)->differential_0 = _S3061; - s_bwd_prop_mul_2(&_S3110, &_S3111, _S3062.differential_0); - Matrix _S3112 = transpose_3(_S3111.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3113; - (&_S3113)->primal_0 = R_11; - (&_S3113)->differential_0 = _S3061; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3114; - (&_S3114)->primal_0 = _S2928; - (&_S3114)->differential_0 = _S3061; - s_bwd_prop_mul_2(&_S3113, &_S3114, _S3110.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3115; - (&_S3115)->primal_0 = _S2926; - (&_S3115)->differential_0 = _S3061; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3116; - (&_S3116)->primal_0 = _S2927; - (&_S3116)->differential_0 = _S3061; - s_bwd_prop_mul_2(&_S3115, &_S3116, _S3114.differential_0); - Matrix _S3117 = _S3115.differential_0 + transpose_3(_S3116.differential_0); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3118; - (&_S3118)->primal_0 = _S2925; - (&_S3118)->differential_0 = _S3061; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3119; - (&_S3119)->primal_0 = S_3; - (&_S3119)->differential_0 = _S3061; - s_bwd_prop_mul_2(&_S3118, &_S3119, _S3117); - Matrix _S3120 = transpose_3(_S3118.differential_0); - float _S3121 = 2.0f * - _S3120.rows[int(2)].z; - float _S3122 = 2.0f * _S3120.rows[int(2)].y; - float _S3123 = 2.0f * _S3120.rows[int(2)].x; - float _S3124 = 2.0f * _S3120.rows[int(1)].z; - float _S3125 = 2.0f * - _S3120.rows[int(1)].y; - float _S3126 = 2.0f * _S3120.rows[int(1)].x; - float _S3127 = 2.0f * _S3120.rows[int(0)].z; - float _S3128 = 2.0f * _S3120.rows[int(0)].y; - float _S3129 = 2.0f * - _S3120.rows[int(0)].x; - float _S3130 = - _S3126 + _S3128; - float _S3131 = _S3123 + - _S3127; - float _S3132 = - _S3122 + _S3124; - float _S3133 = _S3122 + _S3124; - float _S3134 = _S3123 + _S3127; - float _S3135 = _S3126 + _S3128; - float _S3136 = _S2922.w * (_S3125 + _S3129); - float _S3137 = _S2922.z * (_S3121 + _S3129); - float _S3138 = _S2922.y * (_S3121 + _S3125); - float _S3139 = _S2922.x * _S3130 + _S2922.z * _S3133 + _S2922.y * _S3134 + _S3136 + _S3136; - float _S3140 = _S2922.x * _S3131 + _S2922.w * _S3133 + _S2922.y * _S3135 + _S3137 + _S3137; - float _S3141 = _S2922.x * _S3132 + _S2922.w * _S3134 + _S2922.z * _S3135 + _S3138 + _S3138; - float _S3142 = _S2922.w * _S3130 + _S2922.z * _S3131 + _S2922.y * _S3132; - float3 _S3143 = _S3000; - *&((&_S3143)->z) = _S3119.differential_0.rows[int(2)].z; - *&((&_S3143)->y) = _S3119.differential_0.rows[int(1)].y; - *&((&_S3143)->x) = _S3119.differential_0.rows[int(0)].x; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3144; - (&_S3144)->primal_0 = scale_11; - (&_S3144)->differential_0 = _S3000; - s_bwd_prop_exp_1(&_S3144, _S3143); - float4 _S3145 = make_float4 (0.0f); - float4 _S3146 = _S3145; - *&((&_S3146)->w) = _S3139; - *&((&_S3146)->z) = _S3140; - *&((&_S3146)->y) = _S3141; - *&((&_S3146)->x) = _S3142; - DiffPair_vectorx3Cfloatx2C4x3E_0 _S3147; - (&_S3147)->primal_0 = quat_11; - (&_S3147)->differential_0 = _S3145; - s_bwd_normalize_impl_0(&_S3147, _S3146); - float _S3148 = - (_S3027 / _S2921); - DiffPair_float_0 _S3149; - (&_S3149)->primal_0 = _S2918; - (&_S3149)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S3149, _S3148); - float _S3150 = - _S3149.differential_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3151; - (&_S3151)->primal_0 = mean_c_11; - (&_S3151)->differential_0 = _S3000; - s_bwd_length_impl_0(&_S3151, v_depth_3); - float3 _S3152 = _S3076 + _S3088 + _S3100 + _S3109 + _S3151.differential_0 + _S3025; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3153; - (&_S3153)->primal_0 = R_11; - (&_S3153)->differential_0 = _S3061; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3154; - (&_S3154)->primal_0 = mean_12; - (&_S3154)->differential_0 = _S3000; - s_bwd_prop_mul_3(&_S3153, &_S3154, _S3152); - Matrix _S3155 = _S3112 + _S3113.differential_0 + _S3153.differential_0; - float _S3156 = _S3150 + _S3007.differential_0; - float3 _S3157 = _S3144.differential_0 + _S3006.differential_0; - *v_mean_3 = *v_mean_3 + (_S3154.differential_0 + _S3005.differential_0); - *v_quat_3 = *v_quat_3 + _S3147.differential_0; - *v_scale_3 = *v_scale_3 + _S3157; - *v_in_opacity_3 = *v_in_opacity_3 + _S3156; - *v_R_3 = *v_R_3 + _S3155; - *v_t_3 = *v_t_3 + _S3152; - return; -} - -struct s_bwd_prop_DiffProjection3DGS_3dgut_persp_projection_Intermediates_0 -{ - float2 _S3158; - float2 _S3159; - float2 _S3160; - float2 _S3161; - float2 _S3162; - float2 _S3163; - float2 _S3164; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6211; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6212; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6213; }; -inline __device__ void projection_3dgut_persp_vjp(bool antialiased_12, float3 mean_13, float4 quat_12, float3 scale_12, float in_opacity_12, Matrix R_12, float3 t_12, float fx_16, float fy_16, float cx_13, float cy_13, FixedArray dist_coeffs_16, uint image_width_12, uint image_height_12, float2 v_mean2d_4, float v_depth_4, float3 v_conic_4, float v_opacity_4, float3 * v_mean_4, float4 * v_quat_4, float3 * v_scale_4, float * v_in_opacity_4, Matrix * v_R_4, float3 * v_t_4) +inline __device__ void projection_3dgs_equisolid_opencv_vjp(bool antialiased_30, float3 mean_31, float4 quat_30, float3 scale_30, float in_opacity_30, Matrix R_30, float3 t_30, float fx_43, float fy_43, float cx_34, float cy_34, FixedArray dist_coeffs_42, uint image_width_30, uint image_height_30, float2 v_mean2d_8, float v_depth_8, float3 v_conic_8, float v_opacity_8, float3 * v_mean_8, float4 * v_quat_8, float3 * v_scale_8, float * v_in_opacity_8, Matrix * v_R_8, float3 * v_t_8) { - float2 _S3165 = make_float2 (0.0f); - s_bwd_prop_DiffProjection3DGS_3dgut_persp_projection_Intermediates_0 _S3166; - (&_S3166)->_S3158 = _S3165; - (&_S3166)->_S3159 = _S3165; - (&_S3166)->_S3160 = _S3165; - (&_S3166)->_S3161 = _S3165; - (&_S3166)->_S3162 = _S3165; - (&_S3166)->_S3163 = _S3165; - (&_S3166)->_S3164 = _S3165; - float3 _S3167 = make_float3 (0.0f); - float3 _S3168 = s_primal_ctx_exp_1(scale_12); - float4 _S3169 = normalize_0(quat_12); - float _S3170 = _S3169.y; - float x2_12 = _S3170 * _S3170; - float y2_12 = _S3169.z * _S3169.z; - float z2_12 = _S3169.w * _S3169.w; - float xy_12 = _S3169.y * _S3169.z; - float xz_12 = _S3169.y * _S3169.w; - float yz_12 = _S3169.z * _S3169.w; - float wx_12 = _S3169.x * _S3169.y; - float wy_12 = _S3169.x * _S3169.z; - float wz_12 = _S3169.x * _S3169.w; - Matrix _S3171 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_12 + z2_12), 2.0f * (xy_12 + wz_12), 2.0f * (xz_12 - wy_12), 2.0f * (xy_12 - wz_12), 1.0f - 2.0f * (x2_12 + z2_12), 2.0f * (yz_12 + wx_12), 2.0f * (xz_12 + wy_12), 2.0f * (yz_12 - wx_12), 1.0f - 2.0f * (x2_12 + y2_12)))); - FixedArray _S3172 = { - _S3167, _S3167, _S3167, _S3167, _S3167, _S3167, _S3167 - }; - FixedArray _S3173 = { - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f - }; - SigmaPoints_0 _S3174; - (&_S3174)->p_0 = _S3172; - (&_S3174)->w_mean_0 = _S3173; - (&_S3174)->w_cov_0 = _S3173; - (&_S3174)->p_0[int(0)] = mean_13; - SigmaPoints_0 _S3175 = _S3174; - (&_S3175)->w_mean_0[int(0)] = 0.0f; - (&_S3175)->w_cov_0[int(0)] = 2.0f; - float _S3176 = s_primal_ctx_sqrt_0(3.0f); - float _S3177 = _S3176 * _S3168.x; - float3 delta_12 = make_float3 (_S3177) * _S3171.rows[0U]; - float3 _S3178 = mean_13 + delta_12; - (&_S3175)->p_0[1U] = _S3178; - float3 _S3179 = mean_13 - delta_12; - (&_S3175)->p_0[4U] = _S3179; - float _S3180 = _S3176 * _S3168.y; - float3 delta_13 = make_float3 (_S3180) * _S3171.rows[1U]; - float3 _S3181 = mean_13 + delta_13; - (&_S3175)->p_0[2U] = _S3181; - float3 _S3182 = mean_13 - delta_13; - (&_S3175)->p_0[5U] = _S3182; - float _S3183 = _S3176 * _S3168.z; - float3 delta_14 = make_float3 (_S3183) * _S3171.rows[2U]; - float3 _S3184 = mean_13 + delta_14; - (&_S3175)->p_0[3U] = _S3184; - float3 _S3185 = mean_13 - delta_14; - (&_S3175)->p_0[6U] = _S3185; - (&_S3175)->w_mean_0[1U] = 0.1666666716337204f; - SigmaPoints_0 _S3186 = _S3175; - (&_S3186)->w_cov_0[1U] = 0.1666666716337204f; - SigmaPoints_0 _S3187 = _S3186; - (&_S3187)->w_mean_0[2U] = 0.1666666716337204f; - SigmaPoints_0 _S3188 = _S3187; - (&_S3188)->w_cov_0[2U] = 0.1666666716337204f; - SigmaPoints_0 _S3189 = _S3188; - (&_S3189)->w_mean_0[3U] = 0.1666666716337204f; - SigmaPoints_0 _S3190 = _S3189; - (&_S3190)->w_cov_0[3U] = 0.1666666716337204f; - SigmaPoints_0 _S3191 = _S3190; - (&_S3191)->w_mean_0[4U] = 0.1666666716337204f; - SigmaPoints_0 _S3192 = _S3191; - (&_S3192)->w_cov_0[4U] = 0.1666666716337204f; - SigmaPoints_0 _S3193 = _S3192; - (&_S3193)->w_mean_0[5U] = 0.1666666716337204f; - SigmaPoints_0 _S3194 = _S3193; - (&_S3194)->w_cov_0[5U] = 0.1666666716337204f; - SigmaPoints_0 _S3195 = _S3194; - (&_S3195)->w_mean_0[6U] = 0.1666666716337204f; - SigmaPoints_0 _S3196 = _S3195; - (&_S3196)->w_cov_0[6U] = 0.1666666716337204f; - SigmaPoints_0 _S3197 = _S3174; - float3 _S3198 = s_primal_ctx_mul_0(R_12, _S3174.p_0[0U]) + t_12; - _S3174 = _S3196; - (&_S3174)->p_0[0U] = _S3198; - SigmaPoints_0 _S3199 = _S3174; - (&_S3174)->p_0[1U] = s_primal_ctx_mul_0(R_12, _S3178) + t_12; - SigmaPoints_0 _S3200 = _S3174; - (&_S3174)->p_0[2U] = s_primal_ctx_mul_0(R_12, _S3181) + t_12; - SigmaPoints_0 _S3201 = _S3174; - (&_S3174)->p_0[3U] = s_primal_ctx_mul_0(R_12, _S3184) + t_12; - SigmaPoints_0 _S3202 = _S3174; - (&_S3174)->p_0[4U] = s_primal_ctx_mul_0(R_12, _S3179) + t_12; - SigmaPoints_0 _S3203 = _S3174; - (&_S3174)->p_0[5U] = s_primal_ctx_mul_0(R_12, _S3182) + t_12; - SigmaPoints_0 _S3204 = _S3174; - (&_S3174)->p_0[6U] = s_primal_ctx_mul_0(R_12, _S3185) + t_12; - float2 _S3205 = float2 {_S3199.p_0[int(0)].x, _S3199.p_0[int(0)].y} / make_float2 (_S3199.p_0[int(0)].z); - float u_84 = _S3205.x; - float v_84 = _S3205.y; - float r2_84 = u_84 * u_84 + v_84 * v_84; - float _S3206 = 2.0f * dist_coeffs_16[int(4)]; - float _S3207 = 2.0f * dist_coeffs_16[int(5)]; - float2 _S3208 = _S3205 * make_float2 (1.0f + r2_84 * (dist_coeffs_16[int(0)] + r2_84 * (dist_coeffs_16[int(1)] + r2_84 * (dist_coeffs_16[int(2)] + r2_84 * dist_coeffs_16[int(3)])))) + make_float2 (_S3206 * u_84 * v_84 + dist_coeffs_16[int(5)] * (r2_84 + 2.0f * u_84 * u_84) + dist_coeffs_16[int(6)] * r2_84, _S3207 * u_84 * v_84 + dist_coeffs_16[int(4)] * (r2_84 + 2.0f * v_84 * v_84) + dist_coeffs_16[int(7)] * r2_84); - float2 _S3209 = _S3208 + make_float2 (dist_coeffs_16[int(8)] * _S3208.x + dist_coeffs_16[int(9)] * _S3208.y, 0.0f); - (&_S3166)->_S3158 = make_float2 (fx_16 * _S3209.x + cx_13, fy_16 * _S3209.y + cy_13); - float2 _S3210 = float2 {_S3200.p_0[int(1)].x, _S3200.p_0[int(1)].y} / make_float2 (_S3200.p_0[int(1)].z); - float u_85 = _S3210.x; - float v_85 = _S3210.y; - float r2_85 = u_85 * u_85 + v_85 * v_85; - float2 _S3211 = _S3210 * make_float2 (1.0f + r2_85 * (dist_coeffs_16[int(0)] + r2_85 * (dist_coeffs_16[int(1)] + r2_85 * (dist_coeffs_16[int(2)] + r2_85 * dist_coeffs_16[int(3)])))) + make_float2 (_S3206 * u_85 * v_85 + dist_coeffs_16[int(5)] * (r2_85 + 2.0f * u_85 * u_85) + dist_coeffs_16[int(6)] * r2_85, _S3207 * u_85 * v_85 + dist_coeffs_16[int(4)] * (r2_85 + 2.0f * v_85 * v_85) + dist_coeffs_16[int(7)] * r2_85); - float2 _S3212 = _S3211 + make_float2 (dist_coeffs_16[int(8)] * _S3211.x + dist_coeffs_16[int(9)] * _S3211.y, 0.0f); - (&_S3166)->_S3159 = make_float2 (fx_16 * _S3212.x + cx_13, fy_16 * _S3212.y + cy_13); - float2 _S3213 = float2 {_S3201.p_0[int(2)].x, _S3201.p_0[int(2)].y} / make_float2 (_S3201.p_0[int(2)].z); - float u_86 = _S3213.x; - float v_86 = _S3213.y; - float r2_86 = u_86 * u_86 + v_86 * v_86; - float2 _S3214 = _S3213 * make_float2 (1.0f + r2_86 * (dist_coeffs_16[int(0)] + r2_86 * (dist_coeffs_16[int(1)] + r2_86 * (dist_coeffs_16[int(2)] + r2_86 * dist_coeffs_16[int(3)])))) + make_float2 (_S3206 * u_86 * v_86 + dist_coeffs_16[int(5)] * (r2_86 + 2.0f * u_86 * u_86) + dist_coeffs_16[int(6)] * r2_86, _S3207 * u_86 * v_86 + dist_coeffs_16[int(4)] * (r2_86 + 2.0f * v_86 * v_86) + dist_coeffs_16[int(7)] * r2_86); - float2 _S3215 = _S3214 + make_float2 (dist_coeffs_16[int(8)] * _S3214.x + dist_coeffs_16[int(9)] * _S3214.y, 0.0f); - (&_S3166)->_S3160 = make_float2 (fx_16 * _S3215.x + cx_13, fy_16 * _S3215.y + cy_13); - float2 _S3216 = float2 {_S3202.p_0[int(3)].x, _S3202.p_0[int(3)].y} / make_float2 (_S3202.p_0[int(3)].z); - float u_87 = _S3216.x; - float v_87 = _S3216.y; - float r2_87 = u_87 * u_87 + v_87 * v_87; - float2 _S3217 = _S3216 * make_float2 (1.0f + r2_87 * (dist_coeffs_16[int(0)] + r2_87 * (dist_coeffs_16[int(1)] + r2_87 * (dist_coeffs_16[int(2)] + r2_87 * dist_coeffs_16[int(3)])))) + make_float2 (_S3206 * u_87 * v_87 + dist_coeffs_16[int(5)] * (r2_87 + 2.0f * u_87 * u_87) + dist_coeffs_16[int(6)] * r2_87, _S3207 * u_87 * v_87 + dist_coeffs_16[int(4)] * (r2_87 + 2.0f * v_87 * v_87) + dist_coeffs_16[int(7)] * r2_87); - float2 _S3218 = _S3217 + make_float2 (dist_coeffs_16[int(8)] * _S3217.x + dist_coeffs_16[int(9)] * _S3217.y, 0.0f); - (&_S3166)->_S3161 = make_float2 (fx_16 * _S3218.x + cx_13, fy_16 * _S3218.y + cy_13); - float2 _S3219 = float2 {_S3203.p_0[int(4)].x, _S3203.p_0[int(4)].y} / make_float2 (_S3203.p_0[int(4)].z); - float u_88 = _S3219.x; - float v_88 = _S3219.y; - float r2_88 = u_88 * u_88 + v_88 * v_88; - float2 _S3220 = _S3219 * make_float2 (1.0f + r2_88 * (dist_coeffs_16[int(0)] + r2_88 * (dist_coeffs_16[int(1)] + r2_88 * (dist_coeffs_16[int(2)] + r2_88 * dist_coeffs_16[int(3)])))) + make_float2 (_S3206 * u_88 * v_88 + dist_coeffs_16[int(5)] * (r2_88 + 2.0f * u_88 * u_88) + dist_coeffs_16[int(6)] * r2_88, _S3207 * u_88 * v_88 + dist_coeffs_16[int(4)] * (r2_88 + 2.0f * v_88 * v_88) + dist_coeffs_16[int(7)] * r2_88); - float2 _S3221 = _S3220 + make_float2 (dist_coeffs_16[int(8)] * _S3220.x + dist_coeffs_16[int(9)] * _S3220.y, 0.0f); - (&_S3166)->_S3162 = make_float2 (fx_16 * _S3221.x + cx_13, fy_16 * _S3221.y + cy_13); - float2 _S3222 = float2 {_S3204.p_0[int(5)].x, _S3204.p_0[int(5)].y} / make_float2 (_S3204.p_0[int(5)].z); - float u_89 = _S3222.x; - float v_89 = _S3222.y; - float r2_89 = u_89 * u_89 + v_89 * v_89; - float2 _S3223 = _S3222 * make_float2 (1.0f + r2_89 * (dist_coeffs_16[int(0)] + r2_89 * (dist_coeffs_16[int(1)] + r2_89 * (dist_coeffs_16[int(2)] + r2_89 * dist_coeffs_16[int(3)])))) + make_float2 (_S3206 * u_89 * v_89 + dist_coeffs_16[int(5)] * (r2_89 + 2.0f * u_89 * u_89) + dist_coeffs_16[int(6)] * r2_89, _S3207 * u_89 * v_89 + dist_coeffs_16[int(4)] * (r2_89 + 2.0f * v_89 * v_89) + dist_coeffs_16[int(7)] * r2_89); - float2 _S3224 = _S3223 + make_float2 (dist_coeffs_16[int(8)] * _S3223.x + dist_coeffs_16[int(9)] * _S3223.y, 0.0f); - (&_S3166)->_S3163 = make_float2 (fx_16 * _S3224.x + cx_13, fy_16 * _S3224.y + cy_13); - float2 _S3225 = float2 {_S3174.p_0[int(6)].x, _S3174.p_0[int(6)].y} / make_float2 (_S3174.p_0[int(6)].z); - float u_90 = _S3225.x; - float v_90 = _S3225.y; - float r2_90 = u_90 * u_90 + v_90 * v_90; - float2 _S3226 = _S3225 * make_float2 (1.0f + r2_90 * (dist_coeffs_16[int(0)] + r2_90 * (dist_coeffs_16[int(1)] + r2_90 * (dist_coeffs_16[int(2)] + r2_90 * dist_coeffs_16[int(3)])))) + make_float2 (_S3206 * u_90 * v_90 + dist_coeffs_16[int(5)] * (r2_90 + 2.0f * u_90 * u_90) + dist_coeffs_16[int(6)] * r2_90, _S3207 * u_90 * v_90 + dist_coeffs_16[int(4)] * (r2_90 + 2.0f * v_90 * v_90) + dist_coeffs_16[int(7)] * r2_90); - float2 _S3227 = _S3226 + make_float2 (dist_coeffs_16[int(8)] * _S3226.x + dist_coeffs_16[int(9)] * _S3226.y, 0.0f); - (&_S3166)->_S3164 = make_float2 (fx_16 * _S3227.x + cx_13, fy_16 * _S3227.y + cy_13); - float3 mean_c_12 = s_primal_ctx_mul_0(R_12, mean_13) + t_12; - float _S3228 = - in_opacity_12; - float _S3229 = 1.0f + s_primal_ctx_exp_0(_S3228); - float _S3230 = 1.0f / _S3229; - float _S3231 = _S3229 * _S3229; - float3 _S3232 = make_float3 (_S3177); - float3 _S3233 = make_float3 (_S3180); - float3 _S3234 = make_float3 (_S3183); - float _S3235 = float(image_width_12); - float _S3236 = float(image_height_12); - float _S3237 = 0.30000001192092896f * (0.5f * _S3235 / fx_16) * fx_16; - float lim_x_pos_4 = _S3235 + _S3237; - float _S3238 = 0.30000001192092896f * (0.5f * _S3236 / fy_16) * fy_16; - float lim_y_pos_1 = _S3236 + _S3238; - float2 _S3239 = make_float2 (_S3175.w_mean_0[int(1)]) * _S3166._S3159 + make_float2 (_S3187.w_mean_0[int(2)]) * _S3166._S3160 + make_float2 (_S3189.w_mean_0[int(3)]) * _S3166._S3161 + make_float2 (_S3191.w_mean_0[int(4)]) * _S3166._S3162 + make_float2 (_S3193.w_mean_0[int(5)]) * _S3166._S3163 + make_float2 (_S3195.w_mean_0[int(6)]) * _S3166._S3164; - float _S3240 = - _S3237; - float _S3241 = - _S3238; - float2 _S3242 = make_float2 (s_primal_ctx_clamp_0(_S3239.x, _S3240, lim_x_pos_4), s_primal_ctx_clamp_0(_S3239.y, _S3241, lim_y_pos_1)); - float2 d_28 = make_float2 (s_primal_ctx_clamp_0(_S3166._S3158.x, _S3240, lim_x_pos_4), s_primal_ctx_clamp_0(_S3166._S3158.y, _S3241, lim_y_pos_1)) - _S3242; - float _S3243 = d_28.x; - float _S3244 = d_28.y; - float _S3245 = _S3243 * _S3244; - float2 d_29 = make_float2 (s_primal_ctx_clamp_0(_S3166._S3159.x, _S3240, lim_x_pos_4), s_primal_ctx_clamp_0(_S3166._S3159.y, _S3241, lim_y_pos_1)) - _S3242; - float _S3246 = d_29.x; - float _S3247 = d_29.y; - float _S3248 = _S3246 * _S3247; - float2 d_30 = make_float2 (s_primal_ctx_clamp_0(_S3166._S3160.x, _S3240, lim_x_pos_4), s_primal_ctx_clamp_0(_S3166._S3160.y, _S3241, lim_y_pos_1)) - _S3242; - float _S3249 = d_30.x; - float _S3250 = d_30.y; - float _S3251 = _S3249 * _S3250; - float2 d_31 = make_float2 (s_primal_ctx_clamp_0(_S3166._S3161.x, _S3240, lim_x_pos_4), s_primal_ctx_clamp_0(_S3166._S3161.y, _S3241, lim_y_pos_1)) - _S3242; - float _S3252 = d_31.x; - float _S3253 = d_31.y; - float _S3254 = _S3252 * _S3253; - float2 d_32 = make_float2 (s_primal_ctx_clamp_0(_S3166._S3162.x, _S3240, lim_x_pos_4), s_primal_ctx_clamp_0(_S3166._S3162.y, _S3241, lim_y_pos_1)) - _S3242; - float _S3255 = d_32.x; - float _S3256 = d_32.y; - float _S3257 = _S3255 * _S3256; - float2 d_33 = make_float2 (s_primal_ctx_clamp_0(_S3166._S3163.x, _S3240, lim_x_pos_4), s_primal_ctx_clamp_0(_S3166._S3163.y, _S3241, lim_y_pos_1)) - _S3242; - float _S3258 = d_33.x; - float _S3259 = d_33.y; - float _S3260 = _S3258 * _S3259; - float2 d_34 = make_float2 (s_primal_ctx_clamp_0(_S3166._S3164.x, _S3240, lim_x_pos_4), s_primal_ctx_clamp_0(_S3166._S3164.y, _S3241, lim_y_pos_1)) - _S3242; - float _S3261 = d_34.x; - float _S3262 = d_34.y; - float _S3263 = _S3261 * _S3262; - Matrix covar2d_8 = makeMatrix (2.0f) * makeMatrix (_S3243 * _S3243, _S3245, _S3245, _S3244 * _S3244) + makeMatrix (_S3186.w_cov_0[int(1)]) * makeMatrix (_S3246 * _S3246, _S3248, _S3248, _S3247 * _S3247) + makeMatrix (_S3188.w_cov_0[int(2)]) * makeMatrix (_S3249 * _S3249, _S3251, _S3251, _S3250 * _S3250) + makeMatrix (_S3190.w_cov_0[int(3)]) * makeMatrix (_S3252 * _S3252, _S3254, _S3254, _S3253 * _S3253) + makeMatrix (_S3192.w_cov_0[int(4)]) * makeMatrix (_S3255 * _S3255, _S3257, _S3257, _S3256 * _S3256) + makeMatrix (_S3194.w_cov_0[int(5)]) * makeMatrix (_S3258 * _S3258, _S3260, _S3260, _S3259 * _S3259) + makeMatrix (_S3196.w_cov_0[int(6)]) * makeMatrix (_S3261 * _S3261, _S3263, _S3263, _S3262 * _S3262); - float eps2d_12; - if(antialiased_12) + float2 _S6214 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6215 = { _S6214, _S6214 }; + s_bwd_prop_DiffProjection3DGS_3dgs_equisolid_opencv_projection_Intermediates_0 _S6216; + (&_S6216)->_S6211 = _S6215; + (&_S6216)->_S6212 = _S6215; + (&_S6216)->_S6213 = _S6215; + (&(&_S6216)->_S6211)->primal_0 = _S6214; + (&(&_S6216)->_S6211)->differential_0 = _S6214; + (&(&_S6216)->_S6212)->primal_0 = _S6214; + (&(&_S6216)->_S6212)->differential_0 = _S6214; + (&(&_S6216)->_S6213)->primal_0 = _S6214; + (&(&_S6216)->_S6213)->differential_0 = _S6214; + float3 mean_c_30 = s_primal_ctx_mul_0(R_30, mean_31) + t_30; + float2 _S6217 = float2 {mean_c_30.x, mean_c_30.y}; + float2 _S6218 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6219 = { _S6217, _S6218 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6220; + (&_S6220)->primal_0 = _S6217; + (&_S6220)->differential_0 = _S6218; + DiffPair_float_0 _S6221 = s_primal_ctx_s_fwd_length_impl_0(&_S6220); + float _S6222 = mean_c_30.z; + DiffPair_float_0 _S6223 = { _S6221.primal_0, _S6221.differential_0 }; + DiffPair_float_0 _S6224 = { _S6222, 0.0f }; + DiffPair_float_0 _S6225; + (&_S6225)->primal_0 = _S6221.primal_0; + (&_S6225)->differential_0 = _S6221.differential_0; + DiffPair_float_0 _S6226; + (&_S6226)->primal_0 = _S6222; + (&_S6226)->differential_0 = 0.0f; + DiffPair_float_0 _S6227 = s_primal_ctx_d_atan2_0(&_S6225, &_S6226); + bool _S6228 = (_S6221.primal_0) < 9.99999997475242708e-07f; + float k_24; + float s_diff_k_14; + if(_S6228) { - eps2d_12 = 0.10000000149011612f; + float _S6229 = _S6227.differential_0 * _S6227.primal_0; + float _S6230 = (0.0f - (_S6229 + _S6229) * 0.0416666679084301f) * _S6222 / (_S6222 * _S6222); + k_24 = (1.0f - _S6227.primal_0 * _S6227.primal_0 / 24.0f) / _S6222; + s_diff_k_14 = _S6230; } else { - eps2d_12 = 0.30000001192092896f; + float _S6231 = _S6227.differential_0 * 0.5f; + DiffPair_float_0 _S6232; + (&_S6232)->primal_0 = 0.5f * _S6227.primal_0; + (&_S6232)->differential_0 = _S6231; + DiffPair_float_0 _S6233 = s_primal_ctx_d_sin_0(&_S6232); + float _S6234 = 2.0f * _S6233.primal_0; + float _S6235 = (_S6233.differential_0 * 2.0f * _S6221.primal_0 - _S6234 * _S6221.differential_0) / (_S6221.primal_0 * _S6221.primal_0); + k_24 = _S6234 / _S6221.primal_0; + s_diff_k_14 = _S6235; } - float _S3264 = covar2d_8.rows[int(0)].y * covar2d_8.rows[int(1)].x; - float det_orig_12 = covar2d_8.rows[int(0)].x * covar2d_8.rows[int(1)].y - _S3264; - float _S3265 = covar2d_8.rows[int(0)].x + eps2d_12; - Matrix _S3266 = covar2d_8; - *&(((&_S3266)->rows + (int(0)))->x) = _S3265; - float _S3267 = covar2d_8.rows[int(1)].y + eps2d_12; - *&(((&_S3266)->rows + (int(1)))->y) = _S3267; - Matrix _S3268 = _S3266; - Matrix _S3269 = _S3266; - float det_blur_12 = _S3265 * _S3267 - _S3264; - float _S3270 = det_orig_12 / det_blur_12; - float _S3271 = det_blur_12 * det_blur_12; - float _S3272 = (F32_max((0.0f), (_S3270))); - float _S3273 = s_primal_ctx_sqrt_0(_S3272); - float invdet_14 = 1.0f / det_blur_12; - float _S3274 = - covar2d_8.rows[int(0)].y; - float _S3275 = - covar2d_8.rows[int(1)].x; - if(antialiased_12) + float2 _S6236 = _S6217 * make_float2 (k_24); + float2 _S6237 = _S6218 * make_float2 (k_24) + make_float2 (s_diff_k_14) * _S6217; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6238; + (&_S6238)->primal_0 = _S6236; + (&_S6238)->differential_0 = _S6237; + FixedArray _S6239 = dist_coeffs_42; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6240 = s_primal_ctx_s_fwd_DistOpenCV_distort_0(&_S6238, &_S6239); + (&_S6216)->_S6211 = _S6240; + float2 _S6241 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6242 = { _S6217, _S6241 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6243; + (&_S6243)->primal_0 = _S6217; + (&_S6243)->differential_0 = _S6241; + DiffPair_float_0 _S6244 = s_primal_ctx_s_fwd_length_impl_0(&_S6243); + DiffPair_float_0 _S6245 = { _S6244.primal_0, _S6244.differential_0 }; + DiffPair_float_0 _S6246; + (&_S6246)->primal_0 = _S6244.primal_0; + (&_S6246)->differential_0 = _S6244.differential_0; + DiffPair_float_0 _S6247; + (&_S6247)->primal_0 = _S6222; + (&_S6247)->differential_0 = 0.0f; + DiffPair_float_0 _S6248 = s_primal_ctx_d_atan2_0(&_S6246, &_S6247); + bool _S6249 = (_S6244.primal_0) < 9.99999997475242708e-07f; + if(_S6249) { - eps2d_12 = _S3230 * _S3273; + float _S6250 = _S6248.differential_0 * _S6248.primal_0; + float _S6251 = (0.0f - (_S6250 + _S6250) * 0.0416666679084301f) * _S6222 / (_S6222 * _S6222); + k_24 = (1.0f - _S6248.primal_0 * _S6248.primal_0 / 24.0f) / _S6222; + s_diff_k_14 = _S6251; } else { - eps2d_12 = _S3230; + float _S6252 = _S6248.differential_0 * 0.5f; + DiffPair_float_0 _S6253; + (&_S6253)->primal_0 = 0.5f * _S6248.primal_0; + (&_S6253)->differential_0 = _S6252; + DiffPair_float_0 _S6254 = s_primal_ctx_d_sin_0(&_S6253); + float _S6255 = 2.0f * _S6254.primal_0; + float _S6256 = (_S6254.differential_0 * 2.0f * _S6244.primal_0 - _S6255 * _S6244.differential_0) / (_S6244.primal_0 * _S6244.primal_0); + k_24 = _S6255 / _S6244.primal_0; + s_diff_k_14 = _S6256; } - float _S3276 = eps2d_12 / 0.00392156885936856f; - float _S3277 = 2.0f * s_primal_ctx_log_0(_S3276); - float _S3278 = s_primal_ctx_sqrt_0(_S3277); - float _S3279 = _S3268.rows[int(0)].x; - float _S3280 = _S3269.rows[int(1)].y; - float3 campos_5 = - s_primal_ctx_mul_0(transpose_3(R_12), t_12); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3281; - (&_S3281)->primal_0 = mean_13; - (&_S3281)->differential_0 = _S3167; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3282; - (&_S3282)->primal_0 = scale_12; - (&_S3282)->differential_0 = _S3167; - DiffPair_float_0 _S3283; - (&_S3283)->primal_0 = in_opacity_12; - (&_S3283)->differential_0 = 0.0f; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3284; - (&_S3284)->primal_0 = campos_5; - (&_S3284)->differential_0 = _S3167; - s_bwd_prop_view_radius_3dgs_0(&_S3281, &_S3282, &_S3283, &_S3284, 0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3285 = _S3281; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3286 = _S3282; - DiffPair_float_0 _S3287 = _S3283; - float2 _S3288 = _S3165; - *&((&_S3288)->y) = v_conic_4.z; - float2 _S3289 = _S3165; - *&((&_S3289)->y) = v_conic_4.y; - *&((&_S3289)->x) = v_conic_4.x; - DiffPair_float_0 _S3290; - (&_S3290)->primal_0 = _S3280; - (&_S3290)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3290, 0.0f); - DiffPair_float_0 _S3291; - (&_S3291)->primal_0 = _S3279; - (&_S3291)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3291, 0.0f); - DiffPair_float_0 _S3292; - (&_S3292)->primal_0 = 3.32999992370605469f; - (&_S3292)->differential_0 = 0.0f; - DiffPair_float_0 _S3293; - (&_S3293)->primal_0 = _S3278; - (&_S3293)->differential_0 = 0.0f; - _d_min_0(&_S3292, &_S3293, 0.0f); - DiffPair_float_0 _S3294; - (&_S3294)->primal_0 = _S3277; - (&_S3294)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3294, _S3293.differential_0); - float _S3295 = 2.0f * _S3294.differential_0; - DiffPair_float_0 _S3296; - (&_S3296)->primal_0 = _S3276; - (&_S3296)->differential_0 = 0.0f; - s_bwd_prop_log_0(&_S3296, _S3295); - float _S3297 = v_opacity_4 + 254.9999847412109375f * _S3296.differential_0; - Matrix _S3298 = makeMatrix (0.0f); - Matrix _S3299 = _S3298; - _S3299[int(1)] = _S3288; - _S3299[int(0)] = _S3289; - Matrix _S3300 = _S3299; - float2 _S3301 = make_float2 (0.0f, _S3290.differential_0); - float2 _S3302 = make_float2 (_S3291.differential_0, 0.0f); - float _S3303; - if(antialiased_12) + float2 _S6257 = _S6217 * make_float2 (k_24); + float2 _S6258 = _S6241 * make_float2 (k_24) + make_float2 (s_diff_k_14) * _S6217; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6259; + (&_S6259)->primal_0 = _S6257; + (&_S6259)->differential_0 = _S6258; + FixedArray _S6260 = dist_coeffs_42; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6261 = s_primal_ctx_s_fwd_DistOpenCV_distort_0(&_S6259, &_S6260); + (&_S6216)->_S6212 = _S6261; + float2 _S6262 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6263 = { _S6217, _S6262 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6264; + (&_S6264)->primal_0 = _S6217; + (&_S6264)->differential_0 = _S6262; + DiffPair_float_0 _S6265 = s_primal_ctx_s_fwd_length_impl_0(&_S6264); + DiffPair_float_0 _S6266 = { _S6265.primal_0, _S6265.differential_0 }; + DiffPair_float_0 _S6267 = { _S6222, 1.0f }; + DiffPair_float_0 _S6268; + (&_S6268)->primal_0 = _S6265.primal_0; + (&_S6268)->differential_0 = _S6265.differential_0; + DiffPair_float_0 _S6269; + (&_S6269)->primal_0 = _S6222; + (&_S6269)->differential_0 = 1.0f; + DiffPair_float_0 _S6270 = s_primal_ctx_d_atan2_0(&_S6268, &_S6269); + bool _S6271 = (_S6265.primal_0) < 9.99999997475242708e-07f; + if(_S6271) { - float _S3304 = _S3273 * _S3297; - eps2d_12 = _S3230 * _S3297; - _S3303 = _S3304; + float _S6272 = _S6270.differential_0 * _S6270.primal_0; + float _S6273 = 1.0f - _S6270.primal_0 * _S6270.primal_0 / 24.0f; + float _S6274 = ((0.0f - (_S6272 + _S6272) * 0.0416666679084301f) * _S6222 - _S6273) / (_S6222 * _S6222); + k_24 = _S6273 / _S6222; + s_diff_k_14 = _S6274; } else { - eps2d_12 = 0.0f; - _S3303 = _S3297; + float _S6275 = _S6270.differential_0 * 0.5f; + DiffPair_float_0 _S6276; + (&_S6276)->primal_0 = 0.5f * _S6270.primal_0; + (&_S6276)->differential_0 = _S6275; + DiffPair_float_0 _S6277 = s_primal_ctx_d_sin_0(&_S6276); + float _S6278 = 2.0f * _S6277.primal_0; + float _S6279 = (_S6277.differential_0 * 2.0f * _S6265.primal_0 - _S6278 * _S6265.differential_0) / (_S6265.primal_0 * _S6265.primal_0); + k_24 = _S6278 / _S6265.primal_0; + s_diff_k_14 = _S6279; } - float _S3305 = invdet_14 * _S3300.rows[int(1)].y; - float _S3306 = - (invdet_14 * _S3300.rows[int(1)].x); - float _S3307 = - (invdet_14 * _S3300.rows[int(0)].y); - float _S3308 = invdet_14 * _S3300.rows[int(0)].x; - float _S3309 = - ((_S3265 * _S3300.rows[int(1)].y + _S3275 * _S3300.rows[int(1)].x + _S3274 * _S3300.rows[int(0)].y + _S3267 * _S3300.rows[int(0)].x) / _S3271); - DiffPair_float_0 _S3310; - (&_S3310)->primal_0 = _S3272; - (&_S3310)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3310, eps2d_12); - DiffPair_float_0 _S3311; - (&_S3311)->primal_0 = 0.0f; - (&_S3311)->differential_0 = 0.0f; - DiffPair_float_0 _S3312; - (&_S3312)->primal_0 = _S3270; - (&_S3312)->differential_0 = 0.0f; - _d_max_0(&_S3311, &_S3312, _S3310.differential_0); - float _S3313 = _S3312.differential_0 / _S3271; - float s_diff_det_orig_T_4 = det_blur_12 * _S3313; - float _S3314 = det_orig_12 * - _S3313 + _S3309; - float _S3315 = - _S3314; - float _S3316 = _S3265 * _S3314; - float _S3317 = _S3267 * _S3314; - Matrix _S3318 = _S3298; - _S3318[int(1)] = _S3301; - _S3318[int(0)] = _S3302; - float _S3319 = _S3317 + _S3318.rows[int(0)].x + _S3305; - float _S3320 = _S3315 + - s_diff_det_orig_T_4; - float _S3321 = covar2d_8.rows[int(0)].y * _S3320 + _S3306; - float _S3322 = covar2d_8.rows[int(1)].x * _S3320 + _S3307; - float _S3323 = covar2d_8.rows[int(1)].y * s_diff_det_orig_T_4; - float _S3324 = _S3316 + _S3318.rows[int(1)].y + _S3308 + covar2d_8.rows[int(0)].x * s_diff_det_orig_T_4; - float2 _S3325 = _S3165; - *&((&_S3325)->x) = _S3321; - *&((&_S3325)->y) = _S3324; - float _S3326 = _S3319 + _S3323; - float2 _S3327 = _S3165; - *&((&_S3327)->y) = _S3322; - *&((&_S3327)->x) = _S3326; - Matrix _S3328 = _S3298; - _S3328[int(1)] = _S3325; - _S3328[int(0)] = _S3327; - Matrix _S3329 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3330; - (&_S3330)->primal_0 = R_12; - (&_S3330)->differential_0 = _S3329; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3331; - (&_S3331)->primal_0 = _S3185; - (&_S3331)->differential_0 = _S3167; - s_bwd_prop_mul_3(&_S3330, &_S3331, _S3167); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3332; - (&_S3332)->primal_0 = R_12; - (&_S3332)->differential_0 = _S3329; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3333; - (&_S3333)->primal_0 = _S3182; - (&_S3333)->differential_0 = _S3167; - s_bwd_prop_mul_3(&_S3332, &_S3333, _S3167); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3334; - (&_S3334)->primal_0 = R_12; - (&_S3334)->differential_0 = _S3329; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3335; - (&_S3335)->primal_0 = _S3179; - (&_S3335)->differential_0 = _S3167; - s_bwd_prop_mul_3(&_S3334, &_S3335, _S3167); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3336; - (&_S3336)->primal_0 = R_12; - (&_S3336)->differential_0 = _S3329; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3337; - (&_S3337)->primal_0 = _S3184; - (&_S3337)->differential_0 = _S3167; - s_bwd_prop_mul_3(&_S3336, &_S3337, _S3167); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3338; - (&_S3338)->primal_0 = R_12; - (&_S3338)->differential_0 = _S3329; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3339; - (&_S3339)->primal_0 = _S3181; - (&_S3339)->differential_0 = _S3167; - s_bwd_prop_mul_3(&_S3338, &_S3339, _S3167); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3340; - (&_S3340)->primal_0 = R_12; - (&_S3340)->differential_0 = _S3329; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3341; - (&_S3341)->primal_0 = _S3178; - (&_S3341)->differential_0 = _S3167; - s_bwd_prop_mul_3(&_S3340, &_S3341, _S3167); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3342; - (&_S3342)->primal_0 = R_12; - (&_S3342)->differential_0 = _S3329; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3343; - (&_S3343)->primal_0 = _S3197.p_0[0U]; - (&_S3343)->differential_0 = _S3167; - s_bwd_prop_mul_3(&_S3342, &_S3343, _S3167); - float3 _S3344 = - _S3331.differential_0 + _S3337.differential_0; - float3 _S3345 = _S3234 * _S3344; - float3 _S3346 = _S3171.rows[2U] * _S3344; - float _S3347 = _S3176 * (_S3346.x + _S3346.y + _S3346.z); - float3 _S3348 = - _S3333.differential_0 + _S3339.differential_0; - float3 _S3349 = _S3233 * _S3348; - float3 _S3350 = _S3171.rows[1U] * _S3348; - float _S3351 = _S3176 * (_S3350.x + _S3350.y + _S3350.z); - float3 _S3352 = - _S3335.differential_0 + _S3341.differential_0; - float3 _S3353 = _S3232 * _S3352; - float3 _S3354 = _S3171.rows[0U] * _S3352; - float _S3355 = _S3176 * (_S3354.x + _S3354.y + _S3354.z); - Matrix _S3356 = _S3329; - _S3356[2U] = _S3345; - _S3356[1U] = _S3349; - _S3356[0U] = _S3353; - Matrix _S3357 = transpose_3(transpose_3(_S3356)); - float _S3358 = 2.0f * - _S3357.rows[int(2)].z; - float _S3359 = 2.0f * _S3357.rows[int(2)].y; - float _S3360 = 2.0f * _S3357.rows[int(2)].x; - float _S3361 = 2.0f * _S3357.rows[int(1)].z; - float _S3362 = 2.0f * - _S3357.rows[int(1)].y; - float _S3363 = 2.0f * _S3357.rows[int(1)].x; - float _S3364 = 2.0f * _S3357.rows[int(0)].z; - float _S3365 = 2.0f * _S3357.rows[int(0)].y; - float _S3366 = 2.0f * - _S3357.rows[int(0)].x; - float _S3367 = - _S3363 + _S3365; - float _S3368 = _S3360 + - _S3364; - float _S3369 = - _S3359 + _S3361; - float _S3370 = _S3359 + _S3361; - float _S3371 = _S3360 + _S3364; - float _S3372 = _S3363 + _S3365; - float _S3373 = _S3169.w * (_S3362 + _S3366); - float _S3374 = _S3169.z * (_S3358 + _S3366); - float _S3375 = _S3169.y * (_S3358 + _S3362); - float _S3376 = _S3169.x * _S3367 + _S3169.z * _S3370 + _S3169.y * _S3371 + _S3373 + _S3373; - float _S3377 = _S3169.x * _S3368 + _S3169.w * _S3370 + _S3169.y * _S3372 + _S3374 + _S3374; - float _S3378 = _S3169.x * _S3369 + _S3169.w * _S3371 + _S3169.z * _S3372 + _S3375 + _S3375; - float _S3379 = _S3169.w * _S3367 + _S3169.z * _S3368 + _S3169.y * _S3369; - float4 _S3380 = make_float4 (0.0f); - float4 _S3381 = _S3380; - *&((&_S3381)->w) = _S3376; - *&((&_S3381)->z) = _S3377; - *&((&_S3381)->y) = _S3378; - *&((&_S3381)->x) = _S3379; - DiffPair_vectorx3Cfloatx2C4x3E_0 _S3382; - (&_S3382)->primal_0 = quat_12; - (&_S3382)->differential_0 = _S3380; - s_bwd_normalize_impl_0(&_S3382, _S3381); - float3 _S3383 = _S3167; - *&((&_S3383)->z) = _S3347; - *&((&_S3383)->y) = _S3351; - *&((&_S3383)->x) = _S3355; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3384; - (&_S3384)->primal_0 = scale_12; - (&_S3384)->differential_0 = _S3167; - s_bwd_prop_exp_1(&_S3384, _S3383); - float _S3385 = - (_S3303 / _S3231); - DiffPair_float_0 _S3386; - (&_S3386)->primal_0 = _S3228; - (&_S3386)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S3386, _S3385); - float _S3387 = - _S3386.differential_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3388; - (&_S3388)->primal_0 = mean_c_12; - (&_S3388)->differential_0 = _S3167; - s_bwd_length_impl_0(&_S3388, v_depth_4); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3389; - (&_S3389)->primal_0 = R_12; - (&_S3389)->differential_0 = _S3329; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3390; - (&_S3390)->primal_0 = mean_13; - (&_S3390)->differential_0 = _S3167; - s_bwd_prop_mul_3(&_S3389, &_S3390, _S3388.differential_0); - Matrix _S3391 = _S3330.differential_0 + _S3332.differential_0 + _S3334.differential_0 + _S3336.differential_0 + _S3338.differential_0 + _S3340.differential_0 + _S3342.differential_0 + _S3389.differential_0; - float _S3392 = _S3387 + _S3287.differential_0; - float3 _S3393 = _S3384.differential_0 + _S3286.differential_0; - *v_mean_4 = *v_mean_4 + (_S3331.differential_0 + _S3337.differential_0 + _S3333.differential_0 + _S3339.differential_0 + _S3335.differential_0 + _S3341.differential_0 + _S3390.differential_0 + _S3285.differential_0); - *v_quat_4 = *v_quat_4 + _S3382.differential_0; - *v_scale_4 = *v_scale_4 + _S3393; - *v_in_opacity_4 = *v_in_opacity_4 + _S3392; - *v_R_4 = *v_R_4 + _S3391; - *v_t_4 = *v_t_4 + _S3388.differential_0; + float2 _S6280 = _S6217 * make_float2 (k_24); + float2 _S6281 = make_float2 (s_diff_k_14) * _S6217; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6282; + (&_S6282)->primal_0 = _S6280; + (&_S6282)->differential_0 = _S6281; + FixedArray _S6283 = dist_coeffs_42; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6284 = s_primal_ctx_s_fwd_DistOpenCV_distort_0(&_S6282, &_S6283); + (&_S6216)->_S6213 = _S6284; + s_bwd_prop_DiffProjection3DGS_3dgs_equisolid_opencv_projection_Intermediates_0 _S6285 = _S6216; + DiffPair_float_0 _S6286 = { 0.0f, 0.0f }; + float _S6287 = - in_opacity_30; + float _S6288 = 1.0f + s_primal_ctx_exp_0(_S6287); + float _S6289 = 1.0f / _S6288; + float _S6290 = _S6288 * _S6288; + float4 _S6291 = normalize_0(quat_30); + float3 _S6292 = s_primal_ctx_exp_1(scale_30); + float _S6293 = _S6291.y; + float x2_30 = _S6293 * _S6293; + float y2_30 = _S6291.z * _S6291.z; + float z2_30 = _S6291.w * _S6291.w; + float xy_30 = _S6291.y * _S6291.z; + float xz_30 = _S6291.y * _S6291.w; + float yz_30 = _S6291.z * _S6291.w; + float wx_30 = _S6291.x * _S6291.y; + float wy_30 = _S6291.x * _S6291.z; + float wz_30 = _S6291.x * _S6291.w; + Matrix _S6294 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_30 + z2_30), 2.0f * (xy_30 + wz_30), 2.0f * (xz_30 - wy_30), 2.0f * (xy_30 - wz_30), 1.0f - 2.0f * (x2_30 + z2_30), 2.0f * (yz_30 + wx_30), 2.0f * (xz_30 + wy_30), 2.0f * (yz_30 - wx_30), 1.0f - 2.0f * (x2_30 + y2_30))); + Matrix S_8 = makeMatrix (_S6292.x, 0.0f, 0.0f, 0.0f, _S6292.y, 0.0f, 0.0f, 0.0f, _S6292.z); + Matrix _S6295 = s_primal_ctx_mul_1(_S6294, S_8); + Matrix _S6296 = transpose_3(_S6295); + Matrix _S6297 = s_primal_ctx_mul_1(_S6295, _S6296); + Matrix _S6298 = s_primal_ctx_mul_1(R_30, _S6297); + Matrix _S6299 = transpose_3(R_30); + Matrix _S6300 = s_primal_ctx_mul_1(_S6298, _S6299); + Matrix J_40 = makeMatrix (0.0f); + float _S6301; + float _S6302; + float _S6303; + float _S6304; + float _S6305; + float _S6306; + float _S6307; + float _S6308; + float _S6309; + float _S6310; + DiffPair_float_0 _S6311; + if(_S6228) + { + float _S6312 = _S6227.differential_0 * _S6227.primal_0; + float _S6313 = 1.0f - _S6227.primal_0 * _S6227.primal_0 / 24.0f; + float _S6314 = 0.0f - (_S6312 + _S6312) * 0.0416666679084301f; + float _S6315 = _S6222 * _S6222; + float _S6316 = _S6314 * _S6222; + float _S6317 = _S6316 / _S6315; + float _S6318 = _S6315 * _S6315; + k_24 = _S6313 / _S6222; + s_diff_k_14 = _S6317; + _S6301 = _S6318; + _S6302 = _S6316; + _S6303 = _S6315; + _S6304 = _S6313; + _S6305 = _S6314; + _S6306 = 0.0f; + _S6307 = 0.0f; + _S6308 = 0.0f; + _S6309 = 0.0f; + _S6310 = 0.0f; + (&_S6311)->primal_0 = 0.0f; + (&_S6311)->differential_0 = 0.0f; + } + else + { + float _S6319 = 0.5f * _S6227.primal_0; + float _S6320 = _S6227.differential_0 * 0.5f; + DiffPair_float_0 _S6321; + (&_S6321)->primal_0 = _S6319; + (&_S6321)->differential_0 = _S6320; + DiffPair_float_0 _S6322 = s_primal_ctx_d_sin_0(&_S6321); + float _S6323 = 2.0f * _S6322.primal_0; + float _S6324 = _S6322.differential_0 * 2.0f; + float _S6325 = _S6221.primal_0 * _S6221.primal_0; + float _S6326 = _S6324 * _S6221.primal_0 - _S6323 * _S6221.differential_0; + float _S6327 = _S6326 / _S6325; + float _S6328 = _S6325 * _S6325; + k_24 = _S6323 / _S6221.primal_0; + s_diff_k_14 = _S6327; + _S6301 = 0.0f; + _S6302 = 0.0f; + _S6303 = 0.0f; + _S6304 = 0.0f; + _S6305 = 0.0f; + _S6306 = _S6328; + _S6307 = _S6326; + _S6308 = _S6325; + _S6309 = _S6323; + _S6310 = _S6324; + (&_S6311)->primal_0 = _S6319; + (&_S6311)->differential_0 = _S6320; + } + float2 _S6329 = make_float2 (k_24); + float2 _S6330 = make_float2 (s_diff_k_14); + float2 _S6331 = _S6217 * make_float2 (k_24); + float2 _S6332 = _S6218 * make_float2 (k_24) + make_float2 (s_diff_k_14) * _S6217; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6333 = { _S6331, _S6332 }; + float _S6334 = _S6285._S6211.differential_0.x * fx_43; + float _S6335 = _S6285._S6211.differential_0.y * fy_43; + Matrix _S6336 = J_40; + *&(((&_S6336)->rows + (int(0)))->x) = _S6334; + *&(((&_S6336)->rows + (int(1)))->x) = _S6335; + float _S6337; + float _S6338; + float _S6339; + float _S6340; + float _S6341; + float _S6342; + float _S6343; + float _S6344; + float _S6345; + float _S6346; + DiffPair_float_0 _S6347; + if(_S6249) + { + float _S6348 = _S6248.differential_0 * _S6248.primal_0; + float _S6349 = 1.0f - _S6248.primal_0 * _S6248.primal_0 / 24.0f; + float _S6350 = 0.0f - (_S6348 + _S6348) * 0.0416666679084301f; + float _S6351 = _S6222 * _S6222; + float _S6352 = _S6350 * _S6222; + float _S6353 = _S6352 / _S6351; + float _S6354 = _S6351 * _S6351; + k_24 = _S6349 / _S6222; + s_diff_k_14 = _S6353; + _S6337 = _S6354; + _S6338 = _S6352; + _S6339 = _S6351; + _S6340 = _S6349; + _S6341 = _S6350; + _S6342 = 0.0f; + _S6343 = 0.0f; + _S6344 = 0.0f; + _S6345 = 0.0f; + _S6346 = 0.0f; + (&_S6347)->primal_0 = 0.0f; + (&_S6347)->differential_0 = 0.0f; + } + else + { + float _S6355 = 0.5f * _S6248.primal_0; + float _S6356 = _S6248.differential_0 * 0.5f; + DiffPair_float_0 _S6357; + (&_S6357)->primal_0 = _S6355; + (&_S6357)->differential_0 = _S6356; + DiffPair_float_0 _S6358 = s_primal_ctx_d_sin_0(&_S6357); + float _S6359 = 2.0f * _S6358.primal_0; + float _S6360 = _S6358.differential_0 * 2.0f; + float _S6361 = _S6244.primal_0 * _S6244.primal_0; + float _S6362 = _S6360 * _S6244.primal_0 - _S6359 * _S6244.differential_0; + float _S6363 = _S6362 / _S6361; + float _S6364 = _S6361 * _S6361; + k_24 = _S6359 / _S6244.primal_0; + s_diff_k_14 = _S6363; + _S6337 = 0.0f; + _S6338 = 0.0f; + _S6339 = 0.0f; + _S6340 = 0.0f; + _S6341 = 0.0f; + _S6342 = _S6364; + _S6343 = _S6362; + _S6344 = _S6361; + _S6345 = _S6359; + _S6346 = _S6360; + (&_S6347)->primal_0 = _S6355; + (&_S6347)->differential_0 = _S6356; + } + float2 _S6365 = make_float2 (k_24); + float2 _S6366 = make_float2 (s_diff_k_14); + float2 _S6367 = _S6217 * make_float2 (k_24); + float2 _S6368 = _S6241 * make_float2 (k_24) + make_float2 (s_diff_k_14) * _S6217; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6369 = { _S6367, _S6368 }; + float _S6370 = _S6285._S6212.differential_0.y * fy_43; + *&(((&_S6336)->rows + (int(0)))->y) = _S6285._S6212.differential_0.x * fx_43; + *&(((&_S6336)->rows + (int(1)))->y) = _S6370; + float _S6371; + float _S6372; + float _S6373; + float _S6374; + float _S6375; + float _S6376; + float _S6377; + float _S6378; + float _S6379; + float _S6380; + DiffPair_float_0 _S6381; + if(_S6271) + { + float _S6382 = _S6270.differential_0 * _S6270.primal_0; + float _S6383 = 1.0f - _S6270.primal_0 * _S6270.primal_0 / 24.0f; + float _S6384 = 0.0f - (_S6382 + _S6382) * 0.0416666679084301f; + float _S6385 = _S6222 * _S6222; + float _S6386 = _S6384 * _S6222 - _S6383; + float _S6387 = _S6386 / _S6385; + float _S6388 = _S6385 * _S6385; + k_24 = _S6383 / _S6222; + s_diff_k_14 = _S6387; + _S6371 = _S6388; + _S6372 = _S6386; + _S6373 = _S6385; + _S6374 = _S6383; + _S6375 = _S6384; + _S6376 = 0.0f; + _S6377 = 0.0f; + _S6378 = 0.0f; + _S6379 = 0.0f; + _S6380 = 0.0f; + (&_S6381)->primal_0 = 0.0f; + (&_S6381)->differential_0 = 0.0f; + } + else + { + float _S6389 = 0.5f * _S6270.primal_0; + float _S6390 = _S6270.differential_0 * 0.5f; + DiffPair_float_0 _S6391; + (&_S6391)->primal_0 = _S6389; + (&_S6391)->differential_0 = _S6390; + DiffPair_float_0 _S6392 = s_primal_ctx_d_sin_0(&_S6391); + float _S6393 = 2.0f * _S6392.primal_0; + float _S6394 = _S6392.differential_0 * 2.0f; + float _S6395 = _S6265.primal_0 * _S6265.primal_0; + float _S6396 = _S6394 * _S6265.primal_0 - _S6393 * _S6265.differential_0; + float _S6397 = _S6396 / _S6395; + float _S6398 = _S6395 * _S6395; + k_24 = _S6393 / _S6265.primal_0; + s_diff_k_14 = _S6397; + _S6371 = 0.0f; + _S6372 = 0.0f; + _S6373 = 0.0f; + _S6374 = 0.0f; + _S6375 = 0.0f; + _S6376 = _S6398; + _S6377 = _S6396; + _S6378 = _S6395; + _S6379 = _S6393; + _S6380 = _S6394; + (&_S6381)->primal_0 = _S6389; + (&_S6381)->differential_0 = _S6390; + } + float2 _S6399 = make_float2 (k_24); + float2 _S6400 = make_float2 (s_diff_k_14); + float2 _S6401 = _S6217 * make_float2 (k_24); + float2 _S6402 = make_float2 (s_diff_k_14) * _S6217; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6403 = { _S6401, _S6402 }; + float _S6404 = _S6285._S6213.differential_0.y * fy_43; + *&(((&_S6336)->rows + (int(0)))->z) = _S6285._S6213.differential_0.x * fx_43; + *&(((&_S6336)->rows + (int(1)))->z) = _S6404; + Matrix _S6405 = s_primal_ctx_mul_2(_S6336, _S6300); + Matrix _S6406 = transpose_1(_S6336); + Matrix _S6407 = s_primal_ctx_mul_3(_S6405, _S6406); + float eps2d_30; + if(antialiased_30) + { + eps2d_30 = 0.10000000149011612f; + } + else + { + eps2d_30 = 0.30000001192092896f; + } + float _S6408 = _S6407.rows[int(0)].y * _S6407.rows[int(1)].x; + float det_orig_30 = _S6407.rows[int(0)].x * _S6407.rows[int(1)].y - _S6408; + float _S6409 = _S6407.rows[int(0)].x + eps2d_30; + Matrix _S6410 = _S6407; + *&(((&_S6410)->rows + (int(0)))->x) = _S6409; + float _S6411 = _S6407.rows[int(1)].y + eps2d_30; + *&(((&_S6410)->rows + (int(1)))->y) = _S6411; + Matrix _S6412 = _S6410; + Matrix _S6413 = _S6410; + float det_blur_30 = _S6409 * _S6411 - _S6408; + float _S6414 = det_orig_30 / det_blur_30; + float _S6415 = det_blur_30 * det_blur_30; + float _S6416 = (F32_max((0.0f), (_S6414))); + float _S6417 = s_primal_ctx_sqrt_0(_S6416); + float invdet_36 = 1.0f / det_blur_30; + float _S6418 = - _S6407.rows[int(0)].y; + float _S6419 = - _S6407.rows[int(1)].x; + if(antialiased_30) + { + k_24 = _S6289 * _S6417; + } + else + { + k_24 = _S6289; + } + float _S6420 = k_24 / 0.00392156885936856f; + float _S6421 = 2.0f * s_primal_ctx_log_0(_S6420); + float _S6422 = s_primal_ctx_sqrt_0(_S6421); + float _S6423 = _S6412.rows[int(0)].x; + float _S6424 = _S6413.rows[int(1)].y; + float3 campos_9 = - s_primal_ctx_mul_0(_S6299, t_30); + float3 _S6425 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6426; + (&_S6426)->primal_0 = mean_31; + (&_S6426)->differential_0 = _S6425; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6427; + (&_S6427)->primal_0 = scale_30; + (&_S6427)->differential_0 = _S6425; + DiffPair_float_0 _S6428; + (&_S6428)->primal_0 = in_opacity_30; + (&_S6428)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6429; + (&_S6429)->primal_0 = campos_9; + (&_S6429)->differential_0 = _S6425; + s_bwd_prop_view_radius_3dgs_0(&_S6426, &_S6427, &_S6428, &_S6429, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6430 = _S6426; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6431 = _S6427; + DiffPair_float_0 _S6432 = _S6428; + float2 _S6433 = _S6214; + *&((&_S6433)->y) = v_conic_8.z; + float2 _S6434 = _S6214; + *&((&_S6434)->y) = v_conic_8.y; + *&((&_S6434)->x) = v_conic_8.x; + DiffPair_float_0 _S6435; + (&_S6435)->primal_0 = _S6424; + (&_S6435)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S6435, 0.0f); + DiffPair_float_0 _S6436; + (&_S6436)->primal_0 = _S6423; + (&_S6436)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S6436, 0.0f); + DiffPair_float_0 _S6437; + (&_S6437)->primal_0 = 3.32999992370605469f; + (&_S6437)->differential_0 = 0.0f; + DiffPair_float_0 _S6438; + (&_S6438)->primal_0 = _S6422; + (&_S6438)->differential_0 = 0.0f; + _d_min_0(&_S6437, &_S6438, 0.0f); + DiffPair_float_0 _S6439; + (&_S6439)->primal_0 = _S6421; + (&_S6439)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S6439, _S6438.differential_0); + float _S6440 = 2.0f * _S6439.differential_0; + DiffPair_float_0 _S6441; + (&_S6441)->primal_0 = _S6420; + (&_S6441)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S6441, _S6440); + float _S6442 = v_opacity_8 + 254.9999847412109375f * _S6441.differential_0; + Matrix _S6443 = makeMatrix (0.0f); + Matrix _S6444 = _S6443; + _S6444[int(1)] = _S6433; + _S6444[int(0)] = _S6434; + Matrix _S6445 = _S6444; + float2 _S6446 = make_float2 (0.0f, _S6435.differential_0); + float2 _S6447 = make_float2 (_S6436.differential_0, 0.0f); + if(antialiased_30) + { + float _S6448 = _S6417 * _S6442; + k_24 = _S6289 * _S6442; + s_diff_k_14 = _S6448; + } + else + { + k_24 = 0.0f; + s_diff_k_14 = _S6442; + } + float _S6449 = invdet_36 * _S6445.rows[int(1)].y; + float _S6450 = - (invdet_36 * _S6445.rows[int(1)].x); + float _S6451 = - (invdet_36 * _S6445.rows[int(0)].y); + float _S6452 = invdet_36 * _S6445.rows[int(0)].x; + float _S6453 = - ((_S6409 * _S6445.rows[int(1)].y + _S6419 * _S6445.rows[int(1)].x + _S6418 * _S6445.rows[int(0)].y + _S6411 * _S6445.rows[int(0)].x) / _S6415); + DiffPair_float_0 _S6454; + (&_S6454)->primal_0 = _S6416; + (&_S6454)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S6454, k_24); + DiffPair_float_0 _S6455; + (&_S6455)->primal_0 = 0.0f; + (&_S6455)->differential_0 = 0.0f; + DiffPair_float_0 _S6456; + (&_S6456)->primal_0 = _S6414; + (&_S6456)->differential_0 = 0.0f; + _d_max_0(&_S6455, &_S6456, _S6454.differential_0); + float _S6457 = _S6456.differential_0 / _S6415; + float s_diff_det_orig_T_8 = det_blur_30 * _S6457; + float _S6458 = det_orig_30 * - _S6457 + _S6453; + float _S6459 = - _S6458; + float _S6460 = _S6409 * _S6458; + float _S6461 = _S6411 * _S6458; + Matrix _S6462 = _S6443; + _S6462[int(1)] = _S6446; + _S6462[int(0)] = _S6447; + _S6410 = _S6462; + *&(((&_S6410)->rows + (int(1)))->y) = 0.0f; + float _S6463 = _S6460 + _S6462.rows[int(1)].y + _S6452; + *&(((&_S6410)->rows + (int(0)))->x) = 0.0f; + float _S6464 = _S6461 + _S6462.rows[int(0)].x + _S6449; + float _S6465 = _S6459 + - s_diff_det_orig_T_8; + float _S6466 = _S6407.rows[int(0)].y * _S6465 + _S6450; + float _S6467 = _S6407.rows[int(1)].x * _S6465 + _S6451; + float _S6468 = _S6407.rows[int(1)].y * s_diff_det_orig_T_8; + float _S6469 = _S6463 + _S6407.rows[int(0)].x * s_diff_det_orig_T_8; + float2 _S6470 = _S6214; + *&((&_S6470)->x) = _S6466; + *&((&_S6470)->y) = _S6469; + float _S6471 = _S6464 + _S6468; + float2 _S6472 = _S6214; + *&((&_S6472)->y) = _S6467; + *&((&_S6472)->x) = _S6471; + Matrix _S6473 = _S6443; + _S6473[int(1)] = _S6470; + _S6473[int(0)] = _S6472; + Matrix _S6474 = _S6410 + _S6473; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S6475; + (&_S6475)->primal_0 = _S6405; + (&_S6475)->differential_0 = J_40; + Matrix _S6476 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S6477; + (&_S6477)->primal_0 = _S6406; + (&_S6477)->differential_0 = _S6476; + s_bwd_prop_mul_0(&_S6475, &_S6477, _S6474); + Matrix _S6478 = transpose_2(_S6477.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S6479; + (&_S6479)->primal_0 = _S6336; + (&_S6479)->differential_0 = J_40; + Matrix _S6480 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6481; + (&_S6481)->primal_0 = _S6300; + (&_S6481)->differential_0 = _S6480; + s_bwd_prop_mul_1(&_S6479, &_S6481, _S6475.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6482 = _S6481; + Matrix _S6483 = _S6478 + _S6479.differential_0; + float2 _S6484 = make_float2 (fx_43 * _S6483.rows[int(0)].z, fy_43 * _S6483.rows[int(1)].z); + DiffPair_0 _S6485; + (&_S6485)->primal_0 = _S6403; + (&_S6485)->differential_0 = _S6215; + FixedArray _S6486 = dist_coeffs_42; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6487; + (&_S6487)->primal_0 = _S6262; + (&_S6487)->differential_0 = _S6484; + s_bwd_prop_s_fwd_DistOpenCV_distort_0(&_S6485, &_S6486, &_S6487); + float2 _S6488 = _S6217 * _S6485.differential_0.differential_0; + float2 _S6489 = _S6217 * _S6485.differential_0.primal_0; + float _S6490 = _S6489.x + _S6489.y; + float _S6491 = _S6488.x + _S6488.y; + float2 _S6492 = _S6400 * _S6485.differential_0.differential_0 + _S6399 * _S6485.differential_0.primal_0; + if(_S6271) + { + float _S6493 = _S6491 / _S6371; + float _S6494 = _S6373 * _S6493; + float _S6495 = _S6222 * (_S6372 * - _S6493); + float _S6496 = _S6490 / _S6373; + float _S6497 = 0.0416666679084301f * - (_S6222 * _S6494); + float _S6498 = _S6497 + _S6497; + float _S6499 = _S6270.primal_0 * (0.0416666679084301f * - (- _S6494 + _S6222 * _S6496)); + float _S6500 = _S6495 + _S6495 + _S6375 * _S6494 + _S6374 * - _S6496; + float _S6501 = _S6270.differential_0 * _S6498 + _S6499 + _S6499; + k_24 = _S6270.primal_0 * _S6498; + _S6371 = _S6501; + _S6372 = _S6500; + _S6373 = 0.0f; + _S6374 = 0.0f; + } + else + { + float _S6502 = _S6491 / _S6376; + float _S6503 = _S6378 * _S6502; + float _S6504 = _S6265.primal_0 * (_S6377 * - _S6502); + float _S6505 = - _S6503; + float _S6506 = _S6379 * _S6505; + float _S6507 = _S6380 * _S6503; + float _S6508 = _S6490 / _S6378; + float _S6509 = _S6379 * - _S6508; + float _S6510 = 2.0f * (_S6265.primal_0 * _S6503); + float _S6511 = 2.0f * (_S6265.differential_0 * _S6505 + _S6265.primal_0 * _S6508); + DiffPair_1 _S6512; + (&_S6512)->primal_0 = _S6381; + (&_S6512)->differential_0 = _S6286; + DiffPair_float_0 _S6513; + (&_S6513)->primal_0 = _S6511; + (&_S6513)->differential_0 = _S6510; + s_bwd_prop_d_sin_0(&_S6512, &_S6513); + float _S6514 = 0.5f * _S6512.differential_0.primal_0; + float _S6515 = _S6504 + _S6504 + _S6507 + _S6509; + k_24 = 0.5f * _S6512.differential_0.differential_0; + _S6371 = _S6514; + _S6372 = 0.0f; + _S6373 = _S6506; + _S6374 = _S6515; + } + DiffPair_1 _S6516; + (&_S6516)->primal_0 = _S6266; + (&_S6516)->differential_0 = _S6286; + DiffPair_1 _S6517; + (&_S6517)->primal_0 = _S6267; + (&_S6517)->differential_0 = _S6286; + DiffPair_float_0 _S6518; + (&_S6518)->primal_0 = _S6371; + (&_S6518)->differential_0 = k_24; + s_bwd_prop_d_atan2_0(&_S6516, &_S6517, &_S6518); + float _S6519 = _S6517.differential_0.primal_0 + _S6372; + float _S6520 = _S6516.differential_0.differential_0 + _S6373; + float _S6521 = _S6516.differential_0.primal_0 + _S6374; + DiffPair_0 _S6522; + (&_S6522)->primal_0 = _S6263; + (&_S6522)->differential_0 = _S6215; + DiffPair_float_0 _S6523; + (&_S6523)->primal_0 = _S6521; + (&_S6523)->differential_0 = _S6520; + s_bwd_prop_s_fwd_length_impl_0(&_S6522, &_S6523); + float2 _S6524 = _S6522.differential_0.primal_0 + _S6492; + float3 _S6525 = make_float3 (_S6524.x, _S6524.y, _S6519); + float2 _S6526 = make_float2 (fx_43 * _S6483.rows[int(0)].y, fy_43 * _S6483.rows[int(1)].y); + DiffPair_0 _S6527; + (&_S6527)->primal_0 = _S6369; + (&_S6527)->differential_0 = _S6215; + FixedArray _S6528 = dist_coeffs_42; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6529; + (&_S6529)->primal_0 = _S6262; + (&_S6529)->differential_0 = _S6526; + s_bwd_prop_s_fwd_DistOpenCV_distort_0(&_S6527, &_S6528, &_S6529); + DiffPair_0 _S6530 = _S6527; + float2 _S6531 = _S6217 * _S6530.differential_0.differential_0; + float2 _S6532 = _S6241 * _S6530.differential_0.differential_0; + float2 _S6533 = _S6217 * _S6530.differential_0.primal_0; + float _S6534 = _S6532.x + _S6532.y + _S6533.x + _S6533.y; + float _S6535 = _S6531.x + _S6531.y; + float2 _S6536 = _S6366 * _S6530.differential_0.differential_0 + _S6365 * _S6530.differential_0.primal_0; + if(_S6249) + { + float _S6537 = _S6535 / _S6337; + float _S6538 = _S6339 * _S6537; + float _S6539 = _S6222 * (_S6338 * - _S6537); + float _S6540 = _S6534 / _S6339; + float _S6541 = 0.0416666679084301f * - (_S6222 * _S6538); + float _S6542 = _S6541 + _S6541; + float _S6543 = _S6248.primal_0 * (0.0416666679084301f * - (_S6222 * _S6540)); + float _S6544 = _S6539 + _S6539 + _S6341 * _S6538 + _S6340 * - _S6540; + float _S6545 = _S6248.differential_0 * _S6542 + _S6543 + _S6543; + k_24 = _S6248.primal_0 * _S6542; + _S6337 = _S6545; + _S6338 = _S6544; + _S6339 = 0.0f; + _S6340 = 0.0f; + } + else + { + float _S6546 = _S6535 / _S6342; + float _S6547 = _S6344 * _S6546; + float _S6548 = _S6244.primal_0 * (_S6343 * - _S6546); + float _S6549 = - _S6547; + float _S6550 = _S6345 * _S6549; + float _S6551 = _S6346 * _S6547; + float _S6552 = _S6534 / _S6344; + float _S6553 = _S6345 * - _S6552; + float _S6554 = 2.0f * (_S6244.primal_0 * _S6547); + float _S6555 = 2.0f * (_S6244.differential_0 * _S6549 + _S6244.primal_0 * _S6552); + DiffPair_1 _S6556; + (&_S6556)->primal_0 = _S6347; + (&_S6556)->differential_0 = _S6286; + DiffPair_float_0 _S6557; + (&_S6557)->primal_0 = _S6555; + (&_S6557)->differential_0 = _S6554; + s_bwd_prop_d_sin_0(&_S6556, &_S6557); + float _S6558 = 0.5f * _S6556.differential_0.primal_0; + float _S6559 = _S6548 + _S6548 + _S6551 + _S6553; + k_24 = 0.5f * _S6556.differential_0.differential_0; + _S6337 = _S6558; + _S6338 = 0.0f; + _S6339 = _S6550; + _S6340 = _S6559; + } + DiffPair_1 _S6560; + (&_S6560)->primal_0 = _S6245; + (&_S6560)->differential_0 = _S6286; + DiffPair_1 _S6561; + (&_S6561)->primal_0 = _S6224; + (&_S6561)->differential_0 = _S6286; + DiffPair_float_0 _S6562; + (&_S6562)->primal_0 = _S6337; + (&_S6562)->differential_0 = k_24; + s_bwd_prop_d_atan2_0(&_S6560, &_S6561, &_S6562); + float _S6563 = _S6561.differential_0.primal_0 + _S6338; + float _S6564 = _S6560.differential_0.differential_0 + _S6339; + float _S6565 = _S6560.differential_0.primal_0 + _S6340; + DiffPair_0 _S6566; + (&_S6566)->primal_0 = _S6242; + (&_S6566)->differential_0 = _S6215; + DiffPair_float_0 _S6567; + (&_S6567)->primal_0 = _S6565; + (&_S6567)->differential_0 = _S6564; + s_bwd_prop_s_fwd_length_impl_0(&_S6566, &_S6567); + float2 _S6568 = _S6566.differential_0.primal_0 + _S6536; + float3 _S6569 = make_float3 (_S6568.x, _S6568.y, _S6563); + float2 _S6570 = make_float2 (fx_43 * _S6483.rows[int(0)].x, fy_43 * _S6483.rows[int(1)].x); + DiffPair_0 _S6571; + (&_S6571)->primal_0 = _S6333; + (&_S6571)->differential_0 = _S6215; + FixedArray _S6572 = dist_coeffs_42; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6573; + (&_S6573)->primal_0 = _S6262; + (&_S6573)->differential_0 = _S6570; + s_bwd_prop_s_fwd_DistOpenCV_distort_0(&_S6571, &_S6572, &_S6573); + DiffPair_0 _S6574 = _S6571; + float3 _S6575 = _S6569 + _S6525; + float2 _S6576 = _S6217 * _S6574.differential_0.differential_0; + float2 _S6577 = _S6218 * _S6574.differential_0.differential_0; + float2 _S6578 = _S6217 * _S6574.differential_0.primal_0; + float _S6579 = _S6577.x + _S6577.y + _S6578.x + _S6578.y; + float _S6580 = _S6576.x + _S6576.y; + float2 _S6581 = _S6330 * _S6574.differential_0.differential_0 + _S6329 * _S6574.differential_0.primal_0; + if(_S6228) + { + float _S6582 = _S6580 / _S6301; + float _S6583 = _S6303 * _S6582; + float _S6584 = _S6222 * (_S6302 * - _S6582); + float _S6585 = _S6579 / _S6303; + float _S6586 = 0.0416666679084301f * - (_S6222 * _S6583); + float _S6587 = _S6586 + _S6586; + float _S6588 = _S6227.primal_0 * (0.0416666679084301f * - (_S6222 * _S6585)); + float _S6589 = _S6584 + _S6584 + _S6305 * _S6583 + _S6304 * - _S6585; + float _S6590 = _S6227.differential_0 * _S6587 + _S6588 + _S6588; + k_24 = _S6227.primal_0 * _S6587; + _S6301 = _S6590; + _S6302 = _S6589; + _S6303 = 0.0f; + _S6304 = 0.0f; + } + else + { + float _S6591 = _S6580 / _S6306; + float _S6592 = _S6308 * _S6591; + float _S6593 = _S6221.primal_0 * (_S6307 * - _S6591); + float _S6594 = - _S6592; + float _S6595 = _S6309 * _S6594; + float _S6596 = _S6310 * _S6592; + float _S6597 = _S6579 / _S6308; + float _S6598 = _S6309 * - _S6597; + float _S6599 = 2.0f * (_S6221.primal_0 * _S6592); + float _S6600 = 2.0f * (_S6221.differential_0 * _S6594 + _S6221.primal_0 * _S6597); + DiffPair_1 _S6601; + (&_S6601)->primal_0 = _S6311; + (&_S6601)->differential_0 = _S6286; + DiffPair_float_0 _S6602; + (&_S6602)->primal_0 = _S6600; + (&_S6602)->differential_0 = _S6599; + s_bwd_prop_d_sin_0(&_S6601, &_S6602); + float _S6603 = 0.5f * _S6601.differential_0.primal_0; + float _S6604 = _S6593 + _S6593 + _S6596 + _S6598; + k_24 = 0.5f * _S6601.differential_0.differential_0; + _S6301 = _S6603; + _S6302 = 0.0f; + _S6303 = _S6595; + _S6304 = _S6604; + } + DiffPair_1 _S6605; + (&_S6605)->primal_0 = _S6223; + (&_S6605)->differential_0 = _S6286; + DiffPair_1 _S6606; + (&_S6606)->primal_0 = _S6224; + (&_S6606)->differential_0 = _S6286; + DiffPair_float_0 _S6607; + (&_S6607)->primal_0 = _S6301; + (&_S6607)->differential_0 = k_24; + s_bwd_prop_d_atan2_0(&_S6605, &_S6606, &_S6607); + float _S6608 = _S6606.differential_0.primal_0 + _S6302; + float _S6609 = _S6605.differential_0.differential_0 + _S6303; + float _S6610 = _S6605.differential_0.primal_0 + _S6304; + DiffPair_0 _S6611; + (&_S6611)->primal_0 = _S6219; + (&_S6611)->differential_0 = _S6215; + DiffPair_float_0 _S6612; + (&_S6612)->primal_0 = _S6610; + (&_S6612)->differential_0 = _S6609; + s_bwd_prop_s_fwd_length_impl_0(&_S6611, &_S6612); + float2 _S6613 = _S6611.differential_0.primal_0 + _S6581; + float3 _S6614 = make_float3 (_S6613.x, _S6613.y, _S6608); + float _S6615 = length_0(_S6217); + float _S6616 = s_primal_ctx_atan2_0(_S6615, _S6222); + bool _S6617 = _S6615 < 9.99999997475242708e-07f; + if(_S6617) + { + float _S6618 = 1.0f - _S6616 * _S6616 / 24.0f; + float _S6619 = _S6222 * _S6222; + k_24 = _S6618 / _S6222; + _S6301 = _S6619; + _S6302 = _S6618; + _S6303 = 0.0f; + _S6304 = 0.0f; + _S6305 = 0.0f; + } + else + { + float _S6620 = 0.5f * _S6616; + float _S6621 = 2.0f * s_primal_ctx_sin_0(_S6620); + float _S6622 = _S6615 * _S6615; + k_24 = _S6621 / _S6615; + _S6301 = 0.0f; + _S6302 = 0.0f; + _S6303 = _S6622; + _S6304 = _S6621; + _S6305 = _S6620; + } + float2 _S6623 = make_float2 (k_24); + float2 _S6624 = _S6217 * make_float2 (k_24); + float2 _S6625 = make_float2 (fx_43 * v_mean2d_8.x, fy_43 * v_mean2d_8.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6626; + (&_S6626)->primal_0 = _S6624; + (&_S6626)->differential_0 = _S6214; + FixedArray _S6627 = dist_coeffs_42; + s_bwd_prop_DistOpenCV_distort_0(&_S6626, &_S6627, _S6625); + float2 _S6628 = _S6217 * _S6626.differential_0; + float2 _S6629 = _S6623 * _S6626.differential_0; + float _S6630 = _S6628.x + _S6628.y; + if(_S6617) + { + float _S6631 = _S6630 / _S6301; + float _S6632 = _S6302 * - _S6631; + float _S6633 = _S6616 * (0.0416666679084301f * - (_S6222 * _S6631)); + k_24 = _S6633 + _S6633; + _S6301 = _S6632; + _S6302 = 0.0f; + } + else + { + float _S6634 = _S6630 / _S6303; + float _S6635 = _S6304 * - _S6634; + float _S6636 = 2.0f * (_S6615 * _S6634); + DiffPair_float_0 _S6637; + (&_S6637)->primal_0 = _S6305; + (&_S6637)->differential_0 = 0.0f; + s_bwd_prop_sin_0(&_S6637, _S6636); + k_24 = 0.5f * _S6637.differential_0; + _S6301 = 0.0f; + _S6302 = _S6635; + } + DiffPair_float_0 _S6638; + (&_S6638)->primal_0 = _S6615; + (&_S6638)->differential_0 = 0.0f; + DiffPair_float_0 _S6639; + (&_S6639)->primal_0 = _S6222; + (&_S6639)->differential_0 = 0.0f; + s_bwd_prop_atan2_0(&_S6638, &_S6639, k_24); + float _S6640 = _S6639.differential_0 + _S6301; + float _S6641 = _S6638.differential_0 + _S6302; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6642; + (&_S6642)->primal_0 = _S6217; + (&_S6642)->differential_0 = _S6214; + s_bwd_length_impl_2(&_S6642, _S6641); + float2 _S6643 = _S6642.differential_0 + _S6629; + float3 _S6644 = make_float3 (_S6643.x, _S6643.y, _S6640); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6645; + (&_S6645)->primal_0 = _S6298; + (&_S6645)->differential_0 = _S6480; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6646; + (&_S6646)->primal_0 = _S6299; + (&_S6646)->differential_0 = _S6480; + s_bwd_prop_mul_2(&_S6645, &_S6646, _S6482.differential_0); + Matrix _S6647 = transpose_3(_S6646.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6648; + (&_S6648)->primal_0 = R_30; + (&_S6648)->differential_0 = _S6480; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6649; + (&_S6649)->primal_0 = _S6297; + (&_S6649)->differential_0 = _S6480; + s_bwd_prop_mul_2(&_S6648, &_S6649, _S6645.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6650; + (&_S6650)->primal_0 = _S6295; + (&_S6650)->differential_0 = _S6480; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6651; + (&_S6651)->primal_0 = _S6296; + (&_S6651)->differential_0 = _S6480; + s_bwd_prop_mul_2(&_S6650, &_S6651, _S6649.differential_0); + Matrix _S6652 = _S6650.differential_0 + transpose_3(_S6651.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6653; + (&_S6653)->primal_0 = _S6294; + (&_S6653)->differential_0 = _S6480; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6654; + (&_S6654)->primal_0 = S_8; + (&_S6654)->differential_0 = _S6480; + s_bwd_prop_mul_2(&_S6653, &_S6654, _S6652); + Matrix _S6655 = transpose_3(_S6653.differential_0); + float _S6656 = 2.0f * - _S6655.rows[int(2)].z; + float _S6657 = 2.0f * _S6655.rows[int(2)].y; + float _S6658 = 2.0f * _S6655.rows[int(2)].x; + float _S6659 = 2.0f * _S6655.rows[int(1)].z; + float _S6660 = 2.0f * - _S6655.rows[int(1)].y; + float _S6661 = 2.0f * _S6655.rows[int(1)].x; + float _S6662 = 2.0f * _S6655.rows[int(0)].z; + float _S6663 = 2.0f * _S6655.rows[int(0)].y; + float _S6664 = 2.0f * - _S6655.rows[int(0)].x; + float _S6665 = - _S6661 + _S6663; + float _S6666 = _S6658 + - _S6662; + float _S6667 = - _S6657 + _S6659; + float _S6668 = _S6657 + _S6659; + float _S6669 = _S6658 + _S6662; + float _S6670 = _S6661 + _S6663; + float _S6671 = _S6291.w * (_S6660 + _S6664); + float _S6672 = _S6291.z * (_S6656 + _S6664); + float _S6673 = _S6291.y * (_S6656 + _S6660); + float _S6674 = _S6291.x * _S6665 + _S6291.z * _S6668 + _S6291.y * _S6669 + _S6671 + _S6671; + float _S6675 = _S6291.x * _S6666 + _S6291.w * _S6668 + _S6291.y * _S6670 + _S6672 + _S6672; + float _S6676 = _S6291.x * _S6667 + _S6291.w * _S6669 + _S6291.z * _S6670 + _S6673 + _S6673; + float _S6677 = _S6291.w * _S6665 + _S6291.z * _S6666 + _S6291.y * _S6667; + float3 _S6678 = _S6425; + *&((&_S6678)->z) = _S6654.differential_0.rows[int(2)].z; + *&((&_S6678)->y) = _S6654.differential_0.rows[int(1)].y; + *&((&_S6678)->x) = _S6654.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6679; + (&_S6679)->primal_0 = scale_30; + (&_S6679)->differential_0 = _S6425; + s_bwd_prop_exp_1(&_S6679, _S6678); + float4 _S6680 = make_float4 (0.0f); + float4 _S6681 = _S6680; + *&((&_S6681)->w) = _S6674; + *&((&_S6681)->z) = _S6675; + *&((&_S6681)->y) = _S6676; + *&((&_S6681)->x) = _S6677; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S6682; + (&_S6682)->primal_0 = quat_30; + (&_S6682)->differential_0 = _S6680; + s_bwd_normalize_impl_0(&_S6682, _S6681); + float _S6683 = - (s_diff_k_14 / _S6290); + DiffPair_float_0 _S6684; + (&_S6684)->primal_0 = _S6287; + (&_S6684)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S6684, _S6683); + float _S6685 = - _S6684.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6686; + (&_S6686)->primal_0 = mean_c_30; + (&_S6686)->differential_0 = _S6425; + s_bwd_length_impl_0(&_S6686, v_depth_8); + float3 _S6687 = _S6614 + _S6644 + _S6686.differential_0 + _S6575; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6688; + (&_S6688)->primal_0 = R_30; + (&_S6688)->differential_0 = _S6480; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6689; + (&_S6689)->primal_0 = mean_31; + (&_S6689)->differential_0 = _S6425; + s_bwd_prop_mul_3(&_S6688, &_S6689, _S6687); + Matrix _S6690 = _S6647 + _S6648.differential_0 + _S6688.differential_0; + float _S6691 = _S6685 + _S6432.differential_0; + float3 _S6692 = _S6679.differential_0 + _S6431.differential_0; + *v_mean_8 = *v_mean_8 + (_S6689.differential_0 + _S6430.differential_0); + *v_quat_8 = *v_quat_8 + _S6682.differential_0; + *v_scale_8 = *v_scale_8 + _S6692; + *v_in_opacity_8 = *v_in_opacity_8 + _S6691; + *v_R_8 = *v_R_8 + _S6690; + *v_t_8 = *v_t_8 + _S6687; return; } -struct s_bwd_prop_DiffProjection3DGS_3dgut_fisheye_projection_Intermediates_0 +struct s_bwd_prop_DiffProjection3DGS_3dgs_equisolid_prism_projection_Intermediates_0 { - float2 _S3394; - float2 _S3395; - float2 _S3396; - float2 _S3397; - float2 _S3398; - float2 _S3399; - float2 _S3400; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6693; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6694; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6695; }; -inline __device__ void projection_3dgut_fisheye_vjp(bool antialiased_13, float3 mean_14, float4 quat_13, float3 scale_13, float in_opacity_13, Matrix R_13, float3 t_13, float fx_17, float fy_17, float cx_14, float cy_14, FixedArray dist_coeffs_17, uint image_width_13, uint image_height_13, float2 v_mean2d_5, float v_depth_5, float3 v_conic_5, float v_opacity_5, float3 * v_mean_5, float4 * v_quat_5, float3 * v_scale_5, float * v_in_opacity_5, Matrix * v_R_5, float3 * v_t_5) +inline __device__ void projection_3dgs_equisolid_prism_vjp(bool antialiased_31, float3 mean_32, float4 quat_31, float3 scale_31, float in_opacity_31, Matrix R_31, float3 t_31, float fx_44, float fy_44, float cx_35, float cy_35, FixedArray dist_coeffs_43, uint image_width_31, uint image_height_31, float2 v_mean2d_9, float v_depth_9, float3 v_conic_9, float v_opacity_9, float3 * v_mean_9, float4 * v_quat_9, float3 * v_scale_9, float * v_in_opacity_9, Matrix * v_R_9, float3 * v_t_9) { - float2 _S3401 = make_float2 (0.0f); - s_bwd_prop_DiffProjection3DGS_3dgut_fisheye_projection_Intermediates_0 _S3402; - (&_S3402)->_S3394 = _S3401; - (&_S3402)->_S3395 = _S3401; - (&_S3402)->_S3396 = _S3401; - (&_S3402)->_S3397 = _S3401; - (&_S3402)->_S3398 = _S3401; - (&_S3402)->_S3399 = _S3401; - (&_S3402)->_S3400 = _S3401; - (&_S3402)->_S3394 = _S3401; - (&_S3402)->_S3395 = _S3401; - (&_S3402)->_S3396 = _S3401; - (&_S3402)->_S3397 = _S3401; - (&_S3402)->_S3398 = _S3401; - (&_S3402)->_S3399 = _S3401; - (&_S3402)->_S3400 = _S3401; - float3 _S3403 = make_float3 (0.0f); - float3 _S3404 = s_primal_ctx_exp_1(scale_13); - float4 _S3405 = normalize_0(quat_13); - float _S3406 = _S3405.y; - float x2_13 = _S3406 * _S3406; - float y2_13 = _S3405.z * _S3405.z; - float z2_13 = _S3405.w * _S3405.w; - float xy_13 = _S3405.y * _S3405.z; - float xz_13 = _S3405.y * _S3405.w; - float yz_13 = _S3405.z * _S3405.w; - float wx_13 = _S3405.x * _S3405.y; - float wy_13 = _S3405.x * _S3405.z; - float wz_13 = _S3405.x * _S3405.w; - Matrix _S3407 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_13 + z2_13), 2.0f * (xy_13 + wz_13), 2.0f * (xz_13 - wy_13), 2.0f * (xy_13 - wz_13), 1.0f - 2.0f * (x2_13 + z2_13), 2.0f * (yz_13 + wx_13), 2.0f * (xz_13 + wy_13), 2.0f * (yz_13 - wx_13), 1.0f - 2.0f * (x2_13 + y2_13)))); - FixedArray _S3408 = { - _S3403, _S3403, _S3403, _S3403, _S3403, _S3403, _S3403 - }; - FixedArray _S3409 = { - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f - }; - SigmaPoints_0 _S3410; - (&_S3410)->p_0 = _S3408; - (&_S3410)->w_mean_0 = _S3409; - (&_S3410)->w_cov_0 = _S3409; - (&_S3410)->p_0[int(0)] = mean_14; - SigmaPoints_0 _S3411 = _S3410; - (&_S3411)->w_mean_0[int(0)] = 0.0f; - (&_S3411)->w_cov_0[int(0)] = 2.0f; - float _S3412 = s_primal_ctx_sqrt_0(3.0f); - float _S3413 = _S3412 * _S3404.x; - float3 delta_15 = make_float3 (_S3413) * _S3407.rows[0U]; - float3 _S3414 = mean_14 + delta_15; - (&_S3411)->p_0[1U] = _S3414; - float3 _S3415 = mean_14 - delta_15; - (&_S3411)->p_0[4U] = _S3415; - float _S3416 = _S3412 * _S3404.y; - float3 delta_16 = make_float3 (_S3416) * _S3407.rows[1U]; - float3 _S3417 = mean_14 + delta_16; - (&_S3411)->p_0[2U] = _S3417; - float3 _S3418 = mean_14 - delta_16; - (&_S3411)->p_0[5U] = _S3418; - float _S3419 = _S3412 * _S3404.z; - float3 delta_17 = make_float3 (_S3419) * _S3407.rows[2U]; - float3 _S3420 = mean_14 + delta_17; - (&_S3411)->p_0[3U] = _S3420; - float3 _S3421 = mean_14 - delta_17; - (&_S3411)->p_0[6U] = _S3421; - (&_S3411)->w_mean_0[1U] = 0.1666666716337204f; - SigmaPoints_0 _S3422 = _S3411; - (&_S3422)->w_cov_0[1U] = 0.1666666716337204f; - SigmaPoints_0 _S3423 = _S3422; - (&_S3423)->w_mean_0[2U] = 0.1666666716337204f; - SigmaPoints_0 _S3424 = _S3423; - (&_S3424)->w_cov_0[2U] = 0.1666666716337204f; - SigmaPoints_0 _S3425 = _S3424; - (&_S3425)->w_mean_0[3U] = 0.1666666716337204f; - SigmaPoints_0 _S3426 = _S3425; - (&_S3426)->w_cov_0[3U] = 0.1666666716337204f; - SigmaPoints_0 _S3427 = _S3426; - (&_S3427)->w_mean_0[4U] = 0.1666666716337204f; - SigmaPoints_0 _S3428 = _S3427; - (&_S3428)->w_cov_0[4U] = 0.1666666716337204f; - SigmaPoints_0 _S3429 = _S3428; - (&_S3429)->w_mean_0[5U] = 0.1666666716337204f; - SigmaPoints_0 _S3430 = _S3429; - (&_S3430)->w_cov_0[5U] = 0.1666666716337204f; - SigmaPoints_0 _S3431 = _S3430; - (&_S3431)->w_mean_0[6U] = 0.1666666716337204f; - SigmaPoints_0 _S3432 = _S3431; - (&_S3432)->w_cov_0[6U] = 0.1666666716337204f; - SigmaPoints_0 _S3433 = _S3410; - float3 _S3434 = s_primal_ctx_mul_0(R_13, _S3410.p_0[0U]) + t_13; - _S3410 = _S3432; - (&_S3410)->p_0[0U] = _S3434; - SigmaPoints_0 _S3435 = _S3410; - (&_S3410)->p_0[1U] = s_primal_ctx_mul_0(R_13, _S3414) + t_13; - SigmaPoints_0 _S3436 = _S3410; - (&_S3410)->p_0[2U] = s_primal_ctx_mul_0(R_13, _S3417) + t_13; - SigmaPoints_0 _S3437 = _S3410; - (&_S3410)->p_0[3U] = s_primal_ctx_mul_0(R_13, _S3420) + t_13; - SigmaPoints_0 _S3438 = _S3410; - (&_S3410)->p_0[4U] = s_primal_ctx_mul_0(R_13, _S3415) + t_13; - SigmaPoints_0 _S3439 = _S3410; - (&_S3410)->p_0[5U] = s_primal_ctx_mul_0(R_13, _S3418) + t_13; - SigmaPoints_0 _S3440 = _S3410; - (&_S3410)->p_0[6U] = s_primal_ctx_mul_0(R_13, _S3421) + t_13; - SigmaPoints_0 _S3441 = _S3410; - float2 _S3442 = float2 {_S3435.p_0[int(0)].x, _S3435.p_0[int(0)].y}; - float _S3443 = length_0(_S3442); - float _S3444 = _S3435.p_0[int(0)].z; - float _S3445 = s_primal_ctx_atan2_0(_S3443, _S3444); - float k_8; - if(_S3445 < 0.00100000004749745f) + float2 _S6696 = make_float2 (0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6697 = { _S6696, _S6696 }; + s_bwd_prop_DiffProjection3DGS_3dgs_equisolid_prism_projection_Intermediates_0 _S6698; + (&_S6698)->_S6693 = _S6697; + (&_S6698)->_S6694 = _S6697; + (&_S6698)->_S6695 = _S6697; + (&(&_S6698)->_S6693)->primal_0 = _S6696; + (&(&_S6698)->_S6693)->differential_0 = _S6696; + (&(&_S6698)->_S6694)->primal_0 = _S6696; + (&(&_S6698)->_S6694)->differential_0 = _S6696; + (&(&_S6698)->_S6695)->primal_0 = _S6696; + (&(&_S6698)->_S6695)->differential_0 = _S6696; + float3 mean_c_31 = s_primal_ctx_mul_0(R_31, mean_32) + t_31; + float2 _S6699 = float2 {mean_c_31.x, mean_c_31.y}; + float2 _S6700 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6701 = { _S6699, _S6700 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6702; + (&_S6702)->primal_0 = _S6699; + (&_S6702)->differential_0 = _S6700; + DiffPair_float_0 _S6703 = s_primal_ctx_s_fwd_length_impl_0(&_S6702); + float _S6704 = mean_c_31.z; + DiffPair_float_0 _S6705 = { _S6703.primal_0, _S6703.differential_0 }; + DiffPair_float_0 _S6706 = { _S6704, 0.0f }; + DiffPair_float_0 _S6707; + (&_S6707)->primal_0 = _S6703.primal_0; + (&_S6707)->differential_0 = _S6703.differential_0; + DiffPair_float_0 _S6708; + (&_S6708)->primal_0 = _S6704; + (&_S6708)->differential_0 = 0.0f; + DiffPair_float_0 _S6709 = s_primal_ctx_d_atan2_0(&_S6707, &_S6708); + bool _S6710 = (_S6703.primal_0) < 9.99999997475242708e-07f; + float k_25; + float s_diff_k_15; + if(_S6710) { - k_8 = (1.0f - _S3445 * _S3445 / 3.0f) / _S3444; + float _S6711 = _S6709.differential_0 * _S6709.primal_0; + float _S6712 = (0.0f - (_S6711 + _S6711) * 0.0416666679084301f) * _S6704 / (_S6704 * _S6704); + k_25 = (1.0f - _S6709.primal_0 * _S6709.primal_0 / 24.0f) / _S6704; + s_diff_k_15 = _S6712; } else { - k_8 = _S3445 / _S3443; + float _S6713 = _S6709.differential_0 * 0.5f; + DiffPair_float_0 _S6714; + (&_S6714)->primal_0 = 0.5f * _S6709.primal_0; + (&_S6714)->differential_0 = _S6713; + DiffPair_float_0 _S6715 = s_primal_ctx_d_sin_0(&_S6714); + float _S6716 = 2.0f * _S6715.primal_0; + float _S6717 = (_S6715.differential_0 * 2.0f * _S6703.primal_0 - _S6716 * _S6703.differential_0) / (_S6703.primal_0 * _S6703.primal_0); + k_25 = _S6716 / _S6703.primal_0; + s_diff_k_15 = _S6717; } - float2 _S3446 = _S3442 * make_float2 (k_8); - float u_91 = _S3446.x; - float v_91 = _S3446.y; - float r2_91 = u_91 * u_91 + v_91 * v_91; - float _S3447 = 2.0f * dist_coeffs_17[int(4)]; - float _S3448 = 2.0f * dist_coeffs_17[int(5)]; - float2 _S3449 = _S3446 * make_float2 (1.0f + r2_91 * (dist_coeffs_17[int(0)] + r2_91 * (dist_coeffs_17[int(1)] + r2_91 * (dist_coeffs_17[int(2)] + r2_91 * dist_coeffs_17[int(3)])))) + make_float2 (_S3447 * u_91 * v_91 + dist_coeffs_17[int(5)] * (r2_91 + 2.0f * u_91 * u_91) + dist_coeffs_17[int(6)] * r2_91, _S3448 * u_91 * v_91 + dist_coeffs_17[int(4)] * (r2_91 + 2.0f * v_91 * v_91) + dist_coeffs_17[int(7)] * r2_91); - float2 _S3450 = _S3449 + make_float2 (dist_coeffs_17[int(8)] * _S3449.x + dist_coeffs_17[int(9)] * _S3449.y, 0.0f); - (&_S3402)->_S3394 = make_float2 (fx_17 * _S3450.x + cx_14, fy_17 * _S3450.y + cy_14); - float2 _S3451 = float2 {_S3436.p_0[int(1)].x, _S3436.p_0[int(1)].y}; - float _S3452 = length_0(_S3451); - float _S3453 = _S3436.p_0[int(1)].z; - float _S3454 = s_primal_ctx_atan2_0(_S3452, _S3453); - if(_S3454 < 0.00100000004749745f) + float2 _S6718 = _S6699 * make_float2 (k_25); + float2 _S6719 = _S6700 * make_float2 (k_25) + make_float2 (s_diff_k_15) * _S6699; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6720; + (&_S6720)->primal_0 = _S6718; + (&_S6720)->differential_0 = _S6719; + FixedArray _S6721 = dist_coeffs_43; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6722 = s_primal_ctx_s_fwd_DistThinPrism_distort_0(&_S6720, &_S6721); + (&_S6698)->_S6693 = _S6722; + float2 _S6723 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6724 = { _S6699, _S6723 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6725; + (&_S6725)->primal_0 = _S6699; + (&_S6725)->differential_0 = _S6723; + DiffPair_float_0 _S6726 = s_primal_ctx_s_fwd_length_impl_0(&_S6725); + DiffPair_float_0 _S6727 = { _S6726.primal_0, _S6726.differential_0 }; + DiffPair_float_0 _S6728; + (&_S6728)->primal_0 = _S6726.primal_0; + (&_S6728)->differential_0 = _S6726.differential_0; + DiffPair_float_0 _S6729; + (&_S6729)->primal_0 = _S6704; + (&_S6729)->differential_0 = 0.0f; + DiffPair_float_0 _S6730 = s_primal_ctx_d_atan2_0(&_S6728, &_S6729); + bool _S6731 = (_S6726.primal_0) < 9.99999997475242708e-07f; + if(_S6731) { - k_8 = (1.0f - _S3454 * _S3454 / 3.0f) / _S3453; + float _S6732 = _S6730.differential_0 * _S6730.primal_0; + float _S6733 = (0.0f - (_S6732 + _S6732) * 0.0416666679084301f) * _S6704 / (_S6704 * _S6704); + k_25 = (1.0f - _S6730.primal_0 * _S6730.primal_0 / 24.0f) / _S6704; + s_diff_k_15 = _S6733; } else { - k_8 = _S3454 / _S3452; + float _S6734 = _S6730.differential_0 * 0.5f; + DiffPair_float_0 _S6735; + (&_S6735)->primal_0 = 0.5f * _S6730.primal_0; + (&_S6735)->differential_0 = _S6734; + DiffPair_float_0 _S6736 = s_primal_ctx_d_sin_0(&_S6735); + float _S6737 = 2.0f * _S6736.primal_0; + float _S6738 = (_S6736.differential_0 * 2.0f * _S6726.primal_0 - _S6737 * _S6726.differential_0) / (_S6726.primal_0 * _S6726.primal_0); + k_25 = _S6737 / _S6726.primal_0; + s_diff_k_15 = _S6738; } - float2 _S3455 = _S3451 * make_float2 (k_8); - float u_92 = _S3455.x; - float v_92 = _S3455.y; - float r2_92 = u_92 * u_92 + v_92 * v_92; - float2 _S3456 = _S3455 * make_float2 (1.0f + r2_92 * (dist_coeffs_17[int(0)] + r2_92 * (dist_coeffs_17[int(1)] + r2_92 * (dist_coeffs_17[int(2)] + r2_92 * dist_coeffs_17[int(3)])))) + make_float2 (_S3447 * u_92 * v_92 + dist_coeffs_17[int(5)] * (r2_92 + 2.0f * u_92 * u_92) + dist_coeffs_17[int(6)] * r2_92, _S3448 * u_92 * v_92 + dist_coeffs_17[int(4)] * (r2_92 + 2.0f * v_92 * v_92) + dist_coeffs_17[int(7)] * r2_92); - float2 _S3457 = _S3456 + make_float2 (dist_coeffs_17[int(8)] * _S3456.x + dist_coeffs_17[int(9)] * _S3456.y, 0.0f); - (&_S3402)->_S3395 = make_float2 (fx_17 * _S3457.x + cx_14, fy_17 * _S3457.y + cy_14); - float2 _S3458 = float2 {_S3437.p_0[int(2)].x, _S3437.p_0[int(2)].y}; - float _S3459 = length_0(_S3458); - float _S3460 = _S3437.p_0[int(2)].z; - float _S3461 = s_primal_ctx_atan2_0(_S3459, _S3460); - if(_S3461 < 0.00100000004749745f) + float2 _S6739 = _S6699 * make_float2 (k_25); + float2 _S6740 = _S6723 * make_float2 (k_25) + make_float2 (s_diff_k_15) * _S6699; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6741; + (&_S6741)->primal_0 = _S6739; + (&_S6741)->differential_0 = _S6740; + FixedArray _S6742 = dist_coeffs_43; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6743 = s_primal_ctx_s_fwd_DistThinPrism_distort_0(&_S6741, &_S6742); + (&_S6698)->_S6694 = _S6743; + float2 _S6744 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6745 = { _S6699, _S6744 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6746; + (&_S6746)->primal_0 = _S6699; + (&_S6746)->differential_0 = _S6744; + DiffPair_float_0 _S6747 = s_primal_ctx_s_fwd_length_impl_0(&_S6746); + DiffPair_float_0 _S6748 = { _S6747.primal_0, _S6747.differential_0 }; + DiffPair_float_0 _S6749 = { _S6704, 1.0f }; + DiffPair_float_0 _S6750; + (&_S6750)->primal_0 = _S6747.primal_0; + (&_S6750)->differential_0 = _S6747.differential_0; + DiffPair_float_0 _S6751; + (&_S6751)->primal_0 = _S6704; + (&_S6751)->differential_0 = 1.0f; + DiffPair_float_0 _S6752 = s_primal_ctx_d_atan2_0(&_S6750, &_S6751); + bool _S6753 = (_S6747.primal_0) < 9.99999997475242708e-07f; + if(_S6753) { - k_8 = (1.0f - _S3461 * _S3461 / 3.0f) / _S3460; + float _S6754 = _S6752.differential_0 * _S6752.primal_0; + float _S6755 = 1.0f - _S6752.primal_0 * _S6752.primal_0 / 24.0f; + float _S6756 = ((0.0f - (_S6754 + _S6754) * 0.0416666679084301f) * _S6704 - _S6755) / (_S6704 * _S6704); + k_25 = _S6755 / _S6704; + s_diff_k_15 = _S6756; } else { - k_8 = _S3461 / _S3459; + float _S6757 = _S6752.differential_0 * 0.5f; + DiffPair_float_0 _S6758; + (&_S6758)->primal_0 = 0.5f * _S6752.primal_0; + (&_S6758)->differential_0 = _S6757; + DiffPair_float_0 _S6759 = s_primal_ctx_d_sin_0(&_S6758); + float _S6760 = 2.0f * _S6759.primal_0; + float _S6761 = (_S6759.differential_0 * 2.0f * _S6747.primal_0 - _S6760 * _S6747.differential_0) / (_S6747.primal_0 * _S6747.primal_0); + k_25 = _S6760 / _S6747.primal_0; + s_diff_k_15 = _S6761; } - float2 _S3462 = _S3458 * make_float2 (k_8); - float u_93 = _S3462.x; - float v_93 = _S3462.y; - float r2_93 = u_93 * u_93 + v_93 * v_93; - float2 _S3463 = _S3462 * make_float2 (1.0f + r2_93 * (dist_coeffs_17[int(0)] + r2_93 * (dist_coeffs_17[int(1)] + r2_93 * (dist_coeffs_17[int(2)] + r2_93 * dist_coeffs_17[int(3)])))) + make_float2 (_S3447 * u_93 * v_93 + dist_coeffs_17[int(5)] * (r2_93 + 2.0f * u_93 * u_93) + dist_coeffs_17[int(6)] * r2_93, _S3448 * u_93 * v_93 + dist_coeffs_17[int(4)] * (r2_93 + 2.0f * v_93 * v_93) + dist_coeffs_17[int(7)] * r2_93); - float2 _S3464 = _S3463 + make_float2 (dist_coeffs_17[int(8)] * _S3463.x + dist_coeffs_17[int(9)] * _S3463.y, 0.0f); - (&_S3402)->_S3396 = make_float2 (fx_17 * _S3464.x + cx_14, fy_17 * _S3464.y + cy_14); - float2 _S3465 = float2 {_S3438.p_0[int(3)].x, _S3438.p_0[int(3)].y}; - float _S3466 = length_0(_S3465); - float _S3467 = _S3438.p_0[int(3)].z; - float _S3468 = s_primal_ctx_atan2_0(_S3466, _S3467); - if(_S3468 < 0.00100000004749745f) + float2 _S6762 = _S6699 * make_float2 (k_25); + float2 _S6763 = make_float2 (s_diff_k_15) * _S6699; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6764; + (&_S6764)->primal_0 = _S6762; + (&_S6764)->differential_0 = _S6763; + FixedArray _S6765 = dist_coeffs_43; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6766 = s_primal_ctx_s_fwd_DistThinPrism_distort_0(&_S6764, &_S6765); + (&_S6698)->_S6695 = _S6766; + s_bwd_prop_DiffProjection3DGS_3dgs_equisolid_prism_projection_Intermediates_0 _S6767 = _S6698; + DiffPair_float_0 _S6768 = { 0.0f, 0.0f }; + float _S6769 = - in_opacity_31; + float _S6770 = 1.0f + s_primal_ctx_exp_0(_S6769); + float _S6771 = 1.0f / _S6770; + float _S6772 = _S6770 * _S6770; + float4 _S6773 = normalize_0(quat_31); + float3 _S6774 = s_primal_ctx_exp_1(scale_31); + float _S6775 = _S6773.y; + float x2_31 = _S6775 * _S6775; + float y2_31 = _S6773.z * _S6773.z; + float z2_31 = _S6773.w * _S6773.w; + float xy_31 = _S6773.y * _S6773.z; + float xz_31 = _S6773.y * _S6773.w; + float yz_31 = _S6773.z * _S6773.w; + float wx_31 = _S6773.x * _S6773.y; + float wy_31 = _S6773.x * _S6773.z; + float wz_31 = _S6773.x * _S6773.w; + Matrix _S6776 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_31 + z2_31), 2.0f * (xy_31 + wz_31), 2.0f * (xz_31 - wy_31), 2.0f * (xy_31 - wz_31), 1.0f - 2.0f * (x2_31 + z2_31), 2.0f * (yz_31 + wx_31), 2.0f * (xz_31 + wy_31), 2.0f * (yz_31 - wx_31), 1.0f - 2.0f * (x2_31 + y2_31))); + Matrix S_9 = makeMatrix (_S6774.x, 0.0f, 0.0f, 0.0f, _S6774.y, 0.0f, 0.0f, 0.0f, _S6774.z); + Matrix _S6777 = s_primal_ctx_mul_1(_S6776, S_9); + Matrix _S6778 = transpose_3(_S6777); + Matrix _S6779 = s_primal_ctx_mul_1(_S6777, _S6778); + Matrix _S6780 = s_primal_ctx_mul_1(R_31, _S6779); + Matrix _S6781 = transpose_3(R_31); + Matrix _S6782 = s_primal_ctx_mul_1(_S6780, _S6781); + Matrix J_41 = makeMatrix (0.0f); + float _S6783; + float _S6784; + float _S6785; + float _S6786; + float _S6787; + float _S6788; + float _S6789; + float _S6790; + float _S6791; + float _S6792; + DiffPair_float_0 _S6793; + if(_S6710) { - k_8 = (1.0f - _S3468 * _S3468 / 3.0f) / _S3467; + float _S6794 = _S6709.differential_0 * _S6709.primal_0; + float _S6795 = 1.0f - _S6709.primal_0 * _S6709.primal_0 / 24.0f; + float _S6796 = 0.0f - (_S6794 + _S6794) * 0.0416666679084301f; + float _S6797 = _S6704 * _S6704; + float _S6798 = _S6796 * _S6704; + float _S6799 = _S6798 / _S6797; + float _S6800 = _S6797 * _S6797; + k_25 = _S6795 / _S6704; + s_diff_k_15 = _S6799; + _S6783 = _S6800; + _S6784 = _S6798; + _S6785 = _S6797; + _S6786 = _S6795; + _S6787 = _S6796; + _S6788 = 0.0f; + _S6789 = 0.0f; + _S6790 = 0.0f; + _S6791 = 0.0f; + _S6792 = 0.0f; + (&_S6793)->primal_0 = 0.0f; + (&_S6793)->differential_0 = 0.0f; } else { - k_8 = _S3468 / _S3466; + float _S6801 = 0.5f * _S6709.primal_0; + float _S6802 = _S6709.differential_0 * 0.5f; + DiffPair_float_0 _S6803; + (&_S6803)->primal_0 = _S6801; + (&_S6803)->differential_0 = _S6802; + DiffPair_float_0 _S6804 = s_primal_ctx_d_sin_0(&_S6803); + float _S6805 = 2.0f * _S6804.primal_0; + float _S6806 = _S6804.differential_0 * 2.0f; + float _S6807 = _S6703.primal_0 * _S6703.primal_0; + float _S6808 = _S6806 * _S6703.primal_0 - _S6805 * _S6703.differential_0; + float _S6809 = _S6808 / _S6807; + float _S6810 = _S6807 * _S6807; + k_25 = _S6805 / _S6703.primal_0; + s_diff_k_15 = _S6809; + _S6783 = 0.0f; + _S6784 = 0.0f; + _S6785 = 0.0f; + _S6786 = 0.0f; + _S6787 = 0.0f; + _S6788 = _S6810; + _S6789 = _S6808; + _S6790 = _S6807; + _S6791 = _S6805; + _S6792 = _S6806; + (&_S6793)->primal_0 = _S6801; + (&_S6793)->differential_0 = _S6802; } - float2 _S3469 = _S3465 * make_float2 (k_8); - float u_94 = _S3469.x; - float v_94 = _S3469.y; - float r2_94 = u_94 * u_94 + v_94 * v_94; - float2 _S3470 = _S3469 * make_float2 (1.0f + r2_94 * (dist_coeffs_17[int(0)] + r2_94 * (dist_coeffs_17[int(1)] + r2_94 * (dist_coeffs_17[int(2)] + r2_94 * dist_coeffs_17[int(3)])))) + make_float2 (_S3447 * u_94 * v_94 + dist_coeffs_17[int(5)] * (r2_94 + 2.0f * u_94 * u_94) + dist_coeffs_17[int(6)] * r2_94, _S3448 * u_94 * v_94 + dist_coeffs_17[int(4)] * (r2_94 + 2.0f * v_94 * v_94) + dist_coeffs_17[int(7)] * r2_94); - float2 _S3471 = _S3470 + make_float2 (dist_coeffs_17[int(8)] * _S3470.x + dist_coeffs_17[int(9)] * _S3470.y, 0.0f); - (&_S3402)->_S3397 = make_float2 (fx_17 * _S3471.x + cx_14, fy_17 * _S3471.y + cy_14); - float2 _S3472 = float2 {_S3439.p_0[int(4)].x, _S3439.p_0[int(4)].y}; - float _S3473 = length_0(_S3472); - float _S3474 = _S3439.p_0[int(4)].z; - float _S3475 = s_primal_ctx_atan2_0(_S3473, _S3474); - if(_S3475 < 0.00100000004749745f) + float2 _S6811 = make_float2 (k_25); + float2 _S6812 = make_float2 (s_diff_k_15); + float2 _S6813 = _S6699 * make_float2 (k_25); + float2 _S6814 = _S6700 * make_float2 (k_25) + make_float2 (s_diff_k_15) * _S6699; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6815 = { _S6813, _S6814 }; + float _S6816 = _S6767._S6693.differential_0.x * fx_44; + float _S6817 = _S6767._S6693.differential_0.y * fy_44; + Matrix _S6818 = J_41; + *&(((&_S6818)->rows + (int(0)))->x) = _S6816; + *&(((&_S6818)->rows + (int(1)))->x) = _S6817; + float _S6819; + float _S6820; + float _S6821; + float _S6822; + float _S6823; + float _S6824; + float _S6825; + float _S6826; + float _S6827; + float _S6828; + DiffPair_float_0 _S6829; + if(_S6731) { - k_8 = (1.0f - _S3475 * _S3475 / 3.0f) / _S3474; + float _S6830 = _S6730.differential_0 * _S6730.primal_0; + float _S6831 = 1.0f - _S6730.primal_0 * _S6730.primal_0 / 24.0f; + float _S6832 = 0.0f - (_S6830 + _S6830) * 0.0416666679084301f; + float _S6833 = _S6704 * _S6704; + float _S6834 = _S6832 * _S6704; + float _S6835 = _S6834 / _S6833; + float _S6836 = _S6833 * _S6833; + k_25 = _S6831 / _S6704; + s_diff_k_15 = _S6835; + _S6819 = _S6836; + _S6820 = _S6834; + _S6821 = _S6833; + _S6822 = _S6831; + _S6823 = _S6832; + _S6824 = 0.0f; + _S6825 = 0.0f; + _S6826 = 0.0f; + _S6827 = 0.0f; + _S6828 = 0.0f; + (&_S6829)->primal_0 = 0.0f; + (&_S6829)->differential_0 = 0.0f; } else { - k_8 = _S3475 / _S3473; + float _S6837 = 0.5f * _S6730.primal_0; + float _S6838 = _S6730.differential_0 * 0.5f; + DiffPair_float_0 _S6839; + (&_S6839)->primal_0 = _S6837; + (&_S6839)->differential_0 = _S6838; + DiffPair_float_0 _S6840 = s_primal_ctx_d_sin_0(&_S6839); + float _S6841 = 2.0f * _S6840.primal_0; + float _S6842 = _S6840.differential_0 * 2.0f; + float _S6843 = _S6726.primal_0 * _S6726.primal_0; + float _S6844 = _S6842 * _S6726.primal_0 - _S6841 * _S6726.differential_0; + float _S6845 = _S6844 / _S6843; + float _S6846 = _S6843 * _S6843; + k_25 = _S6841 / _S6726.primal_0; + s_diff_k_15 = _S6845; + _S6819 = 0.0f; + _S6820 = 0.0f; + _S6821 = 0.0f; + _S6822 = 0.0f; + _S6823 = 0.0f; + _S6824 = _S6846; + _S6825 = _S6844; + _S6826 = _S6843; + _S6827 = _S6841; + _S6828 = _S6842; + (&_S6829)->primal_0 = _S6837; + (&_S6829)->differential_0 = _S6838; } - float2 _S3476 = _S3472 * make_float2 (k_8); - float u_95 = _S3476.x; - float v_95 = _S3476.y; - float r2_95 = u_95 * u_95 + v_95 * v_95; - float2 _S3477 = _S3476 * make_float2 (1.0f + r2_95 * (dist_coeffs_17[int(0)] + r2_95 * (dist_coeffs_17[int(1)] + r2_95 * (dist_coeffs_17[int(2)] + r2_95 * dist_coeffs_17[int(3)])))) + make_float2 (_S3447 * u_95 * v_95 + dist_coeffs_17[int(5)] * (r2_95 + 2.0f * u_95 * u_95) + dist_coeffs_17[int(6)] * r2_95, _S3448 * u_95 * v_95 + dist_coeffs_17[int(4)] * (r2_95 + 2.0f * v_95 * v_95) + dist_coeffs_17[int(7)] * r2_95); - float2 _S3478 = _S3477 + make_float2 (dist_coeffs_17[int(8)] * _S3477.x + dist_coeffs_17[int(9)] * _S3477.y, 0.0f); - (&_S3402)->_S3398 = make_float2 (fx_17 * _S3478.x + cx_14, fy_17 * _S3478.y + cy_14); - float2 _S3479 = float2 {_S3440.p_0[int(5)].x, _S3440.p_0[int(5)].y}; - float _S3480 = length_0(_S3479); - float _S3481 = _S3440.p_0[int(5)].z; - float _S3482 = s_primal_ctx_atan2_0(_S3480, _S3481); - if(_S3482 < 0.00100000004749745f) + float2 _S6847 = make_float2 (k_25); + float2 _S6848 = make_float2 (s_diff_k_15); + float2 _S6849 = _S6699 * make_float2 (k_25); + float2 _S6850 = _S6723 * make_float2 (k_25) + make_float2 (s_diff_k_15) * _S6699; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6851 = { _S6849, _S6850 }; + float _S6852 = _S6767._S6694.differential_0.y * fy_44; + *&(((&_S6818)->rows + (int(0)))->y) = _S6767._S6694.differential_0.x * fx_44; + *&(((&_S6818)->rows + (int(1)))->y) = _S6852; + float _S6853; + float _S6854; + float _S6855; + float _S6856; + float _S6857; + float _S6858; + float _S6859; + float _S6860; + float _S6861; + float _S6862; + DiffPair_float_0 _S6863; + if(_S6753) { - k_8 = (1.0f - _S3482 * _S3482 / 3.0f) / _S3481; + float _S6864 = _S6752.differential_0 * _S6752.primal_0; + float _S6865 = 1.0f - _S6752.primal_0 * _S6752.primal_0 / 24.0f; + float _S6866 = 0.0f - (_S6864 + _S6864) * 0.0416666679084301f; + float _S6867 = _S6704 * _S6704; + float _S6868 = _S6866 * _S6704 - _S6865; + float _S6869 = _S6868 / _S6867; + float _S6870 = _S6867 * _S6867; + k_25 = _S6865 / _S6704; + s_diff_k_15 = _S6869; + _S6853 = _S6870; + _S6854 = _S6868; + _S6855 = _S6867; + _S6856 = _S6865; + _S6857 = _S6866; + _S6858 = 0.0f; + _S6859 = 0.0f; + _S6860 = 0.0f; + _S6861 = 0.0f; + _S6862 = 0.0f; + (&_S6863)->primal_0 = 0.0f; + (&_S6863)->differential_0 = 0.0f; } else { - k_8 = _S3482 / _S3480; + float _S6871 = 0.5f * _S6752.primal_0; + float _S6872 = _S6752.differential_0 * 0.5f; + DiffPair_float_0 _S6873; + (&_S6873)->primal_0 = _S6871; + (&_S6873)->differential_0 = _S6872; + DiffPair_float_0 _S6874 = s_primal_ctx_d_sin_0(&_S6873); + float _S6875 = 2.0f * _S6874.primal_0; + float _S6876 = _S6874.differential_0 * 2.0f; + float _S6877 = _S6747.primal_0 * _S6747.primal_0; + float _S6878 = _S6876 * _S6747.primal_0 - _S6875 * _S6747.differential_0; + float _S6879 = _S6878 / _S6877; + float _S6880 = _S6877 * _S6877; + k_25 = _S6875 / _S6747.primal_0; + s_diff_k_15 = _S6879; + _S6853 = 0.0f; + _S6854 = 0.0f; + _S6855 = 0.0f; + _S6856 = 0.0f; + _S6857 = 0.0f; + _S6858 = _S6880; + _S6859 = _S6878; + _S6860 = _S6877; + _S6861 = _S6875; + _S6862 = _S6876; + (&_S6863)->primal_0 = _S6871; + (&_S6863)->differential_0 = _S6872; } - float2 _S3483 = _S3479 * make_float2 (k_8); - float u_96 = _S3483.x; - float v_96 = _S3483.y; - float r2_96 = u_96 * u_96 + v_96 * v_96; - float2 _S3484 = _S3483 * make_float2 (1.0f + r2_96 * (dist_coeffs_17[int(0)] + r2_96 * (dist_coeffs_17[int(1)] + r2_96 * (dist_coeffs_17[int(2)] + r2_96 * dist_coeffs_17[int(3)])))) + make_float2 (_S3447 * u_96 * v_96 + dist_coeffs_17[int(5)] * (r2_96 + 2.0f * u_96 * u_96) + dist_coeffs_17[int(6)] * r2_96, _S3448 * u_96 * v_96 + dist_coeffs_17[int(4)] * (r2_96 + 2.0f * v_96 * v_96) + dist_coeffs_17[int(7)] * r2_96); - float2 _S3485 = _S3484 + make_float2 (dist_coeffs_17[int(8)] * _S3484.x + dist_coeffs_17[int(9)] * _S3484.y, 0.0f); - (&_S3402)->_S3399 = make_float2 (fx_17 * _S3485.x + cx_14, fy_17 * _S3485.y + cy_14); - float2 _S3486 = float2 {_S3441.p_0[int(6)].x, _S3441.p_0[int(6)].y}; - float _S3487 = length_0(_S3486); - float _S3488 = _S3441.p_0[int(6)].z; - float _S3489 = s_primal_ctx_atan2_0(_S3487, _S3488); - if(_S3489 < 0.00100000004749745f) + float2 _S6881 = make_float2 (k_25); + float2 _S6882 = make_float2 (s_diff_k_15); + float2 _S6883 = _S6699 * make_float2 (k_25); + float2 _S6884 = make_float2 (s_diff_k_15) * _S6699; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6885 = { _S6883, _S6884 }; + float _S6886 = _S6767._S6695.differential_0.y * fy_44; + *&(((&_S6818)->rows + (int(0)))->z) = _S6767._S6695.differential_0.x * fx_44; + *&(((&_S6818)->rows + (int(1)))->z) = _S6886; + Matrix _S6887 = s_primal_ctx_mul_2(_S6818, _S6782); + Matrix _S6888 = transpose_1(_S6818); + Matrix _S6889 = s_primal_ctx_mul_3(_S6887, _S6888); + float eps2d_31; + if(antialiased_31) { - k_8 = (1.0f - _S3489 * _S3489 / 3.0f) / _S3488; + eps2d_31 = 0.10000000149011612f; } else { - k_8 = _S3489 / _S3487; + eps2d_31 = 0.30000001192092896f; } - float2 _S3490 = _S3486 * make_float2 (k_8); - float u_97 = _S3490.x; - float v_97 = _S3490.y; - float r2_97 = u_97 * u_97 + v_97 * v_97; - float2 _S3491 = _S3490 * make_float2 (1.0f + r2_97 * (dist_coeffs_17[int(0)] + r2_97 * (dist_coeffs_17[int(1)] + r2_97 * (dist_coeffs_17[int(2)] + r2_97 * dist_coeffs_17[int(3)])))) + make_float2 (_S3447 * u_97 * v_97 + dist_coeffs_17[int(5)] * (r2_97 + 2.0f * u_97 * u_97) + dist_coeffs_17[int(6)] * r2_97, _S3448 * u_97 * v_97 + dist_coeffs_17[int(4)] * (r2_97 + 2.0f * v_97 * v_97) + dist_coeffs_17[int(7)] * r2_97); - float2 _S3492 = _S3491 + make_float2 (dist_coeffs_17[int(8)] * _S3491.x + dist_coeffs_17[int(9)] * _S3491.y, 0.0f); - (&_S3402)->_S3400 = make_float2 (fx_17 * _S3492.x + cx_14, fy_17 * _S3492.y + cy_14); - float3 mean_c_13 = s_primal_ctx_mul_0(R_13, mean_14) + t_13; - float _S3493 = - in_opacity_13; - float _S3494 = 1.0f + s_primal_ctx_exp_0(_S3493); - float _S3495 = 1.0f / _S3494; - float _S3496 = _S3494 * _S3494; - float3 _S3497 = make_float3 (_S3413); - float3 _S3498 = make_float3 (_S3416); - float3 _S3499 = make_float3 (_S3419); - float2 _S3500 = make_float2 (_S3411.w_mean_0[int(1)]) * _S3402._S3395 + make_float2 (_S3423.w_mean_0[int(2)]) * _S3402._S3396 + make_float2 (_S3425.w_mean_0[int(3)]) * _S3402._S3397 + make_float2 (_S3427.w_mean_0[int(4)]) * _S3402._S3398 + make_float2 (_S3429.w_mean_0[int(5)]) * _S3402._S3399 + make_float2 (_S3431.w_mean_0[int(6)]) * _S3402._S3400; - float2 d_35 = _S3402._S3394 - _S3500; - float _S3501 = d_35.x; - float _S3502 = d_35.y; - float _S3503 = _S3501 * _S3502; - float2 d_36 = _S3402._S3395 - _S3500; - float _S3504 = d_36.x; - float _S3505 = d_36.y; - float _S3506 = _S3504 * _S3505; - float2 d_37 = _S3402._S3396 - _S3500; - float _S3507 = d_37.x; - float _S3508 = d_37.y; - float _S3509 = _S3507 * _S3508; - float2 d_38 = _S3402._S3397 - _S3500; - float _S3510 = d_38.x; - float _S3511 = d_38.y; - float _S3512 = _S3510 * _S3511; - float2 d_39 = _S3402._S3398 - _S3500; - float _S3513 = d_39.x; - float _S3514 = d_39.y; - float _S3515 = _S3513 * _S3514; - float2 d_40 = _S3402._S3399 - _S3500; - float _S3516 = d_40.x; - float _S3517 = d_40.y; - float _S3518 = _S3516 * _S3517; - float2 d_41 = _S3402._S3400 - _S3500; - float _S3519 = d_41.x; - float _S3520 = d_41.y; - float _S3521 = _S3519 * _S3520; - Matrix covar2d_9 = makeMatrix (2.0f) * makeMatrix (_S3501 * _S3501, _S3503, _S3503, _S3502 * _S3502) + makeMatrix (_S3422.w_cov_0[int(1)]) * makeMatrix (_S3504 * _S3504, _S3506, _S3506, _S3505 * _S3505) + makeMatrix (_S3424.w_cov_0[int(2)]) * makeMatrix (_S3507 * _S3507, _S3509, _S3509, _S3508 * _S3508) + makeMatrix (_S3426.w_cov_0[int(3)]) * makeMatrix (_S3510 * _S3510, _S3512, _S3512, _S3511 * _S3511) + makeMatrix (_S3428.w_cov_0[int(4)]) * makeMatrix (_S3513 * _S3513, _S3515, _S3515, _S3514 * _S3514) + makeMatrix (_S3430.w_cov_0[int(5)]) * makeMatrix (_S3516 * _S3516, _S3518, _S3518, _S3517 * _S3517) + makeMatrix (_S3432.w_cov_0[int(6)]) * makeMatrix (_S3519 * _S3519, _S3521, _S3521, _S3520 * _S3520); - float eps2d_13; - if(antialiased_13) + float _S6890 = _S6889.rows[int(0)].y * _S6889.rows[int(1)].x; + float det_orig_31 = _S6889.rows[int(0)].x * _S6889.rows[int(1)].y - _S6890; + float _S6891 = _S6889.rows[int(0)].x + eps2d_31; + Matrix _S6892 = _S6889; + *&(((&_S6892)->rows + (int(0)))->x) = _S6891; + float _S6893 = _S6889.rows[int(1)].y + eps2d_31; + *&(((&_S6892)->rows + (int(1)))->y) = _S6893; + Matrix _S6894 = _S6892; + Matrix _S6895 = _S6892; + float det_blur_31 = _S6891 * _S6893 - _S6890; + float _S6896 = det_orig_31 / det_blur_31; + float _S6897 = det_blur_31 * det_blur_31; + float _S6898 = (F32_max((0.0f), (_S6896))); + float _S6899 = s_primal_ctx_sqrt_0(_S6898); + float invdet_37 = 1.0f / det_blur_31; + float _S6900 = - _S6889.rows[int(0)].y; + float _S6901 = - _S6889.rows[int(1)].x; + if(antialiased_31) { - eps2d_13 = 0.10000000149011612f; + k_25 = _S6771 * _S6899; } else { - eps2d_13 = 0.30000001192092896f; + k_25 = _S6771; } - float _S3522 = covar2d_9.rows[int(0)].y * covar2d_9.rows[int(1)].x; - float det_orig_13 = covar2d_9.rows[int(0)].x * covar2d_9.rows[int(1)].y - _S3522; - float _S3523 = covar2d_9.rows[int(0)].x + eps2d_13; - Matrix _S3524 = covar2d_9; - *&(((&_S3524)->rows + (int(0)))->x) = _S3523; - float _S3525 = covar2d_9.rows[int(1)].y + eps2d_13; - *&(((&_S3524)->rows + (int(1)))->y) = _S3525; - Matrix _S3526 = _S3524; - Matrix _S3527 = _S3524; - float det_blur_13 = _S3523 * _S3525 - _S3522; - float _S3528 = det_orig_13 / det_blur_13; - float _S3529 = det_blur_13 * det_blur_13; - float _S3530 = (F32_max((0.0f), (_S3528))); - float _S3531 = s_primal_ctx_sqrt_0(_S3530); - float invdet_15 = 1.0f / det_blur_13; - float _S3532 = - covar2d_9.rows[int(0)].y; - float _S3533 = - covar2d_9.rows[int(1)].x; - if(antialiased_13) + float _S6902 = k_25 / 0.00392156885936856f; + float _S6903 = 2.0f * s_primal_ctx_log_0(_S6902); + float _S6904 = s_primal_ctx_sqrt_0(_S6903); + float _S6905 = _S6894.rows[int(0)].x; + float _S6906 = _S6895.rows[int(1)].y; + float3 campos_10 = - s_primal_ctx_mul_0(_S6781, t_31); + float3 _S6907 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6908; + (&_S6908)->primal_0 = mean_32; + (&_S6908)->differential_0 = _S6907; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6909; + (&_S6909)->primal_0 = scale_31; + (&_S6909)->differential_0 = _S6907; + DiffPair_float_0 _S6910; + (&_S6910)->primal_0 = in_opacity_31; + (&_S6910)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6911; + (&_S6911)->primal_0 = campos_10; + (&_S6911)->differential_0 = _S6907; + s_bwd_prop_view_radius_3dgs_0(&_S6908, &_S6909, &_S6910, &_S6911, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6912 = _S6908; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S6913 = _S6909; + DiffPair_float_0 _S6914 = _S6910; + float2 _S6915 = _S6696; + *&((&_S6915)->y) = v_conic_9.z; + float2 _S6916 = _S6696; + *&((&_S6916)->y) = v_conic_9.y; + *&((&_S6916)->x) = v_conic_9.x; + DiffPair_float_0 _S6917; + (&_S6917)->primal_0 = _S6906; + (&_S6917)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S6917, 0.0f); + DiffPair_float_0 _S6918; + (&_S6918)->primal_0 = _S6905; + (&_S6918)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S6918, 0.0f); + DiffPair_float_0 _S6919; + (&_S6919)->primal_0 = 3.32999992370605469f; + (&_S6919)->differential_0 = 0.0f; + DiffPair_float_0 _S6920; + (&_S6920)->primal_0 = _S6904; + (&_S6920)->differential_0 = 0.0f; + _d_min_0(&_S6919, &_S6920, 0.0f); + DiffPair_float_0 _S6921; + (&_S6921)->primal_0 = _S6903; + (&_S6921)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S6921, _S6920.differential_0); + float _S6922 = 2.0f * _S6921.differential_0; + DiffPair_float_0 _S6923; + (&_S6923)->primal_0 = _S6902; + (&_S6923)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S6923, _S6922); + float _S6924 = v_opacity_9 + 254.9999847412109375f * _S6923.differential_0; + Matrix _S6925 = makeMatrix (0.0f); + Matrix _S6926 = _S6925; + _S6926[int(1)] = _S6915; + _S6926[int(0)] = _S6916; + Matrix _S6927 = _S6926; + float2 _S6928 = make_float2 (0.0f, _S6917.differential_0); + float2 _S6929 = make_float2 (_S6918.differential_0, 0.0f); + if(antialiased_31) { - k_8 = _S3495 * _S3531; + float _S6930 = _S6899 * _S6924; + k_25 = _S6771 * _S6924; + s_diff_k_15 = _S6930; } else { - k_8 = _S3495; + k_25 = 0.0f; + s_diff_k_15 = _S6924; } - float _S3534 = k_8 / 0.00392156885936856f; - float _S3535 = 2.0f * s_primal_ctx_log_0(_S3534); - float _S3536 = s_primal_ctx_sqrt_0(_S3535); - float _S3537 = _S3526.rows[int(0)].x; - float _S3538 = _S3527.rows[int(1)].y; - float3 campos_6 = - s_primal_ctx_mul_0(transpose_3(R_13), t_13); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3539; - (&_S3539)->primal_0 = mean_14; - (&_S3539)->differential_0 = _S3403; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3540; - (&_S3540)->primal_0 = scale_13; - (&_S3540)->differential_0 = _S3403; - DiffPair_float_0 _S3541; - (&_S3541)->primal_0 = in_opacity_13; - (&_S3541)->differential_0 = 0.0f; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3542; - (&_S3542)->primal_0 = campos_6; - (&_S3542)->differential_0 = _S3403; - s_bwd_prop_view_radius_3dgs_0(&_S3539, &_S3540, &_S3541, &_S3542, 0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3543 = _S3539; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3544 = _S3540; - DiffPair_float_0 _S3545 = _S3541; - float2 _S3546 = _S3401; - *&((&_S3546)->y) = v_conic_5.z; - float2 _S3547 = _S3401; - *&((&_S3547)->y) = v_conic_5.y; - *&((&_S3547)->x) = v_conic_5.x; - DiffPair_float_0 _S3548; - (&_S3548)->primal_0 = _S3538; - (&_S3548)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3548, 0.0f); - DiffPair_float_0 _S3549; - (&_S3549)->primal_0 = _S3537; - (&_S3549)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3549, 0.0f); - DiffPair_float_0 _S3550; - (&_S3550)->primal_0 = 3.32999992370605469f; - (&_S3550)->differential_0 = 0.0f; - DiffPair_float_0 _S3551; - (&_S3551)->primal_0 = _S3536; - (&_S3551)->differential_0 = 0.0f; - _d_min_0(&_S3550, &_S3551, 0.0f); - DiffPair_float_0 _S3552; - (&_S3552)->primal_0 = _S3535; - (&_S3552)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3552, _S3551.differential_0); - float _S3553 = 2.0f * _S3552.differential_0; - DiffPair_float_0 _S3554; - (&_S3554)->primal_0 = _S3534; - (&_S3554)->differential_0 = 0.0f; - s_bwd_prop_log_0(&_S3554, _S3553); - float _S3555 = v_opacity_5 + 254.9999847412109375f * _S3554.differential_0; - Matrix _S3556 = makeMatrix (0.0f); - Matrix _S3557 = _S3556; - _S3557[int(1)] = _S3546; - _S3557[int(0)] = _S3547; - Matrix _S3558 = _S3557; - float2 _S3559 = make_float2 (0.0f, _S3548.differential_0); - float2 _S3560 = make_float2 (_S3549.differential_0, 0.0f); - if(antialiased_13) + float _S6931 = invdet_37 * _S6927.rows[int(1)].y; + float _S6932 = - (invdet_37 * _S6927.rows[int(1)].x); + float _S6933 = - (invdet_37 * _S6927.rows[int(0)].y); + float _S6934 = invdet_37 * _S6927.rows[int(0)].x; + float _S6935 = - ((_S6891 * _S6927.rows[int(1)].y + _S6901 * _S6927.rows[int(1)].x + _S6900 * _S6927.rows[int(0)].y + _S6893 * _S6927.rows[int(0)].x) / _S6897); + DiffPair_float_0 _S6936; + (&_S6936)->primal_0 = _S6898; + (&_S6936)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S6936, k_25); + DiffPair_float_0 _S6937; + (&_S6937)->primal_0 = 0.0f; + (&_S6937)->differential_0 = 0.0f; + DiffPair_float_0 _S6938; + (&_S6938)->primal_0 = _S6896; + (&_S6938)->differential_0 = 0.0f; + _d_max_0(&_S6937, &_S6938, _S6936.differential_0); + float _S6939 = _S6938.differential_0 / _S6897; + float s_diff_det_orig_T_9 = det_blur_31 * _S6939; + float _S6940 = det_orig_31 * - _S6939 + _S6935; + float _S6941 = - _S6940; + float _S6942 = _S6891 * _S6940; + float _S6943 = _S6893 * _S6940; + Matrix _S6944 = _S6925; + _S6944[int(1)] = _S6928; + _S6944[int(0)] = _S6929; + _S6892 = _S6944; + *&(((&_S6892)->rows + (int(1)))->y) = 0.0f; + float _S6945 = _S6942 + _S6944.rows[int(1)].y + _S6934; + *&(((&_S6892)->rows + (int(0)))->x) = 0.0f; + float _S6946 = _S6943 + _S6944.rows[int(0)].x + _S6931; + float _S6947 = _S6941 + - s_diff_det_orig_T_9; + float _S6948 = _S6889.rows[int(0)].y * _S6947 + _S6932; + float _S6949 = _S6889.rows[int(1)].x * _S6947 + _S6933; + float _S6950 = _S6889.rows[int(1)].y * s_diff_det_orig_T_9; + float _S6951 = _S6945 + _S6889.rows[int(0)].x * s_diff_det_orig_T_9; + float2 _S6952 = _S6696; + *&((&_S6952)->x) = _S6948; + *&((&_S6952)->y) = _S6951; + float _S6953 = _S6946 + _S6950; + float2 _S6954 = _S6696; + *&((&_S6954)->y) = _S6949; + *&((&_S6954)->x) = _S6953; + Matrix _S6955 = _S6925; + _S6955[int(1)] = _S6952; + _S6955[int(0)] = _S6954; + Matrix _S6956 = _S6892 + _S6955; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S6957; + (&_S6957)->primal_0 = _S6887; + (&_S6957)->differential_0 = J_41; + Matrix _S6958 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S6959; + (&_S6959)->primal_0 = _S6888; + (&_S6959)->differential_0 = _S6958; + s_bwd_prop_mul_0(&_S6957, &_S6959, _S6956); + Matrix _S6960 = transpose_2(_S6959.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S6961; + (&_S6961)->primal_0 = _S6818; + (&_S6961)->differential_0 = J_41; + Matrix _S6962 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6963; + (&_S6963)->primal_0 = _S6782; + (&_S6963)->differential_0 = _S6962; + s_bwd_prop_mul_1(&_S6961, &_S6963, _S6957.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S6964 = _S6963; + Matrix _S6965 = _S6960 + _S6961.differential_0; + float2 _S6966 = make_float2 (fx_44 * _S6965.rows[int(0)].z, fy_44 * _S6965.rows[int(1)].z); + DiffPair_0 _S6967; + (&_S6967)->primal_0 = _S6885; + (&_S6967)->differential_0 = _S6697; + FixedArray _S6968 = dist_coeffs_43; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S6969; + (&_S6969)->primal_0 = _S6744; + (&_S6969)->differential_0 = _S6966; + s_bwd_prop_s_fwd_DistThinPrism_distort_0(&_S6967, &_S6968, &_S6969); + float2 _S6970 = _S6699 * _S6967.differential_0.differential_0; + float2 _S6971 = _S6699 * _S6967.differential_0.primal_0; + float _S6972 = _S6971.x + _S6971.y; + float _S6973 = _S6970.x + _S6970.y; + float2 _S6974 = _S6882 * _S6967.differential_0.differential_0 + _S6881 * _S6967.differential_0.primal_0; + if(_S6753) { - float _S3561 = _S3531 * _S3555; - k_8 = _S3495 * _S3555; - eps2d_13 = _S3561; + float _S6975 = _S6973 / _S6853; + float _S6976 = _S6855 * _S6975; + float _S6977 = _S6704 * (_S6854 * - _S6975); + float _S6978 = _S6972 / _S6855; + float _S6979 = 0.0416666679084301f * - (_S6704 * _S6976); + float _S6980 = _S6979 + _S6979; + float _S6981 = _S6752.primal_0 * (0.0416666679084301f * - (- _S6976 + _S6704 * _S6978)); + float _S6982 = _S6977 + _S6977 + _S6857 * _S6976 + _S6856 * - _S6978; + float _S6983 = _S6752.differential_0 * _S6980 + _S6981 + _S6981; + k_25 = _S6752.primal_0 * _S6980; + _S6853 = _S6983; + _S6854 = _S6982; + _S6855 = 0.0f; + _S6856 = 0.0f; } else { - k_8 = 0.0f; - eps2d_13 = _S3555; + float _S6984 = _S6973 / _S6858; + float _S6985 = _S6860 * _S6984; + float _S6986 = _S6747.primal_0 * (_S6859 * - _S6984); + float _S6987 = - _S6985; + float _S6988 = _S6861 * _S6987; + float _S6989 = _S6862 * _S6985; + float _S6990 = _S6972 / _S6860; + float _S6991 = _S6861 * - _S6990; + float _S6992 = 2.0f * (_S6747.primal_0 * _S6985); + float _S6993 = 2.0f * (_S6747.differential_0 * _S6987 + _S6747.primal_0 * _S6990); + DiffPair_1 _S6994; + (&_S6994)->primal_0 = _S6863; + (&_S6994)->differential_0 = _S6768; + DiffPair_float_0 _S6995; + (&_S6995)->primal_0 = _S6993; + (&_S6995)->differential_0 = _S6992; + s_bwd_prop_d_sin_0(&_S6994, &_S6995); + float _S6996 = 0.5f * _S6994.differential_0.primal_0; + float _S6997 = _S6986 + _S6986 + _S6989 + _S6991; + k_25 = 0.5f * _S6994.differential_0.differential_0; + _S6853 = _S6996; + _S6854 = 0.0f; + _S6855 = _S6988; + _S6856 = _S6997; } - float _S3562 = invdet_15 * _S3558.rows[int(1)].y; - float _S3563 = - (invdet_15 * _S3558.rows[int(1)].x); - float _S3564 = - (invdet_15 * _S3558.rows[int(0)].y); - float _S3565 = invdet_15 * _S3558.rows[int(0)].x; - float _S3566 = - ((_S3523 * _S3558.rows[int(1)].y + _S3533 * _S3558.rows[int(1)].x + _S3532 * _S3558.rows[int(0)].y + _S3525 * _S3558.rows[int(0)].x) / _S3529); - DiffPair_float_0 _S3567; - (&_S3567)->primal_0 = _S3530; - (&_S3567)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3567, k_8); - DiffPair_float_0 _S3568; - (&_S3568)->primal_0 = 0.0f; - (&_S3568)->differential_0 = 0.0f; - DiffPair_float_0 _S3569; - (&_S3569)->primal_0 = _S3528; - (&_S3569)->differential_0 = 0.0f; - _d_max_0(&_S3568, &_S3569, _S3567.differential_0); - float _S3570 = _S3569.differential_0 / _S3529; - float s_diff_det_orig_T_5 = det_blur_13 * _S3570; - float _S3571 = det_orig_13 * - _S3570 + _S3566; - float _S3572 = - _S3571; - float _S3573 = _S3523 * _S3571; - float _S3574 = _S3525 * _S3571; - Matrix _S3575 = _S3556; - _S3575[int(1)] = _S3559; - _S3575[int(0)] = _S3560; - float _S3576 = _S3574 + _S3575.rows[int(0)].x + _S3562; - float _S3577 = _S3572 + - s_diff_det_orig_T_5; - float _S3578 = covar2d_9.rows[int(0)].y * _S3577 + _S3563; - float _S3579 = covar2d_9.rows[int(1)].x * _S3577 + _S3564; - float _S3580 = covar2d_9.rows[int(1)].y * s_diff_det_orig_T_5; - float _S3581 = _S3573 + _S3575.rows[int(1)].y + _S3565 + covar2d_9.rows[int(0)].x * s_diff_det_orig_T_5; - float2 _S3582 = _S3401; - *&((&_S3582)->x) = _S3578; - *&((&_S3582)->y) = _S3581; - float _S3583 = _S3576 + _S3580; - float2 _S3584 = _S3401; - *&((&_S3584)->y) = _S3579; - *&((&_S3584)->x) = _S3583; - Matrix _S3585 = _S3556; - _S3585[int(1)] = _S3582; - _S3585[int(0)] = _S3584; - Matrix _S3586 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3587; - (&_S3587)->primal_0 = R_13; - (&_S3587)->differential_0 = _S3586; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3588; - (&_S3588)->primal_0 = _S3421; - (&_S3588)->differential_0 = _S3403; - s_bwd_prop_mul_3(&_S3587, &_S3588, _S3403); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3589; - (&_S3589)->primal_0 = R_13; - (&_S3589)->differential_0 = _S3586; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3590; - (&_S3590)->primal_0 = _S3418; - (&_S3590)->differential_0 = _S3403; - s_bwd_prop_mul_3(&_S3589, &_S3590, _S3403); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3591; - (&_S3591)->primal_0 = R_13; - (&_S3591)->differential_0 = _S3586; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3592; - (&_S3592)->primal_0 = _S3415; - (&_S3592)->differential_0 = _S3403; - s_bwd_prop_mul_3(&_S3591, &_S3592, _S3403); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3593; - (&_S3593)->primal_0 = R_13; - (&_S3593)->differential_0 = _S3586; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3594; - (&_S3594)->primal_0 = _S3420; - (&_S3594)->differential_0 = _S3403; - s_bwd_prop_mul_3(&_S3593, &_S3594, _S3403); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3595; - (&_S3595)->primal_0 = R_13; - (&_S3595)->differential_0 = _S3586; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3596; - (&_S3596)->primal_0 = _S3417; - (&_S3596)->differential_0 = _S3403; - s_bwd_prop_mul_3(&_S3595, &_S3596, _S3403); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3597; - (&_S3597)->primal_0 = R_13; - (&_S3597)->differential_0 = _S3586; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3598; - (&_S3598)->primal_0 = _S3414; - (&_S3598)->differential_0 = _S3403; - s_bwd_prop_mul_3(&_S3597, &_S3598, _S3403); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3599; - (&_S3599)->primal_0 = R_13; - (&_S3599)->differential_0 = _S3586; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3600; - (&_S3600)->primal_0 = _S3433.p_0[0U]; - (&_S3600)->differential_0 = _S3403; - s_bwd_prop_mul_3(&_S3599, &_S3600, _S3403); - float3 _S3601 = - _S3588.differential_0 + _S3594.differential_0; - float3 _S3602 = _S3499 * _S3601; - float3 _S3603 = _S3407.rows[2U] * _S3601; - float _S3604 = _S3412 * (_S3603.x + _S3603.y + _S3603.z); - float3 _S3605 = - _S3590.differential_0 + _S3596.differential_0; - float3 _S3606 = _S3498 * _S3605; - float3 _S3607 = _S3407.rows[1U] * _S3605; - float _S3608 = _S3412 * (_S3607.x + _S3607.y + _S3607.z); - float3 _S3609 = - _S3592.differential_0 + _S3598.differential_0; - float3 _S3610 = _S3497 * _S3609; - float3 _S3611 = _S3407.rows[0U] * _S3609; - float _S3612 = _S3412 * (_S3611.x + _S3611.y + _S3611.z); - Matrix _S3613 = _S3586; - _S3613[2U] = _S3602; - _S3613[1U] = _S3606; - _S3613[0U] = _S3610; - Matrix _S3614 = transpose_3(transpose_3(_S3613)); - float _S3615 = 2.0f * - _S3614.rows[int(2)].z; - float _S3616 = 2.0f * _S3614.rows[int(2)].y; - float _S3617 = 2.0f * _S3614.rows[int(2)].x; - float _S3618 = 2.0f * _S3614.rows[int(1)].z; - float _S3619 = 2.0f * - _S3614.rows[int(1)].y; - float _S3620 = 2.0f * _S3614.rows[int(1)].x; - float _S3621 = 2.0f * _S3614.rows[int(0)].z; - float _S3622 = 2.0f * _S3614.rows[int(0)].y; - float _S3623 = 2.0f * - _S3614.rows[int(0)].x; - float _S3624 = - _S3620 + _S3622; - float _S3625 = _S3617 + - _S3621; - float _S3626 = - _S3616 + _S3618; - float _S3627 = _S3616 + _S3618; - float _S3628 = _S3617 + _S3621; - float _S3629 = _S3620 + _S3622; - float _S3630 = _S3405.w * (_S3619 + _S3623); - float _S3631 = _S3405.z * (_S3615 + _S3623); - float _S3632 = _S3405.y * (_S3615 + _S3619); - float _S3633 = _S3405.x * _S3624 + _S3405.z * _S3627 + _S3405.y * _S3628 + _S3630 + _S3630; - float _S3634 = _S3405.x * _S3625 + _S3405.w * _S3627 + _S3405.y * _S3629 + _S3631 + _S3631; - float _S3635 = _S3405.x * _S3626 + _S3405.w * _S3628 + _S3405.z * _S3629 + _S3632 + _S3632; - float _S3636 = _S3405.w * _S3624 + _S3405.z * _S3625 + _S3405.y * _S3626; - float4 _S3637 = make_float4 (0.0f); - float4 _S3638 = _S3637; - *&((&_S3638)->w) = _S3633; - *&((&_S3638)->z) = _S3634; - *&((&_S3638)->y) = _S3635; - *&((&_S3638)->x) = _S3636; - DiffPair_vectorx3Cfloatx2C4x3E_0 _S3639; - (&_S3639)->primal_0 = quat_13; - (&_S3639)->differential_0 = _S3637; - s_bwd_normalize_impl_0(&_S3639, _S3638); - float3 _S3640 = _S3403; - *&((&_S3640)->z) = _S3604; - *&((&_S3640)->y) = _S3608; - *&((&_S3640)->x) = _S3612; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3641; - (&_S3641)->primal_0 = scale_13; - (&_S3641)->differential_0 = _S3403; - s_bwd_prop_exp_1(&_S3641, _S3640); - float _S3642 = - (eps2d_13 / _S3496); - DiffPair_float_0 _S3643; - (&_S3643)->primal_0 = _S3493; - (&_S3643)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S3643, _S3642); - float _S3644 = - _S3643.differential_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3645; - (&_S3645)->primal_0 = mean_c_13; - (&_S3645)->differential_0 = _S3403; - s_bwd_length_impl_0(&_S3645, v_depth_5); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3646; - (&_S3646)->primal_0 = R_13; - (&_S3646)->differential_0 = _S3586; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3647; - (&_S3647)->primal_0 = mean_14; - (&_S3647)->differential_0 = _S3403; - s_bwd_prop_mul_3(&_S3646, &_S3647, _S3645.differential_0); - Matrix _S3648 = _S3587.differential_0 + _S3589.differential_0 + _S3591.differential_0 + _S3593.differential_0 + _S3595.differential_0 + _S3597.differential_0 + _S3599.differential_0 + _S3646.differential_0; - float _S3649 = _S3644 + _S3545.differential_0; - float3 _S3650 = _S3641.differential_0 + _S3544.differential_0; - *v_mean_5 = *v_mean_5 + (_S3588.differential_0 + _S3594.differential_0 + _S3590.differential_0 + _S3596.differential_0 + _S3592.differential_0 + _S3598.differential_0 + _S3647.differential_0 + _S3543.differential_0); - *v_quat_5 = *v_quat_5 + _S3639.differential_0; - *v_scale_5 = *v_scale_5 + _S3650; - *v_in_opacity_5 = *v_in_opacity_5 + _S3649; - *v_R_5 = *v_R_5 + _S3648; - *v_t_5 = *v_t_5 + _S3645.differential_0; + DiffPair_1 _S6998; + (&_S6998)->primal_0 = _S6748; + (&_S6998)->differential_0 = _S6768; + DiffPair_1 _S6999; + (&_S6999)->primal_0 = _S6749; + (&_S6999)->differential_0 = _S6768; + DiffPair_float_0 _S7000; + (&_S7000)->primal_0 = _S6853; + (&_S7000)->differential_0 = k_25; + s_bwd_prop_d_atan2_0(&_S6998, &_S6999, &_S7000); + float _S7001 = _S6999.differential_0.primal_0 + _S6854; + float _S7002 = _S6998.differential_0.differential_0 + _S6855; + float _S7003 = _S6998.differential_0.primal_0 + _S6856; + DiffPair_0 _S7004; + (&_S7004)->primal_0 = _S6745; + (&_S7004)->differential_0 = _S6697; + DiffPair_float_0 _S7005; + (&_S7005)->primal_0 = _S7003; + (&_S7005)->differential_0 = _S7002; + s_bwd_prop_s_fwd_length_impl_0(&_S7004, &_S7005); + float2 _S7006 = _S7004.differential_0.primal_0 + _S6974; + float3 _S7007 = make_float3 (_S7006.x, _S7006.y, _S7001); + float2 _S7008 = make_float2 (fx_44 * _S6965.rows[int(0)].y, fy_44 * _S6965.rows[int(1)].y); + DiffPair_0 _S7009; + (&_S7009)->primal_0 = _S6851; + (&_S7009)->differential_0 = _S6697; + FixedArray _S7010 = dist_coeffs_43; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7011; + (&_S7011)->primal_0 = _S6744; + (&_S7011)->differential_0 = _S7008; + s_bwd_prop_s_fwd_DistThinPrism_distort_0(&_S7009, &_S7010, &_S7011); + DiffPair_0 _S7012 = _S7009; + float2 _S7013 = _S6699 * _S7012.differential_0.differential_0; + float2 _S7014 = _S6723 * _S7012.differential_0.differential_0; + float2 _S7015 = _S6699 * _S7012.differential_0.primal_0; + float _S7016 = _S7014.x + _S7014.y + _S7015.x + _S7015.y; + float _S7017 = _S7013.x + _S7013.y; + float2 _S7018 = _S6848 * _S7012.differential_0.differential_0 + _S6847 * _S7012.differential_0.primal_0; + if(_S6731) + { + float _S7019 = _S7017 / _S6819; + float _S7020 = _S6821 * _S7019; + float _S7021 = _S6704 * (_S6820 * - _S7019); + float _S7022 = _S7016 / _S6821; + float _S7023 = 0.0416666679084301f * - (_S6704 * _S7020); + float _S7024 = _S7023 + _S7023; + float _S7025 = _S6730.primal_0 * (0.0416666679084301f * - (_S6704 * _S7022)); + float _S7026 = _S7021 + _S7021 + _S6823 * _S7020 + _S6822 * - _S7022; + float _S7027 = _S6730.differential_0 * _S7024 + _S7025 + _S7025; + k_25 = _S6730.primal_0 * _S7024; + _S6819 = _S7027; + _S6820 = _S7026; + _S6821 = 0.0f; + _S6822 = 0.0f; + } + else + { + float _S7028 = _S7017 / _S6824; + float _S7029 = _S6826 * _S7028; + float _S7030 = _S6726.primal_0 * (_S6825 * - _S7028); + float _S7031 = - _S7029; + float _S7032 = _S6827 * _S7031; + float _S7033 = _S6828 * _S7029; + float _S7034 = _S7016 / _S6826; + float _S7035 = _S6827 * - _S7034; + float _S7036 = 2.0f * (_S6726.primal_0 * _S7029); + float _S7037 = 2.0f * (_S6726.differential_0 * _S7031 + _S6726.primal_0 * _S7034); + DiffPair_1 _S7038; + (&_S7038)->primal_0 = _S6829; + (&_S7038)->differential_0 = _S6768; + DiffPair_float_0 _S7039; + (&_S7039)->primal_0 = _S7037; + (&_S7039)->differential_0 = _S7036; + s_bwd_prop_d_sin_0(&_S7038, &_S7039); + float _S7040 = 0.5f * _S7038.differential_0.primal_0; + float _S7041 = _S7030 + _S7030 + _S7033 + _S7035; + k_25 = 0.5f * _S7038.differential_0.differential_0; + _S6819 = _S7040; + _S6820 = 0.0f; + _S6821 = _S7032; + _S6822 = _S7041; + } + DiffPair_1 _S7042; + (&_S7042)->primal_0 = _S6727; + (&_S7042)->differential_0 = _S6768; + DiffPair_1 _S7043; + (&_S7043)->primal_0 = _S6706; + (&_S7043)->differential_0 = _S6768; + DiffPair_float_0 _S7044; + (&_S7044)->primal_0 = _S6819; + (&_S7044)->differential_0 = k_25; + s_bwd_prop_d_atan2_0(&_S7042, &_S7043, &_S7044); + float _S7045 = _S7043.differential_0.primal_0 + _S6820; + float _S7046 = _S7042.differential_0.differential_0 + _S6821; + float _S7047 = _S7042.differential_0.primal_0 + _S6822; + DiffPair_0 _S7048; + (&_S7048)->primal_0 = _S6724; + (&_S7048)->differential_0 = _S6697; + DiffPair_float_0 _S7049; + (&_S7049)->primal_0 = _S7047; + (&_S7049)->differential_0 = _S7046; + s_bwd_prop_s_fwd_length_impl_0(&_S7048, &_S7049); + float2 _S7050 = _S7048.differential_0.primal_0 + _S7018; + float3 _S7051 = make_float3 (_S7050.x, _S7050.y, _S7045); + float2 _S7052 = make_float2 (fx_44 * _S6965.rows[int(0)].x, fy_44 * _S6965.rows[int(1)].x); + DiffPair_0 _S7053; + (&_S7053)->primal_0 = _S6815; + (&_S7053)->differential_0 = _S6697; + FixedArray _S7054 = dist_coeffs_43; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7055; + (&_S7055)->primal_0 = _S6744; + (&_S7055)->differential_0 = _S7052; + s_bwd_prop_s_fwd_DistThinPrism_distort_0(&_S7053, &_S7054, &_S7055); + DiffPair_0 _S7056 = _S7053; + float3 _S7057 = _S7051 + _S7007; + float2 _S7058 = _S6699 * _S7056.differential_0.differential_0; + float2 _S7059 = _S6700 * _S7056.differential_0.differential_0; + float2 _S7060 = _S6699 * _S7056.differential_0.primal_0; + float _S7061 = _S7059.x + _S7059.y + _S7060.x + _S7060.y; + float _S7062 = _S7058.x + _S7058.y; + float2 _S7063 = _S6812 * _S7056.differential_0.differential_0 + _S6811 * _S7056.differential_0.primal_0; + if(_S6710) + { + float _S7064 = _S7062 / _S6783; + float _S7065 = _S6785 * _S7064; + float _S7066 = _S6704 * (_S6784 * - _S7064); + float _S7067 = _S7061 / _S6785; + float _S7068 = 0.0416666679084301f * - (_S6704 * _S7065); + float _S7069 = _S7068 + _S7068; + float _S7070 = _S6709.primal_0 * (0.0416666679084301f * - (_S6704 * _S7067)); + float _S7071 = _S7066 + _S7066 + _S6787 * _S7065 + _S6786 * - _S7067; + float _S7072 = _S6709.differential_0 * _S7069 + _S7070 + _S7070; + k_25 = _S6709.primal_0 * _S7069; + _S6783 = _S7072; + _S6784 = _S7071; + _S6785 = 0.0f; + _S6786 = 0.0f; + } + else + { + float _S7073 = _S7062 / _S6788; + float _S7074 = _S6790 * _S7073; + float _S7075 = _S6703.primal_0 * (_S6789 * - _S7073); + float _S7076 = - _S7074; + float _S7077 = _S6791 * _S7076; + float _S7078 = _S6792 * _S7074; + float _S7079 = _S7061 / _S6790; + float _S7080 = _S6791 * - _S7079; + float _S7081 = 2.0f * (_S6703.primal_0 * _S7074); + float _S7082 = 2.0f * (_S6703.differential_0 * _S7076 + _S6703.primal_0 * _S7079); + DiffPair_1 _S7083; + (&_S7083)->primal_0 = _S6793; + (&_S7083)->differential_0 = _S6768; + DiffPair_float_0 _S7084; + (&_S7084)->primal_0 = _S7082; + (&_S7084)->differential_0 = _S7081; + s_bwd_prop_d_sin_0(&_S7083, &_S7084); + float _S7085 = 0.5f * _S7083.differential_0.primal_0; + float _S7086 = _S7075 + _S7075 + _S7078 + _S7080; + k_25 = 0.5f * _S7083.differential_0.differential_0; + _S6783 = _S7085; + _S6784 = 0.0f; + _S6785 = _S7077; + _S6786 = _S7086; + } + DiffPair_1 _S7087; + (&_S7087)->primal_0 = _S6705; + (&_S7087)->differential_0 = _S6768; + DiffPair_1 _S7088; + (&_S7088)->primal_0 = _S6706; + (&_S7088)->differential_0 = _S6768; + DiffPair_float_0 _S7089; + (&_S7089)->primal_0 = _S6783; + (&_S7089)->differential_0 = k_25; + s_bwd_prop_d_atan2_0(&_S7087, &_S7088, &_S7089); + float _S7090 = _S7088.differential_0.primal_0 + _S6784; + float _S7091 = _S7087.differential_0.differential_0 + _S6785; + float _S7092 = _S7087.differential_0.primal_0 + _S6786; + DiffPair_0 _S7093; + (&_S7093)->primal_0 = _S6701; + (&_S7093)->differential_0 = _S6697; + DiffPair_float_0 _S7094; + (&_S7094)->primal_0 = _S7092; + (&_S7094)->differential_0 = _S7091; + s_bwd_prop_s_fwd_length_impl_0(&_S7093, &_S7094); + float2 _S7095 = _S7093.differential_0.primal_0 + _S7063; + float3 _S7096 = make_float3 (_S7095.x, _S7095.y, _S7090); + float _S7097 = length_0(_S6699); + float _S7098 = s_primal_ctx_atan2_0(_S7097, _S6704); + bool _S7099 = _S7097 < 9.99999997475242708e-07f; + if(_S7099) + { + float _S7100 = 1.0f - _S7098 * _S7098 / 24.0f; + float _S7101 = _S6704 * _S6704; + k_25 = _S7100 / _S6704; + _S6783 = _S7101; + _S6784 = _S7100; + _S6785 = 0.0f; + _S6786 = 0.0f; + _S6787 = 0.0f; + } + else + { + float _S7102 = 0.5f * _S7098; + float _S7103 = 2.0f * s_primal_ctx_sin_0(_S7102); + float _S7104 = _S7097 * _S7097; + k_25 = _S7103 / _S7097; + _S6783 = 0.0f; + _S6784 = 0.0f; + _S6785 = _S7104; + _S6786 = _S7103; + _S6787 = _S7102; + } + float2 _S7105 = make_float2 (k_25); + float2 _S7106 = _S6699 * make_float2 (k_25); + float2 _S7107 = make_float2 (fx_44 * v_mean2d_9.x, fy_44 * v_mean2d_9.y); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7108; + (&_S7108)->primal_0 = _S7106; + (&_S7108)->differential_0 = _S6696; + FixedArray _S7109 = dist_coeffs_43; + s_bwd_prop_DistThinPrism_distort_0(&_S7108, &_S7109, _S7107); + float2 _S7110 = _S6699 * _S7108.differential_0; + float2 _S7111 = _S7105 * _S7108.differential_0; + float _S7112 = _S7110.x + _S7110.y; + if(_S7099) + { + float _S7113 = _S7112 / _S6783; + float _S7114 = _S6784 * - _S7113; + float _S7115 = _S7098 * (0.0416666679084301f * - (_S6704 * _S7113)); + k_25 = _S7115 + _S7115; + _S6783 = _S7114; + _S6784 = 0.0f; + } + else + { + float _S7116 = _S7112 / _S6785; + float _S7117 = _S6786 * - _S7116; + float _S7118 = 2.0f * (_S7097 * _S7116); + DiffPair_float_0 _S7119; + (&_S7119)->primal_0 = _S6787; + (&_S7119)->differential_0 = 0.0f; + s_bwd_prop_sin_0(&_S7119, _S7118); + k_25 = 0.5f * _S7119.differential_0; + _S6783 = 0.0f; + _S6784 = _S7117; + } + DiffPair_float_0 _S7120; + (&_S7120)->primal_0 = _S7097; + (&_S7120)->differential_0 = 0.0f; + DiffPair_float_0 _S7121; + (&_S7121)->primal_0 = _S6704; + (&_S7121)->differential_0 = 0.0f; + s_bwd_prop_atan2_0(&_S7120, &_S7121, k_25); + float _S7122 = _S7121.differential_0 + _S6783; + float _S7123 = _S7120.differential_0 + _S6784; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7124; + (&_S7124)->primal_0 = _S6699; + (&_S7124)->differential_0 = _S6696; + s_bwd_length_impl_2(&_S7124, _S7123); + float2 _S7125 = _S7124.differential_0 + _S7111; + float3 _S7126 = make_float3 (_S7125.x, _S7125.y, _S7122); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7127; + (&_S7127)->primal_0 = _S6780; + (&_S7127)->differential_0 = _S6962; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7128; + (&_S7128)->primal_0 = _S6781; + (&_S7128)->differential_0 = _S6962; + s_bwd_prop_mul_2(&_S7127, &_S7128, _S6964.differential_0); + Matrix _S7129 = transpose_3(_S7128.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7130; + (&_S7130)->primal_0 = R_31; + (&_S7130)->differential_0 = _S6962; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7131; + (&_S7131)->primal_0 = _S6779; + (&_S7131)->differential_0 = _S6962; + s_bwd_prop_mul_2(&_S7130, &_S7131, _S7127.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7132; + (&_S7132)->primal_0 = _S6777; + (&_S7132)->differential_0 = _S6962; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7133; + (&_S7133)->primal_0 = _S6778; + (&_S7133)->differential_0 = _S6962; + s_bwd_prop_mul_2(&_S7132, &_S7133, _S7131.differential_0); + Matrix _S7134 = _S7132.differential_0 + transpose_3(_S7133.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7135; + (&_S7135)->primal_0 = _S6776; + (&_S7135)->differential_0 = _S6962; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7136; + (&_S7136)->primal_0 = S_9; + (&_S7136)->differential_0 = _S6962; + s_bwd_prop_mul_2(&_S7135, &_S7136, _S7134); + Matrix _S7137 = transpose_3(_S7135.differential_0); + float _S7138 = 2.0f * - _S7137.rows[int(2)].z; + float _S7139 = 2.0f * _S7137.rows[int(2)].y; + float _S7140 = 2.0f * _S7137.rows[int(2)].x; + float _S7141 = 2.0f * _S7137.rows[int(1)].z; + float _S7142 = 2.0f * - _S7137.rows[int(1)].y; + float _S7143 = 2.0f * _S7137.rows[int(1)].x; + float _S7144 = 2.0f * _S7137.rows[int(0)].z; + float _S7145 = 2.0f * _S7137.rows[int(0)].y; + float _S7146 = 2.0f * - _S7137.rows[int(0)].x; + float _S7147 = - _S7143 + _S7145; + float _S7148 = _S7140 + - _S7144; + float _S7149 = - _S7139 + _S7141; + float _S7150 = _S7139 + _S7141; + float _S7151 = _S7140 + _S7144; + float _S7152 = _S7143 + _S7145; + float _S7153 = _S6773.w * (_S7142 + _S7146); + float _S7154 = _S6773.z * (_S7138 + _S7146); + float _S7155 = _S6773.y * (_S7138 + _S7142); + float _S7156 = _S6773.x * _S7147 + _S6773.z * _S7150 + _S6773.y * _S7151 + _S7153 + _S7153; + float _S7157 = _S6773.x * _S7148 + _S6773.w * _S7150 + _S6773.y * _S7152 + _S7154 + _S7154; + float _S7158 = _S6773.x * _S7149 + _S6773.w * _S7151 + _S6773.z * _S7152 + _S7155 + _S7155; + float _S7159 = _S6773.w * _S7147 + _S6773.z * _S7148 + _S6773.y * _S7149; + float3 _S7160 = _S6907; + *&((&_S7160)->z) = _S7136.differential_0.rows[int(2)].z; + *&((&_S7160)->y) = _S7136.differential_0.rows[int(1)].y; + *&((&_S7160)->x) = _S7136.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7161; + (&_S7161)->primal_0 = scale_31; + (&_S7161)->differential_0 = _S6907; + s_bwd_prop_exp_1(&_S7161, _S7160); + float4 _S7162 = make_float4 (0.0f); + float4 _S7163 = _S7162; + *&((&_S7163)->w) = _S7156; + *&((&_S7163)->z) = _S7157; + *&((&_S7163)->y) = _S7158; + *&((&_S7163)->x) = _S7159; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S7164; + (&_S7164)->primal_0 = quat_31; + (&_S7164)->differential_0 = _S7162; + s_bwd_normalize_impl_0(&_S7164, _S7163); + float _S7165 = - (s_diff_k_15 / _S6772); + DiffPair_float_0 _S7166; + (&_S7166)->primal_0 = _S6769; + (&_S7166)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S7166, _S7165); + float _S7167 = - _S7166.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7168; + (&_S7168)->primal_0 = mean_c_31; + (&_S7168)->differential_0 = _S6907; + s_bwd_length_impl_0(&_S7168, v_depth_9); + float3 _S7169 = _S7096 + _S7126 + _S7168.differential_0 + _S7057; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7170; + (&_S7170)->primal_0 = R_31; + (&_S7170)->differential_0 = _S6962; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7171; + (&_S7171)->primal_0 = mean_32; + (&_S7171)->differential_0 = _S6907; + s_bwd_prop_mul_3(&_S7170, &_S7171, _S7169); + Matrix _S7172 = _S7129 + _S7130.differential_0 + _S7170.differential_0; + float _S7173 = _S7167 + _S6914.differential_0; + float3 _S7174 = _S7161.differential_0 + _S6913.differential_0; + *v_mean_9 = *v_mean_9 + (_S7171.differential_0 + _S6912.differential_0); + *v_quat_9 = *v_quat_9 + _S7164.differential_0; + *v_scale_9 = *v_scale_9 + _S7174; + *v_in_opacity_9 = *v_in_opacity_9 + _S7173; + *v_R_9 = *v_R_9 + _S7172; + *v_t_9 = *v_t_9 + _S7169; return; } -struct s_bwd_prop_DiffProjection3DGS_3dgut_equisolid_projection_Intermediates_0 +inline __device__ void s_bwd_prop_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S7175, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S7176, float _S7177) { - float2 _S3651; - float2 _S3652; - float2 _S3653; - float2 _S3654; - float2 _S3655; - float2 _S3656; - float2 _S3657; + _d_dot_0(_S7175, _S7176, _S7177); + return; +} + +inline __device__ void projection_3dgs_equirect_none_vjp(bool antialiased_32, float3 mean_33, float4 quat_32, float3 scale_32, float in_opacity_32, Matrix R_32, float3 t_32, float fx_45, float fy_45, float cx_36, float cy_36, FixedArray dist_coeffs_44, uint image_width_32, uint image_height_32, float2 v_mean2d_10, float v_depth_10, float3 v_conic_10, float v_opacity_10, float3 * v_mean_10, float4 * v_quat_10, float3 * v_scale_10, float * v_in_opacity_10, Matrix * v_R_10, float3 * v_t_10) +{ + float3 mean_c_32 = s_primal_ctx_mul_0(R_32, mean_33) + t_32; + float _S7178 = - in_opacity_32; + float _S7179 = 1.0f + s_primal_ctx_exp_0(_S7178); + float _S7180 = 1.0f / _S7179; + float _S7181 = _S7179 * _S7179; + float4 _S7182 = normalize_0(quat_32); + float3 _S7183 = s_primal_ctx_exp_1(scale_32); + float _S7184 = _S7182.y; + float x2_32 = _S7184 * _S7184; + float y2_32 = _S7182.z * _S7182.z; + float z2_32 = _S7182.w * _S7182.w; + float xy_32 = _S7182.y * _S7182.z; + float xz_32 = _S7182.y * _S7182.w; + float yz_32 = _S7182.z * _S7182.w; + float wx_32 = _S7182.x * _S7182.y; + float wy_32 = _S7182.x * _S7182.z; + float wz_32 = _S7182.x * _S7182.w; + Matrix _S7185 = transpose_3(makeMatrix (1.0f - 2.0f * (y2_32 + z2_32), 2.0f * (xy_32 + wz_32), 2.0f * (xz_32 - wy_32), 2.0f * (xy_32 - wz_32), 1.0f - 2.0f * (x2_32 + z2_32), 2.0f * (yz_32 + wx_32), 2.0f * (xz_32 + wy_32), 2.0f * (yz_32 - wx_32), 1.0f - 2.0f * (x2_32 + y2_32))); + Matrix S_10 = makeMatrix (_S7183.x, 0.0f, 0.0f, 0.0f, _S7183.y, 0.0f, 0.0f, 0.0f, _S7183.z); + Matrix _S7186 = s_primal_ctx_mul_1(_S7185, S_10); + Matrix _S7187 = transpose_3(_S7186); + Matrix _S7188 = s_primal_ctx_mul_1(_S7186, _S7187); + Matrix _S7189 = s_primal_ctx_mul_1(R_32, _S7188); + Matrix _S7190 = transpose_3(R_32); + Matrix _S7191 = s_primal_ctx_mul_1(_S7189, _S7190); + Matrix J_42 = makeMatrix (0.0f); + float _S7192 = mean_c_32.x; + float _S7193 = mean_c_32.z; + DiffPair_float_0 _S7194 = { _S7192, 1.0f }; + DiffPair_float_0 _S7195 = { _S7193, 0.0f }; + DiffPair_float_0 _S7196; + (&_S7196)->primal_0 = _S7192; + (&_S7196)->differential_0 = 1.0f; + DiffPair_float_0 _S7197; + (&_S7197)->primal_0 = _S7193; + (&_S7197)->differential_0 = 0.0f; + DiffPair_float_0 _S7198 = s_primal_ctx_d_atan2_0(&_S7196, &_S7197); + float _S7199 = mean_c_32.y; + float2 _S7200 = float2 {mean_c_32.x, mean_c_32.z}; + float2 _S7201 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7202 = { _S7200, _S7201 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7203; + (&_S7203)->primal_0 = _S7200; + (&_S7203)->differential_0 = _S7201; + DiffPair_float_0 _S7204 = s_primal_ctx_s_fwd_length_impl_0(&_S7203); + DiffPair_float_0 _S7205 = { _S7199, 0.0f }; + DiffPair_float_0 _S7206 = { _S7204.primal_0, _S7204.differential_0 }; + DiffPair_float_0 _S7207; + (&_S7207)->primal_0 = _S7199; + (&_S7207)->differential_0 = 0.0f; + DiffPair_float_0 _S7208; + (&_S7208)->primal_0 = _S7204.primal_0; + (&_S7208)->differential_0 = _S7204.differential_0; + DiffPair_float_0 _S7209 = s_primal_ctx_d_atan2_0(&_S7207, &_S7208); + float _S7210 = _S7198.differential_0 * fx_45; + float _S7211 = _S7209.differential_0 * fy_45; + Matrix _S7212 = J_42; + *&(((&_S7212)->rows + (int(0)))->x) = _S7210; + *&(((&_S7212)->rows + (int(1)))->x) = _S7211; + DiffPair_float_0 _S7213 = { _S7192, 0.0f }; + DiffPair_float_0 _S7214; + (&_S7214)->primal_0 = _S7192; + (&_S7214)->differential_0 = 0.0f; + DiffPair_float_0 _S7215; + (&_S7215)->primal_0 = _S7193; + (&_S7215)->differential_0 = 0.0f; + DiffPair_float_0 _S7216 = s_primal_ctx_d_atan2_0(&_S7214, &_S7215); + float2 _S7217 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7218 = { _S7200, _S7217 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7219; + (&_S7219)->primal_0 = _S7200; + (&_S7219)->differential_0 = _S7217; + DiffPair_float_0 _S7220 = s_primal_ctx_s_fwd_length_impl_0(&_S7219); + DiffPair_float_0 _S7221 = { _S7199, 1.0f }; + DiffPair_float_0 _S7222 = { _S7220.primal_0, _S7220.differential_0 }; + DiffPair_float_0 _S7223; + (&_S7223)->primal_0 = _S7199; + (&_S7223)->differential_0 = 1.0f; + DiffPair_float_0 _S7224; + (&_S7224)->primal_0 = _S7220.primal_0; + (&_S7224)->differential_0 = _S7220.differential_0; + DiffPair_float_0 _S7225 = s_primal_ctx_d_atan2_0(&_S7223, &_S7224); + float _S7226 = _S7225.differential_0 * fy_45; + *&(((&_S7212)->rows + (int(0)))->y) = _S7216.differential_0 * fx_45; + *&(((&_S7212)->rows + (int(1)))->y) = _S7226; + DiffPair_float_0 _S7227 = { _S7193, 1.0f }; + DiffPair_float_0 _S7228; + (&_S7228)->primal_0 = _S7192; + (&_S7228)->differential_0 = 0.0f; + DiffPair_float_0 _S7229; + (&_S7229)->primal_0 = _S7193; + (&_S7229)->differential_0 = 1.0f; + DiffPair_float_0 _S7230 = s_primal_ctx_d_atan2_0(&_S7228, &_S7229); + float2 _S7231 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7232 = { _S7200, _S7231 }; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7233; + (&_S7233)->primal_0 = _S7200; + (&_S7233)->differential_0 = _S7231; + DiffPair_float_0 _S7234 = s_primal_ctx_s_fwd_length_impl_0(&_S7233); + DiffPair_float_0 _S7235 = { _S7234.primal_0, _S7234.differential_0 }; + DiffPair_float_0 _S7236; + (&_S7236)->primal_0 = _S7199; + (&_S7236)->differential_0 = 0.0f; + DiffPair_float_0 _S7237; + (&_S7237)->primal_0 = _S7234.primal_0; + (&_S7237)->differential_0 = _S7234.differential_0; + DiffPair_float_0 _S7238 = s_primal_ctx_d_atan2_0(&_S7236, &_S7237); + float _S7239 = _S7238.differential_0 * fy_45; + *&(((&_S7212)->rows + (int(0)))->z) = _S7230.differential_0 * fx_45; + *&(((&_S7212)->rows + (int(1)))->z) = _S7239; + Matrix _S7240 = s_primal_ctx_mul_2(_S7212, _S7191); + Matrix _S7241 = transpose_1(_S7212); + Matrix _S7242 = s_primal_ctx_mul_3(_S7240, _S7241); + float eps2d_32; + if(antialiased_32) + { + eps2d_32 = 0.10000000149011612f; + } + else + { + eps2d_32 = 0.30000001192092896f; + } + float _S7243 = _S7242.rows[int(0)].y * _S7242.rows[int(1)].x; + float det_orig_32 = _S7242.rows[int(0)].x * _S7242.rows[int(1)].y - _S7243; + float _S7244 = _S7242.rows[int(0)].x + eps2d_32; + Matrix _S7245 = _S7242; + *&(((&_S7245)->rows + (int(0)))->x) = _S7244; + float _S7246 = _S7242.rows[int(1)].y + eps2d_32; + *&(((&_S7245)->rows + (int(1)))->y) = _S7246; + Matrix _S7247 = _S7245; + Matrix _S7248 = _S7245; + float det_blur_32 = _S7244 * _S7246 - _S7243; + float _S7249 = det_orig_32 / det_blur_32; + float _S7250 = det_blur_32 * det_blur_32; + float _S7251 = (F32_max((0.0f), (_S7249))); + float _S7252 = s_primal_ctx_sqrt_0(_S7251); + float invdet_38 = 1.0f / det_blur_32; + float _S7253 = - _S7242.rows[int(0)].y; + float _S7254 = - _S7242.rows[int(1)].x; + if(antialiased_32) + { + eps2d_32 = _S7180 * _S7252; + } + else + { + eps2d_32 = _S7180; + } + float _S7255 = eps2d_32 / 0.00392156885936856f; + float _S7256 = 2.0f * s_primal_ctx_log_0(_S7255); + float _S7257 = s_primal_ctx_sqrt_0(_S7256); + float _S7258 = _S7247.rows[int(0)].x; + float _S7259 = _S7248.rows[int(1)].y; + float3 campos_11 = - s_primal_ctx_mul_0(_S7190, t_32); + float3 _S7260 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7261; + (&_S7261)->primal_0 = mean_33; + (&_S7261)->differential_0 = _S7260; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7262; + (&_S7262)->primal_0 = scale_32; + (&_S7262)->differential_0 = _S7260; + DiffPair_float_0 _S7263; + (&_S7263)->primal_0 = in_opacity_32; + (&_S7263)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7264; + (&_S7264)->primal_0 = campos_11; + (&_S7264)->differential_0 = _S7260; + s_bwd_prop_view_radius_3dgs_0(&_S7261, &_S7262, &_S7263, &_S7264, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7265 = _S7261; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7266 = _S7262; + DiffPair_float_0 _S7267 = _S7263; + float2 _S7268 = make_float2 (0.0f); + float2 _S7269 = _S7268; + *&((&_S7269)->y) = v_conic_10.z; + float2 _S7270 = _S7268; + *&((&_S7270)->y) = v_conic_10.y; + *&((&_S7270)->x) = v_conic_10.x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7271; + (&_S7271)->primal_0 = mean_c_32; + (&_S7271)->differential_0 = _S7260; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7272; + (&_S7272)->primal_0 = mean_c_32; + (&_S7272)->differential_0 = _S7260; + s_bwd_prop_dot_0(&_S7271, &_S7272, 0.0f); + DiffPair_float_0 _S7273; + (&_S7273)->primal_0 = _S7259; + (&_S7273)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7273, 0.0f); + DiffPair_float_0 _S7274; + (&_S7274)->primal_0 = _S7258; + (&_S7274)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7274, 0.0f); + DiffPair_float_0 _S7275; + (&_S7275)->primal_0 = 3.32999992370605469f; + (&_S7275)->differential_0 = 0.0f; + DiffPair_float_0 _S7276; + (&_S7276)->primal_0 = _S7257; + (&_S7276)->differential_0 = 0.0f; + _d_min_0(&_S7275, &_S7276, 0.0f); + DiffPair_float_0 _S7277; + (&_S7277)->primal_0 = _S7256; + (&_S7277)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7277, _S7276.differential_0); + float _S7278 = 2.0f * _S7277.differential_0; + DiffPair_float_0 _S7279; + (&_S7279)->primal_0 = _S7255; + (&_S7279)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S7279, _S7278); + float _S7280 = v_opacity_10 + 254.9999847412109375f * _S7279.differential_0; + Matrix _S7281 = makeMatrix (0.0f); + Matrix _S7282 = _S7281; + _S7282[int(1)] = _S7269; + _S7282[int(0)] = _S7270; + Matrix _S7283 = _S7282; + float3 _S7284 = _S7272.differential_0 + _S7271.differential_0; + float2 _S7285 = make_float2 (0.0f, _S7273.differential_0); + float2 _S7286 = make_float2 (_S7274.differential_0, 0.0f); + float _S7287; + if(antialiased_32) + { + float _S7288 = _S7252 * _S7280; + eps2d_32 = _S7180 * _S7280; + _S7287 = _S7288; + } + else + { + eps2d_32 = 0.0f; + _S7287 = _S7280; + } + float _S7289 = invdet_38 * _S7283.rows[int(1)].y; + float _S7290 = - (invdet_38 * _S7283.rows[int(1)].x); + float _S7291 = - (invdet_38 * _S7283.rows[int(0)].y); + float _S7292 = invdet_38 * _S7283.rows[int(0)].x; + float _S7293 = - ((_S7244 * _S7283.rows[int(1)].y + _S7254 * _S7283.rows[int(1)].x + _S7253 * _S7283.rows[int(0)].y + _S7246 * _S7283.rows[int(0)].x) / _S7250); + DiffPair_float_0 _S7294; + (&_S7294)->primal_0 = _S7251; + (&_S7294)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7294, eps2d_32); + DiffPair_float_0 _S7295 = { 0.0f, 0.0f }; + DiffPair_float_0 _S7296; + (&_S7296)->primal_0 = 0.0f; + (&_S7296)->differential_0 = 0.0f; + DiffPair_float_0 _S7297; + (&_S7297)->primal_0 = _S7249; + (&_S7297)->differential_0 = 0.0f; + _d_max_0(&_S7296, &_S7297, _S7294.differential_0); + float _S7298 = _S7297.differential_0 / _S7250; + float s_diff_det_orig_T_10 = det_blur_32 * _S7298; + float _S7299 = det_orig_32 * - _S7298 + _S7293; + float _S7300 = - _S7299; + float _S7301 = _S7244 * _S7299; + float _S7302 = _S7246 * _S7299; + Matrix _S7303 = _S7281; + _S7303[int(1)] = _S7285; + _S7303[int(0)] = _S7286; + _S7245 = _S7303; + *&(((&_S7245)->rows + (int(1)))->y) = 0.0f; + float _S7304 = _S7301 + _S7303.rows[int(1)].y + _S7292; + *&(((&_S7245)->rows + (int(0)))->x) = 0.0f; + float _S7305 = _S7302 + _S7303.rows[int(0)].x + _S7289; + float _S7306 = _S7300 + - s_diff_det_orig_T_10; + float _S7307 = _S7242.rows[int(0)].y * _S7306 + _S7290; + float _S7308 = _S7242.rows[int(1)].x * _S7306 + _S7291; + float _S7309 = _S7242.rows[int(1)].y * s_diff_det_orig_T_10; + float _S7310 = _S7304 + _S7242.rows[int(0)].x * s_diff_det_orig_T_10; + float2 _S7311 = _S7268; + *&((&_S7311)->x) = _S7307; + *&((&_S7311)->y) = _S7310; + float _S7312 = _S7305 + _S7309; + float2 _S7313 = _S7268; + *&((&_S7313)->y) = _S7308; + *&((&_S7313)->x) = _S7312; + Matrix _S7314 = _S7281; + _S7314[int(1)] = _S7311; + _S7314[int(0)] = _S7313; + Matrix _S7315 = _S7245 + _S7314; + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S7316; + (&_S7316)->primal_0 = _S7240; + (&_S7316)->differential_0 = J_42; + Matrix _S7317 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C2x3E_0 _S7318; + (&_S7318)->primal_0 = _S7241; + (&_S7318)->differential_0 = _S7317; + s_bwd_prop_mul_0(&_S7316, &_S7318, _S7315); + Matrix _S7319 = transpose_2(_S7318.differential_0); + DiffPair_matrixx3Cfloatx2C2x2C3x3E_0 _S7320; + (&_S7320)->primal_0 = _S7212; + (&_S7320)->differential_0 = J_42; + Matrix _S7321 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7322; + (&_S7322)->primal_0 = _S7191; + (&_S7322)->differential_0 = _S7321; + s_bwd_prop_mul_1(&_S7320, &_S7322, _S7316.differential_0); + Matrix _S7323 = _S7319 + _S7320.differential_0; + float _S7324 = fy_45 * _S7323.rows[int(1)].z; + float _S7325 = fx_45 * _S7323.rows[int(0)].z; + DiffPair_1 _S7326; + (&_S7326)->primal_0 = _S7205; + (&_S7326)->differential_0 = _S7295; + DiffPair_1 _S7327; + (&_S7327)->primal_0 = _S7235; + (&_S7327)->differential_0 = _S7295; + DiffPair_float_0 _S7328; + (&_S7328)->primal_0 = 0.0f; + (&_S7328)->differential_0 = _S7324; + s_bwd_prop_d_atan2_0(&_S7326, &_S7327, &_S7328); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7329 = { _S7268, _S7268 }; + DiffPair_0 _S7330; + (&_S7330)->primal_0 = _S7232; + (&_S7330)->differential_0 = _S7329; + DiffPair_float_0 _S7331; + (&_S7331)->primal_0 = _S7327.differential_0.primal_0; + (&_S7331)->differential_0 = _S7327.differential_0.differential_0; + s_bwd_prop_s_fwd_length_impl_0(&_S7330, &_S7331); + DiffPair_1 _S7332; + (&_S7332)->primal_0 = _S7213; + (&_S7332)->differential_0 = _S7295; + DiffPair_1 _S7333; + (&_S7333)->primal_0 = _S7227; + (&_S7333)->differential_0 = _S7295; + DiffPair_float_0 _S7334; + (&_S7334)->primal_0 = 0.0f; + (&_S7334)->differential_0 = _S7325; + s_bwd_prop_d_atan2_0(&_S7332, &_S7333, &_S7334); + float3 _S7335 = make_float3 (_S7330.differential_0.primal_0.x + _S7332.differential_0.primal_0, _S7326.differential_0.primal_0, _S7330.differential_0.primal_0.y + _S7333.differential_0.primal_0); + float _S7336 = fy_45 * _S7323.rows[int(1)].y; + float _S7337 = fx_45 * _S7323.rows[int(0)].y; + DiffPair_1 _S7338; + (&_S7338)->primal_0 = _S7221; + (&_S7338)->differential_0 = _S7295; + DiffPair_1 _S7339; + (&_S7339)->primal_0 = _S7222; + (&_S7339)->differential_0 = _S7295; + DiffPair_float_0 _S7340; + (&_S7340)->primal_0 = 0.0f; + (&_S7340)->differential_0 = _S7336; + s_bwd_prop_d_atan2_0(&_S7338, &_S7339, &_S7340); + DiffPair_0 _S7341; + (&_S7341)->primal_0 = _S7218; + (&_S7341)->differential_0 = _S7329; + DiffPair_float_0 _S7342; + (&_S7342)->primal_0 = _S7339.differential_0.primal_0; + (&_S7342)->differential_0 = _S7339.differential_0.differential_0; + s_bwd_prop_s_fwd_length_impl_0(&_S7341, &_S7342); + DiffPair_1 _S7343; + (&_S7343)->primal_0 = _S7213; + (&_S7343)->differential_0 = _S7295; + DiffPair_1 _S7344; + (&_S7344)->primal_0 = _S7195; + (&_S7344)->differential_0 = _S7295; + DiffPair_float_0 _S7345; + (&_S7345)->primal_0 = 0.0f; + (&_S7345)->differential_0 = _S7337; + s_bwd_prop_d_atan2_0(&_S7343, &_S7344, &_S7345); + float3 _S7346 = make_float3 (_S7341.differential_0.primal_0.x + _S7343.differential_0.primal_0, _S7338.differential_0.primal_0, _S7341.differential_0.primal_0.y + _S7344.differential_0.primal_0); + float _S7347 = fy_45 * _S7323.rows[int(1)].x; + float _S7348 = fx_45 * _S7323.rows[int(0)].x; + DiffPair_1 _S7349; + (&_S7349)->primal_0 = _S7205; + (&_S7349)->differential_0 = _S7295; + DiffPair_1 _S7350; + (&_S7350)->primal_0 = _S7206; + (&_S7350)->differential_0 = _S7295; + DiffPair_float_0 _S7351; + (&_S7351)->primal_0 = 0.0f; + (&_S7351)->differential_0 = _S7347; + s_bwd_prop_d_atan2_0(&_S7349, &_S7350, &_S7351); + DiffPair_0 _S7352; + (&_S7352)->primal_0 = _S7202; + (&_S7352)->differential_0 = _S7329; + DiffPair_float_0 _S7353; + (&_S7353)->primal_0 = _S7350.differential_0.primal_0; + (&_S7353)->differential_0 = _S7350.differential_0.differential_0; + s_bwd_prop_s_fwd_length_impl_0(&_S7352, &_S7353); + DiffPair_1 _S7354; + (&_S7354)->primal_0 = _S7194; + (&_S7354)->differential_0 = _S7295; + DiffPair_1 _S7355; + (&_S7355)->primal_0 = _S7195; + (&_S7355)->differential_0 = _S7295; + DiffPair_float_0 _S7356; + (&_S7356)->primal_0 = 0.0f; + (&_S7356)->differential_0 = _S7348; + s_bwd_prop_d_atan2_0(&_S7354, &_S7355, &_S7356); + float3 _S7357 = make_float3 (_S7352.differential_0.primal_0.x + _S7354.differential_0.primal_0, _S7349.differential_0.primal_0, _S7352.differential_0.primal_0.y + _S7355.differential_0.primal_0); + float _S7358 = length_0(_S7200); + float _S7359 = fy_45 * v_mean2d_10.y; + float _S7360 = fx_45 * v_mean2d_10.x; + DiffPair_float_0 _S7361; + (&_S7361)->primal_0 = _S7199; + (&_S7361)->differential_0 = 0.0f; + DiffPair_float_0 _S7362; + (&_S7362)->primal_0 = _S7358; + (&_S7362)->differential_0 = 0.0f; + s_bwd_prop_atan2_0(&_S7361, &_S7362, _S7359); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S7363; + (&_S7363)->primal_0 = _S7200; + (&_S7363)->differential_0 = _S7268; + s_bwd_length_impl_2(&_S7363, _S7362.differential_0); + DiffPair_float_0 _S7364; + (&_S7364)->primal_0 = _S7192; + (&_S7364)->differential_0 = 0.0f; + DiffPair_float_0 _S7365; + (&_S7365)->primal_0 = _S7193; + (&_S7365)->differential_0 = 0.0f; + s_bwd_prop_atan2_0(&_S7364, &_S7365, _S7360); + float3 _S7366 = make_float3 (_S7363.differential_0.x + _S7364.differential_0, _S7361.differential_0, _S7363.differential_0.y + _S7365.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7367; + (&_S7367)->primal_0 = _S7189; + (&_S7367)->differential_0 = _S7321; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7368; + (&_S7368)->primal_0 = _S7190; + (&_S7368)->differential_0 = _S7321; + s_bwd_prop_mul_2(&_S7367, &_S7368, _S7322.differential_0); + Matrix _S7369 = transpose_3(_S7368.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7370; + (&_S7370)->primal_0 = R_32; + (&_S7370)->differential_0 = _S7321; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7371; + (&_S7371)->primal_0 = _S7188; + (&_S7371)->differential_0 = _S7321; + s_bwd_prop_mul_2(&_S7370, &_S7371, _S7367.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7372; + (&_S7372)->primal_0 = _S7186; + (&_S7372)->differential_0 = _S7321; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7373; + (&_S7373)->primal_0 = _S7187; + (&_S7373)->differential_0 = _S7321; + s_bwd_prop_mul_2(&_S7372, &_S7373, _S7371.differential_0); + Matrix _S7374 = _S7372.differential_0 + transpose_3(_S7373.differential_0); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7375; + (&_S7375)->primal_0 = _S7185; + (&_S7375)->differential_0 = _S7321; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7376; + (&_S7376)->primal_0 = S_10; + (&_S7376)->differential_0 = _S7321; + s_bwd_prop_mul_2(&_S7375, &_S7376, _S7374); + Matrix _S7377 = transpose_3(_S7375.differential_0); + float _S7378 = 2.0f * - _S7377.rows[int(2)].z; + float _S7379 = 2.0f * _S7377.rows[int(2)].y; + float _S7380 = 2.0f * _S7377.rows[int(2)].x; + float _S7381 = 2.0f * _S7377.rows[int(1)].z; + float _S7382 = 2.0f * - _S7377.rows[int(1)].y; + float _S7383 = 2.0f * _S7377.rows[int(1)].x; + float _S7384 = 2.0f * _S7377.rows[int(0)].z; + float _S7385 = 2.0f * _S7377.rows[int(0)].y; + float _S7386 = 2.0f * - _S7377.rows[int(0)].x; + float _S7387 = - _S7383 + _S7385; + float _S7388 = _S7380 + - _S7384; + float _S7389 = - _S7379 + _S7381; + float _S7390 = _S7379 + _S7381; + float _S7391 = _S7380 + _S7384; + float _S7392 = _S7383 + _S7385; + float _S7393 = _S7182.w * (_S7382 + _S7386); + float _S7394 = _S7182.z * (_S7378 + _S7386); + float _S7395 = _S7182.y * (_S7378 + _S7382); + float _S7396 = _S7182.x * _S7387 + _S7182.z * _S7390 + _S7182.y * _S7391 + _S7393 + _S7393; + float _S7397 = _S7182.x * _S7388 + _S7182.w * _S7390 + _S7182.y * _S7392 + _S7394 + _S7394; + float _S7398 = _S7182.x * _S7389 + _S7182.w * _S7391 + _S7182.z * _S7392 + _S7395 + _S7395; + float _S7399 = _S7182.w * _S7387 + _S7182.z * _S7388 + _S7182.y * _S7389; + float3 _S7400 = _S7260; + *&((&_S7400)->z) = _S7376.differential_0.rows[int(2)].z; + *&((&_S7400)->y) = _S7376.differential_0.rows[int(1)].y; + *&((&_S7400)->x) = _S7376.differential_0.rows[int(0)].x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7401; + (&_S7401)->primal_0 = scale_32; + (&_S7401)->differential_0 = _S7260; + s_bwd_prop_exp_1(&_S7401, _S7400); + float4 _S7402 = make_float4 (0.0f); + float4 _S7403 = _S7402; + *&((&_S7403)->w) = _S7396; + *&((&_S7403)->z) = _S7397; + *&((&_S7403)->y) = _S7398; + *&((&_S7403)->x) = _S7399; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S7404; + (&_S7404)->primal_0 = quat_32; + (&_S7404)->differential_0 = _S7402; + s_bwd_normalize_impl_0(&_S7404, _S7403); + float _S7405 = - (_S7287 / _S7181); + DiffPair_float_0 _S7406; + (&_S7406)->primal_0 = _S7178; + (&_S7406)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S7406, _S7405); + float _S7407 = - _S7406.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7408; + (&_S7408)->primal_0 = mean_c_32; + (&_S7408)->differential_0 = _S7260; + s_bwd_length_impl_0(&_S7408, v_depth_10); + float3 _S7409 = _S7335 + _S7346 + _S7357 + _S7366 + _S7408.differential_0 + _S7284; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7410; + (&_S7410)->primal_0 = R_32; + (&_S7410)->differential_0 = _S7321; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7411; + (&_S7411)->primal_0 = mean_33; + (&_S7411)->differential_0 = _S7260; + s_bwd_prop_mul_3(&_S7410, &_S7411, _S7409); + Matrix _S7412 = _S7369 + _S7370.differential_0 + _S7410.differential_0; + float _S7413 = _S7407 + _S7267.differential_0; + float3 _S7414 = _S7401.differential_0 + _S7266.differential_0; + *v_mean_10 = *v_mean_10 + (_S7411.differential_0 + _S7265.differential_0); + *v_quat_10 = *v_quat_10 + _S7404.differential_0; + *v_scale_10 = *v_scale_10 + _S7414; + *v_in_opacity_10 = *v_in_opacity_10 + _S7413; + *v_R_10 = *v_R_10 + _S7412; + *v_t_10 = *v_t_10 + _S7409; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgut_persp_none_projection_Intermediates_0 +{ + float2 _S7415; + float2 _S7416; + float2 _S7417; + float2 _S7418; + float2 _S7419; + float2 _S7420; + float2 _S7421; }; -inline __device__ void projection_3dgut_equisolid_vjp(bool antialiased_14, float3 mean_15, float4 quat_14, float3 scale_14, float in_opacity_14, Matrix R_14, float3 t_14, float fx_18, float fy_18, float cx_15, float cy_15, FixedArray dist_coeffs_18, uint image_width_14, uint image_height_14, float2 v_mean2d_6, float v_depth_6, float3 v_conic_6, float v_opacity_6, float3 * v_mean_6, float4 * v_quat_6, float3 * v_scale_6, float * v_in_opacity_6, Matrix * v_R_6, float3 * v_t_6) +inline __device__ float2 s_primal_ctx_DistNone_distort_0(float2 dpuv_8, FixedArray * coeffs_20) { - float2 _S3658 = make_float2 (0.0f); - s_bwd_prop_DiffProjection3DGS_3dgut_equisolid_projection_Intermediates_0 _S3659; - (&_S3659)->_S3651 = _S3658; - (&_S3659)->_S3652 = _S3658; - (&_S3659)->_S3653 = _S3658; - (&_S3659)->_S3654 = _S3658; - (&_S3659)->_S3655 = _S3658; - (&_S3659)->_S3656 = _S3658; - (&_S3659)->_S3657 = _S3658; - (&_S3659)->_S3651 = _S3658; - (&_S3659)->_S3652 = _S3658; - (&_S3659)->_S3653 = _S3658; - (&_S3659)->_S3654 = _S3658; - (&_S3659)->_S3655 = _S3658; - (&_S3659)->_S3656 = _S3658; - (&_S3659)->_S3657 = _S3658; - float3 _S3660 = make_float3 (0.0f); - float3 _S3661 = s_primal_ctx_exp_1(scale_14); - float4 _S3662 = normalize_0(quat_14); - float _S3663 = _S3662.y; - float x2_14 = _S3663 * _S3663; - float y2_14 = _S3662.z * _S3662.z; - float z2_14 = _S3662.w * _S3662.w; - float xy_14 = _S3662.y * _S3662.z; - float xz_14 = _S3662.y * _S3662.w; - float yz_14 = _S3662.z * _S3662.w; - float wx_14 = _S3662.x * _S3662.y; - float wy_14 = _S3662.x * _S3662.z; - float wz_14 = _S3662.x * _S3662.w; - Matrix _S3664 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_14 + z2_14), 2.0f * (xy_14 + wz_14), 2.0f * (xz_14 - wy_14), 2.0f * (xy_14 - wz_14), 1.0f - 2.0f * (x2_14 + z2_14), 2.0f * (yz_14 + wx_14), 2.0f * (xz_14 + wy_14), 2.0f * (yz_14 - wx_14), 1.0f - 2.0f * (x2_14 + y2_14)))); - FixedArray _S3665 = { - _S3660, _S3660, _S3660, _S3660, _S3660, _S3660, _S3660 + return dpuv_8; +} + +inline __device__ void projection_3dgut_persp_none_vjp(bool antialiased_33, float3 mean_34, float4 quat_33, float3 scale_33, float in_opacity_33, Matrix R_33, float3 t_33, float fx_46, float fy_46, float cx_37, float cy_37, FixedArray dist_coeffs_45, uint image_width_33, uint image_height_33, float2 v_mean2d_11, float v_depth_11, float3 v_conic_11, float v_opacity_11, float3 * v_mean_11, float4 * v_quat_11, float3 * v_scale_11, float * v_in_opacity_11, Matrix * v_R_11, float3 * v_t_11) +{ + float2 _S7422 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_persp_none_projection_Intermediates_0 _S7423; + (&_S7423)->_S7415 = _S7422; + (&_S7423)->_S7416 = _S7422; + (&_S7423)->_S7417 = _S7422; + (&_S7423)->_S7418 = _S7422; + (&_S7423)->_S7419 = _S7422; + (&_S7423)->_S7420 = _S7422; + (&_S7423)->_S7421 = _S7422; + float3 _S7424 = make_float3 (0.0f); + float3 _S7425 = s_primal_ctx_exp_1(scale_33); + float4 _S7426 = normalize_0(quat_33); + float _S7427 = _S7426.y; + float x2_33 = _S7427 * _S7427; + float y2_33 = _S7426.z * _S7426.z; + float z2_33 = _S7426.w * _S7426.w; + float xy_33 = _S7426.y * _S7426.z; + float xz_33 = _S7426.y * _S7426.w; + float yz_33 = _S7426.z * _S7426.w; + float wx_33 = _S7426.x * _S7426.y; + float wy_33 = _S7426.x * _S7426.z; + float wz_33 = _S7426.x * _S7426.w; + Matrix _S7428 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_33 + z2_33), 2.0f * (xy_33 + wz_33), 2.0f * (xz_33 - wy_33), 2.0f * (xy_33 - wz_33), 1.0f - 2.0f * (x2_33 + z2_33), 2.0f * (yz_33 + wx_33), 2.0f * (xz_33 + wy_33), 2.0f * (yz_33 - wx_33), 1.0f - 2.0f * (x2_33 + y2_33)))); + FixedArray _S7429 = { + _S7424, _S7424, _S7424, _S7424, _S7424, _S7424, _S7424 }; - FixedArray _S3666 = { + FixedArray _S7430 = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; - SigmaPoints_0 _S3667; - (&_S3667)->p_0 = _S3665; - (&_S3667)->w_mean_0 = _S3666; - (&_S3667)->w_cov_0 = _S3666; - (&_S3667)->p_0[int(0)] = mean_15; - SigmaPoints_0 _S3668 = _S3667; - (&_S3668)->w_mean_0[int(0)] = 0.0f; - (&_S3668)->w_cov_0[int(0)] = 2.0f; - float _S3669 = s_primal_ctx_sqrt_0(3.0f); - float _S3670 = _S3669 * _S3661.x; - float3 delta_18 = make_float3 (_S3670) * _S3664.rows[0U]; - float3 _S3671 = mean_15 + delta_18; - (&_S3668)->p_0[1U] = _S3671; - float3 _S3672 = mean_15 - delta_18; - (&_S3668)->p_0[4U] = _S3672; - float _S3673 = _S3669 * _S3661.y; - float3 delta_19 = make_float3 (_S3673) * _S3664.rows[1U]; - float3 _S3674 = mean_15 + delta_19; - (&_S3668)->p_0[2U] = _S3674; - float3 _S3675 = mean_15 - delta_19; - (&_S3668)->p_0[5U] = _S3675; - float _S3676 = _S3669 * _S3661.z; - float3 delta_20 = make_float3 (_S3676) * _S3664.rows[2U]; - float3 _S3677 = mean_15 + delta_20; - (&_S3668)->p_0[3U] = _S3677; - float3 _S3678 = mean_15 - delta_20; - (&_S3668)->p_0[6U] = _S3678; - (&_S3668)->w_mean_0[1U] = 0.1666666716337204f; - SigmaPoints_0 _S3679 = _S3668; - (&_S3679)->w_cov_0[1U] = 0.1666666716337204f; - SigmaPoints_0 _S3680 = _S3679; - (&_S3680)->w_mean_0[2U] = 0.1666666716337204f; - SigmaPoints_0 _S3681 = _S3680; - (&_S3681)->w_cov_0[2U] = 0.1666666716337204f; - SigmaPoints_0 _S3682 = _S3681; - (&_S3682)->w_mean_0[3U] = 0.1666666716337204f; - SigmaPoints_0 _S3683 = _S3682; - (&_S3683)->w_cov_0[3U] = 0.1666666716337204f; - SigmaPoints_0 _S3684 = _S3683; - (&_S3684)->w_mean_0[4U] = 0.1666666716337204f; - SigmaPoints_0 _S3685 = _S3684; - (&_S3685)->w_cov_0[4U] = 0.1666666716337204f; - SigmaPoints_0 _S3686 = _S3685; - (&_S3686)->w_mean_0[5U] = 0.1666666716337204f; - SigmaPoints_0 _S3687 = _S3686; - (&_S3687)->w_cov_0[5U] = 0.1666666716337204f; - SigmaPoints_0 _S3688 = _S3687; - (&_S3688)->w_mean_0[6U] = 0.1666666716337204f; - SigmaPoints_0 _S3689 = _S3688; - (&_S3689)->w_cov_0[6U] = 0.1666666716337204f; - SigmaPoints_0 _S3690 = _S3667; - float3 _S3691 = s_primal_ctx_mul_0(R_14, _S3667.p_0[0U]) + t_14; - _S3667 = _S3689; - (&_S3667)->p_0[0U] = _S3691; - SigmaPoints_0 _S3692 = _S3667; - (&_S3667)->p_0[1U] = s_primal_ctx_mul_0(R_14, _S3671) + t_14; - SigmaPoints_0 _S3693 = _S3667; - (&_S3667)->p_0[2U] = s_primal_ctx_mul_0(R_14, _S3674) + t_14; - SigmaPoints_0 _S3694 = _S3667; - (&_S3667)->p_0[3U] = s_primal_ctx_mul_0(R_14, _S3677) + t_14; - SigmaPoints_0 _S3695 = _S3667; - (&_S3667)->p_0[4U] = s_primal_ctx_mul_0(R_14, _S3672) + t_14; - SigmaPoints_0 _S3696 = _S3667; - (&_S3667)->p_0[5U] = s_primal_ctx_mul_0(R_14, _S3675) + t_14; - SigmaPoints_0 _S3697 = _S3667; - (&_S3667)->p_0[6U] = s_primal_ctx_mul_0(R_14, _S3678) + t_14; - SigmaPoints_0 _S3698 = _S3667; - float2 _S3699 = float2 {_S3692.p_0[int(0)].x, _S3692.p_0[int(0)].y}; - float _S3700 = length_0(_S3699); - float _S3701 = _S3692.p_0[int(0)].z; - float _S3702 = s_primal_ctx_atan2_0(_S3700, _S3701); - float k_9; - if(_S3700 < 9.99999997475242708e-07f) + SigmaPoints_0 _S7431; + (&_S7431)->p_0 = _S7429; + (&_S7431)->w_mean_0 = _S7430; + (&_S7431)->w_cov_0 = _S7430; + (&_S7431)->p_0[int(0)] = mean_34; + SigmaPoints_0 _S7432 = _S7431; + (&_S7432)->w_mean_0[int(0)] = 0.0f; + (&_S7432)->w_cov_0[int(0)] = 2.0f; + float _S7433 = s_primal_ctx_sqrt_0(3.0f); + float _S7434 = _S7433 * _S7425.x; + float3 delta_33 = make_float3 (_S7434) * _S7428.rows[0U]; + float3 _S7435 = mean_34 + delta_33; + (&_S7432)->p_0[1U] = _S7435; + float3 _S7436 = mean_34 - delta_33; + (&_S7432)->p_0[4U] = _S7436; + float _S7437 = _S7433 * _S7425.y; + float3 delta_34 = make_float3 (_S7437) * _S7428.rows[1U]; + float3 _S7438 = mean_34 + delta_34; + (&_S7432)->p_0[2U] = _S7438; + float3 _S7439 = mean_34 - delta_34; + (&_S7432)->p_0[5U] = _S7439; + float _S7440 = _S7433 * _S7425.z; + float3 delta_35 = make_float3 (_S7440) * _S7428.rows[2U]; + float3 _S7441 = mean_34 + delta_35; + (&_S7432)->p_0[3U] = _S7441; + float3 _S7442 = mean_34 - delta_35; + (&_S7432)->p_0[6U] = _S7442; + (&_S7432)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S7443 = _S7432; + (&_S7443)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S7444 = _S7443; + (&_S7444)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S7445 = _S7444; + (&_S7445)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S7446 = _S7445; + (&_S7446)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S7447 = _S7446; + (&_S7447)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S7448 = _S7447; + (&_S7448)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S7449 = _S7448; + (&_S7449)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S7450 = _S7449; + (&_S7450)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S7451 = _S7450; + (&_S7451)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S7452 = _S7451; + (&_S7452)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S7453 = _S7452; + (&_S7453)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S7454 = _S7431; + float3 _S7455 = s_primal_ctx_mul_0(R_33, _S7431.p_0[0U]) + t_33; + _S7431 = _S7453; + (&_S7431)->p_0[0U] = _S7455; + SigmaPoints_0 _S7456 = _S7431; + (&_S7431)->p_0[1U] = s_primal_ctx_mul_0(R_33, _S7435) + t_33; + SigmaPoints_0 _S7457 = _S7431; + (&_S7431)->p_0[2U] = s_primal_ctx_mul_0(R_33, _S7438) + t_33; + SigmaPoints_0 _S7458 = _S7431; + (&_S7431)->p_0[3U] = s_primal_ctx_mul_0(R_33, _S7441) + t_33; + SigmaPoints_0 _S7459 = _S7431; + (&_S7431)->p_0[4U] = s_primal_ctx_mul_0(R_33, _S7436) + t_33; + SigmaPoints_0 _S7460 = _S7431; + (&_S7431)->p_0[5U] = s_primal_ctx_mul_0(R_33, _S7439) + t_33; + SigmaPoints_0 _S7461 = _S7431; + (&_S7431)->p_0[6U] = s_primal_ctx_mul_0(R_33, _S7442) + t_33; + float2 uv_40 = float2 {_S7456.p_0[int(0)].x, _S7456.p_0[int(0)].y} / make_float2 (_S7456.p_0[int(0)].z); + FixedArray _S7462 = dist_coeffs_45; + float2 _S7463 = s_primal_ctx_DistNone_distort_0(uv_40, &_S7462); + (&_S7423)->_S7415 = make_float2 (fx_46 * _S7463.x + cx_37, fy_46 * _S7463.y + cy_37); + float2 uv_41 = float2 {_S7457.p_0[int(1)].x, _S7457.p_0[int(1)].y} / make_float2 (_S7457.p_0[int(1)].z); + FixedArray _S7464 = dist_coeffs_45; + float2 _S7465 = s_primal_ctx_DistNone_distort_0(uv_41, &_S7464); + (&_S7423)->_S7416 = make_float2 (fx_46 * _S7465.x + cx_37, fy_46 * _S7465.y + cy_37); + float2 uv_42 = float2 {_S7458.p_0[int(2)].x, _S7458.p_0[int(2)].y} / make_float2 (_S7458.p_0[int(2)].z); + FixedArray _S7466 = dist_coeffs_45; + float2 _S7467 = s_primal_ctx_DistNone_distort_0(uv_42, &_S7466); + (&_S7423)->_S7417 = make_float2 (fx_46 * _S7467.x + cx_37, fy_46 * _S7467.y + cy_37); + float2 uv_43 = float2 {_S7459.p_0[int(3)].x, _S7459.p_0[int(3)].y} / make_float2 (_S7459.p_0[int(3)].z); + FixedArray _S7468 = dist_coeffs_45; + float2 _S7469 = s_primal_ctx_DistNone_distort_0(uv_43, &_S7468); + (&_S7423)->_S7418 = make_float2 (fx_46 * _S7469.x + cx_37, fy_46 * _S7469.y + cy_37); + float2 uv_44 = float2 {_S7460.p_0[int(4)].x, _S7460.p_0[int(4)].y} / make_float2 (_S7460.p_0[int(4)].z); + FixedArray _S7470 = dist_coeffs_45; + float2 _S7471 = s_primal_ctx_DistNone_distort_0(uv_44, &_S7470); + (&_S7423)->_S7419 = make_float2 (fx_46 * _S7471.x + cx_37, fy_46 * _S7471.y + cy_37); + float2 uv_45 = float2 {_S7461.p_0[int(5)].x, _S7461.p_0[int(5)].y} / make_float2 (_S7461.p_0[int(5)].z); + FixedArray _S7472 = dist_coeffs_45; + float2 _S7473 = s_primal_ctx_DistNone_distort_0(uv_45, &_S7472); + (&_S7423)->_S7420 = make_float2 (fx_46 * _S7473.x + cx_37, fy_46 * _S7473.y + cy_37); + float2 uv_46 = float2 {_S7431.p_0[int(6)].x, _S7431.p_0[int(6)].y} / make_float2 (_S7431.p_0[int(6)].z); + FixedArray _S7474 = dist_coeffs_45; + float2 _S7475 = s_primal_ctx_DistNone_distort_0(uv_46, &_S7474); + (&_S7423)->_S7421 = make_float2 (fx_46 * _S7475.x + cx_37, fy_46 * _S7475.y + cy_37); + float3 mean_c_33 = s_primal_ctx_mul_0(R_33, mean_34) + t_33; + float _S7476 = - in_opacity_33; + float _S7477 = 1.0f + s_primal_ctx_exp_0(_S7476); + float _S7478 = 1.0f / _S7477; + float _S7479 = _S7477 * _S7477; + float3 _S7480 = make_float3 (_S7434); + float3 _S7481 = make_float3 (_S7437); + float3 _S7482 = make_float3 (_S7440); + float _S7483 = float(image_width_33); + float _S7484 = float(image_height_33); + float _S7485 = 0.30000001192092896f * (0.5f * _S7483 / fx_46) * fx_46; + float lim_x_pos_16 = _S7483 + _S7485; + float _S7486 = 0.30000001192092896f * (0.5f * _S7484 / fy_46) * fy_46; + float lim_y_pos_4 = _S7484 + _S7486; + float2 _S7487 = make_float2 (_S7432.w_mean_0[int(1)]) * _S7423._S7416 + make_float2 (_S7444.w_mean_0[int(2)]) * _S7423._S7417 + make_float2 (_S7446.w_mean_0[int(3)]) * _S7423._S7418 + make_float2 (_S7448.w_mean_0[int(4)]) * _S7423._S7419 + make_float2 (_S7450.w_mean_0[int(5)]) * _S7423._S7420 + make_float2 (_S7452.w_mean_0[int(6)]) * _S7423._S7421; + float _S7488 = - _S7485; + float _S7489 = - _S7486; + float2 _S7490 = make_float2 (s_primal_ctx_clamp_0(_S7487.x, _S7488, lim_x_pos_16), s_primal_ctx_clamp_0(_S7487.y, _S7489, lim_y_pos_4)); + float2 d_77 = make_float2 (s_primal_ctx_clamp_0(_S7423._S7415.x, _S7488, lim_x_pos_16), s_primal_ctx_clamp_0(_S7423._S7415.y, _S7489, lim_y_pos_4)) - _S7490; + float _S7491 = d_77.x; + float _S7492 = d_77.y; + float _S7493 = _S7491 * _S7492; + float2 d_78 = make_float2 (s_primal_ctx_clamp_0(_S7423._S7416.x, _S7488, lim_x_pos_16), s_primal_ctx_clamp_0(_S7423._S7416.y, _S7489, lim_y_pos_4)) - _S7490; + float _S7494 = d_78.x; + float _S7495 = d_78.y; + float _S7496 = _S7494 * _S7495; + float2 d_79 = make_float2 (s_primal_ctx_clamp_0(_S7423._S7417.x, _S7488, lim_x_pos_16), s_primal_ctx_clamp_0(_S7423._S7417.y, _S7489, lim_y_pos_4)) - _S7490; + float _S7497 = d_79.x; + float _S7498 = d_79.y; + float _S7499 = _S7497 * _S7498; + float2 d_80 = make_float2 (s_primal_ctx_clamp_0(_S7423._S7418.x, _S7488, lim_x_pos_16), s_primal_ctx_clamp_0(_S7423._S7418.y, _S7489, lim_y_pos_4)) - _S7490; + float _S7500 = d_80.x; + float _S7501 = d_80.y; + float _S7502 = _S7500 * _S7501; + float2 d_81 = make_float2 (s_primal_ctx_clamp_0(_S7423._S7419.x, _S7488, lim_x_pos_16), s_primal_ctx_clamp_0(_S7423._S7419.y, _S7489, lim_y_pos_4)) - _S7490; + float _S7503 = d_81.x; + float _S7504 = d_81.y; + float _S7505 = _S7503 * _S7504; + float2 d_82 = make_float2 (s_primal_ctx_clamp_0(_S7423._S7420.x, _S7488, lim_x_pos_16), s_primal_ctx_clamp_0(_S7423._S7420.y, _S7489, lim_y_pos_4)) - _S7490; + float _S7506 = d_82.x; + float _S7507 = d_82.y; + float _S7508 = _S7506 * _S7507; + float2 d_83 = make_float2 (s_primal_ctx_clamp_0(_S7423._S7421.x, _S7488, lim_x_pos_16), s_primal_ctx_clamp_0(_S7423._S7421.y, _S7489, lim_y_pos_4)) - _S7490; + float _S7509 = d_83.x; + float _S7510 = d_83.y; + float _S7511 = _S7509 * _S7510; + Matrix covar2d_22 = makeMatrix (2.0f) * makeMatrix (_S7491 * _S7491, _S7493, _S7493, _S7492 * _S7492) + makeMatrix (_S7443.w_cov_0[int(1)]) * makeMatrix (_S7494 * _S7494, _S7496, _S7496, _S7495 * _S7495) + makeMatrix (_S7445.w_cov_0[int(2)]) * makeMatrix (_S7497 * _S7497, _S7499, _S7499, _S7498 * _S7498) + makeMatrix (_S7447.w_cov_0[int(3)]) * makeMatrix (_S7500 * _S7500, _S7502, _S7502, _S7501 * _S7501) + makeMatrix (_S7449.w_cov_0[int(4)]) * makeMatrix (_S7503 * _S7503, _S7505, _S7505, _S7504 * _S7504) + makeMatrix (_S7451.w_cov_0[int(5)]) * makeMatrix (_S7506 * _S7506, _S7508, _S7508, _S7507 * _S7507) + makeMatrix (_S7453.w_cov_0[int(6)]) * makeMatrix (_S7509 * _S7509, _S7511, _S7511, _S7510 * _S7510); + float eps2d_33; + if(antialiased_33) { - k_9 = (1.0f - _S3702 * _S3702 / 24.0f) / _S3701; + eps2d_33 = 0.10000000149011612f; } else { - k_9 = 2.0f * s_primal_ctx_sin_0(0.5f * _S3702) / _S3700; + eps2d_33 = 0.30000001192092896f; } - float2 _S3703 = _S3699 * make_float2 (k_9); - float u_98 = _S3703.x; - float v_98 = _S3703.y; - float r2_98 = u_98 * u_98 + v_98 * v_98; - float _S3704 = 2.0f * dist_coeffs_18[int(4)]; - float _S3705 = 2.0f * dist_coeffs_18[int(5)]; - float2 _S3706 = _S3703 * make_float2 (1.0f + r2_98 * (dist_coeffs_18[int(0)] + r2_98 * (dist_coeffs_18[int(1)] + r2_98 * (dist_coeffs_18[int(2)] + r2_98 * dist_coeffs_18[int(3)])))) + make_float2 (_S3704 * u_98 * v_98 + dist_coeffs_18[int(5)] * (r2_98 + 2.0f * u_98 * u_98) + dist_coeffs_18[int(6)] * r2_98, _S3705 * u_98 * v_98 + dist_coeffs_18[int(4)] * (r2_98 + 2.0f * v_98 * v_98) + dist_coeffs_18[int(7)] * r2_98); - float2 _S3707 = _S3706 + make_float2 (dist_coeffs_18[int(8)] * _S3706.x + dist_coeffs_18[int(9)] * _S3706.y, 0.0f); - (&_S3659)->_S3651 = make_float2 (fx_18 * _S3707.x + cx_15, fy_18 * _S3707.y + cy_15); - float2 _S3708 = float2 {_S3693.p_0[int(1)].x, _S3693.p_0[int(1)].y}; - float _S3709 = length_0(_S3708); - float _S3710 = _S3693.p_0[int(1)].z; - float _S3711 = s_primal_ctx_atan2_0(_S3709, _S3710); - if(_S3709 < 9.99999997475242708e-07f) + float _S7512 = covar2d_22.rows[int(0)].y * covar2d_22.rows[int(1)].x; + float det_orig_33 = covar2d_22.rows[int(0)].x * covar2d_22.rows[int(1)].y - _S7512; + float _S7513 = covar2d_22.rows[int(0)].x + eps2d_33; + Matrix _S7514 = covar2d_22; + *&(((&_S7514)->rows + (int(0)))->x) = _S7513; + float _S7515 = covar2d_22.rows[int(1)].y + eps2d_33; + *&(((&_S7514)->rows + (int(1)))->y) = _S7515; + Matrix _S7516 = _S7514; + Matrix _S7517 = _S7514; + float det_blur_33 = _S7513 * _S7515 - _S7512; + float _S7518 = det_orig_33 / det_blur_33; + float _S7519 = det_blur_33 * det_blur_33; + float _S7520 = (F32_max((0.0f), (_S7518))); + float _S7521 = s_primal_ctx_sqrt_0(_S7520); + float invdet_39 = 1.0f / det_blur_33; + float _S7522 = - covar2d_22.rows[int(0)].y; + float _S7523 = - covar2d_22.rows[int(1)].x; + if(antialiased_33) { - k_9 = (1.0f - _S3711 * _S3711 / 24.0f) / _S3710; + eps2d_33 = _S7478 * _S7521; } else { - k_9 = 2.0f * s_primal_ctx_sin_0(0.5f * _S3711) / _S3709; + eps2d_33 = _S7478; } - float2 _S3712 = _S3708 * make_float2 (k_9); - float u_99 = _S3712.x; - float v_99 = _S3712.y; - float r2_99 = u_99 * u_99 + v_99 * v_99; - float2 _S3713 = _S3712 * make_float2 (1.0f + r2_99 * (dist_coeffs_18[int(0)] + r2_99 * (dist_coeffs_18[int(1)] + r2_99 * (dist_coeffs_18[int(2)] + r2_99 * dist_coeffs_18[int(3)])))) + make_float2 (_S3704 * u_99 * v_99 + dist_coeffs_18[int(5)] * (r2_99 + 2.0f * u_99 * u_99) + dist_coeffs_18[int(6)] * r2_99, _S3705 * u_99 * v_99 + dist_coeffs_18[int(4)] * (r2_99 + 2.0f * v_99 * v_99) + dist_coeffs_18[int(7)] * r2_99); - float2 _S3714 = _S3713 + make_float2 (dist_coeffs_18[int(8)] * _S3713.x + dist_coeffs_18[int(9)] * _S3713.y, 0.0f); - (&_S3659)->_S3652 = make_float2 (fx_18 * _S3714.x + cx_15, fy_18 * _S3714.y + cy_15); - float2 _S3715 = float2 {_S3694.p_0[int(2)].x, _S3694.p_0[int(2)].y}; - float _S3716 = length_0(_S3715); - float _S3717 = _S3694.p_0[int(2)].z; - float _S3718 = s_primal_ctx_atan2_0(_S3716, _S3717); - if(_S3716 < 9.99999997475242708e-07f) + float _S7524 = eps2d_33 / 0.00392156885936856f; + float _S7525 = 2.0f * s_primal_ctx_log_0(_S7524); + float _S7526 = s_primal_ctx_sqrt_0(_S7525); + float _S7527 = _S7516.rows[int(0)].x; + float _S7528 = _S7517.rows[int(1)].y; + float3 campos_12 = - s_primal_ctx_mul_0(transpose_3(R_33), t_33); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7529; + (&_S7529)->primal_0 = mean_34; + (&_S7529)->differential_0 = _S7424; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7530; + (&_S7530)->primal_0 = scale_33; + (&_S7530)->differential_0 = _S7424; + DiffPair_float_0 _S7531; + (&_S7531)->primal_0 = in_opacity_33; + (&_S7531)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7532; + (&_S7532)->primal_0 = campos_12; + (&_S7532)->differential_0 = _S7424; + s_bwd_prop_view_radius_3dgs_0(&_S7529, &_S7530, &_S7531, &_S7532, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7533 = _S7529; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7534 = _S7530; + DiffPair_float_0 _S7535 = _S7531; + float2 _S7536 = _S7422; + *&((&_S7536)->y) = v_conic_11.z; + float2 _S7537 = _S7422; + *&((&_S7537)->y) = v_conic_11.y; + *&((&_S7537)->x) = v_conic_11.x; + DiffPair_float_0 _S7538; + (&_S7538)->primal_0 = _S7528; + (&_S7538)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7538, 0.0f); + DiffPair_float_0 _S7539; + (&_S7539)->primal_0 = _S7527; + (&_S7539)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7539, 0.0f); + DiffPair_float_0 _S7540; + (&_S7540)->primal_0 = 3.32999992370605469f; + (&_S7540)->differential_0 = 0.0f; + DiffPair_float_0 _S7541; + (&_S7541)->primal_0 = _S7526; + (&_S7541)->differential_0 = 0.0f; + _d_min_0(&_S7540, &_S7541, 0.0f); + DiffPair_float_0 _S7542; + (&_S7542)->primal_0 = _S7525; + (&_S7542)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7542, _S7541.differential_0); + float _S7543 = 2.0f * _S7542.differential_0; + DiffPair_float_0 _S7544; + (&_S7544)->primal_0 = _S7524; + (&_S7544)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S7544, _S7543); + float _S7545 = v_opacity_11 + 254.9999847412109375f * _S7544.differential_0; + Matrix _S7546 = makeMatrix (0.0f); + Matrix _S7547 = _S7546; + _S7547[int(1)] = _S7536; + _S7547[int(0)] = _S7537; + Matrix _S7548 = _S7547; + float2 _S7549 = make_float2 (0.0f, _S7538.differential_0); + float2 _S7550 = make_float2 (_S7539.differential_0, 0.0f); + float _S7551; + if(antialiased_33) { - k_9 = (1.0f - _S3718 * _S3718 / 24.0f) / _S3717; + float _S7552 = _S7521 * _S7545; + eps2d_33 = _S7478 * _S7545; + _S7551 = _S7552; } else { - k_9 = 2.0f * s_primal_ctx_sin_0(0.5f * _S3718) / _S3716; + eps2d_33 = 0.0f; + _S7551 = _S7545; } - float2 _S3719 = _S3715 * make_float2 (k_9); - float u_100 = _S3719.x; - float v_100 = _S3719.y; - float r2_100 = u_100 * u_100 + v_100 * v_100; - float2 _S3720 = _S3719 * make_float2 (1.0f + r2_100 * (dist_coeffs_18[int(0)] + r2_100 * (dist_coeffs_18[int(1)] + r2_100 * (dist_coeffs_18[int(2)] + r2_100 * dist_coeffs_18[int(3)])))) + make_float2 (_S3704 * u_100 * v_100 + dist_coeffs_18[int(5)] * (r2_100 + 2.0f * u_100 * u_100) + dist_coeffs_18[int(6)] * r2_100, _S3705 * u_100 * v_100 + dist_coeffs_18[int(4)] * (r2_100 + 2.0f * v_100 * v_100) + dist_coeffs_18[int(7)] * r2_100); - float2 _S3721 = _S3720 + make_float2 (dist_coeffs_18[int(8)] * _S3720.x + dist_coeffs_18[int(9)] * _S3720.y, 0.0f); - (&_S3659)->_S3653 = make_float2 (fx_18 * _S3721.x + cx_15, fy_18 * _S3721.y + cy_15); - float2 _S3722 = float2 {_S3695.p_0[int(3)].x, _S3695.p_0[int(3)].y}; - float _S3723 = length_0(_S3722); - float _S3724 = _S3695.p_0[int(3)].z; - float _S3725 = s_primal_ctx_atan2_0(_S3723, _S3724); - if(_S3723 < 9.99999997475242708e-07f) - { - k_9 = (1.0f - _S3725 * _S3725 / 24.0f) / _S3724; - } - else - { - k_9 = 2.0f * s_primal_ctx_sin_0(0.5f * _S3725) / _S3723; - } - float2 _S3726 = _S3722 * make_float2 (k_9); - float u_101 = _S3726.x; - float v_101 = _S3726.y; - float r2_101 = u_101 * u_101 + v_101 * v_101; - float2 _S3727 = _S3726 * make_float2 (1.0f + r2_101 * (dist_coeffs_18[int(0)] + r2_101 * (dist_coeffs_18[int(1)] + r2_101 * (dist_coeffs_18[int(2)] + r2_101 * dist_coeffs_18[int(3)])))) + make_float2 (_S3704 * u_101 * v_101 + dist_coeffs_18[int(5)] * (r2_101 + 2.0f * u_101 * u_101) + dist_coeffs_18[int(6)] * r2_101, _S3705 * u_101 * v_101 + dist_coeffs_18[int(4)] * (r2_101 + 2.0f * v_101 * v_101) + dist_coeffs_18[int(7)] * r2_101); - float2 _S3728 = _S3727 + make_float2 (dist_coeffs_18[int(8)] * _S3727.x + dist_coeffs_18[int(9)] * _S3727.y, 0.0f); - (&_S3659)->_S3654 = make_float2 (fx_18 * _S3728.x + cx_15, fy_18 * _S3728.y + cy_15); - float2 _S3729 = float2 {_S3696.p_0[int(4)].x, _S3696.p_0[int(4)].y}; - float _S3730 = length_0(_S3729); - float _S3731 = _S3696.p_0[int(4)].z; - float _S3732 = s_primal_ctx_atan2_0(_S3730, _S3731); - if(_S3730 < 9.99999997475242708e-07f) - { - k_9 = (1.0f - _S3732 * _S3732 / 24.0f) / _S3731; - } - else - { - k_9 = 2.0f * s_primal_ctx_sin_0(0.5f * _S3732) / _S3730; - } - float2 _S3733 = _S3729 * make_float2 (k_9); - float u_102 = _S3733.x; - float v_102 = _S3733.y; - float r2_102 = u_102 * u_102 + v_102 * v_102; - float2 _S3734 = _S3733 * make_float2 (1.0f + r2_102 * (dist_coeffs_18[int(0)] + r2_102 * (dist_coeffs_18[int(1)] + r2_102 * (dist_coeffs_18[int(2)] + r2_102 * dist_coeffs_18[int(3)])))) + make_float2 (_S3704 * u_102 * v_102 + dist_coeffs_18[int(5)] * (r2_102 + 2.0f * u_102 * u_102) + dist_coeffs_18[int(6)] * r2_102, _S3705 * u_102 * v_102 + dist_coeffs_18[int(4)] * (r2_102 + 2.0f * v_102 * v_102) + dist_coeffs_18[int(7)] * r2_102); - float2 _S3735 = _S3734 + make_float2 (dist_coeffs_18[int(8)] * _S3734.x + dist_coeffs_18[int(9)] * _S3734.y, 0.0f); - (&_S3659)->_S3655 = make_float2 (fx_18 * _S3735.x + cx_15, fy_18 * _S3735.y + cy_15); - float2 _S3736 = float2 {_S3697.p_0[int(5)].x, _S3697.p_0[int(5)].y}; - float _S3737 = length_0(_S3736); - float _S3738 = _S3697.p_0[int(5)].z; - float _S3739 = s_primal_ctx_atan2_0(_S3737, _S3738); - if(_S3737 < 9.99999997475242708e-07f) - { - k_9 = (1.0f - _S3739 * _S3739 / 24.0f) / _S3738; - } - else - { - k_9 = 2.0f * s_primal_ctx_sin_0(0.5f * _S3739) / _S3737; - } - float2 _S3740 = _S3736 * make_float2 (k_9); - float u_103 = _S3740.x; - float v_103 = _S3740.y; - float r2_103 = u_103 * u_103 + v_103 * v_103; - float2 _S3741 = _S3740 * make_float2 (1.0f + r2_103 * (dist_coeffs_18[int(0)] + r2_103 * (dist_coeffs_18[int(1)] + r2_103 * (dist_coeffs_18[int(2)] + r2_103 * dist_coeffs_18[int(3)])))) + make_float2 (_S3704 * u_103 * v_103 + dist_coeffs_18[int(5)] * (r2_103 + 2.0f * u_103 * u_103) + dist_coeffs_18[int(6)] * r2_103, _S3705 * u_103 * v_103 + dist_coeffs_18[int(4)] * (r2_103 + 2.0f * v_103 * v_103) + dist_coeffs_18[int(7)] * r2_103); - float2 _S3742 = _S3741 + make_float2 (dist_coeffs_18[int(8)] * _S3741.x + dist_coeffs_18[int(9)] * _S3741.y, 0.0f); - (&_S3659)->_S3656 = make_float2 (fx_18 * _S3742.x + cx_15, fy_18 * _S3742.y + cy_15); - float2 _S3743 = float2 {_S3698.p_0[int(6)].x, _S3698.p_0[int(6)].y}; - float _S3744 = length_0(_S3743); - float _S3745 = _S3698.p_0[int(6)].z; - float _S3746 = s_primal_ctx_atan2_0(_S3744, _S3745); - if(_S3744 < 9.99999997475242708e-07f) - { - k_9 = (1.0f - _S3746 * _S3746 / 24.0f) / _S3745; - } - else - { - k_9 = 2.0f * s_primal_ctx_sin_0(0.5f * _S3746) / _S3744; - } - float2 _S3747 = _S3743 * make_float2 (k_9); - float u_104 = _S3747.x; - float v_104 = _S3747.y; - float r2_104 = u_104 * u_104 + v_104 * v_104; - float2 _S3748 = _S3747 * make_float2 (1.0f + r2_104 * (dist_coeffs_18[int(0)] + r2_104 * (dist_coeffs_18[int(1)] + r2_104 * (dist_coeffs_18[int(2)] + r2_104 * dist_coeffs_18[int(3)])))) + make_float2 (_S3704 * u_104 * v_104 + dist_coeffs_18[int(5)] * (r2_104 + 2.0f * u_104 * u_104) + dist_coeffs_18[int(6)] * r2_104, _S3705 * u_104 * v_104 + dist_coeffs_18[int(4)] * (r2_104 + 2.0f * v_104 * v_104) + dist_coeffs_18[int(7)] * r2_104); - float2 _S3749 = _S3748 + make_float2 (dist_coeffs_18[int(8)] * _S3748.x + dist_coeffs_18[int(9)] * _S3748.y, 0.0f); - (&_S3659)->_S3657 = make_float2 (fx_18 * _S3749.x + cx_15, fy_18 * _S3749.y + cy_15); - float3 mean_c_14 = s_primal_ctx_mul_0(R_14, mean_15) + t_14; - float _S3750 = - in_opacity_14; - float _S3751 = 1.0f + s_primal_ctx_exp_0(_S3750); - float _S3752 = 1.0f / _S3751; - float _S3753 = _S3751 * _S3751; - float3 _S3754 = make_float3 (_S3670); - float3 _S3755 = make_float3 (_S3673); - float3 _S3756 = make_float3 (_S3676); - float2 _S3757 = make_float2 (_S3668.w_mean_0[int(1)]) * _S3659._S3652 + make_float2 (_S3680.w_mean_0[int(2)]) * _S3659._S3653 + make_float2 (_S3682.w_mean_0[int(3)]) * _S3659._S3654 + make_float2 (_S3684.w_mean_0[int(4)]) * _S3659._S3655 + make_float2 (_S3686.w_mean_0[int(5)]) * _S3659._S3656 + make_float2 (_S3688.w_mean_0[int(6)]) * _S3659._S3657; - float2 d_42 = _S3659._S3651 - _S3757; - float _S3758 = d_42.x; - float _S3759 = d_42.y; - float _S3760 = _S3758 * _S3759; - float2 d_43 = _S3659._S3652 - _S3757; - float _S3761 = d_43.x; - float _S3762 = d_43.y; - float _S3763 = _S3761 * _S3762; - float2 d_44 = _S3659._S3653 - _S3757; - float _S3764 = d_44.x; - float _S3765 = d_44.y; - float _S3766 = _S3764 * _S3765; - float2 d_45 = _S3659._S3654 - _S3757; - float _S3767 = d_45.x; - float _S3768 = d_45.y; - float _S3769 = _S3767 * _S3768; - float2 d_46 = _S3659._S3655 - _S3757; - float _S3770 = d_46.x; - float _S3771 = d_46.y; - float _S3772 = _S3770 * _S3771; - float2 d_47 = _S3659._S3656 - _S3757; - float _S3773 = d_47.x; - float _S3774 = d_47.y; - float _S3775 = _S3773 * _S3774; - float2 d_48 = _S3659._S3657 - _S3757; - float _S3776 = d_48.x; - float _S3777 = d_48.y; - float _S3778 = _S3776 * _S3777; - Matrix covar2d_10 = makeMatrix (2.0f) * makeMatrix (_S3758 * _S3758, _S3760, _S3760, _S3759 * _S3759) + makeMatrix (_S3679.w_cov_0[int(1)]) * makeMatrix (_S3761 * _S3761, _S3763, _S3763, _S3762 * _S3762) + makeMatrix (_S3681.w_cov_0[int(2)]) * makeMatrix (_S3764 * _S3764, _S3766, _S3766, _S3765 * _S3765) + makeMatrix (_S3683.w_cov_0[int(3)]) * makeMatrix (_S3767 * _S3767, _S3769, _S3769, _S3768 * _S3768) + makeMatrix (_S3685.w_cov_0[int(4)]) * makeMatrix (_S3770 * _S3770, _S3772, _S3772, _S3771 * _S3771) + makeMatrix (_S3687.w_cov_0[int(5)]) * makeMatrix (_S3773 * _S3773, _S3775, _S3775, _S3774 * _S3774) + makeMatrix (_S3689.w_cov_0[int(6)]) * makeMatrix (_S3776 * _S3776, _S3778, _S3778, _S3777 * _S3777); - float eps2d_14; - if(antialiased_14) - { - eps2d_14 = 0.10000000149011612f; - } - else - { - eps2d_14 = 0.30000001192092896f; - } - float _S3779 = covar2d_10.rows[int(0)].y * covar2d_10.rows[int(1)].x; - float det_orig_14 = covar2d_10.rows[int(0)].x * covar2d_10.rows[int(1)].y - _S3779; - float _S3780 = covar2d_10.rows[int(0)].x + eps2d_14; - Matrix _S3781 = covar2d_10; - *&(((&_S3781)->rows + (int(0)))->x) = _S3780; - float _S3782 = covar2d_10.rows[int(1)].y + eps2d_14; - *&(((&_S3781)->rows + (int(1)))->y) = _S3782; - Matrix _S3783 = _S3781; - Matrix _S3784 = _S3781; - float det_blur_14 = _S3780 * _S3782 - _S3779; - float _S3785 = det_orig_14 / det_blur_14; - float _S3786 = det_blur_14 * det_blur_14; - float _S3787 = (F32_max((0.0f), (_S3785))); - float _S3788 = s_primal_ctx_sqrt_0(_S3787); - float invdet_16 = 1.0f / det_blur_14; - float _S3789 = - covar2d_10.rows[int(0)].y; - float _S3790 = - covar2d_10.rows[int(1)].x; - if(antialiased_14) - { - k_9 = _S3752 * _S3788; - } - else - { - k_9 = _S3752; - } - float _S3791 = k_9 / 0.00392156885936856f; - float _S3792 = 2.0f * s_primal_ctx_log_0(_S3791); - float _S3793 = s_primal_ctx_sqrt_0(_S3792); - float _S3794 = _S3783.rows[int(0)].x; - float _S3795 = _S3784.rows[int(1)].y; - float3 campos_7 = - s_primal_ctx_mul_0(transpose_3(R_14), t_14); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3796; - (&_S3796)->primal_0 = mean_15; - (&_S3796)->differential_0 = _S3660; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3797; - (&_S3797)->primal_0 = scale_14; - (&_S3797)->differential_0 = _S3660; - DiffPair_float_0 _S3798; - (&_S3798)->primal_0 = in_opacity_14; - (&_S3798)->differential_0 = 0.0f; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3799; - (&_S3799)->primal_0 = campos_7; - (&_S3799)->differential_0 = _S3660; - s_bwd_prop_view_radius_3dgs_0(&_S3796, &_S3797, &_S3798, &_S3799, 0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3800 = _S3796; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3801 = _S3797; - DiffPair_float_0 _S3802 = _S3798; - float2 _S3803 = _S3658; - *&((&_S3803)->y) = v_conic_6.z; - float2 _S3804 = _S3658; - *&((&_S3804)->y) = v_conic_6.y; - *&((&_S3804)->x) = v_conic_6.x; - DiffPair_float_0 _S3805; - (&_S3805)->primal_0 = _S3795; - (&_S3805)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3805, 0.0f); - DiffPair_float_0 _S3806; - (&_S3806)->primal_0 = _S3794; - (&_S3806)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3806, 0.0f); - DiffPair_float_0 _S3807; - (&_S3807)->primal_0 = 3.32999992370605469f; - (&_S3807)->differential_0 = 0.0f; - DiffPair_float_0 _S3808; - (&_S3808)->primal_0 = _S3793; - (&_S3808)->differential_0 = 0.0f; - _d_min_0(&_S3807, &_S3808, 0.0f); - DiffPair_float_0 _S3809; - (&_S3809)->primal_0 = _S3792; - (&_S3809)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3809, _S3808.differential_0); - float _S3810 = 2.0f * _S3809.differential_0; - DiffPair_float_0 _S3811; - (&_S3811)->primal_0 = _S3791; - (&_S3811)->differential_0 = 0.0f; - s_bwd_prop_log_0(&_S3811, _S3810); - float _S3812 = v_opacity_6 + 254.9999847412109375f * _S3811.differential_0; - Matrix _S3813 = makeMatrix (0.0f); - Matrix _S3814 = _S3813; - _S3814[int(1)] = _S3803; - _S3814[int(0)] = _S3804; - Matrix _S3815 = _S3814; - float2 _S3816 = make_float2 (0.0f, _S3805.differential_0); - float2 _S3817 = make_float2 (_S3806.differential_0, 0.0f); - if(antialiased_14) - { - float _S3818 = _S3788 * _S3812; - k_9 = _S3752 * _S3812; - eps2d_14 = _S3818; - } - else - { - k_9 = 0.0f; - eps2d_14 = _S3812; - } - float _S3819 = invdet_16 * _S3815.rows[int(1)].y; - float _S3820 = - (invdet_16 * _S3815.rows[int(1)].x); - float _S3821 = - (invdet_16 * _S3815.rows[int(0)].y); - float _S3822 = invdet_16 * _S3815.rows[int(0)].x; - float _S3823 = - ((_S3780 * _S3815.rows[int(1)].y + _S3790 * _S3815.rows[int(1)].x + _S3789 * _S3815.rows[int(0)].y + _S3782 * _S3815.rows[int(0)].x) / _S3786); - DiffPair_float_0 _S3824; - (&_S3824)->primal_0 = _S3787; - (&_S3824)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S3824, k_9); - DiffPair_float_0 _S3825; - (&_S3825)->primal_0 = 0.0f; - (&_S3825)->differential_0 = 0.0f; - DiffPair_float_0 _S3826; - (&_S3826)->primal_0 = _S3785; - (&_S3826)->differential_0 = 0.0f; - _d_max_0(&_S3825, &_S3826, _S3824.differential_0); - float _S3827 = _S3826.differential_0 / _S3786; - float s_diff_det_orig_T_6 = det_blur_14 * _S3827; - float _S3828 = det_orig_14 * - _S3827 + _S3823; - float _S3829 = - _S3828; - float _S3830 = _S3780 * _S3828; - float _S3831 = _S3782 * _S3828; - Matrix _S3832 = _S3813; - _S3832[int(1)] = _S3816; - _S3832[int(0)] = _S3817; - float _S3833 = _S3831 + _S3832.rows[int(0)].x + _S3819; - float _S3834 = _S3829 + - s_diff_det_orig_T_6; - float _S3835 = covar2d_10.rows[int(0)].y * _S3834 + _S3820; - float _S3836 = covar2d_10.rows[int(1)].x * _S3834 + _S3821; - float _S3837 = covar2d_10.rows[int(1)].y * s_diff_det_orig_T_6; - float _S3838 = _S3830 + _S3832.rows[int(1)].y + _S3822 + covar2d_10.rows[int(0)].x * s_diff_det_orig_T_6; - float2 _S3839 = _S3658; - *&((&_S3839)->x) = _S3835; - *&((&_S3839)->y) = _S3838; - float _S3840 = _S3833 + _S3837; - float2 _S3841 = _S3658; - *&((&_S3841)->y) = _S3836; - *&((&_S3841)->x) = _S3840; - Matrix _S3842 = _S3813; - _S3842[int(1)] = _S3839; - _S3842[int(0)] = _S3841; - Matrix _S3843 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3844; - (&_S3844)->primal_0 = R_14; - (&_S3844)->differential_0 = _S3843; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3845; - (&_S3845)->primal_0 = _S3678; - (&_S3845)->differential_0 = _S3660; - s_bwd_prop_mul_3(&_S3844, &_S3845, _S3660); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3846; - (&_S3846)->primal_0 = R_14; - (&_S3846)->differential_0 = _S3843; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3847; - (&_S3847)->primal_0 = _S3675; - (&_S3847)->differential_0 = _S3660; - s_bwd_prop_mul_3(&_S3846, &_S3847, _S3660); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3848; - (&_S3848)->primal_0 = R_14; - (&_S3848)->differential_0 = _S3843; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3849; - (&_S3849)->primal_0 = _S3672; - (&_S3849)->differential_0 = _S3660; - s_bwd_prop_mul_3(&_S3848, &_S3849, _S3660); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3850; - (&_S3850)->primal_0 = R_14; - (&_S3850)->differential_0 = _S3843; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3851; - (&_S3851)->primal_0 = _S3677; - (&_S3851)->differential_0 = _S3660; - s_bwd_prop_mul_3(&_S3850, &_S3851, _S3660); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3852; - (&_S3852)->primal_0 = R_14; - (&_S3852)->differential_0 = _S3843; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3853; - (&_S3853)->primal_0 = _S3674; - (&_S3853)->differential_0 = _S3660; - s_bwd_prop_mul_3(&_S3852, &_S3853, _S3660); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3854; - (&_S3854)->primal_0 = R_14; - (&_S3854)->differential_0 = _S3843; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3855; - (&_S3855)->primal_0 = _S3671; - (&_S3855)->differential_0 = _S3660; - s_bwd_prop_mul_3(&_S3854, &_S3855, _S3660); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3856; - (&_S3856)->primal_0 = R_14; - (&_S3856)->differential_0 = _S3843; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3857; - (&_S3857)->primal_0 = _S3690.p_0[0U]; - (&_S3857)->differential_0 = _S3660; - s_bwd_prop_mul_3(&_S3856, &_S3857, _S3660); - float3 _S3858 = - _S3845.differential_0 + _S3851.differential_0; - float3 _S3859 = _S3756 * _S3858; - float3 _S3860 = _S3664.rows[2U] * _S3858; - float _S3861 = _S3669 * (_S3860.x + _S3860.y + _S3860.z); - float3 _S3862 = - _S3847.differential_0 + _S3853.differential_0; - float3 _S3863 = _S3755 * _S3862; - float3 _S3864 = _S3664.rows[1U] * _S3862; - float _S3865 = _S3669 * (_S3864.x + _S3864.y + _S3864.z); - float3 _S3866 = - _S3849.differential_0 + _S3855.differential_0; - float3 _S3867 = _S3754 * _S3866; - float3 _S3868 = _S3664.rows[0U] * _S3866; - float _S3869 = _S3669 * (_S3868.x + _S3868.y + _S3868.z); - Matrix _S3870 = _S3843; - _S3870[2U] = _S3859; - _S3870[1U] = _S3863; - _S3870[0U] = _S3867; - Matrix _S3871 = transpose_3(transpose_3(_S3870)); - float _S3872 = 2.0f * - _S3871.rows[int(2)].z; - float _S3873 = 2.0f * _S3871.rows[int(2)].y; - float _S3874 = 2.0f * _S3871.rows[int(2)].x; - float _S3875 = 2.0f * _S3871.rows[int(1)].z; - float _S3876 = 2.0f * - _S3871.rows[int(1)].y; - float _S3877 = 2.0f * _S3871.rows[int(1)].x; - float _S3878 = 2.0f * _S3871.rows[int(0)].z; - float _S3879 = 2.0f * _S3871.rows[int(0)].y; - float _S3880 = 2.0f * - _S3871.rows[int(0)].x; - float _S3881 = - _S3877 + _S3879; - float _S3882 = _S3874 + - _S3878; - float _S3883 = - _S3873 + _S3875; - float _S3884 = _S3873 + _S3875; - float _S3885 = _S3874 + _S3878; - float _S3886 = _S3877 + _S3879; - float _S3887 = _S3662.w * (_S3876 + _S3880); - float _S3888 = _S3662.z * (_S3872 + _S3880); - float _S3889 = _S3662.y * (_S3872 + _S3876); - float _S3890 = _S3662.x * _S3881 + _S3662.z * _S3884 + _S3662.y * _S3885 + _S3887 + _S3887; - float _S3891 = _S3662.x * _S3882 + _S3662.w * _S3884 + _S3662.y * _S3886 + _S3888 + _S3888; - float _S3892 = _S3662.x * _S3883 + _S3662.w * _S3885 + _S3662.z * _S3886 + _S3889 + _S3889; - float _S3893 = _S3662.w * _S3881 + _S3662.z * _S3882 + _S3662.y * _S3883; - float4 _S3894 = make_float4 (0.0f); - float4 _S3895 = _S3894; - *&((&_S3895)->w) = _S3890; - *&((&_S3895)->z) = _S3891; - *&((&_S3895)->y) = _S3892; - *&((&_S3895)->x) = _S3893; - DiffPair_vectorx3Cfloatx2C4x3E_0 _S3896; - (&_S3896)->primal_0 = quat_14; - (&_S3896)->differential_0 = _S3894; - s_bwd_normalize_impl_0(&_S3896, _S3895); - float3 _S3897 = _S3660; - *&((&_S3897)->z) = _S3861; - *&((&_S3897)->y) = _S3865; - *&((&_S3897)->x) = _S3869; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3898; - (&_S3898)->primal_0 = scale_14; - (&_S3898)->differential_0 = _S3660; - s_bwd_prop_exp_1(&_S3898, _S3897); - float _S3899 = - (eps2d_14 / _S3753); - DiffPair_float_0 _S3900; - (&_S3900)->primal_0 = _S3750; - (&_S3900)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S3900, _S3899); - float _S3901 = - _S3900.differential_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3902; - (&_S3902)->primal_0 = mean_c_14; - (&_S3902)->differential_0 = _S3660; - s_bwd_length_impl_0(&_S3902, v_depth_6); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S3903; - (&_S3903)->primal_0 = R_14; - (&_S3903)->differential_0 = _S3843; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S3904; - (&_S3904)->primal_0 = mean_15; - (&_S3904)->differential_0 = _S3660; - s_bwd_prop_mul_3(&_S3903, &_S3904, _S3902.differential_0); - Matrix _S3905 = _S3844.differential_0 + _S3846.differential_0 + _S3848.differential_0 + _S3850.differential_0 + _S3852.differential_0 + _S3854.differential_0 + _S3856.differential_0 + _S3903.differential_0; - float _S3906 = _S3901 + _S3802.differential_0; - float3 _S3907 = _S3898.differential_0 + _S3801.differential_0; - *v_mean_6 = *v_mean_6 + (_S3845.differential_0 + _S3851.differential_0 + _S3847.differential_0 + _S3853.differential_0 + _S3849.differential_0 + _S3855.differential_0 + _S3904.differential_0 + _S3800.differential_0); - *v_quat_6 = *v_quat_6 + _S3896.differential_0; - *v_scale_6 = *v_scale_6 + _S3907; - *v_in_opacity_6 = *v_in_opacity_6 + _S3906; - *v_R_6 = *v_R_6 + _S3905; - *v_t_6 = *v_t_6 + _S3902.differential_0; + float _S7553 = invdet_39 * _S7548.rows[int(1)].y; + float _S7554 = - (invdet_39 * _S7548.rows[int(1)].x); + float _S7555 = - (invdet_39 * _S7548.rows[int(0)].y); + float _S7556 = invdet_39 * _S7548.rows[int(0)].x; + float _S7557 = - ((_S7513 * _S7548.rows[int(1)].y + _S7523 * _S7548.rows[int(1)].x + _S7522 * _S7548.rows[int(0)].y + _S7515 * _S7548.rows[int(0)].x) / _S7519); + DiffPair_float_0 _S7558; + (&_S7558)->primal_0 = _S7520; + (&_S7558)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7558, eps2d_33); + DiffPair_float_0 _S7559; + (&_S7559)->primal_0 = 0.0f; + (&_S7559)->differential_0 = 0.0f; + DiffPair_float_0 _S7560; + (&_S7560)->primal_0 = _S7518; + (&_S7560)->differential_0 = 0.0f; + _d_max_0(&_S7559, &_S7560, _S7558.differential_0); + float _S7561 = _S7560.differential_0 / _S7519; + float s_diff_det_orig_T_11 = det_blur_33 * _S7561; + float _S7562 = det_orig_33 * - _S7561 + _S7557; + float _S7563 = - _S7562; + float _S7564 = _S7513 * _S7562; + float _S7565 = _S7515 * _S7562; + Matrix _S7566 = _S7546; + _S7566[int(1)] = _S7549; + _S7566[int(0)] = _S7550; + float _S7567 = _S7565 + _S7566.rows[int(0)].x + _S7553; + float _S7568 = _S7563 + - s_diff_det_orig_T_11; + float _S7569 = covar2d_22.rows[int(0)].y * _S7568 + _S7554; + float _S7570 = covar2d_22.rows[int(1)].x * _S7568 + _S7555; + float _S7571 = covar2d_22.rows[int(1)].y * s_diff_det_orig_T_11; + float _S7572 = _S7564 + _S7566.rows[int(1)].y + _S7556 + covar2d_22.rows[int(0)].x * s_diff_det_orig_T_11; + float2 _S7573 = _S7422; + *&((&_S7573)->x) = _S7569; + *&((&_S7573)->y) = _S7572; + float _S7574 = _S7567 + _S7571; + float2 _S7575 = _S7422; + *&((&_S7575)->y) = _S7570; + *&((&_S7575)->x) = _S7574; + Matrix _S7576 = _S7546; + _S7576[int(1)] = _S7573; + _S7576[int(0)] = _S7575; + Matrix _S7577 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7578; + (&_S7578)->primal_0 = R_33; + (&_S7578)->differential_0 = _S7577; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7579; + (&_S7579)->primal_0 = _S7442; + (&_S7579)->differential_0 = _S7424; + s_bwd_prop_mul_3(&_S7578, &_S7579, _S7424); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7580; + (&_S7580)->primal_0 = R_33; + (&_S7580)->differential_0 = _S7577; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7581; + (&_S7581)->primal_0 = _S7439; + (&_S7581)->differential_0 = _S7424; + s_bwd_prop_mul_3(&_S7580, &_S7581, _S7424); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7582; + (&_S7582)->primal_0 = R_33; + (&_S7582)->differential_0 = _S7577; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7583; + (&_S7583)->primal_0 = _S7436; + (&_S7583)->differential_0 = _S7424; + s_bwd_prop_mul_3(&_S7582, &_S7583, _S7424); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7584; + (&_S7584)->primal_0 = R_33; + (&_S7584)->differential_0 = _S7577; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7585; + (&_S7585)->primal_0 = _S7441; + (&_S7585)->differential_0 = _S7424; + s_bwd_prop_mul_3(&_S7584, &_S7585, _S7424); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7586; + (&_S7586)->primal_0 = R_33; + (&_S7586)->differential_0 = _S7577; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7587; + (&_S7587)->primal_0 = _S7438; + (&_S7587)->differential_0 = _S7424; + s_bwd_prop_mul_3(&_S7586, &_S7587, _S7424); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7588; + (&_S7588)->primal_0 = R_33; + (&_S7588)->differential_0 = _S7577; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7589; + (&_S7589)->primal_0 = _S7435; + (&_S7589)->differential_0 = _S7424; + s_bwd_prop_mul_3(&_S7588, &_S7589, _S7424); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7590; + (&_S7590)->primal_0 = R_33; + (&_S7590)->differential_0 = _S7577; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7591; + (&_S7591)->primal_0 = _S7454.p_0[0U]; + (&_S7591)->differential_0 = _S7424; + s_bwd_prop_mul_3(&_S7590, &_S7591, _S7424); + float3 _S7592 = - _S7579.differential_0 + _S7585.differential_0; + float3 _S7593 = _S7482 * _S7592; + float3 _S7594 = _S7428.rows[2U] * _S7592; + float _S7595 = _S7433 * (_S7594.x + _S7594.y + _S7594.z); + float3 _S7596 = - _S7581.differential_0 + _S7587.differential_0; + float3 _S7597 = _S7481 * _S7596; + float3 _S7598 = _S7428.rows[1U] * _S7596; + float _S7599 = _S7433 * (_S7598.x + _S7598.y + _S7598.z); + float3 _S7600 = - _S7583.differential_0 + _S7589.differential_0; + float3 _S7601 = _S7480 * _S7600; + float3 _S7602 = _S7428.rows[0U] * _S7600; + float _S7603 = _S7433 * (_S7602.x + _S7602.y + _S7602.z); + Matrix _S7604 = _S7577; + _S7604[2U] = _S7593; + _S7604[1U] = _S7597; + _S7604[0U] = _S7601; + Matrix _S7605 = transpose_3(transpose_3(_S7604)); + float _S7606 = 2.0f * - _S7605.rows[int(2)].z; + float _S7607 = 2.0f * _S7605.rows[int(2)].y; + float _S7608 = 2.0f * _S7605.rows[int(2)].x; + float _S7609 = 2.0f * _S7605.rows[int(1)].z; + float _S7610 = 2.0f * - _S7605.rows[int(1)].y; + float _S7611 = 2.0f * _S7605.rows[int(1)].x; + float _S7612 = 2.0f * _S7605.rows[int(0)].z; + float _S7613 = 2.0f * _S7605.rows[int(0)].y; + float _S7614 = 2.0f * - _S7605.rows[int(0)].x; + float _S7615 = - _S7611 + _S7613; + float _S7616 = _S7608 + - _S7612; + float _S7617 = - _S7607 + _S7609; + float _S7618 = _S7607 + _S7609; + float _S7619 = _S7608 + _S7612; + float _S7620 = _S7611 + _S7613; + float _S7621 = _S7426.w * (_S7610 + _S7614); + float _S7622 = _S7426.z * (_S7606 + _S7614); + float _S7623 = _S7426.y * (_S7606 + _S7610); + float _S7624 = _S7426.x * _S7615 + _S7426.z * _S7618 + _S7426.y * _S7619 + _S7621 + _S7621; + float _S7625 = _S7426.x * _S7616 + _S7426.w * _S7618 + _S7426.y * _S7620 + _S7622 + _S7622; + float _S7626 = _S7426.x * _S7617 + _S7426.w * _S7619 + _S7426.z * _S7620 + _S7623 + _S7623; + float _S7627 = _S7426.w * _S7615 + _S7426.z * _S7616 + _S7426.y * _S7617; + float4 _S7628 = make_float4 (0.0f); + float4 _S7629 = _S7628; + *&((&_S7629)->w) = _S7624; + *&((&_S7629)->z) = _S7625; + *&((&_S7629)->y) = _S7626; + *&((&_S7629)->x) = _S7627; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S7630; + (&_S7630)->primal_0 = quat_33; + (&_S7630)->differential_0 = _S7628; + s_bwd_normalize_impl_0(&_S7630, _S7629); + float3 _S7631 = _S7424; + *&((&_S7631)->z) = _S7595; + *&((&_S7631)->y) = _S7599; + *&((&_S7631)->x) = _S7603; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7632; + (&_S7632)->primal_0 = scale_33; + (&_S7632)->differential_0 = _S7424; + s_bwd_prop_exp_1(&_S7632, _S7631); + float _S7633 = - (_S7551 / _S7479); + DiffPair_float_0 _S7634; + (&_S7634)->primal_0 = _S7476; + (&_S7634)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S7634, _S7633); + float _S7635 = - _S7634.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7636; + (&_S7636)->primal_0 = mean_c_33; + (&_S7636)->differential_0 = _S7424; + s_bwd_length_impl_0(&_S7636, v_depth_11); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7637; + (&_S7637)->primal_0 = R_33; + (&_S7637)->differential_0 = _S7577; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7638; + (&_S7638)->primal_0 = mean_34; + (&_S7638)->differential_0 = _S7424; + s_bwd_prop_mul_3(&_S7637, &_S7638, _S7636.differential_0); + Matrix _S7639 = _S7578.differential_0 + _S7580.differential_0 + _S7582.differential_0 + _S7584.differential_0 + _S7586.differential_0 + _S7588.differential_0 + _S7590.differential_0 + _S7637.differential_0; + float _S7640 = _S7635 + _S7535.differential_0; + float3 _S7641 = _S7632.differential_0 + _S7534.differential_0; + *v_mean_11 = *v_mean_11 + (_S7579.differential_0 + _S7585.differential_0 + _S7581.differential_0 + _S7587.differential_0 + _S7583.differential_0 + _S7589.differential_0 + _S7638.differential_0 + _S7533.differential_0); + *v_quat_11 = *v_quat_11 + _S7630.differential_0; + *v_scale_11 = *v_scale_11 + _S7641; + *v_in_opacity_11 = *v_in_opacity_11 + _S7640; + *v_R_11 = *v_R_11 + _S7639; + *v_t_11 = *v_t_11 + _S7636.differential_0; return; } -inline __device__ void projection_3dgut_equirect_vjp(bool antialiased_15, float3 mean_16, float4 quat_15, float3 scale_15, float in_opacity_15, Matrix R_15, float3 t_15, float fx_19, float fy_19, float cx_16, float cy_16, FixedArray dist_coeffs_19, uint image_width_15, uint image_height_15, float2 v_mean2d_7, float v_depth_7, float3 v_conic_7, float v_opacity_7, float3 * v_mean_7, float4 * v_quat_7, float3 * v_scale_7, float * v_in_opacity_7, Matrix * v_R_7, float3 * v_t_7) +struct s_bwd_prop_DiffProjection3DGS_3dgut_persp_opencv_projection_Intermediates_0 { - float3 _S3908 = make_float3 (0.0f); - float3 mean_c_15 = s_primal_ctx_mul_0(R_15, mean_16) + t_15; - float _S3909 = - in_opacity_15; - float _S3910 = 1.0f + s_primal_ctx_exp_0(_S3909); - float _S3911 = 1.0f / _S3910; - float _S3912 = _S3910 * _S3910; - float3 _S3913 = s_primal_ctx_exp_1(scale_15); - float4 _S3914 = normalize_0(quat_15); - float _S3915 = _S3914.y; - float x2_15 = _S3915 * _S3915; - float y2_15 = _S3914.z * _S3914.z; - float z2_15 = _S3914.w * _S3914.w; - float xy_15 = _S3914.y * _S3914.z; - float xz_15 = _S3914.y * _S3914.w; - float yz_15 = _S3914.z * _S3914.w; - float wx_15 = _S3914.x * _S3914.y; - float wy_15 = _S3914.x * _S3914.z; - float wz_15 = _S3914.x * _S3914.w; - Matrix _S3916 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_15 + z2_15), 2.0f * (xy_15 + wz_15), 2.0f * (xz_15 - wy_15), 2.0f * (xy_15 - wz_15), 1.0f - 2.0f * (x2_15 + z2_15), 2.0f * (yz_15 + wx_15), 2.0f * (xz_15 + wy_15), 2.0f * (yz_15 - wx_15), 1.0f - 2.0f * (x2_15 + y2_15)))); - FixedArray _S3917 = { - _S3908, _S3908, _S3908, _S3908, _S3908, _S3908, _S3908 + float2 _S7642; + float2 _S7643; + float2 _S7644; + float2 _S7645; + float2 _S7646; + float2 _S7647; + float2 _S7648; +}; + +inline __device__ float2 s_primal_ctx_DistOpenCV_distort_0(float2 dpuv_9, FixedArray * coeffs_21) +{ + float u_15 = dpuv_9.x; + float v_15 = dpuv_9.y; + float r2_15 = u_15 * u_15 + v_15 * v_15; + return dpuv_9 * make_float2 (1.0f + r2_15 * ((*coeffs_21)[int(0)] + r2_15 * (*coeffs_21)[int(1)])) + make_float2 (2.0f * (*coeffs_21)[int(2)] * u_15 * v_15 + (*coeffs_21)[int(3)] * (r2_15 + 2.0f * u_15 * u_15), 2.0f * (*coeffs_21)[int(3)] * u_15 * v_15 + (*coeffs_21)[int(2)] * (r2_15 + 2.0f * v_15 * v_15)); +} + +inline __device__ void projection_3dgut_persp_opencv_vjp(bool antialiased_34, float3 mean_35, float4 quat_34, float3 scale_34, float in_opacity_34, Matrix R_34, float3 t_34, float fx_47, float fy_47, float cx_38, float cy_38, FixedArray dist_coeffs_46, uint image_width_34, uint image_height_34, float2 v_mean2d_12, float v_depth_12, float3 v_conic_12, float v_opacity_12, float3 * v_mean_12, float4 * v_quat_12, float3 * v_scale_12, float * v_in_opacity_12, Matrix * v_R_12, float3 * v_t_12) +{ + float2 _S7649 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_persp_opencv_projection_Intermediates_0 _S7650; + (&_S7650)->_S7642 = _S7649; + (&_S7650)->_S7643 = _S7649; + (&_S7650)->_S7644 = _S7649; + (&_S7650)->_S7645 = _S7649; + (&_S7650)->_S7646 = _S7649; + (&_S7650)->_S7647 = _S7649; + (&_S7650)->_S7648 = _S7649; + float3 _S7651 = make_float3 (0.0f); + float3 _S7652 = s_primal_ctx_exp_1(scale_34); + float4 _S7653 = normalize_0(quat_34); + float _S7654 = _S7653.y; + float x2_34 = _S7654 * _S7654; + float y2_34 = _S7653.z * _S7653.z; + float z2_34 = _S7653.w * _S7653.w; + float xy_34 = _S7653.y * _S7653.z; + float xz_34 = _S7653.y * _S7653.w; + float yz_34 = _S7653.z * _S7653.w; + float wx_34 = _S7653.x * _S7653.y; + float wy_34 = _S7653.x * _S7653.z; + float wz_34 = _S7653.x * _S7653.w; + Matrix _S7655 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_34 + z2_34), 2.0f * (xy_34 + wz_34), 2.0f * (xz_34 - wy_34), 2.0f * (xy_34 - wz_34), 1.0f - 2.0f * (x2_34 + z2_34), 2.0f * (yz_34 + wx_34), 2.0f * (xz_34 + wy_34), 2.0f * (yz_34 - wx_34), 1.0f - 2.0f * (x2_34 + y2_34)))); + FixedArray _S7656 = { + _S7651, _S7651, _S7651, _S7651, _S7651, _S7651, _S7651 }; - FixedArray _S3918 = { + FixedArray _S7657 = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; - SigmaPoints_0 _S3919; - (&_S3919)->p_0 = _S3917; - (&_S3919)->w_mean_0 = _S3918; - (&_S3919)->w_cov_0 = _S3918; - (&_S3919)->p_0[int(0)] = mean_16; - SigmaPoints_0 _S3920 = _S3919; - (&_S3920)->w_mean_0[int(0)] = 0.0f; - (&_S3920)->w_cov_0[int(0)] = 2.0f; - float _S3921 = s_primal_ctx_sqrt_0(3.0f); - float _S3922 = _S3921 * _S3913.x; - float3 _S3923 = make_float3 (_S3922); - float3 delta_21 = make_float3 (_S3922) * _S3916.rows[0U]; - float3 _S3924 = mean_16 + delta_21; - (&_S3920)->p_0[1U] = _S3924; - float3 _S3925 = mean_16 - delta_21; - (&_S3920)->p_0[4U] = _S3925; - float _S3926 = _S3921 * _S3913.y; - float3 _S3927 = make_float3 (_S3926); - float3 delta_22 = make_float3 (_S3926) * _S3916.rows[1U]; - float3 _S3928 = mean_16 + delta_22; - (&_S3920)->p_0[2U] = _S3928; - float3 _S3929 = mean_16 - delta_22; - (&_S3920)->p_0[5U] = _S3929; - float _S3930 = _S3921 * _S3913.z; - float3 _S3931 = make_float3 (_S3930); - float3 delta_23 = make_float3 (_S3930) * _S3916.rows[2U]; - float3 _S3932 = mean_16 + delta_23; - (&_S3920)->p_0[3U] = _S3932; - float3 _S3933 = mean_16 - delta_23; - (&_S3920)->p_0[6U] = _S3933; - (&_S3920)->w_mean_0[1U] = 0.1666666716337204f; - SigmaPoints_0 _S3934 = _S3920; - (&_S3934)->w_cov_0[1U] = 0.1666666716337204f; - SigmaPoints_0 _S3935 = _S3934; - (&_S3935)->w_mean_0[2U] = 0.1666666716337204f; - SigmaPoints_0 _S3936 = _S3935; - (&_S3936)->w_cov_0[2U] = 0.1666666716337204f; - SigmaPoints_0 _S3937 = _S3936; - (&_S3937)->w_mean_0[3U] = 0.1666666716337204f; - SigmaPoints_0 _S3938 = _S3937; - (&_S3938)->w_cov_0[3U] = 0.1666666716337204f; - SigmaPoints_0 _S3939 = _S3938; - (&_S3939)->w_mean_0[4U] = 0.1666666716337204f; - SigmaPoints_0 _S3940 = _S3939; - (&_S3940)->w_cov_0[4U] = 0.1666666716337204f; - SigmaPoints_0 _S3941 = _S3940; - (&_S3941)->w_mean_0[5U] = 0.1666666716337204f; - SigmaPoints_0 _S3942 = _S3941; - (&_S3942)->w_cov_0[5U] = 0.1666666716337204f; - SigmaPoints_0 _S3943 = _S3942; - (&_S3943)->w_mean_0[6U] = 0.1666666716337204f; - SigmaPoints_0 _S3944 = _S3943; - (&_S3944)->w_cov_0[6U] = 0.1666666716337204f; - SigmaPoints_0 _S3945 = _S3919; - float3 _S3946 = s_primal_ctx_mul_0(R_15, _S3919.p_0[0U]) + t_15; - _S3919 = _S3944; - (&_S3919)->p_0[0U] = _S3946; - SigmaPoints_0 _S3947 = _S3919; - (&_S3919)->p_0[1U] = s_primal_ctx_mul_0(R_15, _S3924) + t_15; - SigmaPoints_0 _S3948 = _S3919; - (&_S3919)->p_0[2U] = s_primal_ctx_mul_0(R_15, _S3928) + t_15; - SigmaPoints_0 _S3949 = _S3919; - (&_S3919)->p_0[3U] = s_primal_ctx_mul_0(R_15, _S3932) + t_15; - SigmaPoints_0 _S3950 = _S3919; - (&_S3919)->p_0[4U] = s_primal_ctx_mul_0(R_15, _S3925) + t_15; - SigmaPoints_0 _S3951 = _S3919; - (&_S3919)->p_0[5U] = s_primal_ctx_mul_0(R_15, _S3929) + t_15; - SigmaPoints_0 _S3952 = _S3919; - (&_S3919)->p_0[6U] = s_primal_ctx_mul_0(R_15, _S3933) + t_15; - float _S3953 = fx_19 * s_primal_ctx_atan2_0(_S3947.p_0[int(0)].x, _S3947.p_0[int(0)].z) + cx_16; - float _S3954 = fx_19 * s_primal_ctx_atan2_0(_S3948.p_0[int(1)].x, _S3948.p_0[int(1)].z) + cx_16; - float2 _S3955 = make_float2 (_S3954, fy_19 * s_primal_ctx_atan2_0(_S3948.p_0[int(1)].y, length_0(float2 {_S3948.p_0[int(1)].x, _S3948.p_0[int(1)].z})) + cy_16); - float2 _S3956 = make_float2 (fx_19 * s_primal_ctx_atan2_0(_S3949.p_0[int(2)].x, _S3949.p_0[int(2)].z) + cx_16, fy_19 * s_primal_ctx_atan2_0(_S3949.p_0[int(2)].y, length_0(float2 {_S3949.p_0[int(2)].x, _S3949.p_0[int(2)].z})) + cy_16); - float2 _S3957 = make_float2 (fx_19 * s_primal_ctx_atan2_0(_S3950.p_0[int(3)].x, _S3950.p_0[int(3)].z) + cx_16, fy_19 * s_primal_ctx_atan2_0(_S3950.p_0[int(3)].y, length_0(float2 {_S3950.p_0[int(3)].x, _S3950.p_0[int(3)].z})) + cy_16); - float2 _S3958 = make_float2 (fx_19 * s_primal_ctx_atan2_0(_S3951.p_0[int(4)].x, _S3951.p_0[int(4)].z) + cx_16, fy_19 * s_primal_ctx_atan2_0(_S3951.p_0[int(4)].y, length_0(float2 {_S3951.p_0[int(4)].x, _S3951.p_0[int(4)].z})) + cy_16); - float2 _S3959 = make_float2 (fx_19 * s_primal_ctx_atan2_0(_S3952.p_0[int(5)].x, _S3952.p_0[int(5)].z) + cx_16, fy_19 * s_primal_ctx_atan2_0(_S3952.p_0[int(5)].y, length_0(float2 {_S3952.p_0[int(5)].x, _S3952.p_0[int(5)].z})) + cy_16); - float2 _S3960 = make_float2 (fx_19 * s_primal_ctx_atan2_0(_S3919.p_0[int(6)].x, _S3919.p_0[int(6)].z) + cx_16, fy_19 * s_primal_ctx_atan2_0(_S3919.p_0[int(6)].y, length_0(float2 {_S3919.p_0[int(6)].x, _S3919.p_0[int(6)].z})) + cy_16); - float _S3961 = fx_19 * 6.28318548202514648f; - float du_6 = _S3954 - _S3953; - float _S3962 = _S3953 + (du_6 - _S3961 * (F32_round((du_6 / _S3961)))); - FixedArray _S3963; - _S3963[int(0)] = make_float2 (_S3953, fy_19 * s_primal_ctx_atan2_0(_S3947.p_0[int(0)].y, length_0(float2 {_S3947.p_0[int(0)].x, _S3947.p_0[int(0)].z})) + cy_16); - _S3963[int(1)] = _S3955; - _S3963[int(2)] = _S3956; - _S3963[int(3)] = _S3957; - _S3963[int(4)] = _S3958; - _S3963[int(5)] = _S3959; - _S3963[int(6)] = _S3960; - *&((&_S3963[int(1)])->x) = _S3962; - float du_7 = _S3963[int(2)].x - _S3953; - *&((&_S3963[int(2)])->x) = _S3953 + (du_7 - _S3961 * (F32_round((du_7 / _S3961)))); - float du_8 = _S3963[int(3)].x - _S3953; - *&((&_S3963[int(3)])->x) = _S3953 + (du_8 - _S3961 * (F32_round((du_8 / _S3961)))); - float du_9 = _S3963[int(4)].x - _S3953; - *&((&_S3963[int(4)])->x) = _S3953 + (du_9 - _S3961 * (F32_round((du_9 / _S3961)))); - float du_10 = _S3963[int(5)].x - _S3953; - *&((&_S3963[int(5)])->x) = _S3953 + (du_10 - _S3961 * (F32_round((du_10 / _S3961)))); - float du_11 = _S3963[int(6)].x - _S3953; - *&((&_S3963[int(6)])->x) = _S3953 + (du_11 - _S3961 * (F32_round((du_11 / _S3961)))); - float2 _S3964 = make_float2 (_S3920.w_mean_0[int(1)]); - float2 _S3965 = make_float2 (_S3935.w_mean_0[int(2)]); - float2 _S3966 = make_float2 (_S3937.w_mean_0[int(3)]); - float2 _S3967 = make_float2 (_S3939.w_mean_0[int(4)]); - float2 _S3968 = make_float2 (_S3941.w_mean_0[int(5)]); - float2 _S3969 = make_float2 (_S3943.w_mean_0[int(6)]); - float2 _S3970 = make_float2 (_S3920.w_mean_0[int(1)]) * _S3963[int(1)] + make_float2 (_S3935.w_mean_0[int(2)]) * _S3963[int(2)] + make_float2 (_S3937.w_mean_0[int(3)]) * _S3963[int(3)] + make_float2 (_S3939.w_mean_0[int(4)]) * _S3963[int(4)] + make_float2 (_S3941.w_mean_0[int(5)]) * _S3963[int(5)] + make_float2 (_S3943.w_mean_0[int(6)]) * _S3963[int(6)]; - float2 d_49 = _S3963[int(0)] - _S3970; - float _S3971 = d_49.x; - float _S3972 = d_49.y; - float _S3973 = _S3971 * _S3972; - float2 d_50 = _S3963[int(1)] - _S3970; - Matrix _S3974 = makeMatrix (_S3934.w_cov_0[int(1)]); - float _S3975 = d_50.x; - float _S3976 = d_50.y; - float _S3977 = _S3975 * _S3976; - float2 d_51 = _S3963[int(2)] - _S3970; - Matrix _S3978 = makeMatrix (_S3936.w_cov_0[int(2)]); - float _S3979 = d_51.x; - float _S3980 = d_51.y; - float _S3981 = _S3979 * _S3980; - float2 d_52 = _S3963[int(3)] - _S3970; - Matrix _S3982 = makeMatrix (_S3938.w_cov_0[int(3)]); - float _S3983 = d_52.x; - float _S3984 = d_52.y; - float _S3985 = _S3983 * _S3984; - float2 d_53 = _S3963[int(4)] - _S3970; - Matrix _S3986 = makeMatrix (_S3940.w_cov_0[int(4)]); - float _S3987 = d_53.x; - float _S3988 = d_53.y; - float _S3989 = _S3987 * _S3988; - float2 d_54 = _S3963[int(5)] - _S3970; - Matrix _S3990 = makeMatrix (_S3942.w_cov_0[int(5)]); - float _S3991 = d_54.x; - float _S3992 = d_54.y; - float _S3993 = _S3991 * _S3992; - float2 d_55 = _S3963[int(6)] - _S3970; - Matrix _S3994 = makeMatrix (_S3944.w_cov_0[int(6)]); - float _S3995 = d_55.x; - float _S3996 = d_55.y; - float _S3997 = _S3995 * _S3996; - Matrix covar2d_11 = makeMatrix (2.0f) * makeMatrix (_S3971 * _S3971, _S3973, _S3973, _S3972 * _S3972) + makeMatrix (_S3934.w_cov_0[int(1)]) * makeMatrix (_S3975 * _S3975, _S3977, _S3977, _S3976 * _S3976) + makeMatrix (_S3936.w_cov_0[int(2)]) * makeMatrix (_S3979 * _S3979, _S3981, _S3981, _S3980 * _S3980) + makeMatrix (_S3938.w_cov_0[int(3)]) * makeMatrix (_S3983 * _S3983, _S3985, _S3985, _S3984 * _S3984) + makeMatrix (_S3940.w_cov_0[int(4)]) * makeMatrix (_S3987 * _S3987, _S3989, _S3989, _S3988 * _S3988) + makeMatrix (_S3942.w_cov_0[int(5)]) * makeMatrix (_S3991 * _S3991, _S3993, _S3993, _S3992 * _S3992) + makeMatrix (_S3944.w_cov_0[int(6)]) * makeMatrix (_S3995 * _S3995, _S3997, _S3997, _S3996 * _S3996); - float eps2d_15; - if(antialiased_15) + SigmaPoints_0 _S7658; + (&_S7658)->p_0 = _S7656; + (&_S7658)->w_mean_0 = _S7657; + (&_S7658)->w_cov_0 = _S7657; + (&_S7658)->p_0[int(0)] = mean_35; + SigmaPoints_0 _S7659 = _S7658; + (&_S7659)->w_mean_0[int(0)] = 0.0f; + (&_S7659)->w_cov_0[int(0)] = 2.0f; + float _S7660 = s_primal_ctx_sqrt_0(3.0f); + float _S7661 = _S7660 * _S7652.x; + float3 delta_36 = make_float3 (_S7661) * _S7655.rows[0U]; + float3 _S7662 = mean_35 + delta_36; + (&_S7659)->p_0[1U] = _S7662; + float3 _S7663 = mean_35 - delta_36; + (&_S7659)->p_0[4U] = _S7663; + float _S7664 = _S7660 * _S7652.y; + float3 delta_37 = make_float3 (_S7664) * _S7655.rows[1U]; + float3 _S7665 = mean_35 + delta_37; + (&_S7659)->p_0[2U] = _S7665; + float3 _S7666 = mean_35 - delta_37; + (&_S7659)->p_0[5U] = _S7666; + float _S7667 = _S7660 * _S7652.z; + float3 delta_38 = make_float3 (_S7667) * _S7655.rows[2U]; + float3 _S7668 = mean_35 + delta_38; + (&_S7659)->p_0[3U] = _S7668; + float3 _S7669 = mean_35 - delta_38; + (&_S7659)->p_0[6U] = _S7669; + (&_S7659)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S7670 = _S7659; + (&_S7670)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S7671 = _S7670; + (&_S7671)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S7672 = _S7671; + (&_S7672)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S7673 = _S7672; + (&_S7673)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S7674 = _S7673; + (&_S7674)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S7675 = _S7674; + (&_S7675)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S7676 = _S7675; + (&_S7676)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S7677 = _S7676; + (&_S7677)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S7678 = _S7677; + (&_S7678)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S7679 = _S7678; + (&_S7679)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S7680 = _S7679; + (&_S7680)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S7681 = _S7658; + float3 _S7682 = s_primal_ctx_mul_0(R_34, _S7658.p_0[0U]) + t_34; + _S7658 = _S7680; + (&_S7658)->p_0[0U] = _S7682; + SigmaPoints_0 _S7683 = _S7658; + (&_S7658)->p_0[1U] = s_primal_ctx_mul_0(R_34, _S7662) + t_34; + SigmaPoints_0 _S7684 = _S7658; + (&_S7658)->p_0[2U] = s_primal_ctx_mul_0(R_34, _S7665) + t_34; + SigmaPoints_0 _S7685 = _S7658; + (&_S7658)->p_0[3U] = s_primal_ctx_mul_0(R_34, _S7668) + t_34; + SigmaPoints_0 _S7686 = _S7658; + (&_S7658)->p_0[4U] = s_primal_ctx_mul_0(R_34, _S7663) + t_34; + SigmaPoints_0 _S7687 = _S7658; + (&_S7658)->p_0[5U] = s_primal_ctx_mul_0(R_34, _S7666) + t_34; + SigmaPoints_0 _S7688 = _S7658; + (&_S7658)->p_0[6U] = s_primal_ctx_mul_0(R_34, _S7669) + t_34; + float2 uv_47 = float2 {_S7683.p_0[int(0)].x, _S7683.p_0[int(0)].y} / make_float2 (_S7683.p_0[int(0)].z); + FixedArray _S7689 = dist_coeffs_46; + float2 _S7690 = s_primal_ctx_DistOpenCV_distort_0(uv_47, &_S7689); + (&_S7650)->_S7642 = make_float2 (fx_47 * _S7690.x + cx_38, fy_47 * _S7690.y + cy_38); + float2 uv_48 = float2 {_S7684.p_0[int(1)].x, _S7684.p_0[int(1)].y} / make_float2 (_S7684.p_0[int(1)].z); + FixedArray _S7691 = dist_coeffs_46; + float2 _S7692 = s_primal_ctx_DistOpenCV_distort_0(uv_48, &_S7691); + (&_S7650)->_S7643 = make_float2 (fx_47 * _S7692.x + cx_38, fy_47 * _S7692.y + cy_38); + float2 uv_49 = float2 {_S7685.p_0[int(2)].x, _S7685.p_0[int(2)].y} / make_float2 (_S7685.p_0[int(2)].z); + FixedArray _S7693 = dist_coeffs_46; + float2 _S7694 = s_primal_ctx_DistOpenCV_distort_0(uv_49, &_S7693); + (&_S7650)->_S7644 = make_float2 (fx_47 * _S7694.x + cx_38, fy_47 * _S7694.y + cy_38); + float2 uv_50 = float2 {_S7686.p_0[int(3)].x, _S7686.p_0[int(3)].y} / make_float2 (_S7686.p_0[int(3)].z); + FixedArray _S7695 = dist_coeffs_46; + float2 _S7696 = s_primal_ctx_DistOpenCV_distort_0(uv_50, &_S7695); + (&_S7650)->_S7645 = make_float2 (fx_47 * _S7696.x + cx_38, fy_47 * _S7696.y + cy_38); + float2 uv_51 = float2 {_S7687.p_0[int(4)].x, _S7687.p_0[int(4)].y} / make_float2 (_S7687.p_0[int(4)].z); + FixedArray _S7697 = dist_coeffs_46; + float2 _S7698 = s_primal_ctx_DistOpenCV_distort_0(uv_51, &_S7697); + (&_S7650)->_S7646 = make_float2 (fx_47 * _S7698.x + cx_38, fy_47 * _S7698.y + cy_38); + float2 uv_52 = float2 {_S7688.p_0[int(5)].x, _S7688.p_0[int(5)].y} / make_float2 (_S7688.p_0[int(5)].z); + FixedArray _S7699 = dist_coeffs_46; + float2 _S7700 = s_primal_ctx_DistOpenCV_distort_0(uv_52, &_S7699); + (&_S7650)->_S7647 = make_float2 (fx_47 * _S7700.x + cx_38, fy_47 * _S7700.y + cy_38); + float2 uv_53 = float2 {_S7658.p_0[int(6)].x, _S7658.p_0[int(6)].y} / make_float2 (_S7658.p_0[int(6)].z); + FixedArray _S7701 = dist_coeffs_46; + float2 _S7702 = s_primal_ctx_DistOpenCV_distort_0(uv_53, &_S7701); + (&_S7650)->_S7648 = make_float2 (fx_47 * _S7702.x + cx_38, fy_47 * _S7702.y + cy_38); + float3 mean_c_34 = s_primal_ctx_mul_0(R_34, mean_35) + t_34; + float _S7703 = - in_opacity_34; + float _S7704 = 1.0f + s_primal_ctx_exp_0(_S7703); + float _S7705 = 1.0f / _S7704; + float _S7706 = _S7704 * _S7704; + float3 _S7707 = make_float3 (_S7661); + float3 _S7708 = make_float3 (_S7664); + float3 _S7709 = make_float3 (_S7667); + float _S7710 = float(image_width_34); + float _S7711 = float(image_height_34); + float _S7712 = 0.30000001192092896f * (0.5f * _S7710 / fx_47) * fx_47; + float lim_x_pos_17 = _S7710 + _S7712; + float _S7713 = 0.30000001192092896f * (0.5f * _S7711 / fy_47) * fy_47; + float lim_y_pos_5 = _S7711 + _S7713; + float2 _S7714 = make_float2 (_S7659.w_mean_0[int(1)]) * _S7650._S7643 + make_float2 (_S7671.w_mean_0[int(2)]) * _S7650._S7644 + make_float2 (_S7673.w_mean_0[int(3)]) * _S7650._S7645 + make_float2 (_S7675.w_mean_0[int(4)]) * _S7650._S7646 + make_float2 (_S7677.w_mean_0[int(5)]) * _S7650._S7647 + make_float2 (_S7679.w_mean_0[int(6)]) * _S7650._S7648; + float _S7715 = - _S7712; + float _S7716 = - _S7713; + float2 _S7717 = make_float2 (s_primal_ctx_clamp_0(_S7714.x, _S7715, lim_x_pos_17), s_primal_ctx_clamp_0(_S7714.y, _S7716, lim_y_pos_5)); + float2 d_84 = make_float2 (s_primal_ctx_clamp_0(_S7650._S7642.x, _S7715, lim_x_pos_17), s_primal_ctx_clamp_0(_S7650._S7642.y, _S7716, lim_y_pos_5)) - _S7717; + float _S7718 = d_84.x; + float _S7719 = d_84.y; + float _S7720 = _S7718 * _S7719; + float2 d_85 = make_float2 (s_primal_ctx_clamp_0(_S7650._S7643.x, _S7715, lim_x_pos_17), s_primal_ctx_clamp_0(_S7650._S7643.y, _S7716, lim_y_pos_5)) - _S7717; + float _S7721 = d_85.x; + float _S7722 = d_85.y; + float _S7723 = _S7721 * _S7722; + float2 d_86 = make_float2 (s_primal_ctx_clamp_0(_S7650._S7644.x, _S7715, lim_x_pos_17), s_primal_ctx_clamp_0(_S7650._S7644.y, _S7716, lim_y_pos_5)) - _S7717; + float _S7724 = d_86.x; + float _S7725 = d_86.y; + float _S7726 = _S7724 * _S7725; + float2 d_87 = make_float2 (s_primal_ctx_clamp_0(_S7650._S7645.x, _S7715, lim_x_pos_17), s_primal_ctx_clamp_0(_S7650._S7645.y, _S7716, lim_y_pos_5)) - _S7717; + float _S7727 = d_87.x; + float _S7728 = d_87.y; + float _S7729 = _S7727 * _S7728; + float2 d_88 = make_float2 (s_primal_ctx_clamp_0(_S7650._S7646.x, _S7715, lim_x_pos_17), s_primal_ctx_clamp_0(_S7650._S7646.y, _S7716, lim_y_pos_5)) - _S7717; + float _S7730 = d_88.x; + float _S7731 = d_88.y; + float _S7732 = _S7730 * _S7731; + float2 d_89 = make_float2 (s_primal_ctx_clamp_0(_S7650._S7647.x, _S7715, lim_x_pos_17), s_primal_ctx_clamp_0(_S7650._S7647.y, _S7716, lim_y_pos_5)) - _S7717; + float _S7733 = d_89.x; + float _S7734 = d_89.y; + float _S7735 = _S7733 * _S7734; + float2 d_90 = make_float2 (s_primal_ctx_clamp_0(_S7650._S7648.x, _S7715, lim_x_pos_17), s_primal_ctx_clamp_0(_S7650._S7648.y, _S7716, lim_y_pos_5)) - _S7717; + float _S7736 = d_90.x; + float _S7737 = d_90.y; + float _S7738 = _S7736 * _S7737; + Matrix covar2d_23 = makeMatrix (2.0f) * makeMatrix (_S7718 * _S7718, _S7720, _S7720, _S7719 * _S7719) + makeMatrix (_S7670.w_cov_0[int(1)]) * makeMatrix (_S7721 * _S7721, _S7723, _S7723, _S7722 * _S7722) + makeMatrix (_S7672.w_cov_0[int(2)]) * makeMatrix (_S7724 * _S7724, _S7726, _S7726, _S7725 * _S7725) + makeMatrix (_S7674.w_cov_0[int(3)]) * makeMatrix (_S7727 * _S7727, _S7729, _S7729, _S7728 * _S7728) + makeMatrix (_S7676.w_cov_0[int(4)]) * makeMatrix (_S7730 * _S7730, _S7732, _S7732, _S7731 * _S7731) + makeMatrix (_S7678.w_cov_0[int(5)]) * makeMatrix (_S7733 * _S7733, _S7735, _S7735, _S7734 * _S7734) + makeMatrix (_S7680.w_cov_0[int(6)]) * makeMatrix (_S7736 * _S7736, _S7738, _S7738, _S7737 * _S7737); + float eps2d_34; + if(antialiased_34) { - eps2d_15 = 0.10000000149011612f; + eps2d_34 = 0.10000000149011612f; } else { - eps2d_15 = 0.30000001192092896f; + eps2d_34 = 0.30000001192092896f; } - float _S3998 = covar2d_11.rows[int(0)].y * covar2d_11.rows[int(1)].x; - float det_orig_15 = covar2d_11.rows[int(0)].x * covar2d_11.rows[int(1)].y - _S3998; - float _S3999 = covar2d_11.rows[int(0)].x + eps2d_15; - Matrix _S4000 = covar2d_11; - *&(((&_S4000)->rows + (int(0)))->x) = _S3999; - float _S4001 = covar2d_11.rows[int(1)].y + eps2d_15; - *&(((&_S4000)->rows + (int(1)))->y) = _S4001; - Matrix _S4002 = _S4000; - Matrix _S4003 = _S4000; - float det_blur_15 = _S3999 * _S4001 - _S3998; - float _S4004 = det_orig_15 / det_blur_15; - float _S4005 = det_blur_15 * det_blur_15; - float _S4006 = (F32_max((0.0f), (_S4004))); - float _S4007 = s_primal_ctx_sqrt_0(_S4006); - float invdet_17 = 1.0f / det_blur_15; - float _S4008 = - covar2d_11.rows[int(0)].y; - float _S4009 = - covar2d_11.rows[int(1)].x; - if(antialiased_15) + float _S7739 = covar2d_23.rows[int(0)].y * covar2d_23.rows[int(1)].x; + float det_orig_34 = covar2d_23.rows[int(0)].x * covar2d_23.rows[int(1)].y - _S7739; + float _S7740 = covar2d_23.rows[int(0)].x + eps2d_34; + Matrix _S7741 = covar2d_23; + *&(((&_S7741)->rows + (int(0)))->x) = _S7740; + float _S7742 = covar2d_23.rows[int(1)].y + eps2d_34; + *&(((&_S7741)->rows + (int(1)))->y) = _S7742; + Matrix _S7743 = _S7741; + Matrix _S7744 = _S7741; + float det_blur_34 = _S7740 * _S7742 - _S7739; + float _S7745 = det_orig_34 / det_blur_34; + float _S7746 = det_blur_34 * det_blur_34; + float _S7747 = (F32_max((0.0f), (_S7745))); + float _S7748 = s_primal_ctx_sqrt_0(_S7747); + float invdet_40 = 1.0f / det_blur_34; + float _S7749 = - covar2d_23.rows[int(0)].y; + float _S7750 = - covar2d_23.rows[int(1)].x; + if(antialiased_34) { - eps2d_15 = _S3911 * _S4007; + eps2d_34 = _S7705 * _S7748; } else { - eps2d_15 = _S3911; + eps2d_34 = _S7705; } - float _S4010 = eps2d_15 / 0.00392156885936856f; - float _S4011 = 2.0f * s_primal_ctx_log_0(_S4010); - float _S4012 = s_primal_ctx_sqrt_0(_S4011); - float _S4013 = _S4002.rows[int(0)].x; - float _S4014 = _S4003.rows[int(1)].y; - float3 campos_8 = - s_primal_ctx_mul_0(transpose_3(R_15), t_15); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4015; - (&_S4015)->primal_0 = mean_16; - (&_S4015)->differential_0 = _S3908; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4016; - (&_S4016)->primal_0 = scale_15; - (&_S4016)->differential_0 = _S3908; - DiffPair_float_0 _S4017; - (&_S4017)->primal_0 = in_opacity_15; - (&_S4017)->differential_0 = 0.0f; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4018; - (&_S4018)->primal_0 = campos_8; - (&_S4018)->differential_0 = _S3908; - s_bwd_prop_view_radius_3dgs_0(&_S4015, &_S4016, &_S4017, &_S4018, 0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4019 = _S4015; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4020 = _S4016; - DiffPair_float_0 _S4021 = _S4017; - float2 _S4022 = make_float2 (0.0f); - float2 _S4023 = _S4022; - *&((&_S4023)->y) = v_conic_7.z; - float2 _S4024 = _S4022; - *&((&_S4024)->y) = v_conic_7.y; - *&((&_S4024)->x) = v_conic_7.x; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4025; - (&_S4025)->primal_0 = mean_c_15; - (&_S4025)->differential_0 = _S3908; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4026; - (&_S4026)->primal_0 = mean_c_15; - (&_S4026)->differential_0 = _S3908; - s_bwd_prop_dot_0(&_S4025, &_S4026, 0.0f); - DiffPair_float_0 _S4027; - (&_S4027)->primal_0 = _S4014; - (&_S4027)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S4027, 0.0f); - DiffPair_float_0 _S4028; - (&_S4028)->primal_0 = _S4013; - (&_S4028)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S4028, 0.0f); - DiffPair_float_0 _S4029; - (&_S4029)->primal_0 = 3.32999992370605469f; - (&_S4029)->differential_0 = 0.0f; - DiffPair_float_0 _S4030; - (&_S4030)->primal_0 = _S4012; - (&_S4030)->differential_0 = 0.0f; - _d_min_0(&_S4029, &_S4030, 0.0f); - DiffPair_float_0 _S4031; - (&_S4031)->primal_0 = _S4011; - (&_S4031)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S4031, _S4030.differential_0); - float _S4032 = 2.0f * _S4031.differential_0; - DiffPair_float_0 _S4033; - (&_S4033)->primal_0 = _S4010; - (&_S4033)->differential_0 = 0.0f; - s_bwd_prop_log_0(&_S4033, _S4032); - float _S4034 = v_opacity_7 + 254.9999847412109375f * _S4033.differential_0; - Matrix _S4035 = makeMatrix (0.0f); - Matrix _S4036 = _S4035; - _S4036[int(1)] = _S4023; - _S4036[int(0)] = _S4024; - Matrix _S4037 = _S4036; - float3 _S4038 = _S4026.differential_0 + _S4025.differential_0; - float2 _S4039 = make_float2 (0.0f, _S4027.differential_0); - float2 _S4040 = make_float2 (_S4028.differential_0, 0.0f); - float _S4041; - if(antialiased_15) + float _S7751 = eps2d_34 / 0.00392156885936856f; + float _S7752 = 2.0f * s_primal_ctx_log_0(_S7751); + float _S7753 = s_primal_ctx_sqrt_0(_S7752); + float _S7754 = _S7743.rows[int(0)].x; + float _S7755 = _S7744.rows[int(1)].y; + float3 campos_13 = - s_primal_ctx_mul_0(transpose_3(R_34), t_34); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7756; + (&_S7756)->primal_0 = mean_35; + (&_S7756)->differential_0 = _S7651; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7757; + (&_S7757)->primal_0 = scale_34; + (&_S7757)->differential_0 = _S7651; + DiffPair_float_0 _S7758; + (&_S7758)->primal_0 = in_opacity_34; + (&_S7758)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7759; + (&_S7759)->primal_0 = campos_13; + (&_S7759)->differential_0 = _S7651; + s_bwd_prop_view_radius_3dgs_0(&_S7756, &_S7757, &_S7758, &_S7759, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7760 = _S7756; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7761 = _S7757; + DiffPair_float_0 _S7762 = _S7758; + float2 _S7763 = _S7649; + *&((&_S7763)->y) = v_conic_12.z; + float2 _S7764 = _S7649; + *&((&_S7764)->y) = v_conic_12.y; + *&((&_S7764)->x) = v_conic_12.x; + DiffPair_float_0 _S7765; + (&_S7765)->primal_0 = _S7755; + (&_S7765)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7765, 0.0f); + DiffPair_float_0 _S7766; + (&_S7766)->primal_0 = _S7754; + (&_S7766)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7766, 0.0f); + DiffPair_float_0 _S7767; + (&_S7767)->primal_0 = 3.32999992370605469f; + (&_S7767)->differential_0 = 0.0f; + DiffPair_float_0 _S7768; + (&_S7768)->primal_0 = _S7753; + (&_S7768)->differential_0 = 0.0f; + _d_min_0(&_S7767, &_S7768, 0.0f); + DiffPair_float_0 _S7769; + (&_S7769)->primal_0 = _S7752; + (&_S7769)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7769, _S7768.differential_0); + float _S7770 = 2.0f * _S7769.differential_0; + DiffPair_float_0 _S7771; + (&_S7771)->primal_0 = _S7751; + (&_S7771)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S7771, _S7770); + float _S7772 = v_opacity_12 + 254.9999847412109375f * _S7771.differential_0; + Matrix _S7773 = makeMatrix (0.0f); + Matrix _S7774 = _S7773; + _S7774[int(1)] = _S7763; + _S7774[int(0)] = _S7764; + Matrix _S7775 = _S7774; + float2 _S7776 = make_float2 (0.0f, _S7765.differential_0); + float2 _S7777 = make_float2 (_S7766.differential_0, 0.0f); + float _S7778; + if(antialiased_34) { - float _S4042 = _S4007 * _S4034; - eps2d_15 = _S3911 * _S4034; - _S4041 = _S4042; + float _S7779 = _S7748 * _S7772; + eps2d_34 = _S7705 * _S7772; + _S7778 = _S7779; } else { - eps2d_15 = 0.0f; - _S4041 = _S4034; + eps2d_34 = 0.0f; + _S7778 = _S7772; } - float _S4043 = invdet_17 * _S4037.rows[int(1)].y; - float _S4044 = - (invdet_17 * _S4037.rows[int(1)].x); - float _S4045 = - (invdet_17 * _S4037.rows[int(0)].y); - float _S4046 = invdet_17 * _S4037.rows[int(0)].x; - float _S4047 = - ((_S3999 * _S4037.rows[int(1)].y + _S4009 * _S4037.rows[int(1)].x + _S4008 * _S4037.rows[int(0)].y + _S4001 * _S4037.rows[int(0)].x) / _S4005); - DiffPair_float_0 _S4048; - (&_S4048)->primal_0 = _S4006; - (&_S4048)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S4048, eps2d_15); - DiffPair_float_0 _S4049; - (&_S4049)->primal_0 = 0.0f; - (&_S4049)->differential_0 = 0.0f; - DiffPair_float_0 _S4050; - (&_S4050)->primal_0 = _S4004; - (&_S4050)->differential_0 = 0.0f; - _d_max_0(&_S4049, &_S4050, _S4048.differential_0); - float _S4051 = _S4050.differential_0 / _S4005; - float s_diff_det_orig_T_7 = det_blur_15 * _S4051; - float _S4052 = det_orig_15 * - _S4051 + _S4047; - float _S4053 = - _S4052; - float _S4054 = _S3999 * _S4052; - float _S4055 = _S4001 * _S4052; - Matrix _S4056 = _S4035; - _S4056[int(1)] = _S4039; - _S4056[int(0)] = _S4040; - _S4000 = _S4056; - *&(((&_S4000)->rows + (int(1)))->y) = 0.0f; - float _S4057 = _S4054 + _S4056.rows[int(1)].y + _S4046; - *&(((&_S4000)->rows + (int(0)))->x) = 0.0f; - float _S4058 = _S4055 + _S4056.rows[int(0)].x + _S4043; - float _S4059 = _S4053 + - s_diff_det_orig_T_7; - float _S4060 = covar2d_11.rows[int(0)].y * _S4059 + _S4044; - float _S4061 = covar2d_11.rows[int(1)].x * _S4059 + _S4045; - float _S4062 = covar2d_11.rows[int(1)].y * s_diff_det_orig_T_7; - float _S4063 = _S4057 + covar2d_11.rows[int(0)].x * s_diff_det_orig_T_7; - float2 _S4064 = _S4022; - *&((&_S4064)->x) = _S4060; - *&((&_S4064)->y) = _S4063; - float _S4065 = _S4058 + _S4062; - float2 _S4066 = _S4022; - *&((&_S4066)->y) = _S4061; - *&((&_S4066)->x) = _S4065; - Matrix _S4067 = _S4035; - _S4067[int(1)] = _S4064; - _S4067[int(0)] = _S4066; - Matrix _S4068 = _S4000 + _S4067; - Matrix _S4069 = _S3994 * _S4068; - float _S4070 = _S3996 * _S4069.rows[int(1)].y; - float _S4071 = _S4069.rows[int(0)].y + _S4069.rows[int(1)].x; - float _S4072 = _S3995 * _S4069.rows[int(0)].x; - float2 s_diff_d_T_0 = make_float2 (_S3996 * _S4071 + _S4072 + _S4072, _S4070 + _S4070 + _S3995 * _S4071); - Matrix _S4073 = _S3990 * _S4068; - float _S4074 = _S3992 * _S4073.rows[int(1)].y; - float _S4075 = _S4073.rows[int(0)].y + _S4073.rows[int(1)].x; - float _S4076 = _S3991 * _S4073.rows[int(0)].x; - float2 s_diff_d_T_1 = make_float2 (_S3992 * _S4075 + _S4076 + _S4076, _S4074 + _S4074 + _S3991 * _S4075); - Matrix _S4077 = _S3986 * _S4068; - float _S4078 = _S3988 * _S4077.rows[int(1)].y; - float _S4079 = _S4077.rows[int(0)].y + _S4077.rows[int(1)].x; - float _S4080 = _S3987 * _S4077.rows[int(0)].x; - float2 s_diff_d_T_2 = make_float2 (_S3988 * _S4079 + _S4080 + _S4080, _S4078 + _S4078 + _S3987 * _S4079); - Matrix _S4081 = _S3982 * _S4068; - float _S4082 = _S3984 * _S4081.rows[int(1)].y; - float _S4083 = _S4081.rows[int(0)].y + _S4081.rows[int(1)].x; - float _S4084 = _S3983 * _S4081.rows[int(0)].x; - float2 s_diff_d_T_3 = make_float2 (_S3984 * _S4083 + _S4084 + _S4084, _S4082 + _S4082 + _S3983 * _S4083); - Matrix _S4085 = _S3978 * _S4068; - float _S4086 = _S3980 * _S4085.rows[int(1)].y; - float _S4087 = _S4085.rows[int(0)].y + _S4085.rows[int(1)].x; - float _S4088 = _S3979 * _S4085.rows[int(0)].x; - float2 s_diff_d_T_4 = make_float2 (_S3980 * _S4087 + _S4088 + _S4088, _S4086 + _S4086 + _S3979 * _S4087); - Matrix _S4089 = _S3974 * _S4068; - float _S4090 = _S3976 * _S4089.rows[int(1)].y; - float _S4091 = _S4089.rows[int(0)].y + _S4089.rows[int(1)].x; - float _S4092 = _S3975 * _S4089.rows[int(0)].x; - float2 s_diff_d_T_5 = make_float2 (_S3976 * _S4091 + _S4092 + _S4092, _S4090 + _S4090 + _S3975 * _S4091); - Matrix _S4093 = makeMatrix (2.0f) * _S4068; - float _S4094 = _S3972 * _S4093.rows[int(1)].y; - float _S4095 = _S4093.rows[int(0)].y + _S4093.rows[int(1)].x; - float _S4096 = _S3971 * _S4093.rows[int(0)].x; - float2 s_diff_d_T_6 = make_float2 (_S3972 * _S4095 + _S4096 + _S4096, _S4094 + _S4094 + _S3971 * _S4095); - float2 _S4097 = - s_diff_d_T_0 + - s_diff_d_T_1 + - s_diff_d_T_2 + - s_diff_d_T_3 + - s_diff_d_T_4 + - s_diff_d_T_5 + - s_diff_d_T_6 + v_mean2d_7; - float2 _S4098 = s_diff_d_T_0 + _S3969 * _S4097; - float2 _S4099 = s_diff_d_T_1 + _S3968 * _S4097; - float2 _S4100 = s_diff_d_T_2 + _S3967 * _S4097; - float2 _S4101 = s_diff_d_T_3 + _S3966 * _S4097; - float2 _S4102 = s_diff_d_T_4 + _S3965 * _S4097; - float2 _S4103 = s_diff_d_T_5 + _S3964 * _S4097; - FixedArray _S4104; - _S4104[int(0)] = _S4022; - _S4104[int(1)] = _S4022; - _S4104[int(2)] = _S4022; - _S4104[int(3)] = _S4022; - _S4104[int(4)] = _S4022; - _S4104[int(5)] = _S4022; - _S4104[int(6)] = _S4022; - _S4104[int(6)] = _S4098; - _S4104[int(5)] = _S4099; - _S4104[int(4)] = _S4100; - _S4104[int(3)] = _S4101; - _S4104[int(2)] = _S4102; - _S4104[int(1)] = _S4103; - _S4104[int(0)] = s_diff_d_T_6; - _S3963 = _S4104; - *&((&_S3963[int(6)])->x) = 0.0f; - float2 _S4105 = make_float2 (_S4104[int(6)].x, 0.0f); - FixedArray _S4106; - _S4106[int(0)] = _S4022; - _S4106[int(1)] = _S4022; - _S4106[int(2)] = _S4022; - _S4106[int(3)] = _S4022; - _S4106[int(4)] = _S4022; - _S4106[int(5)] = _S4022; - _S4106[int(6)] = _S4022; - _S4106[int(6)] = _S4105; - float2 _S4107 = _S3963[int(1)] + _S4106[int(1)]; - float2 _S4108 = _S3963[int(2)] + _S4106[int(2)]; - float2 _S4109 = _S3963[int(3)] + _S4106[int(3)]; - float2 _S4110 = _S3963[int(4)] + _S4106[int(4)]; - float2 _S4111 = _S3963[int(5)] + _S4106[int(5)]; - float2 _S4112 = _S3963[int(6)] + _S4106[int(6)]; - _S3963[int(0)] = _S3963[int(0)] + _S4106[int(0)]; - _S3963[int(1)] = _S4107; - _S3963[int(2)] = _S4108; - _S3963[int(3)] = _S4109; - _S3963[int(4)] = _S4110; - _S3963[int(5)] = _S4111; - _S3963[int(6)] = _S4112; - *&((&_S3963[int(5)])->x) = 0.0f; - float2 _S4113 = make_float2 (_S4111.x, 0.0f); - FixedArray _S4114; - _S4114[int(0)] = _S4022; - _S4114[int(1)] = _S4022; - _S4114[int(2)] = _S4022; - _S4114[int(3)] = _S4022; - _S4114[int(4)] = _S4022; - _S4114[int(5)] = _S4022; - _S4114[int(6)] = _S4022; - _S4114[int(5)] = _S4113; - float2 _S4115 = _S3963[int(1)] + _S4114[int(1)]; - float2 _S4116 = _S3963[int(2)] + _S4114[int(2)]; - float2 _S4117 = _S3963[int(3)] + _S4114[int(3)]; - float2 _S4118 = _S3963[int(4)] + _S4114[int(4)]; - float2 _S4119 = _S3963[int(5)] + _S4114[int(5)]; - float2 _S4120 = _S3963[int(6)] + _S4114[int(6)]; - _S3963[int(0)] = _S3963[int(0)] + _S4114[int(0)]; - _S3963[int(1)] = _S4115; - _S3963[int(2)] = _S4116; - _S3963[int(3)] = _S4117; - _S3963[int(4)] = _S4118; - _S3963[int(5)] = _S4119; - _S3963[int(6)] = _S4120; - *&((&_S3963[int(4)])->x) = 0.0f; - Matrix _S4121 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4122; - (&_S4122)->primal_0 = R_15; - (&_S4122)->differential_0 = _S4121; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4123; - (&_S4123)->primal_0 = _S3933; - (&_S4123)->differential_0 = _S3908; - s_bwd_prop_mul_3(&_S4122, &_S4123, _S3908); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4124; - (&_S4124)->primal_0 = R_15; - (&_S4124)->differential_0 = _S4121; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4125; - (&_S4125)->primal_0 = _S3929; - (&_S4125)->differential_0 = _S3908; - s_bwd_prop_mul_3(&_S4124, &_S4125, _S3908); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4126; - (&_S4126)->primal_0 = R_15; - (&_S4126)->differential_0 = _S4121; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4127; - (&_S4127)->primal_0 = _S3925; - (&_S4127)->differential_0 = _S3908; - s_bwd_prop_mul_3(&_S4126, &_S4127, _S3908); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4128; - (&_S4128)->primal_0 = R_15; - (&_S4128)->differential_0 = _S4121; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4129; - (&_S4129)->primal_0 = _S3932; - (&_S4129)->differential_0 = _S3908; - s_bwd_prop_mul_3(&_S4128, &_S4129, _S3908); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4130; - (&_S4130)->primal_0 = R_15; - (&_S4130)->differential_0 = _S4121; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4131; - (&_S4131)->primal_0 = _S3928; - (&_S4131)->differential_0 = _S3908; - s_bwd_prop_mul_3(&_S4130, &_S4131, _S3908); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4132; - (&_S4132)->primal_0 = R_15; - (&_S4132)->differential_0 = _S4121; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4133; - (&_S4133)->primal_0 = _S3924; - (&_S4133)->differential_0 = _S3908; - s_bwd_prop_mul_3(&_S4132, &_S4133, _S3908); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4134; - (&_S4134)->primal_0 = R_15; - (&_S4134)->differential_0 = _S4121; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4135; - (&_S4135)->primal_0 = _S3945.p_0[0U]; - (&_S4135)->differential_0 = _S3908; - s_bwd_prop_mul_3(&_S4134, &_S4135, _S3908); - float3 _S4136 = - _S4123.differential_0 + _S4129.differential_0; - float3 _S4137 = _S3931 * _S4136; - float3 _S4138 = _S3916.rows[2U] * _S4136; - float _S4139 = _S3921 * (_S4138.x + _S4138.y + _S4138.z); - float3 _S4140 = - _S4125.differential_0 + _S4131.differential_0; - float3 _S4141 = _S3927 * _S4140; - float3 _S4142 = _S3916.rows[1U] * _S4140; - float _S4143 = _S3921 * (_S4142.x + _S4142.y + _S4142.z); - float3 _S4144 = - _S4127.differential_0 + _S4133.differential_0; - float3 _S4145 = _S3923 * _S4144; - float3 _S4146 = _S3916.rows[0U] * _S4144; - float _S4147 = _S3921 * (_S4146.x + _S4146.y + _S4146.z); - Matrix _S4148 = _S4121; - _S4148[2U] = _S4137; - _S4148[1U] = _S4141; - _S4148[0U] = _S4145; - Matrix _S4149 = transpose_3(transpose_3(_S4148)); - float _S4150 = 2.0f * - _S4149.rows[int(2)].z; - float _S4151 = 2.0f * _S4149.rows[int(2)].y; - float _S4152 = 2.0f * _S4149.rows[int(2)].x; - float _S4153 = 2.0f * _S4149.rows[int(1)].z; - float _S4154 = 2.0f * - _S4149.rows[int(1)].y; - float _S4155 = 2.0f * _S4149.rows[int(1)].x; - float _S4156 = 2.0f * _S4149.rows[int(0)].z; - float _S4157 = 2.0f * _S4149.rows[int(0)].y; - float _S4158 = 2.0f * - _S4149.rows[int(0)].x; - float _S4159 = - _S4155 + _S4157; - float _S4160 = _S4152 + - _S4156; - float _S4161 = - _S4151 + _S4153; - float _S4162 = _S4151 + _S4153; - float _S4163 = _S4152 + _S4156; - float _S4164 = _S4155 + _S4157; - float _S4165 = _S3914.w * (_S4154 + _S4158); - float _S4166 = _S3914.z * (_S4150 + _S4158); - float _S4167 = _S3914.y * (_S4150 + _S4154); - float _S4168 = _S3914.x * _S4159 + _S3914.z * _S4162 + _S3914.y * _S4163 + _S4165 + _S4165; - float _S4169 = _S3914.x * _S4160 + _S3914.w * _S4162 + _S3914.y * _S4164 + _S4166 + _S4166; - float _S4170 = _S3914.x * _S4161 + _S3914.w * _S4163 + _S3914.z * _S4164 + _S4167 + _S4167; - float _S4171 = _S3914.w * _S4159 + _S3914.z * _S4160 + _S3914.y * _S4161; - float4 _S4172 = make_float4 (0.0f); - float4 _S4173 = _S4172; - *&((&_S4173)->w) = _S4168; - *&((&_S4173)->z) = _S4169; - *&((&_S4173)->y) = _S4170; - *&((&_S4173)->x) = _S4171; - DiffPair_vectorx3Cfloatx2C4x3E_0 _S4174; - (&_S4174)->primal_0 = quat_15; - (&_S4174)->differential_0 = _S4172; - s_bwd_normalize_impl_0(&_S4174, _S4173); - float3 _S4175 = _S3908; - *&((&_S4175)->z) = _S4139; - *&((&_S4175)->y) = _S4143; - *&((&_S4175)->x) = _S4147; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4176; - (&_S4176)->primal_0 = scale_15; - (&_S4176)->differential_0 = _S3908; - s_bwd_prop_exp_1(&_S4176, _S4175); - float _S4177 = - (_S4041 / _S3912); - DiffPair_float_0 _S4178; - (&_S4178)->primal_0 = _S3909; - (&_S4178)->differential_0 = 0.0f; - s_bwd_prop_exp_0(&_S4178, _S4177); - float _S4179 = - _S4178.differential_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4180; - (&_S4180)->primal_0 = mean_c_15; - (&_S4180)->differential_0 = _S3908; - s_bwd_length_impl_0(&_S4180, v_depth_7); - float3 _S4181 = _S4180.differential_0 + _S4038; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S4182; - (&_S4182)->primal_0 = R_15; - (&_S4182)->differential_0 = _S4121; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S4183; - (&_S4183)->primal_0 = mean_16; - (&_S4183)->differential_0 = _S3908; - s_bwd_prop_mul_3(&_S4182, &_S4183, _S4181); - Matrix _S4184 = _S4122.differential_0 + _S4124.differential_0 + _S4126.differential_0 + _S4128.differential_0 + _S4130.differential_0 + _S4132.differential_0 + _S4134.differential_0 + _S4182.differential_0; - float _S4185 = _S4179 + _S4021.differential_0; - float3 _S4186 = _S4176.differential_0 + _S4020.differential_0; - *v_mean_7 = *v_mean_7 + (_S4123.differential_0 + _S4129.differential_0 + _S4125.differential_0 + _S4131.differential_0 + _S4127.differential_0 + _S4133.differential_0 + _S4183.differential_0 + _S4019.differential_0); - *v_quat_7 = *v_quat_7 + _S4174.differential_0; - *v_scale_7 = *v_scale_7 + _S4186; - *v_in_opacity_7 = *v_in_opacity_7 + _S4185; - *v_R_7 = *v_R_7 + _S4184; - *v_t_7 = *v_t_7 + _S4181; + float _S7780 = invdet_40 * _S7775.rows[int(1)].y; + float _S7781 = - (invdet_40 * _S7775.rows[int(1)].x); + float _S7782 = - (invdet_40 * _S7775.rows[int(0)].y); + float _S7783 = invdet_40 * _S7775.rows[int(0)].x; + float _S7784 = - ((_S7740 * _S7775.rows[int(1)].y + _S7750 * _S7775.rows[int(1)].x + _S7749 * _S7775.rows[int(0)].y + _S7742 * _S7775.rows[int(0)].x) / _S7746); + DiffPair_float_0 _S7785; + (&_S7785)->primal_0 = _S7747; + (&_S7785)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7785, eps2d_34); + DiffPair_float_0 _S7786; + (&_S7786)->primal_0 = 0.0f; + (&_S7786)->differential_0 = 0.0f; + DiffPair_float_0 _S7787; + (&_S7787)->primal_0 = _S7745; + (&_S7787)->differential_0 = 0.0f; + _d_max_0(&_S7786, &_S7787, _S7785.differential_0); + float _S7788 = _S7787.differential_0 / _S7746; + float s_diff_det_orig_T_12 = det_blur_34 * _S7788; + float _S7789 = det_orig_34 * - _S7788 + _S7784; + float _S7790 = - _S7789; + float _S7791 = _S7740 * _S7789; + float _S7792 = _S7742 * _S7789; + Matrix _S7793 = _S7773; + _S7793[int(1)] = _S7776; + _S7793[int(0)] = _S7777; + float _S7794 = _S7792 + _S7793.rows[int(0)].x + _S7780; + float _S7795 = _S7790 + - s_diff_det_orig_T_12; + float _S7796 = covar2d_23.rows[int(0)].y * _S7795 + _S7781; + float _S7797 = covar2d_23.rows[int(1)].x * _S7795 + _S7782; + float _S7798 = covar2d_23.rows[int(1)].y * s_diff_det_orig_T_12; + float _S7799 = _S7791 + _S7793.rows[int(1)].y + _S7783 + covar2d_23.rows[int(0)].x * s_diff_det_orig_T_12; + float2 _S7800 = _S7649; + *&((&_S7800)->x) = _S7796; + *&((&_S7800)->y) = _S7799; + float _S7801 = _S7794 + _S7798; + float2 _S7802 = _S7649; + *&((&_S7802)->y) = _S7797; + *&((&_S7802)->x) = _S7801; + Matrix _S7803 = _S7773; + _S7803[int(1)] = _S7800; + _S7803[int(0)] = _S7802; + Matrix _S7804 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7805; + (&_S7805)->primal_0 = R_34; + (&_S7805)->differential_0 = _S7804; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7806; + (&_S7806)->primal_0 = _S7669; + (&_S7806)->differential_0 = _S7651; + s_bwd_prop_mul_3(&_S7805, &_S7806, _S7651); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7807; + (&_S7807)->primal_0 = R_34; + (&_S7807)->differential_0 = _S7804; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7808; + (&_S7808)->primal_0 = _S7666; + (&_S7808)->differential_0 = _S7651; + s_bwd_prop_mul_3(&_S7807, &_S7808, _S7651); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7809; + (&_S7809)->primal_0 = R_34; + (&_S7809)->differential_0 = _S7804; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7810; + (&_S7810)->primal_0 = _S7663; + (&_S7810)->differential_0 = _S7651; + s_bwd_prop_mul_3(&_S7809, &_S7810, _S7651); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7811; + (&_S7811)->primal_0 = R_34; + (&_S7811)->differential_0 = _S7804; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7812; + (&_S7812)->primal_0 = _S7668; + (&_S7812)->differential_0 = _S7651; + s_bwd_prop_mul_3(&_S7811, &_S7812, _S7651); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7813; + (&_S7813)->primal_0 = R_34; + (&_S7813)->differential_0 = _S7804; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7814; + (&_S7814)->primal_0 = _S7665; + (&_S7814)->differential_0 = _S7651; + s_bwd_prop_mul_3(&_S7813, &_S7814, _S7651); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7815; + (&_S7815)->primal_0 = R_34; + (&_S7815)->differential_0 = _S7804; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7816; + (&_S7816)->primal_0 = _S7662; + (&_S7816)->differential_0 = _S7651; + s_bwd_prop_mul_3(&_S7815, &_S7816, _S7651); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7817; + (&_S7817)->primal_0 = R_34; + (&_S7817)->differential_0 = _S7804; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7818; + (&_S7818)->primal_0 = _S7681.p_0[0U]; + (&_S7818)->differential_0 = _S7651; + s_bwd_prop_mul_3(&_S7817, &_S7818, _S7651); + float3 _S7819 = - _S7806.differential_0 + _S7812.differential_0; + float3 _S7820 = _S7709 * _S7819; + float3 _S7821 = _S7655.rows[2U] * _S7819; + float _S7822 = _S7660 * (_S7821.x + _S7821.y + _S7821.z); + float3 _S7823 = - _S7808.differential_0 + _S7814.differential_0; + float3 _S7824 = _S7708 * _S7823; + float3 _S7825 = _S7655.rows[1U] * _S7823; + float _S7826 = _S7660 * (_S7825.x + _S7825.y + _S7825.z); + float3 _S7827 = - _S7810.differential_0 + _S7816.differential_0; + float3 _S7828 = _S7707 * _S7827; + float3 _S7829 = _S7655.rows[0U] * _S7827; + float _S7830 = _S7660 * (_S7829.x + _S7829.y + _S7829.z); + Matrix _S7831 = _S7804; + _S7831[2U] = _S7820; + _S7831[1U] = _S7824; + _S7831[0U] = _S7828; + Matrix _S7832 = transpose_3(transpose_3(_S7831)); + float _S7833 = 2.0f * - _S7832.rows[int(2)].z; + float _S7834 = 2.0f * _S7832.rows[int(2)].y; + float _S7835 = 2.0f * _S7832.rows[int(2)].x; + float _S7836 = 2.0f * _S7832.rows[int(1)].z; + float _S7837 = 2.0f * - _S7832.rows[int(1)].y; + float _S7838 = 2.0f * _S7832.rows[int(1)].x; + float _S7839 = 2.0f * _S7832.rows[int(0)].z; + float _S7840 = 2.0f * _S7832.rows[int(0)].y; + float _S7841 = 2.0f * - _S7832.rows[int(0)].x; + float _S7842 = - _S7838 + _S7840; + float _S7843 = _S7835 + - _S7839; + float _S7844 = - _S7834 + _S7836; + float _S7845 = _S7834 + _S7836; + float _S7846 = _S7835 + _S7839; + float _S7847 = _S7838 + _S7840; + float _S7848 = _S7653.w * (_S7837 + _S7841); + float _S7849 = _S7653.z * (_S7833 + _S7841); + float _S7850 = _S7653.y * (_S7833 + _S7837); + float _S7851 = _S7653.x * _S7842 + _S7653.z * _S7845 + _S7653.y * _S7846 + _S7848 + _S7848; + float _S7852 = _S7653.x * _S7843 + _S7653.w * _S7845 + _S7653.y * _S7847 + _S7849 + _S7849; + float _S7853 = _S7653.x * _S7844 + _S7653.w * _S7846 + _S7653.z * _S7847 + _S7850 + _S7850; + float _S7854 = _S7653.w * _S7842 + _S7653.z * _S7843 + _S7653.y * _S7844; + float4 _S7855 = make_float4 (0.0f); + float4 _S7856 = _S7855; + *&((&_S7856)->w) = _S7851; + *&((&_S7856)->z) = _S7852; + *&((&_S7856)->y) = _S7853; + *&((&_S7856)->x) = _S7854; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S7857; + (&_S7857)->primal_0 = quat_34; + (&_S7857)->differential_0 = _S7855; + s_bwd_normalize_impl_0(&_S7857, _S7856); + float3 _S7858 = _S7651; + *&((&_S7858)->z) = _S7822; + *&((&_S7858)->y) = _S7826; + *&((&_S7858)->x) = _S7830; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7859; + (&_S7859)->primal_0 = scale_34; + (&_S7859)->differential_0 = _S7651; + s_bwd_prop_exp_1(&_S7859, _S7858); + float _S7860 = - (_S7778 / _S7706); + DiffPair_float_0 _S7861; + (&_S7861)->primal_0 = _S7703; + (&_S7861)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S7861, _S7860); + float _S7862 = - _S7861.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7863; + (&_S7863)->primal_0 = mean_c_34; + (&_S7863)->differential_0 = _S7651; + s_bwd_length_impl_0(&_S7863, v_depth_12); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S7864; + (&_S7864)->primal_0 = R_34; + (&_S7864)->differential_0 = _S7804; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7865; + (&_S7865)->primal_0 = mean_35; + (&_S7865)->differential_0 = _S7651; + s_bwd_prop_mul_3(&_S7864, &_S7865, _S7863.differential_0); + Matrix _S7866 = _S7805.differential_0 + _S7807.differential_0 + _S7809.differential_0 + _S7811.differential_0 + _S7813.differential_0 + _S7815.differential_0 + _S7817.differential_0 + _S7864.differential_0; + float _S7867 = _S7862 + _S7762.differential_0; + float3 _S7868 = _S7859.differential_0 + _S7761.differential_0; + *v_mean_12 = *v_mean_12 + (_S7806.differential_0 + _S7812.differential_0 + _S7808.differential_0 + _S7814.differential_0 + _S7810.differential_0 + _S7816.differential_0 + _S7865.differential_0 + _S7760.differential_0); + *v_quat_12 = *v_quat_12 + _S7857.differential_0; + *v_scale_12 = *v_scale_12 + _S7868; + *v_in_opacity_12 = *v_in_opacity_12 + _S7867; + *v_R_12 = *v_R_12 + _S7866; + *v_t_12 = *v_t_12 + _S7863.differential_0; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgut_persp_prism_projection_Intermediates_0 +{ + float2 _S7869; + float2 _S7870; + float2 _S7871; + float2 _S7872; + float2 _S7873; + float2 _S7874; + float2 _S7875; +}; + +inline __device__ float2 s_primal_ctx_DistThinPrism_distort_0(float2 dpuv_10, FixedArray * coeffs_22) +{ + float u_16 = dpuv_10.x; + float v_16 = dpuv_10.y; + float r2_16 = u_16 * u_16 + v_16 * v_16; + return dpuv_10 * make_float2 (1.0f + r2_16 * ((*coeffs_22)[int(0)] + r2_16 * ((*coeffs_22)[int(1)] + r2_16 * ((*coeffs_22)[int(2)] + r2_16 * (*coeffs_22)[int(3)])))) + make_float2 (2.0f * (*coeffs_22)[int(4)] * u_16 * v_16 + (*coeffs_22)[int(5)] * (r2_16 + 2.0f * u_16 * u_16) + (*coeffs_22)[int(6)] * r2_16, 2.0f * (*coeffs_22)[int(5)] * u_16 * v_16 + (*coeffs_22)[int(4)] * (r2_16 + 2.0f * v_16 * v_16) + (*coeffs_22)[int(7)] * r2_16); +} + +inline __device__ void projection_3dgut_persp_prism_vjp(bool antialiased_35, float3 mean_36, float4 quat_35, float3 scale_35, float in_opacity_35, Matrix R_35, float3 t_35, float fx_48, float fy_48, float cx_39, float cy_39, FixedArray dist_coeffs_47, uint image_width_35, uint image_height_35, float2 v_mean2d_13, float v_depth_13, float3 v_conic_13, float v_opacity_13, float3 * v_mean_13, float4 * v_quat_13, float3 * v_scale_13, float * v_in_opacity_13, Matrix * v_R_13, float3 * v_t_13) +{ + float2 _S7876 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_persp_prism_projection_Intermediates_0 _S7877; + (&_S7877)->_S7869 = _S7876; + (&_S7877)->_S7870 = _S7876; + (&_S7877)->_S7871 = _S7876; + (&_S7877)->_S7872 = _S7876; + (&_S7877)->_S7873 = _S7876; + (&_S7877)->_S7874 = _S7876; + (&_S7877)->_S7875 = _S7876; + float3 _S7878 = make_float3 (0.0f); + float3 _S7879 = s_primal_ctx_exp_1(scale_35); + float4 _S7880 = normalize_0(quat_35); + float _S7881 = _S7880.y; + float x2_35 = _S7881 * _S7881; + float y2_35 = _S7880.z * _S7880.z; + float z2_35 = _S7880.w * _S7880.w; + float xy_35 = _S7880.y * _S7880.z; + float xz_35 = _S7880.y * _S7880.w; + float yz_35 = _S7880.z * _S7880.w; + float wx_35 = _S7880.x * _S7880.y; + float wy_35 = _S7880.x * _S7880.z; + float wz_35 = _S7880.x * _S7880.w; + Matrix _S7882 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_35 + z2_35), 2.0f * (xy_35 + wz_35), 2.0f * (xz_35 - wy_35), 2.0f * (xy_35 - wz_35), 1.0f - 2.0f * (x2_35 + z2_35), 2.0f * (yz_35 + wx_35), 2.0f * (xz_35 + wy_35), 2.0f * (yz_35 - wx_35), 1.0f - 2.0f * (x2_35 + y2_35)))); + FixedArray _S7883 = { + _S7878, _S7878, _S7878, _S7878, _S7878, _S7878, _S7878 + }; + FixedArray _S7884 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + SigmaPoints_0 _S7885; + (&_S7885)->p_0 = _S7883; + (&_S7885)->w_mean_0 = _S7884; + (&_S7885)->w_cov_0 = _S7884; + (&_S7885)->p_0[int(0)] = mean_36; + SigmaPoints_0 _S7886 = _S7885; + (&_S7886)->w_mean_0[int(0)] = 0.0f; + (&_S7886)->w_cov_0[int(0)] = 2.0f; + float _S7887 = s_primal_ctx_sqrt_0(3.0f); + float _S7888 = _S7887 * _S7879.x; + float3 delta_39 = make_float3 (_S7888) * _S7882.rows[0U]; + float3 _S7889 = mean_36 + delta_39; + (&_S7886)->p_0[1U] = _S7889; + float3 _S7890 = mean_36 - delta_39; + (&_S7886)->p_0[4U] = _S7890; + float _S7891 = _S7887 * _S7879.y; + float3 delta_40 = make_float3 (_S7891) * _S7882.rows[1U]; + float3 _S7892 = mean_36 + delta_40; + (&_S7886)->p_0[2U] = _S7892; + float3 _S7893 = mean_36 - delta_40; + (&_S7886)->p_0[5U] = _S7893; + float _S7894 = _S7887 * _S7879.z; + float3 delta_41 = make_float3 (_S7894) * _S7882.rows[2U]; + float3 _S7895 = mean_36 + delta_41; + (&_S7886)->p_0[3U] = _S7895; + float3 _S7896 = mean_36 - delta_41; + (&_S7886)->p_0[6U] = _S7896; + (&_S7886)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S7897 = _S7886; + (&_S7897)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S7898 = _S7897; + (&_S7898)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S7899 = _S7898; + (&_S7899)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S7900 = _S7899; + (&_S7900)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S7901 = _S7900; + (&_S7901)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S7902 = _S7901; + (&_S7902)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S7903 = _S7902; + (&_S7903)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S7904 = _S7903; + (&_S7904)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S7905 = _S7904; + (&_S7905)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S7906 = _S7905; + (&_S7906)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S7907 = _S7906; + (&_S7907)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S7908 = _S7885; + float3 _S7909 = s_primal_ctx_mul_0(R_35, _S7885.p_0[0U]) + t_35; + _S7885 = _S7907; + (&_S7885)->p_0[0U] = _S7909; + SigmaPoints_0 _S7910 = _S7885; + (&_S7885)->p_0[1U] = s_primal_ctx_mul_0(R_35, _S7889) + t_35; + SigmaPoints_0 _S7911 = _S7885; + (&_S7885)->p_0[2U] = s_primal_ctx_mul_0(R_35, _S7892) + t_35; + SigmaPoints_0 _S7912 = _S7885; + (&_S7885)->p_0[3U] = s_primal_ctx_mul_0(R_35, _S7895) + t_35; + SigmaPoints_0 _S7913 = _S7885; + (&_S7885)->p_0[4U] = s_primal_ctx_mul_0(R_35, _S7890) + t_35; + SigmaPoints_0 _S7914 = _S7885; + (&_S7885)->p_0[5U] = s_primal_ctx_mul_0(R_35, _S7893) + t_35; + SigmaPoints_0 _S7915 = _S7885; + (&_S7885)->p_0[6U] = s_primal_ctx_mul_0(R_35, _S7896) + t_35; + float2 uv_54 = float2 {_S7910.p_0[int(0)].x, _S7910.p_0[int(0)].y} / make_float2 (_S7910.p_0[int(0)].z); + FixedArray _S7916 = dist_coeffs_47; + float2 _S7917 = s_primal_ctx_DistThinPrism_distort_0(uv_54, &_S7916); + (&_S7877)->_S7869 = make_float2 (fx_48 * _S7917.x + cx_39, fy_48 * _S7917.y + cy_39); + float2 uv_55 = float2 {_S7911.p_0[int(1)].x, _S7911.p_0[int(1)].y} / make_float2 (_S7911.p_0[int(1)].z); + FixedArray _S7918 = dist_coeffs_47; + float2 _S7919 = s_primal_ctx_DistThinPrism_distort_0(uv_55, &_S7918); + (&_S7877)->_S7870 = make_float2 (fx_48 * _S7919.x + cx_39, fy_48 * _S7919.y + cy_39); + float2 uv_56 = float2 {_S7912.p_0[int(2)].x, _S7912.p_0[int(2)].y} / make_float2 (_S7912.p_0[int(2)].z); + FixedArray _S7920 = dist_coeffs_47; + float2 _S7921 = s_primal_ctx_DistThinPrism_distort_0(uv_56, &_S7920); + (&_S7877)->_S7871 = make_float2 (fx_48 * _S7921.x + cx_39, fy_48 * _S7921.y + cy_39); + float2 uv_57 = float2 {_S7913.p_0[int(3)].x, _S7913.p_0[int(3)].y} / make_float2 (_S7913.p_0[int(3)].z); + FixedArray _S7922 = dist_coeffs_47; + float2 _S7923 = s_primal_ctx_DistThinPrism_distort_0(uv_57, &_S7922); + (&_S7877)->_S7872 = make_float2 (fx_48 * _S7923.x + cx_39, fy_48 * _S7923.y + cy_39); + float2 uv_58 = float2 {_S7914.p_0[int(4)].x, _S7914.p_0[int(4)].y} / make_float2 (_S7914.p_0[int(4)].z); + FixedArray _S7924 = dist_coeffs_47; + float2 _S7925 = s_primal_ctx_DistThinPrism_distort_0(uv_58, &_S7924); + (&_S7877)->_S7873 = make_float2 (fx_48 * _S7925.x + cx_39, fy_48 * _S7925.y + cy_39); + float2 uv_59 = float2 {_S7915.p_0[int(5)].x, _S7915.p_0[int(5)].y} / make_float2 (_S7915.p_0[int(5)].z); + FixedArray _S7926 = dist_coeffs_47; + float2 _S7927 = s_primal_ctx_DistThinPrism_distort_0(uv_59, &_S7926); + (&_S7877)->_S7874 = make_float2 (fx_48 * _S7927.x + cx_39, fy_48 * _S7927.y + cy_39); + float2 uv_60 = float2 {_S7885.p_0[int(6)].x, _S7885.p_0[int(6)].y} / make_float2 (_S7885.p_0[int(6)].z); + FixedArray _S7928 = dist_coeffs_47; + float2 _S7929 = s_primal_ctx_DistThinPrism_distort_0(uv_60, &_S7928); + (&_S7877)->_S7875 = make_float2 (fx_48 * _S7929.x + cx_39, fy_48 * _S7929.y + cy_39); + float3 mean_c_35 = s_primal_ctx_mul_0(R_35, mean_36) + t_35; + float _S7930 = - in_opacity_35; + float _S7931 = 1.0f + s_primal_ctx_exp_0(_S7930); + float _S7932 = 1.0f / _S7931; + float _S7933 = _S7931 * _S7931; + float3 _S7934 = make_float3 (_S7888); + float3 _S7935 = make_float3 (_S7891); + float3 _S7936 = make_float3 (_S7894); + float _S7937 = float(image_width_35); + float _S7938 = float(image_height_35); + float _S7939 = 0.30000001192092896f * (0.5f * _S7937 / fx_48) * fx_48; + float lim_x_pos_18 = _S7937 + _S7939; + float _S7940 = 0.30000001192092896f * (0.5f * _S7938 / fy_48) * fy_48; + float lim_y_pos_6 = _S7938 + _S7940; + float2 _S7941 = make_float2 (_S7886.w_mean_0[int(1)]) * _S7877._S7870 + make_float2 (_S7898.w_mean_0[int(2)]) * _S7877._S7871 + make_float2 (_S7900.w_mean_0[int(3)]) * _S7877._S7872 + make_float2 (_S7902.w_mean_0[int(4)]) * _S7877._S7873 + make_float2 (_S7904.w_mean_0[int(5)]) * _S7877._S7874 + make_float2 (_S7906.w_mean_0[int(6)]) * _S7877._S7875; + float _S7942 = - _S7939; + float _S7943 = - _S7940; + float2 _S7944 = make_float2 (s_primal_ctx_clamp_0(_S7941.x, _S7942, lim_x_pos_18), s_primal_ctx_clamp_0(_S7941.y, _S7943, lim_y_pos_6)); + float2 d_91 = make_float2 (s_primal_ctx_clamp_0(_S7877._S7869.x, _S7942, lim_x_pos_18), s_primal_ctx_clamp_0(_S7877._S7869.y, _S7943, lim_y_pos_6)) - _S7944; + float _S7945 = d_91.x; + float _S7946 = d_91.y; + float _S7947 = _S7945 * _S7946; + float2 d_92 = make_float2 (s_primal_ctx_clamp_0(_S7877._S7870.x, _S7942, lim_x_pos_18), s_primal_ctx_clamp_0(_S7877._S7870.y, _S7943, lim_y_pos_6)) - _S7944; + float _S7948 = d_92.x; + float _S7949 = d_92.y; + float _S7950 = _S7948 * _S7949; + float2 d_93 = make_float2 (s_primal_ctx_clamp_0(_S7877._S7871.x, _S7942, lim_x_pos_18), s_primal_ctx_clamp_0(_S7877._S7871.y, _S7943, lim_y_pos_6)) - _S7944; + float _S7951 = d_93.x; + float _S7952 = d_93.y; + float _S7953 = _S7951 * _S7952; + float2 d_94 = make_float2 (s_primal_ctx_clamp_0(_S7877._S7872.x, _S7942, lim_x_pos_18), s_primal_ctx_clamp_0(_S7877._S7872.y, _S7943, lim_y_pos_6)) - _S7944; + float _S7954 = d_94.x; + float _S7955 = d_94.y; + float _S7956 = _S7954 * _S7955; + float2 d_95 = make_float2 (s_primal_ctx_clamp_0(_S7877._S7873.x, _S7942, lim_x_pos_18), s_primal_ctx_clamp_0(_S7877._S7873.y, _S7943, lim_y_pos_6)) - _S7944; + float _S7957 = d_95.x; + float _S7958 = d_95.y; + float _S7959 = _S7957 * _S7958; + float2 d_96 = make_float2 (s_primal_ctx_clamp_0(_S7877._S7874.x, _S7942, lim_x_pos_18), s_primal_ctx_clamp_0(_S7877._S7874.y, _S7943, lim_y_pos_6)) - _S7944; + float _S7960 = d_96.x; + float _S7961 = d_96.y; + float _S7962 = _S7960 * _S7961; + float2 d_97 = make_float2 (s_primal_ctx_clamp_0(_S7877._S7875.x, _S7942, lim_x_pos_18), s_primal_ctx_clamp_0(_S7877._S7875.y, _S7943, lim_y_pos_6)) - _S7944; + float _S7963 = d_97.x; + float _S7964 = d_97.y; + float _S7965 = _S7963 * _S7964; + Matrix covar2d_24 = makeMatrix (2.0f) * makeMatrix (_S7945 * _S7945, _S7947, _S7947, _S7946 * _S7946) + makeMatrix (_S7897.w_cov_0[int(1)]) * makeMatrix (_S7948 * _S7948, _S7950, _S7950, _S7949 * _S7949) + makeMatrix (_S7899.w_cov_0[int(2)]) * makeMatrix (_S7951 * _S7951, _S7953, _S7953, _S7952 * _S7952) + makeMatrix (_S7901.w_cov_0[int(3)]) * makeMatrix (_S7954 * _S7954, _S7956, _S7956, _S7955 * _S7955) + makeMatrix (_S7903.w_cov_0[int(4)]) * makeMatrix (_S7957 * _S7957, _S7959, _S7959, _S7958 * _S7958) + makeMatrix (_S7905.w_cov_0[int(5)]) * makeMatrix (_S7960 * _S7960, _S7962, _S7962, _S7961 * _S7961) + makeMatrix (_S7907.w_cov_0[int(6)]) * makeMatrix (_S7963 * _S7963, _S7965, _S7965, _S7964 * _S7964); + float eps2d_35; + if(antialiased_35) + { + eps2d_35 = 0.10000000149011612f; + } + else + { + eps2d_35 = 0.30000001192092896f; + } + float _S7966 = covar2d_24.rows[int(0)].y * covar2d_24.rows[int(1)].x; + float det_orig_35 = covar2d_24.rows[int(0)].x * covar2d_24.rows[int(1)].y - _S7966; + float _S7967 = covar2d_24.rows[int(0)].x + eps2d_35; + Matrix _S7968 = covar2d_24; + *&(((&_S7968)->rows + (int(0)))->x) = _S7967; + float _S7969 = covar2d_24.rows[int(1)].y + eps2d_35; + *&(((&_S7968)->rows + (int(1)))->y) = _S7969; + Matrix _S7970 = _S7968; + Matrix _S7971 = _S7968; + float det_blur_35 = _S7967 * _S7969 - _S7966; + float _S7972 = det_orig_35 / det_blur_35; + float _S7973 = det_blur_35 * det_blur_35; + float _S7974 = (F32_max((0.0f), (_S7972))); + float _S7975 = s_primal_ctx_sqrt_0(_S7974); + float invdet_41 = 1.0f / det_blur_35; + float _S7976 = - covar2d_24.rows[int(0)].y; + float _S7977 = - covar2d_24.rows[int(1)].x; + if(antialiased_35) + { + eps2d_35 = _S7932 * _S7975; + } + else + { + eps2d_35 = _S7932; + } + float _S7978 = eps2d_35 / 0.00392156885936856f; + float _S7979 = 2.0f * s_primal_ctx_log_0(_S7978); + float _S7980 = s_primal_ctx_sqrt_0(_S7979); + float _S7981 = _S7970.rows[int(0)].x; + float _S7982 = _S7971.rows[int(1)].y; + float3 campos_14 = - s_primal_ctx_mul_0(transpose_3(R_35), t_35); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7983; + (&_S7983)->primal_0 = mean_36; + (&_S7983)->differential_0 = _S7878; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7984; + (&_S7984)->primal_0 = scale_35; + (&_S7984)->differential_0 = _S7878; + DiffPair_float_0 _S7985; + (&_S7985)->primal_0 = in_opacity_35; + (&_S7985)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7986; + (&_S7986)->primal_0 = campos_14; + (&_S7986)->differential_0 = _S7878; + s_bwd_prop_view_radius_3dgs_0(&_S7983, &_S7984, &_S7985, &_S7986, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7987 = _S7983; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S7988 = _S7984; + DiffPair_float_0 _S7989 = _S7985; + float2 _S7990 = _S7876; + *&((&_S7990)->y) = v_conic_13.z; + float2 _S7991 = _S7876; + *&((&_S7991)->y) = v_conic_13.y; + *&((&_S7991)->x) = v_conic_13.x; + DiffPair_float_0 _S7992; + (&_S7992)->primal_0 = _S7982; + (&_S7992)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7992, 0.0f); + DiffPair_float_0 _S7993; + (&_S7993)->primal_0 = _S7981; + (&_S7993)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7993, 0.0f); + DiffPair_float_0 _S7994; + (&_S7994)->primal_0 = 3.32999992370605469f; + (&_S7994)->differential_0 = 0.0f; + DiffPair_float_0 _S7995; + (&_S7995)->primal_0 = _S7980; + (&_S7995)->differential_0 = 0.0f; + _d_min_0(&_S7994, &_S7995, 0.0f); + DiffPair_float_0 _S7996; + (&_S7996)->primal_0 = _S7979; + (&_S7996)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S7996, _S7995.differential_0); + float _S7997 = 2.0f * _S7996.differential_0; + DiffPair_float_0 _S7998; + (&_S7998)->primal_0 = _S7978; + (&_S7998)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S7998, _S7997); + float _S7999 = v_opacity_13 + 254.9999847412109375f * _S7998.differential_0; + Matrix _S8000 = makeMatrix (0.0f); + Matrix _S8001 = _S8000; + _S8001[int(1)] = _S7990; + _S8001[int(0)] = _S7991; + Matrix _S8002 = _S8001; + float2 _S8003 = make_float2 (0.0f, _S7992.differential_0); + float2 _S8004 = make_float2 (_S7993.differential_0, 0.0f); + float _S8005; + if(antialiased_35) + { + float _S8006 = _S7975 * _S7999; + eps2d_35 = _S7932 * _S7999; + _S8005 = _S8006; + } + else + { + eps2d_35 = 0.0f; + _S8005 = _S7999; + } + float _S8007 = invdet_41 * _S8002.rows[int(1)].y; + float _S8008 = - (invdet_41 * _S8002.rows[int(1)].x); + float _S8009 = - (invdet_41 * _S8002.rows[int(0)].y); + float _S8010 = invdet_41 * _S8002.rows[int(0)].x; + float _S8011 = - ((_S7967 * _S8002.rows[int(1)].y + _S7977 * _S8002.rows[int(1)].x + _S7976 * _S8002.rows[int(0)].y + _S7969 * _S8002.rows[int(0)].x) / _S7973); + DiffPair_float_0 _S8012; + (&_S8012)->primal_0 = _S7974; + (&_S8012)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8012, eps2d_35); + DiffPair_float_0 _S8013; + (&_S8013)->primal_0 = 0.0f; + (&_S8013)->differential_0 = 0.0f; + DiffPair_float_0 _S8014; + (&_S8014)->primal_0 = _S7972; + (&_S8014)->differential_0 = 0.0f; + _d_max_0(&_S8013, &_S8014, _S8012.differential_0); + float _S8015 = _S8014.differential_0 / _S7973; + float s_diff_det_orig_T_13 = det_blur_35 * _S8015; + float _S8016 = det_orig_35 * - _S8015 + _S8011; + float _S8017 = - _S8016; + float _S8018 = _S7967 * _S8016; + float _S8019 = _S7969 * _S8016; + Matrix _S8020 = _S8000; + _S8020[int(1)] = _S8003; + _S8020[int(0)] = _S8004; + float _S8021 = _S8019 + _S8020.rows[int(0)].x + _S8007; + float _S8022 = _S8017 + - s_diff_det_orig_T_13; + float _S8023 = covar2d_24.rows[int(0)].y * _S8022 + _S8008; + float _S8024 = covar2d_24.rows[int(1)].x * _S8022 + _S8009; + float _S8025 = covar2d_24.rows[int(1)].y * s_diff_det_orig_T_13; + float _S8026 = _S8018 + _S8020.rows[int(1)].y + _S8010 + covar2d_24.rows[int(0)].x * s_diff_det_orig_T_13; + float2 _S8027 = _S7876; + *&((&_S8027)->x) = _S8023; + *&((&_S8027)->y) = _S8026; + float _S8028 = _S8021 + _S8025; + float2 _S8029 = _S7876; + *&((&_S8029)->y) = _S8024; + *&((&_S8029)->x) = _S8028; + Matrix _S8030 = _S8000; + _S8030[int(1)] = _S8027; + _S8030[int(0)] = _S8029; + Matrix _S8031 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8032; + (&_S8032)->primal_0 = R_35; + (&_S8032)->differential_0 = _S8031; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8033; + (&_S8033)->primal_0 = _S7896; + (&_S8033)->differential_0 = _S7878; + s_bwd_prop_mul_3(&_S8032, &_S8033, _S7878); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8034; + (&_S8034)->primal_0 = R_35; + (&_S8034)->differential_0 = _S8031; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8035; + (&_S8035)->primal_0 = _S7893; + (&_S8035)->differential_0 = _S7878; + s_bwd_prop_mul_3(&_S8034, &_S8035, _S7878); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8036; + (&_S8036)->primal_0 = R_35; + (&_S8036)->differential_0 = _S8031; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8037; + (&_S8037)->primal_0 = _S7890; + (&_S8037)->differential_0 = _S7878; + s_bwd_prop_mul_3(&_S8036, &_S8037, _S7878); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8038; + (&_S8038)->primal_0 = R_35; + (&_S8038)->differential_0 = _S8031; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8039; + (&_S8039)->primal_0 = _S7895; + (&_S8039)->differential_0 = _S7878; + s_bwd_prop_mul_3(&_S8038, &_S8039, _S7878); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8040; + (&_S8040)->primal_0 = R_35; + (&_S8040)->differential_0 = _S8031; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8041; + (&_S8041)->primal_0 = _S7892; + (&_S8041)->differential_0 = _S7878; + s_bwd_prop_mul_3(&_S8040, &_S8041, _S7878); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8042; + (&_S8042)->primal_0 = R_35; + (&_S8042)->differential_0 = _S8031; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8043; + (&_S8043)->primal_0 = _S7889; + (&_S8043)->differential_0 = _S7878; + s_bwd_prop_mul_3(&_S8042, &_S8043, _S7878); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8044; + (&_S8044)->primal_0 = R_35; + (&_S8044)->differential_0 = _S8031; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8045; + (&_S8045)->primal_0 = _S7908.p_0[0U]; + (&_S8045)->differential_0 = _S7878; + s_bwd_prop_mul_3(&_S8044, &_S8045, _S7878); + float3 _S8046 = - _S8033.differential_0 + _S8039.differential_0; + float3 _S8047 = _S7936 * _S8046; + float3 _S8048 = _S7882.rows[2U] * _S8046; + float _S8049 = _S7887 * (_S8048.x + _S8048.y + _S8048.z); + float3 _S8050 = - _S8035.differential_0 + _S8041.differential_0; + float3 _S8051 = _S7935 * _S8050; + float3 _S8052 = _S7882.rows[1U] * _S8050; + float _S8053 = _S7887 * (_S8052.x + _S8052.y + _S8052.z); + float3 _S8054 = - _S8037.differential_0 + _S8043.differential_0; + float3 _S8055 = _S7934 * _S8054; + float3 _S8056 = _S7882.rows[0U] * _S8054; + float _S8057 = _S7887 * (_S8056.x + _S8056.y + _S8056.z); + Matrix _S8058 = _S8031; + _S8058[2U] = _S8047; + _S8058[1U] = _S8051; + _S8058[0U] = _S8055; + Matrix _S8059 = transpose_3(transpose_3(_S8058)); + float _S8060 = 2.0f * - _S8059.rows[int(2)].z; + float _S8061 = 2.0f * _S8059.rows[int(2)].y; + float _S8062 = 2.0f * _S8059.rows[int(2)].x; + float _S8063 = 2.0f * _S8059.rows[int(1)].z; + float _S8064 = 2.0f * - _S8059.rows[int(1)].y; + float _S8065 = 2.0f * _S8059.rows[int(1)].x; + float _S8066 = 2.0f * _S8059.rows[int(0)].z; + float _S8067 = 2.0f * _S8059.rows[int(0)].y; + float _S8068 = 2.0f * - _S8059.rows[int(0)].x; + float _S8069 = - _S8065 + _S8067; + float _S8070 = _S8062 + - _S8066; + float _S8071 = - _S8061 + _S8063; + float _S8072 = _S8061 + _S8063; + float _S8073 = _S8062 + _S8066; + float _S8074 = _S8065 + _S8067; + float _S8075 = _S7880.w * (_S8064 + _S8068); + float _S8076 = _S7880.z * (_S8060 + _S8068); + float _S8077 = _S7880.y * (_S8060 + _S8064); + float _S8078 = _S7880.x * _S8069 + _S7880.z * _S8072 + _S7880.y * _S8073 + _S8075 + _S8075; + float _S8079 = _S7880.x * _S8070 + _S7880.w * _S8072 + _S7880.y * _S8074 + _S8076 + _S8076; + float _S8080 = _S7880.x * _S8071 + _S7880.w * _S8073 + _S7880.z * _S8074 + _S8077 + _S8077; + float _S8081 = _S7880.w * _S8069 + _S7880.z * _S8070 + _S7880.y * _S8071; + float4 _S8082 = make_float4 (0.0f); + float4 _S8083 = _S8082; + *&((&_S8083)->w) = _S8078; + *&((&_S8083)->z) = _S8079; + *&((&_S8083)->y) = _S8080; + *&((&_S8083)->x) = _S8081; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S8084; + (&_S8084)->primal_0 = quat_35; + (&_S8084)->differential_0 = _S8082; + s_bwd_normalize_impl_0(&_S8084, _S8083); + float3 _S8085 = _S7878; + *&((&_S8085)->z) = _S8049; + *&((&_S8085)->y) = _S8053; + *&((&_S8085)->x) = _S8057; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8086; + (&_S8086)->primal_0 = scale_35; + (&_S8086)->differential_0 = _S7878; + s_bwd_prop_exp_1(&_S8086, _S8085); + float _S8087 = - (_S8005 / _S7933); + DiffPair_float_0 _S8088; + (&_S8088)->primal_0 = _S7930; + (&_S8088)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S8088, _S8087); + float _S8089 = - _S8088.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8090; + (&_S8090)->primal_0 = mean_c_35; + (&_S8090)->differential_0 = _S7878; + s_bwd_length_impl_0(&_S8090, v_depth_13); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8091; + (&_S8091)->primal_0 = R_35; + (&_S8091)->differential_0 = _S8031; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8092; + (&_S8092)->primal_0 = mean_36; + (&_S8092)->differential_0 = _S7878; + s_bwd_prop_mul_3(&_S8091, &_S8092, _S8090.differential_0); + Matrix _S8093 = _S8032.differential_0 + _S8034.differential_0 + _S8036.differential_0 + _S8038.differential_0 + _S8040.differential_0 + _S8042.differential_0 + _S8044.differential_0 + _S8091.differential_0; + float _S8094 = _S8089 + _S7989.differential_0; + float3 _S8095 = _S8086.differential_0 + _S7988.differential_0; + *v_mean_13 = *v_mean_13 + (_S8033.differential_0 + _S8039.differential_0 + _S8035.differential_0 + _S8041.differential_0 + _S8037.differential_0 + _S8043.differential_0 + _S8092.differential_0 + _S7987.differential_0); + *v_quat_13 = *v_quat_13 + _S8084.differential_0; + *v_scale_13 = *v_scale_13 + _S8095; + *v_in_opacity_13 = *v_in_opacity_13 + _S8094; + *v_R_13 = *v_R_13 + _S8093; + *v_t_13 = *v_t_13 + _S8090.differential_0; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgut_persp_rational_projection_Intermediates_0 +{ + float2 _S8096; + float2 _S8097; + float2 _S8098; + float2 _S8099; + float2 _S8100; + float2 _S8101; + float2 _S8102; +}; + +inline __device__ float2 s_primal_ctx_DistRational_distort_0(float2 dpuv_11, FixedArray * coeffs_23) +{ + float u_17 = dpuv_11.x; + float v_17 = dpuv_11.y; + float r2_17 = u_17 * u_17 + v_17 * v_17; + return dpuv_11 * make_float2 ((1.0f + r2_17 * ((*coeffs_23)[int(0)] + r2_17 * ((*coeffs_23)[int(1)] + r2_17 * (*coeffs_23)[int(2)]))) / (1.0f + r2_17 * ((*coeffs_23)[int(3)] + r2_17 * ((*coeffs_23)[int(4)] + r2_17 * (*coeffs_23)[int(5)])))) + make_float2 (2.0f * (*coeffs_23)[int(6)] * u_17 * v_17 + (*coeffs_23)[int(7)] * (r2_17 + 2.0f * u_17 * u_17), 2.0f * (*coeffs_23)[int(7)] * u_17 * v_17 + (*coeffs_23)[int(6)] * (r2_17 + 2.0f * v_17 * v_17)); +} + +inline __device__ void projection_3dgut_persp_rational_vjp(bool antialiased_36, float3 mean_37, float4 quat_36, float3 scale_36, float in_opacity_36, Matrix R_36, float3 t_36, float fx_49, float fy_49, float cx_40, float cy_40, FixedArray dist_coeffs_48, uint image_width_36, uint image_height_36, float2 v_mean2d_14, float v_depth_14, float3 v_conic_14, float v_opacity_14, float3 * v_mean_14, float4 * v_quat_14, float3 * v_scale_14, float * v_in_opacity_14, Matrix * v_R_14, float3 * v_t_14) +{ + float2 _S8103 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_persp_rational_projection_Intermediates_0 _S8104; + (&_S8104)->_S8096 = _S8103; + (&_S8104)->_S8097 = _S8103; + (&_S8104)->_S8098 = _S8103; + (&_S8104)->_S8099 = _S8103; + (&_S8104)->_S8100 = _S8103; + (&_S8104)->_S8101 = _S8103; + (&_S8104)->_S8102 = _S8103; + float3 _S8105 = make_float3 (0.0f); + float3 _S8106 = s_primal_ctx_exp_1(scale_36); + float4 _S8107 = normalize_0(quat_36); + float _S8108 = _S8107.y; + float x2_36 = _S8108 * _S8108; + float y2_36 = _S8107.z * _S8107.z; + float z2_36 = _S8107.w * _S8107.w; + float xy_36 = _S8107.y * _S8107.z; + float xz_36 = _S8107.y * _S8107.w; + float yz_36 = _S8107.z * _S8107.w; + float wx_36 = _S8107.x * _S8107.y; + float wy_36 = _S8107.x * _S8107.z; + float wz_36 = _S8107.x * _S8107.w; + Matrix _S8109 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_36 + z2_36), 2.0f * (xy_36 + wz_36), 2.0f * (xz_36 - wy_36), 2.0f * (xy_36 - wz_36), 1.0f - 2.0f * (x2_36 + z2_36), 2.0f * (yz_36 + wx_36), 2.0f * (xz_36 + wy_36), 2.0f * (yz_36 - wx_36), 1.0f - 2.0f * (x2_36 + y2_36)))); + FixedArray _S8110 = { + _S8105, _S8105, _S8105, _S8105, _S8105, _S8105, _S8105 + }; + FixedArray _S8111 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + SigmaPoints_0 _S8112; + (&_S8112)->p_0 = _S8110; + (&_S8112)->w_mean_0 = _S8111; + (&_S8112)->w_cov_0 = _S8111; + (&_S8112)->p_0[int(0)] = mean_37; + SigmaPoints_0 _S8113 = _S8112; + (&_S8113)->w_mean_0[int(0)] = 0.0f; + (&_S8113)->w_cov_0[int(0)] = 2.0f; + float _S8114 = s_primal_ctx_sqrt_0(3.0f); + float _S8115 = _S8114 * _S8106.x; + float3 delta_42 = make_float3 (_S8115) * _S8109.rows[0U]; + float3 _S8116 = mean_37 + delta_42; + (&_S8113)->p_0[1U] = _S8116; + float3 _S8117 = mean_37 - delta_42; + (&_S8113)->p_0[4U] = _S8117; + float _S8118 = _S8114 * _S8106.y; + float3 delta_43 = make_float3 (_S8118) * _S8109.rows[1U]; + float3 _S8119 = mean_37 + delta_43; + (&_S8113)->p_0[2U] = _S8119; + float3 _S8120 = mean_37 - delta_43; + (&_S8113)->p_0[5U] = _S8120; + float _S8121 = _S8114 * _S8106.z; + float3 delta_44 = make_float3 (_S8121) * _S8109.rows[2U]; + float3 _S8122 = mean_37 + delta_44; + (&_S8113)->p_0[3U] = _S8122; + float3 _S8123 = mean_37 - delta_44; + (&_S8113)->p_0[6U] = _S8123; + (&_S8113)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S8124 = _S8113; + (&_S8124)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S8125 = _S8124; + (&_S8125)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S8126 = _S8125; + (&_S8126)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S8127 = _S8126; + (&_S8127)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S8128 = _S8127; + (&_S8128)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S8129 = _S8128; + (&_S8129)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S8130 = _S8129; + (&_S8130)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S8131 = _S8130; + (&_S8131)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S8132 = _S8131; + (&_S8132)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S8133 = _S8132; + (&_S8133)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S8134 = _S8133; + (&_S8134)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S8135 = _S8112; + float3 _S8136 = s_primal_ctx_mul_0(R_36, _S8112.p_0[0U]) + t_36; + _S8112 = _S8134; + (&_S8112)->p_0[0U] = _S8136; + SigmaPoints_0 _S8137 = _S8112; + (&_S8112)->p_0[1U] = s_primal_ctx_mul_0(R_36, _S8116) + t_36; + SigmaPoints_0 _S8138 = _S8112; + (&_S8112)->p_0[2U] = s_primal_ctx_mul_0(R_36, _S8119) + t_36; + SigmaPoints_0 _S8139 = _S8112; + (&_S8112)->p_0[3U] = s_primal_ctx_mul_0(R_36, _S8122) + t_36; + SigmaPoints_0 _S8140 = _S8112; + (&_S8112)->p_0[4U] = s_primal_ctx_mul_0(R_36, _S8117) + t_36; + SigmaPoints_0 _S8141 = _S8112; + (&_S8112)->p_0[5U] = s_primal_ctx_mul_0(R_36, _S8120) + t_36; + SigmaPoints_0 _S8142 = _S8112; + (&_S8112)->p_0[6U] = s_primal_ctx_mul_0(R_36, _S8123) + t_36; + float2 uv_61 = float2 {_S8137.p_0[int(0)].x, _S8137.p_0[int(0)].y} / make_float2 (_S8137.p_0[int(0)].z); + FixedArray _S8143 = dist_coeffs_48; + float2 _S8144 = s_primal_ctx_DistRational_distort_0(uv_61, &_S8143); + (&_S8104)->_S8096 = make_float2 (fx_49 * _S8144.x + cx_40, fy_49 * _S8144.y + cy_40); + float2 uv_62 = float2 {_S8138.p_0[int(1)].x, _S8138.p_0[int(1)].y} / make_float2 (_S8138.p_0[int(1)].z); + FixedArray _S8145 = dist_coeffs_48; + float2 _S8146 = s_primal_ctx_DistRational_distort_0(uv_62, &_S8145); + (&_S8104)->_S8097 = make_float2 (fx_49 * _S8146.x + cx_40, fy_49 * _S8146.y + cy_40); + float2 uv_63 = float2 {_S8139.p_0[int(2)].x, _S8139.p_0[int(2)].y} / make_float2 (_S8139.p_0[int(2)].z); + FixedArray _S8147 = dist_coeffs_48; + float2 _S8148 = s_primal_ctx_DistRational_distort_0(uv_63, &_S8147); + (&_S8104)->_S8098 = make_float2 (fx_49 * _S8148.x + cx_40, fy_49 * _S8148.y + cy_40); + float2 uv_64 = float2 {_S8140.p_0[int(3)].x, _S8140.p_0[int(3)].y} / make_float2 (_S8140.p_0[int(3)].z); + FixedArray _S8149 = dist_coeffs_48; + float2 _S8150 = s_primal_ctx_DistRational_distort_0(uv_64, &_S8149); + (&_S8104)->_S8099 = make_float2 (fx_49 * _S8150.x + cx_40, fy_49 * _S8150.y + cy_40); + float2 uv_65 = float2 {_S8141.p_0[int(4)].x, _S8141.p_0[int(4)].y} / make_float2 (_S8141.p_0[int(4)].z); + FixedArray _S8151 = dist_coeffs_48; + float2 _S8152 = s_primal_ctx_DistRational_distort_0(uv_65, &_S8151); + (&_S8104)->_S8100 = make_float2 (fx_49 * _S8152.x + cx_40, fy_49 * _S8152.y + cy_40); + float2 uv_66 = float2 {_S8142.p_0[int(5)].x, _S8142.p_0[int(5)].y} / make_float2 (_S8142.p_0[int(5)].z); + FixedArray _S8153 = dist_coeffs_48; + float2 _S8154 = s_primal_ctx_DistRational_distort_0(uv_66, &_S8153); + (&_S8104)->_S8101 = make_float2 (fx_49 * _S8154.x + cx_40, fy_49 * _S8154.y + cy_40); + float2 uv_67 = float2 {_S8112.p_0[int(6)].x, _S8112.p_0[int(6)].y} / make_float2 (_S8112.p_0[int(6)].z); + FixedArray _S8155 = dist_coeffs_48; + float2 _S8156 = s_primal_ctx_DistRational_distort_0(uv_67, &_S8155); + (&_S8104)->_S8102 = make_float2 (fx_49 * _S8156.x + cx_40, fy_49 * _S8156.y + cy_40); + float3 mean_c_36 = s_primal_ctx_mul_0(R_36, mean_37) + t_36; + float _S8157 = - in_opacity_36; + float _S8158 = 1.0f + s_primal_ctx_exp_0(_S8157); + float _S8159 = 1.0f / _S8158; + float _S8160 = _S8158 * _S8158; + float3 _S8161 = make_float3 (_S8115); + float3 _S8162 = make_float3 (_S8118); + float3 _S8163 = make_float3 (_S8121); + float _S8164 = float(image_width_36); + float _S8165 = float(image_height_36); + float _S8166 = 0.30000001192092896f * (0.5f * _S8164 / fx_49) * fx_49; + float lim_x_pos_19 = _S8164 + _S8166; + float _S8167 = 0.30000001192092896f * (0.5f * _S8165 / fy_49) * fy_49; + float lim_y_pos_7 = _S8165 + _S8167; + float2 _S8168 = make_float2 (_S8113.w_mean_0[int(1)]) * _S8104._S8097 + make_float2 (_S8125.w_mean_0[int(2)]) * _S8104._S8098 + make_float2 (_S8127.w_mean_0[int(3)]) * _S8104._S8099 + make_float2 (_S8129.w_mean_0[int(4)]) * _S8104._S8100 + make_float2 (_S8131.w_mean_0[int(5)]) * _S8104._S8101 + make_float2 (_S8133.w_mean_0[int(6)]) * _S8104._S8102; + float _S8169 = - _S8166; + float _S8170 = - _S8167; + float2 _S8171 = make_float2 (s_primal_ctx_clamp_0(_S8168.x, _S8169, lim_x_pos_19), s_primal_ctx_clamp_0(_S8168.y, _S8170, lim_y_pos_7)); + float2 d_98 = make_float2 (s_primal_ctx_clamp_0(_S8104._S8096.x, _S8169, lim_x_pos_19), s_primal_ctx_clamp_0(_S8104._S8096.y, _S8170, lim_y_pos_7)) - _S8171; + float _S8172 = d_98.x; + float _S8173 = d_98.y; + float _S8174 = _S8172 * _S8173; + float2 d_99 = make_float2 (s_primal_ctx_clamp_0(_S8104._S8097.x, _S8169, lim_x_pos_19), s_primal_ctx_clamp_0(_S8104._S8097.y, _S8170, lim_y_pos_7)) - _S8171; + float _S8175 = d_99.x; + float _S8176 = d_99.y; + float _S8177 = _S8175 * _S8176; + float2 d_100 = make_float2 (s_primal_ctx_clamp_0(_S8104._S8098.x, _S8169, lim_x_pos_19), s_primal_ctx_clamp_0(_S8104._S8098.y, _S8170, lim_y_pos_7)) - _S8171; + float _S8178 = d_100.x; + float _S8179 = d_100.y; + float _S8180 = _S8178 * _S8179; + float2 d_101 = make_float2 (s_primal_ctx_clamp_0(_S8104._S8099.x, _S8169, lim_x_pos_19), s_primal_ctx_clamp_0(_S8104._S8099.y, _S8170, lim_y_pos_7)) - _S8171; + float _S8181 = d_101.x; + float _S8182 = d_101.y; + float _S8183 = _S8181 * _S8182; + float2 d_102 = make_float2 (s_primal_ctx_clamp_0(_S8104._S8100.x, _S8169, lim_x_pos_19), s_primal_ctx_clamp_0(_S8104._S8100.y, _S8170, lim_y_pos_7)) - _S8171; + float _S8184 = d_102.x; + float _S8185 = d_102.y; + float _S8186 = _S8184 * _S8185; + float2 d_103 = make_float2 (s_primal_ctx_clamp_0(_S8104._S8101.x, _S8169, lim_x_pos_19), s_primal_ctx_clamp_0(_S8104._S8101.y, _S8170, lim_y_pos_7)) - _S8171; + float _S8187 = d_103.x; + float _S8188 = d_103.y; + float _S8189 = _S8187 * _S8188; + float2 d_104 = make_float2 (s_primal_ctx_clamp_0(_S8104._S8102.x, _S8169, lim_x_pos_19), s_primal_ctx_clamp_0(_S8104._S8102.y, _S8170, lim_y_pos_7)) - _S8171; + float _S8190 = d_104.x; + float _S8191 = d_104.y; + float _S8192 = _S8190 * _S8191; + Matrix covar2d_25 = makeMatrix (2.0f) * makeMatrix (_S8172 * _S8172, _S8174, _S8174, _S8173 * _S8173) + makeMatrix (_S8124.w_cov_0[int(1)]) * makeMatrix (_S8175 * _S8175, _S8177, _S8177, _S8176 * _S8176) + makeMatrix (_S8126.w_cov_0[int(2)]) * makeMatrix (_S8178 * _S8178, _S8180, _S8180, _S8179 * _S8179) + makeMatrix (_S8128.w_cov_0[int(3)]) * makeMatrix (_S8181 * _S8181, _S8183, _S8183, _S8182 * _S8182) + makeMatrix (_S8130.w_cov_0[int(4)]) * makeMatrix (_S8184 * _S8184, _S8186, _S8186, _S8185 * _S8185) + makeMatrix (_S8132.w_cov_0[int(5)]) * makeMatrix (_S8187 * _S8187, _S8189, _S8189, _S8188 * _S8188) + makeMatrix (_S8134.w_cov_0[int(6)]) * makeMatrix (_S8190 * _S8190, _S8192, _S8192, _S8191 * _S8191); + float eps2d_36; + if(antialiased_36) + { + eps2d_36 = 0.10000000149011612f; + } + else + { + eps2d_36 = 0.30000001192092896f; + } + float _S8193 = covar2d_25.rows[int(0)].y * covar2d_25.rows[int(1)].x; + float det_orig_36 = covar2d_25.rows[int(0)].x * covar2d_25.rows[int(1)].y - _S8193; + float _S8194 = covar2d_25.rows[int(0)].x + eps2d_36; + Matrix _S8195 = covar2d_25; + *&(((&_S8195)->rows + (int(0)))->x) = _S8194; + float _S8196 = covar2d_25.rows[int(1)].y + eps2d_36; + *&(((&_S8195)->rows + (int(1)))->y) = _S8196; + Matrix _S8197 = _S8195; + Matrix _S8198 = _S8195; + float det_blur_36 = _S8194 * _S8196 - _S8193; + float _S8199 = det_orig_36 / det_blur_36; + float _S8200 = det_blur_36 * det_blur_36; + float _S8201 = (F32_max((0.0f), (_S8199))); + float _S8202 = s_primal_ctx_sqrt_0(_S8201); + float invdet_42 = 1.0f / det_blur_36; + float _S8203 = - covar2d_25.rows[int(0)].y; + float _S8204 = - covar2d_25.rows[int(1)].x; + if(antialiased_36) + { + eps2d_36 = _S8159 * _S8202; + } + else + { + eps2d_36 = _S8159; + } + float _S8205 = eps2d_36 / 0.00392156885936856f; + float _S8206 = 2.0f * s_primal_ctx_log_0(_S8205); + float _S8207 = s_primal_ctx_sqrt_0(_S8206); + float _S8208 = _S8197.rows[int(0)].x; + float _S8209 = _S8198.rows[int(1)].y; + float3 campos_15 = - s_primal_ctx_mul_0(transpose_3(R_36), t_36); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8210; + (&_S8210)->primal_0 = mean_37; + (&_S8210)->differential_0 = _S8105; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8211; + (&_S8211)->primal_0 = scale_36; + (&_S8211)->differential_0 = _S8105; + DiffPair_float_0 _S8212; + (&_S8212)->primal_0 = in_opacity_36; + (&_S8212)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8213; + (&_S8213)->primal_0 = campos_15; + (&_S8213)->differential_0 = _S8105; + s_bwd_prop_view_radius_3dgs_0(&_S8210, &_S8211, &_S8212, &_S8213, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8214 = _S8210; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8215 = _S8211; + DiffPair_float_0 _S8216 = _S8212; + float2 _S8217 = _S8103; + *&((&_S8217)->y) = v_conic_14.z; + float2 _S8218 = _S8103; + *&((&_S8218)->y) = v_conic_14.y; + *&((&_S8218)->x) = v_conic_14.x; + DiffPair_float_0 _S8219; + (&_S8219)->primal_0 = _S8209; + (&_S8219)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8219, 0.0f); + DiffPair_float_0 _S8220; + (&_S8220)->primal_0 = _S8208; + (&_S8220)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8220, 0.0f); + DiffPair_float_0 _S8221; + (&_S8221)->primal_0 = 3.32999992370605469f; + (&_S8221)->differential_0 = 0.0f; + DiffPair_float_0 _S8222; + (&_S8222)->primal_0 = _S8207; + (&_S8222)->differential_0 = 0.0f; + _d_min_0(&_S8221, &_S8222, 0.0f); + DiffPair_float_0 _S8223; + (&_S8223)->primal_0 = _S8206; + (&_S8223)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8223, _S8222.differential_0); + float _S8224 = 2.0f * _S8223.differential_0; + DiffPair_float_0 _S8225; + (&_S8225)->primal_0 = _S8205; + (&_S8225)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S8225, _S8224); + float _S8226 = v_opacity_14 + 254.9999847412109375f * _S8225.differential_0; + Matrix _S8227 = makeMatrix (0.0f); + Matrix _S8228 = _S8227; + _S8228[int(1)] = _S8217; + _S8228[int(0)] = _S8218; + Matrix _S8229 = _S8228; + float2 _S8230 = make_float2 (0.0f, _S8219.differential_0); + float2 _S8231 = make_float2 (_S8220.differential_0, 0.0f); + float _S8232; + if(antialiased_36) + { + float _S8233 = _S8202 * _S8226; + eps2d_36 = _S8159 * _S8226; + _S8232 = _S8233; + } + else + { + eps2d_36 = 0.0f; + _S8232 = _S8226; + } + float _S8234 = invdet_42 * _S8229.rows[int(1)].y; + float _S8235 = - (invdet_42 * _S8229.rows[int(1)].x); + float _S8236 = - (invdet_42 * _S8229.rows[int(0)].y); + float _S8237 = invdet_42 * _S8229.rows[int(0)].x; + float _S8238 = - ((_S8194 * _S8229.rows[int(1)].y + _S8204 * _S8229.rows[int(1)].x + _S8203 * _S8229.rows[int(0)].y + _S8196 * _S8229.rows[int(0)].x) / _S8200); + DiffPair_float_0 _S8239; + (&_S8239)->primal_0 = _S8201; + (&_S8239)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8239, eps2d_36); + DiffPair_float_0 _S8240; + (&_S8240)->primal_0 = 0.0f; + (&_S8240)->differential_0 = 0.0f; + DiffPair_float_0 _S8241; + (&_S8241)->primal_0 = _S8199; + (&_S8241)->differential_0 = 0.0f; + _d_max_0(&_S8240, &_S8241, _S8239.differential_0); + float _S8242 = _S8241.differential_0 / _S8200; + float s_diff_det_orig_T_14 = det_blur_36 * _S8242; + float _S8243 = det_orig_36 * - _S8242 + _S8238; + float _S8244 = - _S8243; + float _S8245 = _S8194 * _S8243; + float _S8246 = _S8196 * _S8243; + Matrix _S8247 = _S8227; + _S8247[int(1)] = _S8230; + _S8247[int(0)] = _S8231; + float _S8248 = _S8246 + _S8247.rows[int(0)].x + _S8234; + float _S8249 = _S8244 + - s_diff_det_orig_T_14; + float _S8250 = covar2d_25.rows[int(0)].y * _S8249 + _S8235; + float _S8251 = covar2d_25.rows[int(1)].x * _S8249 + _S8236; + float _S8252 = covar2d_25.rows[int(1)].y * s_diff_det_orig_T_14; + float _S8253 = _S8245 + _S8247.rows[int(1)].y + _S8237 + covar2d_25.rows[int(0)].x * s_diff_det_orig_T_14; + float2 _S8254 = _S8103; + *&((&_S8254)->x) = _S8250; + *&((&_S8254)->y) = _S8253; + float _S8255 = _S8248 + _S8252; + float2 _S8256 = _S8103; + *&((&_S8256)->y) = _S8251; + *&((&_S8256)->x) = _S8255; + Matrix _S8257 = _S8227; + _S8257[int(1)] = _S8254; + _S8257[int(0)] = _S8256; + Matrix _S8258 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8259; + (&_S8259)->primal_0 = R_36; + (&_S8259)->differential_0 = _S8258; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8260; + (&_S8260)->primal_0 = _S8123; + (&_S8260)->differential_0 = _S8105; + s_bwd_prop_mul_3(&_S8259, &_S8260, _S8105); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8261; + (&_S8261)->primal_0 = R_36; + (&_S8261)->differential_0 = _S8258; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8262; + (&_S8262)->primal_0 = _S8120; + (&_S8262)->differential_0 = _S8105; + s_bwd_prop_mul_3(&_S8261, &_S8262, _S8105); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8263; + (&_S8263)->primal_0 = R_36; + (&_S8263)->differential_0 = _S8258; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8264; + (&_S8264)->primal_0 = _S8117; + (&_S8264)->differential_0 = _S8105; + s_bwd_prop_mul_3(&_S8263, &_S8264, _S8105); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8265; + (&_S8265)->primal_0 = R_36; + (&_S8265)->differential_0 = _S8258; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8266; + (&_S8266)->primal_0 = _S8122; + (&_S8266)->differential_0 = _S8105; + s_bwd_prop_mul_3(&_S8265, &_S8266, _S8105); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8267; + (&_S8267)->primal_0 = R_36; + (&_S8267)->differential_0 = _S8258; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8268; + (&_S8268)->primal_0 = _S8119; + (&_S8268)->differential_0 = _S8105; + s_bwd_prop_mul_3(&_S8267, &_S8268, _S8105); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8269; + (&_S8269)->primal_0 = R_36; + (&_S8269)->differential_0 = _S8258; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8270; + (&_S8270)->primal_0 = _S8116; + (&_S8270)->differential_0 = _S8105; + s_bwd_prop_mul_3(&_S8269, &_S8270, _S8105); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8271; + (&_S8271)->primal_0 = R_36; + (&_S8271)->differential_0 = _S8258; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8272; + (&_S8272)->primal_0 = _S8135.p_0[0U]; + (&_S8272)->differential_0 = _S8105; + s_bwd_prop_mul_3(&_S8271, &_S8272, _S8105); + float3 _S8273 = - _S8260.differential_0 + _S8266.differential_0; + float3 _S8274 = _S8163 * _S8273; + float3 _S8275 = _S8109.rows[2U] * _S8273; + float _S8276 = _S8114 * (_S8275.x + _S8275.y + _S8275.z); + float3 _S8277 = - _S8262.differential_0 + _S8268.differential_0; + float3 _S8278 = _S8162 * _S8277; + float3 _S8279 = _S8109.rows[1U] * _S8277; + float _S8280 = _S8114 * (_S8279.x + _S8279.y + _S8279.z); + float3 _S8281 = - _S8264.differential_0 + _S8270.differential_0; + float3 _S8282 = _S8161 * _S8281; + float3 _S8283 = _S8109.rows[0U] * _S8281; + float _S8284 = _S8114 * (_S8283.x + _S8283.y + _S8283.z); + Matrix _S8285 = _S8258; + _S8285[2U] = _S8274; + _S8285[1U] = _S8278; + _S8285[0U] = _S8282; + Matrix _S8286 = transpose_3(transpose_3(_S8285)); + float _S8287 = 2.0f * - _S8286.rows[int(2)].z; + float _S8288 = 2.0f * _S8286.rows[int(2)].y; + float _S8289 = 2.0f * _S8286.rows[int(2)].x; + float _S8290 = 2.0f * _S8286.rows[int(1)].z; + float _S8291 = 2.0f * - _S8286.rows[int(1)].y; + float _S8292 = 2.0f * _S8286.rows[int(1)].x; + float _S8293 = 2.0f * _S8286.rows[int(0)].z; + float _S8294 = 2.0f * _S8286.rows[int(0)].y; + float _S8295 = 2.0f * - _S8286.rows[int(0)].x; + float _S8296 = - _S8292 + _S8294; + float _S8297 = _S8289 + - _S8293; + float _S8298 = - _S8288 + _S8290; + float _S8299 = _S8288 + _S8290; + float _S8300 = _S8289 + _S8293; + float _S8301 = _S8292 + _S8294; + float _S8302 = _S8107.w * (_S8291 + _S8295); + float _S8303 = _S8107.z * (_S8287 + _S8295); + float _S8304 = _S8107.y * (_S8287 + _S8291); + float _S8305 = _S8107.x * _S8296 + _S8107.z * _S8299 + _S8107.y * _S8300 + _S8302 + _S8302; + float _S8306 = _S8107.x * _S8297 + _S8107.w * _S8299 + _S8107.y * _S8301 + _S8303 + _S8303; + float _S8307 = _S8107.x * _S8298 + _S8107.w * _S8300 + _S8107.z * _S8301 + _S8304 + _S8304; + float _S8308 = _S8107.w * _S8296 + _S8107.z * _S8297 + _S8107.y * _S8298; + float4 _S8309 = make_float4 (0.0f); + float4 _S8310 = _S8309; + *&((&_S8310)->w) = _S8305; + *&((&_S8310)->z) = _S8306; + *&((&_S8310)->y) = _S8307; + *&((&_S8310)->x) = _S8308; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S8311; + (&_S8311)->primal_0 = quat_36; + (&_S8311)->differential_0 = _S8309; + s_bwd_normalize_impl_0(&_S8311, _S8310); + float3 _S8312 = _S8105; + *&((&_S8312)->z) = _S8276; + *&((&_S8312)->y) = _S8280; + *&((&_S8312)->x) = _S8284; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8313; + (&_S8313)->primal_0 = scale_36; + (&_S8313)->differential_0 = _S8105; + s_bwd_prop_exp_1(&_S8313, _S8312); + float _S8314 = - (_S8232 / _S8160); + DiffPair_float_0 _S8315; + (&_S8315)->primal_0 = _S8157; + (&_S8315)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S8315, _S8314); + float _S8316 = - _S8315.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8317; + (&_S8317)->primal_0 = mean_c_36; + (&_S8317)->differential_0 = _S8105; + s_bwd_length_impl_0(&_S8317, v_depth_14); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8318; + (&_S8318)->primal_0 = R_36; + (&_S8318)->differential_0 = _S8258; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8319; + (&_S8319)->primal_0 = mean_37; + (&_S8319)->differential_0 = _S8105; + s_bwd_prop_mul_3(&_S8318, &_S8319, _S8317.differential_0); + Matrix _S8320 = _S8259.differential_0 + _S8261.differential_0 + _S8263.differential_0 + _S8265.differential_0 + _S8267.differential_0 + _S8269.differential_0 + _S8271.differential_0 + _S8318.differential_0; + float _S8321 = _S8316 + _S8216.differential_0; + float3 _S8322 = _S8313.differential_0 + _S8215.differential_0; + *v_mean_14 = *v_mean_14 + (_S8260.differential_0 + _S8266.differential_0 + _S8262.differential_0 + _S8268.differential_0 + _S8264.differential_0 + _S8270.differential_0 + _S8319.differential_0 + _S8214.differential_0); + *v_quat_14 = *v_quat_14 + _S8311.differential_0; + *v_scale_14 = *v_scale_14 + _S8322; + *v_in_opacity_14 = *v_in_opacity_14 + _S8321; + *v_R_14 = *v_R_14 + _S8320; + *v_t_14 = *v_t_14 + _S8317.differential_0; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgut_fisheye_none_projection_Intermediates_0 +{ + float2 _S8323; + float2 _S8324; + float2 _S8325; + float2 _S8326; + float2 _S8327; + float2 _S8328; + float2 _S8329; +}; + +inline __device__ void projection_3dgut_fisheye_none_vjp(bool antialiased_37, float3 mean_38, float4 quat_37, float3 scale_37, float in_opacity_37, Matrix R_37, float3 t_37, float fx_50, float fy_50, float cx_41, float cy_41, FixedArray dist_coeffs_49, uint image_width_37, uint image_height_37, float2 v_mean2d_15, float v_depth_15, float3 v_conic_15, float v_opacity_15, float3 * v_mean_15, float4 * v_quat_15, float3 * v_scale_15, float * v_in_opacity_15, Matrix * v_R_15, float3 * v_t_15) +{ + float2 _S8330 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_fisheye_none_projection_Intermediates_0 _S8331; + (&_S8331)->_S8323 = _S8330; + (&_S8331)->_S8324 = _S8330; + (&_S8331)->_S8325 = _S8330; + (&_S8331)->_S8326 = _S8330; + (&_S8331)->_S8327 = _S8330; + (&_S8331)->_S8328 = _S8330; + (&_S8331)->_S8329 = _S8330; + (&_S8331)->_S8323 = _S8330; + (&_S8331)->_S8324 = _S8330; + (&_S8331)->_S8325 = _S8330; + (&_S8331)->_S8326 = _S8330; + (&_S8331)->_S8327 = _S8330; + (&_S8331)->_S8328 = _S8330; + (&_S8331)->_S8329 = _S8330; + float3 _S8332 = make_float3 (0.0f); + float3 _S8333 = s_primal_ctx_exp_1(scale_37); + float4 _S8334 = normalize_0(quat_37); + float _S8335 = _S8334.y; + float x2_37 = _S8335 * _S8335; + float y2_37 = _S8334.z * _S8334.z; + float z2_37 = _S8334.w * _S8334.w; + float xy_37 = _S8334.y * _S8334.z; + float xz_37 = _S8334.y * _S8334.w; + float yz_37 = _S8334.z * _S8334.w; + float wx_37 = _S8334.x * _S8334.y; + float wy_37 = _S8334.x * _S8334.z; + float wz_37 = _S8334.x * _S8334.w; + Matrix _S8336 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_37 + z2_37), 2.0f * (xy_37 + wz_37), 2.0f * (xz_37 - wy_37), 2.0f * (xy_37 - wz_37), 1.0f - 2.0f * (x2_37 + z2_37), 2.0f * (yz_37 + wx_37), 2.0f * (xz_37 + wy_37), 2.0f * (yz_37 - wx_37), 1.0f - 2.0f * (x2_37 + y2_37)))); + FixedArray _S8337 = { + _S8332, _S8332, _S8332, _S8332, _S8332, _S8332, _S8332 + }; + FixedArray _S8338 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + SigmaPoints_0 _S8339; + (&_S8339)->p_0 = _S8337; + (&_S8339)->w_mean_0 = _S8338; + (&_S8339)->w_cov_0 = _S8338; + (&_S8339)->p_0[int(0)] = mean_38; + SigmaPoints_0 _S8340 = _S8339; + (&_S8340)->w_mean_0[int(0)] = 0.0f; + (&_S8340)->w_cov_0[int(0)] = 2.0f; + float _S8341 = s_primal_ctx_sqrt_0(3.0f); + float _S8342 = _S8341 * _S8333.x; + float3 delta_45 = make_float3 (_S8342) * _S8336.rows[0U]; + float3 _S8343 = mean_38 + delta_45; + (&_S8340)->p_0[1U] = _S8343; + float3 _S8344 = mean_38 - delta_45; + (&_S8340)->p_0[4U] = _S8344; + float _S8345 = _S8341 * _S8333.y; + float3 delta_46 = make_float3 (_S8345) * _S8336.rows[1U]; + float3 _S8346 = mean_38 + delta_46; + (&_S8340)->p_0[2U] = _S8346; + float3 _S8347 = mean_38 - delta_46; + (&_S8340)->p_0[5U] = _S8347; + float _S8348 = _S8341 * _S8333.z; + float3 delta_47 = make_float3 (_S8348) * _S8336.rows[2U]; + float3 _S8349 = mean_38 + delta_47; + (&_S8340)->p_0[3U] = _S8349; + float3 _S8350 = mean_38 - delta_47; + (&_S8340)->p_0[6U] = _S8350; + (&_S8340)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S8351 = _S8340; + (&_S8351)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S8352 = _S8351; + (&_S8352)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S8353 = _S8352; + (&_S8353)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S8354 = _S8353; + (&_S8354)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S8355 = _S8354; + (&_S8355)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S8356 = _S8355; + (&_S8356)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S8357 = _S8356; + (&_S8357)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S8358 = _S8357; + (&_S8358)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S8359 = _S8358; + (&_S8359)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S8360 = _S8359; + (&_S8360)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S8361 = _S8360; + (&_S8361)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S8362 = _S8339; + float3 _S8363 = s_primal_ctx_mul_0(R_37, _S8339.p_0[0U]) + t_37; + _S8339 = _S8361; + (&_S8339)->p_0[0U] = _S8363; + SigmaPoints_0 _S8364 = _S8339; + (&_S8339)->p_0[1U] = s_primal_ctx_mul_0(R_37, _S8343) + t_37; + SigmaPoints_0 _S8365 = _S8339; + (&_S8339)->p_0[2U] = s_primal_ctx_mul_0(R_37, _S8346) + t_37; + SigmaPoints_0 _S8366 = _S8339; + (&_S8339)->p_0[3U] = s_primal_ctx_mul_0(R_37, _S8349) + t_37; + SigmaPoints_0 _S8367 = _S8339; + (&_S8339)->p_0[4U] = s_primal_ctx_mul_0(R_37, _S8344) + t_37; + SigmaPoints_0 _S8368 = _S8339; + (&_S8339)->p_0[5U] = s_primal_ctx_mul_0(R_37, _S8347) + t_37; + SigmaPoints_0 _S8369 = _S8339; + (&_S8339)->p_0[6U] = s_primal_ctx_mul_0(R_37, _S8350) + t_37; + SigmaPoints_0 _S8370 = _S8339; + float2 _S8371 = float2 {_S8364.p_0[int(0)].x, _S8364.p_0[int(0)].y}; + float _S8372 = length_0(_S8371); + float _S8373 = _S8364.p_0[int(0)].z; + float _S8374 = s_primal_ctx_atan2_0(_S8372, _S8373); + float k_26; + if(_S8374 < 0.00100000004749745f) + { + k_26 = (1.0f - _S8374 * _S8374 / 3.0f) / _S8373; + } + else + { + k_26 = _S8374 / _S8372; + } + float2 _S8375 = _S8371 * make_float2 (k_26); + FixedArray _S8376 = dist_coeffs_49; + float2 _S8377 = s_primal_ctx_DistNone_distort_0(_S8375, &_S8376); + (&_S8331)->_S8323 = make_float2 (fx_50 * _S8377.x + cx_41, fy_50 * _S8377.y + cy_41); + float2 _S8378 = float2 {_S8365.p_0[int(1)].x, _S8365.p_0[int(1)].y}; + float _S8379 = length_0(_S8378); + float _S8380 = _S8365.p_0[int(1)].z; + float _S8381 = s_primal_ctx_atan2_0(_S8379, _S8380); + if(_S8381 < 0.00100000004749745f) + { + k_26 = (1.0f - _S8381 * _S8381 / 3.0f) / _S8380; + } + else + { + k_26 = _S8381 / _S8379; + } + float2 _S8382 = _S8378 * make_float2 (k_26); + FixedArray _S8383 = dist_coeffs_49; + float2 _S8384 = s_primal_ctx_DistNone_distort_0(_S8382, &_S8383); + (&_S8331)->_S8324 = make_float2 (fx_50 * _S8384.x + cx_41, fy_50 * _S8384.y + cy_41); + float2 _S8385 = float2 {_S8366.p_0[int(2)].x, _S8366.p_0[int(2)].y}; + float _S8386 = length_0(_S8385); + float _S8387 = _S8366.p_0[int(2)].z; + float _S8388 = s_primal_ctx_atan2_0(_S8386, _S8387); + if(_S8388 < 0.00100000004749745f) + { + k_26 = (1.0f - _S8388 * _S8388 / 3.0f) / _S8387; + } + else + { + k_26 = _S8388 / _S8386; + } + float2 _S8389 = _S8385 * make_float2 (k_26); + FixedArray _S8390 = dist_coeffs_49; + float2 _S8391 = s_primal_ctx_DistNone_distort_0(_S8389, &_S8390); + (&_S8331)->_S8325 = make_float2 (fx_50 * _S8391.x + cx_41, fy_50 * _S8391.y + cy_41); + float2 _S8392 = float2 {_S8367.p_0[int(3)].x, _S8367.p_0[int(3)].y}; + float _S8393 = length_0(_S8392); + float _S8394 = _S8367.p_0[int(3)].z; + float _S8395 = s_primal_ctx_atan2_0(_S8393, _S8394); + if(_S8395 < 0.00100000004749745f) + { + k_26 = (1.0f - _S8395 * _S8395 / 3.0f) / _S8394; + } + else + { + k_26 = _S8395 / _S8393; + } + float2 _S8396 = _S8392 * make_float2 (k_26); + FixedArray _S8397 = dist_coeffs_49; + float2 _S8398 = s_primal_ctx_DistNone_distort_0(_S8396, &_S8397); + (&_S8331)->_S8326 = make_float2 (fx_50 * _S8398.x + cx_41, fy_50 * _S8398.y + cy_41); + float2 _S8399 = float2 {_S8368.p_0[int(4)].x, _S8368.p_0[int(4)].y}; + float _S8400 = length_0(_S8399); + float _S8401 = _S8368.p_0[int(4)].z; + float _S8402 = s_primal_ctx_atan2_0(_S8400, _S8401); + if(_S8402 < 0.00100000004749745f) + { + k_26 = (1.0f - _S8402 * _S8402 / 3.0f) / _S8401; + } + else + { + k_26 = _S8402 / _S8400; + } + float2 _S8403 = _S8399 * make_float2 (k_26); + FixedArray _S8404 = dist_coeffs_49; + float2 _S8405 = s_primal_ctx_DistNone_distort_0(_S8403, &_S8404); + (&_S8331)->_S8327 = make_float2 (fx_50 * _S8405.x + cx_41, fy_50 * _S8405.y + cy_41); + float2 _S8406 = float2 {_S8369.p_0[int(5)].x, _S8369.p_0[int(5)].y}; + float _S8407 = length_0(_S8406); + float _S8408 = _S8369.p_0[int(5)].z; + float _S8409 = s_primal_ctx_atan2_0(_S8407, _S8408); + if(_S8409 < 0.00100000004749745f) + { + k_26 = (1.0f - _S8409 * _S8409 / 3.0f) / _S8408; + } + else + { + k_26 = _S8409 / _S8407; + } + float2 _S8410 = _S8406 * make_float2 (k_26); + FixedArray _S8411 = dist_coeffs_49; + float2 _S8412 = s_primal_ctx_DistNone_distort_0(_S8410, &_S8411); + (&_S8331)->_S8328 = make_float2 (fx_50 * _S8412.x + cx_41, fy_50 * _S8412.y + cy_41); + float2 _S8413 = float2 {_S8370.p_0[int(6)].x, _S8370.p_0[int(6)].y}; + float _S8414 = length_0(_S8413); + float _S8415 = _S8370.p_0[int(6)].z; + float _S8416 = s_primal_ctx_atan2_0(_S8414, _S8415); + if(_S8416 < 0.00100000004749745f) + { + k_26 = (1.0f - _S8416 * _S8416 / 3.0f) / _S8415; + } + else + { + k_26 = _S8416 / _S8414; + } + float2 _S8417 = _S8413 * make_float2 (k_26); + FixedArray _S8418 = dist_coeffs_49; + float2 _S8419 = s_primal_ctx_DistNone_distort_0(_S8417, &_S8418); + (&_S8331)->_S8329 = make_float2 (fx_50 * _S8419.x + cx_41, fy_50 * _S8419.y + cy_41); + float3 mean_c_37 = s_primal_ctx_mul_0(R_37, mean_38) + t_37; + float _S8420 = - in_opacity_37; + float _S8421 = 1.0f + s_primal_ctx_exp_0(_S8420); + float _S8422 = 1.0f / _S8421; + float _S8423 = _S8421 * _S8421; + float3 _S8424 = make_float3 (_S8342); + float3 _S8425 = make_float3 (_S8345); + float3 _S8426 = make_float3 (_S8348); + float2 _S8427 = make_float2 (_S8340.w_mean_0[int(1)]) * _S8331._S8324 + make_float2 (_S8352.w_mean_0[int(2)]) * _S8331._S8325 + make_float2 (_S8354.w_mean_0[int(3)]) * _S8331._S8326 + make_float2 (_S8356.w_mean_0[int(4)]) * _S8331._S8327 + make_float2 (_S8358.w_mean_0[int(5)]) * _S8331._S8328 + make_float2 (_S8360.w_mean_0[int(6)]) * _S8331._S8329; + float2 d_105 = _S8331._S8323 - _S8427; + float _S8428 = d_105.x; + float _S8429 = d_105.y; + float _S8430 = _S8428 * _S8429; + float2 d_106 = _S8331._S8324 - _S8427; + float _S8431 = d_106.x; + float _S8432 = d_106.y; + float _S8433 = _S8431 * _S8432; + float2 d_107 = _S8331._S8325 - _S8427; + float _S8434 = d_107.x; + float _S8435 = d_107.y; + float _S8436 = _S8434 * _S8435; + float2 d_108 = _S8331._S8326 - _S8427; + float _S8437 = d_108.x; + float _S8438 = d_108.y; + float _S8439 = _S8437 * _S8438; + float2 d_109 = _S8331._S8327 - _S8427; + float _S8440 = d_109.x; + float _S8441 = d_109.y; + float _S8442 = _S8440 * _S8441; + float2 d_110 = _S8331._S8328 - _S8427; + float _S8443 = d_110.x; + float _S8444 = d_110.y; + float _S8445 = _S8443 * _S8444; + float2 d_111 = _S8331._S8329 - _S8427; + float _S8446 = d_111.x; + float _S8447 = d_111.y; + float _S8448 = _S8446 * _S8447; + Matrix covar2d_26 = makeMatrix (2.0f) * makeMatrix (_S8428 * _S8428, _S8430, _S8430, _S8429 * _S8429) + makeMatrix (_S8351.w_cov_0[int(1)]) * makeMatrix (_S8431 * _S8431, _S8433, _S8433, _S8432 * _S8432) + makeMatrix (_S8353.w_cov_0[int(2)]) * makeMatrix (_S8434 * _S8434, _S8436, _S8436, _S8435 * _S8435) + makeMatrix (_S8355.w_cov_0[int(3)]) * makeMatrix (_S8437 * _S8437, _S8439, _S8439, _S8438 * _S8438) + makeMatrix (_S8357.w_cov_0[int(4)]) * makeMatrix (_S8440 * _S8440, _S8442, _S8442, _S8441 * _S8441) + makeMatrix (_S8359.w_cov_0[int(5)]) * makeMatrix (_S8443 * _S8443, _S8445, _S8445, _S8444 * _S8444) + makeMatrix (_S8361.w_cov_0[int(6)]) * makeMatrix (_S8446 * _S8446, _S8448, _S8448, _S8447 * _S8447); + float eps2d_37; + if(antialiased_37) + { + eps2d_37 = 0.10000000149011612f; + } + else + { + eps2d_37 = 0.30000001192092896f; + } + float _S8449 = covar2d_26.rows[int(0)].y * covar2d_26.rows[int(1)].x; + float det_orig_37 = covar2d_26.rows[int(0)].x * covar2d_26.rows[int(1)].y - _S8449; + float _S8450 = covar2d_26.rows[int(0)].x + eps2d_37; + Matrix _S8451 = covar2d_26; + *&(((&_S8451)->rows + (int(0)))->x) = _S8450; + float _S8452 = covar2d_26.rows[int(1)].y + eps2d_37; + *&(((&_S8451)->rows + (int(1)))->y) = _S8452; + Matrix _S8453 = _S8451; + Matrix _S8454 = _S8451; + float det_blur_37 = _S8450 * _S8452 - _S8449; + float _S8455 = det_orig_37 / det_blur_37; + float _S8456 = det_blur_37 * det_blur_37; + float _S8457 = (F32_max((0.0f), (_S8455))); + float _S8458 = s_primal_ctx_sqrt_0(_S8457); + float invdet_43 = 1.0f / det_blur_37; + float _S8459 = - covar2d_26.rows[int(0)].y; + float _S8460 = - covar2d_26.rows[int(1)].x; + if(antialiased_37) + { + k_26 = _S8422 * _S8458; + } + else + { + k_26 = _S8422; + } + float _S8461 = k_26 / 0.00392156885936856f; + float _S8462 = 2.0f * s_primal_ctx_log_0(_S8461); + float _S8463 = s_primal_ctx_sqrt_0(_S8462); + float _S8464 = _S8453.rows[int(0)].x; + float _S8465 = _S8454.rows[int(1)].y; + float3 campos_16 = - s_primal_ctx_mul_0(transpose_3(R_37), t_37); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8466; + (&_S8466)->primal_0 = mean_38; + (&_S8466)->differential_0 = _S8332; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8467; + (&_S8467)->primal_0 = scale_37; + (&_S8467)->differential_0 = _S8332; + DiffPair_float_0 _S8468; + (&_S8468)->primal_0 = in_opacity_37; + (&_S8468)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8469; + (&_S8469)->primal_0 = campos_16; + (&_S8469)->differential_0 = _S8332; + s_bwd_prop_view_radius_3dgs_0(&_S8466, &_S8467, &_S8468, &_S8469, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8470 = _S8466; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8471 = _S8467; + DiffPair_float_0 _S8472 = _S8468; + float2 _S8473 = _S8330; + *&((&_S8473)->y) = v_conic_15.z; + float2 _S8474 = _S8330; + *&((&_S8474)->y) = v_conic_15.y; + *&((&_S8474)->x) = v_conic_15.x; + DiffPair_float_0 _S8475; + (&_S8475)->primal_0 = _S8465; + (&_S8475)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8475, 0.0f); + DiffPair_float_0 _S8476; + (&_S8476)->primal_0 = _S8464; + (&_S8476)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8476, 0.0f); + DiffPair_float_0 _S8477; + (&_S8477)->primal_0 = 3.32999992370605469f; + (&_S8477)->differential_0 = 0.0f; + DiffPair_float_0 _S8478; + (&_S8478)->primal_0 = _S8463; + (&_S8478)->differential_0 = 0.0f; + _d_min_0(&_S8477, &_S8478, 0.0f); + DiffPair_float_0 _S8479; + (&_S8479)->primal_0 = _S8462; + (&_S8479)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8479, _S8478.differential_0); + float _S8480 = 2.0f * _S8479.differential_0; + DiffPair_float_0 _S8481; + (&_S8481)->primal_0 = _S8461; + (&_S8481)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S8481, _S8480); + float _S8482 = v_opacity_15 + 254.9999847412109375f * _S8481.differential_0; + Matrix _S8483 = makeMatrix (0.0f); + Matrix _S8484 = _S8483; + _S8484[int(1)] = _S8473; + _S8484[int(0)] = _S8474; + Matrix _S8485 = _S8484; + float2 _S8486 = make_float2 (0.0f, _S8475.differential_0); + float2 _S8487 = make_float2 (_S8476.differential_0, 0.0f); + if(antialiased_37) + { + float _S8488 = _S8458 * _S8482; + k_26 = _S8422 * _S8482; + eps2d_37 = _S8488; + } + else + { + k_26 = 0.0f; + eps2d_37 = _S8482; + } + float _S8489 = invdet_43 * _S8485.rows[int(1)].y; + float _S8490 = - (invdet_43 * _S8485.rows[int(1)].x); + float _S8491 = - (invdet_43 * _S8485.rows[int(0)].y); + float _S8492 = invdet_43 * _S8485.rows[int(0)].x; + float _S8493 = - ((_S8450 * _S8485.rows[int(1)].y + _S8460 * _S8485.rows[int(1)].x + _S8459 * _S8485.rows[int(0)].y + _S8452 * _S8485.rows[int(0)].x) / _S8456); + DiffPair_float_0 _S8494; + (&_S8494)->primal_0 = _S8457; + (&_S8494)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8494, k_26); + DiffPair_float_0 _S8495; + (&_S8495)->primal_0 = 0.0f; + (&_S8495)->differential_0 = 0.0f; + DiffPair_float_0 _S8496; + (&_S8496)->primal_0 = _S8455; + (&_S8496)->differential_0 = 0.0f; + _d_max_0(&_S8495, &_S8496, _S8494.differential_0); + float _S8497 = _S8496.differential_0 / _S8456; + float s_diff_det_orig_T_15 = det_blur_37 * _S8497; + float _S8498 = det_orig_37 * - _S8497 + _S8493; + float _S8499 = - _S8498; + float _S8500 = _S8450 * _S8498; + float _S8501 = _S8452 * _S8498; + Matrix _S8502 = _S8483; + _S8502[int(1)] = _S8486; + _S8502[int(0)] = _S8487; + float _S8503 = _S8501 + _S8502.rows[int(0)].x + _S8489; + float _S8504 = _S8499 + - s_diff_det_orig_T_15; + float _S8505 = covar2d_26.rows[int(0)].y * _S8504 + _S8490; + float _S8506 = covar2d_26.rows[int(1)].x * _S8504 + _S8491; + float _S8507 = covar2d_26.rows[int(1)].y * s_diff_det_orig_T_15; + float _S8508 = _S8500 + _S8502.rows[int(1)].y + _S8492 + covar2d_26.rows[int(0)].x * s_diff_det_orig_T_15; + float2 _S8509 = _S8330; + *&((&_S8509)->x) = _S8505; + *&((&_S8509)->y) = _S8508; + float _S8510 = _S8503 + _S8507; + float2 _S8511 = _S8330; + *&((&_S8511)->y) = _S8506; + *&((&_S8511)->x) = _S8510; + Matrix _S8512 = _S8483; + _S8512[int(1)] = _S8509; + _S8512[int(0)] = _S8511; + Matrix _S8513 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8514; + (&_S8514)->primal_0 = R_37; + (&_S8514)->differential_0 = _S8513; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8515; + (&_S8515)->primal_0 = _S8350; + (&_S8515)->differential_0 = _S8332; + s_bwd_prop_mul_3(&_S8514, &_S8515, _S8332); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8516; + (&_S8516)->primal_0 = R_37; + (&_S8516)->differential_0 = _S8513; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8517; + (&_S8517)->primal_0 = _S8347; + (&_S8517)->differential_0 = _S8332; + s_bwd_prop_mul_3(&_S8516, &_S8517, _S8332); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8518; + (&_S8518)->primal_0 = R_37; + (&_S8518)->differential_0 = _S8513; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8519; + (&_S8519)->primal_0 = _S8344; + (&_S8519)->differential_0 = _S8332; + s_bwd_prop_mul_3(&_S8518, &_S8519, _S8332); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8520; + (&_S8520)->primal_0 = R_37; + (&_S8520)->differential_0 = _S8513; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8521; + (&_S8521)->primal_0 = _S8349; + (&_S8521)->differential_0 = _S8332; + s_bwd_prop_mul_3(&_S8520, &_S8521, _S8332); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8522; + (&_S8522)->primal_0 = R_37; + (&_S8522)->differential_0 = _S8513; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8523; + (&_S8523)->primal_0 = _S8346; + (&_S8523)->differential_0 = _S8332; + s_bwd_prop_mul_3(&_S8522, &_S8523, _S8332); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8524; + (&_S8524)->primal_0 = R_37; + (&_S8524)->differential_0 = _S8513; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8525; + (&_S8525)->primal_0 = _S8343; + (&_S8525)->differential_0 = _S8332; + s_bwd_prop_mul_3(&_S8524, &_S8525, _S8332); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8526; + (&_S8526)->primal_0 = R_37; + (&_S8526)->differential_0 = _S8513; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8527; + (&_S8527)->primal_0 = _S8362.p_0[0U]; + (&_S8527)->differential_0 = _S8332; + s_bwd_prop_mul_3(&_S8526, &_S8527, _S8332); + float3 _S8528 = - _S8515.differential_0 + _S8521.differential_0; + float3 _S8529 = _S8426 * _S8528; + float3 _S8530 = _S8336.rows[2U] * _S8528; + float _S8531 = _S8341 * (_S8530.x + _S8530.y + _S8530.z); + float3 _S8532 = - _S8517.differential_0 + _S8523.differential_0; + float3 _S8533 = _S8425 * _S8532; + float3 _S8534 = _S8336.rows[1U] * _S8532; + float _S8535 = _S8341 * (_S8534.x + _S8534.y + _S8534.z); + float3 _S8536 = - _S8519.differential_0 + _S8525.differential_0; + float3 _S8537 = _S8424 * _S8536; + float3 _S8538 = _S8336.rows[0U] * _S8536; + float _S8539 = _S8341 * (_S8538.x + _S8538.y + _S8538.z); + Matrix _S8540 = _S8513; + _S8540[2U] = _S8529; + _S8540[1U] = _S8533; + _S8540[0U] = _S8537; + Matrix _S8541 = transpose_3(transpose_3(_S8540)); + float _S8542 = 2.0f * - _S8541.rows[int(2)].z; + float _S8543 = 2.0f * _S8541.rows[int(2)].y; + float _S8544 = 2.0f * _S8541.rows[int(2)].x; + float _S8545 = 2.0f * _S8541.rows[int(1)].z; + float _S8546 = 2.0f * - _S8541.rows[int(1)].y; + float _S8547 = 2.0f * _S8541.rows[int(1)].x; + float _S8548 = 2.0f * _S8541.rows[int(0)].z; + float _S8549 = 2.0f * _S8541.rows[int(0)].y; + float _S8550 = 2.0f * - _S8541.rows[int(0)].x; + float _S8551 = - _S8547 + _S8549; + float _S8552 = _S8544 + - _S8548; + float _S8553 = - _S8543 + _S8545; + float _S8554 = _S8543 + _S8545; + float _S8555 = _S8544 + _S8548; + float _S8556 = _S8547 + _S8549; + float _S8557 = _S8334.w * (_S8546 + _S8550); + float _S8558 = _S8334.z * (_S8542 + _S8550); + float _S8559 = _S8334.y * (_S8542 + _S8546); + float _S8560 = _S8334.x * _S8551 + _S8334.z * _S8554 + _S8334.y * _S8555 + _S8557 + _S8557; + float _S8561 = _S8334.x * _S8552 + _S8334.w * _S8554 + _S8334.y * _S8556 + _S8558 + _S8558; + float _S8562 = _S8334.x * _S8553 + _S8334.w * _S8555 + _S8334.z * _S8556 + _S8559 + _S8559; + float _S8563 = _S8334.w * _S8551 + _S8334.z * _S8552 + _S8334.y * _S8553; + float4 _S8564 = make_float4 (0.0f); + float4 _S8565 = _S8564; + *&((&_S8565)->w) = _S8560; + *&((&_S8565)->z) = _S8561; + *&((&_S8565)->y) = _S8562; + *&((&_S8565)->x) = _S8563; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S8566; + (&_S8566)->primal_0 = quat_37; + (&_S8566)->differential_0 = _S8564; + s_bwd_normalize_impl_0(&_S8566, _S8565); + float3 _S8567 = _S8332; + *&((&_S8567)->z) = _S8531; + *&((&_S8567)->y) = _S8535; + *&((&_S8567)->x) = _S8539; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8568; + (&_S8568)->primal_0 = scale_37; + (&_S8568)->differential_0 = _S8332; + s_bwd_prop_exp_1(&_S8568, _S8567); + float _S8569 = - (eps2d_37 / _S8423); + DiffPair_float_0 _S8570; + (&_S8570)->primal_0 = _S8420; + (&_S8570)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S8570, _S8569); + float _S8571 = - _S8570.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8572; + (&_S8572)->primal_0 = mean_c_37; + (&_S8572)->differential_0 = _S8332; + s_bwd_length_impl_0(&_S8572, v_depth_15); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8573; + (&_S8573)->primal_0 = R_37; + (&_S8573)->differential_0 = _S8513; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8574; + (&_S8574)->primal_0 = mean_38; + (&_S8574)->differential_0 = _S8332; + s_bwd_prop_mul_3(&_S8573, &_S8574, _S8572.differential_0); + Matrix _S8575 = _S8514.differential_0 + _S8516.differential_0 + _S8518.differential_0 + _S8520.differential_0 + _S8522.differential_0 + _S8524.differential_0 + _S8526.differential_0 + _S8573.differential_0; + float _S8576 = _S8571 + _S8472.differential_0; + float3 _S8577 = _S8568.differential_0 + _S8471.differential_0; + *v_mean_15 = *v_mean_15 + (_S8515.differential_0 + _S8521.differential_0 + _S8517.differential_0 + _S8523.differential_0 + _S8519.differential_0 + _S8525.differential_0 + _S8574.differential_0 + _S8470.differential_0); + *v_quat_15 = *v_quat_15 + _S8566.differential_0; + *v_scale_15 = *v_scale_15 + _S8577; + *v_in_opacity_15 = *v_in_opacity_15 + _S8576; + *v_R_15 = *v_R_15 + _S8575; + *v_t_15 = *v_t_15 + _S8572.differential_0; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgut_fisheye_opencv_projection_Intermediates_0 +{ + float2 _S8578; + float2 _S8579; + float2 _S8580; + float2 _S8581; + float2 _S8582; + float2 _S8583; + float2 _S8584; +}; + +inline __device__ void projection_3dgut_fisheye_opencv_vjp(bool antialiased_38, float3 mean_39, float4 quat_38, float3 scale_38, float in_opacity_38, Matrix R_38, float3 t_38, float fx_51, float fy_51, float cx_42, float cy_42, FixedArray dist_coeffs_50, uint image_width_38, uint image_height_38, float2 v_mean2d_16, float v_depth_16, float3 v_conic_16, float v_opacity_16, float3 * v_mean_16, float4 * v_quat_16, float3 * v_scale_16, float * v_in_opacity_16, Matrix * v_R_16, float3 * v_t_16) +{ + float2 _S8585 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_fisheye_opencv_projection_Intermediates_0 _S8586; + (&_S8586)->_S8578 = _S8585; + (&_S8586)->_S8579 = _S8585; + (&_S8586)->_S8580 = _S8585; + (&_S8586)->_S8581 = _S8585; + (&_S8586)->_S8582 = _S8585; + (&_S8586)->_S8583 = _S8585; + (&_S8586)->_S8584 = _S8585; + (&_S8586)->_S8578 = _S8585; + (&_S8586)->_S8579 = _S8585; + (&_S8586)->_S8580 = _S8585; + (&_S8586)->_S8581 = _S8585; + (&_S8586)->_S8582 = _S8585; + (&_S8586)->_S8583 = _S8585; + (&_S8586)->_S8584 = _S8585; + float3 _S8587 = make_float3 (0.0f); + float3 _S8588 = s_primal_ctx_exp_1(scale_38); + float4 _S8589 = normalize_0(quat_38); + float _S8590 = _S8589.y; + float x2_38 = _S8590 * _S8590; + float y2_38 = _S8589.z * _S8589.z; + float z2_38 = _S8589.w * _S8589.w; + float xy_38 = _S8589.y * _S8589.z; + float xz_38 = _S8589.y * _S8589.w; + float yz_38 = _S8589.z * _S8589.w; + float wx_38 = _S8589.x * _S8589.y; + float wy_38 = _S8589.x * _S8589.z; + float wz_38 = _S8589.x * _S8589.w; + Matrix _S8591 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_38 + z2_38), 2.0f * (xy_38 + wz_38), 2.0f * (xz_38 - wy_38), 2.0f * (xy_38 - wz_38), 1.0f - 2.0f * (x2_38 + z2_38), 2.0f * (yz_38 + wx_38), 2.0f * (xz_38 + wy_38), 2.0f * (yz_38 - wx_38), 1.0f - 2.0f * (x2_38 + y2_38)))); + FixedArray _S8592 = { + _S8587, _S8587, _S8587, _S8587, _S8587, _S8587, _S8587 + }; + FixedArray _S8593 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + SigmaPoints_0 _S8594; + (&_S8594)->p_0 = _S8592; + (&_S8594)->w_mean_0 = _S8593; + (&_S8594)->w_cov_0 = _S8593; + (&_S8594)->p_0[int(0)] = mean_39; + SigmaPoints_0 _S8595 = _S8594; + (&_S8595)->w_mean_0[int(0)] = 0.0f; + (&_S8595)->w_cov_0[int(0)] = 2.0f; + float _S8596 = s_primal_ctx_sqrt_0(3.0f); + float _S8597 = _S8596 * _S8588.x; + float3 delta_48 = make_float3 (_S8597) * _S8591.rows[0U]; + float3 _S8598 = mean_39 + delta_48; + (&_S8595)->p_0[1U] = _S8598; + float3 _S8599 = mean_39 - delta_48; + (&_S8595)->p_0[4U] = _S8599; + float _S8600 = _S8596 * _S8588.y; + float3 delta_49 = make_float3 (_S8600) * _S8591.rows[1U]; + float3 _S8601 = mean_39 + delta_49; + (&_S8595)->p_0[2U] = _S8601; + float3 _S8602 = mean_39 - delta_49; + (&_S8595)->p_0[5U] = _S8602; + float _S8603 = _S8596 * _S8588.z; + float3 delta_50 = make_float3 (_S8603) * _S8591.rows[2U]; + float3 _S8604 = mean_39 + delta_50; + (&_S8595)->p_0[3U] = _S8604; + float3 _S8605 = mean_39 - delta_50; + (&_S8595)->p_0[6U] = _S8605; + (&_S8595)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S8606 = _S8595; + (&_S8606)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S8607 = _S8606; + (&_S8607)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S8608 = _S8607; + (&_S8608)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S8609 = _S8608; + (&_S8609)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S8610 = _S8609; + (&_S8610)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S8611 = _S8610; + (&_S8611)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S8612 = _S8611; + (&_S8612)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S8613 = _S8612; + (&_S8613)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S8614 = _S8613; + (&_S8614)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S8615 = _S8614; + (&_S8615)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S8616 = _S8615; + (&_S8616)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S8617 = _S8594; + float3 _S8618 = s_primal_ctx_mul_0(R_38, _S8594.p_0[0U]) + t_38; + _S8594 = _S8616; + (&_S8594)->p_0[0U] = _S8618; + SigmaPoints_0 _S8619 = _S8594; + (&_S8594)->p_0[1U] = s_primal_ctx_mul_0(R_38, _S8598) + t_38; + SigmaPoints_0 _S8620 = _S8594; + (&_S8594)->p_0[2U] = s_primal_ctx_mul_0(R_38, _S8601) + t_38; + SigmaPoints_0 _S8621 = _S8594; + (&_S8594)->p_0[3U] = s_primal_ctx_mul_0(R_38, _S8604) + t_38; + SigmaPoints_0 _S8622 = _S8594; + (&_S8594)->p_0[4U] = s_primal_ctx_mul_0(R_38, _S8599) + t_38; + SigmaPoints_0 _S8623 = _S8594; + (&_S8594)->p_0[5U] = s_primal_ctx_mul_0(R_38, _S8602) + t_38; + SigmaPoints_0 _S8624 = _S8594; + (&_S8594)->p_0[6U] = s_primal_ctx_mul_0(R_38, _S8605) + t_38; + SigmaPoints_0 _S8625 = _S8594; + float2 _S8626 = float2 {_S8619.p_0[int(0)].x, _S8619.p_0[int(0)].y}; + float _S8627 = length_0(_S8626); + float _S8628 = _S8619.p_0[int(0)].z; + float _S8629 = s_primal_ctx_atan2_0(_S8627, _S8628); + float k_27; + if(_S8629 < 0.00100000004749745f) + { + k_27 = (1.0f - _S8629 * _S8629 / 3.0f) / _S8628; + } + else + { + k_27 = _S8629 / _S8627; + } + float2 _S8630 = _S8626 * make_float2 (k_27); + FixedArray _S8631 = dist_coeffs_50; + float2 _S8632 = s_primal_ctx_DistOpenCV_distort_0(_S8630, &_S8631); + (&_S8586)->_S8578 = make_float2 (fx_51 * _S8632.x + cx_42, fy_51 * _S8632.y + cy_42); + float2 _S8633 = float2 {_S8620.p_0[int(1)].x, _S8620.p_0[int(1)].y}; + float _S8634 = length_0(_S8633); + float _S8635 = _S8620.p_0[int(1)].z; + float _S8636 = s_primal_ctx_atan2_0(_S8634, _S8635); + if(_S8636 < 0.00100000004749745f) + { + k_27 = (1.0f - _S8636 * _S8636 / 3.0f) / _S8635; + } + else + { + k_27 = _S8636 / _S8634; + } + float2 _S8637 = _S8633 * make_float2 (k_27); + FixedArray _S8638 = dist_coeffs_50; + float2 _S8639 = s_primal_ctx_DistOpenCV_distort_0(_S8637, &_S8638); + (&_S8586)->_S8579 = make_float2 (fx_51 * _S8639.x + cx_42, fy_51 * _S8639.y + cy_42); + float2 _S8640 = float2 {_S8621.p_0[int(2)].x, _S8621.p_0[int(2)].y}; + float _S8641 = length_0(_S8640); + float _S8642 = _S8621.p_0[int(2)].z; + float _S8643 = s_primal_ctx_atan2_0(_S8641, _S8642); + if(_S8643 < 0.00100000004749745f) + { + k_27 = (1.0f - _S8643 * _S8643 / 3.0f) / _S8642; + } + else + { + k_27 = _S8643 / _S8641; + } + float2 _S8644 = _S8640 * make_float2 (k_27); + FixedArray _S8645 = dist_coeffs_50; + float2 _S8646 = s_primal_ctx_DistOpenCV_distort_0(_S8644, &_S8645); + (&_S8586)->_S8580 = make_float2 (fx_51 * _S8646.x + cx_42, fy_51 * _S8646.y + cy_42); + float2 _S8647 = float2 {_S8622.p_0[int(3)].x, _S8622.p_0[int(3)].y}; + float _S8648 = length_0(_S8647); + float _S8649 = _S8622.p_0[int(3)].z; + float _S8650 = s_primal_ctx_atan2_0(_S8648, _S8649); + if(_S8650 < 0.00100000004749745f) + { + k_27 = (1.0f - _S8650 * _S8650 / 3.0f) / _S8649; + } + else + { + k_27 = _S8650 / _S8648; + } + float2 _S8651 = _S8647 * make_float2 (k_27); + FixedArray _S8652 = dist_coeffs_50; + float2 _S8653 = s_primal_ctx_DistOpenCV_distort_0(_S8651, &_S8652); + (&_S8586)->_S8581 = make_float2 (fx_51 * _S8653.x + cx_42, fy_51 * _S8653.y + cy_42); + float2 _S8654 = float2 {_S8623.p_0[int(4)].x, _S8623.p_0[int(4)].y}; + float _S8655 = length_0(_S8654); + float _S8656 = _S8623.p_0[int(4)].z; + float _S8657 = s_primal_ctx_atan2_0(_S8655, _S8656); + if(_S8657 < 0.00100000004749745f) + { + k_27 = (1.0f - _S8657 * _S8657 / 3.0f) / _S8656; + } + else + { + k_27 = _S8657 / _S8655; + } + float2 _S8658 = _S8654 * make_float2 (k_27); + FixedArray _S8659 = dist_coeffs_50; + float2 _S8660 = s_primal_ctx_DistOpenCV_distort_0(_S8658, &_S8659); + (&_S8586)->_S8582 = make_float2 (fx_51 * _S8660.x + cx_42, fy_51 * _S8660.y + cy_42); + float2 _S8661 = float2 {_S8624.p_0[int(5)].x, _S8624.p_0[int(5)].y}; + float _S8662 = length_0(_S8661); + float _S8663 = _S8624.p_0[int(5)].z; + float _S8664 = s_primal_ctx_atan2_0(_S8662, _S8663); + if(_S8664 < 0.00100000004749745f) + { + k_27 = (1.0f - _S8664 * _S8664 / 3.0f) / _S8663; + } + else + { + k_27 = _S8664 / _S8662; + } + float2 _S8665 = _S8661 * make_float2 (k_27); + FixedArray _S8666 = dist_coeffs_50; + float2 _S8667 = s_primal_ctx_DistOpenCV_distort_0(_S8665, &_S8666); + (&_S8586)->_S8583 = make_float2 (fx_51 * _S8667.x + cx_42, fy_51 * _S8667.y + cy_42); + float2 _S8668 = float2 {_S8625.p_0[int(6)].x, _S8625.p_0[int(6)].y}; + float _S8669 = length_0(_S8668); + float _S8670 = _S8625.p_0[int(6)].z; + float _S8671 = s_primal_ctx_atan2_0(_S8669, _S8670); + if(_S8671 < 0.00100000004749745f) + { + k_27 = (1.0f - _S8671 * _S8671 / 3.0f) / _S8670; + } + else + { + k_27 = _S8671 / _S8669; + } + float2 _S8672 = _S8668 * make_float2 (k_27); + FixedArray _S8673 = dist_coeffs_50; + float2 _S8674 = s_primal_ctx_DistOpenCV_distort_0(_S8672, &_S8673); + (&_S8586)->_S8584 = make_float2 (fx_51 * _S8674.x + cx_42, fy_51 * _S8674.y + cy_42); + float3 mean_c_38 = s_primal_ctx_mul_0(R_38, mean_39) + t_38; + float _S8675 = - in_opacity_38; + float _S8676 = 1.0f + s_primal_ctx_exp_0(_S8675); + float _S8677 = 1.0f / _S8676; + float _S8678 = _S8676 * _S8676; + float3 _S8679 = make_float3 (_S8597); + float3 _S8680 = make_float3 (_S8600); + float3 _S8681 = make_float3 (_S8603); + float2 _S8682 = make_float2 (_S8595.w_mean_0[int(1)]) * _S8586._S8579 + make_float2 (_S8607.w_mean_0[int(2)]) * _S8586._S8580 + make_float2 (_S8609.w_mean_0[int(3)]) * _S8586._S8581 + make_float2 (_S8611.w_mean_0[int(4)]) * _S8586._S8582 + make_float2 (_S8613.w_mean_0[int(5)]) * _S8586._S8583 + make_float2 (_S8615.w_mean_0[int(6)]) * _S8586._S8584; + float2 d_112 = _S8586._S8578 - _S8682; + float _S8683 = d_112.x; + float _S8684 = d_112.y; + float _S8685 = _S8683 * _S8684; + float2 d_113 = _S8586._S8579 - _S8682; + float _S8686 = d_113.x; + float _S8687 = d_113.y; + float _S8688 = _S8686 * _S8687; + float2 d_114 = _S8586._S8580 - _S8682; + float _S8689 = d_114.x; + float _S8690 = d_114.y; + float _S8691 = _S8689 * _S8690; + float2 d_115 = _S8586._S8581 - _S8682; + float _S8692 = d_115.x; + float _S8693 = d_115.y; + float _S8694 = _S8692 * _S8693; + float2 d_116 = _S8586._S8582 - _S8682; + float _S8695 = d_116.x; + float _S8696 = d_116.y; + float _S8697 = _S8695 * _S8696; + float2 d_117 = _S8586._S8583 - _S8682; + float _S8698 = d_117.x; + float _S8699 = d_117.y; + float _S8700 = _S8698 * _S8699; + float2 d_118 = _S8586._S8584 - _S8682; + float _S8701 = d_118.x; + float _S8702 = d_118.y; + float _S8703 = _S8701 * _S8702; + Matrix covar2d_27 = makeMatrix (2.0f) * makeMatrix (_S8683 * _S8683, _S8685, _S8685, _S8684 * _S8684) + makeMatrix (_S8606.w_cov_0[int(1)]) * makeMatrix (_S8686 * _S8686, _S8688, _S8688, _S8687 * _S8687) + makeMatrix (_S8608.w_cov_0[int(2)]) * makeMatrix (_S8689 * _S8689, _S8691, _S8691, _S8690 * _S8690) + makeMatrix (_S8610.w_cov_0[int(3)]) * makeMatrix (_S8692 * _S8692, _S8694, _S8694, _S8693 * _S8693) + makeMatrix (_S8612.w_cov_0[int(4)]) * makeMatrix (_S8695 * _S8695, _S8697, _S8697, _S8696 * _S8696) + makeMatrix (_S8614.w_cov_0[int(5)]) * makeMatrix (_S8698 * _S8698, _S8700, _S8700, _S8699 * _S8699) + makeMatrix (_S8616.w_cov_0[int(6)]) * makeMatrix (_S8701 * _S8701, _S8703, _S8703, _S8702 * _S8702); + float eps2d_38; + if(antialiased_38) + { + eps2d_38 = 0.10000000149011612f; + } + else + { + eps2d_38 = 0.30000001192092896f; + } + float _S8704 = covar2d_27.rows[int(0)].y * covar2d_27.rows[int(1)].x; + float det_orig_38 = covar2d_27.rows[int(0)].x * covar2d_27.rows[int(1)].y - _S8704; + float _S8705 = covar2d_27.rows[int(0)].x + eps2d_38; + Matrix _S8706 = covar2d_27; + *&(((&_S8706)->rows + (int(0)))->x) = _S8705; + float _S8707 = covar2d_27.rows[int(1)].y + eps2d_38; + *&(((&_S8706)->rows + (int(1)))->y) = _S8707; + Matrix _S8708 = _S8706; + Matrix _S8709 = _S8706; + float det_blur_38 = _S8705 * _S8707 - _S8704; + float _S8710 = det_orig_38 / det_blur_38; + float _S8711 = det_blur_38 * det_blur_38; + float _S8712 = (F32_max((0.0f), (_S8710))); + float _S8713 = s_primal_ctx_sqrt_0(_S8712); + float invdet_44 = 1.0f / det_blur_38; + float _S8714 = - covar2d_27.rows[int(0)].y; + float _S8715 = - covar2d_27.rows[int(1)].x; + if(antialiased_38) + { + k_27 = _S8677 * _S8713; + } + else + { + k_27 = _S8677; + } + float _S8716 = k_27 / 0.00392156885936856f; + float _S8717 = 2.0f * s_primal_ctx_log_0(_S8716); + float _S8718 = s_primal_ctx_sqrt_0(_S8717); + float _S8719 = _S8708.rows[int(0)].x; + float _S8720 = _S8709.rows[int(1)].y; + float3 campos_17 = - s_primal_ctx_mul_0(transpose_3(R_38), t_38); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8721; + (&_S8721)->primal_0 = mean_39; + (&_S8721)->differential_0 = _S8587; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8722; + (&_S8722)->primal_0 = scale_38; + (&_S8722)->differential_0 = _S8587; + DiffPair_float_0 _S8723; + (&_S8723)->primal_0 = in_opacity_38; + (&_S8723)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8724; + (&_S8724)->primal_0 = campos_17; + (&_S8724)->differential_0 = _S8587; + s_bwd_prop_view_radius_3dgs_0(&_S8721, &_S8722, &_S8723, &_S8724, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8725 = _S8721; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8726 = _S8722; + DiffPair_float_0 _S8727 = _S8723; + float2 _S8728 = _S8585; + *&((&_S8728)->y) = v_conic_16.z; + float2 _S8729 = _S8585; + *&((&_S8729)->y) = v_conic_16.y; + *&((&_S8729)->x) = v_conic_16.x; + DiffPair_float_0 _S8730; + (&_S8730)->primal_0 = _S8720; + (&_S8730)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8730, 0.0f); + DiffPair_float_0 _S8731; + (&_S8731)->primal_0 = _S8719; + (&_S8731)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8731, 0.0f); + DiffPair_float_0 _S8732; + (&_S8732)->primal_0 = 3.32999992370605469f; + (&_S8732)->differential_0 = 0.0f; + DiffPair_float_0 _S8733; + (&_S8733)->primal_0 = _S8718; + (&_S8733)->differential_0 = 0.0f; + _d_min_0(&_S8732, &_S8733, 0.0f); + DiffPair_float_0 _S8734; + (&_S8734)->primal_0 = _S8717; + (&_S8734)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8734, _S8733.differential_0); + float _S8735 = 2.0f * _S8734.differential_0; + DiffPair_float_0 _S8736; + (&_S8736)->primal_0 = _S8716; + (&_S8736)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S8736, _S8735); + float _S8737 = v_opacity_16 + 254.9999847412109375f * _S8736.differential_0; + Matrix _S8738 = makeMatrix (0.0f); + Matrix _S8739 = _S8738; + _S8739[int(1)] = _S8728; + _S8739[int(0)] = _S8729; + Matrix _S8740 = _S8739; + float2 _S8741 = make_float2 (0.0f, _S8730.differential_0); + float2 _S8742 = make_float2 (_S8731.differential_0, 0.0f); + if(antialiased_38) + { + float _S8743 = _S8713 * _S8737; + k_27 = _S8677 * _S8737; + eps2d_38 = _S8743; + } + else + { + k_27 = 0.0f; + eps2d_38 = _S8737; + } + float _S8744 = invdet_44 * _S8740.rows[int(1)].y; + float _S8745 = - (invdet_44 * _S8740.rows[int(1)].x); + float _S8746 = - (invdet_44 * _S8740.rows[int(0)].y); + float _S8747 = invdet_44 * _S8740.rows[int(0)].x; + float _S8748 = - ((_S8705 * _S8740.rows[int(1)].y + _S8715 * _S8740.rows[int(1)].x + _S8714 * _S8740.rows[int(0)].y + _S8707 * _S8740.rows[int(0)].x) / _S8711); + DiffPair_float_0 _S8749; + (&_S8749)->primal_0 = _S8712; + (&_S8749)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8749, k_27); + DiffPair_float_0 _S8750; + (&_S8750)->primal_0 = 0.0f; + (&_S8750)->differential_0 = 0.0f; + DiffPair_float_0 _S8751; + (&_S8751)->primal_0 = _S8710; + (&_S8751)->differential_0 = 0.0f; + _d_max_0(&_S8750, &_S8751, _S8749.differential_0); + float _S8752 = _S8751.differential_0 / _S8711; + float s_diff_det_orig_T_16 = det_blur_38 * _S8752; + float _S8753 = det_orig_38 * - _S8752 + _S8748; + float _S8754 = - _S8753; + float _S8755 = _S8705 * _S8753; + float _S8756 = _S8707 * _S8753; + Matrix _S8757 = _S8738; + _S8757[int(1)] = _S8741; + _S8757[int(0)] = _S8742; + float _S8758 = _S8756 + _S8757.rows[int(0)].x + _S8744; + float _S8759 = _S8754 + - s_diff_det_orig_T_16; + float _S8760 = covar2d_27.rows[int(0)].y * _S8759 + _S8745; + float _S8761 = covar2d_27.rows[int(1)].x * _S8759 + _S8746; + float _S8762 = covar2d_27.rows[int(1)].y * s_diff_det_orig_T_16; + float _S8763 = _S8755 + _S8757.rows[int(1)].y + _S8747 + covar2d_27.rows[int(0)].x * s_diff_det_orig_T_16; + float2 _S8764 = _S8585; + *&((&_S8764)->x) = _S8760; + *&((&_S8764)->y) = _S8763; + float _S8765 = _S8758 + _S8762; + float2 _S8766 = _S8585; + *&((&_S8766)->y) = _S8761; + *&((&_S8766)->x) = _S8765; + Matrix _S8767 = _S8738; + _S8767[int(1)] = _S8764; + _S8767[int(0)] = _S8766; + Matrix _S8768 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8769; + (&_S8769)->primal_0 = R_38; + (&_S8769)->differential_0 = _S8768; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8770; + (&_S8770)->primal_0 = _S8605; + (&_S8770)->differential_0 = _S8587; + s_bwd_prop_mul_3(&_S8769, &_S8770, _S8587); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8771; + (&_S8771)->primal_0 = R_38; + (&_S8771)->differential_0 = _S8768; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8772; + (&_S8772)->primal_0 = _S8602; + (&_S8772)->differential_0 = _S8587; + s_bwd_prop_mul_3(&_S8771, &_S8772, _S8587); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8773; + (&_S8773)->primal_0 = R_38; + (&_S8773)->differential_0 = _S8768; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8774; + (&_S8774)->primal_0 = _S8599; + (&_S8774)->differential_0 = _S8587; + s_bwd_prop_mul_3(&_S8773, &_S8774, _S8587); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8775; + (&_S8775)->primal_0 = R_38; + (&_S8775)->differential_0 = _S8768; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8776; + (&_S8776)->primal_0 = _S8604; + (&_S8776)->differential_0 = _S8587; + s_bwd_prop_mul_3(&_S8775, &_S8776, _S8587); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8777; + (&_S8777)->primal_0 = R_38; + (&_S8777)->differential_0 = _S8768; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8778; + (&_S8778)->primal_0 = _S8601; + (&_S8778)->differential_0 = _S8587; + s_bwd_prop_mul_3(&_S8777, &_S8778, _S8587); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8779; + (&_S8779)->primal_0 = R_38; + (&_S8779)->differential_0 = _S8768; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8780; + (&_S8780)->primal_0 = _S8598; + (&_S8780)->differential_0 = _S8587; + s_bwd_prop_mul_3(&_S8779, &_S8780, _S8587); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8781; + (&_S8781)->primal_0 = R_38; + (&_S8781)->differential_0 = _S8768; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8782; + (&_S8782)->primal_0 = _S8617.p_0[0U]; + (&_S8782)->differential_0 = _S8587; + s_bwd_prop_mul_3(&_S8781, &_S8782, _S8587); + float3 _S8783 = - _S8770.differential_0 + _S8776.differential_0; + float3 _S8784 = _S8681 * _S8783; + float3 _S8785 = _S8591.rows[2U] * _S8783; + float _S8786 = _S8596 * (_S8785.x + _S8785.y + _S8785.z); + float3 _S8787 = - _S8772.differential_0 + _S8778.differential_0; + float3 _S8788 = _S8680 * _S8787; + float3 _S8789 = _S8591.rows[1U] * _S8787; + float _S8790 = _S8596 * (_S8789.x + _S8789.y + _S8789.z); + float3 _S8791 = - _S8774.differential_0 + _S8780.differential_0; + float3 _S8792 = _S8679 * _S8791; + float3 _S8793 = _S8591.rows[0U] * _S8791; + float _S8794 = _S8596 * (_S8793.x + _S8793.y + _S8793.z); + Matrix _S8795 = _S8768; + _S8795[2U] = _S8784; + _S8795[1U] = _S8788; + _S8795[0U] = _S8792; + Matrix _S8796 = transpose_3(transpose_3(_S8795)); + float _S8797 = 2.0f * - _S8796.rows[int(2)].z; + float _S8798 = 2.0f * _S8796.rows[int(2)].y; + float _S8799 = 2.0f * _S8796.rows[int(2)].x; + float _S8800 = 2.0f * _S8796.rows[int(1)].z; + float _S8801 = 2.0f * - _S8796.rows[int(1)].y; + float _S8802 = 2.0f * _S8796.rows[int(1)].x; + float _S8803 = 2.0f * _S8796.rows[int(0)].z; + float _S8804 = 2.0f * _S8796.rows[int(0)].y; + float _S8805 = 2.0f * - _S8796.rows[int(0)].x; + float _S8806 = - _S8802 + _S8804; + float _S8807 = _S8799 + - _S8803; + float _S8808 = - _S8798 + _S8800; + float _S8809 = _S8798 + _S8800; + float _S8810 = _S8799 + _S8803; + float _S8811 = _S8802 + _S8804; + float _S8812 = _S8589.w * (_S8801 + _S8805); + float _S8813 = _S8589.z * (_S8797 + _S8805); + float _S8814 = _S8589.y * (_S8797 + _S8801); + float _S8815 = _S8589.x * _S8806 + _S8589.z * _S8809 + _S8589.y * _S8810 + _S8812 + _S8812; + float _S8816 = _S8589.x * _S8807 + _S8589.w * _S8809 + _S8589.y * _S8811 + _S8813 + _S8813; + float _S8817 = _S8589.x * _S8808 + _S8589.w * _S8810 + _S8589.z * _S8811 + _S8814 + _S8814; + float _S8818 = _S8589.w * _S8806 + _S8589.z * _S8807 + _S8589.y * _S8808; + float4 _S8819 = make_float4 (0.0f); + float4 _S8820 = _S8819; + *&((&_S8820)->w) = _S8815; + *&((&_S8820)->z) = _S8816; + *&((&_S8820)->y) = _S8817; + *&((&_S8820)->x) = _S8818; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S8821; + (&_S8821)->primal_0 = quat_38; + (&_S8821)->differential_0 = _S8819; + s_bwd_normalize_impl_0(&_S8821, _S8820); + float3 _S8822 = _S8587; + *&((&_S8822)->z) = _S8786; + *&((&_S8822)->y) = _S8790; + *&((&_S8822)->x) = _S8794; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8823; + (&_S8823)->primal_0 = scale_38; + (&_S8823)->differential_0 = _S8587; + s_bwd_prop_exp_1(&_S8823, _S8822); + float _S8824 = - (eps2d_38 / _S8678); + DiffPair_float_0 _S8825; + (&_S8825)->primal_0 = _S8675; + (&_S8825)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S8825, _S8824); + float _S8826 = - _S8825.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8827; + (&_S8827)->primal_0 = mean_c_38; + (&_S8827)->differential_0 = _S8587; + s_bwd_length_impl_0(&_S8827, v_depth_16); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S8828; + (&_S8828)->primal_0 = R_38; + (&_S8828)->differential_0 = _S8768; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8829; + (&_S8829)->primal_0 = mean_39; + (&_S8829)->differential_0 = _S8587; + s_bwd_prop_mul_3(&_S8828, &_S8829, _S8827.differential_0); + Matrix _S8830 = _S8769.differential_0 + _S8771.differential_0 + _S8773.differential_0 + _S8775.differential_0 + _S8777.differential_0 + _S8779.differential_0 + _S8781.differential_0 + _S8828.differential_0; + float _S8831 = _S8826 + _S8727.differential_0; + float3 _S8832 = _S8823.differential_0 + _S8726.differential_0; + *v_mean_16 = *v_mean_16 + (_S8770.differential_0 + _S8776.differential_0 + _S8772.differential_0 + _S8778.differential_0 + _S8774.differential_0 + _S8780.differential_0 + _S8829.differential_0 + _S8725.differential_0); + *v_quat_16 = *v_quat_16 + _S8821.differential_0; + *v_scale_16 = *v_scale_16 + _S8832; + *v_in_opacity_16 = *v_in_opacity_16 + _S8831; + *v_R_16 = *v_R_16 + _S8830; + *v_t_16 = *v_t_16 + _S8827.differential_0; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgut_fisheye_prism_projection_Intermediates_0 +{ + float2 _S8833; + float2 _S8834; + float2 _S8835; + float2 _S8836; + float2 _S8837; + float2 _S8838; + float2 _S8839; +}; + +inline __device__ void projection_3dgut_fisheye_prism_vjp(bool antialiased_39, float3 mean_40, float4 quat_39, float3 scale_39, float in_opacity_39, Matrix R_39, float3 t_39, float fx_52, float fy_52, float cx_43, float cy_43, FixedArray dist_coeffs_51, uint image_width_39, uint image_height_39, float2 v_mean2d_17, float v_depth_17, float3 v_conic_17, float v_opacity_17, float3 * v_mean_17, float4 * v_quat_17, float3 * v_scale_17, float * v_in_opacity_17, Matrix * v_R_17, float3 * v_t_17) +{ + float2 _S8840 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_fisheye_prism_projection_Intermediates_0 _S8841; + (&_S8841)->_S8833 = _S8840; + (&_S8841)->_S8834 = _S8840; + (&_S8841)->_S8835 = _S8840; + (&_S8841)->_S8836 = _S8840; + (&_S8841)->_S8837 = _S8840; + (&_S8841)->_S8838 = _S8840; + (&_S8841)->_S8839 = _S8840; + (&_S8841)->_S8833 = _S8840; + (&_S8841)->_S8834 = _S8840; + (&_S8841)->_S8835 = _S8840; + (&_S8841)->_S8836 = _S8840; + (&_S8841)->_S8837 = _S8840; + (&_S8841)->_S8838 = _S8840; + (&_S8841)->_S8839 = _S8840; + float3 _S8842 = make_float3 (0.0f); + float3 _S8843 = s_primal_ctx_exp_1(scale_39); + float4 _S8844 = normalize_0(quat_39); + float _S8845 = _S8844.y; + float x2_39 = _S8845 * _S8845; + float y2_39 = _S8844.z * _S8844.z; + float z2_39 = _S8844.w * _S8844.w; + float xy_39 = _S8844.y * _S8844.z; + float xz_39 = _S8844.y * _S8844.w; + float yz_39 = _S8844.z * _S8844.w; + float wx_39 = _S8844.x * _S8844.y; + float wy_39 = _S8844.x * _S8844.z; + float wz_39 = _S8844.x * _S8844.w; + Matrix _S8846 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_39 + z2_39), 2.0f * (xy_39 + wz_39), 2.0f * (xz_39 - wy_39), 2.0f * (xy_39 - wz_39), 1.0f - 2.0f * (x2_39 + z2_39), 2.0f * (yz_39 + wx_39), 2.0f * (xz_39 + wy_39), 2.0f * (yz_39 - wx_39), 1.0f - 2.0f * (x2_39 + y2_39)))); + FixedArray _S8847 = { + _S8842, _S8842, _S8842, _S8842, _S8842, _S8842, _S8842 + }; + FixedArray _S8848 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + SigmaPoints_0 _S8849; + (&_S8849)->p_0 = _S8847; + (&_S8849)->w_mean_0 = _S8848; + (&_S8849)->w_cov_0 = _S8848; + (&_S8849)->p_0[int(0)] = mean_40; + SigmaPoints_0 _S8850 = _S8849; + (&_S8850)->w_mean_0[int(0)] = 0.0f; + (&_S8850)->w_cov_0[int(0)] = 2.0f; + float _S8851 = s_primal_ctx_sqrt_0(3.0f); + float _S8852 = _S8851 * _S8843.x; + float3 delta_51 = make_float3 (_S8852) * _S8846.rows[0U]; + float3 _S8853 = mean_40 + delta_51; + (&_S8850)->p_0[1U] = _S8853; + float3 _S8854 = mean_40 - delta_51; + (&_S8850)->p_0[4U] = _S8854; + float _S8855 = _S8851 * _S8843.y; + float3 delta_52 = make_float3 (_S8855) * _S8846.rows[1U]; + float3 _S8856 = mean_40 + delta_52; + (&_S8850)->p_0[2U] = _S8856; + float3 _S8857 = mean_40 - delta_52; + (&_S8850)->p_0[5U] = _S8857; + float _S8858 = _S8851 * _S8843.z; + float3 delta_53 = make_float3 (_S8858) * _S8846.rows[2U]; + float3 _S8859 = mean_40 + delta_53; + (&_S8850)->p_0[3U] = _S8859; + float3 _S8860 = mean_40 - delta_53; + (&_S8850)->p_0[6U] = _S8860; + (&_S8850)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S8861 = _S8850; + (&_S8861)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S8862 = _S8861; + (&_S8862)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S8863 = _S8862; + (&_S8863)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S8864 = _S8863; + (&_S8864)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S8865 = _S8864; + (&_S8865)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S8866 = _S8865; + (&_S8866)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S8867 = _S8866; + (&_S8867)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S8868 = _S8867; + (&_S8868)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S8869 = _S8868; + (&_S8869)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S8870 = _S8869; + (&_S8870)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S8871 = _S8870; + (&_S8871)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S8872 = _S8849; + float3 _S8873 = s_primal_ctx_mul_0(R_39, _S8849.p_0[0U]) + t_39; + _S8849 = _S8871; + (&_S8849)->p_0[0U] = _S8873; + SigmaPoints_0 _S8874 = _S8849; + (&_S8849)->p_0[1U] = s_primal_ctx_mul_0(R_39, _S8853) + t_39; + SigmaPoints_0 _S8875 = _S8849; + (&_S8849)->p_0[2U] = s_primal_ctx_mul_0(R_39, _S8856) + t_39; + SigmaPoints_0 _S8876 = _S8849; + (&_S8849)->p_0[3U] = s_primal_ctx_mul_0(R_39, _S8859) + t_39; + SigmaPoints_0 _S8877 = _S8849; + (&_S8849)->p_0[4U] = s_primal_ctx_mul_0(R_39, _S8854) + t_39; + SigmaPoints_0 _S8878 = _S8849; + (&_S8849)->p_0[5U] = s_primal_ctx_mul_0(R_39, _S8857) + t_39; + SigmaPoints_0 _S8879 = _S8849; + (&_S8849)->p_0[6U] = s_primal_ctx_mul_0(R_39, _S8860) + t_39; + SigmaPoints_0 _S8880 = _S8849; + float2 _S8881 = float2 {_S8874.p_0[int(0)].x, _S8874.p_0[int(0)].y}; + float _S8882 = length_0(_S8881); + float _S8883 = _S8874.p_0[int(0)].z; + float _S8884 = s_primal_ctx_atan2_0(_S8882, _S8883); + float k_28; + if(_S8884 < 0.00100000004749745f) + { + k_28 = (1.0f - _S8884 * _S8884 / 3.0f) / _S8883; + } + else + { + k_28 = _S8884 / _S8882; + } + float2 _S8885 = _S8881 * make_float2 (k_28); + FixedArray _S8886 = dist_coeffs_51; + float2 _S8887 = s_primal_ctx_DistThinPrism_distort_0(_S8885, &_S8886); + (&_S8841)->_S8833 = make_float2 (fx_52 * _S8887.x + cx_43, fy_52 * _S8887.y + cy_43); + float2 _S8888 = float2 {_S8875.p_0[int(1)].x, _S8875.p_0[int(1)].y}; + float _S8889 = length_0(_S8888); + float _S8890 = _S8875.p_0[int(1)].z; + float _S8891 = s_primal_ctx_atan2_0(_S8889, _S8890); + if(_S8891 < 0.00100000004749745f) + { + k_28 = (1.0f - _S8891 * _S8891 / 3.0f) / _S8890; + } + else + { + k_28 = _S8891 / _S8889; + } + float2 _S8892 = _S8888 * make_float2 (k_28); + FixedArray _S8893 = dist_coeffs_51; + float2 _S8894 = s_primal_ctx_DistThinPrism_distort_0(_S8892, &_S8893); + (&_S8841)->_S8834 = make_float2 (fx_52 * _S8894.x + cx_43, fy_52 * _S8894.y + cy_43); + float2 _S8895 = float2 {_S8876.p_0[int(2)].x, _S8876.p_0[int(2)].y}; + float _S8896 = length_0(_S8895); + float _S8897 = _S8876.p_0[int(2)].z; + float _S8898 = s_primal_ctx_atan2_0(_S8896, _S8897); + if(_S8898 < 0.00100000004749745f) + { + k_28 = (1.0f - _S8898 * _S8898 / 3.0f) / _S8897; + } + else + { + k_28 = _S8898 / _S8896; + } + float2 _S8899 = _S8895 * make_float2 (k_28); + FixedArray _S8900 = dist_coeffs_51; + float2 _S8901 = s_primal_ctx_DistThinPrism_distort_0(_S8899, &_S8900); + (&_S8841)->_S8835 = make_float2 (fx_52 * _S8901.x + cx_43, fy_52 * _S8901.y + cy_43); + float2 _S8902 = float2 {_S8877.p_0[int(3)].x, _S8877.p_0[int(3)].y}; + float _S8903 = length_0(_S8902); + float _S8904 = _S8877.p_0[int(3)].z; + float _S8905 = s_primal_ctx_atan2_0(_S8903, _S8904); + if(_S8905 < 0.00100000004749745f) + { + k_28 = (1.0f - _S8905 * _S8905 / 3.0f) / _S8904; + } + else + { + k_28 = _S8905 / _S8903; + } + float2 _S8906 = _S8902 * make_float2 (k_28); + FixedArray _S8907 = dist_coeffs_51; + float2 _S8908 = s_primal_ctx_DistThinPrism_distort_0(_S8906, &_S8907); + (&_S8841)->_S8836 = make_float2 (fx_52 * _S8908.x + cx_43, fy_52 * _S8908.y + cy_43); + float2 _S8909 = float2 {_S8878.p_0[int(4)].x, _S8878.p_0[int(4)].y}; + float _S8910 = length_0(_S8909); + float _S8911 = _S8878.p_0[int(4)].z; + float _S8912 = s_primal_ctx_atan2_0(_S8910, _S8911); + if(_S8912 < 0.00100000004749745f) + { + k_28 = (1.0f - _S8912 * _S8912 / 3.0f) / _S8911; + } + else + { + k_28 = _S8912 / _S8910; + } + float2 _S8913 = _S8909 * make_float2 (k_28); + FixedArray _S8914 = dist_coeffs_51; + float2 _S8915 = s_primal_ctx_DistThinPrism_distort_0(_S8913, &_S8914); + (&_S8841)->_S8837 = make_float2 (fx_52 * _S8915.x + cx_43, fy_52 * _S8915.y + cy_43); + float2 _S8916 = float2 {_S8879.p_0[int(5)].x, _S8879.p_0[int(5)].y}; + float _S8917 = length_0(_S8916); + float _S8918 = _S8879.p_0[int(5)].z; + float _S8919 = s_primal_ctx_atan2_0(_S8917, _S8918); + if(_S8919 < 0.00100000004749745f) + { + k_28 = (1.0f - _S8919 * _S8919 / 3.0f) / _S8918; + } + else + { + k_28 = _S8919 / _S8917; + } + float2 _S8920 = _S8916 * make_float2 (k_28); + FixedArray _S8921 = dist_coeffs_51; + float2 _S8922 = s_primal_ctx_DistThinPrism_distort_0(_S8920, &_S8921); + (&_S8841)->_S8838 = make_float2 (fx_52 * _S8922.x + cx_43, fy_52 * _S8922.y + cy_43); + float2 _S8923 = float2 {_S8880.p_0[int(6)].x, _S8880.p_0[int(6)].y}; + float _S8924 = length_0(_S8923); + float _S8925 = _S8880.p_0[int(6)].z; + float _S8926 = s_primal_ctx_atan2_0(_S8924, _S8925); + if(_S8926 < 0.00100000004749745f) + { + k_28 = (1.0f - _S8926 * _S8926 / 3.0f) / _S8925; + } + else + { + k_28 = _S8926 / _S8924; + } + float2 _S8927 = _S8923 * make_float2 (k_28); + FixedArray _S8928 = dist_coeffs_51; + float2 _S8929 = s_primal_ctx_DistThinPrism_distort_0(_S8927, &_S8928); + (&_S8841)->_S8839 = make_float2 (fx_52 * _S8929.x + cx_43, fy_52 * _S8929.y + cy_43); + float3 mean_c_39 = s_primal_ctx_mul_0(R_39, mean_40) + t_39; + float _S8930 = - in_opacity_39; + float _S8931 = 1.0f + s_primal_ctx_exp_0(_S8930); + float _S8932 = 1.0f / _S8931; + float _S8933 = _S8931 * _S8931; + float3 _S8934 = make_float3 (_S8852); + float3 _S8935 = make_float3 (_S8855); + float3 _S8936 = make_float3 (_S8858); + float2 _S8937 = make_float2 (_S8850.w_mean_0[int(1)]) * _S8841._S8834 + make_float2 (_S8862.w_mean_0[int(2)]) * _S8841._S8835 + make_float2 (_S8864.w_mean_0[int(3)]) * _S8841._S8836 + make_float2 (_S8866.w_mean_0[int(4)]) * _S8841._S8837 + make_float2 (_S8868.w_mean_0[int(5)]) * _S8841._S8838 + make_float2 (_S8870.w_mean_0[int(6)]) * _S8841._S8839; + float2 d_119 = _S8841._S8833 - _S8937; + float _S8938 = d_119.x; + float _S8939 = d_119.y; + float _S8940 = _S8938 * _S8939; + float2 d_120 = _S8841._S8834 - _S8937; + float _S8941 = d_120.x; + float _S8942 = d_120.y; + float _S8943 = _S8941 * _S8942; + float2 d_121 = _S8841._S8835 - _S8937; + float _S8944 = d_121.x; + float _S8945 = d_121.y; + float _S8946 = _S8944 * _S8945; + float2 d_122 = _S8841._S8836 - _S8937; + float _S8947 = d_122.x; + float _S8948 = d_122.y; + float _S8949 = _S8947 * _S8948; + float2 d_123 = _S8841._S8837 - _S8937; + float _S8950 = d_123.x; + float _S8951 = d_123.y; + float _S8952 = _S8950 * _S8951; + float2 d_124 = _S8841._S8838 - _S8937; + float _S8953 = d_124.x; + float _S8954 = d_124.y; + float _S8955 = _S8953 * _S8954; + float2 d_125 = _S8841._S8839 - _S8937; + float _S8956 = d_125.x; + float _S8957 = d_125.y; + float _S8958 = _S8956 * _S8957; + Matrix covar2d_28 = makeMatrix (2.0f) * makeMatrix (_S8938 * _S8938, _S8940, _S8940, _S8939 * _S8939) + makeMatrix (_S8861.w_cov_0[int(1)]) * makeMatrix (_S8941 * _S8941, _S8943, _S8943, _S8942 * _S8942) + makeMatrix (_S8863.w_cov_0[int(2)]) * makeMatrix (_S8944 * _S8944, _S8946, _S8946, _S8945 * _S8945) + makeMatrix (_S8865.w_cov_0[int(3)]) * makeMatrix (_S8947 * _S8947, _S8949, _S8949, _S8948 * _S8948) + makeMatrix (_S8867.w_cov_0[int(4)]) * makeMatrix (_S8950 * _S8950, _S8952, _S8952, _S8951 * _S8951) + makeMatrix (_S8869.w_cov_0[int(5)]) * makeMatrix (_S8953 * _S8953, _S8955, _S8955, _S8954 * _S8954) + makeMatrix (_S8871.w_cov_0[int(6)]) * makeMatrix (_S8956 * _S8956, _S8958, _S8958, _S8957 * _S8957); + float eps2d_39; + if(antialiased_39) + { + eps2d_39 = 0.10000000149011612f; + } + else + { + eps2d_39 = 0.30000001192092896f; + } + float _S8959 = covar2d_28.rows[int(0)].y * covar2d_28.rows[int(1)].x; + float det_orig_39 = covar2d_28.rows[int(0)].x * covar2d_28.rows[int(1)].y - _S8959; + float _S8960 = covar2d_28.rows[int(0)].x + eps2d_39; + Matrix _S8961 = covar2d_28; + *&(((&_S8961)->rows + (int(0)))->x) = _S8960; + float _S8962 = covar2d_28.rows[int(1)].y + eps2d_39; + *&(((&_S8961)->rows + (int(1)))->y) = _S8962; + Matrix _S8963 = _S8961; + Matrix _S8964 = _S8961; + float det_blur_39 = _S8960 * _S8962 - _S8959; + float _S8965 = det_orig_39 / det_blur_39; + float _S8966 = det_blur_39 * det_blur_39; + float _S8967 = (F32_max((0.0f), (_S8965))); + float _S8968 = s_primal_ctx_sqrt_0(_S8967); + float invdet_45 = 1.0f / det_blur_39; + float _S8969 = - covar2d_28.rows[int(0)].y; + float _S8970 = - covar2d_28.rows[int(1)].x; + if(antialiased_39) + { + k_28 = _S8932 * _S8968; + } + else + { + k_28 = _S8932; + } + float _S8971 = k_28 / 0.00392156885936856f; + float _S8972 = 2.0f * s_primal_ctx_log_0(_S8971); + float _S8973 = s_primal_ctx_sqrt_0(_S8972); + float _S8974 = _S8963.rows[int(0)].x; + float _S8975 = _S8964.rows[int(1)].y; + float3 campos_18 = - s_primal_ctx_mul_0(transpose_3(R_39), t_39); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8976; + (&_S8976)->primal_0 = mean_40; + (&_S8976)->differential_0 = _S8842; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8977; + (&_S8977)->primal_0 = scale_39; + (&_S8977)->differential_0 = _S8842; + DiffPair_float_0 _S8978; + (&_S8978)->primal_0 = in_opacity_39; + (&_S8978)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8979; + (&_S8979)->primal_0 = campos_18; + (&_S8979)->differential_0 = _S8842; + s_bwd_prop_view_radius_3dgs_0(&_S8976, &_S8977, &_S8978, &_S8979, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8980 = _S8976; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S8981 = _S8977; + DiffPair_float_0 _S8982 = _S8978; + float2 _S8983 = _S8840; + *&((&_S8983)->y) = v_conic_17.z; + float2 _S8984 = _S8840; + *&((&_S8984)->y) = v_conic_17.y; + *&((&_S8984)->x) = v_conic_17.x; + DiffPair_float_0 _S8985; + (&_S8985)->primal_0 = _S8975; + (&_S8985)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8985, 0.0f); + DiffPair_float_0 _S8986; + (&_S8986)->primal_0 = _S8974; + (&_S8986)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8986, 0.0f); + DiffPair_float_0 _S8987; + (&_S8987)->primal_0 = 3.32999992370605469f; + (&_S8987)->differential_0 = 0.0f; + DiffPair_float_0 _S8988; + (&_S8988)->primal_0 = _S8973; + (&_S8988)->differential_0 = 0.0f; + _d_min_0(&_S8987, &_S8988, 0.0f); + DiffPair_float_0 _S8989; + (&_S8989)->primal_0 = _S8972; + (&_S8989)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S8989, _S8988.differential_0); + float _S8990 = 2.0f * _S8989.differential_0; + DiffPair_float_0 _S8991; + (&_S8991)->primal_0 = _S8971; + (&_S8991)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S8991, _S8990); + float _S8992 = v_opacity_17 + 254.9999847412109375f * _S8991.differential_0; + Matrix _S8993 = makeMatrix (0.0f); + Matrix _S8994 = _S8993; + _S8994[int(1)] = _S8983; + _S8994[int(0)] = _S8984; + Matrix _S8995 = _S8994; + float2 _S8996 = make_float2 (0.0f, _S8985.differential_0); + float2 _S8997 = make_float2 (_S8986.differential_0, 0.0f); + if(antialiased_39) + { + float _S8998 = _S8968 * _S8992; + k_28 = _S8932 * _S8992; + eps2d_39 = _S8998; + } + else + { + k_28 = 0.0f; + eps2d_39 = _S8992; + } + float _S8999 = invdet_45 * _S8995.rows[int(1)].y; + float _S9000 = - (invdet_45 * _S8995.rows[int(1)].x); + float _S9001 = - (invdet_45 * _S8995.rows[int(0)].y); + float _S9002 = invdet_45 * _S8995.rows[int(0)].x; + float _S9003 = - ((_S8960 * _S8995.rows[int(1)].y + _S8970 * _S8995.rows[int(1)].x + _S8969 * _S8995.rows[int(0)].y + _S8962 * _S8995.rows[int(0)].x) / _S8966); + DiffPair_float_0 _S9004; + (&_S9004)->primal_0 = _S8967; + (&_S9004)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9004, k_28); + DiffPair_float_0 _S9005; + (&_S9005)->primal_0 = 0.0f; + (&_S9005)->differential_0 = 0.0f; + DiffPair_float_0 _S9006; + (&_S9006)->primal_0 = _S8965; + (&_S9006)->differential_0 = 0.0f; + _d_max_0(&_S9005, &_S9006, _S9004.differential_0); + float _S9007 = _S9006.differential_0 / _S8966; + float s_diff_det_orig_T_17 = det_blur_39 * _S9007; + float _S9008 = det_orig_39 * - _S9007 + _S9003; + float _S9009 = - _S9008; + float _S9010 = _S8960 * _S9008; + float _S9011 = _S8962 * _S9008; + Matrix _S9012 = _S8993; + _S9012[int(1)] = _S8996; + _S9012[int(0)] = _S8997; + float _S9013 = _S9011 + _S9012.rows[int(0)].x + _S8999; + float _S9014 = _S9009 + - s_diff_det_orig_T_17; + float _S9015 = covar2d_28.rows[int(0)].y * _S9014 + _S9000; + float _S9016 = covar2d_28.rows[int(1)].x * _S9014 + _S9001; + float _S9017 = covar2d_28.rows[int(1)].y * s_diff_det_orig_T_17; + float _S9018 = _S9010 + _S9012.rows[int(1)].y + _S9002 + covar2d_28.rows[int(0)].x * s_diff_det_orig_T_17; + float2 _S9019 = _S8840; + *&((&_S9019)->x) = _S9015; + *&((&_S9019)->y) = _S9018; + float _S9020 = _S9013 + _S9017; + float2 _S9021 = _S8840; + *&((&_S9021)->y) = _S9016; + *&((&_S9021)->x) = _S9020; + Matrix _S9022 = _S8993; + _S9022[int(1)] = _S9019; + _S9022[int(0)] = _S9021; + Matrix _S9023 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9024; + (&_S9024)->primal_0 = R_39; + (&_S9024)->differential_0 = _S9023; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9025; + (&_S9025)->primal_0 = _S8860; + (&_S9025)->differential_0 = _S8842; + s_bwd_prop_mul_3(&_S9024, &_S9025, _S8842); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9026; + (&_S9026)->primal_0 = R_39; + (&_S9026)->differential_0 = _S9023; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9027; + (&_S9027)->primal_0 = _S8857; + (&_S9027)->differential_0 = _S8842; + s_bwd_prop_mul_3(&_S9026, &_S9027, _S8842); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9028; + (&_S9028)->primal_0 = R_39; + (&_S9028)->differential_0 = _S9023; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9029; + (&_S9029)->primal_0 = _S8854; + (&_S9029)->differential_0 = _S8842; + s_bwd_prop_mul_3(&_S9028, &_S9029, _S8842); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9030; + (&_S9030)->primal_0 = R_39; + (&_S9030)->differential_0 = _S9023; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9031; + (&_S9031)->primal_0 = _S8859; + (&_S9031)->differential_0 = _S8842; + s_bwd_prop_mul_3(&_S9030, &_S9031, _S8842); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9032; + (&_S9032)->primal_0 = R_39; + (&_S9032)->differential_0 = _S9023; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9033; + (&_S9033)->primal_0 = _S8856; + (&_S9033)->differential_0 = _S8842; + s_bwd_prop_mul_3(&_S9032, &_S9033, _S8842); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9034; + (&_S9034)->primal_0 = R_39; + (&_S9034)->differential_0 = _S9023; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9035; + (&_S9035)->primal_0 = _S8853; + (&_S9035)->differential_0 = _S8842; + s_bwd_prop_mul_3(&_S9034, &_S9035, _S8842); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9036; + (&_S9036)->primal_0 = R_39; + (&_S9036)->differential_0 = _S9023; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9037; + (&_S9037)->primal_0 = _S8872.p_0[0U]; + (&_S9037)->differential_0 = _S8842; + s_bwd_prop_mul_3(&_S9036, &_S9037, _S8842); + float3 _S9038 = - _S9025.differential_0 + _S9031.differential_0; + float3 _S9039 = _S8936 * _S9038; + float3 _S9040 = _S8846.rows[2U] * _S9038; + float _S9041 = _S8851 * (_S9040.x + _S9040.y + _S9040.z); + float3 _S9042 = - _S9027.differential_0 + _S9033.differential_0; + float3 _S9043 = _S8935 * _S9042; + float3 _S9044 = _S8846.rows[1U] * _S9042; + float _S9045 = _S8851 * (_S9044.x + _S9044.y + _S9044.z); + float3 _S9046 = - _S9029.differential_0 + _S9035.differential_0; + float3 _S9047 = _S8934 * _S9046; + float3 _S9048 = _S8846.rows[0U] * _S9046; + float _S9049 = _S8851 * (_S9048.x + _S9048.y + _S9048.z); + Matrix _S9050 = _S9023; + _S9050[2U] = _S9039; + _S9050[1U] = _S9043; + _S9050[0U] = _S9047; + Matrix _S9051 = transpose_3(transpose_3(_S9050)); + float _S9052 = 2.0f * - _S9051.rows[int(2)].z; + float _S9053 = 2.0f * _S9051.rows[int(2)].y; + float _S9054 = 2.0f * _S9051.rows[int(2)].x; + float _S9055 = 2.0f * _S9051.rows[int(1)].z; + float _S9056 = 2.0f * - _S9051.rows[int(1)].y; + float _S9057 = 2.0f * _S9051.rows[int(1)].x; + float _S9058 = 2.0f * _S9051.rows[int(0)].z; + float _S9059 = 2.0f * _S9051.rows[int(0)].y; + float _S9060 = 2.0f * - _S9051.rows[int(0)].x; + float _S9061 = - _S9057 + _S9059; + float _S9062 = _S9054 + - _S9058; + float _S9063 = - _S9053 + _S9055; + float _S9064 = _S9053 + _S9055; + float _S9065 = _S9054 + _S9058; + float _S9066 = _S9057 + _S9059; + float _S9067 = _S8844.w * (_S9056 + _S9060); + float _S9068 = _S8844.z * (_S9052 + _S9060); + float _S9069 = _S8844.y * (_S9052 + _S9056); + float _S9070 = _S8844.x * _S9061 + _S8844.z * _S9064 + _S8844.y * _S9065 + _S9067 + _S9067; + float _S9071 = _S8844.x * _S9062 + _S8844.w * _S9064 + _S8844.y * _S9066 + _S9068 + _S9068; + float _S9072 = _S8844.x * _S9063 + _S8844.w * _S9065 + _S8844.z * _S9066 + _S9069 + _S9069; + float _S9073 = _S8844.w * _S9061 + _S8844.z * _S9062 + _S8844.y * _S9063; + float4 _S9074 = make_float4 (0.0f); + float4 _S9075 = _S9074; + *&((&_S9075)->w) = _S9070; + *&((&_S9075)->z) = _S9071; + *&((&_S9075)->y) = _S9072; + *&((&_S9075)->x) = _S9073; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S9076; + (&_S9076)->primal_0 = quat_39; + (&_S9076)->differential_0 = _S9074; + s_bwd_normalize_impl_0(&_S9076, _S9075); + float3 _S9077 = _S8842; + *&((&_S9077)->z) = _S9041; + *&((&_S9077)->y) = _S9045; + *&((&_S9077)->x) = _S9049; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9078; + (&_S9078)->primal_0 = scale_39; + (&_S9078)->differential_0 = _S8842; + s_bwd_prop_exp_1(&_S9078, _S9077); + float _S9079 = - (eps2d_39 / _S8933); + DiffPair_float_0 _S9080; + (&_S9080)->primal_0 = _S8930; + (&_S9080)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S9080, _S9079); + float _S9081 = - _S9080.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9082; + (&_S9082)->primal_0 = mean_c_39; + (&_S9082)->differential_0 = _S8842; + s_bwd_length_impl_0(&_S9082, v_depth_17); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9083; + (&_S9083)->primal_0 = R_39; + (&_S9083)->differential_0 = _S9023; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9084; + (&_S9084)->primal_0 = mean_40; + (&_S9084)->differential_0 = _S8842; + s_bwd_prop_mul_3(&_S9083, &_S9084, _S9082.differential_0); + Matrix _S9085 = _S9024.differential_0 + _S9026.differential_0 + _S9028.differential_0 + _S9030.differential_0 + _S9032.differential_0 + _S9034.differential_0 + _S9036.differential_0 + _S9083.differential_0; + float _S9086 = _S9081 + _S8982.differential_0; + float3 _S9087 = _S9078.differential_0 + _S8981.differential_0; + *v_mean_17 = *v_mean_17 + (_S9025.differential_0 + _S9031.differential_0 + _S9027.differential_0 + _S9033.differential_0 + _S9029.differential_0 + _S9035.differential_0 + _S9084.differential_0 + _S8980.differential_0); + *v_quat_17 = *v_quat_17 + _S9076.differential_0; + *v_scale_17 = *v_scale_17 + _S9087; + *v_in_opacity_17 = *v_in_opacity_17 + _S9086; + *v_R_17 = *v_R_17 + _S9085; + *v_t_17 = *v_t_17 + _S9082.differential_0; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgut_equisolid_none_projection_Intermediates_0 +{ + float2 _S9088; + float2 _S9089; + float2 _S9090; + float2 _S9091; + float2 _S9092; + float2 _S9093; + float2 _S9094; +}; + +inline __device__ void projection_3dgut_equisolid_none_vjp(bool antialiased_40, float3 mean_41, float4 quat_40, float3 scale_40, float in_opacity_40, Matrix R_40, float3 t_40, float fx_53, float fy_53, float cx_44, float cy_44, FixedArray dist_coeffs_52, uint image_width_40, uint image_height_40, float2 v_mean2d_18, float v_depth_18, float3 v_conic_18, float v_opacity_18, float3 * v_mean_18, float4 * v_quat_18, float3 * v_scale_18, float * v_in_opacity_18, Matrix * v_R_18, float3 * v_t_18) +{ + float2 _S9095 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_equisolid_none_projection_Intermediates_0 _S9096; + (&_S9096)->_S9088 = _S9095; + (&_S9096)->_S9089 = _S9095; + (&_S9096)->_S9090 = _S9095; + (&_S9096)->_S9091 = _S9095; + (&_S9096)->_S9092 = _S9095; + (&_S9096)->_S9093 = _S9095; + (&_S9096)->_S9094 = _S9095; + (&_S9096)->_S9088 = _S9095; + (&_S9096)->_S9089 = _S9095; + (&_S9096)->_S9090 = _S9095; + (&_S9096)->_S9091 = _S9095; + (&_S9096)->_S9092 = _S9095; + (&_S9096)->_S9093 = _S9095; + (&_S9096)->_S9094 = _S9095; + float3 _S9097 = make_float3 (0.0f); + float3 _S9098 = s_primal_ctx_exp_1(scale_40); + float4 _S9099 = normalize_0(quat_40); + float _S9100 = _S9099.y; + float x2_40 = _S9100 * _S9100; + float y2_40 = _S9099.z * _S9099.z; + float z2_40 = _S9099.w * _S9099.w; + float xy_40 = _S9099.y * _S9099.z; + float xz_40 = _S9099.y * _S9099.w; + float yz_40 = _S9099.z * _S9099.w; + float wx_40 = _S9099.x * _S9099.y; + float wy_40 = _S9099.x * _S9099.z; + float wz_40 = _S9099.x * _S9099.w; + Matrix _S9101 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_40 + z2_40), 2.0f * (xy_40 + wz_40), 2.0f * (xz_40 - wy_40), 2.0f * (xy_40 - wz_40), 1.0f - 2.0f * (x2_40 + z2_40), 2.0f * (yz_40 + wx_40), 2.0f * (xz_40 + wy_40), 2.0f * (yz_40 - wx_40), 1.0f - 2.0f * (x2_40 + y2_40)))); + FixedArray _S9102 = { + _S9097, _S9097, _S9097, _S9097, _S9097, _S9097, _S9097 + }; + FixedArray _S9103 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + SigmaPoints_0 _S9104; + (&_S9104)->p_0 = _S9102; + (&_S9104)->w_mean_0 = _S9103; + (&_S9104)->w_cov_0 = _S9103; + (&_S9104)->p_0[int(0)] = mean_41; + SigmaPoints_0 _S9105 = _S9104; + (&_S9105)->w_mean_0[int(0)] = 0.0f; + (&_S9105)->w_cov_0[int(0)] = 2.0f; + float _S9106 = s_primal_ctx_sqrt_0(3.0f); + float _S9107 = _S9106 * _S9098.x; + float3 delta_54 = make_float3 (_S9107) * _S9101.rows[0U]; + float3 _S9108 = mean_41 + delta_54; + (&_S9105)->p_0[1U] = _S9108; + float3 _S9109 = mean_41 - delta_54; + (&_S9105)->p_0[4U] = _S9109; + float _S9110 = _S9106 * _S9098.y; + float3 delta_55 = make_float3 (_S9110) * _S9101.rows[1U]; + float3 _S9111 = mean_41 + delta_55; + (&_S9105)->p_0[2U] = _S9111; + float3 _S9112 = mean_41 - delta_55; + (&_S9105)->p_0[5U] = _S9112; + float _S9113 = _S9106 * _S9098.z; + float3 delta_56 = make_float3 (_S9113) * _S9101.rows[2U]; + float3 _S9114 = mean_41 + delta_56; + (&_S9105)->p_0[3U] = _S9114; + float3 _S9115 = mean_41 - delta_56; + (&_S9105)->p_0[6U] = _S9115; + (&_S9105)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S9116 = _S9105; + (&_S9116)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S9117 = _S9116; + (&_S9117)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S9118 = _S9117; + (&_S9118)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S9119 = _S9118; + (&_S9119)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S9120 = _S9119; + (&_S9120)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S9121 = _S9120; + (&_S9121)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S9122 = _S9121; + (&_S9122)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S9123 = _S9122; + (&_S9123)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S9124 = _S9123; + (&_S9124)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S9125 = _S9124; + (&_S9125)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S9126 = _S9125; + (&_S9126)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S9127 = _S9104; + float3 _S9128 = s_primal_ctx_mul_0(R_40, _S9104.p_0[0U]) + t_40; + _S9104 = _S9126; + (&_S9104)->p_0[0U] = _S9128; + SigmaPoints_0 _S9129 = _S9104; + (&_S9104)->p_0[1U] = s_primal_ctx_mul_0(R_40, _S9108) + t_40; + SigmaPoints_0 _S9130 = _S9104; + (&_S9104)->p_0[2U] = s_primal_ctx_mul_0(R_40, _S9111) + t_40; + SigmaPoints_0 _S9131 = _S9104; + (&_S9104)->p_0[3U] = s_primal_ctx_mul_0(R_40, _S9114) + t_40; + SigmaPoints_0 _S9132 = _S9104; + (&_S9104)->p_0[4U] = s_primal_ctx_mul_0(R_40, _S9109) + t_40; + SigmaPoints_0 _S9133 = _S9104; + (&_S9104)->p_0[5U] = s_primal_ctx_mul_0(R_40, _S9112) + t_40; + SigmaPoints_0 _S9134 = _S9104; + (&_S9104)->p_0[6U] = s_primal_ctx_mul_0(R_40, _S9115) + t_40; + SigmaPoints_0 _S9135 = _S9104; + float2 _S9136 = float2 {_S9129.p_0[int(0)].x, _S9129.p_0[int(0)].y}; + float _S9137 = length_0(_S9136); + float _S9138 = _S9129.p_0[int(0)].z; + float _S9139 = s_primal_ctx_atan2_0(_S9137, _S9138); + float k_29; + if(_S9137 < 9.99999997475242708e-07f) + { + k_29 = (1.0f - _S9139 * _S9139 / 24.0f) / _S9138; + } + else + { + k_29 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9139) / _S9137; + } + float2 _S9140 = _S9136 * make_float2 (k_29); + FixedArray _S9141 = dist_coeffs_52; + float2 _S9142 = s_primal_ctx_DistNone_distort_0(_S9140, &_S9141); + (&_S9096)->_S9088 = make_float2 (fx_53 * _S9142.x + cx_44, fy_53 * _S9142.y + cy_44); + float2 _S9143 = float2 {_S9130.p_0[int(1)].x, _S9130.p_0[int(1)].y}; + float _S9144 = length_0(_S9143); + float _S9145 = _S9130.p_0[int(1)].z; + float _S9146 = s_primal_ctx_atan2_0(_S9144, _S9145); + if(_S9144 < 9.99999997475242708e-07f) + { + k_29 = (1.0f - _S9146 * _S9146 / 24.0f) / _S9145; + } + else + { + k_29 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9146) / _S9144; + } + float2 _S9147 = _S9143 * make_float2 (k_29); + FixedArray _S9148 = dist_coeffs_52; + float2 _S9149 = s_primal_ctx_DistNone_distort_0(_S9147, &_S9148); + (&_S9096)->_S9089 = make_float2 (fx_53 * _S9149.x + cx_44, fy_53 * _S9149.y + cy_44); + float2 _S9150 = float2 {_S9131.p_0[int(2)].x, _S9131.p_0[int(2)].y}; + float _S9151 = length_0(_S9150); + float _S9152 = _S9131.p_0[int(2)].z; + float _S9153 = s_primal_ctx_atan2_0(_S9151, _S9152); + if(_S9151 < 9.99999997475242708e-07f) + { + k_29 = (1.0f - _S9153 * _S9153 / 24.0f) / _S9152; + } + else + { + k_29 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9153) / _S9151; + } + float2 _S9154 = _S9150 * make_float2 (k_29); + FixedArray _S9155 = dist_coeffs_52; + float2 _S9156 = s_primal_ctx_DistNone_distort_0(_S9154, &_S9155); + (&_S9096)->_S9090 = make_float2 (fx_53 * _S9156.x + cx_44, fy_53 * _S9156.y + cy_44); + float2 _S9157 = float2 {_S9132.p_0[int(3)].x, _S9132.p_0[int(3)].y}; + float _S9158 = length_0(_S9157); + float _S9159 = _S9132.p_0[int(3)].z; + float _S9160 = s_primal_ctx_atan2_0(_S9158, _S9159); + if(_S9158 < 9.99999997475242708e-07f) + { + k_29 = (1.0f - _S9160 * _S9160 / 24.0f) / _S9159; + } + else + { + k_29 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9160) / _S9158; + } + float2 _S9161 = _S9157 * make_float2 (k_29); + FixedArray _S9162 = dist_coeffs_52; + float2 _S9163 = s_primal_ctx_DistNone_distort_0(_S9161, &_S9162); + (&_S9096)->_S9091 = make_float2 (fx_53 * _S9163.x + cx_44, fy_53 * _S9163.y + cy_44); + float2 _S9164 = float2 {_S9133.p_0[int(4)].x, _S9133.p_0[int(4)].y}; + float _S9165 = length_0(_S9164); + float _S9166 = _S9133.p_0[int(4)].z; + float _S9167 = s_primal_ctx_atan2_0(_S9165, _S9166); + if(_S9165 < 9.99999997475242708e-07f) + { + k_29 = (1.0f - _S9167 * _S9167 / 24.0f) / _S9166; + } + else + { + k_29 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9167) / _S9165; + } + float2 _S9168 = _S9164 * make_float2 (k_29); + FixedArray _S9169 = dist_coeffs_52; + float2 _S9170 = s_primal_ctx_DistNone_distort_0(_S9168, &_S9169); + (&_S9096)->_S9092 = make_float2 (fx_53 * _S9170.x + cx_44, fy_53 * _S9170.y + cy_44); + float2 _S9171 = float2 {_S9134.p_0[int(5)].x, _S9134.p_0[int(5)].y}; + float _S9172 = length_0(_S9171); + float _S9173 = _S9134.p_0[int(5)].z; + float _S9174 = s_primal_ctx_atan2_0(_S9172, _S9173); + if(_S9172 < 9.99999997475242708e-07f) + { + k_29 = (1.0f - _S9174 * _S9174 / 24.0f) / _S9173; + } + else + { + k_29 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9174) / _S9172; + } + float2 _S9175 = _S9171 * make_float2 (k_29); + FixedArray _S9176 = dist_coeffs_52; + float2 _S9177 = s_primal_ctx_DistNone_distort_0(_S9175, &_S9176); + (&_S9096)->_S9093 = make_float2 (fx_53 * _S9177.x + cx_44, fy_53 * _S9177.y + cy_44); + float2 _S9178 = float2 {_S9135.p_0[int(6)].x, _S9135.p_0[int(6)].y}; + float _S9179 = length_0(_S9178); + float _S9180 = _S9135.p_0[int(6)].z; + float _S9181 = s_primal_ctx_atan2_0(_S9179, _S9180); + if(_S9179 < 9.99999997475242708e-07f) + { + k_29 = (1.0f - _S9181 * _S9181 / 24.0f) / _S9180; + } + else + { + k_29 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9181) / _S9179; + } + float2 _S9182 = _S9178 * make_float2 (k_29); + FixedArray _S9183 = dist_coeffs_52; + float2 _S9184 = s_primal_ctx_DistNone_distort_0(_S9182, &_S9183); + (&_S9096)->_S9094 = make_float2 (fx_53 * _S9184.x + cx_44, fy_53 * _S9184.y + cy_44); + float3 mean_c_40 = s_primal_ctx_mul_0(R_40, mean_41) + t_40; + float _S9185 = - in_opacity_40; + float _S9186 = 1.0f + s_primal_ctx_exp_0(_S9185); + float _S9187 = 1.0f / _S9186; + float _S9188 = _S9186 * _S9186; + float3 _S9189 = make_float3 (_S9107); + float3 _S9190 = make_float3 (_S9110); + float3 _S9191 = make_float3 (_S9113); + float2 _S9192 = make_float2 (_S9105.w_mean_0[int(1)]) * _S9096._S9089 + make_float2 (_S9117.w_mean_0[int(2)]) * _S9096._S9090 + make_float2 (_S9119.w_mean_0[int(3)]) * _S9096._S9091 + make_float2 (_S9121.w_mean_0[int(4)]) * _S9096._S9092 + make_float2 (_S9123.w_mean_0[int(5)]) * _S9096._S9093 + make_float2 (_S9125.w_mean_0[int(6)]) * _S9096._S9094; + float2 d_126 = _S9096._S9088 - _S9192; + float _S9193 = d_126.x; + float _S9194 = d_126.y; + float _S9195 = _S9193 * _S9194; + float2 d_127 = _S9096._S9089 - _S9192; + float _S9196 = d_127.x; + float _S9197 = d_127.y; + float _S9198 = _S9196 * _S9197; + float2 d_128 = _S9096._S9090 - _S9192; + float _S9199 = d_128.x; + float _S9200 = d_128.y; + float _S9201 = _S9199 * _S9200; + float2 d_129 = _S9096._S9091 - _S9192; + float _S9202 = d_129.x; + float _S9203 = d_129.y; + float _S9204 = _S9202 * _S9203; + float2 d_130 = _S9096._S9092 - _S9192; + float _S9205 = d_130.x; + float _S9206 = d_130.y; + float _S9207 = _S9205 * _S9206; + float2 d_131 = _S9096._S9093 - _S9192; + float _S9208 = d_131.x; + float _S9209 = d_131.y; + float _S9210 = _S9208 * _S9209; + float2 d_132 = _S9096._S9094 - _S9192; + float _S9211 = d_132.x; + float _S9212 = d_132.y; + float _S9213 = _S9211 * _S9212; + Matrix covar2d_29 = makeMatrix (2.0f) * makeMatrix (_S9193 * _S9193, _S9195, _S9195, _S9194 * _S9194) + makeMatrix (_S9116.w_cov_0[int(1)]) * makeMatrix (_S9196 * _S9196, _S9198, _S9198, _S9197 * _S9197) + makeMatrix (_S9118.w_cov_0[int(2)]) * makeMatrix (_S9199 * _S9199, _S9201, _S9201, _S9200 * _S9200) + makeMatrix (_S9120.w_cov_0[int(3)]) * makeMatrix (_S9202 * _S9202, _S9204, _S9204, _S9203 * _S9203) + makeMatrix (_S9122.w_cov_0[int(4)]) * makeMatrix (_S9205 * _S9205, _S9207, _S9207, _S9206 * _S9206) + makeMatrix (_S9124.w_cov_0[int(5)]) * makeMatrix (_S9208 * _S9208, _S9210, _S9210, _S9209 * _S9209) + makeMatrix (_S9126.w_cov_0[int(6)]) * makeMatrix (_S9211 * _S9211, _S9213, _S9213, _S9212 * _S9212); + float eps2d_40; + if(antialiased_40) + { + eps2d_40 = 0.10000000149011612f; + } + else + { + eps2d_40 = 0.30000001192092896f; + } + float _S9214 = covar2d_29.rows[int(0)].y * covar2d_29.rows[int(1)].x; + float det_orig_40 = covar2d_29.rows[int(0)].x * covar2d_29.rows[int(1)].y - _S9214; + float _S9215 = covar2d_29.rows[int(0)].x + eps2d_40; + Matrix _S9216 = covar2d_29; + *&(((&_S9216)->rows + (int(0)))->x) = _S9215; + float _S9217 = covar2d_29.rows[int(1)].y + eps2d_40; + *&(((&_S9216)->rows + (int(1)))->y) = _S9217; + Matrix _S9218 = _S9216; + Matrix _S9219 = _S9216; + float det_blur_40 = _S9215 * _S9217 - _S9214; + float _S9220 = det_orig_40 / det_blur_40; + float _S9221 = det_blur_40 * det_blur_40; + float _S9222 = (F32_max((0.0f), (_S9220))); + float _S9223 = s_primal_ctx_sqrt_0(_S9222); + float invdet_46 = 1.0f / det_blur_40; + float _S9224 = - covar2d_29.rows[int(0)].y; + float _S9225 = - covar2d_29.rows[int(1)].x; + if(antialiased_40) + { + k_29 = _S9187 * _S9223; + } + else + { + k_29 = _S9187; + } + float _S9226 = k_29 / 0.00392156885936856f; + float _S9227 = 2.0f * s_primal_ctx_log_0(_S9226); + float _S9228 = s_primal_ctx_sqrt_0(_S9227); + float _S9229 = _S9218.rows[int(0)].x; + float _S9230 = _S9219.rows[int(1)].y; + float3 campos_19 = - s_primal_ctx_mul_0(transpose_3(R_40), t_40); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9231; + (&_S9231)->primal_0 = mean_41; + (&_S9231)->differential_0 = _S9097; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9232; + (&_S9232)->primal_0 = scale_40; + (&_S9232)->differential_0 = _S9097; + DiffPair_float_0 _S9233; + (&_S9233)->primal_0 = in_opacity_40; + (&_S9233)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9234; + (&_S9234)->primal_0 = campos_19; + (&_S9234)->differential_0 = _S9097; + s_bwd_prop_view_radius_3dgs_0(&_S9231, &_S9232, &_S9233, &_S9234, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9235 = _S9231; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9236 = _S9232; + DiffPair_float_0 _S9237 = _S9233; + float2 _S9238 = _S9095; + *&((&_S9238)->y) = v_conic_18.z; + float2 _S9239 = _S9095; + *&((&_S9239)->y) = v_conic_18.y; + *&((&_S9239)->x) = v_conic_18.x; + DiffPair_float_0 _S9240; + (&_S9240)->primal_0 = _S9230; + (&_S9240)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9240, 0.0f); + DiffPair_float_0 _S9241; + (&_S9241)->primal_0 = _S9229; + (&_S9241)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9241, 0.0f); + DiffPair_float_0 _S9242; + (&_S9242)->primal_0 = 3.32999992370605469f; + (&_S9242)->differential_0 = 0.0f; + DiffPair_float_0 _S9243; + (&_S9243)->primal_0 = _S9228; + (&_S9243)->differential_0 = 0.0f; + _d_min_0(&_S9242, &_S9243, 0.0f); + DiffPair_float_0 _S9244; + (&_S9244)->primal_0 = _S9227; + (&_S9244)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9244, _S9243.differential_0); + float _S9245 = 2.0f * _S9244.differential_0; + DiffPair_float_0 _S9246; + (&_S9246)->primal_0 = _S9226; + (&_S9246)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S9246, _S9245); + float _S9247 = v_opacity_18 + 254.9999847412109375f * _S9246.differential_0; + Matrix _S9248 = makeMatrix (0.0f); + Matrix _S9249 = _S9248; + _S9249[int(1)] = _S9238; + _S9249[int(0)] = _S9239; + Matrix _S9250 = _S9249; + float2 _S9251 = make_float2 (0.0f, _S9240.differential_0); + float2 _S9252 = make_float2 (_S9241.differential_0, 0.0f); + if(antialiased_40) + { + float _S9253 = _S9223 * _S9247; + k_29 = _S9187 * _S9247; + eps2d_40 = _S9253; + } + else + { + k_29 = 0.0f; + eps2d_40 = _S9247; + } + float _S9254 = invdet_46 * _S9250.rows[int(1)].y; + float _S9255 = - (invdet_46 * _S9250.rows[int(1)].x); + float _S9256 = - (invdet_46 * _S9250.rows[int(0)].y); + float _S9257 = invdet_46 * _S9250.rows[int(0)].x; + float _S9258 = - ((_S9215 * _S9250.rows[int(1)].y + _S9225 * _S9250.rows[int(1)].x + _S9224 * _S9250.rows[int(0)].y + _S9217 * _S9250.rows[int(0)].x) / _S9221); + DiffPair_float_0 _S9259; + (&_S9259)->primal_0 = _S9222; + (&_S9259)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9259, k_29); + DiffPair_float_0 _S9260; + (&_S9260)->primal_0 = 0.0f; + (&_S9260)->differential_0 = 0.0f; + DiffPair_float_0 _S9261; + (&_S9261)->primal_0 = _S9220; + (&_S9261)->differential_0 = 0.0f; + _d_max_0(&_S9260, &_S9261, _S9259.differential_0); + float _S9262 = _S9261.differential_0 / _S9221; + float s_diff_det_orig_T_18 = det_blur_40 * _S9262; + float _S9263 = det_orig_40 * - _S9262 + _S9258; + float _S9264 = - _S9263; + float _S9265 = _S9215 * _S9263; + float _S9266 = _S9217 * _S9263; + Matrix _S9267 = _S9248; + _S9267[int(1)] = _S9251; + _S9267[int(0)] = _S9252; + float _S9268 = _S9266 + _S9267.rows[int(0)].x + _S9254; + float _S9269 = _S9264 + - s_diff_det_orig_T_18; + float _S9270 = covar2d_29.rows[int(0)].y * _S9269 + _S9255; + float _S9271 = covar2d_29.rows[int(1)].x * _S9269 + _S9256; + float _S9272 = covar2d_29.rows[int(1)].y * s_diff_det_orig_T_18; + float _S9273 = _S9265 + _S9267.rows[int(1)].y + _S9257 + covar2d_29.rows[int(0)].x * s_diff_det_orig_T_18; + float2 _S9274 = _S9095; + *&((&_S9274)->x) = _S9270; + *&((&_S9274)->y) = _S9273; + float _S9275 = _S9268 + _S9272; + float2 _S9276 = _S9095; + *&((&_S9276)->y) = _S9271; + *&((&_S9276)->x) = _S9275; + Matrix _S9277 = _S9248; + _S9277[int(1)] = _S9274; + _S9277[int(0)] = _S9276; + Matrix _S9278 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9279; + (&_S9279)->primal_0 = R_40; + (&_S9279)->differential_0 = _S9278; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9280; + (&_S9280)->primal_0 = _S9115; + (&_S9280)->differential_0 = _S9097; + s_bwd_prop_mul_3(&_S9279, &_S9280, _S9097); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9281; + (&_S9281)->primal_0 = R_40; + (&_S9281)->differential_0 = _S9278; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9282; + (&_S9282)->primal_0 = _S9112; + (&_S9282)->differential_0 = _S9097; + s_bwd_prop_mul_3(&_S9281, &_S9282, _S9097); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9283; + (&_S9283)->primal_0 = R_40; + (&_S9283)->differential_0 = _S9278; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9284; + (&_S9284)->primal_0 = _S9109; + (&_S9284)->differential_0 = _S9097; + s_bwd_prop_mul_3(&_S9283, &_S9284, _S9097); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9285; + (&_S9285)->primal_0 = R_40; + (&_S9285)->differential_0 = _S9278; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9286; + (&_S9286)->primal_0 = _S9114; + (&_S9286)->differential_0 = _S9097; + s_bwd_prop_mul_3(&_S9285, &_S9286, _S9097); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9287; + (&_S9287)->primal_0 = R_40; + (&_S9287)->differential_0 = _S9278; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9288; + (&_S9288)->primal_0 = _S9111; + (&_S9288)->differential_0 = _S9097; + s_bwd_prop_mul_3(&_S9287, &_S9288, _S9097); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9289; + (&_S9289)->primal_0 = R_40; + (&_S9289)->differential_0 = _S9278; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9290; + (&_S9290)->primal_0 = _S9108; + (&_S9290)->differential_0 = _S9097; + s_bwd_prop_mul_3(&_S9289, &_S9290, _S9097); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9291; + (&_S9291)->primal_0 = R_40; + (&_S9291)->differential_0 = _S9278; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9292; + (&_S9292)->primal_0 = _S9127.p_0[0U]; + (&_S9292)->differential_0 = _S9097; + s_bwd_prop_mul_3(&_S9291, &_S9292, _S9097); + float3 _S9293 = - _S9280.differential_0 + _S9286.differential_0; + float3 _S9294 = _S9191 * _S9293; + float3 _S9295 = _S9101.rows[2U] * _S9293; + float _S9296 = _S9106 * (_S9295.x + _S9295.y + _S9295.z); + float3 _S9297 = - _S9282.differential_0 + _S9288.differential_0; + float3 _S9298 = _S9190 * _S9297; + float3 _S9299 = _S9101.rows[1U] * _S9297; + float _S9300 = _S9106 * (_S9299.x + _S9299.y + _S9299.z); + float3 _S9301 = - _S9284.differential_0 + _S9290.differential_0; + float3 _S9302 = _S9189 * _S9301; + float3 _S9303 = _S9101.rows[0U] * _S9301; + float _S9304 = _S9106 * (_S9303.x + _S9303.y + _S9303.z); + Matrix _S9305 = _S9278; + _S9305[2U] = _S9294; + _S9305[1U] = _S9298; + _S9305[0U] = _S9302; + Matrix _S9306 = transpose_3(transpose_3(_S9305)); + float _S9307 = 2.0f * - _S9306.rows[int(2)].z; + float _S9308 = 2.0f * _S9306.rows[int(2)].y; + float _S9309 = 2.0f * _S9306.rows[int(2)].x; + float _S9310 = 2.0f * _S9306.rows[int(1)].z; + float _S9311 = 2.0f * - _S9306.rows[int(1)].y; + float _S9312 = 2.0f * _S9306.rows[int(1)].x; + float _S9313 = 2.0f * _S9306.rows[int(0)].z; + float _S9314 = 2.0f * _S9306.rows[int(0)].y; + float _S9315 = 2.0f * - _S9306.rows[int(0)].x; + float _S9316 = - _S9312 + _S9314; + float _S9317 = _S9309 + - _S9313; + float _S9318 = - _S9308 + _S9310; + float _S9319 = _S9308 + _S9310; + float _S9320 = _S9309 + _S9313; + float _S9321 = _S9312 + _S9314; + float _S9322 = _S9099.w * (_S9311 + _S9315); + float _S9323 = _S9099.z * (_S9307 + _S9315); + float _S9324 = _S9099.y * (_S9307 + _S9311); + float _S9325 = _S9099.x * _S9316 + _S9099.z * _S9319 + _S9099.y * _S9320 + _S9322 + _S9322; + float _S9326 = _S9099.x * _S9317 + _S9099.w * _S9319 + _S9099.y * _S9321 + _S9323 + _S9323; + float _S9327 = _S9099.x * _S9318 + _S9099.w * _S9320 + _S9099.z * _S9321 + _S9324 + _S9324; + float _S9328 = _S9099.w * _S9316 + _S9099.z * _S9317 + _S9099.y * _S9318; + float4 _S9329 = make_float4 (0.0f); + float4 _S9330 = _S9329; + *&((&_S9330)->w) = _S9325; + *&((&_S9330)->z) = _S9326; + *&((&_S9330)->y) = _S9327; + *&((&_S9330)->x) = _S9328; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S9331; + (&_S9331)->primal_0 = quat_40; + (&_S9331)->differential_0 = _S9329; + s_bwd_normalize_impl_0(&_S9331, _S9330); + float3 _S9332 = _S9097; + *&((&_S9332)->z) = _S9296; + *&((&_S9332)->y) = _S9300; + *&((&_S9332)->x) = _S9304; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9333; + (&_S9333)->primal_0 = scale_40; + (&_S9333)->differential_0 = _S9097; + s_bwd_prop_exp_1(&_S9333, _S9332); + float _S9334 = - (eps2d_40 / _S9188); + DiffPair_float_0 _S9335; + (&_S9335)->primal_0 = _S9185; + (&_S9335)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S9335, _S9334); + float _S9336 = - _S9335.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9337; + (&_S9337)->primal_0 = mean_c_40; + (&_S9337)->differential_0 = _S9097; + s_bwd_length_impl_0(&_S9337, v_depth_18); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9338; + (&_S9338)->primal_0 = R_40; + (&_S9338)->differential_0 = _S9278; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9339; + (&_S9339)->primal_0 = mean_41; + (&_S9339)->differential_0 = _S9097; + s_bwd_prop_mul_3(&_S9338, &_S9339, _S9337.differential_0); + Matrix _S9340 = _S9279.differential_0 + _S9281.differential_0 + _S9283.differential_0 + _S9285.differential_0 + _S9287.differential_0 + _S9289.differential_0 + _S9291.differential_0 + _S9338.differential_0; + float _S9341 = _S9336 + _S9237.differential_0; + float3 _S9342 = _S9333.differential_0 + _S9236.differential_0; + *v_mean_18 = *v_mean_18 + (_S9280.differential_0 + _S9286.differential_0 + _S9282.differential_0 + _S9288.differential_0 + _S9284.differential_0 + _S9290.differential_0 + _S9339.differential_0 + _S9235.differential_0); + *v_quat_18 = *v_quat_18 + _S9331.differential_0; + *v_scale_18 = *v_scale_18 + _S9342; + *v_in_opacity_18 = *v_in_opacity_18 + _S9341; + *v_R_18 = *v_R_18 + _S9340; + *v_t_18 = *v_t_18 + _S9337.differential_0; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgut_equisolid_opencv_projection_Intermediates_0 +{ + float2 _S9343; + float2 _S9344; + float2 _S9345; + float2 _S9346; + float2 _S9347; + float2 _S9348; + float2 _S9349; +}; + +inline __device__ void projection_3dgut_equisolid_opencv_vjp(bool antialiased_41, float3 mean_42, float4 quat_41, float3 scale_41, float in_opacity_41, Matrix R_41, float3 t_41, float fx_54, float fy_54, float cx_45, float cy_45, FixedArray dist_coeffs_53, uint image_width_41, uint image_height_41, float2 v_mean2d_19, float v_depth_19, float3 v_conic_19, float v_opacity_19, float3 * v_mean_19, float4 * v_quat_19, float3 * v_scale_19, float * v_in_opacity_19, Matrix * v_R_19, float3 * v_t_19) +{ + float2 _S9350 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_equisolid_opencv_projection_Intermediates_0 _S9351; + (&_S9351)->_S9343 = _S9350; + (&_S9351)->_S9344 = _S9350; + (&_S9351)->_S9345 = _S9350; + (&_S9351)->_S9346 = _S9350; + (&_S9351)->_S9347 = _S9350; + (&_S9351)->_S9348 = _S9350; + (&_S9351)->_S9349 = _S9350; + (&_S9351)->_S9343 = _S9350; + (&_S9351)->_S9344 = _S9350; + (&_S9351)->_S9345 = _S9350; + (&_S9351)->_S9346 = _S9350; + (&_S9351)->_S9347 = _S9350; + (&_S9351)->_S9348 = _S9350; + (&_S9351)->_S9349 = _S9350; + float3 _S9352 = make_float3 (0.0f); + float3 _S9353 = s_primal_ctx_exp_1(scale_41); + float4 _S9354 = normalize_0(quat_41); + float _S9355 = _S9354.y; + float x2_41 = _S9355 * _S9355; + float y2_41 = _S9354.z * _S9354.z; + float z2_41 = _S9354.w * _S9354.w; + float xy_41 = _S9354.y * _S9354.z; + float xz_41 = _S9354.y * _S9354.w; + float yz_41 = _S9354.z * _S9354.w; + float wx_41 = _S9354.x * _S9354.y; + float wy_41 = _S9354.x * _S9354.z; + float wz_41 = _S9354.x * _S9354.w; + Matrix _S9356 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_41 + z2_41), 2.0f * (xy_41 + wz_41), 2.0f * (xz_41 - wy_41), 2.0f * (xy_41 - wz_41), 1.0f - 2.0f * (x2_41 + z2_41), 2.0f * (yz_41 + wx_41), 2.0f * (xz_41 + wy_41), 2.0f * (yz_41 - wx_41), 1.0f - 2.0f * (x2_41 + y2_41)))); + FixedArray _S9357 = { + _S9352, _S9352, _S9352, _S9352, _S9352, _S9352, _S9352 + }; + FixedArray _S9358 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + SigmaPoints_0 _S9359; + (&_S9359)->p_0 = _S9357; + (&_S9359)->w_mean_0 = _S9358; + (&_S9359)->w_cov_0 = _S9358; + (&_S9359)->p_0[int(0)] = mean_42; + SigmaPoints_0 _S9360 = _S9359; + (&_S9360)->w_mean_0[int(0)] = 0.0f; + (&_S9360)->w_cov_0[int(0)] = 2.0f; + float _S9361 = s_primal_ctx_sqrt_0(3.0f); + float _S9362 = _S9361 * _S9353.x; + float3 delta_57 = make_float3 (_S9362) * _S9356.rows[0U]; + float3 _S9363 = mean_42 + delta_57; + (&_S9360)->p_0[1U] = _S9363; + float3 _S9364 = mean_42 - delta_57; + (&_S9360)->p_0[4U] = _S9364; + float _S9365 = _S9361 * _S9353.y; + float3 delta_58 = make_float3 (_S9365) * _S9356.rows[1U]; + float3 _S9366 = mean_42 + delta_58; + (&_S9360)->p_0[2U] = _S9366; + float3 _S9367 = mean_42 - delta_58; + (&_S9360)->p_0[5U] = _S9367; + float _S9368 = _S9361 * _S9353.z; + float3 delta_59 = make_float3 (_S9368) * _S9356.rows[2U]; + float3 _S9369 = mean_42 + delta_59; + (&_S9360)->p_0[3U] = _S9369; + float3 _S9370 = mean_42 - delta_59; + (&_S9360)->p_0[6U] = _S9370; + (&_S9360)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S9371 = _S9360; + (&_S9371)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S9372 = _S9371; + (&_S9372)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S9373 = _S9372; + (&_S9373)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S9374 = _S9373; + (&_S9374)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S9375 = _S9374; + (&_S9375)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S9376 = _S9375; + (&_S9376)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S9377 = _S9376; + (&_S9377)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S9378 = _S9377; + (&_S9378)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S9379 = _S9378; + (&_S9379)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S9380 = _S9379; + (&_S9380)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S9381 = _S9380; + (&_S9381)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S9382 = _S9359; + float3 _S9383 = s_primal_ctx_mul_0(R_41, _S9359.p_0[0U]) + t_41; + _S9359 = _S9381; + (&_S9359)->p_0[0U] = _S9383; + SigmaPoints_0 _S9384 = _S9359; + (&_S9359)->p_0[1U] = s_primal_ctx_mul_0(R_41, _S9363) + t_41; + SigmaPoints_0 _S9385 = _S9359; + (&_S9359)->p_0[2U] = s_primal_ctx_mul_0(R_41, _S9366) + t_41; + SigmaPoints_0 _S9386 = _S9359; + (&_S9359)->p_0[3U] = s_primal_ctx_mul_0(R_41, _S9369) + t_41; + SigmaPoints_0 _S9387 = _S9359; + (&_S9359)->p_0[4U] = s_primal_ctx_mul_0(R_41, _S9364) + t_41; + SigmaPoints_0 _S9388 = _S9359; + (&_S9359)->p_0[5U] = s_primal_ctx_mul_0(R_41, _S9367) + t_41; + SigmaPoints_0 _S9389 = _S9359; + (&_S9359)->p_0[6U] = s_primal_ctx_mul_0(R_41, _S9370) + t_41; + SigmaPoints_0 _S9390 = _S9359; + float2 _S9391 = float2 {_S9384.p_0[int(0)].x, _S9384.p_0[int(0)].y}; + float _S9392 = length_0(_S9391); + float _S9393 = _S9384.p_0[int(0)].z; + float _S9394 = s_primal_ctx_atan2_0(_S9392, _S9393); + float k_30; + if(_S9392 < 9.99999997475242708e-07f) + { + k_30 = (1.0f - _S9394 * _S9394 / 24.0f) / _S9393; + } + else + { + k_30 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9394) / _S9392; + } + float2 _S9395 = _S9391 * make_float2 (k_30); + FixedArray _S9396 = dist_coeffs_53; + float2 _S9397 = s_primal_ctx_DistOpenCV_distort_0(_S9395, &_S9396); + (&_S9351)->_S9343 = make_float2 (fx_54 * _S9397.x + cx_45, fy_54 * _S9397.y + cy_45); + float2 _S9398 = float2 {_S9385.p_0[int(1)].x, _S9385.p_0[int(1)].y}; + float _S9399 = length_0(_S9398); + float _S9400 = _S9385.p_0[int(1)].z; + float _S9401 = s_primal_ctx_atan2_0(_S9399, _S9400); + if(_S9399 < 9.99999997475242708e-07f) + { + k_30 = (1.0f - _S9401 * _S9401 / 24.0f) / _S9400; + } + else + { + k_30 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9401) / _S9399; + } + float2 _S9402 = _S9398 * make_float2 (k_30); + FixedArray _S9403 = dist_coeffs_53; + float2 _S9404 = s_primal_ctx_DistOpenCV_distort_0(_S9402, &_S9403); + (&_S9351)->_S9344 = make_float2 (fx_54 * _S9404.x + cx_45, fy_54 * _S9404.y + cy_45); + float2 _S9405 = float2 {_S9386.p_0[int(2)].x, _S9386.p_0[int(2)].y}; + float _S9406 = length_0(_S9405); + float _S9407 = _S9386.p_0[int(2)].z; + float _S9408 = s_primal_ctx_atan2_0(_S9406, _S9407); + if(_S9406 < 9.99999997475242708e-07f) + { + k_30 = (1.0f - _S9408 * _S9408 / 24.0f) / _S9407; + } + else + { + k_30 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9408) / _S9406; + } + float2 _S9409 = _S9405 * make_float2 (k_30); + FixedArray _S9410 = dist_coeffs_53; + float2 _S9411 = s_primal_ctx_DistOpenCV_distort_0(_S9409, &_S9410); + (&_S9351)->_S9345 = make_float2 (fx_54 * _S9411.x + cx_45, fy_54 * _S9411.y + cy_45); + float2 _S9412 = float2 {_S9387.p_0[int(3)].x, _S9387.p_0[int(3)].y}; + float _S9413 = length_0(_S9412); + float _S9414 = _S9387.p_0[int(3)].z; + float _S9415 = s_primal_ctx_atan2_0(_S9413, _S9414); + if(_S9413 < 9.99999997475242708e-07f) + { + k_30 = (1.0f - _S9415 * _S9415 / 24.0f) / _S9414; + } + else + { + k_30 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9415) / _S9413; + } + float2 _S9416 = _S9412 * make_float2 (k_30); + FixedArray _S9417 = dist_coeffs_53; + float2 _S9418 = s_primal_ctx_DistOpenCV_distort_0(_S9416, &_S9417); + (&_S9351)->_S9346 = make_float2 (fx_54 * _S9418.x + cx_45, fy_54 * _S9418.y + cy_45); + float2 _S9419 = float2 {_S9388.p_0[int(4)].x, _S9388.p_0[int(4)].y}; + float _S9420 = length_0(_S9419); + float _S9421 = _S9388.p_0[int(4)].z; + float _S9422 = s_primal_ctx_atan2_0(_S9420, _S9421); + if(_S9420 < 9.99999997475242708e-07f) + { + k_30 = (1.0f - _S9422 * _S9422 / 24.0f) / _S9421; + } + else + { + k_30 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9422) / _S9420; + } + float2 _S9423 = _S9419 * make_float2 (k_30); + FixedArray _S9424 = dist_coeffs_53; + float2 _S9425 = s_primal_ctx_DistOpenCV_distort_0(_S9423, &_S9424); + (&_S9351)->_S9347 = make_float2 (fx_54 * _S9425.x + cx_45, fy_54 * _S9425.y + cy_45); + float2 _S9426 = float2 {_S9389.p_0[int(5)].x, _S9389.p_0[int(5)].y}; + float _S9427 = length_0(_S9426); + float _S9428 = _S9389.p_0[int(5)].z; + float _S9429 = s_primal_ctx_atan2_0(_S9427, _S9428); + if(_S9427 < 9.99999997475242708e-07f) + { + k_30 = (1.0f - _S9429 * _S9429 / 24.0f) / _S9428; + } + else + { + k_30 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9429) / _S9427; + } + float2 _S9430 = _S9426 * make_float2 (k_30); + FixedArray _S9431 = dist_coeffs_53; + float2 _S9432 = s_primal_ctx_DistOpenCV_distort_0(_S9430, &_S9431); + (&_S9351)->_S9348 = make_float2 (fx_54 * _S9432.x + cx_45, fy_54 * _S9432.y + cy_45); + float2 _S9433 = float2 {_S9390.p_0[int(6)].x, _S9390.p_0[int(6)].y}; + float _S9434 = length_0(_S9433); + float _S9435 = _S9390.p_0[int(6)].z; + float _S9436 = s_primal_ctx_atan2_0(_S9434, _S9435); + if(_S9434 < 9.99999997475242708e-07f) + { + k_30 = (1.0f - _S9436 * _S9436 / 24.0f) / _S9435; + } + else + { + k_30 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9436) / _S9434; + } + float2 _S9437 = _S9433 * make_float2 (k_30); + FixedArray _S9438 = dist_coeffs_53; + float2 _S9439 = s_primal_ctx_DistOpenCV_distort_0(_S9437, &_S9438); + (&_S9351)->_S9349 = make_float2 (fx_54 * _S9439.x + cx_45, fy_54 * _S9439.y + cy_45); + float3 mean_c_41 = s_primal_ctx_mul_0(R_41, mean_42) + t_41; + float _S9440 = - in_opacity_41; + float _S9441 = 1.0f + s_primal_ctx_exp_0(_S9440); + float _S9442 = 1.0f / _S9441; + float _S9443 = _S9441 * _S9441; + float3 _S9444 = make_float3 (_S9362); + float3 _S9445 = make_float3 (_S9365); + float3 _S9446 = make_float3 (_S9368); + float2 _S9447 = make_float2 (_S9360.w_mean_0[int(1)]) * _S9351._S9344 + make_float2 (_S9372.w_mean_0[int(2)]) * _S9351._S9345 + make_float2 (_S9374.w_mean_0[int(3)]) * _S9351._S9346 + make_float2 (_S9376.w_mean_0[int(4)]) * _S9351._S9347 + make_float2 (_S9378.w_mean_0[int(5)]) * _S9351._S9348 + make_float2 (_S9380.w_mean_0[int(6)]) * _S9351._S9349; + float2 d_133 = _S9351._S9343 - _S9447; + float _S9448 = d_133.x; + float _S9449 = d_133.y; + float _S9450 = _S9448 * _S9449; + float2 d_134 = _S9351._S9344 - _S9447; + float _S9451 = d_134.x; + float _S9452 = d_134.y; + float _S9453 = _S9451 * _S9452; + float2 d_135 = _S9351._S9345 - _S9447; + float _S9454 = d_135.x; + float _S9455 = d_135.y; + float _S9456 = _S9454 * _S9455; + float2 d_136 = _S9351._S9346 - _S9447; + float _S9457 = d_136.x; + float _S9458 = d_136.y; + float _S9459 = _S9457 * _S9458; + float2 d_137 = _S9351._S9347 - _S9447; + float _S9460 = d_137.x; + float _S9461 = d_137.y; + float _S9462 = _S9460 * _S9461; + float2 d_138 = _S9351._S9348 - _S9447; + float _S9463 = d_138.x; + float _S9464 = d_138.y; + float _S9465 = _S9463 * _S9464; + float2 d_139 = _S9351._S9349 - _S9447; + float _S9466 = d_139.x; + float _S9467 = d_139.y; + float _S9468 = _S9466 * _S9467; + Matrix covar2d_30 = makeMatrix (2.0f) * makeMatrix (_S9448 * _S9448, _S9450, _S9450, _S9449 * _S9449) + makeMatrix (_S9371.w_cov_0[int(1)]) * makeMatrix (_S9451 * _S9451, _S9453, _S9453, _S9452 * _S9452) + makeMatrix (_S9373.w_cov_0[int(2)]) * makeMatrix (_S9454 * _S9454, _S9456, _S9456, _S9455 * _S9455) + makeMatrix (_S9375.w_cov_0[int(3)]) * makeMatrix (_S9457 * _S9457, _S9459, _S9459, _S9458 * _S9458) + makeMatrix (_S9377.w_cov_0[int(4)]) * makeMatrix (_S9460 * _S9460, _S9462, _S9462, _S9461 * _S9461) + makeMatrix (_S9379.w_cov_0[int(5)]) * makeMatrix (_S9463 * _S9463, _S9465, _S9465, _S9464 * _S9464) + makeMatrix (_S9381.w_cov_0[int(6)]) * makeMatrix (_S9466 * _S9466, _S9468, _S9468, _S9467 * _S9467); + float eps2d_41; + if(antialiased_41) + { + eps2d_41 = 0.10000000149011612f; + } + else + { + eps2d_41 = 0.30000001192092896f; + } + float _S9469 = covar2d_30.rows[int(0)].y * covar2d_30.rows[int(1)].x; + float det_orig_41 = covar2d_30.rows[int(0)].x * covar2d_30.rows[int(1)].y - _S9469; + float _S9470 = covar2d_30.rows[int(0)].x + eps2d_41; + Matrix _S9471 = covar2d_30; + *&(((&_S9471)->rows + (int(0)))->x) = _S9470; + float _S9472 = covar2d_30.rows[int(1)].y + eps2d_41; + *&(((&_S9471)->rows + (int(1)))->y) = _S9472; + Matrix _S9473 = _S9471; + Matrix _S9474 = _S9471; + float det_blur_41 = _S9470 * _S9472 - _S9469; + float _S9475 = det_orig_41 / det_blur_41; + float _S9476 = det_blur_41 * det_blur_41; + float _S9477 = (F32_max((0.0f), (_S9475))); + float _S9478 = s_primal_ctx_sqrt_0(_S9477); + float invdet_47 = 1.0f / det_blur_41; + float _S9479 = - covar2d_30.rows[int(0)].y; + float _S9480 = - covar2d_30.rows[int(1)].x; + if(antialiased_41) + { + k_30 = _S9442 * _S9478; + } + else + { + k_30 = _S9442; + } + float _S9481 = k_30 / 0.00392156885936856f; + float _S9482 = 2.0f * s_primal_ctx_log_0(_S9481); + float _S9483 = s_primal_ctx_sqrt_0(_S9482); + float _S9484 = _S9473.rows[int(0)].x; + float _S9485 = _S9474.rows[int(1)].y; + float3 campos_20 = - s_primal_ctx_mul_0(transpose_3(R_41), t_41); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9486; + (&_S9486)->primal_0 = mean_42; + (&_S9486)->differential_0 = _S9352; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9487; + (&_S9487)->primal_0 = scale_41; + (&_S9487)->differential_0 = _S9352; + DiffPair_float_0 _S9488; + (&_S9488)->primal_0 = in_opacity_41; + (&_S9488)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9489; + (&_S9489)->primal_0 = campos_20; + (&_S9489)->differential_0 = _S9352; + s_bwd_prop_view_radius_3dgs_0(&_S9486, &_S9487, &_S9488, &_S9489, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9490 = _S9486; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9491 = _S9487; + DiffPair_float_0 _S9492 = _S9488; + float2 _S9493 = _S9350; + *&((&_S9493)->y) = v_conic_19.z; + float2 _S9494 = _S9350; + *&((&_S9494)->y) = v_conic_19.y; + *&((&_S9494)->x) = v_conic_19.x; + DiffPair_float_0 _S9495; + (&_S9495)->primal_0 = _S9485; + (&_S9495)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9495, 0.0f); + DiffPair_float_0 _S9496; + (&_S9496)->primal_0 = _S9484; + (&_S9496)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9496, 0.0f); + DiffPair_float_0 _S9497; + (&_S9497)->primal_0 = 3.32999992370605469f; + (&_S9497)->differential_0 = 0.0f; + DiffPair_float_0 _S9498; + (&_S9498)->primal_0 = _S9483; + (&_S9498)->differential_0 = 0.0f; + _d_min_0(&_S9497, &_S9498, 0.0f); + DiffPair_float_0 _S9499; + (&_S9499)->primal_0 = _S9482; + (&_S9499)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9499, _S9498.differential_0); + float _S9500 = 2.0f * _S9499.differential_0; + DiffPair_float_0 _S9501; + (&_S9501)->primal_0 = _S9481; + (&_S9501)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S9501, _S9500); + float _S9502 = v_opacity_19 + 254.9999847412109375f * _S9501.differential_0; + Matrix _S9503 = makeMatrix (0.0f); + Matrix _S9504 = _S9503; + _S9504[int(1)] = _S9493; + _S9504[int(0)] = _S9494; + Matrix _S9505 = _S9504; + float2 _S9506 = make_float2 (0.0f, _S9495.differential_0); + float2 _S9507 = make_float2 (_S9496.differential_0, 0.0f); + if(antialiased_41) + { + float _S9508 = _S9478 * _S9502; + k_30 = _S9442 * _S9502; + eps2d_41 = _S9508; + } + else + { + k_30 = 0.0f; + eps2d_41 = _S9502; + } + float _S9509 = invdet_47 * _S9505.rows[int(1)].y; + float _S9510 = - (invdet_47 * _S9505.rows[int(1)].x); + float _S9511 = - (invdet_47 * _S9505.rows[int(0)].y); + float _S9512 = invdet_47 * _S9505.rows[int(0)].x; + float _S9513 = - ((_S9470 * _S9505.rows[int(1)].y + _S9480 * _S9505.rows[int(1)].x + _S9479 * _S9505.rows[int(0)].y + _S9472 * _S9505.rows[int(0)].x) / _S9476); + DiffPair_float_0 _S9514; + (&_S9514)->primal_0 = _S9477; + (&_S9514)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9514, k_30); + DiffPair_float_0 _S9515; + (&_S9515)->primal_0 = 0.0f; + (&_S9515)->differential_0 = 0.0f; + DiffPair_float_0 _S9516; + (&_S9516)->primal_0 = _S9475; + (&_S9516)->differential_0 = 0.0f; + _d_max_0(&_S9515, &_S9516, _S9514.differential_0); + float _S9517 = _S9516.differential_0 / _S9476; + float s_diff_det_orig_T_19 = det_blur_41 * _S9517; + float _S9518 = det_orig_41 * - _S9517 + _S9513; + float _S9519 = - _S9518; + float _S9520 = _S9470 * _S9518; + float _S9521 = _S9472 * _S9518; + Matrix _S9522 = _S9503; + _S9522[int(1)] = _S9506; + _S9522[int(0)] = _S9507; + float _S9523 = _S9521 + _S9522.rows[int(0)].x + _S9509; + float _S9524 = _S9519 + - s_diff_det_orig_T_19; + float _S9525 = covar2d_30.rows[int(0)].y * _S9524 + _S9510; + float _S9526 = covar2d_30.rows[int(1)].x * _S9524 + _S9511; + float _S9527 = covar2d_30.rows[int(1)].y * s_diff_det_orig_T_19; + float _S9528 = _S9520 + _S9522.rows[int(1)].y + _S9512 + covar2d_30.rows[int(0)].x * s_diff_det_orig_T_19; + float2 _S9529 = _S9350; + *&((&_S9529)->x) = _S9525; + *&((&_S9529)->y) = _S9528; + float _S9530 = _S9523 + _S9527; + float2 _S9531 = _S9350; + *&((&_S9531)->y) = _S9526; + *&((&_S9531)->x) = _S9530; + Matrix _S9532 = _S9503; + _S9532[int(1)] = _S9529; + _S9532[int(0)] = _S9531; + Matrix _S9533 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9534; + (&_S9534)->primal_0 = R_41; + (&_S9534)->differential_0 = _S9533; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9535; + (&_S9535)->primal_0 = _S9370; + (&_S9535)->differential_0 = _S9352; + s_bwd_prop_mul_3(&_S9534, &_S9535, _S9352); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9536; + (&_S9536)->primal_0 = R_41; + (&_S9536)->differential_0 = _S9533; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9537; + (&_S9537)->primal_0 = _S9367; + (&_S9537)->differential_0 = _S9352; + s_bwd_prop_mul_3(&_S9536, &_S9537, _S9352); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9538; + (&_S9538)->primal_0 = R_41; + (&_S9538)->differential_0 = _S9533; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9539; + (&_S9539)->primal_0 = _S9364; + (&_S9539)->differential_0 = _S9352; + s_bwd_prop_mul_3(&_S9538, &_S9539, _S9352); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9540; + (&_S9540)->primal_0 = R_41; + (&_S9540)->differential_0 = _S9533; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9541; + (&_S9541)->primal_0 = _S9369; + (&_S9541)->differential_0 = _S9352; + s_bwd_prop_mul_3(&_S9540, &_S9541, _S9352); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9542; + (&_S9542)->primal_0 = R_41; + (&_S9542)->differential_0 = _S9533; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9543; + (&_S9543)->primal_0 = _S9366; + (&_S9543)->differential_0 = _S9352; + s_bwd_prop_mul_3(&_S9542, &_S9543, _S9352); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9544; + (&_S9544)->primal_0 = R_41; + (&_S9544)->differential_0 = _S9533; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9545; + (&_S9545)->primal_0 = _S9363; + (&_S9545)->differential_0 = _S9352; + s_bwd_prop_mul_3(&_S9544, &_S9545, _S9352); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9546; + (&_S9546)->primal_0 = R_41; + (&_S9546)->differential_0 = _S9533; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9547; + (&_S9547)->primal_0 = _S9382.p_0[0U]; + (&_S9547)->differential_0 = _S9352; + s_bwd_prop_mul_3(&_S9546, &_S9547, _S9352); + float3 _S9548 = - _S9535.differential_0 + _S9541.differential_0; + float3 _S9549 = _S9446 * _S9548; + float3 _S9550 = _S9356.rows[2U] * _S9548; + float _S9551 = _S9361 * (_S9550.x + _S9550.y + _S9550.z); + float3 _S9552 = - _S9537.differential_0 + _S9543.differential_0; + float3 _S9553 = _S9445 * _S9552; + float3 _S9554 = _S9356.rows[1U] * _S9552; + float _S9555 = _S9361 * (_S9554.x + _S9554.y + _S9554.z); + float3 _S9556 = - _S9539.differential_0 + _S9545.differential_0; + float3 _S9557 = _S9444 * _S9556; + float3 _S9558 = _S9356.rows[0U] * _S9556; + float _S9559 = _S9361 * (_S9558.x + _S9558.y + _S9558.z); + Matrix _S9560 = _S9533; + _S9560[2U] = _S9549; + _S9560[1U] = _S9553; + _S9560[0U] = _S9557; + Matrix _S9561 = transpose_3(transpose_3(_S9560)); + float _S9562 = 2.0f * - _S9561.rows[int(2)].z; + float _S9563 = 2.0f * _S9561.rows[int(2)].y; + float _S9564 = 2.0f * _S9561.rows[int(2)].x; + float _S9565 = 2.0f * _S9561.rows[int(1)].z; + float _S9566 = 2.0f * - _S9561.rows[int(1)].y; + float _S9567 = 2.0f * _S9561.rows[int(1)].x; + float _S9568 = 2.0f * _S9561.rows[int(0)].z; + float _S9569 = 2.0f * _S9561.rows[int(0)].y; + float _S9570 = 2.0f * - _S9561.rows[int(0)].x; + float _S9571 = - _S9567 + _S9569; + float _S9572 = _S9564 + - _S9568; + float _S9573 = - _S9563 + _S9565; + float _S9574 = _S9563 + _S9565; + float _S9575 = _S9564 + _S9568; + float _S9576 = _S9567 + _S9569; + float _S9577 = _S9354.w * (_S9566 + _S9570); + float _S9578 = _S9354.z * (_S9562 + _S9570); + float _S9579 = _S9354.y * (_S9562 + _S9566); + float _S9580 = _S9354.x * _S9571 + _S9354.z * _S9574 + _S9354.y * _S9575 + _S9577 + _S9577; + float _S9581 = _S9354.x * _S9572 + _S9354.w * _S9574 + _S9354.y * _S9576 + _S9578 + _S9578; + float _S9582 = _S9354.x * _S9573 + _S9354.w * _S9575 + _S9354.z * _S9576 + _S9579 + _S9579; + float _S9583 = _S9354.w * _S9571 + _S9354.z * _S9572 + _S9354.y * _S9573; + float4 _S9584 = make_float4 (0.0f); + float4 _S9585 = _S9584; + *&((&_S9585)->w) = _S9580; + *&((&_S9585)->z) = _S9581; + *&((&_S9585)->y) = _S9582; + *&((&_S9585)->x) = _S9583; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S9586; + (&_S9586)->primal_0 = quat_41; + (&_S9586)->differential_0 = _S9584; + s_bwd_normalize_impl_0(&_S9586, _S9585); + float3 _S9587 = _S9352; + *&((&_S9587)->z) = _S9551; + *&((&_S9587)->y) = _S9555; + *&((&_S9587)->x) = _S9559; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9588; + (&_S9588)->primal_0 = scale_41; + (&_S9588)->differential_0 = _S9352; + s_bwd_prop_exp_1(&_S9588, _S9587); + float _S9589 = - (eps2d_41 / _S9443); + DiffPair_float_0 _S9590; + (&_S9590)->primal_0 = _S9440; + (&_S9590)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S9590, _S9589); + float _S9591 = - _S9590.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9592; + (&_S9592)->primal_0 = mean_c_41; + (&_S9592)->differential_0 = _S9352; + s_bwd_length_impl_0(&_S9592, v_depth_19); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9593; + (&_S9593)->primal_0 = R_41; + (&_S9593)->differential_0 = _S9533; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9594; + (&_S9594)->primal_0 = mean_42; + (&_S9594)->differential_0 = _S9352; + s_bwd_prop_mul_3(&_S9593, &_S9594, _S9592.differential_0); + Matrix _S9595 = _S9534.differential_0 + _S9536.differential_0 + _S9538.differential_0 + _S9540.differential_0 + _S9542.differential_0 + _S9544.differential_0 + _S9546.differential_0 + _S9593.differential_0; + float _S9596 = _S9591 + _S9492.differential_0; + float3 _S9597 = _S9588.differential_0 + _S9491.differential_0; + *v_mean_19 = *v_mean_19 + (_S9535.differential_0 + _S9541.differential_0 + _S9537.differential_0 + _S9543.differential_0 + _S9539.differential_0 + _S9545.differential_0 + _S9594.differential_0 + _S9490.differential_0); + *v_quat_19 = *v_quat_19 + _S9586.differential_0; + *v_scale_19 = *v_scale_19 + _S9597; + *v_in_opacity_19 = *v_in_opacity_19 + _S9596; + *v_R_19 = *v_R_19 + _S9595; + *v_t_19 = *v_t_19 + _S9592.differential_0; + return; +} + +struct s_bwd_prop_DiffProjection3DGS_3dgut_equisolid_prism_projection_Intermediates_0 +{ + float2 _S9598; + float2 _S9599; + float2 _S9600; + float2 _S9601; + float2 _S9602; + float2 _S9603; + float2 _S9604; +}; + +inline __device__ void projection_3dgut_equisolid_prism_vjp(bool antialiased_42, float3 mean_43, float4 quat_42, float3 scale_42, float in_opacity_42, Matrix R_42, float3 t_42, float fx_55, float fy_55, float cx_46, float cy_46, FixedArray dist_coeffs_54, uint image_width_42, uint image_height_42, float2 v_mean2d_20, float v_depth_20, float3 v_conic_20, float v_opacity_20, float3 * v_mean_20, float4 * v_quat_20, float3 * v_scale_20, float * v_in_opacity_20, Matrix * v_R_20, float3 * v_t_20) +{ + float2 _S9605 = make_float2 (0.0f); + s_bwd_prop_DiffProjection3DGS_3dgut_equisolid_prism_projection_Intermediates_0 _S9606; + (&_S9606)->_S9598 = _S9605; + (&_S9606)->_S9599 = _S9605; + (&_S9606)->_S9600 = _S9605; + (&_S9606)->_S9601 = _S9605; + (&_S9606)->_S9602 = _S9605; + (&_S9606)->_S9603 = _S9605; + (&_S9606)->_S9604 = _S9605; + (&_S9606)->_S9598 = _S9605; + (&_S9606)->_S9599 = _S9605; + (&_S9606)->_S9600 = _S9605; + (&_S9606)->_S9601 = _S9605; + (&_S9606)->_S9602 = _S9605; + (&_S9606)->_S9603 = _S9605; + (&_S9606)->_S9604 = _S9605; + float3 _S9607 = make_float3 (0.0f); + float3 _S9608 = s_primal_ctx_exp_1(scale_42); + float4 _S9609 = normalize_0(quat_42); + float _S9610 = _S9609.y; + float x2_42 = _S9610 * _S9610; + float y2_42 = _S9609.z * _S9609.z; + float z2_42 = _S9609.w * _S9609.w; + float xy_42 = _S9609.y * _S9609.z; + float xz_42 = _S9609.y * _S9609.w; + float yz_42 = _S9609.z * _S9609.w; + float wx_42 = _S9609.x * _S9609.y; + float wy_42 = _S9609.x * _S9609.z; + float wz_42 = _S9609.x * _S9609.w; + Matrix _S9611 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_42 + z2_42), 2.0f * (xy_42 + wz_42), 2.0f * (xz_42 - wy_42), 2.0f * (xy_42 - wz_42), 1.0f - 2.0f * (x2_42 + z2_42), 2.0f * (yz_42 + wx_42), 2.0f * (xz_42 + wy_42), 2.0f * (yz_42 - wx_42), 1.0f - 2.0f * (x2_42 + y2_42)))); + FixedArray _S9612 = { + _S9607, _S9607, _S9607, _S9607, _S9607, _S9607, _S9607 + }; + FixedArray _S9613 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + SigmaPoints_0 _S9614; + (&_S9614)->p_0 = _S9612; + (&_S9614)->w_mean_0 = _S9613; + (&_S9614)->w_cov_0 = _S9613; + (&_S9614)->p_0[int(0)] = mean_43; + SigmaPoints_0 _S9615 = _S9614; + (&_S9615)->w_mean_0[int(0)] = 0.0f; + (&_S9615)->w_cov_0[int(0)] = 2.0f; + float _S9616 = s_primal_ctx_sqrt_0(3.0f); + float _S9617 = _S9616 * _S9608.x; + float3 delta_60 = make_float3 (_S9617) * _S9611.rows[0U]; + float3 _S9618 = mean_43 + delta_60; + (&_S9615)->p_0[1U] = _S9618; + float3 _S9619 = mean_43 - delta_60; + (&_S9615)->p_0[4U] = _S9619; + float _S9620 = _S9616 * _S9608.y; + float3 delta_61 = make_float3 (_S9620) * _S9611.rows[1U]; + float3 _S9621 = mean_43 + delta_61; + (&_S9615)->p_0[2U] = _S9621; + float3 _S9622 = mean_43 - delta_61; + (&_S9615)->p_0[5U] = _S9622; + float _S9623 = _S9616 * _S9608.z; + float3 delta_62 = make_float3 (_S9623) * _S9611.rows[2U]; + float3 _S9624 = mean_43 + delta_62; + (&_S9615)->p_0[3U] = _S9624; + float3 _S9625 = mean_43 - delta_62; + (&_S9615)->p_0[6U] = _S9625; + (&_S9615)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S9626 = _S9615; + (&_S9626)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S9627 = _S9626; + (&_S9627)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S9628 = _S9627; + (&_S9628)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S9629 = _S9628; + (&_S9629)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S9630 = _S9629; + (&_S9630)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S9631 = _S9630; + (&_S9631)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S9632 = _S9631; + (&_S9632)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S9633 = _S9632; + (&_S9633)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S9634 = _S9633; + (&_S9634)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S9635 = _S9634; + (&_S9635)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S9636 = _S9635; + (&_S9636)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S9637 = _S9614; + float3 _S9638 = s_primal_ctx_mul_0(R_42, _S9614.p_0[0U]) + t_42; + _S9614 = _S9636; + (&_S9614)->p_0[0U] = _S9638; + SigmaPoints_0 _S9639 = _S9614; + (&_S9614)->p_0[1U] = s_primal_ctx_mul_0(R_42, _S9618) + t_42; + SigmaPoints_0 _S9640 = _S9614; + (&_S9614)->p_0[2U] = s_primal_ctx_mul_0(R_42, _S9621) + t_42; + SigmaPoints_0 _S9641 = _S9614; + (&_S9614)->p_0[3U] = s_primal_ctx_mul_0(R_42, _S9624) + t_42; + SigmaPoints_0 _S9642 = _S9614; + (&_S9614)->p_0[4U] = s_primal_ctx_mul_0(R_42, _S9619) + t_42; + SigmaPoints_0 _S9643 = _S9614; + (&_S9614)->p_0[5U] = s_primal_ctx_mul_0(R_42, _S9622) + t_42; + SigmaPoints_0 _S9644 = _S9614; + (&_S9614)->p_0[6U] = s_primal_ctx_mul_0(R_42, _S9625) + t_42; + SigmaPoints_0 _S9645 = _S9614; + float2 _S9646 = float2 {_S9639.p_0[int(0)].x, _S9639.p_0[int(0)].y}; + float _S9647 = length_0(_S9646); + float _S9648 = _S9639.p_0[int(0)].z; + float _S9649 = s_primal_ctx_atan2_0(_S9647, _S9648); + float k_31; + if(_S9647 < 9.99999997475242708e-07f) + { + k_31 = (1.0f - _S9649 * _S9649 / 24.0f) / _S9648; + } + else + { + k_31 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9649) / _S9647; + } + float2 _S9650 = _S9646 * make_float2 (k_31); + FixedArray _S9651 = dist_coeffs_54; + float2 _S9652 = s_primal_ctx_DistThinPrism_distort_0(_S9650, &_S9651); + (&_S9606)->_S9598 = make_float2 (fx_55 * _S9652.x + cx_46, fy_55 * _S9652.y + cy_46); + float2 _S9653 = float2 {_S9640.p_0[int(1)].x, _S9640.p_0[int(1)].y}; + float _S9654 = length_0(_S9653); + float _S9655 = _S9640.p_0[int(1)].z; + float _S9656 = s_primal_ctx_atan2_0(_S9654, _S9655); + if(_S9654 < 9.99999997475242708e-07f) + { + k_31 = (1.0f - _S9656 * _S9656 / 24.0f) / _S9655; + } + else + { + k_31 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9656) / _S9654; + } + float2 _S9657 = _S9653 * make_float2 (k_31); + FixedArray _S9658 = dist_coeffs_54; + float2 _S9659 = s_primal_ctx_DistThinPrism_distort_0(_S9657, &_S9658); + (&_S9606)->_S9599 = make_float2 (fx_55 * _S9659.x + cx_46, fy_55 * _S9659.y + cy_46); + float2 _S9660 = float2 {_S9641.p_0[int(2)].x, _S9641.p_0[int(2)].y}; + float _S9661 = length_0(_S9660); + float _S9662 = _S9641.p_0[int(2)].z; + float _S9663 = s_primal_ctx_atan2_0(_S9661, _S9662); + if(_S9661 < 9.99999997475242708e-07f) + { + k_31 = (1.0f - _S9663 * _S9663 / 24.0f) / _S9662; + } + else + { + k_31 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9663) / _S9661; + } + float2 _S9664 = _S9660 * make_float2 (k_31); + FixedArray _S9665 = dist_coeffs_54; + float2 _S9666 = s_primal_ctx_DistThinPrism_distort_0(_S9664, &_S9665); + (&_S9606)->_S9600 = make_float2 (fx_55 * _S9666.x + cx_46, fy_55 * _S9666.y + cy_46); + float2 _S9667 = float2 {_S9642.p_0[int(3)].x, _S9642.p_0[int(3)].y}; + float _S9668 = length_0(_S9667); + float _S9669 = _S9642.p_0[int(3)].z; + float _S9670 = s_primal_ctx_atan2_0(_S9668, _S9669); + if(_S9668 < 9.99999997475242708e-07f) + { + k_31 = (1.0f - _S9670 * _S9670 / 24.0f) / _S9669; + } + else + { + k_31 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9670) / _S9668; + } + float2 _S9671 = _S9667 * make_float2 (k_31); + FixedArray _S9672 = dist_coeffs_54; + float2 _S9673 = s_primal_ctx_DistThinPrism_distort_0(_S9671, &_S9672); + (&_S9606)->_S9601 = make_float2 (fx_55 * _S9673.x + cx_46, fy_55 * _S9673.y + cy_46); + float2 _S9674 = float2 {_S9643.p_0[int(4)].x, _S9643.p_0[int(4)].y}; + float _S9675 = length_0(_S9674); + float _S9676 = _S9643.p_0[int(4)].z; + float _S9677 = s_primal_ctx_atan2_0(_S9675, _S9676); + if(_S9675 < 9.99999997475242708e-07f) + { + k_31 = (1.0f - _S9677 * _S9677 / 24.0f) / _S9676; + } + else + { + k_31 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9677) / _S9675; + } + float2 _S9678 = _S9674 * make_float2 (k_31); + FixedArray _S9679 = dist_coeffs_54; + float2 _S9680 = s_primal_ctx_DistThinPrism_distort_0(_S9678, &_S9679); + (&_S9606)->_S9602 = make_float2 (fx_55 * _S9680.x + cx_46, fy_55 * _S9680.y + cy_46); + float2 _S9681 = float2 {_S9644.p_0[int(5)].x, _S9644.p_0[int(5)].y}; + float _S9682 = length_0(_S9681); + float _S9683 = _S9644.p_0[int(5)].z; + float _S9684 = s_primal_ctx_atan2_0(_S9682, _S9683); + if(_S9682 < 9.99999997475242708e-07f) + { + k_31 = (1.0f - _S9684 * _S9684 / 24.0f) / _S9683; + } + else + { + k_31 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9684) / _S9682; + } + float2 _S9685 = _S9681 * make_float2 (k_31); + FixedArray _S9686 = dist_coeffs_54; + float2 _S9687 = s_primal_ctx_DistThinPrism_distort_0(_S9685, &_S9686); + (&_S9606)->_S9603 = make_float2 (fx_55 * _S9687.x + cx_46, fy_55 * _S9687.y + cy_46); + float2 _S9688 = float2 {_S9645.p_0[int(6)].x, _S9645.p_0[int(6)].y}; + float _S9689 = length_0(_S9688); + float _S9690 = _S9645.p_0[int(6)].z; + float _S9691 = s_primal_ctx_atan2_0(_S9689, _S9690); + if(_S9689 < 9.99999997475242708e-07f) + { + k_31 = (1.0f - _S9691 * _S9691 / 24.0f) / _S9690; + } + else + { + k_31 = 2.0f * s_primal_ctx_sin_0(0.5f * _S9691) / _S9689; + } + float2 _S9692 = _S9688 * make_float2 (k_31); + FixedArray _S9693 = dist_coeffs_54; + float2 _S9694 = s_primal_ctx_DistThinPrism_distort_0(_S9692, &_S9693); + (&_S9606)->_S9604 = make_float2 (fx_55 * _S9694.x + cx_46, fy_55 * _S9694.y + cy_46); + float3 mean_c_42 = s_primal_ctx_mul_0(R_42, mean_43) + t_42; + float _S9695 = - in_opacity_42; + float _S9696 = 1.0f + s_primal_ctx_exp_0(_S9695); + float _S9697 = 1.0f / _S9696; + float _S9698 = _S9696 * _S9696; + float3 _S9699 = make_float3 (_S9617); + float3 _S9700 = make_float3 (_S9620); + float3 _S9701 = make_float3 (_S9623); + float2 _S9702 = make_float2 (_S9615.w_mean_0[int(1)]) * _S9606._S9599 + make_float2 (_S9627.w_mean_0[int(2)]) * _S9606._S9600 + make_float2 (_S9629.w_mean_0[int(3)]) * _S9606._S9601 + make_float2 (_S9631.w_mean_0[int(4)]) * _S9606._S9602 + make_float2 (_S9633.w_mean_0[int(5)]) * _S9606._S9603 + make_float2 (_S9635.w_mean_0[int(6)]) * _S9606._S9604; + float2 d_140 = _S9606._S9598 - _S9702; + float _S9703 = d_140.x; + float _S9704 = d_140.y; + float _S9705 = _S9703 * _S9704; + float2 d_141 = _S9606._S9599 - _S9702; + float _S9706 = d_141.x; + float _S9707 = d_141.y; + float _S9708 = _S9706 * _S9707; + float2 d_142 = _S9606._S9600 - _S9702; + float _S9709 = d_142.x; + float _S9710 = d_142.y; + float _S9711 = _S9709 * _S9710; + float2 d_143 = _S9606._S9601 - _S9702; + float _S9712 = d_143.x; + float _S9713 = d_143.y; + float _S9714 = _S9712 * _S9713; + float2 d_144 = _S9606._S9602 - _S9702; + float _S9715 = d_144.x; + float _S9716 = d_144.y; + float _S9717 = _S9715 * _S9716; + float2 d_145 = _S9606._S9603 - _S9702; + float _S9718 = d_145.x; + float _S9719 = d_145.y; + float _S9720 = _S9718 * _S9719; + float2 d_146 = _S9606._S9604 - _S9702; + float _S9721 = d_146.x; + float _S9722 = d_146.y; + float _S9723 = _S9721 * _S9722; + Matrix covar2d_31 = makeMatrix (2.0f) * makeMatrix (_S9703 * _S9703, _S9705, _S9705, _S9704 * _S9704) + makeMatrix (_S9626.w_cov_0[int(1)]) * makeMatrix (_S9706 * _S9706, _S9708, _S9708, _S9707 * _S9707) + makeMatrix (_S9628.w_cov_0[int(2)]) * makeMatrix (_S9709 * _S9709, _S9711, _S9711, _S9710 * _S9710) + makeMatrix (_S9630.w_cov_0[int(3)]) * makeMatrix (_S9712 * _S9712, _S9714, _S9714, _S9713 * _S9713) + makeMatrix (_S9632.w_cov_0[int(4)]) * makeMatrix (_S9715 * _S9715, _S9717, _S9717, _S9716 * _S9716) + makeMatrix (_S9634.w_cov_0[int(5)]) * makeMatrix (_S9718 * _S9718, _S9720, _S9720, _S9719 * _S9719) + makeMatrix (_S9636.w_cov_0[int(6)]) * makeMatrix (_S9721 * _S9721, _S9723, _S9723, _S9722 * _S9722); + float eps2d_42; + if(antialiased_42) + { + eps2d_42 = 0.10000000149011612f; + } + else + { + eps2d_42 = 0.30000001192092896f; + } + float _S9724 = covar2d_31.rows[int(0)].y * covar2d_31.rows[int(1)].x; + float det_orig_42 = covar2d_31.rows[int(0)].x * covar2d_31.rows[int(1)].y - _S9724; + float _S9725 = covar2d_31.rows[int(0)].x + eps2d_42; + Matrix _S9726 = covar2d_31; + *&(((&_S9726)->rows + (int(0)))->x) = _S9725; + float _S9727 = covar2d_31.rows[int(1)].y + eps2d_42; + *&(((&_S9726)->rows + (int(1)))->y) = _S9727; + Matrix _S9728 = _S9726; + Matrix _S9729 = _S9726; + float det_blur_42 = _S9725 * _S9727 - _S9724; + float _S9730 = det_orig_42 / det_blur_42; + float _S9731 = det_blur_42 * det_blur_42; + float _S9732 = (F32_max((0.0f), (_S9730))); + float _S9733 = s_primal_ctx_sqrt_0(_S9732); + float invdet_48 = 1.0f / det_blur_42; + float _S9734 = - covar2d_31.rows[int(0)].y; + float _S9735 = - covar2d_31.rows[int(1)].x; + if(antialiased_42) + { + k_31 = _S9697 * _S9733; + } + else + { + k_31 = _S9697; + } + float _S9736 = k_31 / 0.00392156885936856f; + float _S9737 = 2.0f * s_primal_ctx_log_0(_S9736); + float _S9738 = s_primal_ctx_sqrt_0(_S9737); + float _S9739 = _S9728.rows[int(0)].x; + float _S9740 = _S9729.rows[int(1)].y; + float3 campos_21 = - s_primal_ctx_mul_0(transpose_3(R_42), t_42); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9741; + (&_S9741)->primal_0 = mean_43; + (&_S9741)->differential_0 = _S9607; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9742; + (&_S9742)->primal_0 = scale_42; + (&_S9742)->differential_0 = _S9607; + DiffPair_float_0 _S9743; + (&_S9743)->primal_0 = in_opacity_42; + (&_S9743)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9744; + (&_S9744)->primal_0 = campos_21; + (&_S9744)->differential_0 = _S9607; + s_bwd_prop_view_radius_3dgs_0(&_S9741, &_S9742, &_S9743, &_S9744, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9745 = _S9741; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9746 = _S9742; + DiffPair_float_0 _S9747 = _S9743; + float2 _S9748 = _S9605; + *&((&_S9748)->y) = v_conic_20.z; + float2 _S9749 = _S9605; + *&((&_S9749)->y) = v_conic_20.y; + *&((&_S9749)->x) = v_conic_20.x; + DiffPair_float_0 _S9750; + (&_S9750)->primal_0 = _S9740; + (&_S9750)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9750, 0.0f); + DiffPair_float_0 _S9751; + (&_S9751)->primal_0 = _S9739; + (&_S9751)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9751, 0.0f); + DiffPair_float_0 _S9752; + (&_S9752)->primal_0 = 3.32999992370605469f; + (&_S9752)->differential_0 = 0.0f; + DiffPair_float_0 _S9753; + (&_S9753)->primal_0 = _S9738; + (&_S9753)->differential_0 = 0.0f; + _d_min_0(&_S9752, &_S9753, 0.0f); + DiffPair_float_0 _S9754; + (&_S9754)->primal_0 = _S9737; + (&_S9754)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9754, _S9753.differential_0); + float _S9755 = 2.0f * _S9754.differential_0; + DiffPair_float_0 _S9756; + (&_S9756)->primal_0 = _S9736; + (&_S9756)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S9756, _S9755); + float _S9757 = v_opacity_20 + 254.9999847412109375f * _S9756.differential_0; + Matrix _S9758 = makeMatrix (0.0f); + Matrix _S9759 = _S9758; + _S9759[int(1)] = _S9748; + _S9759[int(0)] = _S9749; + Matrix _S9760 = _S9759; + float2 _S9761 = make_float2 (0.0f, _S9750.differential_0); + float2 _S9762 = make_float2 (_S9751.differential_0, 0.0f); + if(antialiased_42) + { + float _S9763 = _S9733 * _S9757; + k_31 = _S9697 * _S9757; + eps2d_42 = _S9763; + } + else + { + k_31 = 0.0f; + eps2d_42 = _S9757; + } + float _S9764 = invdet_48 * _S9760.rows[int(1)].y; + float _S9765 = - (invdet_48 * _S9760.rows[int(1)].x); + float _S9766 = - (invdet_48 * _S9760.rows[int(0)].y); + float _S9767 = invdet_48 * _S9760.rows[int(0)].x; + float _S9768 = - ((_S9725 * _S9760.rows[int(1)].y + _S9735 * _S9760.rows[int(1)].x + _S9734 * _S9760.rows[int(0)].y + _S9727 * _S9760.rows[int(0)].x) / _S9731); + DiffPair_float_0 _S9769; + (&_S9769)->primal_0 = _S9732; + (&_S9769)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9769, k_31); + DiffPair_float_0 _S9770; + (&_S9770)->primal_0 = 0.0f; + (&_S9770)->differential_0 = 0.0f; + DiffPair_float_0 _S9771; + (&_S9771)->primal_0 = _S9730; + (&_S9771)->differential_0 = 0.0f; + _d_max_0(&_S9770, &_S9771, _S9769.differential_0); + float _S9772 = _S9771.differential_0 / _S9731; + float s_diff_det_orig_T_20 = det_blur_42 * _S9772; + float _S9773 = det_orig_42 * - _S9772 + _S9768; + float _S9774 = - _S9773; + float _S9775 = _S9725 * _S9773; + float _S9776 = _S9727 * _S9773; + Matrix _S9777 = _S9758; + _S9777[int(1)] = _S9761; + _S9777[int(0)] = _S9762; + float _S9778 = _S9776 + _S9777.rows[int(0)].x + _S9764; + float _S9779 = _S9774 + - s_diff_det_orig_T_20; + float _S9780 = covar2d_31.rows[int(0)].y * _S9779 + _S9765; + float _S9781 = covar2d_31.rows[int(1)].x * _S9779 + _S9766; + float _S9782 = covar2d_31.rows[int(1)].y * s_diff_det_orig_T_20; + float _S9783 = _S9775 + _S9777.rows[int(1)].y + _S9767 + covar2d_31.rows[int(0)].x * s_diff_det_orig_T_20; + float2 _S9784 = _S9605; + *&((&_S9784)->x) = _S9780; + *&((&_S9784)->y) = _S9783; + float _S9785 = _S9778 + _S9782; + float2 _S9786 = _S9605; + *&((&_S9786)->y) = _S9781; + *&((&_S9786)->x) = _S9785; + Matrix _S9787 = _S9758; + _S9787[int(1)] = _S9784; + _S9787[int(0)] = _S9786; + Matrix _S9788 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9789; + (&_S9789)->primal_0 = R_42; + (&_S9789)->differential_0 = _S9788; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9790; + (&_S9790)->primal_0 = _S9625; + (&_S9790)->differential_0 = _S9607; + s_bwd_prop_mul_3(&_S9789, &_S9790, _S9607); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9791; + (&_S9791)->primal_0 = R_42; + (&_S9791)->differential_0 = _S9788; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9792; + (&_S9792)->primal_0 = _S9622; + (&_S9792)->differential_0 = _S9607; + s_bwd_prop_mul_3(&_S9791, &_S9792, _S9607); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9793; + (&_S9793)->primal_0 = R_42; + (&_S9793)->differential_0 = _S9788; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9794; + (&_S9794)->primal_0 = _S9619; + (&_S9794)->differential_0 = _S9607; + s_bwd_prop_mul_3(&_S9793, &_S9794, _S9607); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9795; + (&_S9795)->primal_0 = R_42; + (&_S9795)->differential_0 = _S9788; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9796; + (&_S9796)->primal_0 = _S9624; + (&_S9796)->differential_0 = _S9607; + s_bwd_prop_mul_3(&_S9795, &_S9796, _S9607); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9797; + (&_S9797)->primal_0 = R_42; + (&_S9797)->differential_0 = _S9788; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9798; + (&_S9798)->primal_0 = _S9621; + (&_S9798)->differential_0 = _S9607; + s_bwd_prop_mul_3(&_S9797, &_S9798, _S9607); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9799; + (&_S9799)->primal_0 = R_42; + (&_S9799)->differential_0 = _S9788; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9800; + (&_S9800)->primal_0 = _S9618; + (&_S9800)->differential_0 = _S9607; + s_bwd_prop_mul_3(&_S9799, &_S9800, _S9607); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9801; + (&_S9801)->primal_0 = R_42; + (&_S9801)->differential_0 = _S9788; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9802; + (&_S9802)->primal_0 = _S9637.p_0[0U]; + (&_S9802)->differential_0 = _S9607; + s_bwd_prop_mul_3(&_S9801, &_S9802, _S9607); + float3 _S9803 = - _S9790.differential_0 + _S9796.differential_0; + float3 _S9804 = _S9701 * _S9803; + float3 _S9805 = _S9611.rows[2U] * _S9803; + float _S9806 = _S9616 * (_S9805.x + _S9805.y + _S9805.z); + float3 _S9807 = - _S9792.differential_0 + _S9798.differential_0; + float3 _S9808 = _S9700 * _S9807; + float3 _S9809 = _S9611.rows[1U] * _S9807; + float _S9810 = _S9616 * (_S9809.x + _S9809.y + _S9809.z); + float3 _S9811 = - _S9794.differential_0 + _S9800.differential_0; + float3 _S9812 = _S9699 * _S9811; + float3 _S9813 = _S9611.rows[0U] * _S9811; + float _S9814 = _S9616 * (_S9813.x + _S9813.y + _S9813.z); + Matrix _S9815 = _S9788; + _S9815[2U] = _S9804; + _S9815[1U] = _S9808; + _S9815[0U] = _S9812; + Matrix _S9816 = transpose_3(transpose_3(_S9815)); + float _S9817 = 2.0f * - _S9816.rows[int(2)].z; + float _S9818 = 2.0f * _S9816.rows[int(2)].y; + float _S9819 = 2.0f * _S9816.rows[int(2)].x; + float _S9820 = 2.0f * _S9816.rows[int(1)].z; + float _S9821 = 2.0f * - _S9816.rows[int(1)].y; + float _S9822 = 2.0f * _S9816.rows[int(1)].x; + float _S9823 = 2.0f * _S9816.rows[int(0)].z; + float _S9824 = 2.0f * _S9816.rows[int(0)].y; + float _S9825 = 2.0f * - _S9816.rows[int(0)].x; + float _S9826 = - _S9822 + _S9824; + float _S9827 = _S9819 + - _S9823; + float _S9828 = - _S9818 + _S9820; + float _S9829 = _S9818 + _S9820; + float _S9830 = _S9819 + _S9823; + float _S9831 = _S9822 + _S9824; + float _S9832 = _S9609.w * (_S9821 + _S9825); + float _S9833 = _S9609.z * (_S9817 + _S9825); + float _S9834 = _S9609.y * (_S9817 + _S9821); + float _S9835 = _S9609.x * _S9826 + _S9609.z * _S9829 + _S9609.y * _S9830 + _S9832 + _S9832; + float _S9836 = _S9609.x * _S9827 + _S9609.w * _S9829 + _S9609.y * _S9831 + _S9833 + _S9833; + float _S9837 = _S9609.x * _S9828 + _S9609.w * _S9830 + _S9609.z * _S9831 + _S9834 + _S9834; + float _S9838 = _S9609.w * _S9826 + _S9609.z * _S9827 + _S9609.y * _S9828; + float4 _S9839 = make_float4 (0.0f); + float4 _S9840 = _S9839; + *&((&_S9840)->w) = _S9835; + *&((&_S9840)->z) = _S9836; + *&((&_S9840)->y) = _S9837; + *&((&_S9840)->x) = _S9838; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S9841; + (&_S9841)->primal_0 = quat_42; + (&_S9841)->differential_0 = _S9839; + s_bwd_normalize_impl_0(&_S9841, _S9840); + float3 _S9842 = _S9607; + *&((&_S9842)->z) = _S9806; + *&((&_S9842)->y) = _S9810; + *&((&_S9842)->x) = _S9814; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9843; + (&_S9843)->primal_0 = scale_42; + (&_S9843)->differential_0 = _S9607; + s_bwd_prop_exp_1(&_S9843, _S9842); + float _S9844 = - (eps2d_42 / _S9698); + DiffPair_float_0 _S9845; + (&_S9845)->primal_0 = _S9695; + (&_S9845)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S9845, _S9844); + float _S9846 = - _S9845.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9847; + (&_S9847)->primal_0 = mean_c_42; + (&_S9847)->differential_0 = _S9607; + s_bwd_length_impl_0(&_S9847, v_depth_20); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S9848; + (&_S9848)->primal_0 = R_42; + (&_S9848)->differential_0 = _S9788; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9849; + (&_S9849)->primal_0 = mean_43; + (&_S9849)->differential_0 = _S9607; + s_bwd_prop_mul_3(&_S9848, &_S9849, _S9847.differential_0); + Matrix _S9850 = _S9789.differential_0 + _S9791.differential_0 + _S9793.differential_0 + _S9795.differential_0 + _S9797.differential_0 + _S9799.differential_0 + _S9801.differential_0 + _S9848.differential_0; + float _S9851 = _S9846 + _S9747.differential_0; + float3 _S9852 = _S9843.differential_0 + _S9746.differential_0; + *v_mean_20 = *v_mean_20 + (_S9790.differential_0 + _S9796.differential_0 + _S9792.differential_0 + _S9798.differential_0 + _S9794.differential_0 + _S9800.differential_0 + _S9849.differential_0 + _S9745.differential_0); + *v_quat_20 = *v_quat_20 + _S9841.differential_0; + *v_scale_20 = *v_scale_20 + _S9852; + *v_in_opacity_20 = *v_in_opacity_20 + _S9851; + *v_R_20 = *v_R_20 + _S9850; + *v_t_20 = *v_t_20 + _S9847.differential_0; + return; +} + +inline __device__ void projection_3dgut_equirect_none_vjp(bool antialiased_43, float3 mean_44, float4 quat_43, float3 scale_43, float in_opacity_43, Matrix R_43, float3 t_43, float fx_56, float fy_56, float cx_47, float cy_47, FixedArray dist_coeffs_55, uint image_width_43, uint image_height_43, float2 v_mean2d_21, float v_depth_21, float3 v_conic_21, float v_opacity_21, float3 * v_mean_21, float4 * v_quat_21, float3 * v_scale_21, float * v_in_opacity_21, Matrix * v_R_21, float3 * v_t_21) +{ + float3 _S9853 = make_float3 (0.0f); + float3 mean_c_43 = s_primal_ctx_mul_0(R_43, mean_44) + t_43; + float _S9854 = - in_opacity_43; + float _S9855 = 1.0f + s_primal_ctx_exp_0(_S9854); + float _S9856 = 1.0f / _S9855; + float _S9857 = _S9855 * _S9855; + float3 _S9858 = s_primal_ctx_exp_1(scale_43); + float4 _S9859 = normalize_0(quat_43); + float _S9860 = _S9859.y; + float x2_43 = _S9860 * _S9860; + float y2_43 = _S9859.z * _S9859.z; + float z2_43 = _S9859.w * _S9859.w; + float xy_43 = _S9859.y * _S9859.z; + float xz_43 = _S9859.y * _S9859.w; + float yz_43 = _S9859.z * _S9859.w; + float wx_43 = _S9859.x * _S9859.y; + float wy_43 = _S9859.x * _S9859.z; + float wz_43 = _S9859.x * _S9859.w; + Matrix _S9861 = transpose_3(transpose_3(makeMatrix (1.0f - 2.0f * (y2_43 + z2_43), 2.0f * (xy_43 + wz_43), 2.0f * (xz_43 - wy_43), 2.0f * (xy_43 - wz_43), 1.0f - 2.0f * (x2_43 + z2_43), 2.0f * (yz_43 + wx_43), 2.0f * (xz_43 + wy_43), 2.0f * (yz_43 - wx_43), 1.0f - 2.0f * (x2_43 + y2_43)))); + FixedArray _S9862 = { + _S9853, _S9853, _S9853, _S9853, _S9853, _S9853, _S9853 + }; + FixedArray _S9863 = { + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f + }; + SigmaPoints_0 _S9864; + (&_S9864)->p_0 = _S9862; + (&_S9864)->w_mean_0 = _S9863; + (&_S9864)->w_cov_0 = _S9863; + (&_S9864)->p_0[int(0)] = mean_44; + SigmaPoints_0 _S9865 = _S9864; + (&_S9865)->w_mean_0[int(0)] = 0.0f; + (&_S9865)->w_cov_0[int(0)] = 2.0f; + float _S9866 = s_primal_ctx_sqrt_0(3.0f); + float _S9867 = _S9866 * _S9858.x; + float3 _S9868 = make_float3 (_S9867); + float3 delta_63 = make_float3 (_S9867) * _S9861.rows[0U]; + float3 _S9869 = mean_44 + delta_63; + (&_S9865)->p_0[1U] = _S9869; + float3 _S9870 = mean_44 - delta_63; + (&_S9865)->p_0[4U] = _S9870; + float _S9871 = _S9866 * _S9858.y; + float3 _S9872 = make_float3 (_S9871); + float3 delta_64 = make_float3 (_S9871) * _S9861.rows[1U]; + float3 _S9873 = mean_44 + delta_64; + (&_S9865)->p_0[2U] = _S9873; + float3 _S9874 = mean_44 - delta_64; + (&_S9865)->p_0[5U] = _S9874; + float _S9875 = _S9866 * _S9858.z; + float3 _S9876 = make_float3 (_S9875); + float3 delta_65 = make_float3 (_S9875) * _S9861.rows[2U]; + float3 _S9877 = mean_44 + delta_65; + (&_S9865)->p_0[3U] = _S9877; + float3 _S9878 = mean_44 - delta_65; + (&_S9865)->p_0[6U] = _S9878; + (&_S9865)->w_mean_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S9879 = _S9865; + (&_S9879)->w_cov_0[1U] = 0.1666666716337204f; + SigmaPoints_0 _S9880 = _S9879; + (&_S9880)->w_mean_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S9881 = _S9880; + (&_S9881)->w_cov_0[2U] = 0.1666666716337204f; + SigmaPoints_0 _S9882 = _S9881; + (&_S9882)->w_mean_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S9883 = _S9882; + (&_S9883)->w_cov_0[3U] = 0.1666666716337204f; + SigmaPoints_0 _S9884 = _S9883; + (&_S9884)->w_mean_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S9885 = _S9884; + (&_S9885)->w_cov_0[4U] = 0.1666666716337204f; + SigmaPoints_0 _S9886 = _S9885; + (&_S9886)->w_mean_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S9887 = _S9886; + (&_S9887)->w_cov_0[5U] = 0.1666666716337204f; + SigmaPoints_0 _S9888 = _S9887; + (&_S9888)->w_mean_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S9889 = _S9888; + (&_S9889)->w_cov_0[6U] = 0.1666666716337204f; + SigmaPoints_0 _S9890 = _S9864; + float3 _S9891 = s_primal_ctx_mul_0(R_43, _S9864.p_0[0U]) + t_43; + _S9864 = _S9889; + (&_S9864)->p_0[0U] = _S9891; + SigmaPoints_0 _S9892 = _S9864; + (&_S9864)->p_0[1U] = s_primal_ctx_mul_0(R_43, _S9869) + t_43; + SigmaPoints_0 _S9893 = _S9864; + (&_S9864)->p_0[2U] = s_primal_ctx_mul_0(R_43, _S9873) + t_43; + SigmaPoints_0 _S9894 = _S9864; + (&_S9864)->p_0[3U] = s_primal_ctx_mul_0(R_43, _S9877) + t_43; + SigmaPoints_0 _S9895 = _S9864; + (&_S9864)->p_0[4U] = s_primal_ctx_mul_0(R_43, _S9870) + t_43; + SigmaPoints_0 _S9896 = _S9864; + (&_S9864)->p_0[5U] = s_primal_ctx_mul_0(R_43, _S9874) + t_43; + SigmaPoints_0 _S9897 = _S9864; + (&_S9864)->p_0[6U] = s_primal_ctx_mul_0(R_43, _S9878) + t_43; + float _S9898 = fx_56 * s_primal_ctx_atan2_0(_S9892.p_0[int(0)].x, _S9892.p_0[int(0)].z) + cx_47; + float _S9899 = fx_56 * s_primal_ctx_atan2_0(_S9893.p_0[int(1)].x, _S9893.p_0[int(1)].z) + cx_47; + float2 _S9900 = make_float2 (_S9899, fy_56 * s_primal_ctx_atan2_0(_S9893.p_0[int(1)].y, length_0(float2 {_S9893.p_0[int(1)].x, _S9893.p_0[int(1)].z})) + cy_47); + float2 _S9901 = make_float2 (fx_56 * s_primal_ctx_atan2_0(_S9894.p_0[int(2)].x, _S9894.p_0[int(2)].z) + cx_47, fy_56 * s_primal_ctx_atan2_0(_S9894.p_0[int(2)].y, length_0(float2 {_S9894.p_0[int(2)].x, _S9894.p_0[int(2)].z})) + cy_47); + float2 _S9902 = make_float2 (fx_56 * s_primal_ctx_atan2_0(_S9895.p_0[int(3)].x, _S9895.p_0[int(3)].z) + cx_47, fy_56 * s_primal_ctx_atan2_0(_S9895.p_0[int(3)].y, length_0(float2 {_S9895.p_0[int(3)].x, _S9895.p_0[int(3)].z})) + cy_47); + float2 _S9903 = make_float2 (fx_56 * s_primal_ctx_atan2_0(_S9896.p_0[int(4)].x, _S9896.p_0[int(4)].z) + cx_47, fy_56 * s_primal_ctx_atan2_0(_S9896.p_0[int(4)].y, length_0(float2 {_S9896.p_0[int(4)].x, _S9896.p_0[int(4)].z})) + cy_47); + float2 _S9904 = make_float2 (fx_56 * s_primal_ctx_atan2_0(_S9897.p_0[int(5)].x, _S9897.p_0[int(5)].z) + cx_47, fy_56 * s_primal_ctx_atan2_0(_S9897.p_0[int(5)].y, length_0(float2 {_S9897.p_0[int(5)].x, _S9897.p_0[int(5)].z})) + cy_47); + float2 _S9905 = make_float2 (fx_56 * s_primal_ctx_atan2_0(_S9864.p_0[int(6)].x, _S9864.p_0[int(6)].z) + cx_47, fy_56 * s_primal_ctx_atan2_0(_S9864.p_0[int(6)].y, length_0(float2 {_S9864.p_0[int(6)].x, _S9864.p_0[int(6)].z})) + cy_47); + float _S9906 = fx_56 * 6.28318548202514648f; + float du_6 = _S9899 - _S9898; + float _S9907 = _S9898 + (du_6 - _S9906 * (F32_round((du_6 / _S9906)))); + FixedArray _S9908; + _S9908[int(0)] = make_float2 (_S9898, fy_56 * s_primal_ctx_atan2_0(_S9892.p_0[int(0)].y, length_0(float2 {_S9892.p_0[int(0)].x, _S9892.p_0[int(0)].z})) + cy_47); + _S9908[int(1)] = _S9900; + _S9908[int(2)] = _S9901; + _S9908[int(3)] = _S9902; + _S9908[int(4)] = _S9903; + _S9908[int(5)] = _S9904; + _S9908[int(6)] = _S9905; + *&((&_S9908[int(1)])->x) = _S9907; + float du_7 = _S9908[int(2)].x - _S9898; + *&((&_S9908[int(2)])->x) = _S9898 + (du_7 - _S9906 * (F32_round((du_7 / _S9906)))); + float du_8 = _S9908[int(3)].x - _S9898; + *&((&_S9908[int(3)])->x) = _S9898 + (du_8 - _S9906 * (F32_round((du_8 / _S9906)))); + float du_9 = _S9908[int(4)].x - _S9898; + *&((&_S9908[int(4)])->x) = _S9898 + (du_9 - _S9906 * (F32_round((du_9 / _S9906)))); + float du_10 = _S9908[int(5)].x - _S9898; + *&((&_S9908[int(5)])->x) = _S9898 + (du_10 - _S9906 * (F32_round((du_10 / _S9906)))); + float du_11 = _S9908[int(6)].x - _S9898; + *&((&_S9908[int(6)])->x) = _S9898 + (du_11 - _S9906 * (F32_round((du_11 / _S9906)))); + float2 _S9909 = make_float2 (_S9865.w_mean_0[int(1)]); + float2 _S9910 = make_float2 (_S9880.w_mean_0[int(2)]); + float2 _S9911 = make_float2 (_S9882.w_mean_0[int(3)]); + float2 _S9912 = make_float2 (_S9884.w_mean_0[int(4)]); + float2 _S9913 = make_float2 (_S9886.w_mean_0[int(5)]); + float2 _S9914 = make_float2 (_S9888.w_mean_0[int(6)]); + float2 _S9915 = make_float2 (_S9865.w_mean_0[int(1)]) * _S9908[int(1)] + make_float2 (_S9880.w_mean_0[int(2)]) * _S9908[int(2)] + make_float2 (_S9882.w_mean_0[int(3)]) * _S9908[int(3)] + make_float2 (_S9884.w_mean_0[int(4)]) * _S9908[int(4)] + make_float2 (_S9886.w_mean_0[int(5)]) * _S9908[int(5)] + make_float2 (_S9888.w_mean_0[int(6)]) * _S9908[int(6)]; + float2 d_147 = _S9908[int(0)] - _S9915; + float _S9916 = d_147.x; + float _S9917 = d_147.y; + float _S9918 = _S9916 * _S9917; + float2 d_148 = _S9908[int(1)] - _S9915; + Matrix _S9919 = makeMatrix (_S9879.w_cov_0[int(1)]); + float _S9920 = d_148.x; + float _S9921 = d_148.y; + float _S9922 = _S9920 * _S9921; + float2 d_149 = _S9908[int(2)] - _S9915; + Matrix _S9923 = makeMatrix (_S9881.w_cov_0[int(2)]); + float _S9924 = d_149.x; + float _S9925 = d_149.y; + float _S9926 = _S9924 * _S9925; + float2 d_150 = _S9908[int(3)] - _S9915; + Matrix _S9927 = makeMatrix (_S9883.w_cov_0[int(3)]); + float _S9928 = d_150.x; + float _S9929 = d_150.y; + float _S9930 = _S9928 * _S9929; + float2 d_151 = _S9908[int(4)] - _S9915; + Matrix _S9931 = makeMatrix (_S9885.w_cov_0[int(4)]); + float _S9932 = d_151.x; + float _S9933 = d_151.y; + float _S9934 = _S9932 * _S9933; + float2 d_152 = _S9908[int(5)] - _S9915; + Matrix _S9935 = makeMatrix (_S9887.w_cov_0[int(5)]); + float _S9936 = d_152.x; + float _S9937 = d_152.y; + float _S9938 = _S9936 * _S9937; + float2 d_153 = _S9908[int(6)] - _S9915; + Matrix _S9939 = makeMatrix (_S9889.w_cov_0[int(6)]); + float _S9940 = d_153.x; + float _S9941 = d_153.y; + float _S9942 = _S9940 * _S9941; + Matrix covar2d_32 = makeMatrix (2.0f) * makeMatrix (_S9916 * _S9916, _S9918, _S9918, _S9917 * _S9917) + makeMatrix (_S9879.w_cov_0[int(1)]) * makeMatrix (_S9920 * _S9920, _S9922, _S9922, _S9921 * _S9921) + makeMatrix (_S9881.w_cov_0[int(2)]) * makeMatrix (_S9924 * _S9924, _S9926, _S9926, _S9925 * _S9925) + makeMatrix (_S9883.w_cov_0[int(3)]) * makeMatrix (_S9928 * _S9928, _S9930, _S9930, _S9929 * _S9929) + makeMatrix (_S9885.w_cov_0[int(4)]) * makeMatrix (_S9932 * _S9932, _S9934, _S9934, _S9933 * _S9933) + makeMatrix (_S9887.w_cov_0[int(5)]) * makeMatrix (_S9936 * _S9936, _S9938, _S9938, _S9937 * _S9937) + makeMatrix (_S9889.w_cov_0[int(6)]) * makeMatrix (_S9940 * _S9940, _S9942, _S9942, _S9941 * _S9941); + float eps2d_43; + if(antialiased_43) + { + eps2d_43 = 0.10000000149011612f; + } + else + { + eps2d_43 = 0.30000001192092896f; + } + float _S9943 = covar2d_32.rows[int(0)].y * covar2d_32.rows[int(1)].x; + float det_orig_43 = covar2d_32.rows[int(0)].x * covar2d_32.rows[int(1)].y - _S9943; + float _S9944 = covar2d_32.rows[int(0)].x + eps2d_43; + Matrix _S9945 = covar2d_32; + *&(((&_S9945)->rows + (int(0)))->x) = _S9944; + float _S9946 = covar2d_32.rows[int(1)].y + eps2d_43; + *&(((&_S9945)->rows + (int(1)))->y) = _S9946; + Matrix _S9947 = _S9945; + Matrix _S9948 = _S9945; + float det_blur_43 = _S9944 * _S9946 - _S9943; + float _S9949 = det_orig_43 / det_blur_43; + float _S9950 = det_blur_43 * det_blur_43; + float _S9951 = (F32_max((0.0f), (_S9949))); + float _S9952 = s_primal_ctx_sqrt_0(_S9951); + float invdet_49 = 1.0f / det_blur_43; + float _S9953 = - covar2d_32.rows[int(0)].y; + float _S9954 = - covar2d_32.rows[int(1)].x; + if(antialiased_43) + { + eps2d_43 = _S9856 * _S9952; + } + else + { + eps2d_43 = _S9856; + } + float _S9955 = eps2d_43 / 0.00392156885936856f; + float _S9956 = 2.0f * s_primal_ctx_log_0(_S9955); + float _S9957 = s_primal_ctx_sqrt_0(_S9956); + float _S9958 = _S9947.rows[int(0)].x; + float _S9959 = _S9948.rows[int(1)].y; + float3 campos_22 = - s_primal_ctx_mul_0(transpose_3(R_43), t_43); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9960; + (&_S9960)->primal_0 = mean_44; + (&_S9960)->differential_0 = _S9853; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9961; + (&_S9961)->primal_0 = scale_43; + (&_S9961)->differential_0 = _S9853; + DiffPair_float_0 _S9962; + (&_S9962)->primal_0 = in_opacity_43; + (&_S9962)->differential_0 = 0.0f; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9963; + (&_S9963)->primal_0 = campos_22; + (&_S9963)->differential_0 = _S9853; + s_bwd_prop_view_radius_3dgs_0(&_S9960, &_S9961, &_S9962, &_S9963, 0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9964 = _S9960; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9965 = _S9961; + DiffPair_float_0 _S9966 = _S9962; + float2 _S9967 = make_float2 (0.0f); + float2 _S9968 = _S9967; + *&((&_S9968)->y) = v_conic_21.z; + float2 _S9969 = _S9967; + *&((&_S9969)->y) = v_conic_21.y; + *&((&_S9969)->x) = v_conic_21.x; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9970; + (&_S9970)->primal_0 = mean_c_43; + (&_S9970)->differential_0 = _S9853; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S9971; + (&_S9971)->primal_0 = mean_c_43; + (&_S9971)->differential_0 = _S9853; + s_bwd_prop_dot_0(&_S9970, &_S9971, 0.0f); + DiffPair_float_0 _S9972; + (&_S9972)->primal_0 = _S9959; + (&_S9972)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9972, 0.0f); + DiffPair_float_0 _S9973; + (&_S9973)->primal_0 = _S9958; + (&_S9973)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9973, 0.0f); + DiffPair_float_0 _S9974; + (&_S9974)->primal_0 = 3.32999992370605469f; + (&_S9974)->differential_0 = 0.0f; + DiffPair_float_0 _S9975; + (&_S9975)->primal_0 = _S9957; + (&_S9975)->differential_0 = 0.0f; + _d_min_0(&_S9974, &_S9975, 0.0f); + DiffPair_float_0 _S9976; + (&_S9976)->primal_0 = _S9956; + (&_S9976)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9976, _S9975.differential_0); + float _S9977 = 2.0f * _S9976.differential_0; + DiffPair_float_0 _S9978; + (&_S9978)->primal_0 = _S9955; + (&_S9978)->differential_0 = 0.0f; + s_bwd_prop_log_0(&_S9978, _S9977); + float _S9979 = v_opacity_21 + 254.9999847412109375f * _S9978.differential_0; + Matrix _S9980 = makeMatrix (0.0f); + Matrix _S9981 = _S9980; + _S9981[int(1)] = _S9968; + _S9981[int(0)] = _S9969; + Matrix _S9982 = _S9981; + float3 _S9983 = _S9971.differential_0 + _S9970.differential_0; + float2 _S9984 = make_float2 (0.0f, _S9972.differential_0); + float2 _S9985 = make_float2 (_S9973.differential_0, 0.0f); + float _S9986; + if(antialiased_43) + { + float _S9987 = _S9952 * _S9979; + eps2d_43 = _S9856 * _S9979; + _S9986 = _S9987; + } + else + { + eps2d_43 = 0.0f; + _S9986 = _S9979; + } + float _S9988 = invdet_49 * _S9982.rows[int(1)].y; + float _S9989 = - (invdet_49 * _S9982.rows[int(1)].x); + float _S9990 = - (invdet_49 * _S9982.rows[int(0)].y); + float _S9991 = invdet_49 * _S9982.rows[int(0)].x; + float _S9992 = - ((_S9944 * _S9982.rows[int(1)].y + _S9954 * _S9982.rows[int(1)].x + _S9953 * _S9982.rows[int(0)].y + _S9946 * _S9982.rows[int(0)].x) / _S9950); + DiffPair_float_0 _S9993; + (&_S9993)->primal_0 = _S9951; + (&_S9993)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S9993, eps2d_43); + DiffPair_float_0 _S9994; + (&_S9994)->primal_0 = 0.0f; + (&_S9994)->differential_0 = 0.0f; + DiffPair_float_0 _S9995; + (&_S9995)->primal_0 = _S9949; + (&_S9995)->differential_0 = 0.0f; + _d_max_0(&_S9994, &_S9995, _S9993.differential_0); + float _S9996 = _S9995.differential_0 / _S9950; + float s_diff_det_orig_T_21 = det_blur_43 * _S9996; + float _S9997 = det_orig_43 * - _S9996 + _S9992; + float _S9998 = - _S9997; + float _S9999 = _S9944 * _S9997; + float _S10000 = _S9946 * _S9997; + Matrix _S10001 = _S9980; + _S10001[int(1)] = _S9984; + _S10001[int(0)] = _S9985; + _S9945 = _S10001; + *&(((&_S9945)->rows + (int(1)))->y) = 0.0f; + float _S10002 = _S9999 + _S10001.rows[int(1)].y + _S9991; + *&(((&_S9945)->rows + (int(0)))->x) = 0.0f; + float _S10003 = _S10000 + _S10001.rows[int(0)].x + _S9988; + float _S10004 = _S9998 + - s_diff_det_orig_T_21; + float _S10005 = covar2d_32.rows[int(0)].y * _S10004 + _S9989; + float _S10006 = covar2d_32.rows[int(1)].x * _S10004 + _S9990; + float _S10007 = covar2d_32.rows[int(1)].y * s_diff_det_orig_T_21; + float _S10008 = _S10002 + covar2d_32.rows[int(0)].x * s_diff_det_orig_T_21; + float2 _S10009 = _S9967; + *&((&_S10009)->x) = _S10005; + *&((&_S10009)->y) = _S10008; + float _S10010 = _S10003 + _S10007; + float2 _S10011 = _S9967; + *&((&_S10011)->y) = _S10006; + *&((&_S10011)->x) = _S10010; + Matrix _S10012 = _S9980; + _S10012[int(1)] = _S10009; + _S10012[int(0)] = _S10011; + Matrix _S10013 = _S9945 + _S10012; + Matrix _S10014 = _S9939 * _S10013; + float _S10015 = _S9941 * _S10014.rows[int(1)].y; + float _S10016 = _S10014.rows[int(0)].y + _S10014.rows[int(1)].x; + float _S10017 = _S9940 * _S10014.rows[int(0)].x; + float2 s_diff_d_T_0 = make_float2 (_S9941 * _S10016 + _S10017 + _S10017, _S10015 + _S10015 + _S9940 * _S10016); + Matrix _S10018 = _S9935 * _S10013; + float _S10019 = _S9937 * _S10018.rows[int(1)].y; + float _S10020 = _S10018.rows[int(0)].y + _S10018.rows[int(1)].x; + float _S10021 = _S9936 * _S10018.rows[int(0)].x; + float2 s_diff_d_T_1 = make_float2 (_S9937 * _S10020 + _S10021 + _S10021, _S10019 + _S10019 + _S9936 * _S10020); + Matrix _S10022 = _S9931 * _S10013; + float _S10023 = _S9933 * _S10022.rows[int(1)].y; + float _S10024 = _S10022.rows[int(0)].y + _S10022.rows[int(1)].x; + float _S10025 = _S9932 * _S10022.rows[int(0)].x; + float2 s_diff_d_T_2 = make_float2 (_S9933 * _S10024 + _S10025 + _S10025, _S10023 + _S10023 + _S9932 * _S10024); + Matrix _S10026 = _S9927 * _S10013; + float _S10027 = _S9929 * _S10026.rows[int(1)].y; + float _S10028 = _S10026.rows[int(0)].y + _S10026.rows[int(1)].x; + float _S10029 = _S9928 * _S10026.rows[int(0)].x; + float2 s_diff_d_T_3 = make_float2 (_S9929 * _S10028 + _S10029 + _S10029, _S10027 + _S10027 + _S9928 * _S10028); + Matrix _S10030 = _S9923 * _S10013; + float _S10031 = _S9925 * _S10030.rows[int(1)].y; + float _S10032 = _S10030.rows[int(0)].y + _S10030.rows[int(1)].x; + float _S10033 = _S9924 * _S10030.rows[int(0)].x; + float2 s_diff_d_T_4 = make_float2 (_S9925 * _S10032 + _S10033 + _S10033, _S10031 + _S10031 + _S9924 * _S10032); + Matrix _S10034 = _S9919 * _S10013; + float _S10035 = _S9921 * _S10034.rows[int(1)].y; + float _S10036 = _S10034.rows[int(0)].y + _S10034.rows[int(1)].x; + float _S10037 = _S9920 * _S10034.rows[int(0)].x; + float2 s_diff_d_T_5 = make_float2 (_S9921 * _S10036 + _S10037 + _S10037, _S10035 + _S10035 + _S9920 * _S10036); + Matrix _S10038 = makeMatrix (2.0f) * _S10013; + float _S10039 = _S9917 * _S10038.rows[int(1)].y; + float _S10040 = _S10038.rows[int(0)].y + _S10038.rows[int(1)].x; + float _S10041 = _S9916 * _S10038.rows[int(0)].x; + float2 s_diff_d_T_6 = make_float2 (_S9917 * _S10040 + _S10041 + _S10041, _S10039 + _S10039 + _S9916 * _S10040); + float2 _S10042 = - s_diff_d_T_0 + - s_diff_d_T_1 + - s_diff_d_T_2 + - s_diff_d_T_3 + - s_diff_d_T_4 + - s_diff_d_T_5 + - s_diff_d_T_6 + v_mean2d_21; + float2 _S10043 = s_diff_d_T_0 + _S9914 * _S10042; + float2 _S10044 = s_diff_d_T_1 + _S9913 * _S10042; + float2 _S10045 = s_diff_d_T_2 + _S9912 * _S10042; + float2 _S10046 = s_diff_d_T_3 + _S9911 * _S10042; + float2 _S10047 = s_diff_d_T_4 + _S9910 * _S10042; + float2 _S10048 = s_diff_d_T_5 + _S9909 * _S10042; + FixedArray _S10049; + _S10049[int(0)] = _S9967; + _S10049[int(1)] = _S9967; + _S10049[int(2)] = _S9967; + _S10049[int(3)] = _S9967; + _S10049[int(4)] = _S9967; + _S10049[int(5)] = _S9967; + _S10049[int(6)] = _S9967; + _S10049[int(6)] = _S10043; + _S10049[int(5)] = _S10044; + _S10049[int(4)] = _S10045; + _S10049[int(3)] = _S10046; + _S10049[int(2)] = _S10047; + _S10049[int(1)] = _S10048; + _S10049[int(0)] = s_diff_d_T_6; + _S9908 = _S10049; + *&((&_S9908[int(6)])->x) = 0.0f; + float2 _S10050 = make_float2 (_S10049[int(6)].x, 0.0f); + FixedArray _S10051; + _S10051[int(0)] = _S9967; + _S10051[int(1)] = _S9967; + _S10051[int(2)] = _S9967; + _S10051[int(3)] = _S9967; + _S10051[int(4)] = _S9967; + _S10051[int(5)] = _S9967; + _S10051[int(6)] = _S9967; + _S10051[int(6)] = _S10050; + float2 _S10052 = _S9908[int(1)] + _S10051[int(1)]; + float2 _S10053 = _S9908[int(2)] + _S10051[int(2)]; + float2 _S10054 = _S9908[int(3)] + _S10051[int(3)]; + float2 _S10055 = _S9908[int(4)] + _S10051[int(4)]; + float2 _S10056 = _S9908[int(5)] + _S10051[int(5)]; + float2 _S10057 = _S9908[int(6)] + _S10051[int(6)]; + _S9908[int(0)] = _S9908[int(0)] + _S10051[int(0)]; + _S9908[int(1)] = _S10052; + _S9908[int(2)] = _S10053; + _S9908[int(3)] = _S10054; + _S9908[int(4)] = _S10055; + _S9908[int(5)] = _S10056; + _S9908[int(6)] = _S10057; + *&((&_S9908[int(5)])->x) = 0.0f; + float2 _S10058 = make_float2 (_S10056.x, 0.0f); + FixedArray _S10059; + _S10059[int(0)] = _S9967; + _S10059[int(1)] = _S9967; + _S10059[int(2)] = _S9967; + _S10059[int(3)] = _S9967; + _S10059[int(4)] = _S9967; + _S10059[int(5)] = _S9967; + _S10059[int(6)] = _S9967; + _S10059[int(5)] = _S10058; + float2 _S10060 = _S9908[int(1)] + _S10059[int(1)]; + float2 _S10061 = _S9908[int(2)] + _S10059[int(2)]; + float2 _S10062 = _S9908[int(3)] + _S10059[int(3)]; + float2 _S10063 = _S9908[int(4)] + _S10059[int(4)]; + float2 _S10064 = _S9908[int(5)] + _S10059[int(5)]; + float2 _S10065 = _S9908[int(6)] + _S10059[int(6)]; + _S9908[int(0)] = _S9908[int(0)] + _S10059[int(0)]; + _S9908[int(1)] = _S10060; + _S9908[int(2)] = _S10061; + _S9908[int(3)] = _S10062; + _S9908[int(4)] = _S10063; + _S9908[int(5)] = _S10064; + _S9908[int(6)] = _S10065; + *&((&_S9908[int(4)])->x) = 0.0f; + Matrix _S10066 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S10067; + (&_S10067)->primal_0 = R_43; + (&_S10067)->differential_0 = _S10066; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10068; + (&_S10068)->primal_0 = _S9878; + (&_S10068)->differential_0 = _S9853; + s_bwd_prop_mul_3(&_S10067, &_S10068, _S9853); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S10069; + (&_S10069)->primal_0 = R_43; + (&_S10069)->differential_0 = _S10066; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10070; + (&_S10070)->primal_0 = _S9874; + (&_S10070)->differential_0 = _S9853; + s_bwd_prop_mul_3(&_S10069, &_S10070, _S9853); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S10071; + (&_S10071)->primal_0 = R_43; + (&_S10071)->differential_0 = _S10066; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10072; + (&_S10072)->primal_0 = _S9870; + (&_S10072)->differential_0 = _S9853; + s_bwd_prop_mul_3(&_S10071, &_S10072, _S9853); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S10073; + (&_S10073)->primal_0 = R_43; + (&_S10073)->differential_0 = _S10066; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10074; + (&_S10074)->primal_0 = _S9877; + (&_S10074)->differential_0 = _S9853; + s_bwd_prop_mul_3(&_S10073, &_S10074, _S9853); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S10075; + (&_S10075)->primal_0 = R_43; + (&_S10075)->differential_0 = _S10066; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10076; + (&_S10076)->primal_0 = _S9873; + (&_S10076)->differential_0 = _S9853; + s_bwd_prop_mul_3(&_S10075, &_S10076, _S9853); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S10077; + (&_S10077)->primal_0 = R_43; + (&_S10077)->differential_0 = _S10066; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10078; + (&_S10078)->primal_0 = _S9869; + (&_S10078)->differential_0 = _S9853; + s_bwd_prop_mul_3(&_S10077, &_S10078, _S9853); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S10079; + (&_S10079)->primal_0 = R_43; + (&_S10079)->differential_0 = _S10066; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10080; + (&_S10080)->primal_0 = _S9890.p_0[0U]; + (&_S10080)->differential_0 = _S9853; + s_bwd_prop_mul_3(&_S10079, &_S10080, _S9853); + float3 _S10081 = - _S10068.differential_0 + _S10074.differential_0; + float3 _S10082 = _S9876 * _S10081; + float3 _S10083 = _S9861.rows[2U] * _S10081; + float _S10084 = _S9866 * (_S10083.x + _S10083.y + _S10083.z); + float3 _S10085 = - _S10070.differential_0 + _S10076.differential_0; + float3 _S10086 = _S9872 * _S10085; + float3 _S10087 = _S9861.rows[1U] * _S10085; + float _S10088 = _S9866 * (_S10087.x + _S10087.y + _S10087.z); + float3 _S10089 = - _S10072.differential_0 + _S10078.differential_0; + float3 _S10090 = _S9868 * _S10089; + float3 _S10091 = _S9861.rows[0U] * _S10089; + float _S10092 = _S9866 * (_S10091.x + _S10091.y + _S10091.z); + Matrix _S10093 = _S10066; + _S10093[2U] = _S10082; + _S10093[1U] = _S10086; + _S10093[0U] = _S10090; + Matrix _S10094 = transpose_3(transpose_3(_S10093)); + float _S10095 = 2.0f * - _S10094.rows[int(2)].z; + float _S10096 = 2.0f * _S10094.rows[int(2)].y; + float _S10097 = 2.0f * _S10094.rows[int(2)].x; + float _S10098 = 2.0f * _S10094.rows[int(1)].z; + float _S10099 = 2.0f * - _S10094.rows[int(1)].y; + float _S10100 = 2.0f * _S10094.rows[int(1)].x; + float _S10101 = 2.0f * _S10094.rows[int(0)].z; + float _S10102 = 2.0f * _S10094.rows[int(0)].y; + float _S10103 = 2.0f * - _S10094.rows[int(0)].x; + float _S10104 = - _S10100 + _S10102; + float _S10105 = _S10097 + - _S10101; + float _S10106 = - _S10096 + _S10098; + float _S10107 = _S10096 + _S10098; + float _S10108 = _S10097 + _S10101; + float _S10109 = _S10100 + _S10102; + float _S10110 = _S9859.w * (_S10099 + _S10103); + float _S10111 = _S9859.z * (_S10095 + _S10103); + float _S10112 = _S9859.y * (_S10095 + _S10099); + float _S10113 = _S9859.x * _S10104 + _S9859.z * _S10107 + _S9859.y * _S10108 + _S10110 + _S10110; + float _S10114 = _S9859.x * _S10105 + _S9859.w * _S10107 + _S9859.y * _S10109 + _S10111 + _S10111; + float _S10115 = _S9859.x * _S10106 + _S9859.w * _S10108 + _S9859.z * _S10109 + _S10112 + _S10112; + float _S10116 = _S9859.w * _S10104 + _S9859.z * _S10105 + _S9859.y * _S10106; + float4 _S10117 = make_float4 (0.0f); + float4 _S10118 = _S10117; + *&((&_S10118)->w) = _S10113; + *&((&_S10118)->z) = _S10114; + *&((&_S10118)->y) = _S10115; + *&((&_S10118)->x) = _S10116; + DiffPair_vectorx3Cfloatx2C4x3E_0 _S10119; + (&_S10119)->primal_0 = quat_43; + (&_S10119)->differential_0 = _S10117; + s_bwd_normalize_impl_0(&_S10119, _S10118); + float3 _S10120 = _S9853; + *&((&_S10120)->z) = _S10084; + *&((&_S10120)->y) = _S10088; + *&((&_S10120)->x) = _S10092; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10121; + (&_S10121)->primal_0 = scale_43; + (&_S10121)->differential_0 = _S9853; + s_bwd_prop_exp_1(&_S10121, _S10120); + float _S10122 = - (_S9986 / _S9857); + DiffPair_float_0 _S10123; + (&_S10123)->primal_0 = _S9854; + (&_S10123)->differential_0 = 0.0f; + s_bwd_prop_exp_0(&_S10123, _S10122); + float _S10124 = - _S10123.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10125; + (&_S10125)->primal_0 = mean_c_43; + (&_S10125)->differential_0 = _S9853; + s_bwd_length_impl_0(&_S10125, v_depth_21); + float3 _S10126 = _S10125.differential_0 + _S9983; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S10127; + (&_S10127)->primal_0 = R_43; + (&_S10127)->differential_0 = _S10066; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S10128; + (&_S10128)->primal_0 = mean_44; + (&_S10128)->differential_0 = _S9853; + s_bwd_prop_mul_3(&_S10127, &_S10128, _S10126); + Matrix _S10129 = _S10067.differential_0 + _S10069.differential_0 + _S10071.differential_0 + _S10073.differential_0 + _S10075.differential_0 + _S10077.differential_0 + _S10079.differential_0 + _S10127.differential_0; + float _S10130 = _S10124 + _S9966.differential_0; + float3 _S10131 = _S10121.differential_0 + _S9965.differential_0; + *v_mean_21 = *v_mean_21 + (_S10068.differential_0 + _S10074.differential_0 + _S10070.differential_0 + _S10076.differential_0 + _S10072.differential_0 + _S10078.differential_0 + _S10128.differential_0 + _S9964.differential_0); + *v_quat_21 = *v_quat_21 + _S10119.differential_0; + *v_scale_21 = *v_scale_21 + _S10131; + *v_in_opacity_21 = *v_in_opacity_21 + _S10130; + *v_R_21 = *v_R_21 + _S10129; + *v_t_21 = *v_t_21 + _S10126; return; } diff --git a/src/generated/projection_utils.cuh b/src/generated/projection_utils.cuh index c30983a9..8c5e41b6 100644 --- a/src/generated/projection_utils.cuh +++ b/src/generated/projection_utils.cuh @@ -350,190 +350,49 @@ inline __device__ float3 apply_covar_to_vec(float4 quat_4, float3 scale_3, fl return mul_2(mul_1(M_2, transpose_0(M_2)), vec_1); } -inline __device__ float determinant_0(Matrix m_0) -{ - return m_0.rows[int(0)].x * m_0.rows[int(1)].y - m_0.rows[int(0)].y * m_0.rows[int(1)].x; -} - -inline __device__ bool is_valid_distortion(float2 uv_0, FixedArray dist_coeffs_0) -{ - float u_0 = uv_0.x; - float v_0 = uv_0.y; - float _S4 = 0.0f * v_0; - float r2_0 = u_0 * u_0 + v_0 * v_0; - float s_diff_r2_0 = u_0 + u_0 + (_S4 + _S4); - float _S5 = dist_coeffs_0[int(2)] + r2_0 * dist_coeffs_0[int(3)]; - float _S6 = dist_coeffs_0[int(1)] + r2_0 * _S5; - float _S7 = dist_coeffs_0[int(0)] + r2_0 * _S6; - float radial_0 = 1.0f + r2_0 * _S7; - float _S8 = 2.0f * dist_coeffs_0[int(4)]; - float _S9 = _S8 * u_0; - float _S10 = 2.0f * u_0; - float _S11 = 2.0f * dist_coeffs_0[int(5)]; - float _S12 = _S11 * u_0; - float _S13 = 2.0f * v_0; - float2 _S14 = make_float2 (1.0f, 0.0f) * make_float2 (radial_0) + make_float2 (s_diff_r2_0 * _S7 + (s_diff_r2_0 * _S6 + (s_diff_r2_0 * _S5 + s_diff_r2_0 * dist_coeffs_0[int(3)] * r2_0) * r2_0) * r2_0) * uv_0 + make_float2 (_S8 * v_0 + 0.0f * _S9 + (s_diff_r2_0 + (_S10 + _S10)) * dist_coeffs_0[int(5)] + s_diff_r2_0 * dist_coeffs_0[int(6)], _S11 * v_0 + 0.0f * _S12 + (s_diff_r2_0 + (_S4 + 0.0f * _S13)) * dist_coeffs_0[int(4)] + s_diff_r2_0 * dist_coeffs_0[int(7)]); - float _S15 = 0.0f * u_0; - float s_diff_r2_1 = _S15 + _S15 + (v_0 + v_0); - float2 _S16 = make_float2 (0.0f, 1.0f) * make_float2 (radial_0) + make_float2 (s_diff_r2_1 * _S7 + (s_diff_r2_1 * _S6 + (s_diff_r2_1 * _S5 + s_diff_r2_1 * dist_coeffs_0[int(3)] * r2_0) * r2_0) * r2_0) * uv_0 + make_float2 (0.0f * _S8 * v_0 + _S9 + (s_diff_r2_1 + (_S15 + 0.0f * _S10)) * dist_coeffs_0[int(5)] + s_diff_r2_1 * dist_coeffs_0[int(6)], 0.0f * _S11 * v_0 + _S12 + (s_diff_r2_1 + (_S13 + _S13)) * dist_coeffs_0[int(4)] + s_diff_r2_1 * dist_coeffs_0[int(7)]); - Matrix _S17 = transpose_1(makeMatrix (_S14 + make_float2 (_S14.x * dist_coeffs_0[int(8)] + _S14.y * dist_coeffs_0[int(9)], 0.0f), _S16 + make_float2 (_S16.x * dist_coeffs_0[int(8)] + _S16.y * dist_coeffs_0[int(9)], 0.0f))); - return (F32_min((determinant_0(_S17)), ((F32_min((_S17.rows[int(0)].x), (_S17.rows[int(1)].y)))))) > 0.0f; -} - -inline __device__ bool persp_proj_nav(float3 p_view_0, float4 intrins_0, FixedArray dist_coeffs_1, float2 * uv_1) -{ - bool _S18; - for(;;) - { - float _S19 = p_view_0.z; - *uv_1 = float2 {p_view_0.x, p_view_0.y} / make_float2 (_S19); - if(_S19 < 0.0f) - { - _S18 = true; - } - else - { - float u_1 = (*uv_1).x; - float v_1 = (*uv_1).y; - float _S20 = 0.0f * v_1; - float r2_1 = u_1 * u_1 + v_1 * v_1; - float s_diff_r2_2 = u_1 + u_1 + (_S20 + _S20); - float _S21 = dist_coeffs_1[int(2)] + r2_1 * dist_coeffs_1[int(3)]; - float _S22 = dist_coeffs_1[int(1)] + r2_1 * _S21; - float _S23 = dist_coeffs_1[int(0)] + r2_1 * _S22; - float radial_1 = 1.0f + r2_1 * _S23; - float _S24 = 2.0f * dist_coeffs_1[int(4)]; - float _S25 = _S24 * u_1; - float _S26 = 2.0f * u_1; - float _S27 = 2.0f * dist_coeffs_1[int(5)]; - float _S28 = _S27 * u_1; - float _S29 = 2.0f * v_1; - float2 _S30 = make_float2 (1.0f, 0.0f) * make_float2 (radial_1) + make_float2 (s_diff_r2_2 * _S23 + (s_diff_r2_2 * _S22 + (s_diff_r2_2 * _S21 + s_diff_r2_2 * dist_coeffs_1[int(3)] * r2_1) * r2_1) * r2_1) * *uv_1 + make_float2 (_S24 * v_1 + 0.0f * _S25 + (s_diff_r2_2 + (_S26 + _S26)) * dist_coeffs_1[int(5)] + s_diff_r2_2 * dist_coeffs_1[int(6)], _S27 * v_1 + 0.0f * _S28 + (s_diff_r2_2 + (_S20 + 0.0f * _S29)) * dist_coeffs_1[int(4)] + s_diff_r2_2 * dist_coeffs_1[int(7)]); - float _S31 = 0.0f * u_1; - float s_diff_r2_3 = _S31 + _S31 + (v_1 + v_1); - float2 _S32 = make_float2 (0.0f, 1.0f) * make_float2 (radial_1) + make_float2 (s_diff_r2_3 * _S23 + (s_diff_r2_3 * _S22 + (s_diff_r2_3 * _S21 + s_diff_r2_3 * dist_coeffs_1[int(3)] * r2_1) * r2_1) * r2_1) * *uv_1 + make_float2 (0.0f * _S24 * v_1 + _S25 + (s_diff_r2_3 + (_S31 + 0.0f * _S26)) * dist_coeffs_1[int(5)] + s_diff_r2_3 * dist_coeffs_1[int(6)], 0.0f * _S27 * v_1 + _S28 + (s_diff_r2_3 + (_S29 + _S29)) * dist_coeffs_1[int(4)] + s_diff_r2_3 * dist_coeffs_1[int(7)]); - Matrix _S33 = transpose_1(makeMatrix (_S30 + make_float2 (_S30.x * dist_coeffs_1[int(8)] + _S30.y * dist_coeffs_1[int(9)], 0.0f), _S32 + make_float2 (_S32.x * dist_coeffs_1[int(8)] + _S32.y * dist_coeffs_1[int(9)], 0.0f))); - _S18 = !((F32_min((determinant_0(_S33)), ((F32_min((_S33.rows[int(0)].x), (_S33.rows[int(1)].y)))))) > 0.0f); - } - if(_S18) - { - break; - } - float u_2 = (*uv_1).x; - float v_2 = (*uv_1).y; - float r2_2 = u_2 * u_2 + v_2 * v_2; - float2 _S34 = *uv_1 * make_float2 (1.0f + r2_2 * (dist_coeffs_1[int(0)] + r2_2 * (dist_coeffs_1[int(1)] + r2_2 * (dist_coeffs_1[int(2)] + r2_2 * dist_coeffs_1[int(3)])))) + make_float2 (2.0f * dist_coeffs_1[int(4)] * u_2 * v_2 + dist_coeffs_1[int(5)] * (r2_2 + 2.0f * u_2 * u_2) + dist_coeffs_1[int(6)] * r2_2, 2.0f * dist_coeffs_1[int(5)] * u_2 * v_2 + dist_coeffs_1[int(4)] * (r2_2 + 2.0f * v_2 * v_2) + dist_coeffs_1[int(7)] * r2_2); - float2 _S35 = _S34 + make_float2 (dist_coeffs_1[int(8)] * _S34.x + dist_coeffs_1[int(9)] * _S34.y, 0.0f); - *uv_1 = make_float2 (intrins_0.x * _S35.x + intrins_0.z, intrins_0.y * _S35.y + intrins_0.w); - break; - } - return !_S18; -} - -inline __device__ Matrix persp_proj_jac(float3 p_view_1, float4 intrins_1, FixedArray dist_coeffs_2) -{ - float2 _S36 = float2 {p_view_1.x, p_view_1.y}; - float _S37 = p_view_1.z; - float2 _S38 = _S36 / make_float2 (_S37); - float2 _S39 = _S36 * make_float2 (0.0f); - float _S40 = _S37 * _S37; - float2 _S41 = (make_float2 (1.0f, 0.0f) * make_float2 (_S37) - _S39) / make_float2 (_S40); - float u_3 = _S38.x; - float s_diff_u_0 = _S41.x; - float v_3 = _S38.y; - float s_diff_v_0 = _S41.y; - float _S42 = s_diff_u_0 * u_3; - float _S43 = s_diff_v_0 * v_3; - float r2_3 = u_3 * u_3 + v_3 * v_3; - float s_diff_r2_4 = _S42 + _S42 + (_S43 + _S43); - float _S44 = dist_coeffs_2[int(2)] + r2_3 * dist_coeffs_2[int(3)]; - float _S45 = dist_coeffs_2[int(1)] + r2_3 * _S44; - float _S46 = dist_coeffs_2[int(0)] + r2_3 * _S45; - float _S47 = 2.0f * dist_coeffs_2[int(4)]; - float _S48 = 2.0f * dist_coeffs_2[int(5)]; - float2 _S49 = _S41 * make_float2 (1.0f + r2_3 * _S46) + make_float2 (s_diff_r2_4 * _S46 + (s_diff_r2_4 * _S45 + (s_diff_r2_4 * _S44 + s_diff_r2_4 * dist_coeffs_2[int(3)] * r2_3) * r2_3) * r2_3) * _S38 + make_float2 (s_diff_u_0 * _S47 * v_3 + s_diff_v_0 * (_S47 * u_3) + (s_diff_r2_4 + (s_diff_u_0 * 2.0f * u_3 + s_diff_u_0 * (2.0f * u_3))) * dist_coeffs_2[int(5)] + s_diff_r2_4 * dist_coeffs_2[int(6)], s_diff_u_0 * _S48 * v_3 + s_diff_v_0 * (_S48 * u_3) + (s_diff_r2_4 + (s_diff_v_0 * 2.0f * v_3 + s_diff_v_0 * (2.0f * v_3))) * dist_coeffs_2[int(4)] + s_diff_r2_4 * dist_coeffs_2[int(7)]); - float2 _S50 = _S49 + make_float2 (_S49.x * dist_coeffs_2[int(8)] + _S49.y * dist_coeffs_2[int(9)], 0.0f); - float fx_0 = intrins_1.x; - float fy_0 = intrins_1.y; - float _S51 = _S50.y * fy_0; - Matrix J_0; - *&(((&J_0)->rows + (int(0)))->x) = _S50.x * fx_0; - *&(((&J_0)->rows + (int(1)))->x) = _S51; - float2 _S52 = _S36 / make_float2 (_S37); - float2 _S53 = (make_float2 (0.0f, 1.0f) * make_float2 (_S37) - _S39) / make_float2 (_S40); - float u_4 = _S52.x; - float s_diff_u_1 = _S53.x; - float v_4 = _S52.y; - float s_diff_v_1 = _S53.y; - float _S54 = s_diff_u_1 * u_4; - float _S55 = s_diff_v_1 * v_4; - float r2_4 = u_4 * u_4 + v_4 * v_4; - float s_diff_r2_5 = _S54 + _S54 + (_S55 + _S55); - float _S56 = dist_coeffs_2[int(2)] + r2_4 * dist_coeffs_2[int(3)]; - float _S57 = dist_coeffs_2[int(1)] + r2_4 * _S56; - float _S58 = dist_coeffs_2[int(0)] + r2_4 * _S57; - float2 _S59 = _S53 * make_float2 (1.0f + r2_4 * _S58) + make_float2 (s_diff_r2_5 * _S58 + (s_diff_r2_5 * _S57 + (s_diff_r2_5 * _S56 + s_diff_r2_5 * dist_coeffs_2[int(3)] * r2_4) * r2_4) * r2_4) * _S52 + make_float2 (s_diff_u_1 * _S47 * v_4 + s_diff_v_1 * (_S47 * u_4) + (s_diff_r2_5 + (s_diff_u_1 * 2.0f * u_4 + s_diff_u_1 * (2.0f * u_4))) * dist_coeffs_2[int(5)] + s_diff_r2_5 * dist_coeffs_2[int(6)], s_diff_u_1 * _S48 * v_4 + s_diff_v_1 * (_S48 * u_4) + (s_diff_r2_5 + (s_diff_v_1 * 2.0f * v_4 + s_diff_v_1 * (2.0f * v_4))) * dist_coeffs_2[int(4)] + s_diff_r2_5 * dist_coeffs_2[int(7)]); - float2 _S60 = _S59 + make_float2 (_S59.x * dist_coeffs_2[int(8)] + _S59.y * dist_coeffs_2[int(9)], 0.0f); - float _S61 = _S60.y * fy_0; - *&(((&J_0)->rows + (int(0)))->y) = _S60.x * fx_0; - *&(((&J_0)->rows + (int(1)))->y) = _S61; - float2 _S62 = _S36 / make_float2 (_S37); - float2 _S63 = (make_float2 (0.0f, 0.0f) * make_float2 (_S37) - _S36) / make_float2 (_S40); - float u_5 = _S62.x; - float s_diff_u_2 = _S63.x; - float v_5 = _S62.y; - float s_diff_v_2 = _S63.y; - float _S64 = s_diff_u_2 * u_5; - float _S65 = s_diff_v_2 * v_5; - float r2_5 = u_5 * u_5 + v_5 * v_5; - float s_diff_r2_6 = _S64 + _S64 + (_S65 + _S65); - float _S66 = dist_coeffs_2[int(2)] + r2_5 * dist_coeffs_2[int(3)]; - float _S67 = dist_coeffs_2[int(1)] + r2_5 * _S66; - float _S68 = dist_coeffs_2[int(0)] + r2_5 * _S67; - float2 _S69 = _S63 * make_float2 (1.0f + r2_5 * _S68) + make_float2 (s_diff_r2_6 * _S68 + (s_diff_r2_6 * _S67 + (s_diff_r2_6 * _S66 + s_diff_r2_6 * dist_coeffs_2[int(3)] * r2_5) * r2_5) * r2_5) * _S62 + make_float2 (s_diff_u_2 * _S47 * v_5 + s_diff_v_2 * (_S47 * u_5) + (s_diff_r2_6 + (s_diff_u_2 * 2.0f * u_5 + s_diff_u_2 * (2.0f * u_5))) * dist_coeffs_2[int(5)] + s_diff_r2_6 * dist_coeffs_2[int(6)], s_diff_u_2 * _S48 * v_5 + s_diff_v_2 * (_S48 * u_5) + (s_diff_r2_6 + (s_diff_v_2 * 2.0f * v_5 + s_diff_v_2 * (2.0f * v_5))) * dist_coeffs_2[int(4)] + s_diff_r2_6 * dist_coeffs_2[int(7)]); - float2 _S70 = _S69 + make_float2 (_S69.x * dist_coeffs_2[int(8)] + _S69.y * dist_coeffs_2[int(9)], 0.0f); - float _S71 = _S70.y * fy_0; - *&(((&J_0)->rows + (int(0)))->z) = _S70.x * fx_0; - *&(((&J_0)->rows + (int(1)))->z) = _S71; - return J_0; -} - struct DiffPair_float_0 { float primal_0; float differential_0; }; -inline __device__ DiffPair_float_0 _d_sqrt_0(DiffPair_float_0 * dpx_0) +inline __device__ DiffPair_float_0 _d_atan2_0(DiffPair_float_0 * dpy_0, DiffPair_float_0 * dpx_0) { - DiffPair_float_0 _S72 = { (F32_sqrt((dpx_0->primal_0))), 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), (dpx_0->primal_0)))))) * dpx_0->differential_0 }; - return _S72; + float _S4 = dpx_0->primal_0 * dpx_0->primal_0 + dpy_0->primal_0 * dpy_0->primal_0; + DiffPair_float_0 _S5 = { (F32_atan2((dpy_0->primal_0), (dpx_0->primal_0))), - dpy_0->primal_0 / _S4 * dpx_0->differential_0 + dpx_0->primal_0 / _S4 * dpy_0->differential_0 }; + return _S5; } -inline __device__ void _d_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_1, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpy_0, float dOut_2) +inline __device__ DiffPair_float_0 _d_sqrt_0(DiffPair_float_0 * dpx_1) +{ + DiffPair_float_0 _S6 = { (F32_sqrt((dpx_1->primal_0))), 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), (dpx_1->primal_0)))))) * dpx_1->differential_0 }; + return _S6; +} + +inline __device__ void _d_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_2, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpy_1, float dOut_2) { float3 x_d_result_0; - *&((&x_d_result_0)->x) = (*dpy_0).primal_0.x * dOut_2; + *&((&x_d_result_0)->x) = (*dpy_1).primal_0.x * dOut_2; float3 y_d_result_0; - *&((&y_d_result_0)->x) = (*dpx_1).primal_0.x * dOut_2; - *&((&x_d_result_0)->y) = (*dpy_0).primal_0.y * dOut_2; - *&((&y_d_result_0)->y) = (*dpx_1).primal_0.y * dOut_2; - *&((&x_d_result_0)->z) = (*dpy_0).primal_0.z * dOut_2; - *&((&y_d_result_0)->z) = (*dpx_1).primal_0.z * dOut_2; - dpx_1->primal_0 = (*dpx_1).primal_0; - dpx_1->differential_0 = x_d_result_0; - dpy_0->primal_0 = (*dpy_0).primal_0; - dpy_0->differential_0 = y_d_result_0; + *&((&y_d_result_0)->x) = (*dpx_2).primal_0.x * dOut_2; + *&((&x_d_result_0)->y) = (*dpy_1).primal_0.y * dOut_2; + *&((&y_d_result_0)->y) = (*dpx_2).primal_0.y * dOut_2; + *&((&x_d_result_0)->z) = (*dpy_1).primal_0.z * dOut_2; + *&((&y_d_result_0)->z) = (*dpx_2).primal_0.z * dOut_2; + dpx_2->primal_0 = (*dpx_2).primal_0; + dpx_2->differential_0 = x_d_result_0; + dpy_1->primal_0 = (*dpy_1).primal_0; + dpy_1->differential_0 = y_d_result_0; return; } -inline __device__ float dot_0(float3 x_7, float3 y_0) +inline __device__ float dot_0(float2 x_7, float2 y_0) { int i_2 = int(0); float result_4 = 0.0f; for(;;) { - if(i_2 < int(3)) + if(i_2 < int(2)) { } else @@ -547,13 +406,13 @@ inline __device__ float dot_0(float3 x_7, float3 y_0) return result_4; } -inline __device__ float dot_1(float2 x_8, float2 y_1) +inline __device__ float dot_1(float3 x_8, float3 y_1) { int i_3 = int(0); float result_6 = 0.0f; for(;;) { - if(i_3 < int(2)) + if(i_3 < int(3)) { } else @@ -569,139 +428,18 @@ inline __device__ float dot_1(float2 x_8, float2 y_1) inline __device__ float length_0(float2 x_9) { - return (F32_sqrt((dot_1(x_9, x_9)))); + return (F32_sqrt((dot_0(x_9, x_9)))); } inline __device__ float length_1(float3 x_10) { - return (F32_sqrt((dot_0(x_10, x_10)))); + return (F32_sqrt((dot_1(x_10, x_10)))); } -inline __device__ DiffPair_float_0 _d_atan2_0(DiffPair_float_0 * dpy_1, DiffPair_float_0 * dpx_2) +inline __device__ bool equirect_proj_nav(float3 p_view_0, float4 intrins_0, float2 * uv_0) { - float _S73 = dpx_2->primal_0 * dpx_2->primal_0 + dpy_1->primal_0 * dpy_1->primal_0; - DiffPair_float_0 _S74 = { (F32_atan2((dpy_1->primal_0), (dpx_2->primal_0))), - dpy_1->primal_0 / _S73 * dpx_2->differential_0 + dpx_2->primal_0 / _S73 * dpy_1->differential_0 }; - return _S74; -} - -inline __device__ bool fisheye_proj_nav(float3 p_view_2, float4 intrins_2, FixedArray dist_coeffs_3, float2 * uv_2) -{ - bool _S75; - for(;;) - { - float2 _S76 = float2 {p_view_2.x, p_view_2.y}; - float r_3 = length_0(_S76); - float _S77 = p_view_2.z; - float theta_0 = (F32_atan2((r_3), (_S77))); - float k_0; - if(theta_0 < 0.00100000004749745f) - { - k_0 = (1.0f - theta_0 * theta_0 / 3.0f) / _S77; - } - else - { - k_0 = theta_0 / r_3; - } - float2 _S78 = _S76 * make_float2 (k_0); - *uv_2 = _S78; - float u_6 = _S78.x; - float v_6 = _S78.y; - float _S79 = 0.0f * v_6; - float r2_6 = u_6 * u_6 + v_6 * v_6; - float s_diff_r2_7 = u_6 + u_6 + (_S79 + _S79); - float _S80 = dist_coeffs_3[int(2)] + r2_6 * dist_coeffs_3[int(3)]; - float _S81 = dist_coeffs_3[int(1)] + r2_6 * _S80; - float _S82 = dist_coeffs_3[int(0)] + r2_6 * _S81; - float radial_2 = 1.0f + r2_6 * _S82; - float _S83 = 2.0f * dist_coeffs_3[int(4)]; - float _S84 = _S83 * u_6; - float _S85 = 2.0f * u_6; - float _S86 = 2.0f * dist_coeffs_3[int(5)]; - float _S87 = _S86 * u_6; - float _S88 = 2.0f * v_6; - float2 _S89 = make_float2 (1.0f, 0.0f) * make_float2 (radial_2) + make_float2 (s_diff_r2_7 * _S82 + (s_diff_r2_7 * _S81 + (s_diff_r2_7 * _S80 + s_diff_r2_7 * dist_coeffs_3[int(3)] * r2_6) * r2_6) * r2_6) * _S78 + make_float2 (_S83 * v_6 + 0.0f * _S84 + (s_diff_r2_7 + (_S85 + _S85)) * dist_coeffs_3[int(5)] + s_diff_r2_7 * dist_coeffs_3[int(6)], _S86 * v_6 + 0.0f * _S87 + (s_diff_r2_7 + (_S79 + 0.0f * _S88)) * dist_coeffs_3[int(4)] + s_diff_r2_7 * dist_coeffs_3[int(7)]); - float _S90 = 0.0f * u_6; - float s_diff_r2_8 = _S90 + _S90 + (v_6 + v_6); - float2 _S91 = make_float2 (0.0f, 1.0f) * make_float2 (radial_2) + make_float2 (s_diff_r2_8 * _S82 + (s_diff_r2_8 * _S81 + (s_diff_r2_8 * _S80 + s_diff_r2_8 * dist_coeffs_3[int(3)] * r2_6) * r2_6) * r2_6) * _S78 + make_float2 (0.0f * _S83 * v_6 + _S84 + (s_diff_r2_8 + (_S90 + 0.0f * _S85)) * dist_coeffs_3[int(5)] + s_diff_r2_8 * dist_coeffs_3[int(6)], 0.0f * _S86 * v_6 + _S87 + (s_diff_r2_8 + (_S88 + _S88)) * dist_coeffs_3[int(4)] + s_diff_r2_8 * dist_coeffs_3[int(7)]); - Matrix _S92 = transpose_1(makeMatrix (_S89 + make_float2 (_S89.x * dist_coeffs_3[int(8)] + _S89.y * dist_coeffs_3[int(9)], 0.0f), _S91 + make_float2 (_S91.x * dist_coeffs_3[int(8)] + _S91.y * dist_coeffs_3[int(9)], 0.0f))); - bool _S93 = !((F32_min((determinant_0(_S92)), ((F32_min((_S92.rows[int(0)].x), (_S92.rows[int(1)].y)))))) > 0.0f); - _S75 = _S93; - if(_S93) - { - break; - } - float u_7 = (*uv_2).x; - float v_7 = (*uv_2).y; - float r2_7 = u_7 * u_7 + v_7 * v_7; - float2 _S94 = *uv_2 * make_float2 (1.0f + r2_7 * (dist_coeffs_3[int(0)] + r2_7 * (dist_coeffs_3[int(1)] + r2_7 * (dist_coeffs_3[int(2)] + r2_7 * dist_coeffs_3[int(3)])))) + make_float2 (_S83 * u_7 * v_7 + dist_coeffs_3[int(5)] * (r2_7 + 2.0f * u_7 * u_7) + dist_coeffs_3[int(6)] * r2_7, _S86 * u_7 * v_7 + dist_coeffs_3[int(4)] * (r2_7 + 2.0f * v_7 * v_7) + dist_coeffs_3[int(7)] * r2_7); - float2 _S95 = _S94 + make_float2 (dist_coeffs_3[int(8)] * _S94.x + dist_coeffs_3[int(9)] * _S94.y, 0.0f); - *uv_2 = make_float2 (intrins_2.x * _S95.x + intrins_2.z, intrins_2.y * _S95.y + intrins_2.w); - break; - } - return !_S75; -} - -inline __device__ DiffPair_float_0 _d_sin_0(DiffPair_float_0 * dpx_3) -{ - DiffPair_float_0 _S96 = { (F32_sin((dpx_3->primal_0))), (F32_cos((dpx_3->primal_0))) * dpx_3->differential_0 }; - return _S96; -} - -inline __device__ bool equisolid_proj_nav(float3 p_view_3, float4 intrins_3, FixedArray dist_coeffs_4, float2 * uv_3) -{ - bool _S97; - for(;;) - { - float2 _S98 = float2 {p_view_3.x, p_view_3.y}; - float r_4 = length_0(_S98); - float _S99 = p_view_3.z; - float theta_1 = (F32_atan2((r_4), (_S99))); - float k_1; - if(r_4 < 9.99999997475242708e-07f) - { - k_1 = (1.0f - theta_1 * theta_1 / 24.0f) / _S99; - } - else - { - k_1 = 2.0f * (F32_sin((0.5f * theta_1))) / r_4; - } - float2 _S100 = _S98 * make_float2 (k_1); - *uv_3 = _S100; - float u_8 = _S100.x; - float v_8 = _S100.y; - float _S101 = 0.0f * v_8; - float r2_8 = u_8 * u_8 + v_8 * v_8; - float s_diff_r2_9 = u_8 + u_8 + (_S101 + _S101); - float _S102 = dist_coeffs_4[int(2)] + r2_8 * dist_coeffs_4[int(3)]; - float _S103 = dist_coeffs_4[int(1)] + r2_8 * _S102; - float _S104 = dist_coeffs_4[int(0)] + r2_8 * _S103; - float radial_3 = 1.0f + r2_8 * _S104; - float _S105 = 2.0f * dist_coeffs_4[int(4)]; - float _S106 = _S105 * u_8; - float _S107 = 2.0f * u_8; - float _S108 = 2.0f * dist_coeffs_4[int(5)]; - float _S109 = _S108 * u_8; - float _S110 = 2.0f * v_8; - float2 _S111 = make_float2 (1.0f, 0.0f) * make_float2 (radial_3) + make_float2 (s_diff_r2_9 * _S104 + (s_diff_r2_9 * _S103 + (s_diff_r2_9 * _S102 + s_diff_r2_9 * dist_coeffs_4[int(3)] * r2_8) * r2_8) * r2_8) * _S100 + make_float2 (_S105 * v_8 + 0.0f * _S106 + (s_diff_r2_9 + (_S107 + _S107)) * dist_coeffs_4[int(5)] + s_diff_r2_9 * dist_coeffs_4[int(6)], _S108 * v_8 + 0.0f * _S109 + (s_diff_r2_9 + (_S101 + 0.0f * _S110)) * dist_coeffs_4[int(4)] + s_diff_r2_9 * dist_coeffs_4[int(7)]); - float _S112 = 0.0f * u_8; - float s_diff_r2_10 = _S112 + _S112 + (v_8 + v_8); - float2 _S113 = make_float2 (0.0f, 1.0f) * make_float2 (radial_3) + make_float2 (s_diff_r2_10 * _S104 + (s_diff_r2_10 * _S103 + (s_diff_r2_10 * _S102 + s_diff_r2_10 * dist_coeffs_4[int(3)] * r2_8) * r2_8) * r2_8) * _S100 + make_float2 (0.0f * _S105 * v_8 + _S106 + (s_diff_r2_10 + (_S112 + 0.0f * _S107)) * dist_coeffs_4[int(5)] + s_diff_r2_10 * dist_coeffs_4[int(6)], 0.0f * _S108 * v_8 + _S109 + (s_diff_r2_10 + (_S110 + _S110)) * dist_coeffs_4[int(4)] + s_diff_r2_10 * dist_coeffs_4[int(7)]); - Matrix _S114 = transpose_1(makeMatrix (_S111 + make_float2 (_S111.x * dist_coeffs_4[int(8)] + _S111.y * dist_coeffs_4[int(9)], 0.0f), _S113 + make_float2 (_S113.x * dist_coeffs_4[int(8)] + _S113.y * dist_coeffs_4[int(9)], 0.0f))); - bool _S115 = !((F32_min((determinant_0(_S114)), ((F32_min((_S114.rows[int(0)].x), (_S114.rows[int(1)].y)))))) > 0.0f); - _S97 = _S115; - if(_S115) - { - break; - } - float u_9 = (*uv_3).x; - float v_9 = (*uv_3).y; - float r2_9 = u_9 * u_9 + v_9 * v_9; - float2 _S116 = *uv_3 * make_float2 (1.0f + r2_9 * (dist_coeffs_4[int(0)] + r2_9 * (dist_coeffs_4[int(1)] + r2_9 * (dist_coeffs_4[int(2)] + r2_9 * dist_coeffs_4[int(3)])))) + make_float2 (_S105 * u_9 * v_9 + dist_coeffs_4[int(5)] * (r2_9 + 2.0f * u_9 * u_9) + dist_coeffs_4[int(6)] * r2_9, _S108 * u_9 * v_9 + dist_coeffs_4[int(4)] * (r2_9 + 2.0f * v_9 * v_9) + dist_coeffs_4[int(7)] * r2_9); - float2 _S117 = _S116 + make_float2 (dist_coeffs_4[int(8)] * _S116.x + dist_coeffs_4[int(9)] * _S116.y, 0.0f); - *uv_3 = make_float2 (intrins_3.x * _S117.x + intrins_3.z, intrins_3.y * _S117.y + intrins_3.w); - break; - } - return !_S97; + *uv_0 = make_float2 (intrins_0.x * (F32_atan2((p_view_0.x), (p_view_0.z))) + intrins_0.z, intrins_0.y * (F32_atan2((p_view_0.y), (length_0(float2 {p_view_0.x, p_view_0.z})))) + intrins_0.w); + return true; } struct DiffPair_vectorx3Cfloatx2C2x3E_0 @@ -710,654 +448,989 @@ struct DiffPair_vectorx3Cfloatx2C2x3E_0 float2 differential_0; }; -inline __device__ DiffPair_float_0 s_fwd_length_impl_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpx_4) +inline __device__ DiffPair_float_0 s_fwd_length_impl_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpx_3) { - float _S118 = *&((&dpx_4->differential_0)->x) * *&((&dpx_4->primal_0)->x); - float _S119 = *&((&dpx_4->differential_0)->y) * *&((&dpx_4->primal_0)->y); - float s_diff_len_0 = _S118 + _S118 + (_S119 + _S119); - DiffPair_float_0 _S120; - (&_S120)->primal_0 = *&((&dpx_4->primal_0)->x) * *&((&dpx_4->primal_0)->x) + *&((&dpx_4->primal_0)->y) * *&((&dpx_4->primal_0)->y); - (&_S120)->differential_0 = s_diff_len_0; - DiffPair_float_0 _S121 = _d_sqrt_0(&_S120); - DiffPair_float_0 _S122 = { _S121.primal_0, _S121.differential_0 }; - return _S122; + float _S7 = *&((&dpx_3->differential_0)->x) * *&((&dpx_3->primal_0)->x); + float _S8 = *&((&dpx_3->differential_0)->y) * *&((&dpx_3->primal_0)->y); + float s_diff_len_0 = _S7 + _S7 + (_S8 + _S8); + DiffPair_float_0 _S9; + (&_S9)->primal_0 = *&((&dpx_3->primal_0)->x) * *&((&dpx_3->primal_0)->x) + *&((&dpx_3->primal_0)->y) * *&((&dpx_3->primal_0)->y); + (&_S9)->differential_0 = s_diff_len_0; + DiffPair_float_0 _S10 = _d_sqrt_0(&_S9); + DiffPair_float_0 _S11 = { _S10.primal_0, _S10.differential_0 }; + return _S11; } -inline __device__ Matrix fisheye_proj_jac(float3 p_view_4, float4 intrins_4, FixedArray dist_coeffs_5) +inline __device__ Matrix equirect_proj_jac(float3 p_view_1, float4 intrins_1) { - Matrix J_1; - float2 _S123 = float2 {p_view_4.x, p_view_4.y}; - float2 _S124 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S125; - (&_S125)->primal_0 = _S123; - (&_S125)->differential_0 = _S124; - DiffPair_float_0 _S126 = s_fwd_length_impl_0(&_S125); - float _S127 = p_view_4.z; - DiffPair_float_0 _S128; - (&_S128)->primal_0 = _S126.primal_0; - (&_S128)->differential_0 = _S126.differential_0; - DiffPair_float_0 _S129; - (&_S129)->primal_0 = _S127; - (&_S129)->differential_0 = 0.0f; - DiffPair_float_0 _S130 = _d_atan2_0(&_S128, &_S129); - float k_2; - float s_diff_k_0; - if((_S130.primal_0) < 0.00100000004749745f) - { - float _S131 = _S130.differential_0 * _S130.primal_0; - float _S132 = 1.0f - _S130.primal_0 * _S130.primal_0 / 3.0f; - float _S133 = ((0.0f - (_S131 + _S131) * 0.3333333432674408f) * _S127 - _S132 * 0.0f) / (_S127 * _S127); - k_2 = _S132 / _S127; - s_diff_k_0 = _S133; - } - else - { - float _S134 = (_S130.differential_0 * _S126.primal_0 - _S130.primal_0 * _S126.differential_0) / (_S126.primal_0 * _S126.primal_0); - k_2 = _S130.primal_0 / _S126.primal_0; - s_diff_k_0 = _S134; - } - float2 _S135 = _S123 * make_float2 (k_2); - float2 _S136 = _S124 * make_float2 (k_2) + make_float2 (s_diff_k_0) * _S123; - float u_10 = _S135.x; - float s_diff_u_3 = _S136.x; - float v_10 = _S135.y; - float s_diff_v_3 = _S136.y; - float _S137 = s_diff_u_3 * u_10; - float _S138 = s_diff_v_3 * v_10; - float r2_10 = u_10 * u_10 + v_10 * v_10; - float s_diff_r2_11 = _S137 + _S137 + (_S138 + _S138); - float _S139 = dist_coeffs_5[int(2)] + r2_10 * dist_coeffs_5[int(3)]; - float _S140 = dist_coeffs_5[int(1)] + r2_10 * _S139; - float _S141 = dist_coeffs_5[int(0)] + r2_10 * _S140; - float _S142 = 2.0f * dist_coeffs_5[int(4)]; - float _S143 = 2.0f * dist_coeffs_5[int(5)]; - float2 _S144 = _S136 * make_float2 (1.0f + r2_10 * _S141) + make_float2 (s_diff_r2_11 * _S141 + (s_diff_r2_11 * _S140 + (s_diff_r2_11 * _S139 + s_diff_r2_11 * dist_coeffs_5[int(3)] * r2_10) * r2_10) * r2_10) * _S135 + make_float2 (s_diff_u_3 * _S142 * v_10 + s_diff_v_3 * (_S142 * u_10) + (s_diff_r2_11 + (s_diff_u_3 * 2.0f * u_10 + s_diff_u_3 * (2.0f * u_10))) * dist_coeffs_5[int(5)] + s_diff_r2_11 * dist_coeffs_5[int(6)], s_diff_u_3 * _S143 * v_10 + s_diff_v_3 * (_S143 * u_10) + (s_diff_r2_11 + (s_diff_v_3 * 2.0f * v_10 + s_diff_v_3 * (2.0f * v_10))) * dist_coeffs_5[int(4)] + s_diff_r2_11 * dist_coeffs_5[int(7)]); - float2 _S145 = _S144 + make_float2 (_S144.x * dist_coeffs_5[int(8)] + _S144.y * dist_coeffs_5[int(9)], 0.0f); - float fx_1 = intrins_4.x; - float fy_1 = intrins_4.y; - float _S146 = _S145.y * fy_1; - *&(((&J_1)->rows + (int(0)))->x) = _S145.x * fx_1; - *&(((&J_1)->rows + (int(1)))->x) = _S146; - float2 _S147 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S148; - (&_S148)->primal_0 = _S123; - (&_S148)->differential_0 = _S147; - DiffPair_float_0 _S149 = s_fwd_length_impl_0(&_S148); - DiffPair_float_0 _S150; - (&_S150)->primal_0 = _S149.primal_0; - (&_S150)->differential_0 = _S149.differential_0; - DiffPair_float_0 _S151; - (&_S151)->primal_0 = _S127; - (&_S151)->differential_0 = 0.0f; - DiffPair_float_0 _S152 = _d_atan2_0(&_S150, &_S151); - if((_S152.primal_0) < 0.00100000004749745f) - { - float _S153 = _S152.differential_0 * _S152.primal_0; - float _S154 = 1.0f - _S152.primal_0 * _S152.primal_0 / 3.0f; - float _S155 = ((0.0f - (_S153 + _S153) * 0.3333333432674408f) * _S127 - _S154 * 0.0f) / (_S127 * _S127); - k_2 = _S154 / _S127; - s_diff_k_0 = _S155; - } - else - { - float _S156 = (_S152.differential_0 * _S149.primal_0 - _S152.primal_0 * _S149.differential_0) / (_S149.primal_0 * _S149.primal_0); - k_2 = _S152.primal_0 / _S149.primal_0; - s_diff_k_0 = _S156; - } - float2 _S157 = _S123 * make_float2 (k_2); - float2 _S158 = _S147 * make_float2 (k_2) + make_float2 (s_diff_k_0) * _S123; - float u_11 = _S157.x; - float s_diff_u_4 = _S158.x; - float v_11 = _S157.y; - float s_diff_v_4 = _S158.y; - float _S159 = s_diff_u_4 * u_11; - float _S160 = s_diff_v_4 * v_11; - float r2_11 = u_11 * u_11 + v_11 * v_11; - float s_diff_r2_12 = _S159 + _S159 + (_S160 + _S160); - float _S161 = dist_coeffs_5[int(2)] + r2_11 * dist_coeffs_5[int(3)]; - float _S162 = dist_coeffs_5[int(1)] + r2_11 * _S161; - float _S163 = dist_coeffs_5[int(0)] + r2_11 * _S162; - float2 _S164 = _S158 * make_float2 (1.0f + r2_11 * _S163) + make_float2 (s_diff_r2_12 * _S163 + (s_diff_r2_12 * _S162 + (s_diff_r2_12 * _S161 + s_diff_r2_12 * dist_coeffs_5[int(3)] * r2_11) * r2_11) * r2_11) * _S157 + make_float2 (s_diff_u_4 * _S142 * v_11 + s_diff_v_4 * (_S142 * u_11) + (s_diff_r2_12 + (s_diff_u_4 * 2.0f * u_11 + s_diff_u_4 * (2.0f * u_11))) * dist_coeffs_5[int(5)] + s_diff_r2_12 * dist_coeffs_5[int(6)], s_diff_u_4 * _S143 * v_11 + s_diff_v_4 * (_S143 * u_11) + (s_diff_r2_12 + (s_diff_v_4 * 2.0f * v_11 + s_diff_v_4 * (2.0f * v_11))) * dist_coeffs_5[int(4)] + s_diff_r2_12 * dist_coeffs_5[int(7)]); - float2 _S165 = _S164 + make_float2 (_S164.x * dist_coeffs_5[int(8)] + _S164.y * dist_coeffs_5[int(9)], 0.0f); - float _S166 = _S165.y * fy_1; - *&(((&J_1)->rows + (int(0)))->y) = _S165.x * fx_1; - *&(((&J_1)->rows + (int(1)))->y) = _S166; - float2 _S167 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S168; - (&_S168)->primal_0 = _S123; - (&_S168)->differential_0 = _S167; - DiffPair_float_0 _S169 = s_fwd_length_impl_0(&_S168); - DiffPair_float_0 _S170; - (&_S170)->primal_0 = _S169.primal_0; - (&_S170)->differential_0 = _S169.differential_0; - DiffPair_float_0 _S171; - (&_S171)->primal_0 = _S127; - (&_S171)->differential_0 = 1.0f; - DiffPair_float_0 _S172 = _d_atan2_0(&_S170, &_S171); - if((_S172.primal_0) < 0.00100000004749745f) - { - float _S173 = _S172.differential_0 * _S172.primal_0; - float _S174 = 1.0f - _S172.primal_0 * _S172.primal_0 / 3.0f; - float _S175 = ((0.0f - (_S173 + _S173) * 0.3333333432674408f) * _S127 - _S174) / (_S127 * _S127); - k_2 = _S174 / _S127; - s_diff_k_0 = _S175; - } - else - { - float _S176 = (_S172.differential_0 * _S169.primal_0 - _S172.primal_0 * _S169.differential_0) / (_S169.primal_0 * _S169.primal_0); - k_2 = _S172.primal_0 / _S169.primal_0; - s_diff_k_0 = _S176; - } - float2 _S177 = _S123 * make_float2 (k_2); - float2 _S178 = _S167 * make_float2 (k_2) + make_float2 (s_diff_k_0) * _S123; - float u_12 = _S177.x; - float s_diff_u_5 = _S178.x; - float v_12 = _S177.y; - float s_diff_v_5 = _S178.y; - float _S179 = s_diff_u_5 * u_12; - float _S180 = s_diff_v_5 * v_12; - float r2_12 = u_12 * u_12 + v_12 * v_12; - float s_diff_r2_13 = _S179 + _S179 + (_S180 + _S180); - float _S181 = dist_coeffs_5[int(2)] + r2_12 * dist_coeffs_5[int(3)]; - float _S182 = dist_coeffs_5[int(1)] + r2_12 * _S181; - float _S183 = dist_coeffs_5[int(0)] + r2_12 * _S182; - float2 _S184 = _S178 * make_float2 (1.0f + r2_12 * _S183) + make_float2 (s_diff_r2_13 * _S183 + (s_diff_r2_13 * _S182 + (s_diff_r2_13 * _S181 + s_diff_r2_13 * dist_coeffs_5[int(3)] * r2_12) * r2_12) * r2_12) * _S177 + make_float2 (s_diff_u_5 * _S142 * v_12 + s_diff_v_5 * (_S142 * u_12) + (s_diff_r2_13 + (s_diff_u_5 * 2.0f * u_12 + s_diff_u_5 * (2.0f * u_12))) * dist_coeffs_5[int(5)] + s_diff_r2_13 * dist_coeffs_5[int(6)], s_diff_u_5 * _S143 * v_12 + s_diff_v_5 * (_S143 * u_12) + (s_diff_r2_13 + (s_diff_v_5 * 2.0f * v_12 + s_diff_v_5 * (2.0f * v_12))) * dist_coeffs_5[int(4)] + s_diff_r2_13 * dist_coeffs_5[int(7)]); - float2 _S185 = _S184 + make_float2 (_S184.x * dist_coeffs_5[int(8)] + _S184.y * dist_coeffs_5[int(9)], 0.0f); - float _S186 = _S185.y * fy_1; - *&(((&J_1)->rows + (int(0)))->z) = _S185.x * fx_1; - *&(((&J_1)->rows + (int(1)))->z) = _S186; - return J_1; + float _S12 = p_view_1.x; + float _S13 = p_view_1.z; + DiffPair_float_0 _S14; + (&_S14)->primal_0 = _S12; + (&_S14)->differential_0 = 1.0f; + DiffPair_float_0 _S15; + (&_S15)->primal_0 = _S13; + (&_S15)->differential_0 = 0.0f; + DiffPair_float_0 _S16 = _d_atan2_0(&_S14, &_S15); + float _S17 = p_view_1.y; + float2 _S18 = float2 {p_view_1.x, p_view_1.z}; + float2 _S19 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S20; + (&_S20)->primal_0 = _S18; + (&_S20)->differential_0 = _S19; + DiffPair_float_0 _S21 = s_fwd_length_impl_0(&_S20); + DiffPair_float_0 _S22; + (&_S22)->primal_0 = _S17; + (&_S22)->differential_0 = 0.0f; + DiffPair_float_0 _S23; + (&_S23)->primal_0 = _S21.primal_0; + (&_S23)->differential_0 = _S21.differential_0; + DiffPair_float_0 _S24 = _d_atan2_0(&_S22, &_S23); + float fx_0 = intrins_1.x; + float fy_0 = intrins_1.y; + float _S25 = _S24.differential_0 * fy_0; + Matrix J_0; + *&(((&J_0)->rows + (int(0)))->x) = _S16.differential_0 * fx_0; + *&(((&J_0)->rows + (int(1)))->x) = _S25; + DiffPair_float_0 _S26; + (&_S26)->primal_0 = _S12; + (&_S26)->differential_0 = 0.0f; + DiffPair_float_0 _S27; + (&_S27)->primal_0 = _S13; + (&_S27)->differential_0 = 0.0f; + DiffPair_float_0 _S28 = _d_atan2_0(&_S26, &_S27); + float2 _S29 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S30; + (&_S30)->primal_0 = _S18; + (&_S30)->differential_0 = _S29; + DiffPair_float_0 _S31 = s_fwd_length_impl_0(&_S30); + DiffPair_float_0 _S32; + (&_S32)->primal_0 = _S17; + (&_S32)->differential_0 = 1.0f; + DiffPair_float_0 _S33; + (&_S33)->primal_0 = _S31.primal_0; + (&_S33)->differential_0 = _S31.differential_0; + DiffPair_float_0 _S34 = _d_atan2_0(&_S32, &_S33); + float _S35 = _S34.differential_0 * fy_0; + *&(((&J_0)->rows + (int(0)))->y) = _S28.differential_0 * fx_0; + *&(((&J_0)->rows + (int(1)))->y) = _S35; + DiffPair_float_0 _S36; + (&_S36)->primal_0 = _S12; + (&_S36)->differential_0 = 0.0f; + DiffPair_float_0 _S37; + (&_S37)->primal_0 = _S13; + (&_S37)->differential_0 = 1.0f; + DiffPair_float_0 _S38 = _d_atan2_0(&_S36, &_S37); + float2 _S39 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S40; + (&_S40)->primal_0 = _S18; + (&_S40)->differential_0 = _S39; + DiffPair_float_0 _S41 = s_fwd_length_impl_0(&_S40); + DiffPair_float_0 _S42; + (&_S42)->primal_0 = _S17; + (&_S42)->differential_0 = 0.0f; + DiffPair_float_0 _S43; + (&_S43)->primal_0 = _S41.primal_0; + (&_S43)->differential_0 = _S41.differential_0; + DiffPair_float_0 _S44 = _d_atan2_0(&_S42, &_S43); + float _S45 = _S44.differential_0 * fy_0; + *&(((&J_0)->rows + (int(0)))->z) = _S38.differential_0 * fx_0; + *&(((&J_0)->rows + (int(1)))->z) = _S45; + return J_0; } -inline __device__ Matrix equisolid_proj_jac(float3 p_view_5, float4 intrins_5, FixedArray dist_coeffs_6) +inline __device__ float determinant_0(Matrix m_0) { - Matrix J_2; - float2 _S187 = float2 {p_view_5.x, p_view_5.y}; - float2 _S188 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S189; - (&_S189)->primal_0 = _S187; - (&_S189)->differential_0 = _S188; - DiffPair_float_0 _S190 = s_fwd_length_impl_0(&_S189); - float _S191 = p_view_5.z; - DiffPair_float_0 _S192; - (&_S192)->primal_0 = _S190.primal_0; - (&_S192)->differential_0 = _S190.differential_0; - DiffPair_float_0 _S193; - (&_S193)->primal_0 = _S191; - (&_S193)->differential_0 = 0.0f; - DiffPair_float_0 _S194 = _d_atan2_0(&_S192, &_S193); - float k_3; - float s_diff_k_1; - if((_S190.primal_0) < 9.99999997475242708e-07f) - { - float _S195 = _S194.differential_0 * _S194.primal_0; - float _S196 = 1.0f - _S194.primal_0 * _S194.primal_0 / 24.0f; - float _S197 = ((0.0f - (_S195 + _S195) * 0.0416666679084301f) * _S191 - _S196 * 0.0f) / (_S191 * _S191); - k_3 = _S196 / _S191; - s_diff_k_1 = _S197; - } - else - { - float _S198 = _S194.differential_0 * 0.5f; - DiffPair_float_0 _S199; - (&_S199)->primal_0 = 0.5f * _S194.primal_0; - (&_S199)->differential_0 = _S198; - DiffPair_float_0 _S200 = _d_sin_0(&_S199); - float _S201 = 2.0f * _S200.primal_0; - float _S202 = (_S200.differential_0 * 2.0f * _S190.primal_0 - _S201 * _S190.differential_0) / (_S190.primal_0 * _S190.primal_0); - k_3 = _S201 / _S190.primal_0; - s_diff_k_1 = _S202; - } - float2 _S203 = _S187 * make_float2 (k_3); - float2 _S204 = _S188 * make_float2 (k_3) + make_float2 (s_diff_k_1) * _S187; - float u_13 = _S203.x; - float s_diff_u_6 = _S204.x; - float v_13 = _S203.y; - float s_diff_v_6 = _S204.y; - float _S205 = s_diff_u_6 * u_13; - float _S206 = s_diff_v_6 * v_13; - float r2_13 = u_13 * u_13 + v_13 * v_13; - float s_diff_r2_14 = _S205 + _S205 + (_S206 + _S206); - float _S207 = dist_coeffs_6[int(2)] + r2_13 * dist_coeffs_6[int(3)]; - float _S208 = dist_coeffs_6[int(1)] + r2_13 * _S207; - float _S209 = dist_coeffs_6[int(0)] + r2_13 * _S208; - float _S210 = 2.0f * dist_coeffs_6[int(4)]; - float _S211 = 2.0f * dist_coeffs_6[int(5)]; - float2 _S212 = _S204 * make_float2 (1.0f + r2_13 * _S209) + make_float2 (s_diff_r2_14 * _S209 + (s_diff_r2_14 * _S208 + (s_diff_r2_14 * _S207 + s_diff_r2_14 * dist_coeffs_6[int(3)] * r2_13) * r2_13) * r2_13) * _S203 + make_float2 (s_diff_u_6 * _S210 * v_13 + s_diff_v_6 * (_S210 * u_13) + (s_diff_r2_14 + (s_diff_u_6 * 2.0f * u_13 + s_diff_u_6 * (2.0f * u_13))) * dist_coeffs_6[int(5)] + s_diff_r2_14 * dist_coeffs_6[int(6)], s_diff_u_6 * _S211 * v_13 + s_diff_v_6 * (_S211 * u_13) + (s_diff_r2_14 + (s_diff_v_6 * 2.0f * v_13 + s_diff_v_6 * (2.0f * v_13))) * dist_coeffs_6[int(4)] + s_diff_r2_14 * dist_coeffs_6[int(7)]); - float2 _S213 = _S212 + make_float2 (_S212.x * dist_coeffs_6[int(8)] + _S212.y * dist_coeffs_6[int(9)], 0.0f); - float fx_2 = intrins_5.x; - float fy_2 = intrins_5.y; - float _S214 = _S213.y * fy_2; - *&(((&J_2)->rows + (int(0)))->x) = _S213.x * fx_2; - *&(((&J_2)->rows + (int(1)))->x) = _S214; - float2 _S215 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S216; - (&_S216)->primal_0 = _S187; - (&_S216)->differential_0 = _S215; - DiffPair_float_0 _S217 = s_fwd_length_impl_0(&_S216); - DiffPair_float_0 _S218; - (&_S218)->primal_0 = _S217.primal_0; - (&_S218)->differential_0 = _S217.differential_0; - DiffPair_float_0 _S219; - (&_S219)->primal_0 = _S191; - (&_S219)->differential_0 = 0.0f; - DiffPair_float_0 _S220 = _d_atan2_0(&_S218, &_S219); - if((_S217.primal_0) < 9.99999997475242708e-07f) - { - float _S221 = _S220.differential_0 * _S220.primal_0; - float _S222 = 1.0f - _S220.primal_0 * _S220.primal_0 / 24.0f; - float _S223 = ((0.0f - (_S221 + _S221) * 0.0416666679084301f) * _S191 - _S222 * 0.0f) / (_S191 * _S191); - k_3 = _S222 / _S191; - s_diff_k_1 = _S223; - } - else - { - float _S224 = _S220.differential_0 * 0.5f; - DiffPair_float_0 _S225; - (&_S225)->primal_0 = 0.5f * _S220.primal_0; - (&_S225)->differential_0 = _S224; - DiffPair_float_0 _S226 = _d_sin_0(&_S225); - float _S227 = 2.0f * _S226.primal_0; - float _S228 = (_S226.differential_0 * 2.0f * _S217.primal_0 - _S227 * _S217.differential_0) / (_S217.primal_0 * _S217.primal_0); - k_3 = _S227 / _S217.primal_0; - s_diff_k_1 = _S228; - } - float2 _S229 = _S187 * make_float2 (k_3); - float2 _S230 = _S215 * make_float2 (k_3) + make_float2 (s_diff_k_1) * _S187; - float u_14 = _S229.x; - float s_diff_u_7 = _S230.x; - float v_14 = _S229.y; - float s_diff_v_7 = _S230.y; - float _S231 = s_diff_u_7 * u_14; - float _S232 = s_diff_v_7 * v_14; - float r2_14 = u_14 * u_14 + v_14 * v_14; - float s_diff_r2_15 = _S231 + _S231 + (_S232 + _S232); - float _S233 = dist_coeffs_6[int(2)] + r2_14 * dist_coeffs_6[int(3)]; - float _S234 = dist_coeffs_6[int(1)] + r2_14 * _S233; - float _S235 = dist_coeffs_6[int(0)] + r2_14 * _S234; - float2 _S236 = _S230 * make_float2 (1.0f + r2_14 * _S235) + make_float2 (s_diff_r2_15 * _S235 + (s_diff_r2_15 * _S234 + (s_diff_r2_15 * _S233 + s_diff_r2_15 * dist_coeffs_6[int(3)] * r2_14) * r2_14) * r2_14) * _S229 + make_float2 (s_diff_u_7 * _S210 * v_14 + s_diff_v_7 * (_S210 * u_14) + (s_diff_r2_15 + (s_diff_u_7 * 2.0f * u_14 + s_diff_u_7 * (2.0f * u_14))) * dist_coeffs_6[int(5)] + s_diff_r2_15 * dist_coeffs_6[int(6)], s_diff_u_7 * _S211 * v_14 + s_diff_v_7 * (_S211 * u_14) + (s_diff_r2_15 + (s_diff_v_7 * 2.0f * v_14 + s_diff_v_7 * (2.0f * v_14))) * dist_coeffs_6[int(4)] + s_diff_r2_15 * dist_coeffs_6[int(7)]); - float2 _S237 = _S236 + make_float2 (_S236.x * dist_coeffs_6[int(8)] + _S236.y * dist_coeffs_6[int(9)], 0.0f); - float _S238 = _S237.y * fy_2; - *&(((&J_2)->rows + (int(0)))->y) = _S237.x * fx_2; - *&(((&J_2)->rows + (int(1)))->y) = _S238; - float2 _S239 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S240; - (&_S240)->primal_0 = _S187; - (&_S240)->differential_0 = _S239; - DiffPair_float_0 _S241 = s_fwd_length_impl_0(&_S240); - DiffPair_float_0 _S242; - (&_S242)->primal_0 = _S241.primal_0; - (&_S242)->differential_0 = _S241.differential_0; - DiffPair_float_0 _S243; - (&_S243)->primal_0 = _S191; - (&_S243)->differential_0 = 1.0f; - DiffPair_float_0 _S244 = _d_atan2_0(&_S242, &_S243); - if((_S241.primal_0) < 9.99999997475242708e-07f) - { - float _S245 = _S244.differential_0 * _S244.primal_0; - float _S246 = 1.0f - _S244.primal_0 * _S244.primal_0 / 24.0f; - float _S247 = ((0.0f - (_S245 + _S245) * 0.0416666679084301f) * _S191 - _S246) / (_S191 * _S191); - k_3 = _S246 / _S191; - s_diff_k_1 = _S247; - } - else - { - float _S248 = _S244.differential_0 * 0.5f; - DiffPair_float_0 _S249; - (&_S249)->primal_0 = 0.5f * _S244.primal_0; - (&_S249)->differential_0 = _S248; - DiffPair_float_0 _S250 = _d_sin_0(&_S249); - float _S251 = 2.0f * _S250.primal_0; - float _S252 = (_S250.differential_0 * 2.0f * _S241.primal_0 - _S251 * _S241.differential_0) / (_S241.primal_0 * _S241.primal_0); - k_3 = _S251 / _S241.primal_0; - s_diff_k_1 = _S252; - } - float2 _S253 = _S187 * make_float2 (k_3); - float2 _S254 = _S239 * make_float2 (k_3) + make_float2 (s_diff_k_1) * _S187; - float u_15 = _S253.x; - float s_diff_u_8 = _S254.x; - float v_15 = _S253.y; - float s_diff_v_8 = _S254.y; - float _S255 = s_diff_u_8 * u_15; - float _S256 = s_diff_v_8 * v_15; - float r2_15 = u_15 * u_15 + v_15 * v_15; - float s_diff_r2_16 = _S255 + _S255 + (_S256 + _S256); - float _S257 = dist_coeffs_6[int(2)] + r2_15 * dist_coeffs_6[int(3)]; - float _S258 = dist_coeffs_6[int(1)] + r2_15 * _S257; - float _S259 = dist_coeffs_6[int(0)] + r2_15 * _S258; - float2 _S260 = _S254 * make_float2 (1.0f + r2_15 * _S259) + make_float2 (s_diff_r2_16 * _S259 + (s_diff_r2_16 * _S258 + (s_diff_r2_16 * _S257 + s_diff_r2_16 * dist_coeffs_6[int(3)] * r2_15) * r2_15) * r2_15) * _S253 + make_float2 (s_diff_u_8 * _S210 * v_15 + s_diff_v_8 * (_S210 * u_15) + (s_diff_r2_16 + (s_diff_u_8 * 2.0f * u_15 + s_diff_u_8 * (2.0f * u_15))) * dist_coeffs_6[int(5)] + s_diff_r2_16 * dist_coeffs_6[int(6)], s_diff_u_8 * _S211 * v_15 + s_diff_v_8 * (_S211 * u_15) + (s_diff_r2_16 + (s_diff_v_8 * 2.0f * v_15 + s_diff_v_8 * (2.0f * v_15))) * dist_coeffs_6[int(4)] + s_diff_r2_16 * dist_coeffs_6[int(7)]); - float2 _S261 = _S260 + make_float2 (_S260.x * dist_coeffs_6[int(8)] + _S260.y * dist_coeffs_6[int(9)], 0.0f); - float _S262 = _S261.y * fy_2; - *&(((&J_2)->rows + (int(0)))->z) = _S261.x * fx_2; - *&(((&J_2)->rows + (int(1)))->z) = _S262; - return J_2; + return m_0.rows[int(0)].x * m_0.rows[int(1)].y - m_0.rows[int(0)].y * m_0.rows[int(1)].x; } -inline __device__ bool equirect_proj_nav(float3 p_view_6, float4 intrins_6, FixedArray dist_coeffs_7, float2 * uv_4) +inline __device__ bool is_valid_distortion_none(float2 uv_1, FixedArray dist_coeffs_0) { - *uv_4 = make_float2 (intrins_6.x * (F32_atan2((p_view_6.x), (p_view_6.z))) + intrins_6.z, intrins_6.y * (F32_atan2((p_view_6.y), (length_0(float2 {p_view_6.x, p_view_6.z})))) + intrins_6.w); return true; } -inline __device__ Matrix equirect_proj_jac(float3 p_view_7, float4 intrins_7, FixedArray dist_coeffs_8) +inline __device__ float2 DistNone_distort_0(float2 uv_2, FixedArray * coeffs_0) { - float _S263 = p_view_7.x; - float _S264 = p_view_7.z; - DiffPair_float_0 _S265; - (&_S265)->primal_0 = _S263; - (&_S265)->differential_0 = 1.0f; - DiffPair_float_0 _S266; - (&_S266)->primal_0 = _S264; - (&_S266)->differential_0 = 0.0f; - DiffPair_float_0 _S267 = _d_atan2_0(&_S265, &_S266); - float _S268 = p_view_7.y; - float2 _S269 = float2 {p_view_7.x, p_view_7.z}; - float2 _S270 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S271; - (&_S271)->primal_0 = _S269; - (&_S271)->differential_0 = _S270; - DiffPair_float_0 _S272 = s_fwd_length_impl_0(&_S271); - DiffPair_float_0 _S273; - (&_S273)->primal_0 = _S268; - (&_S273)->differential_0 = 0.0f; - DiffPair_float_0 _S274; - (&_S274)->primal_0 = _S272.primal_0; - (&_S274)->differential_0 = _S272.differential_0; - DiffPair_float_0 _S275 = _d_atan2_0(&_S273, &_S274); - float fx_3 = intrins_7.x; - float fy_3 = intrins_7.y; - float _S276 = _S275.differential_0 * fy_3; - Matrix J_3; - *&(((&J_3)->rows + (int(0)))->x) = _S267.differential_0 * fx_3; - *&(((&J_3)->rows + (int(1)))->x) = _S276; - DiffPair_float_0 _S277; - (&_S277)->primal_0 = _S263; - (&_S277)->differential_0 = 0.0f; - DiffPair_float_0 _S278; - (&_S278)->primal_0 = _S264; - (&_S278)->differential_0 = 0.0f; - DiffPair_float_0 _S279 = _d_atan2_0(&_S277, &_S278); - float2 _S280 = make_float2 (0.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S281; - (&_S281)->primal_0 = _S269; - (&_S281)->differential_0 = _S280; - DiffPair_float_0 _S282 = s_fwd_length_impl_0(&_S281); - DiffPair_float_0 _S283; - (&_S283)->primal_0 = _S268; - (&_S283)->differential_0 = 1.0f; - DiffPair_float_0 _S284; - (&_S284)->primal_0 = _S282.primal_0; - (&_S284)->differential_0 = _S282.differential_0; - DiffPair_float_0 _S285 = _d_atan2_0(&_S283, &_S284); - float _S286 = _S285.differential_0 * fy_3; - *&(((&J_3)->rows + (int(0)))->y) = _S279.differential_0 * fx_3; - *&(((&J_3)->rows + (int(1)))->y) = _S286; - DiffPair_float_0 _S287; - (&_S287)->primal_0 = _S263; - (&_S287)->differential_0 = 0.0f; - DiffPair_float_0 _S288; - (&_S288)->primal_0 = _S264; - (&_S288)->differential_0 = 1.0f; - DiffPair_float_0 _S289 = _d_atan2_0(&_S287, &_S288); - float2 _S290 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S291; - (&_S291)->primal_0 = _S269; - (&_S291)->differential_0 = _S290; - DiffPair_float_0 _S292 = s_fwd_length_impl_0(&_S291); - DiffPair_float_0 _S293; - (&_S293)->primal_0 = _S268; - (&_S293)->differential_0 = 0.0f; - DiffPair_float_0 _S294; - (&_S294)->primal_0 = _S292.primal_0; - (&_S294)->differential_0 = _S292.differential_0; - DiffPair_float_0 _S295 = _d_atan2_0(&_S293, &_S294); - float _S296 = _S295.differential_0 * fy_3; - *&(((&J_3)->rows + (int(0)))->z) = _S289.differential_0 * fx_3; - *&(((&J_3)->rows + (int(1)))->z) = _S296; - return J_3; + return uv_2; } -inline __device__ float2 distort_point(float2 uv_5, int camera_model_0, FixedArray dist_coeffs_9) +inline __device__ bool persp_proj_nav_none(float3 p_view_2, float4 intrins_2, FixedArray dist_coeffs_1, float2 * uv_3) { - if(camera_model_0 == int(3)) + bool _S46; + for(;;) { - return uv_5; + float2 _S47 = float2 {p_view_2.x, p_view_2.y}; + float _S48 = p_view_2.z; + float2 uv0_0 = _S47 / make_float2 (_S48); + bool _S49 = _S48 < 0.0f; + if(_S49) + { + *uv_3 = uv0_0; + _S46 = false; + break; + } + float2 uv_4 = _S47 / make_float2 (_S48); + FixedArray _S50 = dist_coeffs_1; + float2 _S51 = DistNone_distort_0(uv_4, &_S50); + *uv_3 = make_float2 (intrins_2.x * _S51.x + intrins_2.z, intrins_2.y * _S51.y + intrins_2.w); + _S46 = true; + break; } - float k_4; - float2 _S297; - if(camera_model_0 == int(1)) + return _S46; +} + +inline __device__ bool fisheye_proj_nav_none(float3 p_view_3, float4 intrins_3, FixedArray dist_coeffs_2, float2 * uv_5) +{ + float2 _S52 = float2 {p_view_3.x, p_view_3.y}; + float r_3 = length_0(_S52); + float _S53 = p_view_3.z; + float theta_0 = (F32_atan2((r_3), (_S53))); + float k_0; + if(theta_0 < 0.00100000004749745f) { - float r_5 = length_0(uv_5); - float theta_2 = (F32_atan((r_5))); - if(r_5 < 0.00100000004749745f) - { - k_4 = 1.0f - theta_2 * theta_2 / 6.0f; - } - else - { - k_4 = theta_2 / r_5; - } - _S297 = uv_5 * make_float2 (k_4); + k_0 = (1.0f - theta_0 * theta_0 / 3.0f) / _S53; } else { - if(camera_model_0 == int(2)) + k_0 = theta_0 / r_3; + } + float2 _S54 = _S52 * make_float2 (k_0); + FixedArray _S55 = dist_coeffs_2; + float2 _S56 = DistNone_distort_0(_S54, &_S55); + *uv_5 = make_float2 (intrins_3.x * _S56.x + intrins_3.z, intrins_3.y * _S56.y + intrins_3.w); + return true; +} + +inline __device__ DiffPair_float_0 _d_sin_0(DiffPair_float_0 * dpx_4) +{ + DiffPair_float_0 _S57 = { (F32_sin((dpx_4->primal_0))), (F32_cos((dpx_4->primal_0))) * dpx_4->differential_0 }; + return _S57; +} + +inline __device__ bool equisolid_proj_nav_none(float3 p_view_4, float4 intrins_4, FixedArray dist_coeffs_3, float2 * uv_6) +{ + float2 _S58 = float2 {p_view_4.x, p_view_4.y}; + float r_4 = length_0(_S58); + float _S59 = p_view_4.z; + float theta_1 = (F32_atan2((r_4), (_S59))); + float k_1; + if(r_4 < 9.99999997475242708e-07f) + { + k_1 = (1.0f - theta_1 * theta_1 / 24.0f) / _S59; + } + else + { + k_1 = 2.0f * (F32_sin((0.5f * theta_1))) / r_4; + } + float2 _S60 = _S58 * make_float2 (k_1); + FixedArray _S61 = dist_coeffs_3; + float2 _S62 = DistNone_distort_0(_S60, &_S61); + *uv_6 = make_float2 (intrins_4.x * _S62.x + intrins_4.z, intrins_4.y * _S62.y + intrins_4.w); + return true; +} + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistNone_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_0, FixedArray * coeffs_1) +{ + DiffPair_vectorx3Cfloatx2C2x3E_0 _S63 = { dpuv_0->primal_0, dpuv_0->differential_0 }; + return _S63; +} + +inline __device__ Matrix persp_proj_jac_none(float3 p_view_5, float4 intrins_5, FixedArray dist_coeffs_4) +{ + float2 _S64 = float2 {p_view_5.x, p_view_5.y}; + float _S65 = p_view_5.z; + float2 _S66 = _S64 * make_float2 (0.0f); + float _S67 = _S65 * _S65; + float2 s_diff_uv_0 = (make_float2 (1.0f, 0.0f) * make_float2 (_S65) - _S66) / make_float2 (_S67); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S68; + (&_S68)->primal_0 = _S64 / make_float2 (_S65); + (&_S68)->differential_0 = s_diff_uv_0; + FixedArray _S69 = dist_coeffs_4; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S70 = s_fwd_DistNone_distort_0(&_S68, &_S69); + float fx_1 = intrins_5.x; + float fy_1 = intrins_5.y; + float _S71 = _S70.differential_0.y * fy_1; + Matrix J_1; + *&(((&J_1)->rows + (int(0)))->x) = _S70.differential_0.x * fx_1; + *&(((&J_1)->rows + (int(1)))->x) = _S71; + float2 s_diff_uv_1 = (make_float2 (0.0f, 1.0f) * make_float2 (_S65) - _S66) / make_float2 (_S67); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S72; + (&_S72)->primal_0 = _S64 / make_float2 (_S65); + (&_S72)->differential_0 = s_diff_uv_1; + FixedArray _S73 = dist_coeffs_4; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S74 = s_fwd_DistNone_distort_0(&_S72, &_S73); + float _S75 = _S74.differential_0.y * fy_1; + *&(((&J_1)->rows + (int(0)))->y) = _S74.differential_0.x * fx_1; + *&(((&J_1)->rows + (int(1)))->y) = _S75; + float2 s_diff_uv_2 = (make_float2 (0.0f, 0.0f) * make_float2 (_S65) - _S64) / make_float2 (_S67); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S76; + (&_S76)->primal_0 = _S64 / make_float2 (_S65); + (&_S76)->differential_0 = s_diff_uv_2; + FixedArray _S77 = dist_coeffs_4; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S78 = s_fwd_DistNone_distort_0(&_S76, &_S77); + float _S79 = _S78.differential_0.y * fy_1; + *&(((&J_1)->rows + (int(0)))->z) = _S78.differential_0.x * fx_1; + *&(((&J_1)->rows + (int(1)))->z) = _S79; + return J_1; +} + +inline __device__ Matrix fisheye_proj_jac_none(float3 p_view_6, float4 intrins_6, FixedArray dist_coeffs_5) +{ + Matrix J_2; + float2 _S80 = float2 {p_view_6.x, p_view_6.y}; + float2 _S81 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S82; + (&_S82)->primal_0 = _S80; + (&_S82)->differential_0 = _S81; + DiffPair_float_0 _S83 = s_fwd_length_impl_0(&_S82); + float _S84 = p_view_6.z; + DiffPair_float_0 _S85; + (&_S85)->primal_0 = _S83.primal_0; + (&_S85)->differential_0 = _S83.differential_0; + DiffPair_float_0 _S86; + (&_S86)->primal_0 = _S84; + (&_S86)->differential_0 = 0.0f; + DiffPair_float_0 _S87 = _d_atan2_0(&_S85, &_S86); + float k_2; + float s_diff_k_0; + if((_S87.primal_0) < 0.00100000004749745f) + { + float _S88 = _S87.differential_0 * _S87.primal_0; + float _S89 = 1.0f - _S87.primal_0 * _S87.primal_0 / 3.0f; + float _S90 = ((0.0f - (_S88 + _S88) * 0.3333333432674408f) * _S84 - _S89 * 0.0f) / (_S84 * _S84); + k_2 = _S89 / _S84; + s_diff_k_0 = _S90; + } + else + { + float _S91 = (_S87.differential_0 * _S83.primal_0 - _S87.primal_0 * _S83.differential_0) / (_S83.primal_0 * _S83.primal_0); + k_2 = _S87.primal_0 / _S83.primal_0; + s_diff_k_0 = _S91; + } + float2 _S92 = _S80 * make_float2 (k_2); + float2 _S93 = _S81 * make_float2 (k_2) + make_float2 (s_diff_k_0) * _S80; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S94; + (&_S94)->primal_0 = _S92; + (&_S94)->differential_0 = _S93; + FixedArray _S95 = dist_coeffs_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S96 = s_fwd_DistNone_distort_0(&_S94, &_S95); + float fx_2 = intrins_6.x; + float fy_2 = intrins_6.y; + float _S97 = _S96.differential_0.y * fy_2; + *&(((&J_2)->rows + (int(0)))->x) = _S96.differential_0.x * fx_2; + *&(((&J_2)->rows + (int(1)))->x) = _S97; + float2 _S98 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S99; + (&_S99)->primal_0 = _S80; + (&_S99)->differential_0 = _S98; + DiffPair_float_0 _S100 = s_fwd_length_impl_0(&_S99); + DiffPair_float_0 _S101; + (&_S101)->primal_0 = _S100.primal_0; + (&_S101)->differential_0 = _S100.differential_0; + DiffPair_float_0 _S102; + (&_S102)->primal_0 = _S84; + (&_S102)->differential_0 = 0.0f; + DiffPair_float_0 _S103 = _d_atan2_0(&_S101, &_S102); + if((_S103.primal_0) < 0.00100000004749745f) + { + float _S104 = _S103.differential_0 * _S103.primal_0; + float _S105 = 1.0f - _S103.primal_0 * _S103.primal_0 / 3.0f; + float _S106 = ((0.0f - (_S104 + _S104) * 0.3333333432674408f) * _S84 - _S105 * 0.0f) / (_S84 * _S84); + k_2 = _S105 / _S84; + s_diff_k_0 = _S106; + } + else + { + float _S107 = (_S103.differential_0 * _S100.primal_0 - _S103.primal_0 * _S100.differential_0) / (_S100.primal_0 * _S100.primal_0); + k_2 = _S103.primal_0 / _S100.primal_0; + s_diff_k_0 = _S107; + } + float2 _S108 = _S80 * make_float2 (k_2); + float2 _S109 = _S98 * make_float2 (k_2) + make_float2 (s_diff_k_0) * _S80; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S110; + (&_S110)->primal_0 = _S108; + (&_S110)->differential_0 = _S109; + FixedArray _S111 = dist_coeffs_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S112 = s_fwd_DistNone_distort_0(&_S110, &_S111); + float _S113 = _S112.differential_0.y * fy_2; + *&(((&J_2)->rows + (int(0)))->y) = _S112.differential_0.x * fx_2; + *&(((&J_2)->rows + (int(1)))->y) = _S113; + float2 _S114 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S115; + (&_S115)->primal_0 = _S80; + (&_S115)->differential_0 = _S114; + DiffPair_float_0 _S116 = s_fwd_length_impl_0(&_S115); + DiffPair_float_0 _S117; + (&_S117)->primal_0 = _S116.primal_0; + (&_S117)->differential_0 = _S116.differential_0; + DiffPair_float_0 _S118; + (&_S118)->primal_0 = _S84; + (&_S118)->differential_0 = 1.0f; + DiffPair_float_0 _S119 = _d_atan2_0(&_S117, &_S118); + if((_S119.primal_0) < 0.00100000004749745f) + { + float _S120 = _S119.differential_0 * _S119.primal_0; + float _S121 = 1.0f - _S119.primal_0 * _S119.primal_0 / 3.0f; + float _S122 = ((0.0f - (_S120 + _S120) * 0.3333333432674408f) * _S84 - _S121) / (_S84 * _S84); + k_2 = _S121 / _S84; + s_diff_k_0 = _S122; + } + else + { + float _S123 = (_S119.differential_0 * _S116.primal_0 - _S119.primal_0 * _S116.differential_0) / (_S116.primal_0 * _S116.primal_0); + k_2 = _S119.primal_0 / _S116.primal_0; + s_diff_k_0 = _S123; + } + float2 _S124 = _S80 * make_float2 (k_2); + float2 _S125 = _S114 * make_float2 (k_2) + make_float2 (s_diff_k_0) * _S80; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S126; + (&_S126)->primal_0 = _S124; + (&_S126)->differential_0 = _S125; + FixedArray _S127 = dist_coeffs_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S128 = s_fwd_DistNone_distort_0(&_S126, &_S127); + float _S129 = _S128.differential_0.y * fy_2; + *&(((&J_2)->rows + (int(0)))->z) = _S128.differential_0.x * fx_2; + *&(((&J_2)->rows + (int(1)))->z) = _S129; + return J_2; +} + +inline __device__ Matrix equisolid_proj_jac_none(float3 p_view_7, float4 intrins_7, FixedArray dist_coeffs_6) +{ + Matrix J_3; + float2 _S130 = float2 {p_view_7.x, p_view_7.y}; + float2 _S131 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S132; + (&_S132)->primal_0 = _S130; + (&_S132)->differential_0 = _S131; + DiffPair_float_0 _S133 = s_fwd_length_impl_0(&_S132); + float _S134 = p_view_7.z; + DiffPair_float_0 _S135; + (&_S135)->primal_0 = _S133.primal_0; + (&_S135)->differential_0 = _S133.differential_0; + DiffPair_float_0 _S136; + (&_S136)->primal_0 = _S134; + (&_S136)->differential_0 = 0.0f; + DiffPair_float_0 _S137 = _d_atan2_0(&_S135, &_S136); + float k_3; + float s_diff_k_1; + if((_S133.primal_0) < 9.99999997475242708e-07f) + { + float _S138 = _S137.differential_0 * _S137.primal_0; + float _S139 = 1.0f - _S137.primal_0 * _S137.primal_0 / 24.0f; + float _S140 = ((0.0f - (_S138 + _S138) * 0.0416666679084301f) * _S134 - _S139 * 0.0f) / (_S134 * _S134); + k_3 = _S139 / _S134; + s_diff_k_1 = _S140; + } + else + { + float _S141 = _S137.differential_0 * 0.5f; + DiffPair_float_0 _S142; + (&_S142)->primal_0 = 0.5f * _S137.primal_0; + (&_S142)->differential_0 = _S141; + DiffPair_float_0 _S143 = _d_sin_0(&_S142); + float _S144 = 2.0f * _S143.primal_0; + float _S145 = (_S143.differential_0 * 2.0f * _S133.primal_0 - _S144 * _S133.differential_0) / (_S133.primal_0 * _S133.primal_0); + k_3 = _S144 / _S133.primal_0; + s_diff_k_1 = _S145; + } + float2 _S146 = _S130 * make_float2 (k_3); + float2 _S147 = _S131 * make_float2 (k_3) + make_float2 (s_diff_k_1) * _S130; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S148; + (&_S148)->primal_0 = _S146; + (&_S148)->differential_0 = _S147; + FixedArray _S149 = dist_coeffs_6; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S150 = s_fwd_DistNone_distort_0(&_S148, &_S149); + float fx_3 = intrins_7.x; + float fy_3 = intrins_7.y; + float _S151 = _S150.differential_0.y * fy_3; + *&(((&J_3)->rows + (int(0)))->x) = _S150.differential_0.x * fx_3; + *&(((&J_3)->rows + (int(1)))->x) = _S151; + float2 _S152 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S153; + (&_S153)->primal_0 = _S130; + (&_S153)->differential_0 = _S152; + DiffPair_float_0 _S154 = s_fwd_length_impl_0(&_S153); + DiffPair_float_0 _S155; + (&_S155)->primal_0 = _S154.primal_0; + (&_S155)->differential_0 = _S154.differential_0; + DiffPair_float_0 _S156; + (&_S156)->primal_0 = _S134; + (&_S156)->differential_0 = 0.0f; + DiffPair_float_0 _S157 = _d_atan2_0(&_S155, &_S156); + if((_S154.primal_0) < 9.99999997475242708e-07f) + { + float _S158 = _S157.differential_0 * _S157.primal_0; + float _S159 = 1.0f - _S157.primal_0 * _S157.primal_0 / 24.0f; + float _S160 = ((0.0f - (_S158 + _S158) * 0.0416666679084301f) * _S134 - _S159 * 0.0f) / (_S134 * _S134); + k_3 = _S159 / _S134; + s_diff_k_1 = _S160; + } + else + { + float _S161 = _S157.differential_0 * 0.5f; + DiffPair_float_0 _S162; + (&_S162)->primal_0 = 0.5f * _S157.primal_0; + (&_S162)->differential_0 = _S161; + DiffPair_float_0 _S163 = _d_sin_0(&_S162); + float _S164 = 2.0f * _S163.primal_0; + float _S165 = (_S163.differential_0 * 2.0f * _S154.primal_0 - _S164 * _S154.differential_0) / (_S154.primal_0 * _S154.primal_0); + k_3 = _S164 / _S154.primal_0; + s_diff_k_1 = _S165; + } + float2 _S166 = _S130 * make_float2 (k_3); + float2 _S167 = _S152 * make_float2 (k_3) + make_float2 (s_diff_k_1) * _S130; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S168; + (&_S168)->primal_0 = _S166; + (&_S168)->differential_0 = _S167; + FixedArray _S169 = dist_coeffs_6; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S170 = s_fwd_DistNone_distort_0(&_S168, &_S169); + float _S171 = _S170.differential_0.y * fy_3; + *&(((&J_3)->rows + (int(0)))->y) = _S170.differential_0.x * fx_3; + *&(((&J_3)->rows + (int(1)))->y) = _S171; + float2 _S172 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S173; + (&_S173)->primal_0 = _S130; + (&_S173)->differential_0 = _S172; + DiffPair_float_0 _S174 = s_fwd_length_impl_0(&_S173); + DiffPair_float_0 _S175; + (&_S175)->primal_0 = _S174.primal_0; + (&_S175)->differential_0 = _S174.differential_0; + DiffPair_float_0 _S176; + (&_S176)->primal_0 = _S134; + (&_S176)->differential_0 = 1.0f; + DiffPair_float_0 _S177 = _d_atan2_0(&_S175, &_S176); + if((_S174.primal_0) < 9.99999997475242708e-07f) + { + float _S178 = _S177.differential_0 * _S177.primal_0; + float _S179 = 1.0f - _S177.primal_0 * _S177.primal_0 / 24.0f; + float _S180 = ((0.0f - (_S178 + _S178) * 0.0416666679084301f) * _S134 - _S179) / (_S134 * _S134); + k_3 = _S179 / _S134; + s_diff_k_1 = _S180; + } + else + { + float _S181 = _S177.differential_0 * 0.5f; + DiffPair_float_0 _S182; + (&_S182)->primal_0 = 0.5f * _S177.primal_0; + (&_S182)->differential_0 = _S181; + DiffPair_float_0 _S183 = _d_sin_0(&_S182); + float _S184 = 2.0f * _S183.primal_0; + float _S185 = (_S183.differential_0 * 2.0f * _S174.primal_0 - _S184 * _S174.differential_0) / (_S174.primal_0 * _S174.primal_0); + k_3 = _S184 / _S174.primal_0; + s_diff_k_1 = _S185; + } + float2 _S186 = _S130 * make_float2 (k_3); + float2 _S187 = _S172 * make_float2 (k_3) + make_float2 (s_diff_k_1) * _S130; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S188; + (&_S188)->primal_0 = _S186; + (&_S188)->differential_0 = _S187; + FixedArray _S189 = dist_coeffs_6; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S190 = s_fwd_DistNone_distort_0(&_S188, &_S189); + float _S191 = _S190.differential_0.y * fy_3; + *&(((&J_3)->rows + (int(0)))->z) = _S190.differential_0.x * fx_3; + *&(((&J_3)->rows + (int(1)))->z) = _S191; + return J_3; +} + +inline __device__ float2 distort_point_none(float2 uv_7, int camera_model_0, FixedArray dist_coeffs_7) +{ + float2 _S192; + for(;;) + { + if(camera_model_0 == int(3)) { - float r_6 = length_0(uv_5); - float theta_3 = (F32_atan((r_6))); - if(r_6 < 0.00100000004749745f) + _S192 = uv_7; + break; + } + float k_4; + if(camera_model_0 == int(1)) + { + float r_5 = length_0(uv_7); + float theta_2 = (F32_atan((r_5))); + if(r_5 < 0.00100000004749745f) { - k_4 = 1.0f - theta_3 * theta_3 / 24.0f; + k_4 = 1.0f - theta_2 * theta_2 / 6.0f; } else { - k_4 = 2.0f * (F32_sin((0.5f * theta_3))) / r_6; + k_4 = theta_2 / r_5; } - _S297 = uv_5 * make_float2 (k_4); + _S192 = uv_7 * make_float2 (k_4); } else { - _S297 = uv_5; + if(camera_model_0 == int(2)) + { + float r_6 = length_0(uv_7); + float theta_3 = (F32_atan((r_6))); + if(r_6 < 0.00100000004749745f) + { + k_4 = 1.0f - theta_3 * theta_3 / 24.0f; + } + else + { + k_4 = 2.0f * (F32_sin((0.5f * theta_3))) / r_6; + } + _S192 = uv_7 * make_float2 (k_4); + } + else + { + _S192 = uv_7; + } } + FixedArray _S193 = dist_coeffs_7; + float2 _S194 = DistNone_distort_0(_S192, &_S193); + _S192 = _S194; + break; } - float u_16 = _S297.x; - float v_16 = _S297.y; - float r2_16 = u_16 * u_16 + v_16 * v_16; - float2 _S298 = _S297 * make_float2 (1.0f + r2_16 * (dist_coeffs_9[int(0)] + r2_16 * (dist_coeffs_9[int(1)] + r2_16 * (dist_coeffs_9[int(2)] + r2_16 * dist_coeffs_9[int(3)])))) + make_float2 (2.0f * dist_coeffs_9[int(4)] * u_16 * v_16 + dist_coeffs_9[int(5)] * (r2_16 + 2.0f * u_16 * u_16) + dist_coeffs_9[int(6)] * r2_16, 2.0f * dist_coeffs_9[int(5)] * u_16 * v_16 + dist_coeffs_9[int(4)] * (r2_16 + 2.0f * v_16 * v_16) + dist_coeffs_9[int(7)] * r2_16); - return _S298 + make_float2 (dist_coeffs_9[int(8)] * _S298.x + dist_coeffs_9[int(9)] * _S298.y, 0.0f); + return _S192; } -inline __device__ bool undistort_point_0(float2 uv_6, FixedArray * dist_coeffs_10, int maxiter_0, float2 * uv_undist_0) +inline __device__ bool undistort_point_0(float2 uv_8, FixedArray * dist_coeffs_8, int maxiter_0, float2 * uv_undist_0) +{ + *uv_undist_0 = uv_8; + return true; +} + +inline __device__ float2 DistOpenCV_distort_0(float2 uv_9, FixedArray * coeffs_2) +{ + float u_0 = uv_9.x; + float v_0 = uv_9.y; + float r2_0 = u_0 * u_0 + v_0 * v_0; + return uv_9 * make_float2 (1.0f + r2_0 * ((*coeffs_2)[int(0)] + r2_0 * (*coeffs_2)[int(1)])) + make_float2 (2.0f * (*coeffs_2)[int(2)] * u_0 * v_0 + (*coeffs_2)[int(3)] * (r2_0 + 2.0f * u_0 * u_0), 2.0f * (*coeffs_2)[int(3)] * u_0 * v_0 + (*coeffs_2)[int(2)] * (r2_0 + 2.0f * v_0 * v_0)); +} + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistOpenCV_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_1, FixedArray * coeffs_3) +{ + float u_1 = dpuv_1->primal_0.x; + float s_diff_u_0 = dpuv_1->differential_0.x; + float v_1 = dpuv_1->primal_0.y; + float s_diff_v_0 = dpuv_1->differential_0.y; + float _S195 = s_diff_u_0 * u_1; + float _S196 = s_diff_v_0 * v_1; + float r2_1 = u_1 * u_1 + v_1 * v_1; + float s_diff_r2_0 = _S195 + _S195 + (_S196 + _S196); + float _S197 = (*coeffs_3)[int(0)] + r2_1 * (*coeffs_3)[int(1)]; + float radial_0 = 1.0f + r2_1 * _S197; + float _S198 = 2.0f * (*coeffs_3)[int(2)]; + float _S199 = _S198 * u_1; + float _S200 = 2.0f * u_1; + float _S201 = 2.0f * (*coeffs_3)[int(3)]; + float _S202 = _S201 * u_1; + float _S203 = 2.0f * v_1; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S204 = { dpuv_1->primal_0 * make_float2 (radial_0) + make_float2 (_S199 * v_1 + (*coeffs_3)[int(3)] * (r2_1 + _S200 * u_1), _S202 * v_1 + (*coeffs_3)[int(2)] * (r2_1 + _S203 * v_1)), dpuv_1->differential_0 * make_float2 (radial_0) + make_float2 (s_diff_r2_0 * _S197 + s_diff_r2_0 * (*coeffs_3)[int(1)] * r2_1) * dpuv_1->primal_0 + make_float2 (s_diff_u_0 * _S198 * v_1 + s_diff_v_0 * _S199 + (s_diff_r2_0 + (s_diff_u_0 * 2.0f * u_1 + s_diff_u_0 * _S200)) * (*coeffs_3)[int(3)], s_diff_u_0 * _S201 * v_1 + s_diff_v_0 * _S202 + (s_diff_r2_0 + (s_diff_v_0 * 2.0f * v_1 + s_diff_v_0 * _S203)) * (*coeffs_3)[int(2)]) }; + return _S204; +} + +inline __device__ bool undistort_point_1(float2 uv_10, FixedArray * dist_coeffs_9, int maxiter_1, float2 * uv_undist_1) { int i_4 = int(0); - float2 q_0 = uv_6; + float2 q_0 = uv_10; for(;;) { - if(i_4 < maxiter_0) + if(i_4 < maxiter_1) { } else { break; } - float _S299 = (*dist_coeffs_10)[int(3)]; - float _S300 = (*dist_coeffs_10)[int(4)]; - float _S301 = (*dist_coeffs_10)[int(5)]; - float _S302 = (*dist_coeffs_10)[int(6)]; - float _S303 = (*dist_coeffs_10)[int(7)]; - float _S304 = (*dist_coeffs_10)[int(8)]; - float _S305 = (*dist_coeffs_10)[int(9)]; - float u_17 = q_0.x; - float v_17 = q_0.y; - float r2_17 = u_17 * u_17 + v_17 * v_17; - float _S306 = (*dist_coeffs_10)[int(2)] + r2_17 * (*dist_coeffs_10)[int(3)]; - float _S307 = (*dist_coeffs_10)[int(1)] + r2_17 * _S306; - float _S308 = (*dist_coeffs_10)[int(0)] + r2_17 * _S307; - float radial_4 = 1.0f + r2_17 * _S308; - float _S309 = 2.0f * (*dist_coeffs_10)[int(4)]; - float _S310 = _S309 * u_17; - float _S311 = 2.0f * u_17; - float _S312 = 2.0f * (*dist_coeffs_10)[int(5)]; - float _S313 = _S312 * u_17; - float _S314 = 2.0f * v_17; - float2 _S315 = q_0 * make_float2 (radial_4) + make_float2 (_S310 * v_17 + (*dist_coeffs_10)[int(5)] * (r2_17 + _S311 * u_17) + (*dist_coeffs_10)[int(6)] * r2_17, _S313 * v_17 + (*dist_coeffs_10)[int(4)] * (r2_17 + _S314 * v_17) + (*dist_coeffs_10)[int(7)] * r2_17); - float2 r_7 = _S315 + make_float2 ((*dist_coeffs_10)[int(8)] * _S315.x + (*dist_coeffs_10)[int(9)] * _S315.y, 0.0f) - uv_6; - float _S316 = 0.0f * v_17; - float s_diff_r2_17 = u_17 + u_17 + (_S316 + _S316); - float2 _S317 = make_float2 (1.0f, 0.0f) * make_float2 (radial_4) + make_float2 (s_diff_r2_17 * _S308 + (s_diff_r2_17 * _S307 + (s_diff_r2_17 * _S306 + s_diff_r2_17 * _S299 * r2_17) * r2_17) * r2_17) * q_0 + make_float2 (_S309 * v_17 + 0.0f * _S310 + (s_diff_r2_17 + (_S311 + _S311)) * _S301 + s_diff_r2_17 * _S302, _S312 * v_17 + 0.0f * _S313 + (s_diff_r2_17 + (_S316 + 0.0f * _S314)) * _S300 + s_diff_r2_17 * _S303); - float _S318 = 0.0f * u_17; - float s_diff_r2_18 = _S318 + _S318 + (v_17 + v_17); - float2 _S319 = make_float2 (0.0f, 1.0f) * make_float2 (radial_4) + make_float2 (s_diff_r2_18 * _S308 + (s_diff_r2_18 * _S307 + (s_diff_r2_18 * _S306 + s_diff_r2_18 * _S299 * r2_17) * r2_17) * r2_17) * q_0 + make_float2 (0.0f * _S309 * v_17 + _S310 + (s_diff_r2_18 + (_S318 + 0.0f * _S311)) * _S301 + s_diff_r2_18 * _S302, 0.0f * _S312 * v_17 + _S313 + (s_diff_r2_18 + (_S314 + _S314)) * _S300 + s_diff_r2_18 * _S303); - Matrix _S320 = transpose_1(makeMatrix (_S317 + make_float2 (_S317.x * _S304 + _S317.y * _S305, 0.0f), _S319 + make_float2 (_S319.x * _S304 + _S319.y * _S305, 0.0f))); - float inv_det_0 = 1.0f / (_S320.rows[int(0)].x * _S320.rows[int(1)].y - _S320.rows[int(0)].y * _S320.rows[int(1)].x); - float _S321 = r_7.x; - float _S322 = r_7.y; - float2 q_1 = q_0 - make_float2 ((_S321 * _S320.rows[int(1)].y - _S322 * _S320.rows[int(0)].y) * inv_det_0, (- _S321 * _S320.rows[int(1)].x + _S322 * _S320.rows[int(0)].x) * inv_det_0); + float2 _S205 = DistOpenCV_distort_0(q_0, dist_coeffs_9); + float2 r_7 = _S205 - uv_10; + float2 _S206 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S207; + (&_S207)->primal_0 = q_0; + (&_S207)->differential_0 = _S206; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S208 = s_fwd_DistOpenCV_distort_0(&_S207, dist_coeffs_9); + float2 _S209 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S210; + (&_S210)->primal_0 = q_0; + (&_S210)->differential_0 = _S209; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S211 = s_fwd_DistOpenCV_distort_0(&_S210, dist_coeffs_9); + Matrix _S212 = transpose_1(makeMatrix (_S208.differential_0, _S211.differential_0)); + float inv_det_0 = 1.0f / (_S212.rows[int(0)].x * _S212.rows[int(1)].y - _S212.rows[int(0)].y * _S212.rows[int(1)].x); + float _S213 = r_7.x; + float _S214 = r_7.y; + float2 q_1 = q_0 - make_float2 ((_S213 * _S212.rows[int(1)].y - _S214 * _S212.rows[int(0)].y) * inv_det_0, (- _S213 * _S212.rows[int(1)].x + _S214 * _S212.rows[int(0)].x) * inv_det_0); i_4 = i_4 + int(1); q_0 = q_1; } - *uv_undist_0 = q_0; - float _S323 = (*dist_coeffs_10)[int(0)]; - float _S324 = (*dist_coeffs_10)[int(1)]; - float _S325 = (*dist_coeffs_10)[int(2)]; - float _S326 = (*dist_coeffs_10)[int(3)]; - float _S327 = (*dist_coeffs_10)[int(4)]; - float _S328 = (*dist_coeffs_10)[int(5)]; - float _S329 = (*dist_coeffs_10)[int(6)]; - float _S330 = (*dist_coeffs_10)[int(7)]; - float _S331 = (*dist_coeffs_10)[int(8)]; - float _S332 = (*dist_coeffs_10)[int(9)]; - float u_18 = q_0.x; - float v_18 = q_0.y; - float _S333 = 0.0f * v_18; - float r2_18 = u_18 * u_18 + v_18 * v_18; - float s_diff_r2_19 = u_18 + u_18 + (_S333 + _S333); - float _S334 = (*dist_coeffs_10)[int(2)] + r2_18 * (*dist_coeffs_10)[int(3)]; - float _S335 = (*dist_coeffs_10)[int(1)] + r2_18 * _S334; - float _S336 = (*dist_coeffs_10)[int(0)] + r2_18 * _S335; - float radial_5 = 1.0f + r2_18 * _S336; - float _S337 = 2.0f * (*dist_coeffs_10)[int(4)]; - float _S338 = _S337 * u_18; - float _S339 = 2.0f * u_18; - float _S340 = 2.0f * (*dist_coeffs_10)[int(5)]; - float _S341 = _S340 * u_18; - float _S342 = 2.0f * v_18; - float2 _S343 = make_float2 (1.0f, 0.0f) * make_float2 (radial_5) + make_float2 (s_diff_r2_19 * _S336 + (s_diff_r2_19 * _S335 + (s_diff_r2_19 * _S334 + s_diff_r2_19 * (*dist_coeffs_10)[int(3)] * r2_18) * r2_18) * r2_18) * q_0 + make_float2 (_S337 * v_18 + 0.0f * _S338 + (s_diff_r2_19 + (_S339 + _S339)) * (*dist_coeffs_10)[int(5)] + s_diff_r2_19 * (*dist_coeffs_10)[int(6)], _S340 * v_18 + 0.0f * _S341 + (s_diff_r2_19 + (_S333 + 0.0f * _S342)) * (*dist_coeffs_10)[int(4)] + s_diff_r2_19 * (*dist_coeffs_10)[int(7)]); - float _S344 = 0.0f * u_18; - float s_diff_r2_20 = _S344 + _S344 + (v_18 + v_18); - float2 _S345 = make_float2 (0.0f, 1.0f) * make_float2 (radial_5) + make_float2 (s_diff_r2_20 * _S336 + (s_diff_r2_20 * _S335 + (s_diff_r2_20 * _S334 + s_diff_r2_20 * (*dist_coeffs_10)[int(3)] * r2_18) * r2_18) * r2_18) * q_0 + make_float2 (0.0f * _S337 * v_18 + _S338 + (s_diff_r2_20 + (_S344 + 0.0f * _S339)) * (*dist_coeffs_10)[int(5)] + s_diff_r2_20 * (*dist_coeffs_10)[int(6)], 0.0f * _S340 * v_18 + _S341 + (s_diff_r2_20 + (_S342 + _S342)) * (*dist_coeffs_10)[int(4)] + s_diff_r2_20 * (*dist_coeffs_10)[int(7)]); - Matrix _S346 = transpose_1(makeMatrix (_S343 + make_float2 (_S343.x * (*dist_coeffs_10)[int(8)] + _S343.y * (*dist_coeffs_10)[int(9)], 0.0f), _S345 + make_float2 (_S345.x * (*dist_coeffs_10)[int(8)] + _S345.y * (*dist_coeffs_10)[int(9)], 0.0f))); - bool _S347; - if((F32_min((determinant_0(_S346)), ((F32_min((_S346.rows[int(0)].x), (_S346.rows[int(1)].y)))))) > 0.0f) + *uv_undist_1 = q_0; + float2 _S215 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S216; + (&_S216)->primal_0 = q_0; + (&_S216)->differential_0 = _S215; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S217 = s_fwd_DistOpenCV_distort_0(&_S216, dist_coeffs_9); + float2 _S218 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S219; + (&_S219)->primal_0 = q_0; + (&_S219)->differential_0 = _S218; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S220 = s_fwd_DistOpenCV_distort_0(&_S219, dist_coeffs_9); + Matrix _S221 = transpose_1(makeMatrix (_S217.differential_0, _S220.differential_0)); + float _S222 = (F32_min((determinant_0(_S221)), ((F32_min((_S221.rows[int(0)].x), (_S221.rows[int(1)].y)))))); + bool _S223; + if(_S222 > 0.25f) { - float u_19 = (*uv_undist_0).x; - float v_19 = (*uv_undist_0).y; - float r2_19 = u_19 * u_19 + v_19 * v_19; - float2 _S348 = *uv_undist_0 * make_float2 (1.0f + r2_19 * (_S323 + r2_19 * (_S324 + r2_19 * (_S325 + r2_19 * _S326)))) + make_float2 (_S337 * u_19 * v_19 + _S328 * (r2_19 + 2.0f * u_19 * u_19) + _S329 * r2_19, _S340 * u_19 * v_19 + _S327 * (r2_19 + 2.0f * v_19 * v_19) + _S330 * r2_19); - _S347 = (length_0(_S348 + make_float2 (_S331 * _S348.x + _S332 * _S348.y, 0.0f) - uv_6)) < 0.00999999977648258f; + _S223 = _S222 < 4.0f; } else { - _S347 = false; + _S223 = false; } - return _S347; + if(_S223) + { + float2 _S224 = DistOpenCV_distort_0(q_0, dist_coeffs_9); + _S223 = (dot_0(q_0, _S224)) >= 0.0f; + } + else + { + _S223 = false; + } + if(_S223) + { + float2 _S225 = DistOpenCV_distort_0(*uv_undist_1, dist_coeffs_9); + _S223 = (length_0(_S225 - uv_10)) < 0.00999999977648258f; + } + else + { + _S223 = false; + } + return _S223; } -inline __device__ bool undistort_point(float2 uv_7, int camera_model_1, FixedArray dist_coeffs_11, float2 * uv_undist_1) +inline __device__ float2 DistThinPrism_distort_0(float2 uv_11, FixedArray * coeffs_4) { - float2 _S349 = uv_7; - if(camera_model_1 == int(3)) - { - float lon_0 = _S349.x; - float lat_0 = _S349.y; - float cl_0 = (F32_cos((lat_0))); - *uv_undist_1 = make_float2 (cl_0 * (F32_sin((lon_0))), (F32_sin((lat_0)))) / make_float2 ((F32_max((cl_0 * (F32_cos((lon_0)))), (9.999999960041972e-13f)))); - return true; - } - FixedArray _S350 = dist_coeffs_11; - bool _S351 = undistort_point_0(_S349, &_S350, int(8), &_S349); - if(!_S351) - { - return false; - } - float3 raydir_0; - if(camera_model_1 == int(1)) - { - float r_8 = length_0(_S349); - float s_0; - if(r_8 < 0.00100000004749745f) - { - s_0 = 1.0f - r_8 * r_8 / 6.0f; - } - else - { - s_0 = (F32_sin((r_8))) / r_8; - } - raydir_0 = make_float3 ((_S349 * make_float2 (s_0)).x, (_S349 * make_float2 (s_0)).y, (F32_cos((r_8)))); - } - else - { - if(camera_model_1 == int(2)) - { - float r_9 = length_0(_S349); - raydir_0 = make_float3 ((_S349 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_9 * r_9)))))))).x, (_S349 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_9 * r_9)))))))).y, 1.0f - 0.5f * r_9 * r_9); - } - else - { - raydir_0 = make_float3 (_S349.x, _S349.y, 1.0f); - } - } - *uv_undist_1 = float2 {raydir_0.x, raydir_0.y} / make_float2 ((F32_max((raydir_0.z), (9.999999960041972e-13f)))); - return true; + float u_2 = uv_11.x; + float v_2 = uv_11.y; + float r2_2 = u_2 * u_2 + v_2 * v_2; + return uv_11 * make_float2 (1.0f + r2_2 * ((*coeffs_4)[int(0)] + r2_2 * ((*coeffs_4)[int(1)] + r2_2 * ((*coeffs_4)[int(2)] + r2_2 * (*coeffs_4)[int(3)])))) + make_float2 (2.0f * (*coeffs_4)[int(4)] * u_2 * v_2 + (*coeffs_4)[int(5)] * (r2_2 + 2.0f * u_2 * u_2) + (*coeffs_4)[int(6)] * r2_2, 2.0f * (*coeffs_4)[int(5)] * u_2 * v_2 + (*coeffs_4)[int(4)] * (r2_2 + 2.0f * v_2 * v_2) + (*coeffs_4)[int(7)] * r2_2); } -inline __device__ bool unproject_point(float2 uv_8, int camera_model_2, FixedArray dist_coeffs_12, float3 * raydir_1) +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistThinPrism_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_2, FixedArray * coeffs_5) { - float2 _S352 = uv_8; - int3 _S353 = make_int3 (int(0)); - float3 _S354 = make_float3 ((float)_S353.x, (float)_S353.y, (float)_S353.z); - *raydir_1 = _S354; - if(camera_model_2 == int(3)) + float u_3 = dpuv_2->primal_0.x; + float s_diff_u_1 = dpuv_2->differential_0.x; + float v_3 = dpuv_2->primal_0.y; + float s_diff_v_1 = dpuv_2->differential_0.y; + float _S226 = s_diff_u_1 * u_3; + float _S227 = s_diff_v_1 * v_3; + float r2_3 = u_3 * u_3 + v_3 * v_3; + float s_diff_r2_1 = _S226 + _S226 + (_S227 + _S227); + float _S228 = (*coeffs_5)[int(2)] + r2_3 * (*coeffs_5)[int(3)]; + float _S229 = (*coeffs_5)[int(1)] + r2_3 * _S228; + float _S230 = (*coeffs_5)[int(0)] + r2_3 * _S229; + float radial_1 = 1.0f + r2_3 * _S230; + float _S231 = 2.0f * (*coeffs_5)[int(4)]; + float _S232 = _S231 * u_3; + float _S233 = 2.0f * u_3; + float _S234 = 2.0f * (*coeffs_5)[int(5)]; + float _S235 = _S234 * u_3; + float _S236 = 2.0f * v_3; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S237 = { dpuv_2->primal_0 * make_float2 (radial_1) + make_float2 (_S232 * v_3 + (*coeffs_5)[int(5)] * (r2_3 + _S233 * u_3) + (*coeffs_5)[int(6)] * r2_3, _S235 * v_3 + (*coeffs_5)[int(4)] * (r2_3 + _S236 * v_3) + (*coeffs_5)[int(7)] * r2_3), dpuv_2->differential_0 * make_float2 (radial_1) + make_float2 (s_diff_r2_1 * _S230 + (s_diff_r2_1 * _S229 + (s_diff_r2_1 * _S228 + s_diff_r2_1 * (*coeffs_5)[int(3)] * r2_3) * r2_3) * r2_3) * dpuv_2->primal_0 + make_float2 (s_diff_u_1 * _S231 * v_3 + s_diff_v_1 * _S232 + (s_diff_r2_1 + (s_diff_u_1 * 2.0f * u_3 + s_diff_u_1 * _S233)) * (*coeffs_5)[int(5)] + s_diff_r2_1 * (*coeffs_5)[int(6)], s_diff_u_1 * _S234 * v_3 + s_diff_v_1 * _S235 + (s_diff_r2_1 + (s_diff_v_1 * 2.0f * v_3 + s_diff_v_1 * _S236)) * (*coeffs_5)[int(4)] + s_diff_r2_1 * (*coeffs_5)[int(7)]) }; + return _S237; +} + +inline __device__ bool undistort_point_2(float2 uv_12, FixedArray * dist_coeffs_10, int maxiter_2, float2 * uv_undist_2) +{ + int i_5 = int(0); + float2 q_2 = uv_12; + for(;;) { - float lon_1 = _S352.x; - float lat_1 = _S352.y; - float cl_1 = (F32_cos((lat_1))); - *raydir_1 = make_float3 (cl_1 * (F32_sin((lon_1))), (F32_sin((lat_1))), cl_1 * (F32_cos((lon_1)))); - return true; - } - FixedArray _S355 = dist_coeffs_12; - bool _S356 = undistort_point_0(_S352, &_S355, int(8), &_S352); - if(!_S356) - { - return false; - } - if(camera_model_2 == int(1)) - { - float r_10 = length_0(_S352); - float s_1; - if(r_10 < 0.00100000004749745f) + if(i_5 < maxiter_2) { - s_1 = 1.0f - r_10 * r_10 / 6.0f; } else { - s_1 = (F32_sin((r_10))) / r_10; + break; } - *raydir_1 = make_float3 ((_S352 * make_float2 (s_1)).x, (_S352 * make_float2 (s_1)).y, (F32_cos((r_10)))); + float2 _S238 = DistThinPrism_distort_0(q_2, dist_coeffs_10); + float2 r_8 = _S238 - uv_12; + float2 _S239 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S240; + (&_S240)->primal_0 = q_2; + (&_S240)->differential_0 = _S239; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S241 = s_fwd_DistThinPrism_distort_0(&_S240, dist_coeffs_10); + float2 _S242 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S243; + (&_S243)->primal_0 = q_2; + (&_S243)->differential_0 = _S242; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S244 = s_fwd_DistThinPrism_distort_0(&_S243, dist_coeffs_10); + Matrix _S245 = transpose_1(makeMatrix (_S241.differential_0, _S244.differential_0)); + float inv_det_1 = 1.0f / (_S245.rows[int(0)].x * _S245.rows[int(1)].y - _S245.rows[int(0)].y * _S245.rows[int(1)].x); + float _S246 = r_8.x; + float _S247 = r_8.y; + float2 q_3 = q_2 - make_float2 ((_S246 * _S245.rows[int(1)].y - _S247 * _S245.rows[int(0)].y) * inv_det_1, (- _S246 * _S245.rows[int(1)].x + _S247 * _S245.rows[int(0)].x) * inv_det_1); + i_5 = i_5 + int(1); + q_2 = q_3; + } + *uv_undist_2 = q_2; + float2 _S248 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S249; + (&_S249)->primal_0 = q_2; + (&_S249)->differential_0 = _S248; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S250 = s_fwd_DistThinPrism_distort_0(&_S249, dist_coeffs_10); + float2 _S251 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S252; + (&_S252)->primal_0 = q_2; + (&_S252)->differential_0 = _S251; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S253 = s_fwd_DistThinPrism_distort_0(&_S252, dist_coeffs_10); + Matrix _S254 = transpose_1(makeMatrix (_S250.differential_0, _S253.differential_0)); + float _S255 = (F32_min((determinant_0(_S254)), ((F32_min((_S254.rows[int(0)].x), (_S254.rows[int(1)].y)))))); + bool _S256; + if(_S255 > 0.25f) + { + _S256 = _S255 < 4.0f; } else { - if(camera_model_2 == int(2)) + _S256 = false; + } + if(_S256) + { + float2 _S257 = DistThinPrism_distort_0(q_2, dist_coeffs_10); + _S256 = (dot_0(q_2, _S257)) >= 0.0f; + } + else + { + _S256 = false; + } + if(_S256) + { + float2 _S258 = DistThinPrism_distort_0(*uv_undist_2, dist_coeffs_10); + _S256 = (length_0(_S258 - uv_12)) < 0.00999999977648258f; + } + else + { + _S256 = false; + } + return _S256; +} + +inline __device__ float2 DistRational_distort_0(float2 uv_13, FixedArray * coeffs_6) +{ + float u_4 = uv_13.x; + float v_4 = uv_13.y; + float r2_4 = u_4 * u_4 + v_4 * v_4; + return uv_13 * make_float2 ((1.0f + r2_4 * ((*coeffs_6)[int(0)] + r2_4 * ((*coeffs_6)[int(1)] + r2_4 * (*coeffs_6)[int(2)]))) / (1.0f + r2_4 * ((*coeffs_6)[int(3)] + r2_4 * ((*coeffs_6)[int(4)] + r2_4 * (*coeffs_6)[int(5)])))) + make_float2 (2.0f * (*coeffs_6)[int(6)] * u_4 * v_4 + (*coeffs_6)[int(7)] * (r2_4 + 2.0f * u_4 * u_4), 2.0f * (*coeffs_6)[int(7)] * u_4 * v_4 + (*coeffs_6)[int(6)] * (r2_4 + 2.0f * v_4 * v_4)); +} + +inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistRational_distort_0(DiffPair_vectorx3Cfloatx2C2x3E_0 * dpuv_3, FixedArray * coeffs_7) +{ + float u_5 = dpuv_3->primal_0.x; + float s_diff_u_2 = dpuv_3->differential_0.x; + float v_5 = dpuv_3->primal_0.y; + float s_diff_v_2 = dpuv_3->differential_0.y; + float _S259 = s_diff_u_2 * u_5; + float _S260 = s_diff_v_2 * v_5; + float r2_5 = u_5 * u_5 + v_5 * v_5; + float s_diff_r2_2 = _S259 + _S259 + (_S260 + _S260); + float _S261 = (*coeffs_7)[int(1)] + r2_5 * (*coeffs_7)[int(2)]; + float _S262 = (*coeffs_7)[int(0)] + r2_5 * _S261; + float _S263 = 1.0f + r2_5 * _S262; + float _S264 = (*coeffs_7)[int(4)] + r2_5 * (*coeffs_7)[int(5)]; + float _S265 = (*coeffs_7)[int(3)] + r2_5 * _S264; + float _S266 = 1.0f + r2_5 * _S265; + float radial_2 = _S263 / _S266; + float _S267 = 2.0f * (*coeffs_7)[int(6)]; + float _S268 = _S267 * u_5; + float _S269 = 2.0f * u_5; + float _S270 = 2.0f * (*coeffs_7)[int(7)]; + float _S271 = _S270 * u_5; + float _S272 = 2.0f * v_5; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S273 = { dpuv_3->primal_0 * make_float2 (radial_2) + make_float2 (_S268 * v_5 + (*coeffs_7)[int(7)] * (r2_5 + _S269 * u_5), _S271 * v_5 + (*coeffs_7)[int(6)] * (r2_5 + _S272 * v_5)), dpuv_3->differential_0 * make_float2 (radial_2) + make_float2 (((s_diff_r2_2 * _S262 + (s_diff_r2_2 * _S261 + s_diff_r2_2 * (*coeffs_7)[int(2)] * r2_5) * r2_5) * _S266 - _S263 * (s_diff_r2_2 * _S265 + (s_diff_r2_2 * _S264 + s_diff_r2_2 * (*coeffs_7)[int(5)] * r2_5) * r2_5)) / (_S266 * _S266)) * dpuv_3->primal_0 + make_float2 (s_diff_u_2 * _S267 * v_5 + s_diff_v_2 * _S268 + (s_diff_r2_2 + (s_diff_u_2 * 2.0f * u_5 + s_diff_u_2 * _S269)) * (*coeffs_7)[int(7)], s_diff_u_2 * _S270 * v_5 + s_diff_v_2 * _S271 + (s_diff_r2_2 + (s_diff_v_2 * 2.0f * v_5 + s_diff_v_2 * _S272)) * (*coeffs_7)[int(6)]) }; + return _S273; +} + +inline __device__ bool undistort_point_3(float2 uv_14, FixedArray * dist_coeffs_11, int maxiter_3, float2 * uv_undist_3) +{ + int i_6 = int(0); + float2 q_4 = uv_14; + for(;;) + { + if(i_6 < maxiter_3) { - float r_11 = length_0(_S352); - *raydir_1 = make_float3 ((_S352 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_11 * r_11)))))))).x, (_S352 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_11 * r_11)))))))).y, 1.0f - 0.5f * r_11 * r_11); } else { - *raydir_1 = make_float3 (_S352.x, _S352.y, 1.0f); + break; } + float2 _S274 = DistRational_distort_0(q_4, dist_coeffs_11); + float2 r_9 = _S274 - uv_14; + float2 _S275 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S276; + (&_S276)->primal_0 = q_4; + (&_S276)->differential_0 = _S275; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S277 = s_fwd_DistRational_distort_0(&_S276, dist_coeffs_11); + float2 _S278 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S279; + (&_S279)->primal_0 = q_4; + (&_S279)->differential_0 = _S278; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S280 = s_fwd_DistRational_distort_0(&_S279, dist_coeffs_11); + Matrix _S281 = transpose_1(makeMatrix (_S277.differential_0, _S280.differential_0)); + float inv_det_2 = 1.0f / (_S281.rows[int(0)].x * _S281.rows[int(1)].y - _S281.rows[int(0)].y * _S281.rows[int(1)].x); + float _S282 = r_9.x; + float _S283 = r_9.y; + float2 q_5 = q_4 - make_float2 ((_S282 * _S281.rows[int(1)].y - _S283 * _S281.rows[int(0)].y) * inv_det_2, (- _S282 * _S281.rows[int(1)].x + _S283 * _S281.rows[int(0)].x) * inv_det_2); + i_6 = i_6 + int(1); + q_4 = q_5; } - return true; + *uv_undist_3 = q_4; + float2 _S284 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S285; + (&_S285)->primal_0 = q_4; + (&_S285)->differential_0 = _S284; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S286 = s_fwd_DistRational_distort_0(&_S285, dist_coeffs_11); + float2 _S287 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S288; + (&_S288)->primal_0 = q_4; + (&_S288)->differential_0 = _S287; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S289 = s_fwd_DistRational_distort_0(&_S288, dist_coeffs_11); + Matrix _S290 = transpose_1(makeMatrix (_S286.differential_0, _S289.differential_0)); + float _S291 = (F32_min((determinant_0(_S290)), ((F32_min((_S290.rows[int(0)].x), (_S290.rows[int(1)].y)))))); + bool _S292; + if(_S291 > 0.25f) + { + _S292 = _S291 < 4.0f; + } + else + { + _S292 = false; + } + if(_S292) + { + float2 _S293 = DistRational_distort_0(q_4, dist_coeffs_11); + _S292 = (dot_0(q_4, _S293)) >= 0.0f; + } + else + { + _S292 = false; + } + if(_S292) + { + float2 _S294 = DistRational_distort_0(*uv_undist_3, dist_coeffs_11); + _S292 = (length_0(_S294 - uv_14)) < 0.00999999977648258f; + } + else + { + _S292 = false; + } + return _S292; +} + +inline __device__ bool undistort_point_none(float2 uv_15, int camera_model_1, FixedArray dist_coeffs_12, float2 * uv_undist_4) +{ + bool _S295; + for(;;) + { + *uv_undist_4 = make_float2 (0.0f); + if(camera_model_1 == int(3)) + { + float lon_0 = uv_15.x; + float lat_0 = uv_15.y; + float cl_0 = (F32_cos((lat_0))); + *uv_undist_4 = make_float2 (cl_0 * (F32_sin((lon_0))), (F32_sin((lat_0)))) / make_float2 ((F32_max((cl_0 * (F32_cos((lon_0)))), (9.999999960041972e-13f)))); + _S295 = true; + break; + } + FixedArray _S296 = dist_coeffs_12; + float2 uv_u_0; + bool _S297 = undistort_point_0(uv_15, &_S296, int(8), &uv_u_0); + if(!_S297) + { + _S295 = false; + break; + } + float2 _S298 = uv_u_0; + float3 raydir_0; + if(camera_model_1 == int(1)) + { + float r_10 = length_0(_S298); + float s_0; + if(r_10 < 0.00100000004749745f) + { + s_0 = 1.0f - r_10 * r_10 / 6.0f; + } + else + { + s_0 = (F32_sin((r_10))) / r_10; + } + raydir_0 = make_float3 ((_S298 * make_float2 (s_0)).x, (_S298 * make_float2 (s_0)).y, (F32_cos((r_10)))); + } + else + { + if(camera_model_1 == int(2)) + { + float r_11 = length_0(_S298); + raydir_0 = make_float3 ((_S298 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_11 * r_11)))))))).x, (_S298 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_11 * r_11)))))))).y, 1.0f - 0.5f * r_11 * r_11); + } + else + { + raydir_0 = make_float3 (_S298.x, _S298.y, 1.0f); + } + } + *uv_undist_4 = float2 {raydir_0.x, raydir_0.y} / make_float2 ((F32_max((raydir_0.z), (9.999999960041972e-13f)))); + _S295 = true; + break; + } + return _S295; +} + +inline __device__ bool unproject_point_none(float2 uv_16, int camera_model_2, FixedArray dist_coeffs_13, float3 * raydir_1) +{ + bool _S299; + for(;;) + { + int3 _S300 = make_int3 (int(0)); + float3 _S301 = make_float3 ((float)_S300.x, (float)_S300.y, (float)_S300.z); + *raydir_1 = _S301; + if(camera_model_2 == int(3)) + { + float lon_1 = uv_16.x; + float lat_1 = uv_16.y; + float cl_1 = (F32_cos((lat_1))); + *raydir_1 = make_float3 (cl_1 * (F32_sin((lon_1))), (F32_sin((lat_1))), cl_1 * (F32_cos((lon_1)))); + _S299 = true; + break; + } + FixedArray _S302 = dist_coeffs_13; + float2 uv_u_1; + bool _S303 = undistort_point_0(uv_16, &_S302, int(8), &uv_u_1); + if(!_S303) + { + _S299 = false; + break; + } + float2 _S304 = uv_u_1; + if(camera_model_2 == int(1)) + { + float r_12 = length_0(_S304); + float s_1; + if(r_12 < 0.00100000004749745f) + { + s_1 = 1.0f - r_12 * r_12 / 6.0f; + } + else + { + s_1 = (F32_sin((r_12))) / r_12; + } + *raydir_1 = make_float3 ((_S304 * make_float2 (s_1)).x, (_S304 * make_float2 (s_1)).y, (F32_cos((r_12)))); + } + else + { + if(camera_model_2 == int(2)) + { + float r_13 = length_0(_S304); + *raydir_1 = make_float3 ((_S304 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_13 * r_13)))))))).x, (_S304 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_13 * r_13)))))))).y, 1.0f - 0.5f * r_13 * r_13); + } + else + { + *raydir_1 = make_float3 (_S304.x, _S304.y, 1.0f); + } + } + _S299 = true; + break; + } + return _S299; } inline __device__ float3 normalize_0(float3 x_11) @@ -1365,107 +1438,2554 @@ inline __device__ float3 normalize_0(float3 x_11) return x_11 / make_float3 (length_1(x_11)); } -inline __device__ bool generate_ray(float2 uv_9, int camera_model_3, FixedArray dist_coeffs_13, float3 * raydir_2) +inline __device__ bool generate_ray_none(float2 uv_17, int camera_model_3, FixedArray dist_coeffs_14, float3 * raydir_2) { - float2 _S357 = uv_9; - if(camera_model_3 == int(3)) + bool _S305; + for(;;) { - bool _S358; - if((F32_abs((_S357.x))) > 3.14159274101257324f) + if(camera_model_3 == int(3)) { - _S358 = true; + float _S306 = uv_17.x; + if((F32_abs((_S306))) > 3.14159274101257324f) + { + _S305 = true; + } + else + { + _S305 = (F32_abs((uv_17.y))) > 1.57079637050628662f; + } + if(_S305) + { + int3 _S307 = make_int3 (int(0)); + float3 _S308 = make_float3 ((float)_S307.x, (float)_S307.y, (float)_S307.z); + *raydir_2 = _S308; + _S305 = false; + break; + } + float lat_2 = uv_17.y; + float cl_2 = (F32_cos((lat_2))); + *raydir_2 = make_float3 (cl_2 * (F32_sin((_S306))), (F32_sin((lat_2))), cl_2 * (F32_cos((_S306)))); + _S305 = true; + break; + } + FixedArray _S309 = dist_coeffs_14; + float2 uv_u_2; + bool _S310 = undistort_point_0(uv_17, &_S309, int(8), &uv_u_2); + if(!_S310) + { + int3 _S311 = make_int3 (int(0)); + float3 _S312 = make_float3 ((float)_S311.x, (float)_S311.y, (float)_S311.z); + *raydir_2 = _S312; + _S305 = false; + break; + } + float2 _S313 = uv_u_2; + if(camera_model_3 == int(1)) + { + float r_14 = length_0(_S313); + if(r_14 >= 3.14159274101257324f) + { + int3 _S314 = make_int3 (int(0)); + float3 _S315 = make_float3 ((float)_S314.x, (float)_S314.y, (float)_S314.z); + *raydir_2 = _S315; + _S305 = false; + break; + } + float s_2; + if(r_14 < 0.00100000004749745f) + { + s_2 = 1.0f - r_14 * r_14 / 6.0f; + } + else + { + s_2 = (F32_sin((r_14))) / r_14; + } + *raydir_2 = make_float3 ((_S313 * make_float2 (s_2)).x, (_S313 * make_float2 (s_2)).y, (F32_cos((r_14)))); } else { - _S358 = (F32_abs((_S357.y))) > 1.57079637050628662f; + if(camera_model_3 == int(2)) + { + float r_15 = length_0(_S313); + if(r_15 >= 2.0f) + { + int3 _S316 = make_int3 (int(0)); + float3 _S317 = make_float3 ((float)_S316.x, (float)_S316.y, (float)_S316.z); + *raydir_2 = _S317; + _S305 = false; + break; + } + *raydir_2 = make_float3 ((_S313 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_15 * r_15)))))))).x, (_S313 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_15 * r_15)))))))).y, 1.0f - 0.5f * r_15 * r_15); + } + else + { + *raydir_2 = make_float3 (_S313.x, _S313.y, 1.0f); + } } - if(_S358) - { - int3 _S359 = make_int3 (int(0)); - float3 _S360 = make_float3 ((float)_S359.x, (float)_S359.y, (float)_S359.z); - *raydir_2 = _S360; - return false; - } - float lon_2 = _S357.x; - float lat_2 = _S357.y; - float cl_2 = (F32_cos((lat_2))); - *raydir_2 = make_float3 (cl_2 * (F32_sin((lon_2))), (F32_sin((lat_2))), cl_2 * (F32_cos((lon_2)))); - return true; + *raydir_2 = normalize_0(*raydir_2); + _S305 = true; + break; } - FixedArray _S361 = dist_coeffs_13; - bool _S362 = undistort_point_0(_S357, &_S361, int(8), &_S357); - if(!_S362) + return _S305; +} + +inline __device__ bool is_valid_distortion_opencv(float2 uv_18, FixedArray dist_coeffs_15) +{ + float2 _S318 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S319; + (&_S319)->primal_0 = uv_18; + (&_S319)->differential_0 = _S318; + FixedArray _S320 = dist_coeffs_15; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S321 = s_fwd_DistOpenCV_distort_0(&_S319, &_S320); + float2 _S322 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S323; + (&_S323)->primal_0 = uv_18; + (&_S323)->differential_0 = _S322; + FixedArray _S324 = dist_coeffs_15; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S325 = s_fwd_DistOpenCV_distort_0(&_S323, &_S324); + Matrix _S326 = transpose_1(makeMatrix (_S321.differential_0, _S325.differential_0)); + float _S327 = (F32_min((determinant_0(_S326)), ((F32_min((_S326.rows[int(0)].x), (_S326.rows[int(1)].y)))))); + bool _S328; + if(_S327 > 0.25f) { - int3 _S363 = make_int3 (int(0)); - float3 _S364 = make_float3 ((float)_S363.x, (float)_S363.y, (float)_S363.z); - *raydir_2 = _S364; - return false; - } - if(camera_model_3 == int(1)) - { - float r_12 = length_0(_S357); - if(r_12 >= 3.14159274101257324f) - { - int3 _S365 = make_int3 (int(0)); - float3 _S366 = make_float3 ((float)_S365.x, (float)_S365.y, (float)_S365.z); - *raydir_2 = _S366; - return false; - } - float s_2; - if(r_12 < 0.00100000004749745f) - { - s_2 = 1.0f - r_12 * r_12 / 6.0f; - } - else - { - s_2 = (F32_sin((r_12))) / r_12; - } - *raydir_2 = make_float3 ((_S357 * make_float2 (s_2)).x, (_S357 * make_float2 (s_2)).y, (F32_cos((r_12)))); + _S328 = _S327 < 4.0f; } else { - if(camera_model_3 == int(2)) + _S328 = false; + } + if(_S328) + { + FixedArray _S329 = dist_coeffs_15; + float2 _S330 = DistOpenCV_distort_0(uv_18, &_S329); + _S328 = (dot_0(uv_18, _S330)) >= 0.0f; + } + else + { + _S328 = false; + } + return _S328; +} + +inline __device__ bool persp_proj_nav_opencv(float3 p_view_8, float4 intrins_8, FixedArray dist_coeffs_16, float2 * uv_19) +{ + bool _S331; + for(;;) + { + float2 _S332 = float2 {p_view_8.x, p_view_8.y}; + float _S333 = p_view_8.z; + float2 uv0_1 = _S332 / make_float2 (_S333); + if(_S333 < 0.0f) { - float r_13 = length_0(_S357); - if(r_13 >= 2.0f) - { - int3 _S367 = make_int3 (int(0)); - float3 _S368 = make_float3 ((float)_S367.x, (float)_S367.y, (float)_S367.z); - *raydir_2 = _S368; - return false; - } - *raydir_2 = make_float3 ((_S357 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_13 * r_13)))))))).x, (_S357 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_13 * r_13)))))))).y, 1.0f - 0.5f * r_13 * r_13); + _S331 = true; } else { - *raydir_2 = make_float3 (_S357.x, _S357.y, 1.0f); + float2 _S334 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S335; + (&_S335)->primal_0 = uv0_1; + (&_S335)->differential_0 = _S334; + FixedArray _S336 = dist_coeffs_16; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S337 = s_fwd_DistOpenCV_distort_0(&_S335, &_S336); + float2 _S338 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S339; + (&_S339)->primal_0 = uv0_1; + (&_S339)->differential_0 = _S338; + FixedArray _S340 = dist_coeffs_16; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S341 = s_fwd_DistOpenCV_distort_0(&_S339, &_S340); + Matrix _S342 = transpose_1(makeMatrix (_S337.differential_0, _S341.differential_0)); + float _S343 = (F32_min((determinant_0(_S342)), ((F32_min((_S342.rows[int(0)].x), (_S342.rows[int(1)].y)))))); + if(_S343 > 0.25f) + { + _S331 = _S343 < 4.0f; + } + else + { + _S331 = false; + } + if(_S331) + { + FixedArray _S344 = dist_coeffs_16; + float2 _S345 = DistOpenCV_distort_0(uv0_1, &_S344); + _S331 = (dot_0(uv0_1, _S345)) >= 0.0f; + } + else + { + _S331 = false; + } + _S331 = !_S331; } + if(_S331) + { + *uv_19 = uv0_1; + _S331 = false; + break; + } + float2 uv_20 = _S332 / make_float2 (_S333); + FixedArray _S346 = dist_coeffs_16; + float2 _S347 = DistOpenCV_distort_0(uv_20, &_S346); + *uv_19 = make_float2 (intrins_8.x * _S347.x + intrins_8.z, intrins_8.y * _S347.y + intrins_8.w); + _S331 = true; + break; } - *raydir_2 = normalize_0(*raydir_2); - return true; + return _S331; +} + +inline __device__ bool fisheye_proj_nav_opencv(float3 p_view_9, float4 intrins_9, FixedArray dist_coeffs_17, float2 * uv_21) +{ + bool _S348; + for(;;) + { + float2 _S349 = float2 {p_view_9.x, p_view_9.y}; + float r_16 = length_0(_S349); + float _S350 = p_view_9.z; + float theta_4 = (F32_atan2((r_16), (_S350))); + bool _S351 = theta_4 < 0.00100000004749745f; + float k_5; + if(_S351) + { + k_5 = (1.0f - theta_4 * theta_4 / 3.0f) / _S350; + } + else + { + k_5 = theta_4 / r_16; + } + float2 _S352 = _S349 * make_float2 (k_5); + float2 _S353 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S354; + (&_S354)->primal_0 = _S352; + (&_S354)->differential_0 = _S353; + FixedArray _S355 = dist_coeffs_17; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S356 = s_fwd_DistOpenCV_distort_0(&_S354, &_S355); + float2 _S357 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S358; + (&_S358)->primal_0 = _S352; + (&_S358)->differential_0 = _S357; + FixedArray _S359 = dist_coeffs_17; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S360 = s_fwd_DistOpenCV_distort_0(&_S358, &_S359); + Matrix _S361 = transpose_1(makeMatrix (_S356.differential_0, _S360.differential_0)); + float _S362 = (F32_min((determinant_0(_S361)), ((F32_min((_S361.rows[int(0)].x), (_S361.rows[int(1)].y)))))); + if(_S362 > 0.25f) + { + _S348 = _S362 < 4.0f; + } + else + { + _S348 = false; + } + if(_S348) + { + FixedArray _S363 = dist_coeffs_17; + float2 _S364 = DistOpenCV_distort_0(_S352, &_S363); + _S348 = (dot_0(_S352, _S364)) >= 0.0f; + } + else + { + _S348 = false; + } + if(!_S348) + { + *uv_21 = _S352; + _S348 = false; + break; + } + if(_S351) + { + k_5 = (1.0f - theta_4 * theta_4 / 3.0f) / _S350; + } + else + { + k_5 = theta_4 / r_16; + } + float2 _S365 = _S349 * make_float2 (k_5); + FixedArray _S366 = dist_coeffs_17; + float2 _S367 = DistOpenCV_distort_0(_S365, &_S366); + *uv_21 = make_float2 (intrins_9.x * _S367.x + intrins_9.z, intrins_9.y * _S367.y + intrins_9.w); + _S348 = true; + break; + } + return _S348; +} + +inline __device__ bool equisolid_proj_nav_opencv(float3 p_view_10, float4 intrins_10, FixedArray dist_coeffs_18, float2 * uv_22) +{ + bool _S368; + for(;;) + { + float2 _S369 = float2 {p_view_10.x, p_view_10.y}; + float r_17 = length_0(_S369); + float _S370 = p_view_10.z; + float theta_5 = (F32_atan2((r_17), (_S370))); + bool _S371 = r_17 < 9.99999997475242708e-07f; + float k_6; + if(_S371) + { + k_6 = (1.0f - theta_5 * theta_5 / 24.0f) / _S370; + } + else + { + k_6 = 2.0f * (F32_sin((0.5f * theta_5))) / r_17; + } + float2 _S372 = _S369 * make_float2 (k_6); + float2 _S373 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S374; + (&_S374)->primal_0 = _S372; + (&_S374)->differential_0 = _S373; + FixedArray _S375 = dist_coeffs_18; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S376 = s_fwd_DistOpenCV_distort_0(&_S374, &_S375); + float2 _S377 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S378; + (&_S378)->primal_0 = _S372; + (&_S378)->differential_0 = _S377; + FixedArray _S379 = dist_coeffs_18; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S380 = s_fwd_DistOpenCV_distort_0(&_S378, &_S379); + Matrix _S381 = transpose_1(makeMatrix (_S376.differential_0, _S380.differential_0)); + float _S382 = (F32_min((determinant_0(_S381)), ((F32_min((_S381.rows[int(0)].x), (_S381.rows[int(1)].y)))))); + if(_S382 > 0.25f) + { + _S368 = _S382 < 4.0f; + } + else + { + _S368 = false; + } + if(_S368) + { + FixedArray _S383 = dist_coeffs_18; + float2 _S384 = DistOpenCV_distort_0(_S372, &_S383); + _S368 = (dot_0(_S372, _S384)) >= 0.0f; + } + else + { + _S368 = false; + } + if(!_S368) + { + *uv_22 = _S372; + _S368 = false; + break; + } + if(_S371) + { + k_6 = (1.0f - theta_5 * theta_5 / 24.0f) / _S370; + } + else + { + k_6 = 2.0f * (F32_sin((0.5f * theta_5))) / r_17; + } + float2 _S385 = _S369 * make_float2 (k_6); + FixedArray _S386 = dist_coeffs_18; + float2 _S387 = DistOpenCV_distort_0(_S385, &_S386); + *uv_22 = make_float2 (intrins_10.x * _S387.x + intrins_10.z, intrins_10.y * _S387.y + intrins_10.w); + _S368 = true; + break; + } + return _S368; +} + +inline __device__ Matrix persp_proj_jac_opencv(float3 p_view_11, float4 intrins_11, FixedArray dist_coeffs_19) +{ + float2 _S388 = float2 {p_view_11.x, p_view_11.y}; + float _S389 = p_view_11.z; + float2 _S390 = _S388 * make_float2 (0.0f); + float _S391 = _S389 * _S389; + float2 s_diff_uv_3 = (make_float2 (1.0f, 0.0f) * make_float2 (_S389) - _S390) / make_float2 (_S391); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S392; + (&_S392)->primal_0 = _S388 / make_float2 (_S389); + (&_S392)->differential_0 = s_diff_uv_3; + FixedArray _S393 = dist_coeffs_19; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S394 = s_fwd_DistOpenCV_distort_0(&_S392, &_S393); + float fx_4 = intrins_11.x; + float fy_4 = intrins_11.y; + float _S395 = _S394.differential_0.y * fy_4; + Matrix J_4; + *&(((&J_4)->rows + (int(0)))->x) = _S394.differential_0.x * fx_4; + *&(((&J_4)->rows + (int(1)))->x) = _S395; + float2 s_diff_uv_4 = (make_float2 (0.0f, 1.0f) * make_float2 (_S389) - _S390) / make_float2 (_S391); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S396; + (&_S396)->primal_0 = _S388 / make_float2 (_S389); + (&_S396)->differential_0 = s_diff_uv_4; + FixedArray _S397 = dist_coeffs_19; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S398 = s_fwd_DistOpenCV_distort_0(&_S396, &_S397); + float _S399 = _S398.differential_0.y * fy_4; + *&(((&J_4)->rows + (int(0)))->y) = _S398.differential_0.x * fx_4; + *&(((&J_4)->rows + (int(1)))->y) = _S399; + float2 s_diff_uv_5 = (make_float2 (0.0f, 0.0f) * make_float2 (_S389) - _S388) / make_float2 (_S391); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S400; + (&_S400)->primal_0 = _S388 / make_float2 (_S389); + (&_S400)->differential_0 = s_diff_uv_5; + FixedArray _S401 = dist_coeffs_19; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S402 = s_fwd_DistOpenCV_distort_0(&_S400, &_S401); + float _S403 = _S402.differential_0.y * fy_4; + *&(((&J_4)->rows + (int(0)))->z) = _S402.differential_0.x * fx_4; + *&(((&J_4)->rows + (int(1)))->z) = _S403; + return J_4; +} + +inline __device__ Matrix fisheye_proj_jac_opencv(float3 p_view_12, float4 intrins_12, FixedArray dist_coeffs_20) +{ + Matrix J_5; + float2 _S404 = float2 {p_view_12.x, p_view_12.y}; + float2 _S405 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S406; + (&_S406)->primal_0 = _S404; + (&_S406)->differential_0 = _S405; + DiffPair_float_0 _S407 = s_fwd_length_impl_0(&_S406); + float _S408 = p_view_12.z; + DiffPair_float_0 _S409; + (&_S409)->primal_0 = _S407.primal_0; + (&_S409)->differential_0 = _S407.differential_0; + DiffPair_float_0 _S410; + (&_S410)->primal_0 = _S408; + (&_S410)->differential_0 = 0.0f; + DiffPair_float_0 _S411 = _d_atan2_0(&_S409, &_S410); + float k_7; + float s_diff_k_2; + if((_S411.primal_0) < 0.00100000004749745f) + { + float _S412 = _S411.differential_0 * _S411.primal_0; + float _S413 = 1.0f - _S411.primal_0 * _S411.primal_0 / 3.0f; + float _S414 = ((0.0f - (_S412 + _S412) * 0.3333333432674408f) * _S408 - _S413 * 0.0f) / (_S408 * _S408); + k_7 = _S413 / _S408; + s_diff_k_2 = _S414; + } + else + { + float _S415 = (_S411.differential_0 * _S407.primal_0 - _S411.primal_0 * _S407.differential_0) / (_S407.primal_0 * _S407.primal_0); + k_7 = _S411.primal_0 / _S407.primal_0; + s_diff_k_2 = _S415; + } + float2 _S416 = _S404 * make_float2 (k_7); + float2 _S417 = _S405 * make_float2 (k_7) + make_float2 (s_diff_k_2) * _S404; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S418; + (&_S418)->primal_0 = _S416; + (&_S418)->differential_0 = _S417; + FixedArray _S419 = dist_coeffs_20; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S420 = s_fwd_DistOpenCV_distort_0(&_S418, &_S419); + float fx_5 = intrins_12.x; + float fy_5 = intrins_12.y; + float _S421 = _S420.differential_0.y * fy_5; + *&(((&J_5)->rows + (int(0)))->x) = _S420.differential_0.x * fx_5; + *&(((&J_5)->rows + (int(1)))->x) = _S421; + float2 _S422 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S423; + (&_S423)->primal_0 = _S404; + (&_S423)->differential_0 = _S422; + DiffPair_float_0 _S424 = s_fwd_length_impl_0(&_S423); + DiffPair_float_0 _S425; + (&_S425)->primal_0 = _S424.primal_0; + (&_S425)->differential_0 = _S424.differential_0; + DiffPair_float_0 _S426; + (&_S426)->primal_0 = _S408; + (&_S426)->differential_0 = 0.0f; + DiffPair_float_0 _S427 = _d_atan2_0(&_S425, &_S426); + if((_S427.primal_0) < 0.00100000004749745f) + { + float _S428 = _S427.differential_0 * _S427.primal_0; + float _S429 = 1.0f - _S427.primal_0 * _S427.primal_0 / 3.0f; + float _S430 = ((0.0f - (_S428 + _S428) * 0.3333333432674408f) * _S408 - _S429 * 0.0f) / (_S408 * _S408); + k_7 = _S429 / _S408; + s_diff_k_2 = _S430; + } + else + { + float _S431 = (_S427.differential_0 * _S424.primal_0 - _S427.primal_0 * _S424.differential_0) / (_S424.primal_0 * _S424.primal_0); + k_7 = _S427.primal_0 / _S424.primal_0; + s_diff_k_2 = _S431; + } + float2 _S432 = _S404 * make_float2 (k_7); + float2 _S433 = _S422 * make_float2 (k_7) + make_float2 (s_diff_k_2) * _S404; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S434; + (&_S434)->primal_0 = _S432; + (&_S434)->differential_0 = _S433; + FixedArray _S435 = dist_coeffs_20; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S436 = s_fwd_DistOpenCV_distort_0(&_S434, &_S435); + float _S437 = _S436.differential_0.y * fy_5; + *&(((&J_5)->rows + (int(0)))->y) = _S436.differential_0.x * fx_5; + *&(((&J_5)->rows + (int(1)))->y) = _S437; + float2 _S438 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S439; + (&_S439)->primal_0 = _S404; + (&_S439)->differential_0 = _S438; + DiffPair_float_0 _S440 = s_fwd_length_impl_0(&_S439); + DiffPair_float_0 _S441; + (&_S441)->primal_0 = _S440.primal_0; + (&_S441)->differential_0 = _S440.differential_0; + DiffPair_float_0 _S442; + (&_S442)->primal_0 = _S408; + (&_S442)->differential_0 = 1.0f; + DiffPair_float_0 _S443 = _d_atan2_0(&_S441, &_S442); + if((_S443.primal_0) < 0.00100000004749745f) + { + float _S444 = _S443.differential_0 * _S443.primal_0; + float _S445 = 1.0f - _S443.primal_0 * _S443.primal_0 / 3.0f; + float _S446 = ((0.0f - (_S444 + _S444) * 0.3333333432674408f) * _S408 - _S445) / (_S408 * _S408); + k_7 = _S445 / _S408; + s_diff_k_2 = _S446; + } + else + { + float _S447 = (_S443.differential_0 * _S440.primal_0 - _S443.primal_0 * _S440.differential_0) / (_S440.primal_0 * _S440.primal_0); + k_7 = _S443.primal_0 / _S440.primal_0; + s_diff_k_2 = _S447; + } + float2 _S448 = _S404 * make_float2 (k_7); + float2 _S449 = _S438 * make_float2 (k_7) + make_float2 (s_diff_k_2) * _S404; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S450; + (&_S450)->primal_0 = _S448; + (&_S450)->differential_0 = _S449; + FixedArray _S451 = dist_coeffs_20; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S452 = s_fwd_DistOpenCV_distort_0(&_S450, &_S451); + float _S453 = _S452.differential_0.y * fy_5; + *&(((&J_5)->rows + (int(0)))->z) = _S452.differential_0.x * fx_5; + *&(((&J_5)->rows + (int(1)))->z) = _S453; + return J_5; +} + +inline __device__ Matrix equisolid_proj_jac_opencv(float3 p_view_13, float4 intrins_13, FixedArray dist_coeffs_21) +{ + Matrix J_6; + float2 _S454 = float2 {p_view_13.x, p_view_13.y}; + float2 _S455 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S456; + (&_S456)->primal_0 = _S454; + (&_S456)->differential_0 = _S455; + DiffPair_float_0 _S457 = s_fwd_length_impl_0(&_S456); + float _S458 = p_view_13.z; + DiffPair_float_0 _S459; + (&_S459)->primal_0 = _S457.primal_0; + (&_S459)->differential_0 = _S457.differential_0; + DiffPair_float_0 _S460; + (&_S460)->primal_0 = _S458; + (&_S460)->differential_0 = 0.0f; + DiffPair_float_0 _S461 = _d_atan2_0(&_S459, &_S460); + float k_8; + float s_diff_k_3; + if((_S457.primal_0) < 9.99999997475242708e-07f) + { + float _S462 = _S461.differential_0 * _S461.primal_0; + float _S463 = 1.0f - _S461.primal_0 * _S461.primal_0 / 24.0f; + float _S464 = ((0.0f - (_S462 + _S462) * 0.0416666679084301f) * _S458 - _S463 * 0.0f) / (_S458 * _S458); + k_8 = _S463 / _S458; + s_diff_k_3 = _S464; + } + else + { + float _S465 = _S461.differential_0 * 0.5f; + DiffPair_float_0 _S466; + (&_S466)->primal_0 = 0.5f * _S461.primal_0; + (&_S466)->differential_0 = _S465; + DiffPair_float_0 _S467 = _d_sin_0(&_S466); + float _S468 = 2.0f * _S467.primal_0; + float _S469 = (_S467.differential_0 * 2.0f * _S457.primal_0 - _S468 * _S457.differential_0) / (_S457.primal_0 * _S457.primal_0); + k_8 = _S468 / _S457.primal_0; + s_diff_k_3 = _S469; + } + float2 _S470 = _S454 * make_float2 (k_8); + float2 _S471 = _S455 * make_float2 (k_8) + make_float2 (s_diff_k_3) * _S454; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S472; + (&_S472)->primal_0 = _S470; + (&_S472)->differential_0 = _S471; + FixedArray _S473 = dist_coeffs_21; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S474 = s_fwd_DistOpenCV_distort_0(&_S472, &_S473); + float fx_6 = intrins_13.x; + float fy_6 = intrins_13.y; + float _S475 = _S474.differential_0.y * fy_6; + *&(((&J_6)->rows + (int(0)))->x) = _S474.differential_0.x * fx_6; + *&(((&J_6)->rows + (int(1)))->x) = _S475; + float2 _S476 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S477; + (&_S477)->primal_0 = _S454; + (&_S477)->differential_0 = _S476; + DiffPair_float_0 _S478 = s_fwd_length_impl_0(&_S477); + DiffPair_float_0 _S479; + (&_S479)->primal_0 = _S478.primal_0; + (&_S479)->differential_0 = _S478.differential_0; + DiffPair_float_0 _S480; + (&_S480)->primal_0 = _S458; + (&_S480)->differential_0 = 0.0f; + DiffPair_float_0 _S481 = _d_atan2_0(&_S479, &_S480); + if((_S478.primal_0) < 9.99999997475242708e-07f) + { + float _S482 = _S481.differential_0 * _S481.primal_0; + float _S483 = 1.0f - _S481.primal_0 * _S481.primal_0 / 24.0f; + float _S484 = ((0.0f - (_S482 + _S482) * 0.0416666679084301f) * _S458 - _S483 * 0.0f) / (_S458 * _S458); + k_8 = _S483 / _S458; + s_diff_k_3 = _S484; + } + else + { + float _S485 = _S481.differential_0 * 0.5f; + DiffPair_float_0 _S486; + (&_S486)->primal_0 = 0.5f * _S481.primal_0; + (&_S486)->differential_0 = _S485; + DiffPair_float_0 _S487 = _d_sin_0(&_S486); + float _S488 = 2.0f * _S487.primal_0; + float _S489 = (_S487.differential_0 * 2.0f * _S478.primal_0 - _S488 * _S478.differential_0) / (_S478.primal_0 * _S478.primal_0); + k_8 = _S488 / _S478.primal_0; + s_diff_k_3 = _S489; + } + float2 _S490 = _S454 * make_float2 (k_8); + float2 _S491 = _S476 * make_float2 (k_8) + make_float2 (s_diff_k_3) * _S454; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S492; + (&_S492)->primal_0 = _S490; + (&_S492)->differential_0 = _S491; + FixedArray _S493 = dist_coeffs_21; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S494 = s_fwd_DistOpenCV_distort_0(&_S492, &_S493); + float _S495 = _S494.differential_0.y * fy_6; + *&(((&J_6)->rows + (int(0)))->y) = _S494.differential_0.x * fx_6; + *&(((&J_6)->rows + (int(1)))->y) = _S495; + float2 _S496 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S497; + (&_S497)->primal_0 = _S454; + (&_S497)->differential_0 = _S496; + DiffPair_float_0 _S498 = s_fwd_length_impl_0(&_S497); + DiffPair_float_0 _S499; + (&_S499)->primal_0 = _S498.primal_0; + (&_S499)->differential_0 = _S498.differential_0; + DiffPair_float_0 _S500; + (&_S500)->primal_0 = _S458; + (&_S500)->differential_0 = 1.0f; + DiffPair_float_0 _S501 = _d_atan2_0(&_S499, &_S500); + if((_S498.primal_0) < 9.99999997475242708e-07f) + { + float _S502 = _S501.differential_0 * _S501.primal_0; + float _S503 = 1.0f - _S501.primal_0 * _S501.primal_0 / 24.0f; + float _S504 = ((0.0f - (_S502 + _S502) * 0.0416666679084301f) * _S458 - _S503) / (_S458 * _S458); + k_8 = _S503 / _S458; + s_diff_k_3 = _S504; + } + else + { + float _S505 = _S501.differential_0 * 0.5f; + DiffPair_float_0 _S506; + (&_S506)->primal_0 = 0.5f * _S501.primal_0; + (&_S506)->differential_0 = _S505; + DiffPair_float_0 _S507 = _d_sin_0(&_S506); + float _S508 = 2.0f * _S507.primal_0; + float _S509 = (_S507.differential_0 * 2.0f * _S498.primal_0 - _S508 * _S498.differential_0) / (_S498.primal_0 * _S498.primal_0); + k_8 = _S508 / _S498.primal_0; + s_diff_k_3 = _S509; + } + float2 _S510 = _S454 * make_float2 (k_8); + float2 _S511 = _S496 * make_float2 (k_8) + make_float2 (s_diff_k_3) * _S454; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S512; + (&_S512)->primal_0 = _S510; + (&_S512)->differential_0 = _S511; + FixedArray _S513 = dist_coeffs_21; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S514 = s_fwd_DistOpenCV_distort_0(&_S512, &_S513); + float _S515 = _S514.differential_0.y * fy_6; + *&(((&J_6)->rows + (int(0)))->z) = _S514.differential_0.x * fx_6; + *&(((&J_6)->rows + (int(1)))->z) = _S515; + return J_6; +} + +inline __device__ float2 distort_point_opencv(float2 uv_23, int camera_model_4, FixedArray dist_coeffs_22) +{ + float2 _S516; + for(;;) + { + if(camera_model_4 == int(3)) + { + _S516 = uv_23; + break; + } + float k_9; + if(camera_model_4 == int(1)) + { + float r_18 = length_0(uv_23); + float theta_6 = (F32_atan((r_18))); + if(r_18 < 0.00100000004749745f) + { + k_9 = 1.0f - theta_6 * theta_6 / 6.0f; + } + else + { + k_9 = theta_6 / r_18; + } + _S516 = uv_23 * make_float2 (k_9); + } + else + { + if(camera_model_4 == int(2)) + { + float r_19 = length_0(uv_23); + float theta_7 = (F32_atan((r_19))); + if(r_19 < 0.00100000004749745f) + { + k_9 = 1.0f - theta_7 * theta_7 / 24.0f; + } + else + { + k_9 = 2.0f * (F32_sin((0.5f * theta_7))) / r_19; + } + _S516 = uv_23 * make_float2 (k_9); + } + else + { + _S516 = uv_23; + } + } + FixedArray _S517 = dist_coeffs_22; + float2 _S518 = DistOpenCV_distort_0(_S516, &_S517); + _S516 = _S518; + break; + } + return _S516; +} + +inline __device__ bool undistort_point_opencv(float2 uv_24, int camera_model_5, FixedArray dist_coeffs_23, float2 * uv_undist_5) +{ + bool _S519; + for(;;) + { + *uv_undist_5 = make_float2 (0.0f); + if(camera_model_5 == int(3)) + { + float lon_2 = uv_24.x; + float lat_3 = uv_24.y; + float cl_3 = (F32_cos((lat_3))); + *uv_undist_5 = make_float2 (cl_3 * (F32_sin((lon_2))), (F32_sin((lat_3)))) / make_float2 ((F32_max((cl_3 * (F32_cos((lon_2)))), (9.999999960041972e-13f)))); + _S519 = true; + break; + } + FixedArray _S520 = dist_coeffs_23; + float2 uv_u_3; + bool _S521 = undistort_point_1(uv_24, &_S520, int(8), &uv_u_3); + if(!_S521) + { + _S519 = false; + break; + } + float2 _S522 = uv_u_3; + float3 raydir_3; + if(camera_model_5 == int(1)) + { + float r_20 = length_0(_S522); + float s_3; + if(r_20 < 0.00100000004749745f) + { + s_3 = 1.0f - r_20 * r_20 / 6.0f; + } + else + { + s_3 = (F32_sin((r_20))) / r_20; + } + raydir_3 = make_float3 ((_S522 * make_float2 (s_3)).x, (_S522 * make_float2 (s_3)).y, (F32_cos((r_20)))); + } + else + { + if(camera_model_5 == int(2)) + { + float r_21 = length_0(_S522); + raydir_3 = make_float3 ((_S522 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_21 * r_21)))))))).x, (_S522 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_21 * r_21)))))))).y, 1.0f - 0.5f * r_21 * r_21); + } + else + { + raydir_3 = make_float3 (_S522.x, _S522.y, 1.0f); + } + } + *uv_undist_5 = float2 {raydir_3.x, raydir_3.y} / make_float2 ((F32_max((raydir_3.z), (9.999999960041972e-13f)))); + _S519 = true; + break; + } + return _S519; +} + +inline __device__ bool unproject_point_opencv(float2 uv_25, int camera_model_6, FixedArray dist_coeffs_24, float3 * raydir_4) +{ + bool _S523; + for(;;) + { + int3 _S524 = make_int3 (int(0)); + float3 _S525 = make_float3 ((float)_S524.x, (float)_S524.y, (float)_S524.z); + *raydir_4 = _S525; + if(camera_model_6 == int(3)) + { + float lon_3 = uv_25.x; + float lat_4 = uv_25.y; + float cl_4 = (F32_cos((lat_4))); + *raydir_4 = make_float3 (cl_4 * (F32_sin((lon_3))), (F32_sin((lat_4))), cl_4 * (F32_cos((lon_3)))); + _S523 = true; + break; + } + FixedArray _S526 = dist_coeffs_24; + float2 uv_u_4; + bool _S527 = undistort_point_1(uv_25, &_S526, int(8), &uv_u_4); + if(!_S527) + { + _S523 = false; + break; + } + float2 _S528 = uv_u_4; + if(camera_model_6 == int(1)) + { + float r_22 = length_0(_S528); + float s_4; + if(r_22 < 0.00100000004749745f) + { + s_4 = 1.0f - r_22 * r_22 / 6.0f; + } + else + { + s_4 = (F32_sin((r_22))) / r_22; + } + *raydir_4 = make_float3 ((_S528 * make_float2 (s_4)).x, (_S528 * make_float2 (s_4)).y, (F32_cos((r_22)))); + } + else + { + if(camera_model_6 == int(2)) + { + float r_23 = length_0(_S528); + *raydir_4 = make_float3 ((_S528 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_23 * r_23)))))))).x, (_S528 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_23 * r_23)))))))).y, 1.0f - 0.5f * r_23 * r_23); + } + else + { + *raydir_4 = make_float3 (_S528.x, _S528.y, 1.0f); + } + } + _S523 = true; + break; + } + return _S523; +} + +inline __device__ bool generate_ray_opencv(float2 uv_26, int camera_model_7, FixedArray dist_coeffs_25, float3 * raydir_5) +{ + bool _S529; + for(;;) + { + if(camera_model_7 == int(3)) + { + float _S530 = uv_26.x; + if((F32_abs((_S530))) > 3.14159274101257324f) + { + _S529 = true; + } + else + { + _S529 = (F32_abs((uv_26.y))) > 1.57079637050628662f; + } + if(_S529) + { + int3 _S531 = make_int3 (int(0)); + float3 _S532 = make_float3 ((float)_S531.x, (float)_S531.y, (float)_S531.z); + *raydir_5 = _S532; + _S529 = false; + break; + } + float lat_5 = uv_26.y; + float cl_5 = (F32_cos((lat_5))); + *raydir_5 = make_float3 (cl_5 * (F32_sin((_S530))), (F32_sin((lat_5))), cl_5 * (F32_cos((_S530)))); + _S529 = true; + break; + } + FixedArray _S533 = dist_coeffs_25; + float2 uv_u_5; + bool _S534 = undistort_point_1(uv_26, &_S533, int(8), &uv_u_5); + if(!_S534) + { + int3 _S535 = make_int3 (int(0)); + float3 _S536 = make_float3 ((float)_S535.x, (float)_S535.y, (float)_S535.z); + *raydir_5 = _S536; + _S529 = false; + break; + } + float2 _S537 = uv_u_5; + if(camera_model_7 == int(1)) + { + float r_24 = length_0(_S537); + if(r_24 >= 3.14159274101257324f) + { + int3 _S538 = make_int3 (int(0)); + float3 _S539 = make_float3 ((float)_S538.x, (float)_S538.y, (float)_S538.z); + *raydir_5 = _S539; + _S529 = false; + break; + } + float s_5; + if(r_24 < 0.00100000004749745f) + { + s_5 = 1.0f - r_24 * r_24 / 6.0f; + } + else + { + s_5 = (F32_sin((r_24))) / r_24; + } + *raydir_5 = make_float3 ((_S537 * make_float2 (s_5)).x, (_S537 * make_float2 (s_5)).y, (F32_cos((r_24)))); + } + else + { + if(camera_model_7 == int(2)) + { + float r_25 = length_0(_S537); + if(r_25 >= 2.0f) + { + int3 _S540 = make_int3 (int(0)); + float3 _S541 = make_float3 ((float)_S540.x, (float)_S540.y, (float)_S540.z); + *raydir_5 = _S541; + _S529 = false; + break; + } + *raydir_5 = make_float3 ((_S537 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_25 * r_25)))))))).x, (_S537 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_25 * r_25)))))))).y, 1.0f - 0.5f * r_25 * r_25); + } + else + { + *raydir_5 = make_float3 (_S537.x, _S537.y, 1.0f); + } + } + *raydir_5 = normalize_0(*raydir_5); + _S529 = true; + break; + } + return _S529; +} + +inline __device__ bool is_valid_distortion_prism(float2 uv_27, FixedArray dist_coeffs_26) +{ + float2 _S542 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S543; + (&_S543)->primal_0 = uv_27; + (&_S543)->differential_0 = _S542; + FixedArray _S544 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S545 = s_fwd_DistThinPrism_distort_0(&_S543, &_S544); + float2 _S546 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S547; + (&_S547)->primal_0 = uv_27; + (&_S547)->differential_0 = _S546; + FixedArray _S548 = dist_coeffs_26; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S549 = s_fwd_DistThinPrism_distort_0(&_S547, &_S548); + Matrix _S550 = transpose_1(makeMatrix (_S545.differential_0, _S549.differential_0)); + float _S551 = (F32_min((determinant_0(_S550)), ((F32_min((_S550.rows[int(0)].x), (_S550.rows[int(1)].y)))))); + bool _S552; + if(_S551 > 0.25f) + { + _S552 = _S551 < 4.0f; + } + else + { + _S552 = false; + } + if(_S552) + { + FixedArray _S553 = dist_coeffs_26; + float2 _S554 = DistThinPrism_distort_0(uv_27, &_S553); + _S552 = (dot_0(uv_27, _S554)) >= 0.0f; + } + else + { + _S552 = false; + } + return _S552; +} + +inline __device__ bool persp_proj_nav_prism(float3 p_view_14, float4 intrins_14, FixedArray dist_coeffs_27, float2 * uv_28) +{ + bool _S555; + for(;;) + { + float2 _S556 = float2 {p_view_14.x, p_view_14.y}; + float _S557 = p_view_14.z; + float2 uv0_2 = _S556 / make_float2 (_S557); + if(_S557 < 0.0f) + { + _S555 = true; + } + else + { + float2 _S558 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S559; + (&_S559)->primal_0 = uv0_2; + (&_S559)->differential_0 = _S558; + FixedArray _S560 = dist_coeffs_27; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S561 = s_fwd_DistThinPrism_distort_0(&_S559, &_S560); + float2 _S562 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S563; + (&_S563)->primal_0 = uv0_2; + (&_S563)->differential_0 = _S562; + FixedArray _S564 = dist_coeffs_27; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S565 = s_fwd_DistThinPrism_distort_0(&_S563, &_S564); + Matrix _S566 = transpose_1(makeMatrix (_S561.differential_0, _S565.differential_0)); + float _S567 = (F32_min((determinant_0(_S566)), ((F32_min((_S566.rows[int(0)].x), (_S566.rows[int(1)].y)))))); + if(_S567 > 0.25f) + { + _S555 = _S567 < 4.0f; + } + else + { + _S555 = false; + } + if(_S555) + { + FixedArray _S568 = dist_coeffs_27; + float2 _S569 = DistThinPrism_distort_0(uv0_2, &_S568); + _S555 = (dot_0(uv0_2, _S569)) >= 0.0f; + } + else + { + _S555 = false; + } + _S555 = !_S555; + } + if(_S555) + { + *uv_28 = uv0_2; + _S555 = false; + break; + } + float2 uv_29 = _S556 / make_float2 (_S557); + FixedArray _S570 = dist_coeffs_27; + float2 _S571 = DistThinPrism_distort_0(uv_29, &_S570); + *uv_28 = make_float2 (intrins_14.x * _S571.x + intrins_14.z, intrins_14.y * _S571.y + intrins_14.w); + _S555 = true; + break; + } + return _S555; +} + +inline __device__ bool fisheye_proj_nav_prism(float3 p_view_15, float4 intrins_15, FixedArray dist_coeffs_28, float2 * uv_30) +{ + bool _S572; + for(;;) + { + float2 _S573 = float2 {p_view_15.x, p_view_15.y}; + float r_26 = length_0(_S573); + float _S574 = p_view_15.z; + float theta_8 = (F32_atan2((r_26), (_S574))); + bool _S575 = theta_8 < 0.00100000004749745f; + float k_10; + if(_S575) + { + k_10 = (1.0f - theta_8 * theta_8 / 3.0f) / _S574; + } + else + { + k_10 = theta_8 / r_26; + } + float2 _S576 = _S573 * make_float2 (k_10); + float2 _S577 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S578; + (&_S578)->primal_0 = _S576; + (&_S578)->differential_0 = _S577; + FixedArray _S579 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S580 = s_fwd_DistThinPrism_distort_0(&_S578, &_S579); + float2 _S581 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S582; + (&_S582)->primal_0 = _S576; + (&_S582)->differential_0 = _S581; + FixedArray _S583 = dist_coeffs_28; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S584 = s_fwd_DistThinPrism_distort_0(&_S582, &_S583); + Matrix _S585 = transpose_1(makeMatrix (_S580.differential_0, _S584.differential_0)); + float _S586 = (F32_min((determinant_0(_S585)), ((F32_min((_S585.rows[int(0)].x), (_S585.rows[int(1)].y)))))); + if(_S586 > 0.25f) + { + _S572 = _S586 < 4.0f; + } + else + { + _S572 = false; + } + if(_S572) + { + FixedArray _S587 = dist_coeffs_28; + float2 _S588 = DistThinPrism_distort_0(_S576, &_S587); + _S572 = (dot_0(_S576, _S588)) >= 0.0f; + } + else + { + _S572 = false; + } + if(!_S572) + { + *uv_30 = _S576; + _S572 = false; + break; + } + if(_S575) + { + k_10 = (1.0f - theta_8 * theta_8 / 3.0f) / _S574; + } + else + { + k_10 = theta_8 / r_26; + } + float2 _S589 = _S573 * make_float2 (k_10); + FixedArray _S590 = dist_coeffs_28; + float2 _S591 = DistThinPrism_distort_0(_S589, &_S590); + *uv_30 = make_float2 (intrins_15.x * _S591.x + intrins_15.z, intrins_15.y * _S591.y + intrins_15.w); + _S572 = true; + break; + } + return _S572; +} + +inline __device__ bool equisolid_proj_nav_prism(float3 p_view_16, float4 intrins_16, FixedArray dist_coeffs_29, float2 * uv_31) +{ + bool _S592; + for(;;) + { + float2 _S593 = float2 {p_view_16.x, p_view_16.y}; + float r_27 = length_0(_S593); + float _S594 = p_view_16.z; + float theta_9 = (F32_atan2((r_27), (_S594))); + bool _S595 = r_27 < 9.99999997475242708e-07f; + float k_11; + if(_S595) + { + k_11 = (1.0f - theta_9 * theta_9 / 24.0f) / _S594; + } + else + { + k_11 = 2.0f * (F32_sin((0.5f * theta_9))) / r_27; + } + float2 _S596 = _S593 * make_float2 (k_11); + float2 _S597 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S598; + (&_S598)->primal_0 = _S596; + (&_S598)->differential_0 = _S597; + FixedArray _S599 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S600 = s_fwd_DistThinPrism_distort_0(&_S598, &_S599); + float2 _S601 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S602; + (&_S602)->primal_0 = _S596; + (&_S602)->differential_0 = _S601; + FixedArray _S603 = dist_coeffs_29; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S604 = s_fwd_DistThinPrism_distort_0(&_S602, &_S603); + Matrix _S605 = transpose_1(makeMatrix (_S600.differential_0, _S604.differential_0)); + float _S606 = (F32_min((determinant_0(_S605)), ((F32_min((_S605.rows[int(0)].x), (_S605.rows[int(1)].y)))))); + if(_S606 > 0.25f) + { + _S592 = _S606 < 4.0f; + } + else + { + _S592 = false; + } + if(_S592) + { + FixedArray _S607 = dist_coeffs_29; + float2 _S608 = DistThinPrism_distort_0(_S596, &_S607); + _S592 = (dot_0(_S596, _S608)) >= 0.0f; + } + else + { + _S592 = false; + } + if(!_S592) + { + *uv_31 = _S596; + _S592 = false; + break; + } + if(_S595) + { + k_11 = (1.0f - theta_9 * theta_9 / 24.0f) / _S594; + } + else + { + k_11 = 2.0f * (F32_sin((0.5f * theta_9))) / r_27; + } + float2 _S609 = _S593 * make_float2 (k_11); + FixedArray _S610 = dist_coeffs_29; + float2 _S611 = DistThinPrism_distort_0(_S609, &_S610); + *uv_31 = make_float2 (intrins_16.x * _S611.x + intrins_16.z, intrins_16.y * _S611.y + intrins_16.w); + _S592 = true; + break; + } + return _S592; +} + +inline __device__ Matrix persp_proj_jac_prism(float3 p_view_17, float4 intrins_17, FixedArray dist_coeffs_30) +{ + float2 _S612 = float2 {p_view_17.x, p_view_17.y}; + float _S613 = p_view_17.z; + float2 _S614 = _S612 * make_float2 (0.0f); + float _S615 = _S613 * _S613; + float2 s_diff_uv_6 = (make_float2 (1.0f, 0.0f) * make_float2 (_S613) - _S614) / make_float2 (_S615); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S616; + (&_S616)->primal_0 = _S612 / make_float2 (_S613); + (&_S616)->differential_0 = s_diff_uv_6; + FixedArray _S617 = dist_coeffs_30; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S618 = s_fwd_DistThinPrism_distort_0(&_S616, &_S617); + float fx_7 = intrins_17.x; + float fy_7 = intrins_17.y; + float _S619 = _S618.differential_0.y * fy_7; + Matrix J_7; + *&(((&J_7)->rows + (int(0)))->x) = _S618.differential_0.x * fx_7; + *&(((&J_7)->rows + (int(1)))->x) = _S619; + float2 s_diff_uv_7 = (make_float2 (0.0f, 1.0f) * make_float2 (_S613) - _S614) / make_float2 (_S615); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S620; + (&_S620)->primal_0 = _S612 / make_float2 (_S613); + (&_S620)->differential_0 = s_diff_uv_7; + FixedArray _S621 = dist_coeffs_30; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S622 = s_fwd_DistThinPrism_distort_0(&_S620, &_S621); + float _S623 = _S622.differential_0.y * fy_7; + *&(((&J_7)->rows + (int(0)))->y) = _S622.differential_0.x * fx_7; + *&(((&J_7)->rows + (int(1)))->y) = _S623; + float2 s_diff_uv_8 = (make_float2 (0.0f, 0.0f) * make_float2 (_S613) - _S612) / make_float2 (_S615); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S624; + (&_S624)->primal_0 = _S612 / make_float2 (_S613); + (&_S624)->differential_0 = s_diff_uv_8; + FixedArray _S625 = dist_coeffs_30; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S626 = s_fwd_DistThinPrism_distort_0(&_S624, &_S625); + float _S627 = _S626.differential_0.y * fy_7; + *&(((&J_7)->rows + (int(0)))->z) = _S626.differential_0.x * fx_7; + *&(((&J_7)->rows + (int(1)))->z) = _S627; + return J_7; +} + +inline __device__ Matrix fisheye_proj_jac_prism(float3 p_view_18, float4 intrins_18, FixedArray dist_coeffs_31) +{ + Matrix J_8; + float2 _S628 = float2 {p_view_18.x, p_view_18.y}; + float2 _S629 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S630; + (&_S630)->primal_0 = _S628; + (&_S630)->differential_0 = _S629; + DiffPair_float_0 _S631 = s_fwd_length_impl_0(&_S630); + float _S632 = p_view_18.z; + DiffPair_float_0 _S633; + (&_S633)->primal_0 = _S631.primal_0; + (&_S633)->differential_0 = _S631.differential_0; + DiffPair_float_0 _S634; + (&_S634)->primal_0 = _S632; + (&_S634)->differential_0 = 0.0f; + DiffPair_float_0 _S635 = _d_atan2_0(&_S633, &_S634); + float k_12; + float s_diff_k_4; + if((_S635.primal_0) < 0.00100000004749745f) + { + float _S636 = _S635.differential_0 * _S635.primal_0; + float _S637 = 1.0f - _S635.primal_0 * _S635.primal_0 / 3.0f; + float _S638 = ((0.0f - (_S636 + _S636) * 0.3333333432674408f) * _S632 - _S637 * 0.0f) / (_S632 * _S632); + k_12 = _S637 / _S632; + s_diff_k_4 = _S638; + } + else + { + float _S639 = (_S635.differential_0 * _S631.primal_0 - _S635.primal_0 * _S631.differential_0) / (_S631.primal_0 * _S631.primal_0); + k_12 = _S635.primal_0 / _S631.primal_0; + s_diff_k_4 = _S639; + } + float2 _S640 = _S628 * make_float2 (k_12); + float2 _S641 = _S629 * make_float2 (k_12) + make_float2 (s_diff_k_4) * _S628; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S642; + (&_S642)->primal_0 = _S640; + (&_S642)->differential_0 = _S641; + FixedArray _S643 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S644 = s_fwd_DistThinPrism_distort_0(&_S642, &_S643); + float fx_8 = intrins_18.x; + float fy_8 = intrins_18.y; + float _S645 = _S644.differential_0.y * fy_8; + *&(((&J_8)->rows + (int(0)))->x) = _S644.differential_0.x * fx_8; + *&(((&J_8)->rows + (int(1)))->x) = _S645; + float2 _S646 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S647; + (&_S647)->primal_0 = _S628; + (&_S647)->differential_0 = _S646; + DiffPair_float_0 _S648 = s_fwd_length_impl_0(&_S647); + DiffPair_float_0 _S649; + (&_S649)->primal_0 = _S648.primal_0; + (&_S649)->differential_0 = _S648.differential_0; + DiffPair_float_0 _S650; + (&_S650)->primal_0 = _S632; + (&_S650)->differential_0 = 0.0f; + DiffPair_float_0 _S651 = _d_atan2_0(&_S649, &_S650); + if((_S651.primal_0) < 0.00100000004749745f) + { + float _S652 = _S651.differential_0 * _S651.primal_0; + float _S653 = 1.0f - _S651.primal_0 * _S651.primal_0 / 3.0f; + float _S654 = ((0.0f - (_S652 + _S652) * 0.3333333432674408f) * _S632 - _S653 * 0.0f) / (_S632 * _S632); + k_12 = _S653 / _S632; + s_diff_k_4 = _S654; + } + else + { + float _S655 = (_S651.differential_0 * _S648.primal_0 - _S651.primal_0 * _S648.differential_0) / (_S648.primal_0 * _S648.primal_0); + k_12 = _S651.primal_0 / _S648.primal_0; + s_diff_k_4 = _S655; + } + float2 _S656 = _S628 * make_float2 (k_12); + float2 _S657 = _S646 * make_float2 (k_12) + make_float2 (s_diff_k_4) * _S628; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S658; + (&_S658)->primal_0 = _S656; + (&_S658)->differential_0 = _S657; + FixedArray _S659 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S660 = s_fwd_DistThinPrism_distort_0(&_S658, &_S659); + float _S661 = _S660.differential_0.y * fy_8; + *&(((&J_8)->rows + (int(0)))->y) = _S660.differential_0.x * fx_8; + *&(((&J_8)->rows + (int(1)))->y) = _S661; + float2 _S662 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S663; + (&_S663)->primal_0 = _S628; + (&_S663)->differential_0 = _S662; + DiffPair_float_0 _S664 = s_fwd_length_impl_0(&_S663); + DiffPair_float_0 _S665; + (&_S665)->primal_0 = _S664.primal_0; + (&_S665)->differential_0 = _S664.differential_0; + DiffPair_float_0 _S666; + (&_S666)->primal_0 = _S632; + (&_S666)->differential_0 = 1.0f; + DiffPair_float_0 _S667 = _d_atan2_0(&_S665, &_S666); + if((_S667.primal_0) < 0.00100000004749745f) + { + float _S668 = _S667.differential_0 * _S667.primal_0; + float _S669 = 1.0f - _S667.primal_0 * _S667.primal_0 / 3.0f; + float _S670 = ((0.0f - (_S668 + _S668) * 0.3333333432674408f) * _S632 - _S669) / (_S632 * _S632); + k_12 = _S669 / _S632; + s_diff_k_4 = _S670; + } + else + { + float _S671 = (_S667.differential_0 * _S664.primal_0 - _S667.primal_0 * _S664.differential_0) / (_S664.primal_0 * _S664.primal_0); + k_12 = _S667.primal_0 / _S664.primal_0; + s_diff_k_4 = _S671; + } + float2 _S672 = _S628 * make_float2 (k_12); + float2 _S673 = _S662 * make_float2 (k_12) + make_float2 (s_diff_k_4) * _S628; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S674; + (&_S674)->primal_0 = _S672; + (&_S674)->differential_0 = _S673; + FixedArray _S675 = dist_coeffs_31; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S676 = s_fwd_DistThinPrism_distort_0(&_S674, &_S675); + float _S677 = _S676.differential_0.y * fy_8; + *&(((&J_8)->rows + (int(0)))->z) = _S676.differential_0.x * fx_8; + *&(((&J_8)->rows + (int(1)))->z) = _S677; + return J_8; +} + +inline __device__ Matrix equisolid_proj_jac_prism(float3 p_view_19, float4 intrins_19, FixedArray dist_coeffs_32) +{ + Matrix J_9; + float2 _S678 = float2 {p_view_19.x, p_view_19.y}; + float2 _S679 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S680; + (&_S680)->primal_0 = _S678; + (&_S680)->differential_0 = _S679; + DiffPair_float_0 _S681 = s_fwd_length_impl_0(&_S680); + float _S682 = p_view_19.z; + DiffPair_float_0 _S683; + (&_S683)->primal_0 = _S681.primal_0; + (&_S683)->differential_0 = _S681.differential_0; + DiffPair_float_0 _S684; + (&_S684)->primal_0 = _S682; + (&_S684)->differential_0 = 0.0f; + DiffPair_float_0 _S685 = _d_atan2_0(&_S683, &_S684); + float k_13; + float s_diff_k_5; + if((_S681.primal_0) < 9.99999997475242708e-07f) + { + float _S686 = _S685.differential_0 * _S685.primal_0; + float _S687 = 1.0f - _S685.primal_0 * _S685.primal_0 / 24.0f; + float _S688 = ((0.0f - (_S686 + _S686) * 0.0416666679084301f) * _S682 - _S687 * 0.0f) / (_S682 * _S682); + k_13 = _S687 / _S682; + s_diff_k_5 = _S688; + } + else + { + float _S689 = _S685.differential_0 * 0.5f; + DiffPair_float_0 _S690; + (&_S690)->primal_0 = 0.5f * _S685.primal_0; + (&_S690)->differential_0 = _S689; + DiffPair_float_0 _S691 = _d_sin_0(&_S690); + float _S692 = 2.0f * _S691.primal_0; + float _S693 = (_S691.differential_0 * 2.0f * _S681.primal_0 - _S692 * _S681.differential_0) / (_S681.primal_0 * _S681.primal_0); + k_13 = _S692 / _S681.primal_0; + s_diff_k_5 = _S693; + } + float2 _S694 = _S678 * make_float2 (k_13); + float2 _S695 = _S679 * make_float2 (k_13) + make_float2 (s_diff_k_5) * _S678; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S696; + (&_S696)->primal_0 = _S694; + (&_S696)->differential_0 = _S695; + FixedArray _S697 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S698 = s_fwd_DistThinPrism_distort_0(&_S696, &_S697); + float fx_9 = intrins_19.x; + float fy_9 = intrins_19.y; + float _S699 = _S698.differential_0.y * fy_9; + *&(((&J_9)->rows + (int(0)))->x) = _S698.differential_0.x * fx_9; + *&(((&J_9)->rows + (int(1)))->x) = _S699; + float2 _S700 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S701; + (&_S701)->primal_0 = _S678; + (&_S701)->differential_0 = _S700; + DiffPair_float_0 _S702 = s_fwd_length_impl_0(&_S701); + DiffPair_float_0 _S703; + (&_S703)->primal_0 = _S702.primal_0; + (&_S703)->differential_0 = _S702.differential_0; + DiffPair_float_0 _S704; + (&_S704)->primal_0 = _S682; + (&_S704)->differential_0 = 0.0f; + DiffPair_float_0 _S705 = _d_atan2_0(&_S703, &_S704); + if((_S702.primal_0) < 9.99999997475242708e-07f) + { + float _S706 = _S705.differential_0 * _S705.primal_0; + float _S707 = 1.0f - _S705.primal_0 * _S705.primal_0 / 24.0f; + float _S708 = ((0.0f - (_S706 + _S706) * 0.0416666679084301f) * _S682 - _S707 * 0.0f) / (_S682 * _S682); + k_13 = _S707 / _S682; + s_diff_k_5 = _S708; + } + else + { + float _S709 = _S705.differential_0 * 0.5f; + DiffPair_float_0 _S710; + (&_S710)->primal_0 = 0.5f * _S705.primal_0; + (&_S710)->differential_0 = _S709; + DiffPair_float_0 _S711 = _d_sin_0(&_S710); + float _S712 = 2.0f * _S711.primal_0; + float _S713 = (_S711.differential_0 * 2.0f * _S702.primal_0 - _S712 * _S702.differential_0) / (_S702.primal_0 * _S702.primal_0); + k_13 = _S712 / _S702.primal_0; + s_diff_k_5 = _S713; + } + float2 _S714 = _S678 * make_float2 (k_13); + float2 _S715 = _S700 * make_float2 (k_13) + make_float2 (s_diff_k_5) * _S678; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S716; + (&_S716)->primal_0 = _S714; + (&_S716)->differential_0 = _S715; + FixedArray _S717 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S718 = s_fwd_DistThinPrism_distort_0(&_S716, &_S717); + float _S719 = _S718.differential_0.y * fy_9; + *&(((&J_9)->rows + (int(0)))->y) = _S718.differential_0.x * fx_9; + *&(((&J_9)->rows + (int(1)))->y) = _S719; + float2 _S720 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S721; + (&_S721)->primal_0 = _S678; + (&_S721)->differential_0 = _S720; + DiffPair_float_0 _S722 = s_fwd_length_impl_0(&_S721); + DiffPair_float_0 _S723; + (&_S723)->primal_0 = _S722.primal_0; + (&_S723)->differential_0 = _S722.differential_0; + DiffPair_float_0 _S724; + (&_S724)->primal_0 = _S682; + (&_S724)->differential_0 = 1.0f; + DiffPair_float_0 _S725 = _d_atan2_0(&_S723, &_S724); + if((_S722.primal_0) < 9.99999997475242708e-07f) + { + float _S726 = _S725.differential_0 * _S725.primal_0; + float _S727 = 1.0f - _S725.primal_0 * _S725.primal_0 / 24.0f; + float _S728 = ((0.0f - (_S726 + _S726) * 0.0416666679084301f) * _S682 - _S727) / (_S682 * _S682); + k_13 = _S727 / _S682; + s_diff_k_5 = _S728; + } + else + { + float _S729 = _S725.differential_0 * 0.5f; + DiffPair_float_0 _S730; + (&_S730)->primal_0 = 0.5f * _S725.primal_0; + (&_S730)->differential_0 = _S729; + DiffPair_float_0 _S731 = _d_sin_0(&_S730); + float _S732 = 2.0f * _S731.primal_0; + float _S733 = (_S731.differential_0 * 2.0f * _S722.primal_0 - _S732 * _S722.differential_0) / (_S722.primal_0 * _S722.primal_0); + k_13 = _S732 / _S722.primal_0; + s_diff_k_5 = _S733; + } + float2 _S734 = _S678 * make_float2 (k_13); + float2 _S735 = _S720 * make_float2 (k_13) + make_float2 (s_diff_k_5) * _S678; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S736; + (&_S736)->primal_0 = _S734; + (&_S736)->differential_0 = _S735; + FixedArray _S737 = dist_coeffs_32; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S738 = s_fwd_DistThinPrism_distort_0(&_S736, &_S737); + float _S739 = _S738.differential_0.y * fy_9; + *&(((&J_9)->rows + (int(0)))->z) = _S738.differential_0.x * fx_9; + *&(((&J_9)->rows + (int(1)))->z) = _S739; + return J_9; +} + +inline __device__ float2 distort_point_prism(float2 uv_32, int camera_model_8, FixedArray dist_coeffs_33) +{ + float2 _S740; + for(;;) + { + if(camera_model_8 == int(3)) + { + _S740 = uv_32; + break; + } + float k_14; + if(camera_model_8 == int(1)) + { + float r_28 = length_0(uv_32); + float theta_10 = (F32_atan((r_28))); + if(r_28 < 0.00100000004749745f) + { + k_14 = 1.0f - theta_10 * theta_10 / 6.0f; + } + else + { + k_14 = theta_10 / r_28; + } + _S740 = uv_32 * make_float2 (k_14); + } + else + { + if(camera_model_8 == int(2)) + { + float r_29 = length_0(uv_32); + float theta_11 = (F32_atan((r_29))); + if(r_29 < 0.00100000004749745f) + { + k_14 = 1.0f - theta_11 * theta_11 / 24.0f; + } + else + { + k_14 = 2.0f * (F32_sin((0.5f * theta_11))) / r_29; + } + _S740 = uv_32 * make_float2 (k_14); + } + else + { + _S740 = uv_32; + } + } + FixedArray _S741 = dist_coeffs_33; + float2 _S742 = DistThinPrism_distort_0(_S740, &_S741); + _S740 = _S742; + break; + } + return _S740; +} + +inline __device__ bool undistort_point_prism(float2 uv_33, int camera_model_9, FixedArray dist_coeffs_34, float2 * uv_undist_6) +{ + bool _S743; + for(;;) + { + *uv_undist_6 = make_float2 (0.0f); + if(camera_model_9 == int(3)) + { + float lon_4 = uv_33.x; + float lat_6 = uv_33.y; + float cl_6 = (F32_cos((lat_6))); + *uv_undist_6 = make_float2 (cl_6 * (F32_sin((lon_4))), (F32_sin((lat_6)))) / make_float2 ((F32_max((cl_6 * (F32_cos((lon_4)))), (9.999999960041972e-13f)))); + _S743 = true; + break; + } + FixedArray _S744 = dist_coeffs_34; + float2 uv_u_6; + bool _S745 = undistort_point_2(uv_33, &_S744, int(8), &uv_u_6); + if(!_S745) + { + _S743 = false; + break; + } + float2 _S746 = uv_u_6; + float3 raydir_6; + if(camera_model_9 == int(1)) + { + float r_30 = length_0(_S746); + float s_6; + if(r_30 < 0.00100000004749745f) + { + s_6 = 1.0f - r_30 * r_30 / 6.0f; + } + else + { + s_6 = (F32_sin((r_30))) / r_30; + } + raydir_6 = make_float3 ((_S746 * make_float2 (s_6)).x, (_S746 * make_float2 (s_6)).y, (F32_cos((r_30)))); + } + else + { + if(camera_model_9 == int(2)) + { + float r_31 = length_0(_S746); + raydir_6 = make_float3 ((_S746 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_31 * r_31)))))))).x, (_S746 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_31 * r_31)))))))).y, 1.0f - 0.5f * r_31 * r_31); + } + else + { + raydir_6 = make_float3 (_S746.x, _S746.y, 1.0f); + } + } + *uv_undist_6 = float2 {raydir_6.x, raydir_6.y} / make_float2 ((F32_max((raydir_6.z), (9.999999960041972e-13f)))); + _S743 = true; + break; + } + return _S743; +} + +inline __device__ bool unproject_point_prism(float2 uv_34, int camera_model_10, FixedArray dist_coeffs_35, float3 * raydir_7) +{ + bool _S747; + for(;;) + { + int3 _S748 = make_int3 (int(0)); + float3 _S749 = make_float3 ((float)_S748.x, (float)_S748.y, (float)_S748.z); + *raydir_7 = _S749; + if(camera_model_10 == int(3)) + { + float lon_5 = uv_34.x; + float lat_7 = uv_34.y; + float cl_7 = (F32_cos((lat_7))); + *raydir_7 = make_float3 (cl_7 * (F32_sin((lon_5))), (F32_sin((lat_7))), cl_7 * (F32_cos((lon_5)))); + _S747 = true; + break; + } + FixedArray _S750 = dist_coeffs_35; + float2 uv_u_7; + bool _S751 = undistort_point_2(uv_34, &_S750, int(8), &uv_u_7); + if(!_S751) + { + _S747 = false; + break; + } + float2 _S752 = uv_u_7; + if(camera_model_10 == int(1)) + { + float r_32 = length_0(_S752); + float s_7; + if(r_32 < 0.00100000004749745f) + { + s_7 = 1.0f - r_32 * r_32 / 6.0f; + } + else + { + s_7 = (F32_sin((r_32))) / r_32; + } + *raydir_7 = make_float3 ((_S752 * make_float2 (s_7)).x, (_S752 * make_float2 (s_7)).y, (F32_cos((r_32)))); + } + else + { + if(camera_model_10 == int(2)) + { + float r_33 = length_0(_S752); + *raydir_7 = make_float3 ((_S752 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_33 * r_33)))))))).x, (_S752 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_33 * r_33)))))))).y, 1.0f - 0.5f * r_33 * r_33); + } + else + { + *raydir_7 = make_float3 (_S752.x, _S752.y, 1.0f); + } + } + _S747 = true; + break; + } + return _S747; +} + +inline __device__ bool generate_ray_prism(float2 uv_35, int camera_model_11, FixedArray dist_coeffs_36, float3 * raydir_8) +{ + bool _S753; + for(;;) + { + if(camera_model_11 == int(3)) + { + float _S754 = uv_35.x; + if((F32_abs((_S754))) > 3.14159274101257324f) + { + _S753 = true; + } + else + { + _S753 = (F32_abs((uv_35.y))) > 1.57079637050628662f; + } + if(_S753) + { + int3 _S755 = make_int3 (int(0)); + float3 _S756 = make_float3 ((float)_S755.x, (float)_S755.y, (float)_S755.z); + *raydir_8 = _S756; + _S753 = false; + break; + } + float lat_8 = uv_35.y; + float cl_8 = (F32_cos((lat_8))); + *raydir_8 = make_float3 (cl_8 * (F32_sin((_S754))), (F32_sin((lat_8))), cl_8 * (F32_cos((_S754)))); + _S753 = true; + break; + } + FixedArray _S757 = dist_coeffs_36; + float2 uv_u_8; + bool _S758 = undistort_point_2(uv_35, &_S757, int(8), &uv_u_8); + if(!_S758) + { + int3 _S759 = make_int3 (int(0)); + float3 _S760 = make_float3 ((float)_S759.x, (float)_S759.y, (float)_S759.z); + *raydir_8 = _S760; + _S753 = false; + break; + } + float2 _S761 = uv_u_8; + if(camera_model_11 == int(1)) + { + float r_34 = length_0(_S761); + if(r_34 >= 3.14159274101257324f) + { + int3 _S762 = make_int3 (int(0)); + float3 _S763 = make_float3 ((float)_S762.x, (float)_S762.y, (float)_S762.z); + *raydir_8 = _S763; + _S753 = false; + break; + } + float s_8; + if(r_34 < 0.00100000004749745f) + { + s_8 = 1.0f - r_34 * r_34 / 6.0f; + } + else + { + s_8 = (F32_sin((r_34))) / r_34; + } + *raydir_8 = make_float3 ((_S761 * make_float2 (s_8)).x, (_S761 * make_float2 (s_8)).y, (F32_cos((r_34)))); + } + else + { + if(camera_model_11 == int(2)) + { + float r_35 = length_0(_S761); + if(r_35 >= 2.0f) + { + int3 _S764 = make_int3 (int(0)); + float3 _S765 = make_float3 ((float)_S764.x, (float)_S764.y, (float)_S764.z); + *raydir_8 = _S765; + _S753 = false; + break; + } + *raydir_8 = make_float3 ((_S761 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_35 * r_35)))))))).x, (_S761 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_35 * r_35)))))))).y, 1.0f - 0.5f * r_35 * r_35); + } + else + { + *raydir_8 = make_float3 (_S761.x, _S761.y, 1.0f); + } + } + *raydir_8 = normalize_0(*raydir_8); + _S753 = true; + break; + } + return _S753; +} + +inline __device__ bool is_valid_distortion_rational(float2 uv_36, FixedArray dist_coeffs_37) +{ + float2 _S766 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S767; + (&_S767)->primal_0 = uv_36; + (&_S767)->differential_0 = _S766; + FixedArray _S768 = dist_coeffs_37; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S769 = s_fwd_DistRational_distort_0(&_S767, &_S768); + float2 _S770 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S771; + (&_S771)->primal_0 = uv_36; + (&_S771)->differential_0 = _S770; + FixedArray _S772 = dist_coeffs_37; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S773 = s_fwd_DistRational_distort_0(&_S771, &_S772); + Matrix _S774 = transpose_1(makeMatrix (_S769.differential_0, _S773.differential_0)); + float _S775 = (F32_min((determinant_0(_S774)), ((F32_min((_S774.rows[int(0)].x), (_S774.rows[int(1)].y)))))); + bool _S776; + if(_S775 > 0.25f) + { + _S776 = _S775 < 4.0f; + } + else + { + _S776 = false; + } + if(_S776) + { + FixedArray _S777 = dist_coeffs_37; + float2 _S778 = DistRational_distort_0(uv_36, &_S777); + _S776 = (dot_0(uv_36, _S778)) >= 0.0f; + } + else + { + _S776 = false; + } + return _S776; +} + +inline __device__ bool persp_proj_nav_rational(float3 p_view_20, float4 intrins_20, FixedArray dist_coeffs_38, float2 * uv_37) +{ + bool _S779; + for(;;) + { + float2 _S780 = float2 {p_view_20.x, p_view_20.y}; + float _S781 = p_view_20.z; + float2 uv0_3 = _S780 / make_float2 (_S781); + if(_S781 < 0.0f) + { + _S779 = true; + } + else + { + float2 _S782 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S783; + (&_S783)->primal_0 = uv0_3; + (&_S783)->differential_0 = _S782; + FixedArray _S784 = dist_coeffs_38; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S785 = s_fwd_DistRational_distort_0(&_S783, &_S784); + float2 _S786 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S787; + (&_S787)->primal_0 = uv0_3; + (&_S787)->differential_0 = _S786; + FixedArray _S788 = dist_coeffs_38; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S789 = s_fwd_DistRational_distort_0(&_S787, &_S788); + Matrix _S790 = transpose_1(makeMatrix (_S785.differential_0, _S789.differential_0)); + float _S791 = (F32_min((determinant_0(_S790)), ((F32_min((_S790.rows[int(0)].x), (_S790.rows[int(1)].y)))))); + if(_S791 > 0.25f) + { + _S779 = _S791 < 4.0f; + } + else + { + _S779 = false; + } + if(_S779) + { + FixedArray _S792 = dist_coeffs_38; + float2 _S793 = DistRational_distort_0(uv0_3, &_S792); + _S779 = (dot_0(uv0_3, _S793)) >= 0.0f; + } + else + { + _S779 = false; + } + _S779 = !_S779; + } + if(_S779) + { + *uv_37 = uv0_3; + _S779 = false; + break; + } + float2 uv_38 = _S780 / make_float2 (_S781); + FixedArray _S794 = dist_coeffs_38; + float2 _S795 = DistRational_distort_0(uv_38, &_S794); + *uv_37 = make_float2 (intrins_20.x * _S795.x + intrins_20.z, intrins_20.y * _S795.y + intrins_20.w); + _S779 = true; + break; + } + return _S779; +} + +inline __device__ bool fisheye_proj_nav_rational(float3 p_view_21, float4 intrins_21, FixedArray dist_coeffs_39, float2 * uv_39) +{ + bool _S796; + for(;;) + { + float2 _S797 = float2 {p_view_21.x, p_view_21.y}; + float r_36 = length_0(_S797); + float _S798 = p_view_21.z; + float theta_12 = (F32_atan2((r_36), (_S798))); + bool _S799 = theta_12 < 0.00100000004749745f; + float k_15; + if(_S799) + { + k_15 = (1.0f - theta_12 * theta_12 / 3.0f) / _S798; + } + else + { + k_15 = theta_12 / r_36; + } + float2 _S800 = _S797 * make_float2 (k_15); + float2 _S801 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S802; + (&_S802)->primal_0 = _S800; + (&_S802)->differential_0 = _S801; + FixedArray _S803 = dist_coeffs_39; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S804 = s_fwd_DistRational_distort_0(&_S802, &_S803); + float2 _S805 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S806; + (&_S806)->primal_0 = _S800; + (&_S806)->differential_0 = _S805; + FixedArray _S807 = dist_coeffs_39; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S808 = s_fwd_DistRational_distort_0(&_S806, &_S807); + Matrix _S809 = transpose_1(makeMatrix (_S804.differential_0, _S808.differential_0)); + float _S810 = (F32_min((determinant_0(_S809)), ((F32_min((_S809.rows[int(0)].x), (_S809.rows[int(1)].y)))))); + if(_S810 > 0.25f) + { + _S796 = _S810 < 4.0f; + } + else + { + _S796 = false; + } + if(_S796) + { + FixedArray _S811 = dist_coeffs_39; + float2 _S812 = DistRational_distort_0(_S800, &_S811); + _S796 = (dot_0(_S800, _S812)) >= 0.0f; + } + else + { + _S796 = false; + } + if(!_S796) + { + *uv_39 = _S800; + _S796 = false; + break; + } + if(_S799) + { + k_15 = (1.0f - theta_12 * theta_12 / 3.0f) / _S798; + } + else + { + k_15 = theta_12 / r_36; + } + float2 _S813 = _S797 * make_float2 (k_15); + FixedArray _S814 = dist_coeffs_39; + float2 _S815 = DistRational_distort_0(_S813, &_S814); + *uv_39 = make_float2 (intrins_21.x * _S815.x + intrins_21.z, intrins_21.y * _S815.y + intrins_21.w); + _S796 = true; + break; + } + return _S796; +} + +inline __device__ bool equisolid_proj_nav_rational(float3 p_view_22, float4 intrins_22, FixedArray dist_coeffs_40, float2 * uv_40) +{ + bool _S816; + for(;;) + { + float2 _S817 = float2 {p_view_22.x, p_view_22.y}; + float r_37 = length_0(_S817); + float _S818 = p_view_22.z; + float theta_13 = (F32_atan2((r_37), (_S818))); + bool _S819 = r_37 < 9.99999997475242708e-07f; + float k_16; + if(_S819) + { + k_16 = (1.0f - theta_13 * theta_13 / 24.0f) / _S818; + } + else + { + k_16 = 2.0f * (F32_sin((0.5f * theta_13))) / r_37; + } + float2 _S820 = _S817 * make_float2 (k_16); + float2 _S821 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S822; + (&_S822)->primal_0 = _S820; + (&_S822)->differential_0 = _S821; + FixedArray _S823 = dist_coeffs_40; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S824 = s_fwd_DistRational_distort_0(&_S822, &_S823); + float2 _S825 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S826; + (&_S826)->primal_0 = _S820; + (&_S826)->differential_0 = _S825; + FixedArray _S827 = dist_coeffs_40; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S828 = s_fwd_DistRational_distort_0(&_S826, &_S827); + Matrix _S829 = transpose_1(makeMatrix (_S824.differential_0, _S828.differential_0)); + float _S830 = (F32_min((determinant_0(_S829)), ((F32_min((_S829.rows[int(0)].x), (_S829.rows[int(1)].y)))))); + if(_S830 > 0.25f) + { + _S816 = _S830 < 4.0f; + } + else + { + _S816 = false; + } + if(_S816) + { + FixedArray _S831 = dist_coeffs_40; + float2 _S832 = DistRational_distort_0(_S820, &_S831); + _S816 = (dot_0(_S820, _S832)) >= 0.0f; + } + else + { + _S816 = false; + } + if(!_S816) + { + *uv_40 = _S820; + _S816 = false; + break; + } + if(_S819) + { + k_16 = (1.0f - theta_13 * theta_13 / 24.0f) / _S818; + } + else + { + k_16 = 2.0f * (F32_sin((0.5f * theta_13))) / r_37; + } + float2 _S833 = _S817 * make_float2 (k_16); + FixedArray _S834 = dist_coeffs_40; + float2 _S835 = DistRational_distort_0(_S833, &_S834); + *uv_40 = make_float2 (intrins_22.x * _S835.x + intrins_22.z, intrins_22.y * _S835.y + intrins_22.w); + _S816 = true; + break; + } + return _S816; +} + +inline __device__ Matrix persp_proj_jac_rational(float3 p_view_23, float4 intrins_23, FixedArray dist_coeffs_41) +{ + float2 _S836 = float2 {p_view_23.x, p_view_23.y}; + float _S837 = p_view_23.z; + float2 _S838 = _S836 * make_float2 (0.0f); + float _S839 = _S837 * _S837; + float2 s_diff_uv_9 = (make_float2 (1.0f, 0.0f) * make_float2 (_S837) - _S838) / make_float2 (_S839); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S840; + (&_S840)->primal_0 = _S836 / make_float2 (_S837); + (&_S840)->differential_0 = s_diff_uv_9; + FixedArray _S841 = dist_coeffs_41; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S842 = s_fwd_DistRational_distort_0(&_S840, &_S841); + float fx_10 = intrins_23.x; + float fy_10 = intrins_23.y; + float _S843 = _S842.differential_0.y * fy_10; + Matrix J_10; + *&(((&J_10)->rows + (int(0)))->x) = _S842.differential_0.x * fx_10; + *&(((&J_10)->rows + (int(1)))->x) = _S843; + float2 s_diff_uv_10 = (make_float2 (0.0f, 1.0f) * make_float2 (_S837) - _S838) / make_float2 (_S839); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S844; + (&_S844)->primal_0 = _S836 / make_float2 (_S837); + (&_S844)->differential_0 = s_diff_uv_10; + FixedArray _S845 = dist_coeffs_41; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S846 = s_fwd_DistRational_distort_0(&_S844, &_S845); + float _S847 = _S846.differential_0.y * fy_10; + *&(((&J_10)->rows + (int(0)))->y) = _S846.differential_0.x * fx_10; + *&(((&J_10)->rows + (int(1)))->y) = _S847; + float2 s_diff_uv_11 = (make_float2 (0.0f, 0.0f) * make_float2 (_S837) - _S836) / make_float2 (_S839); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S848; + (&_S848)->primal_0 = _S836 / make_float2 (_S837); + (&_S848)->differential_0 = s_diff_uv_11; + FixedArray _S849 = dist_coeffs_41; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S850 = s_fwd_DistRational_distort_0(&_S848, &_S849); + float _S851 = _S850.differential_0.y * fy_10; + *&(((&J_10)->rows + (int(0)))->z) = _S850.differential_0.x * fx_10; + *&(((&J_10)->rows + (int(1)))->z) = _S851; + return J_10; +} + +inline __device__ Matrix fisheye_proj_jac_rational(float3 p_view_24, float4 intrins_24, FixedArray dist_coeffs_42) +{ + Matrix J_11; + float2 _S852 = float2 {p_view_24.x, p_view_24.y}; + float2 _S853 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S854; + (&_S854)->primal_0 = _S852; + (&_S854)->differential_0 = _S853; + DiffPair_float_0 _S855 = s_fwd_length_impl_0(&_S854); + float _S856 = p_view_24.z; + DiffPair_float_0 _S857; + (&_S857)->primal_0 = _S855.primal_0; + (&_S857)->differential_0 = _S855.differential_0; + DiffPair_float_0 _S858; + (&_S858)->primal_0 = _S856; + (&_S858)->differential_0 = 0.0f; + DiffPair_float_0 _S859 = _d_atan2_0(&_S857, &_S858); + float k_17; + float s_diff_k_6; + if((_S859.primal_0) < 0.00100000004749745f) + { + float _S860 = _S859.differential_0 * _S859.primal_0; + float _S861 = 1.0f - _S859.primal_0 * _S859.primal_0 / 3.0f; + float _S862 = ((0.0f - (_S860 + _S860) * 0.3333333432674408f) * _S856 - _S861 * 0.0f) / (_S856 * _S856); + k_17 = _S861 / _S856; + s_diff_k_6 = _S862; + } + else + { + float _S863 = (_S859.differential_0 * _S855.primal_0 - _S859.primal_0 * _S855.differential_0) / (_S855.primal_0 * _S855.primal_0); + k_17 = _S859.primal_0 / _S855.primal_0; + s_diff_k_6 = _S863; + } + float2 _S864 = _S852 * make_float2 (k_17); + float2 _S865 = _S853 * make_float2 (k_17) + make_float2 (s_diff_k_6) * _S852; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S866; + (&_S866)->primal_0 = _S864; + (&_S866)->differential_0 = _S865; + FixedArray _S867 = dist_coeffs_42; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S868 = s_fwd_DistRational_distort_0(&_S866, &_S867); + float fx_11 = intrins_24.x; + float fy_11 = intrins_24.y; + float _S869 = _S868.differential_0.y * fy_11; + *&(((&J_11)->rows + (int(0)))->x) = _S868.differential_0.x * fx_11; + *&(((&J_11)->rows + (int(1)))->x) = _S869; + float2 _S870 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S871; + (&_S871)->primal_0 = _S852; + (&_S871)->differential_0 = _S870; + DiffPair_float_0 _S872 = s_fwd_length_impl_0(&_S871); + DiffPair_float_0 _S873; + (&_S873)->primal_0 = _S872.primal_0; + (&_S873)->differential_0 = _S872.differential_0; + DiffPair_float_0 _S874; + (&_S874)->primal_0 = _S856; + (&_S874)->differential_0 = 0.0f; + DiffPair_float_0 _S875 = _d_atan2_0(&_S873, &_S874); + if((_S875.primal_0) < 0.00100000004749745f) + { + float _S876 = _S875.differential_0 * _S875.primal_0; + float _S877 = 1.0f - _S875.primal_0 * _S875.primal_0 / 3.0f; + float _S878 = ((0.0f - (_S876 + _S876) * 0.3333333432674408f) * _S856 - _S877 * 0.0f) / (_S856 * _S856); + k_17 = _S877 / _S856; + s_diff_k_6 = _S878; + } + else + { + float _S879 = (_S875.differential_0 * _S872.primal_0 - _S875.primal_0 * _S872.differential_0) / (_S872.primal_0 * _S872.primal_0); + k_17 = _S875.primal_0 / _S872.primal_0; + s_diff_k_6 = _S879; + } + float2 _S880 = _S852 * make_float2 (k_17); + float2 _S881 = _S870 * make_float2 (k_17) + make_float2 (s_diff_k_6) * _S852; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S882; + (&_S882)->primal_0 = _S880; + (&_S882)->differential_0 = _S881; + FixedArray _S883 = dist_coeffs_42; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S884 = s_fwd_DistRational_distort_0(&_S882, &_S883); + float _S885 = _S884.differential_0.y * fy_11; + *&(((&J_11)->rows + (int(0)))->y) = _S884.differential_0.x * fx_11; + *&(((&J_11)->rows + (int(1)))->y) = _S885; + float2 _S886 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S887; + (&_S887)->primal_0 = _S852; + (&_S887)->differential_0 = _S886; + DiffPair_float_0 _S888 = s_fwd_length_impl_0(&_S887); + DiffPair_float_0 _S889; + (&_S889)->primal_0 = _S888.primal_0; + (&_S889)->differential_0 = _S888.differential_0; + DiffPair_float_0 _S890; + (&_S890)->primal_0 = _S856; + (&_S890)->differential_0 = 1.0f; + DiffPair_float_0 _S891 = _d_atan2_0(&_S889, &_S890); + if((_S891.primal_0) < 0.00100000004749745f) + { + float _S892 = _S891.differential_0 * _S891.primal_0; + float _S893 = 1.0f - _S891.primal_0 * _S891.primal_0 / 3.0f; + float _S894 = ((0.0f - (_S892 + _S892) * 0.3333333432674408f) * _S856 - _S893) / (_S856 * _S856); + k_17 = _S893 / _S856; + s_diff_k_6 = _S894; + } + else + { + float _S895 = (_S891.differential_0 * _S888.primal_0 - _S891.primal_0 * _S888.differential_0) / (_S888.primal_0 * _S888.primal_0); + k_17 = _S891.primal_0 / _S888.primal_0; + s_diff_k_6 = _S895; + } + float2 _S896 = _S852 * make_float2 (k_17); + float2 _S897 = _S886 * make_float2 (k_17) + make_float2 (s_diff_k_6) * _S852; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S898; + (&_S898)->primal_0 = _S896; + (&_S898)->differential_0 = _S897; + FixedArray _S899 = dist_coeffs_42; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S900 = s_fwd_DistRational_distort_0(&_S898, &_S899); + float _S901 = _S900.differential_0.y * fy_11; + *&(((&J_11)->rows + (int(0)))->z) = _S900.differential_0.x * fx_11; + *&(((&J_11)->rows + (int(1)))->z) = _S901; + return J_11; +} + +inline __device__ Matrix equisolid_proj_jac_rational(float3 p_view_25, float4 intrins_25, FixedArray dist_coeffs_43) +{ + Matrix J_12; + float2 _S902 = float2 {p_view_25.x, p_view_25.y}; + float2 _S903 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S904; + (&_S904)->primal_0 = _S902; + (&_S904)->differential_0 = _S903; + DiffPair_float_0 _S905 = s_fwd_length_impl_0(&_S904); + float _S906 = p_view_25.z; + DiffPair_float_0 _S907; + (&_S907)->primal_0 = _S905.primal_0; + (&_S907)->differential_0 = _S905.differential_0; + DiffPair_float_0 _S908; + (&_S908)->primal_0 = _S906; + (&_S908)->differential_0 = 0.0f; + DiffPair_float_0 _S909 = _d_atan2_0(&_S907, &_S908); + float k_18; + float s_diff_k_7; + if((_S905.primal_0) < 9.99999997475242708e-07f) + { + float _S910 = _S909.differential_0 * _S909.primal_0; + float _S911 = 1.0f - _S909.primal_0 * _S909.primal_0 / 24.0f; + float _S912 = ((0.0f - (_S910 + _S910) * 0.0416666679084301f) * _S906 - _S911 * 0.0f) / (_S906 * _S906); + k_18 = _S911 / _S906; + s_diff_k_7 = _S912; + } + else + { + float _S913 = _S909.differential_0 * 0.5f; + DiffPair_float_0 _S914; + (&_S914)->primal_0 = 0.5f * _S909.primal_0; + (&_S914)->differential_0 = _S913; + DiffPair_float_0 _S915 = _d_sin_0(&_S914); + float _S916 = 2.0f * _S915.primal_0; + float _S917 = (_S915.differential_0 * 2.0f * _S905.primal_0 - _S916 * _S905.differential_0) / (_S905.primal_0 * _S905.primal_0); + k_18 = _S916 / _S905.primal_0; + s_diff_k_7 = _S917; + } + float2 _S918 = _S902 * make_float2 (k_18); + float2 _S919 = _S903 * make_float2 (k_18) + make_float2 (s_diff_k_7) * _S902; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S920; + (&_S920)->primal_0 = _S918; + (&_S920)->differential_0 = _S919; + FixedArray _S921 = dist_coeffs_43; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S922 = s_fwd_DistRational_distort_0(&_S920, &_S921); + float fx_12 = intrins_25.x; + float fy_12 = intrins_25.y; + float _S923 = _S922.differential_0.y * fy_12; + *&(((&J_12)->rows + (int(0)))->x) = _S922.differential_0.x * fx_12; + *&(((&J_12)->rows + (int(1)))->x) = _S923; + float2 _S924 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S925; + (&_S925)->primal_0 = _S902; + (&_S925)->differential_0 = _S924; + DiffPair_float_0 _S926 = s_fwd_length_impl_0(&_S925); + DiffPair_float_0 _S927; + (&_S927)->primal_0 = _S926.primal_0; + (&_S927)->differential_0 = _S926.differential_0; + DiffPair_float_0 _S928; + (&_S928)->primal_0 = _S906; + (&_S928)->differential_0 = 0.0f; + DiffPair_float_0 _S929 = _d_atan2_0(&_S927, &_S928); + if((_S926.primal_0) < 9.99999997475242708e-07f) + { + float _S930 = _S929.differential_0 * _S929.primal_0; + float _S931 = 1.0f - _S929.primal_0 * _S929.primal_0 / 24.0f; + float _S932 = ((0.0f - (_S930 + _S930) * 0.0416666679084301f) * _S906 - _S931 * 0.0f) / (_S906 * _S906); + k_18 = _S931 / _S906; + s_diff_k_7 = _S932; + } + else + { + float _S933 = _S929.differential_0 * 0.5f; + DiffPair_float_0 _S934; + (&_S934)->primal_0 = 0.5f * _S929.primal_0; + (&_S934)->differential_0 = _S933; + DiffPair_float_0 _S935 = _d_sin_0(&_S934); + float _S936 = 2.0f * _S935.primal_0; + float _S937 = (_S935.differential_0 * 2.0f * _S926.primal_0 - _S936 * _S926.differential_0) / (_S926.primal_0 * _S926.primal_0); + k_18 = _S936 / _S926.primal_0; + s_diff_k_7 = _S937; + } + float2 _S938 = _S902 * make_float2 (k_18); + float2 _S939 = _S924 * make_float2 (k_18) + make_float2 (s_diff_k_7) * _S902; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S940; + (&_S940)->primal_0 = _S938; + (&_S940)->differential_0 = _S939; + FixedArray _S941 = dist_coeffs_43; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S942 = s_fwd_DistRational_distort_0(&_S940, &_S941); + float _S943 = _S942.differential_0.y * fy_12; + *&(((&J_12)->rows + (int(0)))->y) = _S942.differential_0.x * fx_12; + *&(((&J_12)->rows + (int(1)))->y) = _S943; + float2 _S944 = make_float2 (0.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S945; + (&_S945)->primal_0 = _S902; + (&_S945)->differential_0 = _S944; + DiffPair_float_0 _S946 = s_fwd_length_impl_0(&_S945); + DiffPair_float_0 _S947; + (&_S947)->primal_0 = _S946.primal_0; + (&_S947)->differential_0 = _S946.differential_0; + DiffPair_float_0 _S948; + (&_S948)->primal_0 = _S906; + (&_S948)->differential_0 = 1.0f; + DiffPair_float_0 _S949 = _d_atan2_0(&_S947, &_S948); + if((_S946.primal_0) < 9.99999997475242708e-07f) + { + float _S950 = _S949.differential_0 * _S949.primal_0; + float _S951 = 1.0f - _S949.primal_0 * _S949.primal_0 / 24.0f; + float _S952 = ((0.0f - (_S950 + _S950) * 0.0416666679084301f) * _S906 - _S951) / (_S906 * _S906); + k_18 = _S951 / _S906; + s_diff_k_7 = _S952; + } + else + { + float _S953 = _S949.differential_0 * 0.5f; + DiffPair_float_0 _S954; + (&_S954)->primal_0 = 0.5f * _S949.primal_0; + (&_S954)->differential_0 = _S953; + DiffPair_float_0 _S955 = _d_sin_0(&_S954); + float _S956 = 2.0f * _S955.primal_0; + float _S957 = (_S955.differential_0 * 2.0f * _S946.primal_0 - _S956 * _S946.differential_0) / (_S946.primal_0 * _S946.primal_0); + k_18 = _S956 / _S946.primal_0; + s_diff_k_7 = _S957; + } + float2 _S958 = _S902 * make_float2 (k_18); + float2 _S959 = _S944 * make_float2 (k_18) + make_float2 (s_diff_k_7) * _S902; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S960; + (&_S960)->primal_0 = _S958; + (&_S960)->differential_0 = _S959; + FixedArray _S961 = dist_coeffs_43; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S962 = s_fwd_DistRational_distort_0(&_S960, &_S961); + float _S963 = _S962.differential_0.y * fy_12; + *&(((&J_12)->rows + (int(0)))->z) = _S962.differential_0.x * fx_12; + *&(((&J_12)->rows + (int(1)))->z) = _S963; + return J_12; +} + +inline __device__ float2 distort_point_rational(float2 uv_41, int camera_model_12, FixedArray dist_coeffs_44) +{ + float2 _S964; + for(;;) + { + if(camera_model_12 == int(3)) + { + _S964 = uv_41; + break; + } + float k_19; + if(camera_model_12 == int(1)) + { + float r_38 = length_0(uv_41); + float theta_14 = (F32_atan((r_38))); + if(r_38 < 0.00100000004749745f) + { + k_19 = 1.0f - theta_14 * theta_14 / 6.0f; + } + else + { + k_19 = theta_14 / r_38; + } + _S964 = uv_41 * make_float2 (k_19); + } + else + { + if(camera_model_12 == int(2)) + { + float r_39 = length_0(uv_41); + float theta_15 = (F32_atan((r_39))); + if(r_39 < 0.00100000004749745f) + { + k_19 = 1.0f - theta_15 * theta_15 / 24.0f; + } + else + { + k_19 = 2.0f * (F32_sin((0.5f * theta_15))) / r_39; + } + _S964 = uv_41 * make_float2 (k_19); + } + else + { + _S964 = uv_41; + } + } + FixedArray _S965 = dist_coeffs_44; + float2 _S966 = DistRational_distort_0(_S964, &_S965); + _S964 = _S966; + break; + } + return _S964; +} + +inline __device__ bool undistort_point_rational(float2 uv_42, int camera_model_13, FixedArray dist_coeffs_45, float2 * uv_undist_7) +{ + bool _S967; + for(;;) + { + *uv_undist_7 = make_float2 (0.0f); + if(camera_model_13 == int(3)) + { + float lon_6 = uv_42.x; + float lat_9 = uv_42.y; + float cl_9 = (F32_cos((lat_9))); + *uv_undist_7 = make_float2 (cl_9 * (F32_sin((lon_6))), (F32_sin((lat_9)))) / make_float2 ((F32_max((cl_9 * (F32_cos((lon_6)))), (9.999999960041972e-13f)))); + _S967 = true; + break; + } + FixedArray _S968 = dist_coeffs_45; + float2 uv_u_9; + bool _S969 = undistort_point_3(uv_42, &_S968, int(8), &uv_u_9); + if(!_S969) + { + _S967 = false; + break; + } + float2 _S970 = uv_u_9; + float3 raydir_9; + if(camera_model_13 == int(1)) + { + float r_40 = length_0(_S970); + float s_9; + if(r_40 < 0.00100000004749745f) + { + s_9 = 1.0f - r_40 * r_40 / 6.0f; + } + else + { + s_9 = (F32_sin((r_40))) / r_40; + } + raydir_9 = make_float3 ((_S970 * make_float2 (s_9)).x, (_S970 * make_float2 (s_9)).y, (F32_cos((r_40)))); + } + else + { + if(camera_model_13 == int(2)) + { + float r_41 = length_0(_S970); + raydir_9 = make_float3 ((_S970 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_41 * r_41)))))))).x, (_S970 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_41 * r_41)))))))).y, 1.0f - 0.5f * r_41 * r_41); + } + else + { + raydir_9 = make_float3 (_S970.x, _S970.y, 1.0f); + } + } + *uv_undist_7 = float2 {raydir_9.x, raydir_9.y} / make_float2 ((F32_max((raydir_9.z), (9.999999960041972e-13f)))); + _S967 = true; + break; + } + return _S967; +} + +inline __device__ bool unproject_point_rational(float2 uv_43, int camera_model_14, FixedArray dist_coeffs_46, float3 * raydir_10) +{ + bool _S971; + for(;;) + { + int3 _S972 = make_int3 (int(0)); + float3 _S973 = make_float3 ((float)_S972.x, (float)_S972.y, (float)_S972.z); + *raydir_10 = _S973; + if(camera_model_14 == int(3)) + { + float lon_7 = uv_43.x; + float lat_10 = uv_43.y; + float cl_10 = (F32_cos((lat_10))); + *raydir_10 = make_float3 (cl_10 * (F32_sin((lon_7))), (F32_sin((lat_10))), cl_10 * (F32_cos((lon_7)))); + _S971 = true; + break; + } + FixedArray _S974 = dist_coeffs_46; + float2 uv_u_10; + bool _S975 = undistort_point_3(uv_43, &_S974, int(8), &uv_u_10); + if(!_S975) + { + _S971 = false; + break; + } + float2 _S976 = uv_u_10; + if(camera_model_14 == int(1)) + { + float r_42 = length_0(_S976); + float s_10; + if(r_42 < 0.00100000004749745f) + { + s_10 = 1.0f - r_42 * r_42 / 6.0f; + } + else + { + s_10 = (F32_sin((r_42))) / r_42; + } + *raydir_10 = make_float3 ((_S976 * make_float2 (s_10)).x, (_S976 * make_float2 (s_10)).y, (F32_cos((r_42)))); + } + else + { + if(camera_model_14 == int(2)) + { + float r_43 = length_0(_S976); + *raydir_10 = make_float3 ((_S976 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_43 * r_43)))))))).x, (_S976 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_43 * r_43)))))))).y, 1.0f - 0.5f * r_43 * r_43); + } + else + { + *raydir_10 = make_float3 (_S976.x, _S976.y, 1.0f); + } + } + _S971 = true; + break; + } + return _S971; +} + +inline __device__ bool generate_ray_rational(float2 uv_44, int camera_model_15, FixedArray dist_coeffs_47, float3 * raydir_11) +{ + bool _S977; + for(;;) + { + if(camera_model_15 == int(3)) + { + float _S978 = uv_44.x; + if((F32_abs((_S978))) > 3.14159274101257324f) + { + _S977 = true; + } + else + { + _S977 = (F32_abs((uv_44.y))) > 1.57079637050628662f; + } + if(_S977) + { + int3 _S979 = make_int3 (int(0)); + float3 _S980 = make_float3 ((float)_S979.x, (float)_S979.y, (float)_S979.z); + *raydir_11 = _S980; + _S977 = false; + break; + } + float lat_11 = uv_44.y; + float cl_11 = (F32_cos((lat_11))); + *raydir_11 = make_float3 (cl_11 * (F32_sin((_S978))), (F32_sin((lat_11))), cl_11 * (F32_cos((_S978)))); + _S977 = true; + break; + } + FixedArray _S981 = dist_coeffs_47; + float2 uv_u_11; + bool _S982 = undistort_point_3(uv_44, &_S981, int(8), &uv_u_11); + if(!_S982) + { + int3 _S983 = make_int3 (int(0)); + float3 _S984 = make_float3 ((float)_S983.x, (float)_S983.y, (float)_S983.z); + *raydir_11 = _S984; + _S977 = false; + break; + } + float2 _S985 = uv_u_11; + if(camera_model_15 == int(1)) + { + float r_44 = length_0(_S985); + if(r_44 >= 3.14159274101257324f) + { + int3 _S986 = make_int3 (int(0)); + float3 _S987 = make_float3 ((float)_S986.x, (float)_S986.y, (float)_S986.z); + *raydir_11 = _S987; + _S977 = false; + break; + } + float s_11; + if(r_44 < 0.00100000004749745f) + { + s_11 = 1.0f - r_44 * r_44 / 6.0f; + } + else + { + s_11 = (F32_sin((r_44))) / r_44; + } + *raydir_11 = make_float3 ((_S985 * make_float2 (s_11)).x, (_S985 * make_float2 (s_11)).y, (F32_cos((r_44)))); + } + else + { + if(camera_model_15 == int(2)) + { + float r_45 = length_0(_S985); + if(r_45 >= 2.0f) + { + int3 _S988 = make_int3 (int(0)); + float3 _S989 = make_float3 ((float)_S988.x, (float)_S988.y, (float)_S988.z); + *raydir_11 = _S989; + _S977 = false; + break; + } + *raydir_11 = make_float3 ((_S985 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_45 * r_45)))))))).x, (_S985 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_45 * r_45)))))))).y, 1.0f - 0.5f * r_45 * r_45); + } + else + { + *raydir_11 = make_float3 (_S985.x, _S985.y, 1.0f); + } + } + *raydir_11 = normalize_0(*raydir_11); + _S977 = true; + break; + } + return _S977; } inline __device__ void _d_mul_1(DiffPair_vectorx3Cfloatx2C3x3E_0 * left_4, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * right_4, float3 dOut_3) { - float _S369 = (*right_4).primal_0.rows[int(0)].x * dOut_3.x; + float _S990 = (*right_4).primal_0.rows[int(0)].x * dOut_3.x; Matrix right_d_result_2; *&(((&right_d_result_2)->rows + (int(0)))->x) = (*left_4).primal_0.x * dOut_3.x; - float sum_10 = _S369 + (*right_4).primal_0.rows[int(0)].y * dOut_3.y; + float sum_10 = _S990 + (*right_4).primal_0.rows[int(0)].y * dOut_3.y; *&(((&right_d_result_2)->rows + (int(0)))->y) = (*left_4).primal_0.x * dOut_3.y; float sum_11 = sum_10 + (*right_4).primal_0.rows[int(0)].z * dOut_3.z; *&(((&right_d_result_2)->rows + (int(0)))->z) = (*left_4).primal_0.x * dOut_3.z; float3 left_d_result_2; *&((&left_d_result_2)->x) = sum_11; - float _S370 = (*right_4).primal_0.rows[int(1)].x * dOut_3.x; + float _S991 = (*right_4).primal_0.rows[int(1)].x * dOut_3.x; *&(((&right_d_result_2)->rows + (int(1)))->x) = (*left_4).primal_0.y * dOut_3.x; - float sum_12 = _S370 + (*right_4).primal_0.rows[int(1)].y * dOut_3.y; + float sum_12 = _S991 + (*right_4).primal_0.rows[int(1)].y * dOut_3.y; *&(((&right_d_result_2)->rows + (int(1)))->y) = (*left_4).primal_0.y * dOut_3.y; float sum_13 = sum_12 + (*right_4).primal_0.rows[int(1)].z * dOut_3.z; *&(((&right_d_result_2)->rows + (int(1)))->z) = (*left_4).primal_0.y * dOut_3.z; *&((&left_d_result_2)->y) = sum_13; - float _S371 = (*right_4).primal_0.rows[int(2)].x * dOut_3.x; + float _S992 = (*right_4).primal_0.rows[int(2)].x * dOut_3.x; *&(((&right_d_result_2)->rows + (int(2)))->x) = (*left_4).primal_0.z * dOut_3.x; - float sum_14 = _S371 + (*right_4).primal_0.rows[int(2)].y * dOut_3.y; + float sum_14 = _S992 + (*right_4).primal_0.rows[int(2)].y * dOut_3.y; *&(((&right_d_result_2)->rows + (int(2)))->y) = (*left_4).primal_0.z * dOut_3.y; float sum_15 = sum_14 + (*right_4).primal_0.rows[int(2)].z * dOut_3.z; *&(((&right_d_result_2)->rows + (int(2)))->z) = (*left_4).primal_0.z * dOut_3.z; @@ -1490,19 +4010,19 @@ inline __device__ float3 mul_3(float3 left_5, Matrix right_5) { break; } - int i_5 = int(0); + int i_7 = int(0); float sum_16 = 0.0f; for(;;) { - if(i_5 < int(3)) + if(i_7 < int(3)) { } else { break; } - float sum_17 = sum_16 + _slang_vector_get_element(left_5, i_5) * _slang_vector_get_element(right_5.rows[i_5], j_1); - i_5 = i_5 + int(1); + float sum_17 = sum_16 + _slang_vector_get_element(left_5, i_7) * _slang_vector_get_element(right_5.rows[i_7], j_1); + i_7 = i_7 + int(1); sum_16 = sum_17; } *_slang_vector_get_element_ptr(&result_8, j_1) = sum_16; @@ -1516,57 +4036,57 @@ inline __device__ float3 transform_ray_o(Matrix R_0, float3 t_0) return - mul_3(t_0, R_0); } -inline __device__ float3 transform_ray_d(Matrix R_1, float3 raydir_3) +inline __device__ float3 transform_ray_d(Matrix R_1, float3 raydir_12) { - return mul_3(raydir_3, R_1); + return mul_3(raydir_12, R_1); } -inline __device__ float3 undo_transform_ray_d(Matrix R_2, float3 raydir_4) +inline __device__ float3 undo_transform_ray_d(Matrix R_2, float3 raydir_13) { - return mul_3(raydir_4, transpose_0(R_2)); + return mul_3(raydir_13, transpose_0(R_2)); } -inline __device__ void s_bwd_prop_mul_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S372, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S373, float3 _S374) +inline __device__ void s_bwd_prop_mul_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S993, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S994, float3 _S995) { - _d_mul_1(_S372, _S373, _S374); + _d_mul_1(_S993, _S994, _S995); return; } inline __device__ void s_bwd_prop_transform_ray_o_0(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * dpR_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpt_0, float3 _s_dOut_0) { - float3 _S375 = - _s_dOut_0; - float3 _S376 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S377; - (&_S377)->primal_0 = (*dpt_0).primal_0; - (&_S377)->differential_0 = _S376; - Matrix _S378 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S379; - (&_S379)->primal_0 = (*dpR_0).primal_0; - (&_S379)->differential_0 = _S378; - s_bwd_prop_mul_0(&_S377, &_S379, _S375); + float3 _S996 = - _s_dOut_0; + float3 _S997 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S998; + (&_S998)->primal_0 = (*dpt_0).primal_0; + (&_S998)->differential_0 = _S997; + Matrix _S999 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1000; + (&_S1000)->primal_0 = (*dpR_0).primal_0; + (&_S1000)->differential_0 = _S999; + s_bwd_prop_mul_0(&_S998, &_S1000, _S996); dpt_0->primal_0 = (*dpt_0).primal_0; - dpt_0->differential_0 = _S377.differential_0; + dpt_0->differential_0 = _S998.differential_0; dpR_0->primal_0 = (*dpR_0).primal_0; - dpR_0->differential_0 = _S379.differential_0; + dpR_0->differential_0 = _S1000.differential_0; return; } -inline __device__ void s_bwd_transform_ray_o_0(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S380, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S381, float3 _S382) +inline __device__ void s_bwd_transform_ray_o_0(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1001, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1002, float3 _S1003) { - s_bwd_prop_transform_ray_o_0(_S380, _S381, _S382); + s_bwd_prop_transform_ray_o_0(_S1001, _S1002, _S1003); return; } inline __device__ void transform_ray_o_vjp(Matrix R_3, float3 t_1, float3 v_ray_o_0, Matrix * v_R_0, float3 * v_t_0) { - Matrix _S383 = makeMatrix (0.0f); + Matrix _S1004 = makeMatrix (0.0f); DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 dp_R_0; (&dp_R_0)->primal_0 = R_3; - (&dp_R_0)->differential_0 = _S383; - float3 _S384 = make_float3 (0.0f); + (&dp_R_0)->differential_0 = _S1004; + float3 _S1005 = make_float3 (0.0f); DiffPair_vectorx3Cfloatx2C3x3E_0 dp_t_0; (&dp_t_0)->primal_0 = t_1; - (&dp_t_0)->differential_0 = _S384; + (&dp_t_0)->differential_0 = _S1005; s_bwd_transform_ray_o_0(&dp_R_0, &dp_t_0, v_ray_o_0); *v_R_0 = dp_R_0.differential_0; *v_t_0 = dp_t_0.differential_0; @@ -1575,38 +4095,38 @@ inline __device__ void transform_ray_o_vjp(Matrix R_3, float3 t_1 inline __device__ void s_bwd_prop_transform_ray_d_0(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * dpR_1, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpraydir_0, float3 _s_dOut_1) { - float3 _S385 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S386; - (&_S386)->primal_0 = (*dpraydir_0).primal_0; - (&_S386)->differential_0 = _S385; - Matrix _S387 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S388; - (&_S388)->primal_0 = (*dpR_1).primal_0; - (&_S388)->differential_0 = _S387; - s_bwd_prop_mul_0(&_S386, &_S388, _s_dOut_1); + float3 _S1006 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1007; + (&_S1007)->primal_0 = (*dpraydir_0).primal_0; + (&_S1007)->differential_0 = _S1006; + Matrix _S1008 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1009; + (&_S1009)->primal_0 = (*dpR_1).primal_0; + (&_S1009)->differential_0 = _S1008; + s_bwd_prop_mul_0(&_S1007, &_S1009, _s_dOut_1); dpraydir_0->primal_0 = (*dpraydir_0).primal_0; - dpraydir_0->differential_0 = _S386.differential_0; + dpraydir_0->differential_0 = _S1007.differential_0; dpR_1->primal_0 = (*dpR_1).primal_0; - dpR_1->differential_0 = _S388.differential_0; + dpR_1->differential_0 = _S1009.differential_0; return; } -inline __device__ void s_bwd_transform_ray_d_0(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S389, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S390, float3 _S391) +inline __device__ void s_bwd_transform_ray_d_0(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1010, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1011, float3 _S1012) { - s_bwd_prop_transform_ray_d_0(_S389, _S390, _S391); + s_bwd_prop_transform_ray_d_0(_S1010, _S1011, _S1012); return; } -inline __device__ void transform_ray_d_vjp(Matrix R_4, float3 raydir_5, float3 v_ray_d_0, Matrix * v_R_1, float3 * v_raydir_0) +inline __device__ void transform_ray_d_vjp(Matrix R_4, float3 raydir_14, float3 v_ray_d_0, Matrix * v_R_1, float3 * v_raydir_0) { - Matrix _S392 = makeMatrix (0.0f); + Matrix _S1013 = makeMatrix (0.0f); DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 dp_R_1; (&dp_R_1)->primal_0 = R_4; - (&dp_R_1)->differential_0 = _S392; - float3 _S393 = make_float3 (0.0f); + (&dp_R_1)->differential_0 = _S1013; + float3 _S1014 = make_float3 (0.0f); DiffPair_vectorx3Cfloatx2C3x3E_0 dp_raydir_0; - (&dp_raydir_0)->primal_0 = raydir_5; - (&dp_raydir_0)->differential_0 = _S393; + (&dp_raydir_0)->primal_0 = raydir_14; + (&dp_raydir_0)->differential_0 = _S1014; s_bwd_transform_ray_d_0(&dp_R_1, &dp_raydir_0, v_ray_d_0); *v_R_1 = dp_R_1.differential_0; *v_raydir_0 = dp_raydir_0.differential_0; @@ -1615,36 +4135,36 @@ inline __device__ void transform_ray_d_vjp(Matrix R_4, float3 ray inline __device__ void _d_exp_0(DiffPair_float_0 * dpx_5, float dOut_4) { - float _S394 = (F32_exp(((*dpx_5).primal_0))) * dOut_4; + float _S1015 = (F32_exp(((*dpx_5).primal_0))) * dOut_4; dpx_5->primal_0 = (*dpx_5).primal_0; - dpx_5->differential_0 = _S394; + dpx_5->differential_0 = _S1015; return; } inline __device__ float3 exp_0(float3 x_12) { float3 result_9; - int i_6 = int(0); + int i_8 = int(0); for(;;) { - if(i_6 < int(3)) + if(i_8 < int(3)) { } else { break; } - *_slang_vector_get_element_ptr(&result_9, i_6) = (F32_exp((_slang_vector_get_element(x_12, i_6)))); - i_6 = i_6 + int(1); + *_slang_vector_get_element_ptr(&result_9, i_8) = (F32_exp((_slang_vector_get_element(x_12, i_8)))); + i_8 = i_8 + int(1); } return result_9; } inline __device__ void _d_exp_vector_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_6, float3 dOut_5) { - float3 _S395 = exp_0((*dpx_6).primal_0) * dOut_5; + float3 _S1016 = exp_0((*dpx_6).primal_0) * dOut_5; dpx_6->primal_0 = (*dpx_6).primal_0; - dpx_6->differential_0 = _S395; + dpx_6->differential_0 = _S1016; return; } @@ -1660,8 +4180,8 @@ inline __device__ Matrix compute_3dgut_iscl_rot(float4 quat_5, fl float wx_5 = quat_5.x * quat_5.y; float wy_5 = quat_5.x * quat_5.z; float wz_5 = quat_5.x * quat_5.w; - float3 _S396 = exp_0(- scale_4); - return mul_1(makeMatrix (_S396.x, 0.0f, 0.0f, 0.0f, _S396.y, 0.0f, 0.0f, 0.0f, _S396.z), transpose_0(transpose_0(makeMatrix (1.0f - 2.0f * (y2_5 + z2_5), 2.0f * (xy_5 + wz_5), 2.0f * (xz_5 - wy_5), 2.0f * (xy_5 - wz_5), 1.0f - 2.0f * (x2_5 + z2_5), 2.0f * (yz_5 + wx_5), 2.0f * (xz_5 + wy_5), 2.0f * (yz_5 - wx_5), 1.0f - 2.0f * (x2_5 + y2_5))))); + float3 _S1017 = exp_0(- scale_4); + return mul_1(makeMatrix (_S1017.x, 0.0f, 0.0f, 0.0f, _S1017.y, 0.0f, 0.0f, 0.0f, _S1017.z), transpose_0(transpose_0(makeMatrix (1.0f - 2.0f * (y2_5 + z2_5), 2.0f * (xy_5 + wz_5), 2.0f * (xz_5 - wy_5), 2.0f * (xy_5 - wz_5), 1.0f - 2.0f * (x2_5 + z2_5), 2.0f * (yz_5 + wx_5), 2.0f * (xz_5 + wy_5), 2.0f * (yz_5 - wx_5), 1.0f - 2.0f * (x2_5 + y2_5))))); } struct DiffPair_vectorx3Cfloatx2C4x3E_0 @@ -1670,27 +4190,27 @@ struct DiffPair_vectorx3Cfloatx2C4x3E_0 float4 differential_0; }; -inline __device__ float3 s_primal_ctx_exp_0(float3 _S397) +inline __device__ float3 s_primal_ctx_exp_0(float3 _S1018) { - return exp_0(_S397); + return exp_0(_S1018); } -inline __device__ void s_bwd_prop_mul_1(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S398, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S399, Matrix _S400) +inline __device__ void s_bwd_prop_mul_1(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1019, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1020, Matrix _S1021) { - mul_0(_S398, _S399, _S400); + mul_0(_S1019, _S1020, _S1021); return; } -inline __device__ void s_bwd_prop_exp_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S401, float3 _S402) +inline __device__ void s_bwd_prop_exp_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1022, float3 _S1023) { - _d_exp_vector_0(_S401, _S402); + _d_exp_vector_0(_S1022, _S1023); return; } inline __device__ void s_bwd_prop_compute_3dgut_iscl_rot_0(DiffPair_vectorx3Cfloatx2C4x3E_0 * dpquat_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpscale_0, Matrix _s_dOut_2) { - float _S403 = (*dpquat_0).primal_0.y; - float x2_6 = _S403 * _S403; + float _S1024 = (*dpquat_0).primal_0.y; + float x2_6 = _S1024 * _S1024; float y2_6 = (*dpquat_0).primal_0.z * (*dpquat_0).primal_0.z; float z2_6 = (*dpquat_0).primal_0.w * (*dpquat_0).primal_0.w; float xy_6 = (*dpquat_0).primal_0.y * (*dpquat_0).primal_0.z; @@ -1699,76 +4219,76 @@ inline __device__ void s_bwd_prop_compute_3dgut_iscl_rot_0(DiffPair_vectorx3Cflo float wx_6 = (*dpquat_0).primal_0.x * (*dpquat_0).primal_0.y; float wy_6 = (*dpquat_0).primal_0.x * (*dpquat_0).primal_0.z; float wz_6 = (*dpquat_0).primal_0.x * (*dpquat_0).primal_0.w; - float3 _S404 = - (*dpscale_0).primal_0; - float3 _S405 = s_primal_ctx_exp_0(_S404); - Matrix _S406 = transpose_0(transpose_0(makeMatrix (1.0f - 2.0f * (y2_6 + z2_6), 2.0f * (xy_6 + wz_6), 2.0f * (xz_6 - wy_6), 2.0f * (xy_6 - wz_6), 1.0f - 2.0f * (x2_6 + z2_6), 2.0f * (yz_6 + wx_6), 2.0f * (xz_6 + wy_6), 2.0f * (yz_6 - wx_6), 1.0f - 2.0f * (x2_6 + y2_6)))); - Matrix _S407 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S408; - (&_S408)->primal_0 = makeMatrix (_S405.x, 0.0f, 0.0f, 0.0f, _S405.y, 0.0f, 0.0f, 0.0f, _S405.z); - (&_S408)->differential_0 = _S407; - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S409; - (&_S409)->primal_0 = _S406; - (&_S409)->differential_0 = _S407; - s_bwd_prop_mul_1(&_S408, &_S409, _s_dOut_2); - Matrix _S410 = transpose_0(_S409.differential_0); - float3 _S411 = make_float3 (_S408.differential_0.rows[int(0)].x, _S408.differential_0.rows[int(1)].y, _S408.differential_0.rows[int(2)].z); - float3 _S412 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S413; - (&_S413)->primal_0 = _S404; - (&_S413)->differential_0 = _S412; - s_bwd_prop_exp_0(&_S413, _S411); - float3 _S414 = - _S413.differential_0; - Matrix _S415 = transpose_0(_S410); - float _S416 = 2.0f * - _S415.rows[int(2)].z; - float _S417 = 2.0f * _S415.rows[int(2)].y; - float _S418 = 2.0f * _S415.rows[int(2)].x; - float _S419 = 2.0f * _S415.rows[int(1)].z; - float _S420 = 2.0f * - _S415.rows[int(1)].y; - float _S421 = 2.0f * _S415.rows[int(1)].x; - float _S422 = 2.0f * _S415.rows[int(0)].z; - float _S423 = 2.0f * _S415.rows[int(0)].y; - float _S424 = 2.0f * - _S415.rows[int(0)].x; - float _S425 = - _S421 + _S423; - float _S426 = _S418 + - _S422; - float _S427 = - _S417 + _S419; - float _S428 = _S417 + _S419; - float _S429 = _S418 + _S422; - float _S430 = _S421 + _S423; - float _S431 = (*dpquat_0).primal_0.w * (_S420 + _S424); - float _S432 = (*dpquat_0).primal_0.z * (_S416 + _S424); - float _S433 = (*dpquat_0).primal_0.y * (_S416 + _S420); - float _S434 = (*dpquat_0).primal_0.x * _S425 + (*dpquat_0).primal_0.z * _S428 + (*dpquat_0).primal_0.y * _S429 + _S431 + _S431; - float _S435 = (*dpquat_0).primal_0.x * _S426 + (*dpquat_0).primal_0.w * _S428 + (*dpquat_0).primal_0.y * _S430 + _S432 + _S432; - float _S436 = (*dpquat_0).primal_0.x * _S427 + (*dpquat_0).primal_0.w * _S429 + (*dpquat_0).primal_0.z * _S430 + _S433 + _S433; - float _S437 = (*dpquat_0).primal_0.w * _S425 + (*dpquat_0).primal_0.z * _S426 + (*dpquat_0).primal_0.y * _S427; + float3 _S1025 = - (*dpscale_0).primal_0; + float3 _S1026 = s_primal_ctx_exp_0(_S1025); + Matrix _S1027 = transpose_0(transpose_0(makeMatrix (1.0f - 2.0f * (y2_6 + z2_6), 2.0f * (xy_6 + wz_6), 2.0f * (xz_6 - wy_6), 2.0f * (xy_6 - wz_6), 1.0f - 2.0f * (x2_6 + z2_6), 2.0f * (yz_6 + wx_6), 2.0f * (xz_6 + wy_6), 2.0f * (yz_6 - wx_6), 1.0f - 2.0f * (x2_6 + y2_6)))); + Matrix _S1028 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1029; + (&_S1029)->primal_0 = makeMatrix (_S1026.x, 0.0f, 0.0f, 0.0f, _S1026.y, 0.0f, 0.0f, 0.0f, _S1026.z); + (&_S1029)->differential_0 = _S1028; + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1030; + (&_S1030)->primal_0 = _S1027; + (&_S1030)->differential_0 = _S1028; + s_bwd_prop_mul_1(&_S1029, &_S1030, _s_dOut_2); + Matrix _S1031 = transpose_0(_S1030.differential_0); + float3 _S1032 = make_float3 (_S1029.differential_0.rows[int(0)].x, _S1029.differential_0.rows[int(1)].y, _S1029.differential_0.rows[int(2)].z); + float3 _S1033 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1034; + (&_S1034)->primal_0 = _S1025; + (&_S1034)->differential_0 = _S1033; + s_bwd_prop_exp_0(&_S1034, _S1032); + float3 _S1035 = - _S1034.differential_0; + Matrix _S1036 = transpose_0(_S1031); + float _S1037 = 2.0f * - _S1036.rows[int(2)].z; + float _S1038 = 2.0f * _S1036.rows[int(2)].y; + float _S1039 = 2.0f * _S1036.rows[int(2)].x; + float _S1040 = 2.0f * _S1036.rows[int(1)].z; + float _S1041 = 2.0f * - _S1036.rows[int(1)].y; + float _S1042 = 2.0f * _S1036.rows[int(1)].x; + float _S1043 = 2.0f * _S1036.rows[int(0)].z; + float _S1044 = 2.0f * _S1036.rows[int(0)].y; + float _S1045 = 2.0f * - _S1036.rows[int(0)].x; + float _S1046 = - _S1042 + _S1044; + float _S1047 = _S1039 + - _S1043; + float _S1048 = - _S1038 + _S1040; + float _S1049 = _S1038 + _S1040; + float _S1050 = _S1039 + _S1043; + float _S1051 = _S1042 + _S1044; + float _S1052 = (*dpquat_0).primal_0.w * (_S1041 + _S1045); + float _S1053 = (*dpquat_0).primal_0.z * (_S1037 + _S1045); + float _S1054 = (*dpquat_0).primal_0.y * (_S1037 + _S1041); + float _S1055 = (*dpquat_0).primal_0.x * _S1046 + (*dpquat_0).primal_0.z * _S1049 + (*dpquat_0).primal_0.y * _S1050 + _S1052 + _S1052; + float _S1056 = (*dpquat_0).primal_0.x * _S1047 + (*dpquat_0).primal_0.w * _S1049 + (*dpquat_0).primal_0.y * _S1051 + _S1053 + _S1053; + float _S1057 = (*dpquat_0).primal_0.x * _S1048 + (*dpquat_0).primal_0.w * _S1050 + (*dpquat_0).primal_0.z * _S1051 + _S1054 + _S1054; + float _S1058 = (*dpquat_0).primal_0.w * _S1046 + (*dpquat_0).primal_0.z * _S1047 + (*dpquat_0).primal_0.y * _S1048; dpscale_0->primal_0 = (*dpscale_0).primal_0; - dpscale_0->differential_0 = _S414; - float4 _S438 = make_float4 (0.0f); - *&((&_S438)->w) = _S434; - *&((&_S438)->z) = _S435; - *&((&_S438)->y) = _S436; - *&((&_S438)->x) = _S437; + dpscale_0->differential_0 = _S1035; + float4 _S1059 = make_float4 (0.0f); + *&((&_S1059)->w) = _S1055; + *&((&_S1059)->z) = _S1056; + *&((&_S1059)->y) = _S1057; + *&((&_S1059)->x) = _S1058; dpquat_0->primal_0 = (*dpquat_0).primal_0; - dpquat_0->differential_0 = _S438; + dpquat_0->differential_0 = _S1059; return; } -inline __device__ void s_bwd_compute_3dgut_iscl_rot_0(DiffPair_vectorx3Cfloatx2C4x3E_0 * _S439, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S440, Matrix _S441) +inline __device__ void s_bwd_compute_3dgut_iscl_rot_0(DiffPair_vectorx3Cfloatx2C4x3E_0 * _S1060, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1061, Matrix _S1062) { - s_bwd_prop_compute_3dgut_iscl_rot_0(_S439, _S440, _S441); + s_bwd_prop_compute_3dgut_iscl_rot_0(_S1060, _S1061, _S1062); return; } inline __device__ void compute_3dgut_iscl_rot_vjp(float4 quat_6, float3 scale_5, Matrix v_iscl_rot_0, float4 * v_quat_0, float3 * v_scale_0) { - float4 _S442 = make_float4 (0.0f); + float4 _S1063 = make_float4 (0.0f); DiffPair_vectorx3Cfloatx2C4x3E_0 dp_quat_0; (&dp_quat_0)->primal_0 = quat_6; - (&dp_quat_0)->differential_0 = _S442; - float3 _S443 = make_float3 (0.0f); + (&dp_quat_0)->differential_0 = _S1063; + float3 _S1064 = make_float3 (0.0f); DiffPair_vectorx3Cfloatx2C3x3E_0 dp_scale_0; (&dp_scale_0)->primal_0 = scale_5; - (&dp_scale_0)->differential_0 = _S443; + (&dp_scale_0)->differential_0 = _S1064; s_bwd_compute_3dgut_iscl_rot_0(&dp_quat_0, &dp_scale_0, v_iscl_rot_0); *v_quat_0 = dp_quat_0.differential_0; *v_scale_0 = dp_scale_0.differential_0; @@ -1777,182 +4297,182 @@ inline __device__ void compute_3dgut_iscl_rot_vjp(float4 quat_6, float3 scale_ inline __device__ void _d_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * a_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * b_0, float3 dOut_6) { - float _S444 = dOut_6.y; - float _S445 = dOut_6.z; - float _S446 = dOut_6.x; - float _S447 = (*a_0).primal_0.z * _S444 + - (*a_0).primal_0.y * _S445; - float _S448 = - (*a_0).primal_0.z * _S446 + (*a_0).primal_0.x * _S445; - float _S449 = (*a_0).primal_0.y * _S446 + - (*a_0).primal_0.x * _S444; - float3 _S450 = make_float3 (- (*b_0).primal_0.z * _S444 + (*b_0).primal_0.y * _S445, (*b_0).primal_0.z * _S446 + - (*b_0).primal_0.x * _S445, - (*b_0).primal_0.y * _S446 + (*b_0).primal_0.x * _S444); + float _S1065 = dOut_6.y; + float _S1066 = dOut_6.z; + float _S1067 = dOut_6.x; + float _S1068 = (*a_0).primal_0.z * _S1065 + - (*a_0).primal_0.y * _S1066; + float _S1069 = - (*a_0).primal_0.z * _S1067 + (*a_0).primal_0.x * _S1066; + float _S1070 = (*a_0).primal_0.y * _S1067 + - (*a_0).primal_0.x * _S1065; + float3 _S1071 = make_float3 (- (*b_0).primal_0.z * _S1065 + (*b_0).primal_0.y * _S1066, (*b_0).primal_0.z * _S1067 + - (*b_0).primal_0.x * _S1066, - (*b_0).primal_0.y * _S1067 + (*b_0).primal_0.x * _S1065); a_0->primal_0 = (*a_0).primal_0; - a_0->differential_0 = _S450; - float3 _S451 = make_float3 (_S447, _S448, _S449); + a_0->differential_0 = _S1071; + float3 _S1072 = make_float3 (_S1068, _S1069, _S1070); b_0->primal_0 = (*b_0).primal_0; - b_0->differential_0 = _S451; + b_0->differential_0 = _S1072; return; } inline __device__ float3 cross_0(float3 left_6, float3 right_6) { - float _S452 = left_6.y; - float _S453 = right_6.z; - float _S454 = left_6.z; - float _S455 = right_6.y; - float _S456 = right_6.x; - float _S457 = left_6.x; - return make_float3 (_S452 * _S453 - _S454 * _S455, _S454 * _S456 - _S457 * _S453, _S457 * _S455 - _S452 * _S456); + float _S1073 = left_6.y; + float _S1074 = right_6.z; + float _S1075 = left_6.z; + float _S1076 = right_6.y; + float _S1077 = right_6.x; + float _S1078 = left_6.x; + return make_float3 (_S1073 * _S1074 - _S1075 * _S1076, _S1075 * _S1077 - _S1078 * _S1074, _S1078 * _S1076 - _S1073 * _S1077); } inline __device__ float evaluate_alpha_3dgs(float3 mean_0, Matrix iscl_rot_0, float opacity_0, float3 ray_o_0, float3 ray_d_0) { float3 grd_0 = mul_2(iscl_rot_0, ray_d_0); float3 gcrod_0 = cross_0(grd_0, mul_2(iscl_rot_0, ray_o_0 - mean_0)); - return opacity_0 * (F32_exp((-0.5f * dot_0(gcrod_0, gcrod_0) / dot_0(grd_0, grd_0)))); + return opacity_0 * (F32_exp((-0.5f * dot_1(gcrod_0, gcrod_0) / dot_1(grd_0, grd_0)))); } -inline __device__ float3 s_primal_ctx_mul_0(Matrix _S458, float3 _S459) +inline __device__ float3 s_primal_ctx_mul_0(Matrix _S1079, float3 _S1080) { - return mul_2(_S458, _S459); + return mul_2(_S1079, _S1080); } -inline __device__ float3 s_primal_ctx_cross_0(float3 _S460, float3 _S461) +inline __device__ float3 s_primal_ctx_cross_0(float3 _S1081, float3 _S1082) { - return cross_0(_S460, _S461); + return cross_0(_S1081, _S1082); } -inline __device__ float s_primal_ctx_dot_0(float3 _S462, float3 _S463) +inline __device__ float s_primal_ctx_dot_0(float3 _S1083, float3 _S1084) { - return dot_0(_S462, _S463); + return dot_1(_S1083, _S1084); } -inline __device__ float s_primal_ctx_exp_1(float _S464) +inline __device__ float s_primal_ctx_exp_1(float _S1085) { - return (F32_exp((_S464))); + return (F32_exp((_S1085))); } -inline __device__ void s_bwd_prop_exp_1(DiffPair_float_0 * _S465, float _S466) +inline __device__ void s_bwd_prop_exp_1(DiffPair_float_0 * _S1086, float _S1087) { - _d_exp_0(_S465, _S466); + _d_exp_0(_S1086, _S1087); return; } -inline __device__ void s_bwd_prop_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S467, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S468, float _S469) +inline __device__ void s_bwd_prop_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1088, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1089, float _S1090) { - _d_dot_0(_S467, _S468, _S469); + _d_dot_0(_S1088, _S1089, _S1090); return; } -inline __device__ void s_bwd_prop_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S470, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S471, float3 _S472) +inline __device__ void s_bwd_prop_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1091, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1092, float3 _S1093) { - _d_cross_0(_S470, _S471, _S472); + _d_cross_0(_S1091, _S1092, _S1093); return; } -inline __device__ void s_bwd_prop_mul_2(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S473, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S474, float3 _S475) +inline __device__ void s_bwd_prop_mul_2(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1094, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1095, float3 _S1096) { - _d_mul_0(_S473, _S474, _S475); + _d_mul_0(_S1094, _S1095, _S1096); return; } inline __device__ void s_bwd_prop_evaluate_alpha_3dgs_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpmean_0, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * dpiscl_rot_0, DiffPair_float_0 * dpopacity_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpray_o_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpray_d_0, float _s_dOut_3) { - float3 _S476 = (*dpray_o_0).primal_0 - (*dpmean_0).primal_0; - float3 _S477 = s_primal_ctx_mul_0((*dpiscl_rot_0).primal_0, _S476); - float3 _S478 = s_primal_ctx_mul_0((*dpiscl_rot_0).primal_0, (*dpray_d_0).primal_0); - float3 _S479 = s_primal_ctx_cross_0(_S478, _S477); - float _S480 = -0.5f * s_primal_ctx_dot_0(_S479, _S479); - float _S481 = s_primal_ctx_dot_0(_S478, _S478); - float _S482 = _S480 / _S481; - float _S483 = _S481 * _S481; - float _S484 = (*dpopacity_0).primal_0 * _s_dOut_3; - float _S485 = s_primal_ctx_exp_1(_S482) * _s_dOut_3; - DiffPair_float_0 _S486; - (&_S486)->primal_0 = _S482; - (&_S486)->differential_0 = 0.0f; - s_bwd_prop_exp_1(&_S486, _S484); - float _S487 = _S486.differential_0 / _S483; - float _S488 = _S480 * - _S487; - float _S489 = _S481 * _S487; - float3 _S490 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S491; - (&_S491)->primal_0 = _S478; - (&_S491)->differential_0 = _S490; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S492; - (&_S492)->primal_0 = _S478; - (&_S492)->differential_0 = _S490; - s_bwd_prop_dot_0(&_S491, &_S492, _S488); - float _S493 = -0.5f * _S489; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S494; - (&_S494)->primal_0 = _S479; - (&_S494)->differential_0 = _S490; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S495; - (&_S495)->primal_0 = _S479; - (&_S495)->differential_0 = _S490; - s_bwd_prop_dot_0(&_S494, &_S495, _S493); - float3 _S496 = _S495.differential_0 + _S494.differential_0; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S497; - (&_S497)->primal_0 = _S478; - (&_S497)->differential_0 = _S490; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S498; - (&_S498)->primal_0 = _S477; - (&_S498)->differential_0 = _S490; - s_bwd_prop_cross_0(&_S497, &_S498, _S496); - float3 _S499 = _S492.differential_0 + _S491.differential_0 + _S497.differential_0; - Matrix _S500 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S501; - (&_S501)->primal_0 = (*dpiscl_rot_0).primal_0; - (&_S501)->differential_0 = _S500; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S502; - (&_S502)->primal_0 = (*dpray_d_0).primal_0; - (&_S502)->differential_0 = _S490; - s_bwd_prop_mul_2(&_S501, &_S502, _S499); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S503; - (&_S503)->primal_0 = (*dpiscl_rot_0).primal_0; - (&_S503)->differential_0 = _S500; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S504; - (&_S504)->primal_0 = _S476; - (&_S504)->differential_0 = _S490; - s_bwd_prop_mul_2(&_S503, &_S504, _S498.differential_0); - float3 _S505 = - _S504.differential_0; + float3 _S1097 = (*dpray_o_0).primal_0 - (*dpmean_0).primal_0; + float3 _S1098 = s_primal_ctx_mul_0((*dpiscl_rot_0).primal_0, _S1097); + float3 _S1099 = s_primal_ctx_mul_0((*dpiscl_rot_0).primal_0, (*dpray_d_0).primal_0); + float3 _S1100 = s_primal_ctx_cross_0(_S1099, _S1098); + float _S1101 = -0.5f * s_primal_ctx_dot_0(_S1100, _S1100); + float _S1102 = s_primal_ctx_dot_0(_S1099, _S1099); + float _S1103 = _S1101 / _S1102; + float _S1104 = _S1102 * _S1102; + float _S1105 = (*dpopacity_0).primal_0 * _s_dOut_3; + float _S1106 = s_primal_ctx_exp_1(_S1103) * _s_dOut_3; + DiffPair_float_0 _S1107; + (&_S1107)->primal_0 = _S1103; + (&_S1107)->differential_0 = 0.0f; + s_bwd_prop_exp_1(&_S1107, _S1105); + float _S1108 = _S1107.differential_0 / _S1104; + float _S1109 = _S1101 * - _S1108; + float _S1110 = _S1102 * _S1108; + float3 _S1111 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1112; + (&_S1112)->primal_0 = _S1099; + (&_S1112)->differential_0 = _S1111; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1113; + (&_S1113)->primal_0 = _S1099; + (&_S1113)->differential_0 = _S1111; + s_bwd_prop_dot_0(&_S1112, &_S1113, _S1109); + float _S1114 = -0.5f * _S1110; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1115; + (&_S1115)->primal_0 = _S1100; + (&_S1115)->differential_0 = _S1111; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1116; + (&_S1116)->primal_0 = _S1100; + (&_S1116)->differential_0 = _S1111; + s_bwd_prop_dot_0(&_S1115, &_S1116, _S1114); + float3 _S1117 = _S1116.differential_0 + _S1115.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1118; + (&_S1118)->primal_0 = _S1099; + (&_S1118)->differential_0 = _S1111; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1119; + (&_S1119)->primal_0 = _S1098; + (&_S1119)->differential_0 = _S1111; + s_bwd_prop_cross_0(&_S1118, &_S1119, _S1117); + float3 _S1120 = _S1113.differential_0 + _S1112.differential_0 + _S1118.differential_0; + Matrix _S1121 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1122; + (&_S1122)->primal_0 = (*dpiscl_rot_0).primal_0; + (&_S1122)->differential_0 = _S1121; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1123; + (&_S1123)->primal_0 = (*dpray_d_0).primal_0; + (&_S1123)->differential_0 = _S1111; + s_bwd_prop_mul_2(&_S1122, &_S1123, _S1120); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1124; + (&_S1124)->primal_0 = (*dpiscl_rot_0).primal_0; + (&_S1124)->differential_0 = _S1121; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1125; + (&_S1125)->primal_0 = _S1097; + (&_S1125)->differential_0 = _S1111; + s_bwd_prop_mul_2(&_S1124, &_S1125, _S1119.differential_0); + float3 _S1126 = - _S1125.differential_0; dpray_d_0->primal_0 = (*dpray_d_0).primal_0; - dpray_d_0->differential_0 = _S502.differential_0; + dpray_d_0->differential_0 = _S1123.differential_0; dpray_o_0->primal_0 = (*dpray_o_0).primal_0; - dpray_o_0->differential_0 = _S504.differential_0; + dpray_o_0->differential_0 = _S1125.differential_0; dpopacity_0->primal_0 = (*dpopacity_0).primal_0; - dpopacity_0->differential_0 = _S485; - Matrix _S506 = _S501.differential_0 + _S503.differential_0; + dpopacity_0->differential_0 = _S1106; + Matrix _S1127 = _S1122.differential_0 + _S1124.differential_0; dpiscl_rot_0->primal_0 = (*dpiscl_rot_0).primal_0; - dpiscl_rot_0->differential_0 = _S506; + dpiscl_rot_0->differential_0 = _S1127; dpmean_0->primal_0 = (*dpmean_0).primal_0; - dpmean_0->differential_0 = _S505; + dpmean_0->differential_0 = _S1126; return; } -inline __device__ void s_bwd_evaluate_alpha_3dgs_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S507, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S508, DiffPair_float_0 * _S509, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S510, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S511, float _S512) +inline __device__ void s_bwd_evaluate_alpha_3dgs_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1128, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1129, DiffPair_float_0 * _S1130, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1131, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1132, float _S1133) { - s_bwd_prop_evaluate_alpha_3dgs_0(_S507, _S508, _S509, _S510, _S511, _S512); + s_bwd_prop_evaluate_alpha_3dgs_0(_S1128, _S1129, _S1130, _S1131, _S1132, _S1133); return; } inline __device__ void evaluate_alpha_3dgs_vjp(float3 mean_1, Matrix iscl_rot_1, float opacity_1, float3 ray_o_1, float3 ray_d_1, float v_alpha_0, float3 * v_mean_0, Matrix * v_iscl_rot_1, float * v_opacity_0, float3 * v_ray_o_1, float3 * v_ray_d_1) { - float3 _S513 = make_float3 (0.0f); + float3 _S1134 = make_float3 (0.0f); DiffPair_vectorx3Cfloatx2C3x3E_0 dp_mean_0; (&dp_mean_0)->primal_0 = mean_1; - (&dp_mean_0)->differential_0 = _S513; - Matrix _S514 = makeMatrix (0.0f); + (&dp_mean_0)->differential_0 = _S1134; + Matrix _S1135 = makeMatrix (0.0f); DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 dp_iscl_rot_0; (&dp_iscl_rot_0)->primal_0 = iscl_rot_1; - (&dp_iscl_rot_0)->differential_0 = _S514; + (&dp_iscl_rot_0)->differential_0 = _S1135; DiffPair_float_0 dp_opacity_0; (&dp_opacity_0)->primal_0 = opacity_1; (&dp_opacity_0)->differential_0 = 0.0f; DiffPair_vectorx3Cfloatx2C3x3E_0 dp_ray_o_0; (&dp_ray_o_0)->primal_0 = ray_o_1; - (&dp_ray_o_0)->differential_0 = _S513; + (&dp_ray_o_0)->differential_0 = _S1134; DiffPair_vectorx3Cfloatx2C3x3E_0 dp_ray_d_0; (&dp_ray_d_0)->primal_0 = ray_d_1; - (&dp_ray_d_0)->differential_0 = _S513; + (&dp_ray_d_0)->differential_0 = _S1134; s_bwd_evaluate_alpha_3dgs_0(&dp_mean_0, &dp_iscl_rot_0, &dp_opacity_0, &dp_ray_o_0, &dp_ray_d_0, v_alpha_0); *v_mean_0 = dp_mean_0.differential_0; *v_iscl_rot_1 = dp_iscl_rot_0.differential_0; @@ -1966,96 +4486,96 @@ inline __device__ void evaluate_color_3dgs(float3 mean_2, Matrix { *out_rgb_0 = rgb_0; float3 grd_1 = mul_2(iscl_rot_2, ray_d_2); - *depth_0 = - dot_0(mul_2(iscl_rot_2, ray_o_2 - mean_2), grd_1) / dot_0(grd_1, grd_1); + *depth_0 = - dot_1(mul_2(iscl_rot_2, ray_o_2 - mean_2), grd_1) / dot_1(grd_1, grd_1); return; } inline __device__ void s_bwd_prop_evaluate_color_3dgs_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpmean_1, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * dpiscl_rot_1, DiffPair_float_0 * dpopacity_1, DiffPair_vectorx3Cfloatx2C3x3E_0 * dprgb_0, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpray_o_1, DiffPair_vectorx3Cfloatx2C3x3E_0 * dpray_d_1, float3 dpout_rgb_0, float dpdepth_0) { - float3 _S515 = (*dpray_o_1).primal_0 - (*dpmean_1).primal_0; - float3 _S516 = s_primal_ctx_mul_0((*dpiscl_rot_1).primal_0, _S515); - float3 _S517 = s_primal_ctx_mul_0((*dpiscl_rot_1).primal_0, (*dpray_d_1).primal_0); - float _S518 = s_primal_ctx_dot_0(_S517, _S517); - float _S519 = dpdepth_0 / (_S518 * _S518); - float _S520 = - s_primal_ctx_dot_0(_S516, _S517) * - _S519; - float _S521 = _S518 * _S519; - float3 _S522 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S523; - (&_S523)->primal_0 = _S517; - (&_S523)->differential_0 = _S522; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S524; - (&_S524)->primal_0 = _S517; - (&_S524)->differential_0 = _S522; - s_bwd_prop_dot_0(&_S523, &_S524, _S520); - float _S525 = - _S521; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S526; - (&_S526)->primal_0 = _S516; - (&_S526)->differential_0 = _S522; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S527; - (&_S527)->primal_0 = _S517; - (&_S527)->differential_0 = _S522; - s_bwd_prop_dot_0(&_S526, &_S527, _S525); - float3 _S528 = _S524.differential_0 + _S523.differential_0 + _S527.differential_0; - Matrix _S529 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S530; - (&_S530)->primal_0 = (*dpiscl_rot_1).primal_0; - (&_S530)->differential_0 = _S529; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S531; - (&_S531)->primal_0 = (*dpray_d_1).primal_0; - (&_S531)->differential_0 = _S522; - s_bwd_prop_mul_2(&_S530, &_S531, _S528); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S532; - (&_S532)->primal_0 = (*dpiscl_rot_1).primal_0; - (&_S532)->differential_0 = _S529; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S533; - (&_S533)->primal_0 = _S515; - (&_S533)->differential_0 = _S522; - s_bwd_prop_mul_2(&_S532, &_S533, _S526.differential_0); - float3 _S534 = - _S533.differential_0; + float3 _S1136 = (*dpray_o_1).primal_0 - (*dpmean_1).primal_0; + float3 _S1137 = s_primal_ctx_mul_0((*dpiscl_rot_1).primal_0, _S1136); + float3 _S1138 = s_primal_ctx_mul_0((*dpiscl_rot_1).primal_0, (*dpray_d_1).primal_0); + float _S1139 = s_primal_ctx_dot_0(_S1138, _S1138); + float _S1140 = dpdepth_0 / (_S1139 * _S1139); + float _S1141 = - s_primal_ctx_dot_0(_S1137, _S1138) * - _S1140; + float _S1142 = _S1139 * _S1140; + float3 _S1143 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1144; + (&_S1144)->primal_0 = _S1138; + (&_S1144)->differential_0 = _S1143; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1145; + (&_S1145)->primal_0 = _S1138; + (&_S1145)->differential_0 = _S1143; + s_bwd_prop_dot_0(&_S1144, &_S1145, _S1141); + float _S1146 = - _S1142; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1147; + (&_S1147)->primal_0 = _S1137; + (&_S1147)->differential_0 = _S1143; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1148; + (&_S1148)->primal_0 = _S1138; + (&_S1148)->differential_0 = _S1143; + s_bwd_prop_dot_0(&_S1147, &_S1148, _S1146); + float3 _S1149 = _S1145.differential_0 + _S1144.differential_0 + _S1148.differential_0; + Matrix _S1150 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1151; + (&_S1151)->primal_0 = (*dpiscl_rot_1).primal_0; + (&_S1151)->differential_0 = _S1150; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1152; + (&_S1152)->primal_0 = (*dpray_d_1).primal_0; + (&_S1152)->differential_0 = _S1143; + s_bwd_prop_mul_2(&_S1151, &_S1152, _S1149); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S1153; + (&_S1153)->primal_0 = (*dpiscl_rot_1).primal_0; + (&_S1153)->differential_0 = _S1150; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1154; + (&_S1154)->primal_0 = _S1136; + (&_S1154)->differential_0 = _S1143; + s_bwd_prop_mul_2(&_S1153, &_S1154, _S1147.differential_0); + float3 _S1155 = - _S1154.differential_0; dpray_d_1->primal_0 = (*dpray_d_1).primal_0; - dpray_d_1->differential_0 = _S531.differential_0; + dpray_d_1->differential_0 = _S1152.differential_0; dpray_o_1->primal_0 = (*dpray_o_1).primal_0; - dpray_o_1->differential_0 = _S533.differential_0; + dpray_o_1->differential_0 = _S1154.differential_0; dprgb_0->primal_0 = (*dprgb_0).primal_0; dprgb_0->differential_0 = dpout_rgb_0; dpopacity_1->primal_0 = (*dpopacity_1).primal_0; dpopacity_1->differential_0 = 0.0f; - Matrix _S535 = _S530.differential_0 + _S532.differential_0; + Matrix _S1156 = _S1151.differential_0 + _S1153.differential_0; dpiscl_rot_1->primal_0 = (*dpiscl_rot_1).primal_0; - dpiscl_rot_1->differential_0 = _S535; + dpiscl_rot_1->differential_0 = _S1156; dpmean_1->primal_0 = (*dpmean_1).primal_0; - dpmean_1->differential_0 = _S534; + dpmean_1->differential_0 = _S1155; return; } -inline __device__ void s_bwd_evaluate_color_3dgs_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S536, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S537, DiffPair_float_0 * _S538, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S539, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S540, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S541, float3 _S542, float _S543) +inline __device__ void s_bwd_evaluate_color_3dgs_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1157, DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S1158, DiffPair_float_0 * _S1159, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1160, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1161, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S1162, float3 _S1163, float _S1164) { - s_bwd_prop_evaluate_color_3dgs_0(_S536, _S537, _S538, _S539, _S540, _S541, _S542, _S543); + s_bwd_prop_evaluate_color_3dgs_0(_S1157, _S1158, _S1159, _S1160, _S1161, _S1162, _S1163, _S1164); return; } inline __device__ void evaluate_color_3dgs_vjp(float3 mean_3, Matrix iscl_rot_3, float opacity_3, float3 rgb_1, float3 ray_o_3, float3 ray_d_3, float3 v_out_rgb_0, float v_depth_0, float3 * v_mean_1, Matrix * v_iscl_rot_2, float * v_opacity_1, float3 * v_rgb_0, float3 * v_ray_o_2, float3 * v_ray_d_2) { - float3 _S544 = make_float3 (0.0f); + float3 _S1165 = make_float3 (0.0f); DiffPair_vectorx3Cfloatx2C3x3E_0 dp_mean_1; (&dp_mean_1)->primal_0 = mean_3; - (&dp_mean_1)->differential_0 = _S544; - Matrix _S545 = makeMatrix (0.0f); + (&dp_mean_1)->differential_0 = _S1165; + Matrix _S1166 = makeMatrix (0.0f); DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 dp_iscl_rot_1; (&dp_iscl_rot_1)->primal_0 = iscl_rot_3; - (&dp_iscl_rot_1)->differential_0 = _S545; + (&dp_iscl_rot_1)->differential_0 = _S1166; DiffPair_float_0 dp_opacity_1; (&dp_opacity_1)->primal_0 = opacity_3; (&dp_opacity_1)->differential_0 = 0.0f; DiffPair_vectorx3Cfloatx2C3x3E_0 dp_rgb_0; (&dp_rgb_0)->primal_0 = rgb_1; - (&dp_rgb_0)->differential_0 = _S544; + (&dp_rgb_0)->differential_0 = _S1165; DiffPair_vectorx3Cfloatx2C3x3E_0 dp_ray_o_1; (&dp_ray_o_1)->primal_0 = ray_o_3; - (&dp_ray_o_1)->differential_0 = _S544; + (&dp_ray_o_1)->differential_0 = _S1165; DiffPair_vectorx3Cfloatx2C3x3E_0 dp_ray_d_1; (&dp_ray_d_1)->primal_0 = ray_d_3; - (&dp_ray_d_1)->differential_0 = _S544; + (&dp_ray_d_1)->differential_0 = _S1165; s_bwd_evaluate_color_3dgs_0(&dp_mean_1, &dp_iscl_rot_1, &dp_opacity_1, &dp_rgb_0, &dp_ray_o_1, &dp_ray_d_1, v_out_rgb_0, v_depth_0); *v_mean_1 = dp_mean_1.differential_0; *v_iscl_rot_2 = dp_iscl_rot_1.differential_0; diff --git a/src/i18n/catalog/Data.h b/src/i18n/catalog/Data.h index e63f6a99..c9ec89ad 100644 --- a/src/i18n/catalog/Data.h +++ b/src/i18n/catalog/Data.h @@ -117,6 +117,161 @@ SS_MSG(equirect_not_2to1, TR("EQUIRECTANGULAR kamera {0} {1}x{2} boyutunda, yani 2:1 değil. Motor tam " "bir 360x180 panorama varsaydığı için dikey ölçeği yanlış alacak.")); +SS_MSG(camera_model_fitted, + EN("no exact match here for the {0} camera model ({1} in this dataset); " + "fitted as {2} with {3} distortion, max error {4} px. Its images are " + "re-distorted to match."), + JA("{0} カメラモデル(このデータセットに {1} 台)には厳密に一致するものがないため、" + "{2} と {3} 歪みで近似しました(最大誤差 {4} px)。画像はそれに合わせて" + "再歪曲されます。"), + ZH_HANS("{0} 相机模型(本数据集中 {1} 台)没有精确对应的模型,已用 {2} 与 {3} " + "畸变拟合,最大误差 {4} 像素。其图像会相应重新畸变。"), + ZH_HANT("{0} 相機模型(本資料集中 {1} 台)沒有精確對應的模型,已用 {2} 與 {3} " + "畸變擬合,最大誤差 {4} 像素。其影像會相應重新畸變。"), + KO("{0} 카메라 모델(이 데이터셋에 {1} 대)은 정확히 일치하는 모델이 없어 {2} 와 " + "{3} 왜곡으로 근사했습니다. 최대 오차 {4} px. 해당 이미지는 그에 맞게 다시 " + "왜곡됩니다."), + ES("el modelo de cámara {0} ({1} en este conjunto) no tiene equivalente " + "exacto; ajustado como {2} con distorsión {3}, error máximo {4} px. Sus " + "imágenes se redistorsionan."), + FR("le modèle de caméra {0} ({1} dans ce jeu de données) n'a pas " + "d'équivalent exact ; ajusté en {2} avec la distorsion {3}, erreur " + "maximale {4} px. Ses images sont redistordues."), + DE("für das Kameramodell {0} ({1} in diesem Datensatz) gibt es hier keine " + "exakte Entsprechung; angepasst als {2} mit {3}-Verzeichnung, maximaler " + "Fehler {4} px. Ihre Bilder werden entsprechend neu verzeichnet."), + PT("o modelo de câmera {0} ({1} neste conjunto) não tem equivalente exato; " + "ajustado como {2} com distorção {3}, erro máximo {4} px. As imagens são " + "redistorcidas."), + IT("il modello di camera {0} ({1} in questo dataset) non ha un equivalente " + "esatto; approssimato come {2} con distorsione {3}, errore massimo {4} " + "px. Le immagini vengono ridistorte di conseguenza."), + NL("het cameramodel {0} ({1} in deze dataset) heeft hier geen exacte " + "tegenhanger; benaderd als {2} met {3}-vervorming, maximale fout {4} px. " + "De beelden worden opnieuw vervormd."), + RU("модель камеры {0} ({1} в этом наборе) не имеет точного соответствия; " + "приближена как {2} с искажением {3}, максимальная ошибка {4} пикс. Её " + "изображения переискажаются соответственно."), + TR("{0} kamera modeli (bu veri kumesinde {1} adet) icin birebir karsilik " + "yok; {2} ve {3} bozulmasi ile yaklasildi, en buyuk hata {4} px. " + "Goruntuleri buna gore yeniden bozuluyor.")); + +SS_MSG(camera_model_fitted_exact, + EN("no exact match here for the {0} camera model ({1} in this dataset); " + "fitted as {2} with {3} distortion to within {4} px, so its images are " + "used as they are."), + JA("{0} カメラモデル(このデータセットに {1} 台)には厳密に一致するものがないため、" + "{2} と {3} 歪みで近似しました(誤差 {4} px 以内)。画像はそのまま使います。"), + ZH_HANS("{0} 相机模型(本数据集中 {1} 台)没有精确对应的模型,已用 {2} 与 {3} " + "畸变拟合,误差在 {4} 像素以内,因此其图像按原样使用。"), + ZH_HANT("{0} 相機模型(本資料集中 {1} 台)沒有精確對應的模型,已用 {2} 與 {3} " + "畸變擬合,誤差在 {4} 像素以內,因此其影像按原樣使用。"), + KO("{0} 카메라 모델(이 데이터셋에 {1} 대)은 정확히 일치하는 모델이 없어 {2} 와 " + "{3} 왜곡으로 근사했습니다. 오차 {4} px 이내이므로 이미지는 그대로 사용합니다."), + ES("el modelo de cámara {0} ({1} en este conjunto) no tiene equivalente " + "exacto; ajustado como {2} con distorsión {3} con un error de {4} px, " + "así que sus imágenes se usan tal cual."), + FR("le modèle de caméra {0} ({1} dans ce jeu de données) n'a pas " + "d'équivalent exact ; ajusté en {2} avec la distorsion {3} à {4} px " + "près, donc ses images sont utilisées telles quelles."), + DE("für das Kameramodell {0} ({1} in diesem Datensatz) gibt es hier keine " + "exakte Entsprechung; angepasst als {2} mit {3}-Verzeichnung auf {4} px " + "genau, ihre Bilder werden daher unverändert verwendet."), + PT("o modelo de câmera {0} ({1} neste conjunto) não tem equivalente exato; " + "ajustado como {2} com distorção {3} com erro de {4} px, então as " + "imagens são usadas como estão."), + IT("il modello di camera {0} ({1} in questo dataset) non ha un equivalente " + "esatto; approssimato come {2} con distorsione {3} entro {4} px, quindi " + "le immagini sono usate così come sono."), + NL("het cameramodel {0} ({1} in deze dataset) heeft hier geen exacte " + "tegenhanger; benaderd als {2} met {3}-vervorming tot op {4} px, dus de " + "beelden worden ongewijzigd gebruikt."), + RU("модель камеры {0} ({1} в этом наборе) не имеет точного соответствия; " + "приближена как {2} с искажением {3} с точностью {4} пикс., поэтому её " + "изображения используются как есть."), + TR("{0} kamera modeli (bu veri kumesinde {1} adet) icin birebir karsilik " + "yok; {2} ve {3} bozulmasi ile {4} px hata payiyla yaklasildi, bu " + "yuzden goruntuleri oldugu gibi kullaniliyor.")); + +SS_MSG(camera_sensor_skew, + EN("the camera for {0} has a {1} px sensor skew, which no supported camera " + "model carries; its images are re-distorted onto a {2} camera with {3} " + "distortion, max error {4} px."), + JA("{0} のカメラには {1} px のセンサースキューがあり、対応するモデルがありません。" + "画像は {2} カメラ({3} 歪み)に合わせて再歪曲します(最大誤差 {4} px)。"), + ZH_HANS("{0} 的相机存在 {1} 像素的传感器切变,没有支持的相机模型能表示;其图像会" + "重新畸变到 {2} 相机与 {3} 畸变上,最大误差 {4} 像素。"), + ZH_HANT("{0} 的相機存在 {1} 像素的感光元件切變,沒有支援的相機模型能表示;其影像會" + "重新畸變到 {2} 相機與 {3} 畸變上,最大誤差 {4} 像素。"), + KO("{0} 의 카메라에 {1} px 센서 스큐가 있는데 이를 담는 카메라 모델이 없습니다. " + "이미지는 {2} 카메라와 {3} 왜곡에 맞춰 다시 왜곡됩니다. 최대 오차 {4} px."), + ES("la cámara de {0} tiene una inclinación de sensor de {1} px que ningún " + "modelo admitido representa; sus imágenes se redistorsionan a una cámara " + "{2} con distorsión {3}, error máximo {4} px."), + FR("la caméra de {0} a un cisaillement de capteur de {1} px qu'aucun modèle " + "pris en charge ne porte ; ses images sont redistordues vers une caméra " + "{2} avec la distorsion {3}, erreur maximale {4} px."), + DE("die Kamera von {0} hat eine Sensorscherung von {1} px, die kein " + "unterstütztes Kameramodell trägt; ihre Bilder werden auf eine " + "{2}-Kamera mit {3}-Verzeichnung umverzeichnet, maximaler Fehler {4} px."), + PT("a câmera de {0} tem uma inclinação de sensor de {1} px que nenhum modelo " + "suportado carrega; suas imagens são redistorcidas para uma câmera {2} " + "com distorção {3}, erro máximo {4} px."), + IT("la camera di {0} ha uno scorrimento del sensore di {1} px che nessun " + "modello supportato porta; le sue immagini vengono ridistorte su una " + "camera {2} con distorsione {3}, errore massimo {4} px."), + NL("de camera van {0} heeft een sensorschuining van {1} px die geen enkel " + "ondersteund cameramodel draagt; de beelden worden opnieuw vervormd naar " + "een {2}-camera met {3}-vervorming, maximale fout {4} px."), + RU("камера для {0} имеет наклон матрицы {1} пикс., которого нет ни в одной " + "поддерживаемой модели; её изображения переискажаются в камеру {2} с " + "искажением {3}, максимальная ошибка {4} пикс."), + TR("{0} icin kamerada {1} px sensor egimi var, bunu tasiyan desteklenen bir " + "kamera modeli yok; goruntuleri {3} bozulmali bir {2} kameraya yeniden " + "bozuluyor, en buyuk hata {4} px.")); + +SS_MSG(camera_model_fit_failed, + EN("the {0} camera model ({1} in this dataset) projects nothing this reader " + "understands, so it could not be fitted; falling back to a plain {2}. " + "What is reconstructed from those cameras will be wrong."), + JA("{0} カメラモデル(このデータセットに {1} 台)はこのリーダーが解釈できる投影を" + "返さず、近似できませんでした。素の {2} で代用します。これらのカメラからの" + "復元は正しくなりません。"), + ZH_HANS("{0} 相机模型(本数据集中 {1} 台)未给出本读取器能理解的投影,无法拟合;" + "改用普通的 {2}。由这些相机重建的结果会是错的。"), + ZH_HANT("{0} 相機模型(本資料集中 {1} 台)未給出本讀取器能理解的投影,無法擬合;" + "改用普通的 {2}。由這些相機重建的結果會是錯的。"), + KO("{0} 카메라 모델(이 데이터셋에 {1} 대)은 이 리더가 이해할 수 있는 투영을 " + "내놓지 않아 근사할 수 없었습니다. 기본 {2} 로 대체합니다. 이 카메라들로부터의 " + "복원은 잘못됩니다."), + ES("el modelo de cámara {0} ({1} en este conjunto) no proyecta nada que " + "este lector entienda, así que no se pudo ajustar; se usa una {2} " + "simple. Lo que se reconstruya desde esas cámaras estará mal."), + FR("le modèle de caméra {0} ({1} dans ce jeu de données) ne projette rien " + "que ce lecteur comprenne, il n'a donc pas pu être ajusté ; repli sur " + "une {2} simple. Ce qui sera reconstruit depuis ces caméras sera faux."), + DE("das Kameramodell {0} ({1} in diesem Datensatz) liefert keine Projektion, " + "die dieser Leser versteht, und ließ sich daher nicht anpassen; " + "ersatzweise eine schlichte {2}. Was aus diesen Kameras rekonstruiert " + "wird, ist falsch."), + PT("o modelo de câmera {0} ({1} neste conjunto) não projeta nada que este " + "leitor entenda, então não pôde ser ajustado; usando uma {2} simples. O " + "que for reconstruído a partir dessas câmeras ficará errado."), + IT("il modello di camera {0} ({1} in questo dataset) non proietta nulla che " + "questo lettore capisca, quindi non è stato possibile approssimarlo; si " + "ripiega su una {2} semplice. Ciò che viene ricostruito da queste camere " + "sarà sbagliato."), + NL("het cameramodel {0} ({1} in deze dataset) projecteert niets wat deze " + "lezer begrijpt en kon dus niet benaderd worden; er wordt teruggevallen " + "op een gewone {2}. Wat uit die camera's gereconstrueerd wordt, klopt " + "niet."), + RU("модель камеры {0} ({1} в этом наборе) не даёт проекции, понятной этому " + "загрузчику, поэтому приблизить её не удалось; берётся обычная {2}. " + "Всё, что будет восстановлено с этих камер, окажется неверным."), + TR("{0} kamera modeli (bu veri kumesinde {1} adet) bu okuyucunun anladigi " + "bir izdusum vermiyor, bu yuzden yaklasilamadi; duz bir {2} " + "kullaniliyor. Bu kameralardan yeniden olusturulan sey yanlis olacak.")); + SS_MSG(colmap_parse_failed, EN("the COLMAP data could not be read: {0}"), JA("COLMAP のデータを読めませんでした: {0}"), diff --git a/src/instantiations/FPBO_P3GFPBO.cu b/src/instantiations/FPBO_P3GFPBO.cu index 64d3789f..e20d4e2e 100644 --- a/src/instantiations/FPBO_P3GFPBO.cu +++ b/src/instantiations/FPBO_P3GFPBO.cu @@ -7,6 +7,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, true, true, 0 @@ -64,6 +65,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, true, true, 1 @@ -121,6 +123,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 0 @@ -178,6 +181,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 1 @@ -235,6 +239,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, false, true, 0 @@ -292,6 +297,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, false, true, 1 @@ -349,6 +355,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, false, false, 0 @@ -406,6 +413,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, false, false, 1 @@ -462,7 +470,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, true, 0 diff --git a/src/instantiations/FPBO_P3GFPBO_1.cu b/src/instantiations/FPBO_P3GFPBO_1.cu index 1e9c600f..089d5525 100644 --- a/src/instantiations/FPBO_P3GFPBO_1.cu +++ b/src/instantiations/FPBO_P3GFPBO_1.cu @@ -6,7 +6,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, true, 1 @@ -63,7 +64,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 0 @@ -120,7 +122,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 1 @@ -177,7 +180,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 0 @@ -234,7 +238,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 1 @@ -291,7 +296,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, false, 0 @@ -348,7 +354,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, false, 1 @@ -405,7 +412,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, true, 0 @@ -462,7 +470,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, true, 1 diff --git a/src/instantiations/FPBO_P3GFPBO_10.cu b/src/instantiations/FPBO_P3GFPBO_10.cu index 6da7b949..6b2969fd 100644 --- a/src/instantiations/FPBO_P3GFPBO_10.cu +++ b/src/instantiations/FPBO_P3GFPBO_10.cu @@ -5,464 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::PINHOLE, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::PINHOLE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, + MipSplatting<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 0 @@ -472,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +29,475 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_100.cu b/src/instantiations/FPBO_P3GFPBO_100.cu new file mode 100644 index 00000000..718a62f4 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_100.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_101.cu b/src/instantiations/FPBO_P3GFPBO_101.cu new file mode 100644 index 00000000..05d06a71 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_101.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_102.cu b/src/instantiations/FPBO_P3GFPBO_102.cu new file mode 100644 index 00000000..41ae08c9 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_102.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_103.cu b/src/instantiations/FPBO_P3GFPBO_103.cu new file mode 100644 index 00000000..24b75e8f --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_103.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_104.cu b/src/instantiations/FPBO_P3GFPBO_104.cu new file mode 100644 index 00000000..9dc04ad2 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_104.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_105.cu b/src/instantiations/FPBO_P3GFPBO_105.cu new file mode 100644 index 00000000..35e02172 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_105.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_106.cu b/src/instantiations/FPBO_P3GFPBO_106.cu new file mode 100644 index 00000000..46b6ce66 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_106.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_107.cu b/src/instantiations/FPBO_P3GFPBO_107.cu new file mode 100644 index 00000000..97e5f338 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_107.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_108.cu b/src/instantiations/FPBO_P3GFPBO_108.cu new file mode 100644 index 00000000..19af9eef --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_108.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_109.cu b/src/instantiations/FPBO_P3GFPBO_109.cu new file mode 100644 index 00000000..65a56b5b --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_109.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_11.cu b/src/instantiations/FPBO_P3GFPBO_11.cu index f3595ff7..fd905f60 100644 --- a/src/instantiations/FPBO_P3GFPBO_11.cu +++ b/src/instantiations/FPBO_P3GFPBO_11.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, + MipSplatting<0>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, + MipSplatting<0>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, + MipSplatting<0>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, + MipSplatting<0>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, false, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, + MipSplatting<0>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, false, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, true, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, true, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_110.cu b/src/instantiations/FPBO_P3GFPBO_110.cu new file mode 100644 index 00000000..1de37a9e --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_110.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_111.cu b/src/instantiations/FPBO_P3GFPBO_111.cu new file mode 100644 index 00000000..e89d138e --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_111.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_112.cu b/src/instantiations/FPBO_P3GFPBO_112.cu new file mode 100644 index 00000000..09f30413 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_112.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_113.cu b/src/instantiations/FPBO_P3GFPBO_113.cu new file mode 100644 index 00000000..9d19aace --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_113.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_114.cu b/src/instantiations/FPBO_P3GFPBO_114.cu new file mode 100644 index 00000000..c16971e4 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_114.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_115.cu b/src/instantiations/FPBO_P3GFPBO_115.cu new file mode 100644 index 00000000..4b62ea20 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_115.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_116.cu b/src/instantiations/FPBO_P3GFPBO_116.cu new file mode 100644 index 00000000..bf48f3b7 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_116.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_117.cu b/src/instantiations/FPBO_P3GFPBO_117.cu new file mode 100644 index 00000000..b8c8adab --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_117.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<1>::WorldBuffer g1_splats_world, + Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_118.cu b/src/instantiations/FPBO_P3GFPBO_118.cu new file mode 100644 index 00000000..49d38667 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_118.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_119.cu b/src/instantiations/FPBO_P3GFPBO_119.cu new file mode 100644 index 00000000..582a73f5 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_119.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_12.cu b/src/instantiations/FPBO_P3GFPBO_12.cu index ca337d1c..e3a310fd 100644 --- a/src/instantiations/FPBO_P3GFPBO_12.cu +++ b/src/instantiations/FPBO_P3GFPBO_12.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, true, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, true, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_120.cu b/src/instantiations/FPBO_P3GFPBO_120.cu new file mode 100644 index 00000000..da357886 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_120.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_121.cu b/src/instantiations/FPBO_P3GFPBO_121.cu new file mode 100644 index 00000000..9c2d5f84 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_121.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_122.cu b/src/instantiations/FPBO_P3GFPBO_122.cu new file mode 100644 index 00000000..cc9879af --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_122.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_123.cu b/src/instantiations/FPBO_P3GFPBO_123.cu new file mode 100644 index 00000000..e271a5f9 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_123.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_124.cu b/src/instantiations/FPBO_P3GFPBO_124.cu new file mode 100644 index 00000000..13a53e58 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_124.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_125.cu b/src/instantiations/FPBO_P3GFPBO_125.cu new file mode 100644 index 00000000..077384aa --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_125.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_126.cu b/src/instantiations/FPBO_P3GFPBO_126.cu new file mode 100644 index 00000000..457389f5 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_126.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_127.cu b/src/instantiations/FPBO_P3GFPBO_127.cu new file mode 100644 index 00000000..36c6e8b2 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_127.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<2>::WorldBuffer g1_splats_world, + Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_128.cu b/src/instantiations/FPBO_P3GFPBO_128.cu new file mode 100644 index 00000000..20a75941 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_128.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_129.cu b/src/instantiations/FPBO_P3GFPBO_129.cu new file mode 100644 index 00000000..12df4d23 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_129.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_13.cu b/src/instantiations/FPBO_P3GFPBO_13.cu index 6289c031..91041c75 100644 --- a/src/instantiations/FPBO_P3GFPBO_13.cu +++ b/src/instantiations/FPBO_P3GFPBO_13.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID, + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, true, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, true, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_130.cu b/src/instantiations/FPBO_P3GFPBO_130.cu new file mode 100644 index 00000000..b21b2fc8 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_130.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_131.cu b/src/instantiations/FPBO_P3GFPBO_131.cu new file mode 100644 index 00000000..10ab5221 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_131.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_132.cu b/src/instantiations/FPBO_P3GFPBO_132.cu new file mode 100644 index 00000000..3fee08f0 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_132.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_133.cu b/src/instantiations/FPBO_P3GFPBO_133.cu new file mode 100644 index 00000000..ca00d1a2 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_133.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_134.cu b/src/instantiations/FPBO_P3GFPBO_134.cu new file mode 100644 index 00000000..a2379855 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_134.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_135.cu b/src/instantiations/FPBO_P3GFPBO_135.cu new file mode 100644 index 00000000..ba07bee9 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_135.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_136.cu b/src/instantiations/FPBO_P3GFPBO_136.cu new file mode 100644 index 00000000..4c9b80e0 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_136.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_137.cu b/src/instantiations/FPBO_P3GFPBO_137.cu new file mode 100644 index 00000000..3cb1fec7 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_137.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<3>::WorldBuffer g1_splats_world, + Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_138.cu b/src/instantiations/FPBO_P3GFPBO_138.cu new file mode 100644 index 00000000..226d7632 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_138.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_139.cu b/src/instantiations/FPBO_P3GFPBO_139.cu new file mode 100644 index 00000000..b03996ff --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_139.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_14.cu b/src/instantiations/FPBO_P3GFPBO_14.cu index 3c9548a2..0e51031d 100644 --- a/src/instantiations/FPBO_P3GFPBO_14.cu +++ b/src/instantiations/FPBO_P3GFPBO_14.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<1>::WorldBuffer g1_splats_world, - MipSplatting<1>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, true, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, true, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, false, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, false, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_140.cu b/src/instantiations/FPBO_P3GFPBO_140.cu new file mode 100644 index 00000000..2c63ba6e --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_140.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_141.cu b/src/instantiations/FPBO_P3GFPBO_141.cu new file mode 100644 index 00000000..3a2fa3da --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_141.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_142.cu b/src/instantiations/FPBO_P3GFPBO_142.cu new file mode 100644 index 00000000..28d1f12c --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_142.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_143.cu b/src/instantiations/FPBO_P3GFPBO_143.cu new file mode 100644 index 00000000..846fa501 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_143.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_144.cu b/src/instantiations/FPBO_P3GFPBO_144.cu new file mode 100644 index 00000000..69abba9b --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_144.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_145.cu b/src/instantiations/FPBO_P3GFPBO_145.cu new file mode 100644 index 00000000..91ca650b --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_145.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_146.cu b/src/instantiations/FPBO_P3GFPBO_146.cu new file mode 100644 index 00000000..b602c1aa --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_146.cu @@ -0,0 +1,469 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<4>::WorldBuffer g1_splats_world, + Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_15.cu b/src/instantiations/FPBO_P3GFPBO_15.cu index 7399d780..c84d3c7f 100644 --- a/src/instantiations/FPBO_P3GFPBO_15.cu +++ b/src/instantiations/FPBO_P3GFPBO_15.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, true, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, true, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, false, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, false, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, true, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, false, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, false, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_16.cu b/src/instantiations/FPBO_P3GFPBO_16.cu index 318cfc92..e770361d 100644 --- a/src/instantiations/FPBO_P3GFPBO_16.cu +++ b/src/instantiations/FPBO_P3GFPBO_16.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::EQUISOLID, + CameraDistortionType::None, true, true, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::EQUISOLID, + CameraDistortionType::None, true, true, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::EQUISOLID, + CameraDistortionType::None, true, false, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::EQUISOLID, + CameraDistortionType::None, true, false, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::EQUISOLID, + CameraDistortionType::None, false, true, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::EQUISOLID, + CameraDistortionType::None, false, true, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::EQUISOLID, + CameraDistortionType::None, false, false, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, + MipSplatting<0>, CameraModelType::EQUISOLID, + CameraDistortionType::None, false, false, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, true, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_17.cu b/src/instantiations/FPBO_P3GFPBO_17.cu index cfecbce5..a19e2f9e 100644 --- a/src/instantiations/FPBO_P3GFPBO_17.cu +++ b/src/instantiations/FPBO_P3GFPBO_17.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, true, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, false, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, false, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, true, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, true, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, false, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, false, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<2>::WorldBuffer g1_splats_world, - Vanilla3DGS<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, true, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, true, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_18.cu b/src/instantiations/FPBO_P3GFPBO_18.cu index da5a474b..f79ed5ce 100644 --- a/src/instantiations/FPBO_P3GFPBO_18.cu +++ b/src/instantiations/FPBO_P3GFPBO_18.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, false, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, false, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, false, true, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, false, true, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, false, false, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE, + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, false, false, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, true, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, true, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, false, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_19.cu b/src/instantiations/FPBO_P3GFPBO_19.cu index 63da4af2..0909bea5 100644 --- a/src/instantiations/FPBO_P3GFPBO_19.cu +++ b/src/instantiations/FPBO_P3GFPBO_19.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, false, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, false, true, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, false, true, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, false, false, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE, + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, false, false, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, true, true, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, true, true, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_2.cu b/src/instantiations/FPBO_P3GFPBO_2.cu index 4eebdf36..aab3b4cf 100644 --- a/src/instantiations/FPBO_P3GFPBO_2.cu +++ b/src/instantiations/FPBO_P3GFPBO_2.cu @@ -6,7 +6,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 0 @@ -63,7 +64,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 1 @@ -120,7 +122,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 0 @@ -177,7 +180,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -234,7 +238,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 0 @@ -291,7 +296,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 1 @@ -348,7 +354,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, true, 0 @@ -405,7 +412,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, true, 1 @@ -462,7 +470,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 0 diff --git a/src/instantiations/FPBO_P3GFPBO_20.cu b/src/instantiations/FPBO_P3GFPBO_20.cu index d756e5fa..23796b8e 100644 --- a/src/instantiations/FPBO_P3GFPBO_20.cu +++ b/src/instantiations/FPBO_P3GFPBO_20.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, true, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, true, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, false, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, false, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, true, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, true, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_21.cu b/src/instantiations/FPBO_P3GFPBO_21.cu index 67a79c07..6515bc5d 100644 --- a/src/instantiations/FPBO_P3GFPBO_21.cu +++ b/src/instantiations/FPBO_P3GFPBO_21.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, false, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, false, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<2>::WorldBuffer g1_splats_world, - MipSplatting<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, + Vanilla3DGS<1>, CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, true, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, + Vanilla3DGS<1>, CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, true, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, + Vanilla3DGS<1>, CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, + Vanilla3DGS<1>, CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, + Vanilla3DGS<1>, CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, + Vanilla3DGS<1>, CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_22.cu b/src/instantiations/FPBO_P3GFPBO_22.cu index a40d31cd..b084f216 100644 --- a/src/instantiations/FPBO_P3GFPBO_22.cu +++ b/src/instantiations/FPBO_P3GFPBO_22.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, + Vanilla3DGS<1>, CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, + Vanilla3DGS<1>, CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, true, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, true, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_23.cu b/src/instantiations/FPBO_P3GFPBO_23.cu index 324e78ad..80522abc 100644 --- a/src/instantiations/FPBO_P3GFPBO_23.cu +++ b/src/instantiations/FPBO_P3GFPBO_23.cu @@ -5,65 +5,67 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, CameraModelType::FISHEYE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID, + CameraDistortionType::None, true, true, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, true, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_24.cu b/src/instantiations/FPBO_P3GFPBO_24.cu index 5d5645f5..c39db2ef 100644 --- a/src/instantiations/FPBO_P3GFPBO_24.cu +++ b/src/instantiations/FPBO_P3GFPBO_24.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, true, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, true, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, false, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, false, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<3>::WorldBuffer g1_splats_world, - Vanilla3DGS<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE, + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, true, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_25.cu b/src/instantiations/FPBO_P3GFPBO_25.cu index e8b9f713..45ac12e7 100644 --- a/src/instantiations/FPBO_P3GFPBO_25.cu +++ b/src/instantiations/FPBO_P3GFPBO_25.cu @@ -5,417 +5,19 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, true, - 0 + 1 >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,18 +63,19 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, - true, - 1 + false, + 0 >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +87,417 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_26.cu b/src/instantiations/FPBO_P3GFPBO_26.cu index c5b02b9f..2160513d 100644 --- a/src/instantiations/FPBO_P3GFPBO_26.cu +++ b/src/instantiations/FPBO_P3GFPBO_26.cu @@ -5,464 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUISOLID, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUISOLID, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, CameraModelType::EQUISOLID, + CameraDistortionType::None, true, false, 0 @@ -472,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +29,475 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_27.cu b/src/instantiations/FPBO_P3GFPBO_27.cu index 68f5fe2b..0cf96d7a 100644 --- a/src/instantiations/FPBO_P3GFPBO_27.cu +++ b/src/instantiations/FPBO_P3GFPBO_27.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, false, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, true, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, true, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, false, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, false, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, true, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, true, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, false, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, false, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_28.cu b/src/instantiations/FPBO_P3GFPBO_28.cu index 4cc0ada2..87809d8b 100644 --- a/src/instantiations/FPBO_P3GFPBO_28.cu +++ b/src/instantiations/FPBO_P3GFPBO_28.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, false, true, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, false, true, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,10 +121,127 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, CameraModelType::EQUIRECTANGULAR, - false, - false, + CameraDistortionType::None, + true, + true, 0 >( cudaStream_t stream, @@ -130,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,122 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<3>, + Vanilla3DGS<1>, CameraModelType::EQUIRECTANGULAR, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<3>::WorldBuffer g1_splats_world, - MipSplatting<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE, + CameraDistortionType::None, true, true, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE, + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, false, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE, + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, false, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE, + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, false, true, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_29.cu b/src/instantiations/FPBO_P3GFPBO_29.cu index 6b162984..b6284b23 100644 --- a/src/instantiations/FPBO_P3GFPBO_29.cu +++ b/src/instantiations/FPBO_P3GFPBO_29.cu @@ -5,18 +5,193 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<1>::WorldBuffer g1_splats_world, + Vanilla3DGS<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, CameraModelType::PINHOLE, - false, + CameraDistortionType::None, true, - 1 + true, + 0 >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,18 +237,19 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, + MipSplatting<1>, CameraModelType::PINHOLE, - false, - false, - 0 + CameraDistortionType::None, + true, + true, + 1 >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,179 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, + MipSplatting<1>, CameraModelType::PINHOLE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, true, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, true, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_3.cu b/src/instantiations/FPBO_P3GFPBO_3.cu index dd17440b..42db8ebc 100644 --- a/src/instantiations/FPBO_P3GFPBO_3.cu +++ b/src/instantiations/FPBO_P3GFPBO_3.cu @@ -6,7 +6,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 1 @@ -63,7 +64,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 0 @@ -120,7 +122,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 1 @@ -177,7 +180,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 0 @@ -234,7 +238,8 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 1 @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, true, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, true, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_30.cu b/src/instantiations/FPBO_P3GFPBO_30.cu index 0bc4394a..e9fc36ae 100644 --- a/src/instantiations/FPBO_P3GFPBO_30.cu +++ b/src/instantiations/FPBO_P3GFPBO_30.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, false, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, false, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, true, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, true, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, false, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_31.cu b/src/instantiations/FPBO_P3GFPBO_31.cu index 6fc59bbb..823bdb5f 100644 --- a/src/instantiations/FPBO_P3GFPBO_31.cu +++ b/src/instantiations/FPBO_P3GFPBO_31.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, false, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, true, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, true, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<4>::WorldBuffer g1_splats_world, - Vanilla3DGS<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_32.cu b/src/instantiations/FPBO_P3GFPBO_32.cu index 102a83df..ffe3ae60 100644 --- a/src/instantiations/FPBO_P3GFPBO_32.cu +++ b/src/instantiations/FPBO_P3GFPBO_32.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, true, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, true, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::FISHEYE, + CameraDistortionType::None, true, true, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_33.cu b/src/instantiations/FPBO_P3GFPBO_33.cu index 27cd88a3..0b8444e0 100644 --- a/src/instantiations/FPBO_P3GFPBO_33.cu +++ b/src/instantiations/FPBO_P3GFPBO_33.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::FISHEYE, + CameraDistortionType::None, true, true, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, + MipSplatting<1>, CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, true, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, true, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_34.cu b/src/instantiations/FPBO_P3GFPBO_34.cu index 7fd75119..9baf4832 100644 --- a/src/instantiations/FPBO_P3GFPBO_34.cu +++ b/src/instantiations/FPBO_P3GFPBO_34.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, false, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, false, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, true, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, true, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, false, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_35.cu b/src/instantiations/FPBO_P3GFPBO_35.cu index 7de3ae0d..764b0000 100644 --- a/src/instantiations/FPBO_P3GFPBO_35.cu +++ b/src/instantiations/FPBO_P3GFPBO_35.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, false, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, true, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, false, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, false, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<4>::WorldBuffer g1_splats_world, - MipSplatting<4>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_36.cu b/src/instantiations/FPBO_P3GFPBO_36.cu index fad8b9ad..807ae3bc 100644 --- a/src/instantiations/FPBO_P3GFPBO_36.cu +++ b/src/instantiations/FPBO_P3GFPBO_36.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE, + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, true, 0 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE, + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, true, 1 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE, + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, false, 0 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE, + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, false, 1 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, true, 0 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_37.cu b/src/instantiations/FPBO_P3GFPBO_37.cu index a4a536dd..19d6ec18 100644 --- a/src/instantiations/FPBO_P3GFPBO_37.cu +++ b/src/instantiations/FPBO_P3GFPBO_37.cu @@ -1,421 +1,23 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, + MipSplatting<1>, CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, true, - true, - 0 + 1 >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,18 +63,19 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, + MipSplatting<1>, CameraModelType::EQUISOLID, - true, - true, - 1 + CameraDistortionType::OpenCV, + false, + false, + 0 >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +87,417 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_38.cu b/src/instantiations/FPBO_P3GFPBO_38.cu index 4fa073b3..913be0fa 100644 --- a/src/instantiations/FPBO_P3GFPBO_38.cu +++ b/src/instantiations/FPBO_P3GFPBO_38.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, + MipSplatting<1>, CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, false, false, 0 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, + MipSplatting<1>, CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, false, false, 1 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, + MipSplatting<1>, CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, true, 0 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, + MipSplatting<1>, CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, true, 1 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, + MipSplatting<1>, CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, false, 0 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_39.cu b/src/instantiations/FPBO_P3GFPBO_39.cu index d60a68ed..7c4cbe6b 100644 --- a/src/instantiations/FPBO_P3GFPBO_39.cu +++ b/src/instantiations/FPBO_P3GFPBO_39.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<0>, + MipSplatting<1>, CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, false, false, 1 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<0>::WorldBuffer g1_splats_world, - Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + MipSplatting<1>::WorldBuffer g1_splats_world, + MipSplatting<1>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, + Vanilla3DGS<2>, CameraModelType::PINHOLE, + CameraDistortionType::None, true, true, 0 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, + Vanilla3DGS<2>, CameraModelType::PINHOLE, + CameraDistortionType::None, true, true, 1 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, + Vanilla3DGS<2>, CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 0 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, + Vanilla3DGS<2>, CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 1 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_4.cu b/src/instantiations/FPBO_P3GFPBO_4.cu index 1cfc9cbb..039450a4 100644 --- a/src/instantiations/FPBO_P3GFPBO_4.cu +++ b/src/instantiations/FPBO_P3GFPBO_4.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 0 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 1 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 0 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, true, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, true, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, false, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, false, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_40.cu b/src/instantiations/FPBO_P3GFPBO_40.cu index d4fe6cf3..e3f32064 100644 --- a/src/instantiations/FPBO_P3GFPBO_40.cu +++ b/src/instantiations/FPBO_P3GFPBO_40.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, + Vanilla3DGS<2>, CameraModelType::PINHOLE, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::PINHOLE, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::PINHOLE, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::PINHOLE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, true, true, 0 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, true, 1 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 0 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 1 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 0 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_41.cu b/src/instantiations/FPBO_P3GFPBO_41.cu index 18a6bf16..67419d1e 100644 --- a/src/instantiations/FPBO_P3GFPBO_41.cu +++ b/src/instantiations/FPBO_P3GFPBO_41.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, true, 1 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 0 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, true, false, 1 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 0 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_42.cu b/src/instantiations/FPBO_P3GFPBO_42.cu index 2e162fc7..d0c2375c 100644 --- a/src/instantiations/FPBO_P3GFPBO_42.cu +++ b/src/instantiations/FPBO_P3GFPBO_42.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 0 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, true, false, 1 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 0 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 1 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 0 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_43.cu b/src/instantiations/FPBO_P3GFPBO_43.cu index 476ca5a9..25a9339b 100644 --- a/src/instantiations/FPBO_P3GFPBO_43.cu +++ b/src/instantiations/FPBO_P3GFPBO_43.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<1>::WorldBuffer g1_splats_world, - Vanilla3DGUT<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE, + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, false, 1 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE, + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 0 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE, + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 1 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE, + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 0 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE, + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 1 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_44.cu b/src/instantiations/FPBO_P3GFPBO_44.cu index 1b2f42bc..6e58f52d 100644 --- a/src/instantiations/FPBO_P3GFPBO_44.cu +++ b/src/instantiations/FPBO_P3GFPBO_44.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::FISHEYE, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::FISHEYE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::FISHEYE, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::FISHEYE, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, + Vanilla3DGS<2>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 0 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, + Vanilla3DGS<2>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 1 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, + Vanilla3DGS<2>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 0 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, + Vanilla3DGS<2>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 1 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, true, 0 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_45.cu b/src/instantiations/FPBO_P3GFPBO_45.cu index 264813bd..169ccc18 100644 --- a/src/instantiations/FPBO_P3GFPBO_45.cu +++ b/src/instantiations/FPBO_P3GFPBO_45.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, false, 0 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, false, 1 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, true, true, 0 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, true, true, 1 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_46.cu b/src/instantiations/FPBO_P3GFPBO_46.cu index f26c0589..009464ee 100644 --- a/src/instantiations/FPBO_P3GFPBO_46.cu +++ b/src/instantiations/FPBO_P3GFPBO_46.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, false, 0 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, false, 1 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<2>::WorldBuffer g1_splats_world, - Vanilla3DGUT<2>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, true, 0 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, true, 1 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, false, 0 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_47.cu b/src/instantiations/FPBO_P3GFPBO_47.cu index 6df139b5..5870bf97 100644 --- a/src/instantiations/FPBO_P3GFPBO_47.cu +++ b/src/instantiations/FPBO_P3GFPBO_47.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, false, 1 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, true, 0 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, true, 1 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, false, 0 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE, + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, false, 1 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_48.cu b/src/instantiations/FPBO_P3GFPBO_48.cu index 97fb249b..c54306ce 100644 --- a/src/instantiations/FPBO_P3GFPBO_48.cu +++ b/src/instantiations/FPBO_P3GFPBO_48.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, true, 0 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, true, 1 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, false, 0 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, false, 1 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID, + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, false, true, 0 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<2>::WorldBuffer g1_splats_world, + Vanilla3DGS<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_49.cu b/src/instantiations/FPBO_P3GFPBO_49.cu index 350e7b6a..0b38e649 100644 --- a/src/instantiations/FPBO_P3GFPBO_49.cu +++ b/src/instantiations/FPBO_P3GFPBO_49.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, true, true, 1 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 0 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, true, false, 1 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, true, 0 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, false, true, 1 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_5.cu b/src/instantiations/FPBO_P3GFPBO_5.cu index c529db03..56edb315 100644 --- a/src/instantiations/FPBO_P3GFPBO_5.cu +++ b/src/instantiations/FPBO_P3GFPBO_5.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, true, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, false, false, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, true, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, true, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, false, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, false, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, true, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_50.cu b/src/instantiations/FPBO_P3GFPBO_50.cu index 0ec7a3fe..00f5d0e0 100644 --- a/src/instantiations/FPBO_P3GFPBO_50.cu +++ b/src/instantiations/FPBO_P3GFPBO_50.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<3>::WorldBuffer g1_splats_world, - Vanilla3DGUT<3>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::PINHOLE, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::PINHOLE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, + MipSplatting<2>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 0 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, + MipSplatting<2>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, true, false, 1 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, + MipSplatting<2>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 0 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, + MipSplatting<2>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, true, 1 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, + MipSplatting<2>, CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, false, false, 0 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_51.cu b/src/instantiations/FPBO_P3GFPBO_51.cu index 76ef5e84..2d1df767 100644 --- a/src/instantiations/FPBO_P3GFPBO_51.cu +++ b/src/instantiations/FPBO_P3GFPBO_51.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, + MipSplatting<2>, CameraModelType::PINHOLE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, true, false, 1 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 0 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, true, 1 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 0 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, false, false, 1 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_52.cu b/src/instantiations/FPBO_P3GFPBO_52.cu index 4f6bd134..5055a46e 100644 --- a/src/instantiations/FPBO_P3GFPBO_52.cu +++ b/src/instantiations/FPBO_P3GFPBO_52.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 0 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, true, 1 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 0 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID, + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, false, false, 1 @@ -415,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, true, true, 0 @@ -472,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +261,243 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_53.cu b/src/instantiations/FPBO_P3GFPBO_53.cu index 00088f43..fa5ffc50 100644 --- a/src/instantiations/FPBO_P3GFPBO_53.cu +++ b/src/instantiations/FPBO_P3GFPBO_53.cu @@ -1,240 +1,13 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, true, 1 @@ -244,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 0 @@ -301,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR, + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None, false, false, 1 @@ -358,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +145,359 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGUT<4>::WorldBuffer g1_splats_world, - Vanilla3DGUT<4>::WorldBuffer g2_splats_world, + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_54.cu b/src/instantiations/FPBO_P3GFPBO_54.cu new file mode 100644 index 00000000..7d8b9b56 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_54.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_55.cu b/src/instantiations/FPBO_P3GFPBO_55.cu new file mode 100644 index 00000000..c9a0b0cc --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_55.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_56.cu b/src/instantiations/FPBO_P3GFPBO_56.cu new file mode 100644 index 00000000..46a20bbc --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_56.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_57.cu b/src/instantiations/FPBO_P3GFPBO_57.cu new file mode 100644 index 00000000..c3b416cb --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_57.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_58.cu b/src/instantiations/FPBO_P3GFPBO_58.cu new file mode 100644 index 00000000..025d8eca --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_58.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<2>::WorldBuffer g1_splats_world, + MipSplatting<2>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_59.cu b/src/instantiations/FPBO_P3GFPBO_59.cu new file mode 100644 index 00000000..8acde7e9 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_59.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_6.cu b/src/instantiations/FPBO_P3GFPBO_6.cu index 49d8af15..1d2d0783 100644 --- a/src/instantiations/FPBO_P3GFPBO_6.cu +++ b/src/instantiations/FPBO_P3GFPBO_6.cu @@ -5,10 +5,127 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, CameraModelType::EQUISOLID, - false, - false, + CameraDistortionType::None, + true, + true, 0 >( cudaStream_t stream, @@ -16,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,122 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, + Vanilla3DGS<0>, CameraModelType::EQUISOLID, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, - // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, true, 1 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, true, false, 0 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, true, false, 1 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, true, 0 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, true, 1 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, false, 0 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_60.cu b/src/instantiations/FPBO_P3GFPBO_60.cu new file mode 100644 index 00000000..32c4ef8f --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_60.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_61.cu b/src/instantiations/FPBO_P3GFPBO_61.cu new file mode 100644 index 00000000..354c3c99 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_61.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_62.cu b/src/instantiations/FPBO_P3GFPBO_62.cu new file mode 100644 index 00000000..ff6a8f98 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_62.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_63.cu b/src/instantiations/FPBO_P3GFPBO_63.cu new file mode 100644 index 00000000..a40538a0 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_63.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_64.cu b/src/instantiations/FPBO_P3GFPBO_64.cu new file mode 100644 index 00000000..703d793e --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_64.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_65.cu b/src/instantiations/FPBO_P3GFPBO_65.cu new file mode 100644 index 00000000..643ed16d --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_65.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_66.cu b/src/instantiations/FPBO_P3GFPBO_66.cu new file mode 100644 index 00000000..19334453 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_66.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_67.cu b/src/instantiations/FPBO_P3GFPBO_67.cu new file mode 100644 index 00000000..4962e1ac --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_67.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_68.cu b/src/instantiations/FPBO_P3GFPBO_68.cu new file mode 100644 index 00000000..2b1ff26d --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_68.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<3>::WorldBuffer g1_splats_world, + Vanilla3DGS<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_69.cu b/src/instantiations/FPBO_P3GFPBO_69.cu new file mode 100644 index 00000000..bd1a63dc --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_69.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_7.cu b/src/instantiations/FPBO_P3GFPBO_7.cu index 79392452..72ee59e4 100644 --- a/src/instantiations/FPBO_P3GFPBO_7.cu +++ b/src/instantiations/FPBO_P3GFPBO_7.cu @@ -5,8 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, false, false, 1 @@ -16,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -28,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - MipSplatting<0>::WorldBuffer g1_splats_world, - MipSplatting<0>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -62,8 +63,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, true, 0 @@ -73,7 +75,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -85,11 +87,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -119,8 +121,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, true, 1 @@ -130,7 +133,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -142,11 +145,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -176,8 +179,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, false, 0 @@ -187,7 +191,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -199,11 +203,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -233,8 +237,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, true, false, 1 @@ -244,7 +249,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -256,11 +261,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -290,8 +295,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, true, 0 @@ -301,7 +307,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -313,11 +319,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -347,8 +353,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, true, 1 @@ -358,7 +365,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -370,11 +377,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -404,8 +411,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, false, 0 @@ -415,7 +423,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +435,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,8 +469,9 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE, + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, false, false, 1 @@ -472,7 +481,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +493,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_70.cu b/src/instantiations/FPBO_P3GFPBO_70.cu new file mode 100644 index 00000000..b79a07ab --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_70.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_71.cu b/src/instantiations/FPBO_P3GFPBO_71.cu new file mode 100644 index 00000000..41eb98a8 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_71.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_72.cu b/src/instantiations/FPBO_P3GFPBO_72.cu new file mode 100644 index 00000000..e68eaac9 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_72.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_73.cu b/src/instantiations/FPBO_P3GFPBO_73.cu new file mode 100644 index 00000000..2edf9865 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_73.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_74.cu b/src/instantiations/FPBO_P3GFPBO_74.cu new file mode 100644 index 00000000..abaee723 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_74.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_75.cu b/src/instantiations/FPBO_P3GFPBO_75.cu new file mode 100644 index 00000000..3d8ccf13 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_75.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_76.cu b/src/instantiations/FPBO_P3GFPBO_76.cu new file mode 100644 index 00000000..727e2d2a --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_76.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_77.cu b/src/instantiations/FPBO_P3GFPBO_77.cu new file mode 100644 index 00000000..d5e1df9a --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_77.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_78.cu b/src/instantiations/FPBO_P3GFPBO_78.cu new file mode 100644 index 00000000..bbb48bee --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_78.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<3>::WorldBuffer g1_splats_world, + MipSplatting<3>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_79.cu b/src/instantiations/FPBO_P3GFPBO_79.cu new file mode 100644 index 00000000..951fc935 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_79.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_8.cu b/src/instantiations/FPBO_P3GFPBO_8.cu index 7970041d..a16a40c7 100644 --- a/src/instantiations/FPBO_P3GFPBO_8.cu +++ b/src/instantiations/FPBO_P3GFPBO_8.cu @@ -5,464 +5,9 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE, - true, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, + Vanilla3DGS<0>, CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, true, true, 0 @@ -472,7 +17,7 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +29,475 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_80.cu b/src/instantiations/FPBO_P3GFPBO_80.cu new file mode 100644 index 00000000..edd1e92a --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_80.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_81.cu b/src/instantiations/FPBO_P3GFPBO_81.cu new file mode 100644 index 00000000..c253d0bd --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_81.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_82.cu b/src/instantiations/FPBO_P3GFPBO_82.cu new file mode 100644 index 00000000..73bb423f --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_82.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_83.cu b/src/instantiations/FPBO_P3GFPBO_83.cu new file mode 100644 index 00000000..9a418deb --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_83.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_84.cu b/src/instantiations/FPBO_P3GFPBO_84.cu new file mode 100644 index 00000000..294fa8ab --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_84.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_85.cu b/src/instantiations/FPBO_P3GFPBO_85.cu new file mode 100644 index 00000000..67bde71b --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_85.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_86.cu b/src/instantiations/FPBO_P3GFPBO_86.cu new file mode 100644 index 00000000..b3dd3a01 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_86.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_87.cu b/src/instantiations/FPBO_P3GFPBO_87.cu new file mode 100644 index 00000000..754b9e30 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_87.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<4>::WorldBuffer g1_splats_world, + Vanilla3DGS<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_88.cu b/src/instantiations/FPBO_P3GFPBO_88.cu new file mode 100644 index 00000000..fd5c1b3e --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_88.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_89.cu b/src/instantiations/FPBO_P3GFPBO_89.cu new file mode 100644 index 00000000..f81b3bb1 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_89.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_9.cu b/src/instantiations/FPBO_P3GFPBO_9.cu index 2f423826..c31c02f8 100644 --- a/src/instantiations/FPBO_P3GFPBO_9.cu +++ b/src/instantiations/FPBO_P3GFPBO_9.cu @@ -5,417 +5,19 @@ #include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID, - true, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID, - true, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID, - true, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID, - false, - true, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID, - false, - true, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID, - false, - false, - 0 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID, - false, - false, - 1 ->( - cudaStream_t stream, - // fwd inputs - const uint32_t C, - const uint32_t N, - const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, - const float *__restrict__ viewmats, // [C, 4, 4] - const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy - const CameraDistortionCoeffsBuffer dist_coeffs_buffer, - const uint32_t image_width, - const uint32_t image_height, - // fwd outputs - const int32_t *__restrict__ camera_id_bounds, // [N+1] - const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order - const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos - const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] - // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, - // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, - const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state - float4* __restrict__ sh_quant_bounds, - const uint8_t* __restrict__ sh_value_packed, - float2* __restrict__ sh_value_bounds, - NonShQuantState non_sh, - // float *__restrict__ v_viewmats // [C, 4, 4] optional - // optimizer params - const float* __restrict__ radii, - float* __restrict__ densify_score, - const float lr_means, - const float lr_quats, - const float lr_scales, - const float lr_opacs, - const float lr_features_dc, - const float lr_features_sh, - const float max_gauss_ratio, - const float scale_regularization_weight, - const float mcmc_opacity_reg_weight, - const float mcmc_scale_reg_weight, - const float erank_reg_weight, - const float erank_reg_weight_s3, - const float quat_norm_reg_weight, - const float sh_reg_weight, - const float eps_tr, - const int32_t scalar_step, - const int32_t* __restrict__ steps -); - -template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, + Vanilla3DGS<0>, CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, true, - 0 + 1 >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -427,11 +29,11 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, @@ -461,18 +63,19 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< ); template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< - Vanilla3DGS<1>, + Vanilla3DGS<0>, CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, true, - true, - 1 + false, + 0 >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -484,11 +87,417 @@ template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] // grad outputs from rasterization - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // optimizer states - Vanilla3DGS<1>::WorldBuffer g1_splats_world, - Vanilla3DGS<1>::WorldBuffer g2_splats_world, + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGS<0>::WorldBuffer g1_splats_world, + Vanilla3DGS<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<0>::WorldBuffer g1_splats_world, + MipSplatting<0>::WorldBuffer g2_splats_world, const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state float4* __restrict__ sh_quant_bounds, const uint8_t* __restrict__ sh_value_packed, diff --git a/src/instantiations/FPBO_P3GFPBO_90.cu b/src/instantiations/FPBO_P3GFPBO_90.cu new file mode 100644 index 00000000..1e848756 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_90.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_91.cu b/src/instantiations/FPBO_P3GFPBO_91.cu new file mode 100644 index 00000000..39e4d2c1 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_91.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_92.cu b/src/instantiations/FPBO_P3GFPBO_92.cu new file mode 100644 index 00000000..dd0b9875 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_92.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_93.cu b/src/instantiations/FPBO_P3GFPBO_93.cu new file mode 100644 index 00000000..353e09e9 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_93.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_94.cu b/src/instantiations/FPBO_P3GFPBO_94.cu new file mode 100644 index 00000000..a77b9e1e --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_94.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_95.cu b/src/instantiations/FPBO_P3GFPBO_95.cu new file mode 100644 index 00000000..99bc52d3 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_95.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_96.cu b/src/instantiations/FPBO_P3GFPBO_96.cu new file mode 100644 index 00000000..1e98dcdd --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_96.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_97.cu b/src/instantiations/FPBO_P3GFPBO_97.cu new file mode 100644 index 00000000..1388c1b3 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_97.cu @@ -0,0 +1,411 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + // optimizer states + MipSplatting<4>::WorldBuffer g1_splats_world, + MipSplatting<4>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_98.cu b/src/instantiations/FPBO_P3GFPBO_98.cu new file mode 100644 index 00000000..5e1aa43c --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_98.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/FPBO_P3GFPBO_99.cu b/src/instantiations/FPBO_P3GFPBO_99.cu new file mode 100644 index 00000000..81c244e2 --- /dev/null +++ b/src/instantiations/FPBO_P3GFPBO_99.cu @@ -0,0 +1,527 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/optim/FusedProjectionBwdOptim_kernel.cuh" + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + true, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, + false, + false, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 0 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); + +template void fused_projection_bwd_optimizer_3dgs_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, + true, + true, + 1 +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t *__restrict__ camera_id_bounds, // [N+1] + const int32_t *__restrict__ camera_ids, // [nnz] -- ORIGINAL (unsorted) order + const int32_t *__restrict__ perm, // [nnz] -- sorted_pos -> original_pos + const float4 *__restrict__ aabb, // [C, N, 4] or [nnz, 4] + // grad outputs from rasterization + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // optimizer states + Vanilla3DGUT<0>::WorldBuffer g1_splats_world, + Vanilla3DGUT<0>::WorldBuffer g2_splats_world, + const uint8_t* __restrict__ sh_packed, // AoS (u, sqrt_g2) packed SH state + float4* __restrict__ sh_quant_bounds, + const uint8_t* __restrict__ sh_value_packed, + float2* __restrict__ sh_value_bounds, + NonShQuantState non_sh, + // float *__restrict__ v_viewmats // [C, 4, 4] optional + // optimizer params + const float* __restrict__ radii, + float* __restrict__ densify_score, + const float lr_means, + const float lr_quats, + const float lr_scales, + const float lr_opacs, + const float lr_features_dc, + const float lr_features_sh, + const float max_gauss_ratio, + const float scale_regularization_weight, + const float mcmc_opacity_reg_weight, + const float mcmc_scale_reg_weight, + const float erank_reg_weight, + const float erank_reg_weight_s3, + const float quat_norm_reg_weight, + const float sh_reg_weight, + const float eps_tr, + const int32_t scalar_step, + const int32_t* __restrict__ steps +); diff --git a/src/instantiations/PBQG_P3GPBQG.cu b/src/instantiations/PBQG_P3GPBQG.cu index b7783b81..6a1548c3 100644 --- a/src/instantiations/PBQG_P3GPBQG.cu +++ b/src/instantiations/PBQG_P3GPBQG.cu @@ -6,7 +6,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::PINHOLE + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, @@ -33,7 +34,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< template void projection_bwd_quantgrad_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, @@ -60,7 +62,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< template void projection_bwd_quantgrad_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, @@ -87,7 +90,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< template void projection_bwd_quantgrad_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, @@ -113,14 +117,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -130,8 +135,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -140,14 +145,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<0>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -157,8 +163,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -167,14 +173,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -184,8 +191,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -194,14 +201,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -211,8 +219,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<0>::WorldBuffer v_splats_world, - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -221,14 +229,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -238,8 +247,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, diff --git a/src/instantiations/PBQG_P3GPBQG_1.cu b/src/instantiations/PBQG_P3GPBQG_1.cu index 0a003d75..727047a8 100644 --- a/src/instantiations/PBQG_P3GPBQG_1.cu +++ b/src/instantiations/PBQG_P3GPBQG_1.cu @@ -5,14 +5,15 @@ #include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -22,8 +23,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -32,14 +33,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,8 +51,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -59,14 +61,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -76,8 +79,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<1>::WorldBuffer v_splats_world, - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -86,14 +89,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<1>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -103,8 +107,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -113,14 +117,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -130,8 +135,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -140,14 +145,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -157,8 +163,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -167,14 +173,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -184,8 +191,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<1>::WorldBuffer v_splats_world, - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -194,14 +201,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -211,8 +219,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -221,14 +229,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -238,8 +247,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, diff --git a/src/instantiations/PBQG_P3GPBQG_10.cu b/src/instantiations/PBQG_P3GPBQG_10.cu new file mode 100644 index 00000000..9e9d32c1 --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_10.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_11.cu b/src/instantiations/PBQG_P3GPBQG_11.cu new file mode 100644 index 00000000..f8dc62e2 --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_11.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_12.cu b/src/instantiations/PBQG_P3GPBQG_12.cu new file mode 100644 index 00000000..a4467d79 --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_12.cu @@ -0,0 +1,61 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_13.cu b/src/instantiations/PBQG_P3GPBQG_13.cu new file mode 100644 index 00000000..1f077e3a --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_13.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_14.cu b/src/instantiations/PBQG_P3GPBQG_14.cu new file mode 100644 index 00000000..eb0e81f9 --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_14.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_15.cu b/src/instantiations/PBQG_P3GPBQG_15.cu new file mode 100644 index 00000000..2752d204 --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_15.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_16.cu b/src/instantiations/PBQG_P3GPBQG_16.cu new file mode 100644 index 00000000..b56e69a0 --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_16.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_17.cu b/src/instantiations/PBQG_P3GPBQG_17.cu new file mode 100644 index 00000000..3a65e5eb --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_17.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_18.cu b/src/instantiations/PBQG_P3GPBQG_18.cu new file mode 100644 index 00000000..c6a12bc1 --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_18.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_19.cu b/src/instantiations/PBQG_P3GPBQG_19.cu new file mode 100644 index 00000000..6498441f --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_19.cu @@ -0,0 +1,33 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_2.cu b/src/instantiations/PBQG_P3GPBQG_2.cu index a4051897..5f7445c7 100644 --- a/src/instantiations/PBQG_P3GPBQG_2.cu +++ b/src/instantiations/PBQG_P3GPBQG_2.cu @@ -5,14 +5,15 @@ #include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -22,8 +23,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -32,14 +33,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,8 +51,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<2>::WorldBuffer v_splats_world, - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -59,14 +61,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -76,8 +79,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -86,14 +89,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -103,8 +107,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::WorldBuffer v_splats_world, + MipSplatting<0>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -113,14 +117,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -130,8 +135,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -140,14 +145,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -157,8 +163,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<2>::WorldBuffer v_splats_world, - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -167,14 +173,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -184,8 +191,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -194,14 +201,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -211,8 +219,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -221,14 +229,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -238,8 +247,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, diff --git a/src/instantiations/PBQG_P3GPBQG_3.cu b/src/instantiations/PBQG_P3GPBQG_3.cu index f18d8dbc..bbec40f9 100644 --- a/src/instantiations/PBQG_P3GPBQG_3.cu +++ b/src/instantiations/PBQG_P3GPBQG_3.cu @@ -5,14 +5,15 @@ #include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -22,8 +23,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<3>::WorldBuffer v_splats_world, - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -32,14 +33,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,8 +51,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -59,14 +61,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -76,8 +79,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -86,14 +89,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -103,8 +107,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -113,14 +117,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -130,8 +135,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<3>::WorldBuffer v_splats_world, - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -140,14 +145,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -157,8 +163,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -167,14 +173,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -184,8 +191,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -194,14 +201,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -211,8 +219,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -221,14 +229,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -238,8 +247,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGS<4>::WorldBuffer v_splats_world, - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, diff --git a/src/instantiations/PBQG_P3GPBQG_4.cu b/src/instantiations/PBQG_P3GPBQG_4.cu index 2d0e10f4..524cf475 100644 --- a/src/instantiations/PBQG_P3GPBQG_4.cu +++ b/src/instantiations/PBQG_P3GPBQG_4.cu @@ -5,14 +5,15 @@ #include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<4>, - CameraModelType::PINHOLE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -22,8 +23,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -32,14 +33,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,8 +51,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -59,14 +61,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -76,8 +79,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -86,14 +89,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -103,8 +107,148 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - MipSplatting<4>::WorldBuffer v_splats_world, - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<1>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<1>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, diff --git a/src/instantiations/PBQG_P3GPBQG_5.cu b/src/instantiations/PBQG_P3GPBQG_5.cu index f2d51d48..f6d98fce 100644 --- a/src/instantiations/PBQG_P3GPBQG_5.cu +++ b/src/instantiations/PBQG_P3GPBQG_5.cu @@ -1,18 +1,19 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -22,8 +23,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -32,14 +33,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,8 +51,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -59,14 +61,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -76,8 +79,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -86,14 +89,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -103,8 +107,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<0>::WorldBuffer v_splats_world, - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -113,14 +117,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -130,8 +135,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -140,14 +145,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -157,8 +163,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -167,14 +173,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -184,8 +191,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -194,14 +201,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -211,8 +219,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<1>::WorldBuffer v_splats_world, - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -221,14 +229,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -238,8 +247,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, diff --git a/src/instantiations/PBQG_P3GPBQG_6.cu b/src/instantiations/PBQG_P3GPBQG_6.cu index d83e271b..596d057f 100644 --- a/src/instantiations/PBQG_P3GPBQG_6.cu +++ b/src/instantiations/PBQG_P3GPBQG_6.cu @@ -1,18 +1,19 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -22,8 +23,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -32,14 +33,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,8 +51,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -59,14 +61,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<2>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -76,8 +79,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<2>::WorldBuffer v_splats_world, - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -86,14 +89,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -103,8 +107,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -113,14 +117,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -130,8 +135,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -140,14 +145,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -157,8 +163,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -167,14 +173,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -184,8 +191,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<3>::WorldBuffer v_splats_world, - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -194,14 +201,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -211,8 +219,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -221,14 +229,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -238,8 +247,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, diff --git a/src/instantiations/PBQG_P3GPBQG_7.cu b/src/instantiations/PBQG_P3GPBQG_7.cu index 85c49a75..93679587 100644 --- a/src/instantiations/PBQG_P3GPBQG_7.cu +++ b/src/instantiations/PBQG_P3GPBQG_7.cu @@ -1,18 +1,19 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -22,8 +23,8 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, @@ -32,14 +33,15 @@ template void projection_bwd_quantgrad_kernel_wrapper< ); template void projection_bwd_quantgrad_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, const uint32_t num_sh_buffer, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, const float4 * intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,8 +51,204 @@ template void projection_bwd_quantgrad_kernel_wrapper< const int32_t * camera_ids, const int32_t * perm, const float4 * aabb, - Vanilla3DGUT<4>::WorldBuffer v_splats_world, - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<2>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<2>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, GradQuantBuffers gq, const uint8_t* sh_value_packed, const float2* sh_value_bounds, diff --git a/src/instantiations/PBQG_P3GPBQG_8.cu b/src/instantiations/PBQG_P3GPBQG_8.cu new file mode 100644 index 00000000..e67cfa57 --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_8.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PBQG_P3GPBQG_9.cu b/src/instantiations/PBQG_P3GPBQG_9.cu new file mode 100644 index 00000000..1791f701 --- /dev/null +++ b/src/instantiations/PBQG_P3GPBQG_9.cu @@ -0,0 +1,257 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh" + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + MipSplatting<3>::WorldBuffer v_splats_world, + MipSplatting<3>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); + +template void projection_bwd_quantgrad_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + const uint32_t num_sh_buffer, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, + const float4 * intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int32_t * camera_id_bounds, + const int32_t * camera_ids, + const int32_t * perm, + const float4 * aabb, + Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + GradQuantBuffers gq, + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const int64_t sh_value_bounds_stride, + const int sh_value_bits +); diff --git a/src/instantiations/PB_P3GPB.cu b/src/instantiations/PB_P3GPB.cu index dd766c96..7e82f3f7 100644 --- a/src/instantiations/PB_P3GPB.cu +++ b/src/instantiations/PB_P3GPB.cu @@ -6,7 +6,8 @@ template void projection_fused_bwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::PINHOLE + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs @@ -38,7 +39,8 @@ template void projection_fused_bwd_kernel_wrapper< template void projection_fused_bwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs @@ -70,7 +72,8 @@ template void projection_fused_bwd_kernel_wrapper< template void projection_fused_bwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs @@ -102,7 +105,8 @@ template void projection_fused_bwd_kernel_wrapper< template void projection_fused_bwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, // fwd inputs @@ -133,14 +137,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -151,9 +156,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -165,14 +170,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -183,9 +189,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -197,14 +203,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -215,9 +222,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -229,14 +236,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -247,9 +255,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<0>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -261,14 +269,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -279,9 +288,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. diff --git a/src/instantiations/PB_P3GPB_1.cu b/src/instantiations/PB_P3GPB_1.cu index d671b19f..291359ca 100644 --- a/src/instantiations/PB_P3GPB_1.cu +++ b/src/instantiations/PB_P3GPB_1.cu @@ -5,14 +5,15 @@ #include "kernels/projection/ProjectionBwd_kernel.cuh" template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -23,9 +24,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -37,14 +38,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -55,9 +57,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<0>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<1>::WorldBuffer v_splats_world, + Vanilla3DGS<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -69,14 +71,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -87,9 +90,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<1>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -101,14 +104,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -119,9 +123,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -133,14 +137,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -151,9 +156,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -165,14 +170,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -183,9 +189,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -197,14 +203,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -215,9 +222,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<1>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<1>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -229,14 +236,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -247,9 +255,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<2>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -261,14 +269,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -279,9 +288,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<2>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. diff --git a/src/instantiations/PB_P3GPB_10.cu b/src/instantiations/PB_P3GPB_10.cu new file mode 100644 index 00000000..f67a62d4 --- /dev/null +++ b/src/instantiations/PB_P3GPB_10.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_11.cu b/src/instantiations/PB_P3GPB_11.cu new file mode 100644 index 00000000..f90bcc2c --- /dev/null +++ b/src/instantiations/PB_P3GPB_11.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_12.cu b/src/instantiations/PB_P3GPB_12.cu new file mode 100644 index 00000000..ea448258 --- /dev/null +++ b/src/instantiations/PB_P3GPB_12.cu @@ -0,0 +1,71 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<4>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_13.cu b/src/instantiations/PB_P3GPB_13.cu new file mode 100644 index 00000000..49b888ba --- /dev/null +++ b/src/instantiations/PB_P3GPB_13.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_14.cu b/src/instantiations/PB_P3GPB_14.cu new file mode 100644 index 00000000..97d5d30f --- /dev/null +++ b/src/instantiations/PB_P3GPB_14.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_15.cu b/src/instantiations/PB_P3GPB_15.cu new file mode 100644 index 00000000..a004f98c --- /dev/null +++ b/src/instantiations/PB_P3GPB_15.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_16.cu b/src/instantiations/PB_P3GPB_16.cu new file mode 100644 index 00000000..c44e780b --- /dev/null +++ b/src/instantiations/PB_P3GPB_16.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_17.cu b/src/instantiations/PB_P3GPB_17.cu new file mode 100644 index 00000000..d81144da --- /dev/null +++ b/src/instantiations/PB_P3GPB_17.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_18.cu b/src/instantiations/PB_P3GPB_18.cu new file mode 100644 index 00000000..519f0ee5 --- /dev/null +++ b/src/instantiations/PB_P3GPB_18.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_19.cu b/src/instantiations/PB_P3GPB_19.cu new file mode 100644 index 00000000..eba97bb9 --- /dev/null +++ b/src/instantiations/PB_P3GPB_19.cu @@ -0,0 +1,38 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGUT<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_2.cu b/src/instantiations/PB_P3GPB_2.cu index 9e78708b..face427c 100644 --- a/src/instantiations/PB_P3GPB_2.cu +++ b/src/instantiations/PB_P3GPB_2.cu @@ -5,14 +5,15 @@ #include "kernels/projection/ProjectionBwd_kernel.cuh" template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -23,9 +24,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<2>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -37,14 +38,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -55,9 +57,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<2>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -69,14 +71,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -87,9 +90,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -101,14 +104,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -119,9 +123,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<2>::ScreenBuffer v_splats_screen, + MipSplatting<0>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<2>::WorldBuffer v_splats_world, + MipSplatting<0>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -133,14 +137,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -151,9 +156,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<2>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -165,14 +170,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -183,9 +189,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<2>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -197,14 +203,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -215,9 +222,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -229,14 +236,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -247,9 +255,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -261,14 +269,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -279,9 +288,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. diff --git a/src/instantiations/PB_P3GPB_3.cu b/src/instantiations/PB_P3GPB_3.cu index f5010609..6c424ccf 100644 --- a/src/instantiations/PB_P3GPB_3.cu +++ b/src/instantiations/PB_P3GPB_3.cu @@ -5,14 +5,15 @@ #include "kernels/projection/ProjectionBwd_kernel.cuh" template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -23,9 +24,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<3>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -37,14 +38,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -55,9 +57,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<3>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -69,14 +71,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -87,9 +90,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<3>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -101,14 +104,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -119,9 +123,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<3>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -133,14 +137,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -151,9 +156,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<3>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<3>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -165,14 +170,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -183,9 +189,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + Vanilla3DGS<1>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<4>::WorldBuffer v_splats_world, + Vanilla3DGS<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -197,14 +203,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -215,9 +222,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<4>::WorldBuffer v_splats_world, + MipSplatting<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -229,14 +236,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -247,9 +255,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<4>::WorldBuffer v_splats_world, + MipSplatting<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -261,14 +269,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -279,9 +288,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGS<4>::WorldBuffer v_splats_world, + MipSplatting<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. diff --git a/src/instantiations/PB_P3GPB_4.cu b/src/instantiations/PB_P3GPB_4.cu index 4b47e7d5..7f7f755d 100644 --- a/src/instantiations/PB_P3GPB_4.cu +++ b/src/instantiations/PB_P3GPB_4.cu @@ -5,14 +5,15 @@ #include "kernels/projection/ProjectionBwd_kernel.cuh" template void projection_fused_bwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::PINHOLE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -23,9 +24,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -37,14 +38,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -55,9 +57,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -69,14 +71,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -87,9 +90,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<1>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -101,14 +104,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -119,9 +123,174 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - MipSplatting<4>::ScreenBuffer v_splats_screen, + MipSplatting<1>::ScreenBuffer v_splats_screen, // grad inputs - MipSplatting<4>::WorldBuffer v_splats_world, + MipSplatting<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<1>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<1>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<1>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<1>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<1>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. diff --git a/src/instantiations/PB_P3GPB_5.cu b/src/instantiations/PB_P3GPB_5.cu index 09d83b84..f56cf947 100644 --- a/src/instantiations/PB_P3GPB_5.cu +++ b/src/instantiations/PB_P3GPB_5.cu @@ -1,18 +1,19 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionBwd_kernel.cuh" template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -23,9 +24,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -37,14 +38,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -55,9 +57,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -69,14 +71,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -87,9 +90,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -101,14 +104,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -119,9 +123,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<0>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<0>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -133,14 +137,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -151,9 +156,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -165,14 +170,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -183,9 +189,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -197,14 +203,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -215,9 +222,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -229,14 +236,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -247,9 +255,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<1>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<1>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -261,14 +269,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -279,9 +288,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. diff --git a/src/instantiations/PB_P3GPB_6.cu b/src/instantiations/PB_P3GPB_6.cu index c554f172..1de78c04 100644 --- a/src/instantiations/PB_P3GPB_6.cu +++ b/src/instantiations/PB_P3GPB_6.cu @@ -1,18 +1,19 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionBwd_kernel.cuh" template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -23,9 +24,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + Vanilla3DGS<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<2>::WorldBuffer v_splats_world, + Vanilla3DGS<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -37,14 +38,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -55,9 +57,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<2>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -69,14 +71,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -87,9 +90,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<2>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<2>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -101,14 +104,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -119,9 +123,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<3>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -133,14 +137,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -151,9 +156,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<3>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -165,14 +170,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -183,9 +189,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<3>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -197,14 +203,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -215,9 +222,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<3>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<3>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -229,14 +236,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -247,9 +255,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<4>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -261,14 +269,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -279,9 +288,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<4>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. diff --git a/src/instantiations/PB_P3GPB_7.cu b/src/instantiations/PB_P3GPB_7.cu index ced1ac73..4e8d248b 100644 --- a/src/instantiations/PB_P3GPB_7.cu +++ b/src/instantiations/PB_P3GPB_7.cu @@ -1,18 +1,19 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionBwd_kernel.cuh" template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -23,9 +24,9 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<4>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. @@ -37,14 +38,15 @@ template void projection_fused_bwd_kernel_wrapper< ); template void projection_fused_bwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, // fwd inputs const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float * viewmats, // [C, 4, 4] const float4 * intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -55,9 +57,240 @@ template void projection_fused_bwd_kernel_wrapper< const int32_t * gaussian_ids, // [nnz, 4] const float4 * aabb, // [C, N, 4] // grad outputs - Vanilla3DGUT<4>::ScreenBuffer v_splats_screen, + MipSplatting<2>::ScreenBuffer v_splats_screen, // grad inputs - Vanilla3DGUT<4>::WorldBuffer v_splats_world, + MipSplatting<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<2>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<2>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<2>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, float * v_viewmats, // [C, 4, 4] optional // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel // args; the bwd uses them to evaluate v_dir against the codec'd SH. diff --git a/src/instantiations/PB_P3GPB_8.cu b/src/instantiations/PB_P3GPB_8.cu new file mode 100644 index 00000000..84bd1f28 --- /dev/null +++ b/src/instantiations/PB_P3GPB_8.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<3>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PB_P3GPB_9.cu b/src/instantiations/PB_P3GPB_9.cu new file mode 100644 index 00000000..80ec9119 --- /dev/null +++ b/src/instantiations/PB_P3GPB_9.cu @@ -0,0 +1,302 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionBwd_kernel.cuh" + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + MipSplatting<3>::ScreenBuffer v_splats_screen, + // grad inputs + MipSplatting<3>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_fused_bwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + // fwd inputs + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float * viewmats, // [C, 4, 4] + const float4 * intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // fwd outputs + const int32_t * camera_ids, // [nnz, 4] + const int32_t * gaussian_ids, // [nnz, 4] + const float4 * aabb, // [C, N, 4] + // grad outputs + Vanilla3DGS<4>::ScreenBuffer v_splats_screen, + // grad inputs + Vanilla3DGS<4>::WorldBuffer v_splats_world, + float * v_viewmats, // [C, 4, 4] optional + // SH VALUE-quant (active when sh_value_bits != 32). Mirrors fwd kernel + // args; the bwd uses them to evaluate v_dir against the codec'd SH. + const uint8_t* sh_value_packed, + const float2* sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF.cu b/src/instantiations/PF_P3GPF.cu index 948b8d97..5bf32895 100644 --- a/src/instantiations/PF_P3GPF.cu +++ b/src/instantiations/PF_P3GPF.cu @@ -6,7 +6,8 @@ template void projection_fused_fwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::PINHOLE + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, @@ -34,7 +35,8 @@ template void projection_fused_fwd_kernel_wrapper< template void projection_fused_fwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, @@ -62,7 +64,8 @@ template void projection_fused_fwd_kernel_wrapper< template void projection_fused_fwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, @@ -90,7 +93,8 @@ template void projection_fused_fwd_kernel_wrapper< template void projection_fused_fwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, @@ -117,13 +121,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -133,7 +138,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<0>::ScreenBuffer splats_screen, + Vanilla3DGS<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -161,7 +167,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<0>::ScreenBuffer splats_screen, + Vanilla3DGS<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -189,7 +196,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<0>::ScreenBuffer splats_screen, + Vanilla3DGS<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -217,7 +225,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<0>::ScreenBuffer splats_screen, + Vanilla3DGS<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -245,7 +254,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<1>::ScreenBuffer splats_screen, + Vanilla3DGS<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PF_P3GPF_1.cu b/src/instantiations/PF_P3GPF_1.cu index 9cfc9010..0faf3452 100644 --- a/src/instantiations/PF_P3GPF_1.cu +++ b/src/instantiations/PF_P3GPF_1.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionFwd_kernel.cuh" template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -21,7 +22,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<1>::ScreenBuffer splats_screen, + Vanilla3DGS<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, + Vanilla3DGS<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,7 +51,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<1>::ScreenBuffer splats_screen, + Vanilla3DGS<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -77,7 +80,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<1>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -105,7 +109,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<1>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -133,7 +138,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<1>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -161,7 +167,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<1>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -189,7 +196,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<1>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -217,7 +225,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<2>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -245,7 +254,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<2>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PF_P3GPF_10.cu b/src/instantiations/PF_P3GPF_10.cu new file mode 100644 index 00000000..ec1af439 --- /dev/null +++ b/src/instantiations/PF_P3GPF_10.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_11.cu b/src/instantiations/PF_P3GPF_11.cu new file mode 100644 index 00000000..b294e504 --- /dev/null +++ b/src/instantiations/PF_P3GPF_11.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_12.cu b/src/instantiations/PF_P3GPF_12.cu new file mode 100644 index 00000000..463de8cb --- /dev/null +++ b/src/instantiations/PF_P3GPF_12.cu @@ -0,0 +1,63 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_13.cu b/src/instantiations/PF_P3GPF_13.cu new file mode 100644 index 00000000..eb5c92a5 --- /dev/null +++ b/src/instantiations/PF_P3GPF_13.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_14.cu b/src/instantiations/PF_P3GPF_14.cu new file mode 100644 index 00000000..d6b3bc6a --- /dev/null +++ b/src/instantiations/PF_P3GPF_14.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_15.cu b/src/instantiations/PF_P3GPF_15.cu new file mode 100644 index 00000000..ed6d7777 --- /dev/null +++ b/src/instantiations/PF_P3GPF_15.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_16.cu b/src/instantiations/PF_P3GPF_16.cu new file mode 100644 index 00000000..116a8f55 --- /dev/null +++ b/src/instantiations/PF_P3GPF_16.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_17.cu b/src/instantiations/PF_P3GPF_17.cu new file mode 100644 index 00000000..fa8a0546 --- /dev/null +++ b/src/instantiations/PF_P3GPF_17.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_18.cu b/src/instantiations/PF_P3GPF_18.cu new file mode 100644 index 00000000..a4b91f2f --- /dev/null +++ b/src/instantiations/PF_P3GPF_18.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_19.cu b/src/instantiations/PF_P3GPF_19.cu new file mode 100644 index 00000000..59bf5c90 --- /dev/null +++ b/src/instantiations/PF_P3GPF_19.cu @@ -0,0 +1,34 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_2.cu b/src/instantiations/PF_P3GPF_2.cu index 885319a1..0b1dca62 100644 --- a/src/instantiations/PF_P3GPF_2.cu +++ b/src/instantiations/PF_P3GPF_2.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionFwd_kernel.cuh" template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -21,7 +22,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<2>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,7 +51,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<2>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -77,7 +80,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<2>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, + MipSplatting<0>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -105,7 +109,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<2>::ScreenBuffer splats_screen, + MipSplatting<0>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -133,7 +138,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<2>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -161,7 +167,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<2>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -189,7 +196,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<3>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -217,7 +225,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<3>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -245,7 +254,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<3>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PF_P3GPF_3.cu b/src/instantiations/PF_P3GPF_3.cu index 77e2d0d3..e7ceebe3 100644 --- a/src/instantiations/PF_P3GPF_3.cu +++ b/src/instantiations/PF_P3GPF_3.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionFwd_kernel.cuh" template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -21,7 +22,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<3>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,7 +51,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<3>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -77,7 +80,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<3>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -105,7 +109,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<3>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -133,7 +138,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<3>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, + Vanilla3DGS<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -161,7 +167,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<4>::ScreenBuffer splats_screen, + Vanilla3DGS<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -189,7 +196,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<4>::ScreenBuffer splats_screen, + MipSplatting<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -217,7 +225,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<4>::ScreenBuffer splats_screen, + MipSplatting<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -245,7 +254,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGS<4>::ScreenBuffer splats_screen, + MipSplatting<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PF_P3GPF_4.cu b/src/instantiations/PF_P3GPF_4.cu index cb288800..c3c74185 100644 --- a/src/instantiations/PF_P3GPF_4.cu +++ b/src/instantiations/PF_P3GPF_4.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionFwd_kernel.cuh" template void projection_fused_fwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::PINHOLE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -21,7 +22,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<4>::ScreenBuffer splats_screen, + MipSplatting<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,7 +51,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<4>::ScreenBuffer splats_screen, + MipSplatting<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -77,7 +80,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<4>::ScreenBuffer splats_screen, + MipSplatting<1>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, + MipSplatting<1>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -105,7 +109,152 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - MipSplatting<4>::ScreenBuffer splats_screen, + MipSplatting<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<1>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PF_P3GPF_5.cu b/src/instantiations/PF_P3GPF_5.cu index 7087f234..c16f1110 100644 --- a/src/instantiations/PF_P3GPF_5.cu +++ b/src/instantiations/PF_P3GPF_5.cu @@ -1,17 +1,18 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionFwd_kernel.cuh" template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -21,7 +22,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<0>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,7 +51,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<0>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -77,7 +80,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<0>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -105,7 +109,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<0>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -133,7 +138,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<1>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -161,7 +167,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<1>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -189,7 +196,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<1>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -217,7 +225,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<1>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -245,7 +254,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<2>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PF_P3GPF_6.cu b/src/instantiations/PF_P3GPF_6.cu index 64a3b68e..62277596 100644 --- a/src/instantiations/PF_P3GPF_6.cu +++ b/src/instantiations/PF_P3GPF_6.cu @@ -1,17 +1,18 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionFwd_kernel.cuh" template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, + Vanilla3DGS<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -21,7 +22,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<2>::ScreenBuffer splats_screen, + Vanilla3DGS<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,7 +51,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<2>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -77,7 +80,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<2>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -105,7 +109,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<3>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -133,7 +138,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<3>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -161,7 +167,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<3>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -189,7 +196,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<3>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -217,7 +225,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<4>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -245,7 +254,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<4>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PF_P3GPF_7.cu b/src/instantiations/PF_P3GPF_7.cu index d9ccf29e..496f8430 100644 --- a/src/instantiations/PF_P3GPF_7.cu +++ b/src/instantiations/PF_P3GPF_7.cu @@ -1,17 +1,18 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionFwd_kernel.cuh" template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -21,7 +22,7 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<4>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_fused_fwd_kernel_wrapper< ); template void projection_fused_fwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, + MipSplatting<2>::WorldBuffer splats_world, const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,7 +51,210 @@ template void projection_fused_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [C, N, 4] float *__restrict__ sorting_depths, // [C, N, 1] float *__restrict__ radii, // [N, 1] - Vanilla3DGUT<4>::ScreenBuffer splats_screen, + MipSplatting<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<2>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<2>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PF_P3GPF_8.cu b/src/instantiations/PF_P3GPF_8.cu new file mode 100644 index 00000000..6f73c6fe --- /dev/null +++ b/src/instantiations/PF_P3GPF_8.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PF_P3GPF_9.cu b/src/instantiations/PF_P3GPF_9.cu new file mode 100644 index 00000000..c8290346 --- /dev/null +++ b/src/instantiations/PF_P3GPF_9.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionFwd_kernel.cuh" + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + MipSplatting<3>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); + +template void projection_fused_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + float4 *__restrict__ aabbs, // [C, N, 4] + float *__restrict__ sorting_depths, // [C, N, 1] + float *__restrict__ radii, // [N, 1] + Vanilla3DGS<4>::ScreenBuffer splats_screen, + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + // sh_bounds_stride: cells per value-quant bound. 0 (default) = per-splat + // block (256 * 3 * num_sh_buffer cells/bound, matching FPBO allocation). + // 256 = per-cell block (non-FPBO value-quant allocation). + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF.cu b/src/instantiations/PPF_P3GPPF.cu index 48e7df67..d9ae3c75 100644 --- a/src/instantiations/PPF_P3GPPF.cu +++ b/src/instantiations/PPF_P3GPPF.cu @@ -6,7 +6,8 @@ template void projection_packed_fwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::PINHOLE + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, @@ -34,7 +35,8 @@ template void projection_packed_fwd_kernel_wrapper< template void projection_packed_fwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, @@ -62,7 +64,8 @@ template void projection_packed_fwd_kernel_wrapper< template void projection_packed_fwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, @@ -90,7 +93,8 @@ template void projection_packed_fwd_kernel_wrapper< template void projection_packed_fwd_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, @@ -117,13 +121,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -136,7 +141,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -164,7 +170,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -192,7 +199,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -220,7 +228,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -248,7 +257,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PPF_P3GPPF_1.cu b/src/instantiations/PPF_P3GPPF_1.cu index 4fe37fed..6804b954 100644 --- a/src/instantiations/PPF_P3GPPF_1.cu +++ b/src/instantiations/PPF_P3GPPF_1.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -24,7 +25,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -52,7 +54,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -80,7 +83,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -108,7 +112,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -136,7 +141,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -164,7 +170,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -192,7 +199,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -220,7 +228,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -248,7 +257,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PPF_P3GPPF_10.cu b/src/instantiations/PPF_P3GPPF_10.cu new file mode 100644 index 00000000..4ecd2222 --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_10.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_11.cu b/src/instantiations/PPF_P3GPPF_11.cu new file mode 100644 index 00000000..6d0ed28d --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_11.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_12.cu b/src/instantiations/PPF_P3GPPF_12.cu new file mode 100644 index 00000000..68d47c9c --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_12.cu @@ -0,0 +1,63 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_13.cu b/src/instantiations/PPF_P3GPPF_13.cu new file mode 100644 index 00000000..996abf0e --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_13.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_14.cu b/src/instantiations/PPF_P3GPPF_14.cu new file mode 100644 index 00000000..c05d9fe7 --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_14.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_15.cu b/src/instantiations/PPF_P3GPPF_15.cu new file mode 100644 index 00000000..d5d82029 --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_15.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_16.cu b/src/instantiations/PPF_P3GPPF_16.cu new file mode 100644 index 00000000..f1d45a6a --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_16.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_17.cu b/src/instantiations/PPF_P3GPPF_17.cu new file mode 100644 index 00000000..6f3143d6 --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_17.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_18.cu b/src/instantiations/PPF_P3GPPF_18.cu new file mode 100644 index 00000000..b70553a8 --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_18.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_19.cu b/src/instantiations/PPF_P3GPPF_19.cu new file mode 100644 index 00000000..e71490f3 --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_19.cu @@ -0,0 +1,34 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_2.cu b/src/instantiations/PPF_P3GPPF_2.cu index 70442ecb..46fa9f06 100644 --- a/src/instantiations/PPF_P3GPPF_2.cu +++ b/src/instantiations/PPF_P3GPPF_2.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -24,7 +25,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -52,7 +54,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -80,7 +83,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -108,7 +112,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<0>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -136,7 +141,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -164,7 +170,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -192,7 +199,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -220,7 +228,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -248,7 +257,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PPF_P3GPPF_3.cu b/src/instantiations/PPF_P3GPPF_3.cu index 498e8633..bf1b0916 100644 --- a/src/instantiations/PPF_P3GPPF_3.cu +++ b/src/instantiations/PPF_P3GPPF_3.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -24,7 +25,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -52,7 +54,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -80,7 +83,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -108,7 +112,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -136,7 +141,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -164,7 +170,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -192,7 +199,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -220,7 +228,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -248,7 +257,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PPF_P3GPPF_4.cu b/src/instantiations/PPF_P3GPPF_4.cu index db9d72a1..0c49a3aa 100644 --- a/src/instantiations/PPF_P3GPPF_4.cu +++ b/src/instantiations/PPF_P3GPPF_4.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_fwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::PINHOLE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -24,7 +25,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -52,7 +54,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -80,7 +83,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -108,7 +112,152 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - MipSplatting<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<1>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PPF_P3GPPF_5.cu b/src/instantiations/PPF_P3GPPF_5.cu index 05300d70..5a950a2c 100644 --- a/src/instantiations/PPF_P3GPPF_5.cu +++ b/src/instantiations/PPF_P3GPPF_5.cu @@ -1,17 +1,18 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -24,7 +25,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -52,7 +54,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -80,7 +83,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -108,7 +112,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<0>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -136,7 +141,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -164,7 +170,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -192,7 +199,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -220,7 +228,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<1>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -248,7 +257,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PPF_P3GPPF_6.cu b/src/instantiations/PPF_P3GPPF_6.cu index b298cb38..5d8b1fce 100644 --- a/src/instantiations/PPF_P3GPPF_6.cu +++ b/src/instantiations/PPF_P3GPPF_6.cu @@ -1,17 +1,18 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -24,7 +25,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + Vanilla3DGS<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -52,7 +54,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -61,13 +63,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -80,7 +83,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<2>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -89,13 +92,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -108,7 +112,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -117,13 +121,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -136,7 +141,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -145,13 +150,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -164,7 +170,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -173,13 +179,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -192,7 +199,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<3>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -201,13 +208,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -220,7 +228,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -229,13 +237,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -248,7 +257,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PPF_P3GPPF_7.cu b/src/instantiations/PPF_P3GPPF_7.cu index f4ee07bf..261e7f7d 100644 --- a/src/instantiations/PPF_P3GPPF_7.cu +++ b/src/instantiations/PPF_P3GPPF_7.cu @@ -1,17 +1,18 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -24,7 +25,7 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, @@ -33,13 +34,14 @@ template void projection_packed_fwd_kernel_wrapper< ); template void projection_packed_fwd_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -52,7 +54,210 @@ template void projection_packed_fwd_kernel_wrapper< float4 *__restrict__ aabbs, // [nnz, 4] float *__restrict__ sorting_depths, // [nnz] float *__restrict__ radii, // [N] - Vanilla3DGUT<4>::ScreenBuffer splats_screen, // [nnz, ...] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<2>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] const uint8_t* __restrict__ sh_value_packed, const float2* __restrict__ sh_value_bounds, const uint32_t num_sh_buffer, diff --git a/src/instantiations/PPF_P3GPPF_8.cu b/src/instantiations/PPF_P3GPPF_8.cu new file mode 100644 index 00000000..ef037add --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_8.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPF_P3GPPF_9.cu b/src/instantiations/PPF_P3GPPF_9.cu new file mode 100644 index 00000000..a230b63d --- /dev/null +++ b/src/instantiations/PPF_P3GPPF_9.cu @@ -0,0 +1,266 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + MipSplatting<3>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_fwd_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + const int64_t* __restrict__ intersection_mask_scan, // [C, N], inclusive scan + // outputs + int32_t *__restrict__ camera_ids, // [nnz] + int32_t *__restrict__ gaussian_ids, // [nnz] + float4 *__restrict__ aabbs, // [nnz, 4] + float *__restrict__ sorting_depths, // [nnz] + float *__restrict__ radii, // [N] + Vanilla3DGS<4>::ScreenBuffer splats_screen, // [nnz, ...] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF.cu b/src/instantiations/PPM_P3GPPF.cu index ed2a637a..04666585 100644 --- a/src/instantiations/PPM_P3GPPF.cu +++ b/src/instantiations/PPM_P3GPPF.cu @@ -6,7 +6,8 @@ template void projection_packed_mask_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::PINHOLE + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, @@ -28,7 +29,8 @@ template void projection_packed_mask_kernel_wrapper< template void projection_packed_mask_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::FISHEYE + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, @@ -50,7 +52,8 @@ template void projection_packed_mask_kernel_wrapper< template void projection_packed_mask_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUISOLID + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, @@ -72,7 +75,8 @@ template void projection_packed_mask_kernel_wrapper< template void projection_packed_mask_kernel_wrapper< Vanilla3DGS<0>, - CameraModelType::EQUIRECTANGULAR + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, @@ -93,13 +97,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<0>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -115,13 +120,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<0>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -137,13 +143,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -159,13 +166,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -181,13 +189,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::PINHOLE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, diff --git a/src/instantiations/PPM_P3GPPF_1.cu b/src/instantiations/PPM_P3GPPF_1.cu index 8cdb3d51..afe49de2 100644 --- a/src/instantiations/PPM_P3GPPF_1.cu +++ b/src/instantiations/PPM_P3GPPF_1.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::FISHEYE + Vanilla3DGS<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -27,13 +28,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,13 +51,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -71,13 +74,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<1>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -93,13 +97,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<1>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -115,13 +120,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -137,13 +143,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<1>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -159,13 +166,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -181,13 +189,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, diff --git a/src/instantiations/PPM_P3GPPF_10.cu b/src/instantiations/PPM_P3GPPF_10.cu new file mode 100644 index 00000000..d185a568 --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_10.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_11.cu b/src/instantiations/PPM_P3GPPF_11.cu new file mode 100644 index 00000000..8aa11e3f --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_11.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_12.cu b/src/instantiations/PPM_P3GPPF_12.cu new file mode 100644 index 00000000..66ff2e18 --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_12.cu @@ -0,0 +1,51 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_13.cu b/src/instantiations/PPM_P3GPPF_13.cu new file mode 100644 index 00000000..c7b99366 --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_13.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_14.cu b/src/instantiations/PPM_P3GPPF_14.cu new file mode 100644 index 00000000..a911a00a --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_14.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_15.cu b/src/instantiations/PPM_P3GPPF_15.cu new file mode 100644 index 00000000..a71dde5c --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_15.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_16.cu b/src/instantiations/PPM_P3GPPF_16.cu new file mode 100644 index 00000000..a600e527 --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_16.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_17.cu b/src/instantiations/PPM_P3GPPF_17.cu new file mode 100644 index 00000000..7ad2f621 --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_17.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_18.cu b/src/instantiations/PPM_P3GPPF_18.cu new file mode 100644 index 00000000..208a7c4f --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_18.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_19.cu b/src/instantiations/PPM_P3GPPF_19.cu new file mode 100644 index 00000000..fb8f4ed7 --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_19.cu @@ -0,0 +1,28 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGUT<4>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_2.cu b/src/instantiations/PPM_P3GPPF_2.cu index 48d9a58e..f0bdff5a 100644 --- a/src/instantiations/PPM_P3GPPF_2.cu +++ b/src/instantiations/PPM_P3GPPF_2.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUISOLID + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -27,13 +28,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,13 +51,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<2>, - CameraModelType::PINHOLE + MipSplatting<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -71,13 +74,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<2>, - CameraModelType::FISHEYE + MipSplatting<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<0>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -93,13 +97,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -115,13 +120,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<2>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -137,13 +143,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -159,13 +166,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -181,13 +189,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, diff --git a/src/instantiations/PPM_P3GPPF_3.cu b/src/instantiations/PPM_P3GPPF_3.cu index 5db1d952..95d3ae08 100644 --- a/src/instantiations/PPM_P3GPPF_3.cu +++ b/src/instantiations/PPM_P3GPPF_3.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -27,13 +28,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<3>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,13 +51,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<3>, - CameraModelType::FISHEYE + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -71,13 +74,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUISOLID + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -93,13 +97,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<3>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -115,13 +120,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::PINHOLE + Vanilla3DGS<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -137,13 +143,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -159,13 +166,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -181,13 +189,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGS<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, diff --git a/src/instantiations/PPM_P3GPPF_4.cu b/src/instantiations/PPM_P3GPPF_4.cu index 86c71bd1..0f86f545 100644 --- a/src/instantiations/PPM_P3GPPF_4.cu +++ b/src/instantiations/PPM_P3GPPF_4.cu @@ -5,13 +5,14 @@ #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_mask_kernel_wrapper< - MipSplatting<4>, - CameraModelType::PINHOLE + MipSplatting<1>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -27,13 +28,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<4>, - CameraModelType::FISHEYE + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,13 +51,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUISOLID + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -71,13 +74,129 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - MipSplatting<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<1>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - MipSplatting<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<1>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<1>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, diff --git a/src/instantiations/PPM_P3GPPF_5.cu b/src/instantiations/PPM_P3GPPF_5.cu index 23980cf3..60806a4a 100644 --- a/src/instantiations/PPM_P3GPPF_5.cu +++ b/src/instantiations/PPM_P3GPPF_5.cu @@ -1,17 +1,18 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -27,13 +28,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,13 +51,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -71,13 +74,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<0>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -93,13 +97,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -115,13 +120,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -137,13 +143,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUISOLID + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -159,13 +166,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<1>, - CameraModelType::EQUIRECTANGULAR + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<1>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -181,13 +189,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::PINHOLE + Vanilla3DGS<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, diff --git a/src/instantiations/PPM_P3GPPF_6.cu b/src/instantiations/PPM_P3GPPF_6.cu index a115bf09..faefe6ad 100644 --- a/src/instantiations/PPM_P3GPPF_6.cu +++ b/src/instantiations/PPM_P3GPPF_6.cu @@ -1,17 +1,18 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::FISHEYE + Vanilla3DGS<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + Vanilla3DGS<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -27,13 +28,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -49,13 +51,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<2>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<2>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -71,13 +74,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -93,13 +97,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -115,13 +120,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -137,13 +143,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<3>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<3>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -159,13 +166,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::PINHOLE + MipSplatting<2>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -181,13 +189,14 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::FISHEYE + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::None >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, diff --git a/src/instantiations/PPM_P3GPPF_7.cu b/src/instantiations/PPM_P3GPPF_7.cu index 8fe7bdab..c69cb694 100644 --- a/src/instantiations/PPM_P3GPPF_7.cu +++ b/src/instantiations/PPM_P3GPPF_7.cu @@ -1,17 +1,18 @@ // This file is auto generated by `generate_kernel_instantiation.py` #define NO_TORCH -#include "primitives/Primitive3DGUT.cuh" +#include "primitives/Primitive3DGS.cuh" #include "kernels/projection/ProjectionPackedFwd_kernel.cuh" template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUISOLID + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, @@ -27,13 +28,175 @@ template void projection_packed_mask_kernel_wrapper< ); template void projection_packed_mask_kernel_wrapper< - Vanilla3DGUT<4>, - CameraModelType::EQUIRECTANGULAR + MipSplatting<2>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism >( cudaStream_t stream, const uint32_t C, const uint32_t N, - Vanilla3DGUT<4>::WorldBuffer splats_world, // [N, ...] + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<2>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<2>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] const float *__restrict__ viewmats, // [C, 4, 4] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const CameraDistortionCoeffsBuffer dist_coeffs_buffer, diff --git a/src/instantiations/PPM_P3GPPF_8.cu b/src/instantiations/PPM_P3GPPF_8.cu new file mode 100644 index 00000000..8079d30f --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_8.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::PINHOLE, + CameraDistortionType::Rational +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/PPM_P3GPPF_9.cu b/src/instantiations/PPM_P3GPPF_9.cu new file mode 100644 index 00000000..76ebf769 --- /dev/null +++ b/src/instantiations/PPM_P3GPPF_9.cu @@ -0,0 +1,212 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGS.cuh" +#include "kernels/projection/ProjectionPackedFwd_kernel.cuh" + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + MipSplatting<3>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + MipSplatting<3>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::None +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); + +template void projection_packed_mask_kernel_wrapper< + Vanilla3DGS<4>, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV +>( + cudaStream_t stream, + const uint32_t C, + const uint32_t N, + Vanilla3DGS<4>::WorldBuffer splats_world, // [N, ...] + const float *__restrict__ viewmats, // [C, 4, 4] + const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const uint32_t image_width, + const uint32_t image_height, + // outputs + bool *__restrict__ intersection_mask, // [C, N] + const uint8_t* __restrict__ sh_value_packed, + const float2* __restrict__ sh_value_bounds, + const uint32_t num_sh_buffer, + const int sh_value_bits, + const int64_t sh_bounds_stride +); diff --git a/src/instantiations/RE3B_P3GRE3B.cu b/src/instantiations/RE3B_P3GRE3B.cu index 6dcee923..ece2a03f 100644 --- a/src/instantiations/RE3B_P3GRE3B.cu +++ b/src/instantiations/RE3B_P3GRE3B.cu @@ -7,6 +7,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, true, true, @@ -52,6 +53,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, true, true, @@ -97,6 +99,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, true, false, @@ -142,6 +145,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, true, false, @@ -187,6 +191,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, false, true, @@ -232,6 +237,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, false, true, @@ -277,6 +283,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, false, false, @@ -322,6 +329,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, false, false, @@ -367,6 +375,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, true, true, diff --git a/src/instantiations/RE3B_P3GRE3B_1.cu b/src/instantiations/RE3B_P3GRE3B_1.cu index 987cc16b..9a80a839 100644 --- a/src/instantiations/RE3B_P3GRE3B_1.cu +++ b/src/instantiations/RE3B_P3GRE3B_1.cu @@ -7,6 +7,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, true, true, @@ -52,6 +53,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, true, false, @@ -97,6 +99,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, true, false, @@ -142,6 +145,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, false, true, @@ -187,6 +191,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, false, true, @@ -232,6 +237,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, false, false, @@ -277,6 +283,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, false, false, @@ -322,6 +329,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, true, true, @@ -367,6 +375,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, true, true, diff --git a/src/instantiations/RE3B_P3GRE3B_10.cu b/src/instantiations/RE3B_P3GRE3B_10.cu index 347462a1..8cdaae1b 100644 --- a/src/instantiations/RE3B_P3GRE3B_10.cu +++ b/src/instantiations/RE3B_P3GRE3B_10.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, true, false, @@ -51,7 +52,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, true, false, @@ -96,7 +98,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, false, true, @@ -141,7 +144,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, false, true, @@ -186,7 +190,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, false, false, @@ -231,7 +236,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, false, false, @@ -273,3 +279,141 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< float *__restrict__ o_accum_weight, float *__restrict__ v_viewmats // [B, C, 4, 4] ); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_11.cu b/src/instantiations/RE3B_P3GRE3B_11.cu new file mode 100644 index 00000000..01e8a087 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_11.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_12.cu b/src/instantiations/RE3B_P3GRE3B_12.cu new file mode 100644 index 00000000..7990519f --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_12.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_13.cu b/src/instantiations/RE3B_P3GRE3B_13.cu new file mode 100644 index 00000000..5c68f8c8 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_13.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_14.cu b/src/instantiations/RE3B_P3GRE3B_14.cu new file mode 100644 index 00000000..804291f8 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_14.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_15.cu b/src/instantiations/RE3B_P3GRE3B_15.cu new file mode 100644 index 00000000..dd8069f6 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_15.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_16.cu b/src/instantiations/RE3B_P3GRE3B_16.cu new file mode 100644 index 00000000..b14b038f --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_16.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_17.cu b/src/instantiations/RE3B_P3GRE3B_17.cu new file mode 100644 index 00000000..9e34c8e0 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_17.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_18.cu b/src/instantiations/RE3B_P3GRE3B_18.cu new file mode 100644 index 00000000..d4e418d6 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_18.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_19.cu b/src/instantiations/RE3B_P3GRE3B_19.cu new file mode 100644 index 00000000..81a85252 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_19.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_2.cu b/src/instantiations/RE3B_P3GRE3B_2.cu index aa1763ef..bdcc5dd8 100644 --- a/src/instantiations/RE3B_P3GRE3B_2.cu +++ b/src/instantiations/RE3B_P3GRE3B_2.cu @@ -7,6 +7,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, true, false, @@ -52,6 +53,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, true, false, @@ -97,6 +99,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, false, true, @@ -142,6 +145,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, false, true, @@ -187,6 +191,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, false, false, @@ -232,6 +237,7 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, false, false, @@ -276,7 +282,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, true, true, @@ -321,7 +328,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, true, true, @@ -366,7 +374,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, true, false, diff --git a/src/instantiations/RE3B_P3GRE3B_20.cu b/src/instantiations/RE3B_P3GRE3B_20.cu new file mode 100644 index 00000000..070f7bec --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_20.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_21.cu b/src/instantiations/RE3B_P3GRE3B_21.cu new file mode 100644 index 00000000..56b79e39 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_21.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_22.cu b/src/instantiations/RE3B_P3GRE3B_22.cu new file mode 100644 index 00000000..4961ce6b --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_22.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_23.cu b/src/instantiations/RE3B_P3GRE3B_23.cu new file mode 100644 index 00000000..b3a4ed7a --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_23.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_24.cu b/src/instantiations/RE3B_P3GRE3B_24.cu new file mode 100644 index 00000000..94c743c9 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_24.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_25.cu b/src/instantiations/RE3B_P3GRE3B_25.cu new file mode 100644 index 00000000..8d766818 --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_25.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_26.cu b/src/instantiations/RE3B_P3GRE3B_26.cu new file mode 100644 index 00000000..0f4b014d --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_26.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_27.cu b/src/instantiations/RE3B_P3GRE3B_27.cu new file mode 100644 index 00000000..f6e9c26f --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_27.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_28.cu b/src/instantiations/RE3B_P3GRE3B_28.cu new file mode 100644 index 00000000..33cd61da --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_28.cu @@ -0,0 +1,419 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + true, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + true, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_29.cu b/src/instantiations/RE3B_P3GRE3B_29.cu new file mode 100644 index 00000000..072a20de --- /dev/null +++ b/src/instantiations/RE3B_P3GRE3B_29.cu @@ -0,0 +1,143 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DBwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + true, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + false, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); + +template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + false, + false, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, // zero if packed + const uint32_t n_isects, + // fwd inputs + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [..., tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + // fwd outputs + const float *__restrict__ render_Ts, // [..., image_height, image_width, 1] + const int32_t *__restrict__ last_ids, // [..., image_height, image_width] + RenderOutput::Buffer render_output_buffer, + RenderOutput::Buffer render_distortion_buffer, + const float *__restrict__ loss_map_buffer, // [..., image_height, image_width, 1] + const float *__restrict__ accum_weight_map_buffer, // [..., image_height, image_width, 1] + // grad outputs + RenderOutput::Buffer v_render_output_buffer, + const float *__restrict__ v_render_Ts, // [..., image_height, image_width, 1] + const float *__restrict__ v_median, // [..., image_height, image_width, 1], optional + RenderOutput::Buffer v_distortions_output_buffer, + // grad inputs + Vanilla3DGUT<0>::WorldBuffer v_splat_wbuffer, + Vanilla3DGUT<0>::ScreenBuffer v_splat_sbuffer, + float *__restrict__ o_accum_weight, + float *__restrict__ v_viewmats // [B, C, 4, 4] +); diff --git a/src/instantiations/RE3B_P3GRE3B_3.cu b/src/instantiations/RE3B_P3GRE3B_3.cu index e80d02f0..21ab4358 100644 --- a/src/instantiations/RE3B_P3GRE3B_3.cu +++ b/src/instantiations/RE3B_P3GRE3B_3.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, true, false, @@ -51,7 +52,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, false, true, @@ -96,7 +98,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, false, true, @@ -141,7 +144,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, false, false, @@ -186,7 +190,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, false, false, @@ -231,7 +236,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, true, true, @@ -276,7 +282,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, true, true, @@ -321,7 +328,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, true, false, @@ -366,7 +374,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, true, false, diff --git a/src/instantiations/RE3B_P3GRE3B_4.cu b/src/instantiations/RE3B_P3GRE3B_4.cu index 41393db8..5882153d 100644 --- a/src/instantiations/RE3B_P3GRE3B_4.cu +++ b/src/instantiations/RE3B_P3GRE3B_4.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, false, true, @@ -51,7 +52,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, false, true, @@ -96,7 +98,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, false, false, @@ -141,7 +144,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, false, false, @@ -186,7 +190,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, true, true, @@ -231,7 +236,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, true, true, @@ -276,7 +282,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, true, false, @@ -321,7 +328,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, true, false, @@ -366,7 +374,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, false, true, diff --git a/src/instantiations/RE3B_P3GRE3B_5.cu b/src/instantiations/RE3B_P3GRE3B_5.cu index 2df9ee2f..16836306 100644 --- a/src/instantiations/RE3B_P3GRE3B_5.cu +++ b/src/instantiations/RE3B_P3GRE3B_5.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, false, true, @@ -51,7 +52,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, false, false, @@ -96,7 +98,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, false, false, @@ -141,7 +144,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, true, true, @@ -186,7 +190,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, true, true, @@ -231,7 +236,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, true, false, @@ -276,7 +282,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, true, false, @@ -321,7 +328,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, false, true, @@ -366,7 +374,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, false, true, diff --git a/src/instantiations/RE3B_P3GRE3B_6.cu b/src/instantiations/RE3B_P3GRE3B_6.cu index 1dd44db0..b355d6f9 100644 --- a/src/instantiations/RE3B_P3GRE3B_6.cu +++ b/src/instantiations/RE3B_P3GRE3B_6.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, false, false, @@ -51,7 +52,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, false, false, @@ -96,7 +98,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, true, true, @@ -141,7 +144,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, true, true, @@ -186,7 +190,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, true, false, @@ -231,7 +236,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, true, false, @@ -276,7 +282,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, false, true, @@ -321,7 +328,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, false, true, @@ -366,7 +374,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, false, false, diff --git a/src/instantiations/RE3B_P3GRE3B_7.cu b/src/instantiations/RE3B_P3GRE3B_7.cu index 7c9013fb..47bbf0ec 100644 --- a/src/instantiations/RE3B_P3GRE3B_7.cu +++ b/src/instantiations/RE3B_P3GRE3B_7.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, false, false, @@ -51,7 +52,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, true, true, @@ -96,7 +98,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, true, true, @@ -141,7 +144,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, true, false, @@ -186,7 +190,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, true, false, @@ -231,7 +236,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, false, true, @@ -276,7 +282,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, false, true, @@ -321,7 +328,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, false, false, @@ -366,7 +374,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, false, false, diff --git a/src/instantiations/RE3B_P3GRE3B_8.cu b/src/instantiations/RE3B_P3GRE3B_8.cu index 02d5e9b2..65f7385f 100644 --- a/src/instantiations/RE3B_P3GRE3B_8.cu +++ b/src/instantiations/RE3B_P3GRE3B_8.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, true, true, @@ -51,7 +52,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, true, true, @@ -96,7 +98,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, true, false, @@ -141,7 +144,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, true, false, @@ -186,7 +190,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, false, true, @@ -231,7 +236,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, false, true, @@ -276,7 +282,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, false, false, @@ -321,7 +328,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, false, false, @@ -366,7 +374,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, true, true, diff --git a/src/instantiations/RE3B_P3GRE3B_9.cu b/src/instantiations/RE3B_P3GRE3B_9.cu index a5d5ffcd..d885d8f6 100644 --- a/src/instantiations/RE3B_P3GRE3B_9.cu +++ b/src/instantiations/RE3B_P3GRE3B_9.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, true, true, @@ -51,7 +52,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, true, false, @@ -96,7 +98,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, true, false, @@ -141,7 +144,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, false, true, @@ -186,7 +190,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, false, true, @@ -231,7 +236,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, false, false, @@ -276,7 +282,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, false, false, @@ -321,7 +328,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, true, true, @@ -366,7 +374,8 @@ template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_bwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, true, true, diff --git a/src/instantiations/RE3F_P3GRE3F.cu b/src/instantiations/RE3F_P3GRE3F.cu index 3e8ff2ec..d1e243ef 100644 --- a/src/instantiations/RE3F_P3GRE3F.cu +++ b/src/instantiations/RE3F_P3GRE3F.cu @@ -7,6 +7,7 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, true >( @@ -37,6 +38,7 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::None, false >( @@ -67,6 +69,7 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, true >( @@ -97,6 +100,7 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::D, false >( @@ -127,6 +131,7 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, true >( @@ -157,6 +162,7 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, CameraModelType::PINHOLE, + CameraDistortionType::None, DistortionType::RGB_D, false >( @@ -186,7 +192,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, true >( @@ -216,7 +223,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::None, false >( @@ -246,7 +254,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, true >( diff --git a/src/instantiations/RE3F_P3GRE3F_1.cu b/src/instantiations/RE3F_P3GRE3F_1.cu index 01365f3d..34a08aeb 100644 --- a/src/instantiations/RE3F_P3GRE3F_1.cu +++ b/src/instantiations/RE3F_P3GRE3F_1.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::D, false >( @@ -36,7 +37,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, true >( @@ -66,7 +68,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::FISHEYE, + CameraModelType::PINHOLE, + CameraDistortionType::OpenCV, DistortionType::RGB_D, false >( @@ -96,7 +99,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, true >( @@ -126,7 +130,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::None, false >( @@ -156,7 +161,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, true >( @@ -186,7 +192,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::D, false >( @@ -216,7 +223,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, true >( @@ -246,7 +254,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUISOLID, + CameraModelType::PINHOLE, + CameraDistortionType::ThinPrism, DistortionType::RGB_D, false >( diff --git a/src/instantiations/RE3F_P3GRE3F_2.cu b/src/instantiations/RE3F_P3GRE3F_2.cu index cce9487e..8dec63a3 100644 --- a/src/instantiations/RE3F_P3GRE3F_2.cu +++ b/src/instantiations/RE3F_P3GRE3F_2.cu @@ -6,7 +6,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, true >( @@ -36,7 +37,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::None, false >( @@ -66,7 +68,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, true >( @@ -96,7 +99,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::D, false >( @@ -126,7 +130,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, true >( @@ -156,7 +161,8 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< Vanilla3DGUT<0>, - CameraModelType::EQUIRECTANGULAR, + CameraModelType::PINHOLE, + CameraDistortionType::Rational, DistortionType::RGB_D, false >( @@ -183,3 +189,96 @@ template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] float *__restrict__ render_median // [I, image_height, image_width, 1], optional ); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::None, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); diff --git a/src/instantiations/RE3F_P3GRE3F_3.cu b/src/instantiations/RE3F_P3GRE3F_3.cu new file mode 100644 index 00000000..38c65f57 --- /dev/null +++ b/src/instantiations/RE3F_P3GRE3F_3.cu @@ -0,0 +1,284 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DFwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::None, + DistortionType::RGB_D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::None, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); diff --git a/src/instantiations/RE3F_P3GRE3F_4.cu b/src/instantiations/RE3F_P3GRE3F_4.cu new file mode 100644 index 00000000..2e3bbc70 --- /dev/null +++ b/src/instantiations/RE3F_P3GRE3F_4.cu @@ -0,0 +1,284 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DFwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::None, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::FISHEYE, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::None, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); diff --git a/src/instantiations/RE3F_P3GRE3F_5.cu b/src/instantiations/RE3F_P3GRE3F_5.cu new file mode 100644 index 00000000..df2659ef --- /dev/null +++ b/src/instantiations/RE3F_P3GRE3F_5.cu @@ -0,0 +1,284 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DFwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::None, + DistortionType::RGB_D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::None, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::OpenCV, + DistortionType::RGB_D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); diff --git a/src/instantiations/RE3F_P3GRE3F_6.cu b/src/instantiations/RE3F_P3GRE3F_6.cu new file mode 100644 index 00000000..670a6c75 --- /dev/null +++ b/src/instantiations/RE3F_P3GRE3F_6.cu @@ -0,0 +1,284 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DFwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::None, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUISOLID, + CameraDistortionType::ThinPrism, + DistortionType::RGB_D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::None, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); diff --git a/src/instantiations/RE3F_P3GRE3F_7.cu b/src/instantiations/RE3F_P3GRE3F_7.cu new file mode 100644 index 00000000..5e4cfd71 --- /dev/null +++ b/src/instantiations/RE3F_P3GRE3F_7.cu @@ -0,0 +1,98 @@ +// This file is auto generated by `generate_kernel_instantiation.py` + +#define NO_TORCH +#include "primitives/Primitive3DGUT.cuh" +#include "kernels/raster/RasterizationEval3DFwd_kernel.cuh" + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + true +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); + +template void rasterize_to_pixels_eval3d_fwd_kernel_wrapper< + Vanilla3DGUT<0>, + CameraModelType::EQUIRECTANGULAR, + CameraDistortionType::None, + DistortionType::RGB_D, + false +>( + cudaStream_t stream, + const uint32_t I, + const uint32_t N, + const uint32_t n_isects, + const uint32_t *__restrict__ gaussian_ids, // [nnz] optional, for packed mode + const Vanilla3DGUT<0>::WorldBuffer splat_wbuffer, + const Vanilla3DGUT<0>::ScreenBuffer splat_sbuffer, + const float *__restrict__ viewmats, // [B, C, 4, 4] + const float4 *__restrict__ intrins, // [B, C, 4], fx, fy, cx, cy + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const float4 *__restrict__ aabb, // [..., N] projected 2D AABB + const uint32_t image_width, + const uint32_t image_height, + const uint32_t tile_width, + const uint32_t tile_height, + const int32_t *__restrict__ tile_offsets, // [I, tile_height, tile_width] + const int32_t *__restrict__ flatten_ids, // [n_isects] + RenderOutput::Buffer render_colors, // [I, image_height, image_width, ...] + float *__restrict__ render_Ts, // [I, image_height, image_width, 1] + int32_t *__restrict__ last_ids, // [I, image_height, image_width] + RenderOutput::Buffer render_distortions, // [I, image_height, image_width, ...] + float *__restrict__ render_median // [I, image_height, image_width, 1], optional +); diff --git a/src/kernels/background/BackgroundSphericalHarmonics.cu b/src/kernels/background/BackgroundSphericalHarmonics.cu index 4996f3ff..50d74c41 100644 --- a/src/kernels/background/BackgroundSphericalHarmonics.cu +++ b/src/kernels/background/BackgroundSphericalHarmonics.cu @@ -24,6 +24,8 @@ namespace SlangHarmonics { #include "generated/harmonics.cuh" } +#include "core/CameraDistortion.cuh" + #include @@ -31,20 +33,22 @@ namespace SlangHarmonics { // Load viewmat[:3,:3] (row-major) as a slang-style float3x3, and intrinsics // and (optional) distortion for one camera. +template struct BgCamera { float3x3 R; // world->camera (slang convention) float fx, fy, cx, cy; - CameraDistortionCoeffs dist; + typename SlangDistortion::Coeffs dist; }; -static __device__ __forceinline__ BgCamera _load_bg_camera( +template +static __device__ __forceinline__ BgCamera _load_bg_camera( const float* viewmats, // [N_cam, 16] row-major const float4* intrins, // [N_cam] - const float* dist_coeffs, // [N_cam, 10] or null + const CameraDistortionCoeffsBuffer& dist_coeffs, int cam ) { const float* vm = viewmats + (int64_t)cam * 16; - BgCamera c; + BgCamera c; c.R = float3x3{ vm[0], vm[1], vm[2], // row 0 vm[4], vm[5], vm[6], // row 1 @@ -52,28 +56,23 @@ static __device__ __forceinline__ BgCamera _load_bg_camera( }; float4 intr = intrins[cam]; c.fx = intr.x; c.fy = intr.y; c.cx = intr.z; c.cy = intr.w; - if (dist_coeffs == nullptr) { - #pragma unroll - for (int i = 0; i < 10; ++i) c.dist.m_data[i] = 0.0f; - } else { - const float* d = dist_coeffs + (int64_t)cam * 10; - #pragma unroll - for (int i = 0; i < 10; ++i) c.dist.m_data[i] = d[i]; - } + c.dist = dist_coeffs.load(cam); return c; } // Compute world-space ray direction at pixel (px, py) for the given camera. // Returns false if the pixel maps to an invalid ray (distortion model rejected). +template static __device__ __forceinline__ bool _bg_pixel_world_ray( - const BgCamera& c, int camera_model, int px, int py, float3& out_world_dir + const BgCamera& c, int camera_model, int px, int py, + float3& out_world_dir ) { const float2 uv = { ((float)px + 0.5f - c.cx) / c.fx, ((float)py + 0.5f - c.cy) / c.fy, }; float3 raydir; - if (!SlangProjectionUtils::generate_ray(uv, camera_model, c.dist, &raydir)) + if (!SlangDistortion::generate_ray(uv, camera_model, c.dist, &raydir)) return false; out_world_dir = SlangProjectionUtils::transform_ray_d(c.R, raydir); return true; @@ -82,13 +81,13 @@ static __device__ __forceinline__ bool _bg_pixel_world_ray( // ---- Forward kernel --------------------------------------------------------- -template +template __global__ void render_background_sh_forward_kernel( const dim3 img_size, int camera_model, const float* __restrict__ viewmats, // [B, 16] (per-batch image) const float4* __restrict__ intrins, // [B] - const float* __restrict__ dist_coeffs, // [B, 10] or null + const CameraDistortionCoeffsBuffer dist_coeffs, // [B, 8] const float3* __restrict__ sh_coeffs, // [(SH_DEGREE+1)^2] float3* __restrict__ out_img // [B, H, W] ) { @@ -103,10 +102,10 @@ __global__ void render_background_sh_forward_kernel( // we index directly by bi — NOT by some global camera id. Indexing by // `cam_indices[bi]` (the global-cam-id pattern used by bilagrid/PPISP) is // wrong here: that would read past the buffer's [B] worth of entries. - BgCamera c = _load_bg_camera(viewmats, intrins, dist_coeffs, (int)bi); + auto c = _load_bg_camera(viewmats, intrins, dist_coeffs, (int)bi); float3 world_dir; - if (!_bg_pixel_world_ray(c, camera_model, (int)px, (int)py, world_dir)) { + if (!_bg_pixel_world_ray(c, camera_model, (int)px, (int)py, world_dir)) { out_img[pix_id] = {0.0f, 0.0f, 0.0f}; return; } @@ -135,13 +134,13 @@ __global__ void render_background_sh_forward_kernel( // ---- Backward kernel -------------------------------------------------------- -template +template __global__ void __launch_bounds__(512) render_background_sh_backward_kernel( const dim3 img_size, int camera_model, const float* __restrict__ viewmats, // [B, 16] const float4* __restrict__ intrins, // [B] - const float* __restrict__ dist_coeffs, // [B, 10] or null + const CameraDistortionCoeffsBuffer dist_coeffs, // [B, 8] const float3* __restrict__ sh_coeffs, const float3* __restrict__ out_color, const float3* __restrict__ v_out_color, @@ -166,11 +165,11 @@ __global__ void __launch_bounds__(512) render_background_sh_backward_kernel( } // See forward kernel: index directly by bi (per-batch buffers). - BgCamera c = _load_bg_camera(viewmats, intrins, dist_coeffs, inside ? (int)bi : 0); + auto c = _load_bg_camera(viewmats, intrins, dist_coeffs, inside ? (int)bi : 0); float3 world_dir = {0.0f, 0.0f, 1.0f}; if (inside) { - if (!_bg_pixel_world_ray(c, camera_model, (int)px, (int)py, world_dir)) { + if (!_bg_pixel_world_ray(c, camera_model, (int)px, (int)py, world_dir)) { inside = false; v_color = {0.0f, 0.0f, 0.0f}; } @@ -222,6 +221,63 @@ __global__ void __launch_bounds__(512) render_background_sh_backward_kernel( // ---- Host-side dispatchers -------------------------------------------------- +// The SH degree is a second compile-time axis, so the tier dispatch wraps a +// per-tier helper rather than the launch itself. +template +static void _launch_bg_sh_forward( + int sh_degree, dim3 img_size, int cm, int w, int h, int64_t b, + const float* p_vm, const float4* p_intrins, + const CameraDistortionCoeffsBuffer& p_dist, + const float3* p_sh_coeffs, float3* p_out +) { + #define LAUNCH(DEG) \ + render_background_sh_forward_kernel \ + <<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + img_size, cm, p_vm, p_intrins, p_dist, p_sh_coeffs, p_out) + switch (sh_degree) { + case 0: LAUNCH(0); break; + case 1: LAUNCH(1); break; + case 2: LAUNCH(2); break; + case 3: LAUNCH(3); break; + case 4: LAUNCH(4); break; + } + #undef LAUNCH +} + +template +static void _launch_bg_sh_backward( + int sh_degree, dim3 img_size, int cm, int w, int h, int64_t b, + const float* p_vm, const float4* p_intrins, + const CameraDistortionCoeffsBuffer& p_dist, + const float3* p_sh_coeffs, const float3* p_out_color, + const float3* p_v_out_color, float3* p_v_sh +) { + #define LAUNCH(DEG) \ + render_background_sh_backward_kernel \ + <<<_LAUNCH_ARGS_2D((uint32_t)(w * h), b, 512, 1)>>>( \ + img_size, cm, p_vm, p_intrins, p_dist, p_sh_coeffs, \ + p_out_color, p_v_out_color, p_v_sh) + switch (sh_degree) { + case 0: LAUNCH(0); break; + case 1: LAUNCH(1); break; + case 2: LAUNCH(2); break; + case 3: LAUNCH(3); break; + case 4: LAUNCH(4); break; + } + #undef LAUNCH +} + +#define _SS_DISPATCH_DISTORTION(name, BODY) \ + do { switch (cdt(name)) { \ + case CameraDistortionType::None: BODY(CameraDistortionType::None); break; \ + case CameraDistortionType::OpenCV: BODY(CameraDistortionType::OpenCV); break; \ + case CameraDistortionType::ThinPrism: BODY(CameraDistortionType::ThinPrism); break; \ + case CameraDistortionType::Rational: BODY(CameraDistortionType::Rational); break; \ + default: throw std::runtime_error( \ + "Unknown camera distortion: " + std::string(name)); \ + } } while (0) + + static inline int64_t _batch_count(const TorchTensorView& t, int64_t per_item) { int64_t n = 1; for (auto s : std::get<2>(t)) n *= s; @@ -241,10 +297,11 @@ void render_background_sh_forward( int w, int h, std::string camera_model, + std::string distortion, int sh_degree, // actual SH degree (0..4) TorchTensorView viewmats, // [B, 4, 4] row-major world->camera (per-batch) TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10]; null/empty -> zeros + TorchTensorView dist_coeffs, // [B, 8]; null/empty -> zeros TorchTensorView sh_coeffs, // [(sh_degree+1)^2, 3] TorchTensorView out_color // [B, H, W, 3] pre-allocated ) { @@ -260,23 +317,17 @@ void render_background_sh_forward( const dim3 img_size = {(uint32_t)w, (uint32_t)h, (uint32_t)b}; const float* p_vm = (const float*)std::get<0>(viewmats); const float4* p_intrins = (const float4*)std::get<0>(intrins); - const float* p_dist = (const float*)std::get<0>(dist_coeffs); // null -> zero default + const CameraDistortionCoeffsBuffer p_dist( + (float*)std::get<0>(dist_coeffs)); // null -> zero default const float3* p_sh_coeffs = (const float3*)std::get<0>(sh_coeffs); float3* p_out = (float3*)std::get<0>(out_color); int cm = _camera_model_int(camera_model); - #define LAUNCH(DEG) \ - render_background_sh_forward_kernel \ - <<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ - img_size, cm, p_vm, p_intrins, p_dist, p_sh_coeffs, p_out) - switch (sh_degree) { - case 0: LAUNCH(0); break; - case 1: LAUNCH(1); break; - case 2: LAUNCH(2); break; - case 3: LAUNCH(3); break; - case 4: LAUNCH(4); break; - } + #define LAUNCH(D) \ + _launch_bg_sh_forward(sh_degree, img_size, cm, w, h, b, \ + p_vm, p_intrins, p_dist, p_sh_coeffs, p_out) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -287,6 +338,7 @@ void render_background_sh_backward( int w, int h, std::string camera_model, + std::string distortion, int sh_degree, TorchTensorView viewmats, TorchTensorView intrins, @@ -314,7 +366,7 @@ void render_background_sh_backward( const dim3 img_size = {(uint32_t)w, (uint32_t)h, (uint32_t)b}; const float* p_vm = (const float*)std::get<0>(viewmats); const float4* p_intrins = (const float4*)std::get<0>(intrins); - const float* p_dist = (const float*)std::get<0>(dist_coeffs); + const CameraDistortionCoeffsBuffer p_dist((float*)std::get<0>(dist_coeffs)); const float3* p_sh_coeffs = (const float3*)std::get<0>(sh_coeffs); const float3* p_out_color = (const float3*)std::get<0>(out_color); const float3* p_v_out_color = (const float3*)std::get<0>(v_out_color); @@ -322,18 +374,11 @@ void render_background_sh_backward( int cm = _camera_model_int(camera_model); - #define LAUNCH(DEG) \ - render_background_sh_backward_kernel \ - <<<_LAUNCH_ARGS_2D((uint32_t)(w * h), b, 512, 1)>>>( \ - img_size, cm, p_vm, p_intrins, p_dist, p_sh_coeffs, \ - p_out_color, p_v_out_color, p_v_sh) - switch (sh_degree) { - case 0: LAUNCH(0); break; - case 1: LAUNCH(1); break; - case 2: LAUNCH(2); break; - case 3: LAUNCH(3); break; - case 4: LAUNCH(4); break; - } + #define LAUNCH(D) \ + _launch_bg_sh_backward(sh_degree, img_size, cm, w, h, b, \ + p_vm, p_intrins, p_dist, p_sh_coeffs, \ + p_out_color, p_v_out_color, p_v_sh) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } diff --git a/src/kernels/background/BackgroundSphericalHarmonics.cuh b/src/kernels/background/BackgroundSphericalHarmonics.cuh index 80625ecf..00e94ac9 100644 --- a/src/kernels/background/BackgroundSphericalHarmonics.cuh +++ b/src/kernels/background/BackgroundSphericalHarmonics.cuh @@ -13,10 +13,11 @@ void render_background_sh_forward( int w, int h, std::string camera_model, + std::string distortion, int sh_degree, // actual SH degree (0..4) TorchTensorView viewmats, // [B, 4, 4] row-major world->camera (per-batch) TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10]; null/empty -> zeros + TorchTensorView dist_coeffs, // [B, 8]; null/empty -> zeros TorchTensorView sh_coeffs, // [(sh_degree+1)^2, 3] TorchTensorView out_color // [B, H, W, 3] pre-allocated ); @@ -26,6 +27,7 @@ void render_background_sh_backward( int w, int h, std::string camera_model, + std::string distortion, int sh_degree, TorchTensorView viewmats, TorchTensorView intrins, diff --git a/src/kernels/densify/Densify.cuh b/src/kernels/densify/Densify.cuh index 15abcf25..b927b454 100644 --- a/src/kernels/densify/Densify.cuh +++ b/src/kernels/densify/Densify.cuh @@ -65,11 +65,12 @@ void weighted_sample_without_replacement_tensor( void cov_scale_init_tensor( DeviceVector points, // [N, 3] - DeviceVector is_fisheye, // [C], bool + const std::string camera_model, + const std::string distortion, DeviceVector sizes, // [C, 2], int32 DeviceVector intrins, // [C, 4] DeviceVector viewmats, // [C, 4, 4] as 4*C float4 elements - TorchTensorView dist_coeffs, // [C] + TorchTensorView dist_coeffs, // [C, 8] DeviceVector log_scales // [N, 1] output ); diff --git a/src/kernels/densify/DensifyScoring.cu b/src/kernels/densify/DensifyScoring.cu index fe7470e8..95003eb8 100644 --- a/src/kernels/densify/DensifyScoring.cu +++ b/src/kernels/densify/DensifyScoring.cu @@ -4,15 +4,57 @@ #include "kernels/densify/DensifyCommon.cuh" +#include "kernels/projection/CameraVariants.cuh" + // ================ // Covariance-Based Scale Initialization // ================ +// (camera model, distortion tier) -> the matching *_proj_3dgs_nav export in +// shaders/primitive_3dgs.slang. Only PINHOLE takes the image size; +// EQUIRECTANGULAR takes no coefficients. +template +struct CovProjNav; + +#define _SS_COV_PROJ(MODEL, TIER, CALL) \ +template<> struct CovProjNav { \ + static __device__ __forceinline__ bool proj( \ + float3 p_view, float3x3 cov3d, float4 intrins, \ + const CameraDistortionCoeffsT& c, \ + uint width, uint height, float2x2* cov2d, float2* mean2d \ + ) { return SlangProjectionUtils::CALL; } \ +}; + +#define _SS_COV_PERSP(TIER, SUFFIX) _SS_COV_PROJ(PINHOLE, TIER, \ + persp_proj_3dgs_nav##SUFFIX(p_view, cov3d, intrins, c.v, width, height, cov2d, mean2d)) + +#define _SS_COV_RADIAL(MODEL, PREFIX, TIER, SUFFIX) _SS_COV_PROJ(MODEL, TIER, \ + PREFIX##_proj_3dgs_nav##SUFFIX(p_view, cov3d, intrins, c.v, cov2d, mean2d)) + +#define _SS_COV_RADIAL_TIERS(MODEL, PREFIX) \ + _SS_COV_RADIAL(MODEL, PREFIX, None, _none) \ + _SS_COV_RADIAL(MODEL, PREFIX, OpenCV, _opencv)\ + _SS_COV_RADIAL(MODEL, PREFIX, ThinPrism, _prism) + +_SS_COV_PERSP(None, _none) +_SS_COV_PERSP(OpenCV, _opencv) +_SS_COV_PERSP(ThinPrism, _prism) +_SS_COV_PERSP(Rational, _rational) +_SS_COV_RADIAL_TIERS(FISHEYE, fisheye) +_SS_COV_RADIAL_TIERS(EQUISOLID, equisolid) +_SS_COV_PROJ(EQUIRECTANGULAR, None, + equirect_proj_3dgs_nav(p_view, cov3d, intrins, cov2d, mean2d)) + +#undef _SS_COV_RADIAL_TIERS +#undef _SS_COV_RADIAL +#undef _SS_COV_PERSP +#undef _SS_COV_PROJ + +template __global__ void cov_scale_init_kernel( int64_t num_points, int32_t num_cameras, const float3* __restrict__ points, // [N, 3] - const bool* __restrict__ is_fisheye, // [C]; TODO: equisolid const int2* __restrict__ sizes, // [C, 2] const float4 *__restrict__ intrins, // [C, 4], fx, fy, cx, cy const float4 *__restrict__ viewmats, // [C, 4, 4] @@ -29,7 +71,7 @@ __global__ void cov_scale_init_kernel( for (int32_t i = 0; i < num_cameras; ++i) { float4 intrin = intrins[i]; int width = sizes[i].x, height = sizes[i].y; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(i); + CameraDistortionCoeffsT dist_coeffs = dist_coeffs_buffer.load(i); float4 p_wh = {p_world.x, p_world.y, p_world.z, 1.0f}; float3 p_view = { @@ -38,21 +80,12 @@ __global__ void cov_scale_init_kernel( dot(viewmats[4*i+2], p_wh), }; - bool valid = false; constexpr float eps = 1e-6f; float3x3 cov3d = {eps, 0, 0, 0, eps, 0, 0, 0, eps}; float2x2 cov2d; float2 mean2d; - if (is_fisheye[i]) { - valid = SlangProjectionUtils::fisheye_proj_3dgs_nav( - p_view, cov3d, intrin, dist_coeffs, &cov2d, &mean2d - ); - } - else { - valid = SlangProjectionUtils::persp_proj_3dgs_nav( - p_view, cov3d, intrin, dist_coeffs, width, height, &cov2d, &mean2d - ); - } + bool valid = CovProjNav::proj( + p_view, cov3d, intrin, dist_coeffs, width, height, &cov2d, &mean2d); #pragma unroll for (int i = 0; i < 2; ++i) { @@ -73,26 +106,38 @@ __global__ void cov_scale_init_kernel( /*[AutoHeaderGeneratorExport]*/ void cov_scale_init_tensor( DeviceVector points, // [N, 3] - DeviceVector is_fisheye, // [C], bool + const std::string camera_model, + const std::string distortion, DeviceVector sizes, // [C, 2], int32 DeviceVector intrins, // [C, 4] DeviceVector viewmats, // [C, 4, 4] as 4*C float4 elements - TorchTensorView dist_coeffs, // [C] + TorchTensorView dist_coeffs, // [C, 8] DeviceVector log_scales // [N, 1] output ) { int64_t N = points.size(); int64_t C = intrins.size(); - cov_scale_init_kernel<<<_LAUNCH_ARGS_1D(N, 256)>>>( - N, C, - points.data_ptr(), - is_fisheye.data_ptr(), - sizes.data_ptr(), - intrins.data_ptr(), - viewmats.data_ptr(), - dist_coeffs, - log_scales.data_ptr() - ); + const CameraModelType cm = cmt(camera_model); + const CameraDistortionType cd = cdt(distortion); + + #define _LAUNCH_ARGS ( \ + N, C, \ + points.data_ptr(), \ + sizes.data_ptr(), \ + intrins.data_ptr(), \ + viewmats.data_ptr(), \ + dist_coeffs, \ + log_scales.data_ptr() ) + + #define _DISPATCH(M, D) \ + if (cm == CameraModelType::M && cd == CameraDistortionType::D) \ + cov_scale_init_kernel \ + <<<_LAUNCH_ARGS_1D(N, 256)>>> _LAUNCH_ARGS; else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("cov_scale_init_tensor: unsupported camera model / distortion tier"); + #undef _DISPATCH + #undef _LAUNCH_ARGS + CHECK_DEVICE_ERROR(cudaGetLastError()); } diff --git a/src/kernels/optim/FusedProjectionBwdOptim.cu b/src/kernels/optim/FusedProjectionBwdOptim.cu index 997803fc..7aa44f10 100644 --- a/src/kernels/optim/FusedProjectionBwdOptim.cu +++ b/src/kernels/optim/FusedProjectionBwdOptim.cu @@ -1,5 +1,7 @@ #include "kernels/optim/FusedProjectionBwdOptim.cuh" +#include "kernels/projection/CameraVariants.cuh" + #include #include @@ -11,6 +13,7 @@ namespace cg = cooperative_groups; template< typename SplatPrimitive, CameraModelType camera_model, + CameraDistortionType distortion, const bool use_scale_agnostic_mean, const bool color_trust_linear, const int LEVEL @@ -110,6 +113,7 @@ inline void launch_fused_projection_bwd_optimizer_3dgs_kernel( const uint32_t image_width, const uint32_t image_height, const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, // fwd outputs DeviceVector camera_ids, @@ -238,16 +242,14 @@ inline void launch_fused_projection_bwd_optimizer_3dgs_kernel( scalar_step, steps_ptr \ ) - if (camera_model == CameraModelType::PINHOLE) - fused_projection_bwd_optimizer_3dgs_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::FISHEYE) - fused_projection_bwd_optimizer_3dgs_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUISOLID) - fused_projection_bwd_optimizer_3dgs_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUIRECTANGULAR) - fused_projection_bwd_optimizer_3dgs_kernel_wrapper _LAUNCH_ARGS; - else - throw std::runtime_error("Unsupported camera model"); + #define _DISPATCH(M, D) \ + if (camera_model == CameraModelType::M && distortion == CameraDistortionType::D) \ + fused_projection_bwd_optimizer_3dgs_kernel_wrapper _LAUNCH_ARGS; else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("Unsupported camera model / distortion tier"); + #undef _DISPATCH CHECK_DEVICE_ERROR(cudaGetLastError()); #undef _LAUNCH_ARGS @@ -277,6 +279,7 @@ static inline void _fused_projection_bwd_optimizer_dispatch( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, // fwd outputs const DeviceVector camera_ids, @@ -335,6 +338,7 @@ static inline void _fused_projection_bwd_optimizer_dispatch( image_width, \ image_height, \ cmt(camera_model), \ + cdt(distortion), \ dist_coeffs, \ camera_ids, \ gaussian_ids, \ @@ -424,6 +428,7 @@ void fused_projection_bwd_optimizer_3dgs( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -461,7 +466,7 @@ void fused_projection_bwd_optimizer_3dgs( ) { _fused_projection_bwd_optimizer_dispatch( num_splats, max_sh_degree, splats_world, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_world, v_splats_screen, g1_splats_world, g2_splats_world, sh_packed, sh_quant_bounds, sh_value_packed, sh_value_bounds, @@ -485,6 +490,7 @@ void fused_projection_bwd_optimizer_mip( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -522,7 +528,7 @@ void fused_projection_bwd_optimizer_mip( ) { _fused_projection_bwd_optimizer_dispatch( num_splats, max_sh_degree, splats_world, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_world, v_splats_screen, g1_splats_world, g2_splats_world, sh_packed, sh_quant_bounds, sh_value_packed, sh_value_bounds, @@ -546,6 +552,7 @@ void fused_projection_bwd_optimizer_3dgut( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -583,7 +590,7 @@ void fused_projection_bwd_optimizer_3dgut( ) { _fused_projection_bwd_optimizer_dispatch( num_splats, max_sh_degree, splats_world, viewmats, intrins, image_width, image_height, - camera_model, dist_coeffs, camera_ids, gaussian_ids, aabb, + camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_world, v_splats_screen, g1_splats_world, g2_splats_world, sh_packed, sh_quant_bounds, sh_value_packed, sh_value_bounds, diff --git a/src/kernels/optim/FusedProjectionBwdOptim.cuh b/src/kernels/optim/FusedProjectionBwdOptim.cuh index 7351c009..8f803e42 100644 --- a/src/kernels/optim/FusedProjectionBwdOptim.cuh +++ b/src/kernels/optim/FusedProjectionBwdOptim.cuh @@ -26,6 +26,7 @@ void fused_projection_bwd_optimizer_3dgs( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -72,6 +73,7 @@ void fused_projection_bwd_optimizer_mip( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -118,6 +120,7 @@ void fused_projection_bwd_optimizer_3dgut( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, diff --git a/src/kernels/optim/FusedProjectionBwdOptim_kernel.cuh b/src/kernels/optim/FusedProjectionBwdOptim_kernel.cuh index c3837f32..b0fc254b 100644 --- a/src/kernels/optim/FusedProjectionBwdOptim_kernel.cuh +++ b/src/kernels/optim/FusedProjectionBwdOptim_kernel.cuh @@ -146,6 +146,7 @@ struct _NonShQ { template< typename SplatPrimitive, CameraModelType camera_model, + CameraDistortionType distortion, bool use_scale_agnostic_mean, // Merged flag for the two color-space variants. Both // `OptimConfig::use_color_trust_region` and `OptimConfig::color_is_linear` @@ -277,11 +278,11 @@ __global__ void fused_projection_bwd_optimizer_3dgs_kernel }; float3 t = { viewmats[cid*16+3], viewmats[cid*16+7], viewmats[cid*16+11] }; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - ProjCamera cam = { + ProjCameraT cam = { R, t, fx, fy, cx, cy, image_width, image_height, }; - cam.dist_coeffs = dist_coeffs_buffer.load(cid); + cam.dist_coeffs = dist_coeffs_buffer.load(cid); // Load splat gradient typename SplatPrimitive::Screen v_splat_screen; @@ -294,11 +295,11 @@ __global__ void fused_projection_bwd_optimizer_3dgs_kernel // features_sh (left untouched by value-quant FPBO writeback) which is // typically all zero -> biased v_means / v_R / v_t every step. if constexpr (VALUE_BITS == 32) { - splat_world.template project_vjp(cam, v_splat_screen, v_splat_world, v_R, v_t); + splat_world.template project_vjp(cam, v_splat_screen, v_splat_world, v_R, v_t); } else { const int64_t sh_base_vjp = (int64_t)3 * (int64_t)num_sh_buffer * (int64_t)gid; const int64_t sh_bounds_stride_vjp = (int64_t)256 * 3 * (int64_t)num_sh_buffer; - splat_world.template project_vjp( + splat_world.template project_vjp( cam, v_splat_screen, v_splat_world, v_R, v_t, const_cast(sh_value_packed), sh_value_bounds, sh_base_vjp, sh_bounds_stride_vjp); @@ -1037,6 +1038,7 @@ __global__ void fused_projection_bwd_optimizer_3dgs_kernel template< typename SplatPrimitive, CameraModelType camera_model, + CameraDistortionType distortion, const bool use_scale_agnostic_mean, const bool color_trust_linear, // SH quantization level. Single int collapses the prior (QUANT_BITS, VALUE_BITS) @@ -1118,7 +1120,7 @@ void fused_projection_bwd_optimizer_3dgs_kernel_wrapper( constexpr int KERNEL_BLOCK_SIZE = (LEVEL_QUANT_BITS == 0) ? 0 : BLOCK_SIZE_LAUNCH; constexpr int KERNEL_QUANT_BITS = (LEVEL_QUANT_BITS == 0) ? 8 : LEVEL_QUANT_BITS; fused_projection_bwd_optimizer_3dgs_kernel< - SplatPrimitive, camera_model, + SplatPrimitive, camera_model, distortion, use_scale_agnostic_mean, color_trust_linear, KERNEL_BLOCK_SIZE, KERNEL_QUANT_BITS, LEVEL_VALUE_BITS ><<<_CEIL_DIV(N, BLOCK_SIZE_LAUNCH), BLOCK_SIZE_LAUNCH, 0, stream>>>( diff --git a/src/kernels/pixelwise/DepthGeometry.cu b/src/kernels/pixelwise/DepthGeometry.cu index 12fca81e..0c9e4951 100644 --- a/src/kernels/pixelwise/DepthGeometry.cu +++ b/src/kernels/pixelwise/DepthGeometry.cu @@ -10,6 +10,7 @@ // ================ +template __global__ void depth_to_points_forward_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // fx, fy, cx, cy @@ -30,11 +31,11 @@ __global__ void depth_to_points_forward_kernel( // Load camera float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); // Process float in_depth = in_depths.load1(bid, j, i); - float3 out_point = SlangPixelWise::depth_to_point( + float3 out_point = SlangPixelWiseDist::depth_to_point( {(float)i+0.5f, (float)j+0.5f}, {fx, fy, cx, cy}, dist_coeffs, (int)camera_model, @@ -44,6 +45,7 @@ __global__ void depth_to_points_forward_kernel( out_points.store3(bid, j, i, out_point); } +template __global__ void depth_to_points_backward_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // fx, fy, cx, cy @@ -65,12 +67,12 @@ __global__ void depth_to_points_backward_kernel( // Load camera float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); // Process float in_depth = in_depths.load1(bid, j, i); float3 v_out_point = v_out_points.load3(bid, j, i); - float v_in_depth = SlangPixelWise::depth_to_point_vjp( + float v_in_depth = SlangPixelWiseDist::depth_to_point_vjp( {(float)i+0.5f, (float)j+0.5f}, {fx, fy, cx, cy}, dist_coeffs, (int)camera_model, @@ -83,26 +85,30 @@ __global__ void depth_to_points_backward_kernel( /*[AutoHeaderGeneratorExport]*/ void depth_to_points_forward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D out_points // [B, H, W, 3] ) { int b = depths.size<0>(), h = depths.size<1>(), w = depths.size<2>(); - depth_to_points_forward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, is_ray_depth, - _dt3d_to_tv4(depths), _dt3d_to_tv4(out_points) - ); + #define LAUNCH(D) \ + depth_to_points_forward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, is_ray_depth, \ + _dt3d_to_tv4(depths), _dt3d_to_tv4(out_points)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } /*[AutoHeaderGeneratorExport]*/ void depth_to_points_backward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D in_depths, // [B, H, W, 1] DeviceTensor3D v_out_points,// [B, H, W, 3] @@ -110,11 +116,13 @@ void depth_to_points_backward( ) { int b = in_depths.size<0>(), h = in_depths.size<1>(), w = in_depths.size<2>(); - depth_to_points_backward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, is_ray_depth, - _dt3d_to_tv4(in_depths), _dt3d_to_tv4(v_out_points), - _dt3d_to_tv4(v_in_depths) - ); + #define LAUNCH(D) \ + depth_to_points_backward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, is_ray_depth, \ + _dt3d_to_tv4(in_depths), _dt3d_to_tv4(v_out_points), \ + _dt3d_to_tv4(v_in_depths)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -125,6 +133,7 @@ void depth_to_points_backward( // ================ +template __global__ void depth_to_normal_forward_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // fx, fy, cx, cy @@ -152,7 +161,7 @@ __global__ void depth_to_normal_forward_kernel( // Load camera float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); // Process #if 0 @@ -179,7 +188,7 @@ __global__ void depth_to_normal_forward_kernel( int jg = int(blockIdx.y * TILE) + jt - 1; float depth = (ig >= 0 && ig < W && jg >= 0 && jg < H) ? depths.load1(bid, jg, ig) : 0.0f; - float3 ray = SlangPixelWise::generate_ray_d2n( + float3 ray = SlangPixelWiseDist::generate_ray_d2n( {(float)ig+0.5f, (float)jg+0.5f}, {fx, fy, cx, cy}, dist_coeffs, (int)camera_model, is_ray_depth @@ -202,6 +211,7 @@ __global__ void depth_to_normal_forward_kernel( } +template __global__ void depth_to_normal_backward_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // fx, fy, cx, cy @@ -229,7 +239,7 @@ __global__ void depth_to_normal_backward_kernel( // Load camera float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); // Process #if 0 @@ -262,7 +272,7 @@ __global__ void depth_to_normal_backward_kernel( int jg = int(blockIdx.y * TILE) + jt - 1; float depth = (ig >= 0 && ig < W && jg >= 0 && jg < H) ? depths.load1(bid, jg, ig) : 0.0f; - float3 ray = SlangPixelWise::generate_ray_d2n( + float3 ray = SlangPixelWiseDist::generate_ray_d2n( {(float)ig+0.5f, (float)jg+0.5f}, {fx, fy, cx, cy}, dist_coeffs, (int)camera_model, is_ray_depth @@ -296,26 +306,30 @@ __global__ void depth_to_normal_backward_kernel( /*[AutoHeaderGeneratorExport]*/ void depth_to_normal_forward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D normals // [B, H, W, 3] ) { int b = depths.size<0>(), h = depths.size<1>(), w = depths.size<2>(); - depth_to_normal_forward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - is_ray_depth, _dt3d_to_tv4(depths), _dt3d_to_tv4(normals) - ); + #define LAUNCH(D) \ + depth_to_normal_forward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + is_ray_depth, _dt3d_to_tv4(depths), _dt3d_to_tv4(normals)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } /*[AutoHeaderGeneratorExport]*/ void depth_to_normal_backward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D v_normals, // [B, H, W, 3] @@ -323,21 +337,23 @@ void depth_to_normal_backward( ) { int b = depths.size<0>(), h = depths.size<1>(), w = depths.size<2>(); - depth_to_normal_backward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - is_ray_depth, _dt3d_to_tv4(depths), - _dt3d_to_tv4(v_normals), - _dt3d_to_tv4(v_depths) - ); + #define LAUNCH(D) \ + depth_to_normal_backward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + is_ray_depth, _dt3d_to_tv4(depths), \ + _dt3d_to_tv4(v_normals), \ + _dt3d_to_tv4(v_depths)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } -// Python-callable wrappers using only TorchTensorView (pybind11 can convert tuples). /*[AutoHeaderGeneratorExport]*/ void depth_to_normal_forward_tv( std::string camera_model, + std::string distortion, TorchTensorView intrins, TorchTensorView dist_coeffs, bool is_ray_depth, @@ -345,7 +361,7 @@ void depth_to_normal_forward_tv( TorchTensorView normals // [B, H, W, 3] float32, CUDA (pre-allocated output) ) { depth_to_normal_forward( - camera_model, intrins, dist_coeffs, is_ray_depth, + camera_model, distortion, intrins, dist_coeffs, is_ray_depth, DeviceTensor3D(depths), DeviceTensor3D(normals) ); @@ -354,6 +370,7 @@ void depth_to_normal_forward_tv( /*[AutoHeaderGeneratorExport]*/ void depth_to_normal_backward_tv( std::string camera_model, + std::string distortion, TorchTensorView intrins, TorchTensorView dist_coeffs, bool is_ray_depth, @@ -362,7 +379,7 @@ void depth_to_normal_backward_tv( TorchTensorView v_depths // [B, H, W, 1] accumulated in-place ) { depth_to_normal_backward( - camera_model, intrins, dist_coeffs, is_ray_depth, + camera_model, distortion, intrins, dist_coeffs, is_ray_depth, DeviceTensor3D(depths), DeviceTensor3D(v_normals), DeviceTensor3D(v_depths) @@ -375,6 +392,7 @@ void depth_to_normal_backward_tv( // ================ +template __global__ void depth_normal_loss_forward_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // fx, fy, cx, cy @@ -403,7 +421,7 @@ __global__ void depth_normal_loss_forward_kernel( // Load camera float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); // Process #if 1 @@ -415,7 +433,7 @@ __global__ void depth_normal_loss_forward_kernel( depths.load1(bid, j+1, i), }; float3 gt_normal = gt_normals.load3(bid, j, i); - float loss = SlangPixelWise::depth_normal_loss( + float loss = SlangPixelWiseDist::depth_normal_loss( {(float)i+0.5f, (float)j+0.5f}, {fx, fy, cx, cy}, dist_coeffs, (int)camera_model, is_ray_depth, @@ -428,6 +446,7 @@ __global__ void depth_normal_loss_forward_kernel( } +template __global__ void depth_normal_loss_backward_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // fx, fy, cx, cy @@ -457,7 +476,7 @@ __global__ void depth_normal_loss_backward_kernel( // Load camera float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); // Process #if 1 @@ -475,7 +494,7 @@ __global__ void depth_normal_loss_backward_kernel( float v_loss = v_losses.load1(bid, j, i); float4 v_depth = {0.0f, 0.0f, 0.0f, 0.0f}; float3 v_gt_normal = float3{0.0f, 0.0f, 0.0f}; - SlangPixelWise::depth_normal_loss_vjp( + SlangPixelWiseDist::depth_normal_loss_vjp( {(float)i+0.5f, (float)j+0.5f}, {fx, fy, cx, cy}, dist_coeffs, (int)camera_model, is_ray_depth, @@ -495,8 +514,9 @@ __global__ void depth_normal_loss_backward_kernel( /*[AutoHeaderGeneratorExport]*/ void depth_normal_loss_forward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D gt_normals, // [B, H, W, 3] @@ -504,19 +524,22 @@ void depth_normal_loss_forward( ) { int b = depths.size<0>(), h = depths.size<1>(), w = depths.size<2>(); - depth_normal_loss_forward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - is_ray_depth, _dt3d_to_tv4(depths), _dt3d_to_tv4(gt_normals), - _dt3d_to_tv4(losses) - ); + #define LAUNCH(D) \ + depth_normal_loss_forward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + is_ray_depth, _dt3d_to_tv4(depths), _dt3d_to_tv4(gt_normals), \ + _dt3d_to_tv4(losses)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } /*[AutoHeaderGeneratorExport]*/ void depth_normal_loss_backward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D gt_normals, // [B, H, W, 3] @@ -526,12 +549,14 @@ void depth_normal_loss_backward( ) { int b = depths.size<0>(), h = depths.size<1>(), w = depths.size<2>(); - depth_normal_loss_backward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - is_ray_depth, _dt3d_to_tv4(depths), _dt3d_to_tv4(gt_normals), - _dt3d_to_tv4(v_losses), - _dt3d_to_tv4(v_depths), _dt3d_to_tv4(v_gt_normals) - ); + #define LAUNCH(D) \ + depth_normal_loss_backward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + is_ray_depth, _dt3d_to_tv4(depths), _dt3d_to_tv4(gt_normals), \ + _dt3d_to_tv4(v_losses), \ + _dt3d_to_tv4(v_depths), _dt3d_to_tv4(v_gt_normals)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -541,6 +566,7 @@ void depth_normal_loss_backward( // ================ +template __global__ void ray_depth_to_linear_depth_forward_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // fx, fy, cx, cy @@ -560,11 +586,11 @@ __global__ void ray_depth_to_linear_depth_forward_kernel( // Load camera float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); // Process float in_depth = in_depths.load1(bid, j, i); - float out_depth = in_depth * SlangPixelWise::ray_depth_to_linear_depth_factor( + float out_depth = in_depth * SlangPixelWiseDist::ray_depth_to_linear_depth_factor( {(float)i+0.5f, (float)j+0.5f}, {fx, fy, cx, cy}, dist_coeffs, (int)camera_model @@ -572,6 +598,7 @@ __global__ void ray_depth_to_linear_depth_forward_kernel( out_depths.store1(bid, j, i, out_depth); } +template __global__ void ray_depth_to_linear_depth_backward_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // fx, fy, cx, cy @@ -591,11 +618,11 @@ __global__ void ray_depth_to_linear_depth_backward_kernel( // Load camera float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); // Process float v_out_depth = v_out_depths.load1(bid, j, i); - float factor = SlangPixelWise::ray_depth_to_linear_depth_factor( + float factor = SlangPixelWiseDist::ray_depth_to_linear_depth_factor( {(float)i+0.5f, (float)j+0.5f}, {fx, fy, cx, cy}, dist_coeffs, (int)camera_model @@ -607,36 +634,44 @@ __global__ void ray_depth_to_linear_depth_backward_kernel( /*[AutoHeaderGeneratorExport]*/ void ray_depth_to_linear_depth_forward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView depths, // [B, H, W, 1] TorchTensorView out_depths // [B, H, W, 1] ) { const auto& s = std::get<2>(depths); int64_t b = s[0], h = s[1], w = s[2]; - ray_depth_to_linear_depth_forward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - _bhw1_view(depths), _bhw1_view(out_depths) - ); + #define LAUNCH(D) \ + ray_depth_to_linear_depth_forward_kernel \ + <<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + _bhw1_view(depths), _bhw1_view(out_depths)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } /*[AutoHeaderGeneratorExport]*/ void ray_depth_to_linear_depth_backward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView v_out_depths, // [B, H, W, 1] TorchTensorView v_in_depths // [B, H, W, 1] ) { const auto& s = std::get<2>(v_out_depths); int64_t b = s[0], h = s[1], w = s[2]; - ray_depth_to_linear_depth_backward_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - _bhw1_view(v_out_depths), _bhw1_view(v_in_depths) - ); + #define LAUNCH(D) \ + ray_depth_to_linear_depth_backward_kernel \ + <<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + _bhw1_view(v_out_depths), _bhw1_view(v_in_depths)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -650,6 +685,7 @@ void ray_depth_to_linear_depth_backward( // map resolution (depth maps may differ in size from the rendered image). The // zero sentinel (no GT) and degenerate rays (undistort failure -> factor 0) // map to 0 (i.e. "no supervision here"). +template __global__ void linear_depth_to_ray_depth_inplace_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // image-res fx, fy, cx, cy @@ -672,10 +708,10 @@ __global__ void linear_depth_to_ray_depth_inplace_kernel( float4 intrin = intrins[bid]; float fx = intrin.x * sx, fy = intrin.y * sy; float cx = intrin.z * sx, cy = intrin.w * sy; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); float in_depth = depths.load1(bid, j, i); - float factor = SlangPixelWise::ray_depth_to_linear_depth_factor( + float factor = SlangPixelWiseDist::ray_depth_to_linear_depth_factor( {(float)i+0.5f, (float)j+0.5f}, {fx, fy, cx, cy}, dist_coeffs, (int)camera_model @@ -687,8 +723,9 @@ __global__ void linear_depth_to_ray_depth_inplace_kernel( /*[AutoHeaderGeneratorExport]*/ void linear_depth_to_ray_depth_inplace( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] at image resolution - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] int image_width, int image_height, DeviceTensor3D depths // [B, Hd, Wd, 1] in/out ) { @@ -697,10 +734,13 @@ void linear_depth_to_ray_depth_inplace( float sx = (image_width > 0) ? (float)w / (float)image_width : 1.0f; float sy = (image_height > 0) ? (float)h / (float)image_height : 1.0f; - linear_depth_to_ray_depth_inplace_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - sx, sy, _dt3d_to_tv4(depths) - ); + #define LAUNCH(D) \ + linear_depth_to_ray_depth_inplace_kernel \ + <<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + sx, sy, _dt3d_to_tv4(depths)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } diff --git a/src/kernels/pixelwise/GtDepthNormalWarp.cu b/src/kernels/pixelwise/GtDepthNormalWarp.cu index bee09bca..5e3654f4 100644 --- a/src/kernels/pixelwise/GtDepthNormalWarp.cu +++ b/src/kernels/pixelwise/GtDepthNormalWarp.cu @@ -4,6 +4,7 @@ // Part of the PixelWise family -- see PixelWiseCommon.cuh. #include "kernels/pixelwise/BilinearSample.cuh" +#include "kernels/pixelwise/RedistortSource.cuh" // ================ // GT depth / normal wide -> pinhole warps (for split-mode supervision) @@ -34,11 +35,13 @@ __forceinline__ __device__ float _wide_depth_to_face_ray_depth( return d * rl / rz; } -template +template __global__ void warp_depth_wide_to_pinhole_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // [B, 4] const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const int *__restrict__ source_models, + const float *__restrict__ source_params, TensorView wide_depth, // [B, Hd, Wd, 1] TensorView pinhole_depth, // [B, K, H_out, W_out, 1] const float* __restrict__ axes, // [K, 3, 3] @@ -59,8 +62,8 @@ __global__ void warp_depth_wide_to_pinhole_kernel( float tx = -1.0f + 2.0f * ((float)i + 0.5f) / (float)Wp; float ty = -1.0f + 2.0f * ((float)j + 0.5f) / (float)Hp; - float4 intrin = intrins[bid]; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto to_pixel = make_ray_to_pixel( + bid, camera_model, intrins, dist_coeffs_buffer, source_models, source_params); // Projected pixel is in intrinsics-reference (RGB input) pixel space; // rescale to the GT depth map's own resolution. float sx = (float)Wd / (float)in_W, sy = (float)Hd / (float)in_H; @@ -71,11 +74,7 @@ __global__ void warp_depth_wide_to_pinhole_kernel( float3 axis_z = {axes[9*ki + 6], axes[9*ki + 7], axes[9*ki + 8]}; float3 raydir = axis_z + tx * axis_x + ty * axis_y; float2 uv; - bool valid = camera_model == CameraModelType::FISHEYE ? - SlangProjectionUtils::fisheye_proj_nav(raydir, intrin, dist_coeffs, &uv) : - camera_model == CameraModelType::EQUISOLID ? - SlangProjectionUtils::equisolid_proj_nav(raydir, intrin, dist_coeffs, &uv) : - SlangProjectionUtils::persp_proj_nav(raydir, intrin, dist_coeffs, &uv); + bool valid = to_pixel(raydir, &uv); float out = 0.0f; if (valid) { float d = bilinear_byte_norm( @@ -155,11 +154,13 @@ __forceinline__ __device__ float3 _warp_one_normal( return r / rl; } -template +template __global__ void warp_normal_wide_to_pinhole_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // [B, 4] const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const int *__restrict__ source_models, + const float *__restrict__ source_params, TensorView wide_normal, // [B, Hn, Wn, 3] TensorView pinhole_normal, // [B, K, H_out, W_out, 3] const float* __restrict__ axes, // [K, 3, 3] @@ -179,8 +180,8 @@ __global__ void warp_normal_wide_to_pinhole_kernel( float tx = -1.0f + 2.0f * ((float)i + 0.5f) / (float)Wp; float ty = -1.0f + 2.0f * ((float)j + 0.5f) / (float)Hp; - float4 intrin = intrins[bid]; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto to_pixel = make_ray_to_pixel( + bid, camera_model, intrins, dist_coeffs_buffer, source_models, source_params); float sx = (float)Wn / (float)in_W, sy = (float)Hn / (float)in_H; for (int ki = 0; ki < K; ++ki) { @@ -189,11 +190,7 @@ __global__ void warp_normal_wide_to_pinhole_kernel( float3 axis_z = {axes[9*ki + 6], axes[9*ki + 7], axes[9*ki + 8]}; float3 raydir = axis_z + tx * axis_x + ty * axis_y; float2 uv; - bool valid = camera_model == CameraModelType::FISHEYE ? - SlangProjectionUtils::fisheye_proj_nav(raydir, intrin, dist_coeffs, &uv) : - camera_model == CameraModelType::EQUISOLID ? - SlangProjectionUtils::equisolid_proj_nav(raydir, intrin, dist_coeffs, &uv) : - SlangProjectionUtils::persp_proj_nav(raydir, intrin, dist_coeffs, &uv); + bool valid = to_pixel(raydir, &uv); float3 nf = make_float3(-1.0f, -1.0f, -1.0f); if (valid) { nf = _warp_one_normal( @@ -272,8 +269,11 @@ static inline TensorView _make_tv5_out( /*[AutoHeaderGeneratorExport]*/ void launch_warp_depth_wide( std::string camera_model, + std::string distortion, const float* d_intrins, const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, const void* d_depth, uint32_t elem_size, int B, int Hin, int Win, int in_H, int in_W, @@ -284,21 +284,24 @@ void launch_warp_depth_wide( CameraDistortionCoeffsBuffer dcb(const_cast(d_dist_coeffs)); const float4* intrins_f4 = (const float4*)d_intrins; auto out_v = _make_tv5_out(d_float_out, B, K, Hout, Wout, 1); - if (elem_size == 2) { - warp_depth_wide_to_pinhole_kernel - <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( - cm, intrins_f4, dcb, - _make_tv4_in((const uint16_t*)d_depth, B, Hin, Win, 1), - out_v, d_axes, in_H, in_W, 1.0f, input_is_ray_depth); - } else if (elem_size == 4) { - warp_depth_wide_to_pinhole_kernel - <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( - cm, intrins_f4, dcb, - _make_tv4_in((const float*)d_depth, B, Hin, Win, 1), - out_v, d_axes, in_H, in_W, 1.0f, input_is_ray_depth); - } else { + if (elem_size != 2 && elem_size != 4) throw std::runtime_error("launch_warp_depth_wide: depth must be uint16 or float32"); - } + #define LAUNCH(D, FROM) \ + if (elem_size == 2) { \ + warp_depth_wide_to_pinhole_kernel \ + <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( \ + cm, intrins_f4, dcb, d_source_models, d_source_params, \ + _make_tv4_in((const uint16_t*)d_depth, B, Hin, Win, 1), \ + out_v, d_axes, in_H, in_W, 1.0f, input_is_ray_depth); \ + } else { \ + warp_depth_wide_to_pinhole_kernel \ + <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( \ + cm, intrins_f4, dcb, d_source_models, d_source_params, \ + _make_tv4_in((const float*)d_depth, B, Hin, Win, 1), \ + out_v, d_axes, in_H, in_W, 1.0f, input_is_ray_depth); \ + } + _SS_DISPATCH_SOURCE(distortion, d_source_models != nullptr, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -329,8 +332,11 @@ void launch_warp_depth_equi( /*[AutoHeaderGeneratorExport]*/ void launch_warp_normal_wide( std::string camera_model, + std::string distortion, const float* d_intrins, const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, const void* d_normal, uint32_t elem_size, int B, int Hin, int Win, int in_H, int in_W, @@ -341,21 +347,24 @@ void launch_warp_normal_wide( CameraDistortionCoeffsBuffer dcb(const_cast(d_dist_coeffs)); const float4* intrins_f4 = (const float4*)d_intrins; auto out_v = _make_tv5_out(d_float_out, B, K, Hout, Wout, 3); - if (elem_size == 1) { - warp_normal_wide_to_pinhole_kernel - <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( - cm, intrins_f4, dcb, - _make_tv4_in((const uint8_t*)d_normal, B, Hin, Win, 3), - out_v, d_axes, in_H, in_W, 1.0f / 127.5f, -1.0f); - } else if (elem_size == 4) { - warp_normal_wide_to_pinhole_kernel - <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( - cm, intrins_f4, dcb, - _make_tv4_in((const float*)d_normal, B, Hin, Win, 3), - out_v, d_axes, in_H, in_W, 1.0f, 0.0f); - } else { + if (elem_size != 1 && elem_size != 4) throw std::runtime_error("launch_warp_normal_wide: normal must be uint8 or float32"); - } + #define LAUNCH(D, FROM) \ + if (elem_size == 1) { \ + warp_normal_wide_to_pinhole_kernel \ + <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( \ + cm, intrins_f4, dcb, d_source_models, d_source_params, \ + _make_tv4_in((const uint8_t*)d_normal, B, Hin, Win, 3), \ + out_v, d_axes, in_H, in_W, 1.0f / 127.5f, -1.0f); \ + } else { \ + warp_normal_wide_to_pinhole_kernel \ + <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( \ + cm, intrins_f4, dcb, d_source_models, d_source_params, \ + _make_tv4_in((const float*)d_normal, B, Hin, Win, 3), \ + out_v, d_axes, in_H, in_W, 1.0f, 0.0f); \ + } + _SS_DISPATCH_SOURCE(distortion, d_source_models != nullptr, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -399,7 +408,7 @@ __forceinline__ __device__ float3 solve3(float3 col0, float3 col1, float3 col2, return {x, y, z}; } -template +template __global__ void warp_image_pinhole_to_wide_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // [B, 4] @@ -426,14 +435,15 @@ __global__ void warp_image_pinhole_to_wide_kernel( float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); float total[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float total_count = 0; float2 uv = { (i+0.5f-cx) / fx, (j+0.5f-cy) / fy }; float3 raydir; - if (!SlangProjectionUtils::unproject_point(uv, (int)camera_model, dist_coeffs, &raydir)) { + if (!SlangDistortion::unproject_point( + uv, (int)camera_model, dist_coeffs, &raydir)) { for (int c = 0; c < C; c++) wide_image.at(bid, j, i, c) = 0.0f; return; @@ -507,8 +517,9 @@ __global__ void warp_image_pinhole_to_wide_kernel( /*[AutoHeaderGeneratorExport]*/ void warp_image_pinhole_to_wide_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, C] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -535,19 +546,23 @@ void warp_image_pinhole_to_wide_tensor( return v; }; - warp_image_pinhole_to_wide_kernel<<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - make_tv4(wide_image), make_tv5(pinhole_images), - (float*)std::get<0>(axes) - ); + #define LAUNCH(D) \ + warp_image_pinhole_to_wide_kernel \ + <<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + make_tv4(wide_image), make_tv5(pinhole_images), \ + (float*)std::get<0>(axes)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } /*[AutoHeaderGeneratorExport]*/ void warp_linear_depth_pinhole_to_wide_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, 1] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -574,19 +589,23 @@ void warp_linear_depth_pinhole_to_wide_tensor( return v; }; - warp_image_pinhole_to_wide_kernel<<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - make_tv4(wide_image), make_tv5(pinhole_images), - (float*)std::get<0>(axes) - ); + #define LAUNCH(D) \ + warp_image_pinhole_to_wide_kernel \ + <<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + make_tv4(wide_image), make_tv5(pinhole_images), \ + (float*)std::get<0>(axes)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } /*[AutoHeaderGeneratorExport]*/ void warp_ray_depth_pinhole_to_wide_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, 1] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -613,19 +632,23 @@ void warp_ray_depth_pinhole_to_wide_tensor( return v; }; - warp_image_pinhole_to_wide_kernel<<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - make_tv4(wide_image), make_tv5(pinhole_images), - (float*)std::get<0>(axes) - ); + #define LAUNCH(D) \ + warp_image_pinhole_to_wide_kernel \ + <<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + make_tv4(wide_image), make_tv5(pinhole_images), \ + (float*)std::get<0>(axes)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } /*[AutoHeaderGeneratorExport]*/ void warp_points_pinhole_to_wide_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, 3] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -652,17 +675,21 @@ void warp_points_pinhole_to_wide_tensor( return v; }; - warp_image_pinhole_to_wide_kernel<<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - make_tv4(wide_image), make_tv5(pinhole_images), - (float*)std::get<0>(axes) - ); + #define LAUNCH(D) \ + warp_image_pinhole_to_wide_kernel \ + <<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + make_tv4(wide_image), make_tv5(pinhole_images), \ + (float*)std::get<0>(axes)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } // Resolve scale in relative depth - // The eigenvector corresponding to the smallest eigenvalue of this matrix tells how much depth maps need to be scaled +template __global__ void warp_depth_pinhole_to_wide_scale_matrix_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // [B, 4] @@ -687,11 +714,12 @@ __global__ void warp_depth_pinhole_to_wide_scale_matrix_kernel( float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); float2 uv = { (i+0.5f-cx) / fx, (j+0.5f-cy) / fy }; float3 raydir; - if (!SlangProjectionUtils::unproject_point(uv, (int)camera_model, dist_coeffs, &raydir)) + if (!SlangDistortion::unproject_point( + uv, (int)camera_model, dist_coeffs, &raydir)) return; constexpr int MAX_K = 12; @@ -736,8 +764,9 @@ __global__ void warp_depth_pinhole_to_wide_scale_matrix_kernel( /*[AutoHeaderGeneratorExport]*/ void warp_depth_pinhole_to_wide_scale_matrix_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, 1] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -755,13 +784,16 @@ void warp_depth_pinhole_to_wide_scale_matrix_tensor( return v; }; - warp_depth_pinhole_to_wide_scale_matrix_kernel<<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - out_w, out_h, - make_tv5(pinhole_images), - (float*)std::get<0>(axes), - (float*)std::get<0>(matrix) - ); + #define LAUNCH(D) \ + warp_depth_pinhole_to_wide_scale_matrix_kernel \ + <<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + out_w, out_h, \ + make_tv5(pinhole_images), \ + (float*)std::get<0>(axes), \ + (float*)std::get<0>(matrix)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } diff --git a/src/kernels/pixelwise/ImageDistort.cu b/src/kernels/pixelwise/ImageDistort.cu index 85045e35..023841fe 100644 --- a/src/kernels/pixelwise/ImageDistort.cu +++ b/src/kernels/pixelwise/ImageDistort.cu @@ -9,7 +9,7 @@ // ================ -template +template __global__ void distort_image_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // [B, 4] @@ -30,12 +30,13 @@ __global__ void distort_image_kernel( // Load camera float4 intrin = intrins[bid]; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + using Dist = SlangDistortion; + typename Dist::Coeffs dist_coeffs = dist_coeffs_buffer.load(bid); // Undistort point float2 uv = { (i+0.5f-cx) / fx, (j+0.5f-cy) / fy }; if (is_undistort) { - if (dot(uv, uv) > 0.0f && !SlangProjectionUtils::is_valid_distortion( + if (dot(uv, uv) > 0.0f && !Dist::is_valid_distortion( camera_model == CameraModelType::FISHEYE ? normalize(uv) * atanf(length(uv)) : camera_model == CameraModelType::EQUISOLID ? @@ -44,10 +45,10 @@ __global__ void distort_image_kernel( dist_coeffs )) return; - uv = SlangProjectionUtils::distort_point(uv, (int)camera_model, dist_coeffs); + uv = Dist::distort_point(uv, (int)camera_model, dist_coeffs); } else { - if (!SlangProjectionUtils::undistort_point(uv, (int)camera_model, dist_coeffs, &uv)) + if (!Dist::undistort_point(uv, (int)camera_model, dist_coeffs, &uv)) return; } @@ -73,36 +74,42 @@ static TensorView _bhwc_view(const TorchTensorView& tv) { /*[AutoHeaderGeneratorExport]*/ void distort_image_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView in_image, // [B, H, W, C] float TorchTensorView out_image // [B, H, W, C] float (must be pre-zeroed) ) { const auto& s = std::get<2>(in_image); int b = s[0], h = s[1], w = s[2]; - distort_image_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - _bhwc_view(in_image), _bhwc_view(out_image) - ); + #define LAUNCH(D) \ + distort_image_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + _bhwc_view(in_image), _bhwc_view(out_image)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } /*[AutoHeaderGeneratorExport]*/ void undistort_image_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView in_image, // [B, H, W, C] float TorchTensorView out_image // [B, H, W, C] float (must be pre-zeroed) ) { const auto& s = std::get<2>(in_image); int b = s[0], h = s[1], w = s[2]; - distort_image_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - _bhwc_view(in_image), _bhwc_view(out_image) - ); + #define LAUNCH(D) \ + distort_image_kernel<<<_LAUNCH_ARGS_3D(w, h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + _bhwc_view(in_image), _bhwc_view(out_image)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } diff --git a/src/kernels/pixelwise/ImageRedistort.cu b/src/kernels/pixelwise/ImageRedistort.cu new file mode 100644 index 00000000..6e3fc5ec --- /dev/null +++ b/src/kernels/pixelwise/ImageRedistort.cu @@ -0,0 +1,345 @@ +// ImageRedistort.cu -- resample GT images from a camera whose lens model no +// distortion tier represents onto the tier the parser fitted for it. +// +// The fit does not change the pose, so a destination pixel and its source pixel +// are the SAME ray: depth (linear or ray) and camera-frame normals transfer +// unchanged, and only the sampling coordinate moves. That is why these kernels +// carry none of the point-space handling GtDepthNormalWarp.cu needs -- there +// the destination is a rotated cubemap face. +// +// The fused fisheye case does not come through here at all: when +// warp_to_pinhole is on, the wide->pinhole warps take the source projection +// directly (RayToPixel), so the fitted camera is never materialized +// and no intermediate image is allocated. +// +// Part of the PixelWise family -- see PixelWiseCommon.cuh. + +#include "kernels/pixelwise/BilinearSample.cuh" +#include "kernels/pixelwise/RedistortSource.cuh" + +// ================ +// Re-distort +// ================ + +// Destination pixel -> source pixel. Both grids are expressed relative to the +// intrinsics reference (the RGB resolution), and they need not match: a depth +// or normal map carries its own size, so `scale_out` and `scale_in` differ. +template +__forceinline__ __device__ bool _redistort_lookup( + const RayToPixel& to_source, + CameraModelType camera_model, float4 intrin, + const typename SlangDistortion::Coeffs& coeffs, + float2 scale_out, float2 scale_in, + uint32_t i, uint32_t j, float2* uv_src +) { + float2 uv = { + (((float)i + 0.5f) / scale_out.x - intrin.z) / intrin.x, + (((float)j + 0.5f) / scale_out.y - intrin.w) / intrin.y + }; + float3 raydir; + if (!SlangDistortion::unproject_point( + uv, (int)camera_model, coeffs, &raydir)) + return false; + if (!to_source(raydir, uv_src)) + return false; + uv_src->x *= scale_in.x; + uv_src->y *= scale_in.y; + return true; +} + +template +__global__ void redistort_image_kernel( + CameraModelType camera_model, + const float4 *__restrict__ intrins, // [B, 4] fitted + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const int *__restrict__ source_models, // [B] + const float *__restrict__ source_params, // [B, 16] + TensorView in_image, // [B, H, W, C] + TensorView out_image, // [B, H, W, C] + int ref_H, int ref_W, // intrinsics ref res + float norm_inv, float invalid +) { + const int B = in_image.shape[0], + H = out_image.shape[1], + W = out_image.shape[2], + C = in_image.shape[3]; + uint32_t bid = blockIdx.z * blockDim.z + threadIdx.z; + uint32_t i = blockIdx.x * blockDim.x + threadIdx.x; + uint32_t j = blockIdx.y * blockDim.y + threadIdx.y; + if (bid >= B || i >= W || j >= H) return; + + float4 intrin = intrins[bid]; + auto coeffs = dist_coeffs_buffer.load(bid); + auto to_source = make_ray_to_pixel( + bid, camera_model, intrins, dist_coeffs_buffer, source_models, source_params); + float2 scale_out = { (float)W / (float)ref_W, (float)H / (float)ref_H }; + float2 scale_in = { (float)in_image.shape[2] / (float)ref_W, + (float)in_image.shape[1] / (float)ref_H }; + + float2 uv_src; + bool valid = _redistort_lookup( + to_source, camera_model, intrin, coeffs, scale_out, scale_in, i, j, &uv_src); + for (int c = 0; c < C; c++) { + out_image.at(bid, j, i, c) = valid + ? bilinear_byte_norm(in_image, bid, c, uv_src.x, uv_src.y, + norm_inv, invalid) + : invalid; + } +} + +// Nearest lookup, and out-of-frame is masked OUT rather than padded: the fitted +// camera can see a little past the source image, exactly as the wide->pinhole +// mask warp does. +template +__global__ void redistort_mask_kernel( + CameraModelType camera_model, + const float4 *__restrict__ intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const int *__restrict__ source_models, + const float *__restrict__ source_params, + TensorView in_mask, // [B, H, W, 1] + TensorView out_mask, // [B, H, W, 1] + int ref_H, int ref_W +) { + const int B = in_mask.shape[0], + Hin = in_mask.shape[1], + Win = in_mask.shape[2], + H = out_mask.shape[1], + W = out_mask.shape[2]; + uint32_t bid = blockIdx.z * blockDim.z + threadIdx.z; + uint32_t i = blockIdx.x * blockDim.x + threadIdx.x; + uint32_t j = blockIdx.y * blockDim.y + threadIdx.y; + if (bid >= B || i >= W || j >= H) return; + + float4 intrin = intrins[bid]; + auto coeffs = dist_coeffs_buffer.load(bid); + auto to_source = make_ray_to_pixel( + bid, camera_model, intrins, dist_coeffs_buffer, source_models, source_params); + float2 scale_out = { (float)W / (float)ref_W, (float)H / (float)ref_H }; + float2 scale_in = { (float)Win / (float)ref_W, (float)Hin / (float)ref_H }; + + float2 uv_src; + uint8_t out = 0; + if (_redistort_lookup( + to_source, camera_model, intrin, coeffs, scale_out, scale_in, i, j, &uv_src)) { + int xs = (int)floorf(uv_src.x + 0.5f); + int ys = (int)floorf(uv_src.y + 0.5f); + if (xs >= 0 && xs < Win && ys >= 0 && ys < Hin) + out = (in_mask.at(bid, ys, xs, 0) != 0) ? 1 : 0; + } + out_mask.at(bid, j, i, 0) = out; +} + +// Normals are re-normalized after the bilinear blend and keep the (-1,-1,-1) +// "no data" sentinel, matching _warp_one_normal. +template +__global__ void redistort_normal_kernel( + CameraModelType camera_model, + const float4 *__restrict__ intrins, + const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const int *__restrict__ source_models, + const float *__restrict__ source_params, + TensorView in_normal, // [B, H, W, 3] + TensorView out_normal, // [B, H, W, 3] + int ref_H, int ref_W, + float norm_inv, float decode_off +) { + const int B = in_normal.shape[0], + H = out_normal.shape[1], + W = out_normal.shape[2]; + uint32_t bid = blockIdx.z * blockDim.z + threadIdx.z; + uint32_t i = blockIdx.x * blockDim.x + threadIdx.x; + uint32_t j = blockIdx.y * blockDim.y + threadIdx.y; + if (bid >= B || i >= W || j >= H) return; + + float4 intrin = intrins[bid]; + auto coeffs = dist_coeffs_buffer.load(bid); + auto to_source = make_ray_to_pixel( + bid, camera_model, intrins, dist_coeffs_buffer, source_models, source_params); + float2 scale_out = { (float)W / (float)ref_W, (float)H / (float)ref_H }; + float2 scale_in = { (float)in_normal.shape[2] / (float)ref_W, + (float)in_normal.shape[1] / (float)ref_H }; + + float3 n = make_float3(-1.0f, -1.0f, -1.0f); + float2 uv_src; + if (_redistort_lookup( + to_source, camera_model, intrin, coeffs, scale_out, scale_in, i, j, &uv_src)) { + float3 s; + s.x = bilinear_byte_norm(in_normal, bid, 0, uv_src.x, uv_src.y, norm_inv, 0.0f) + decode_off; + s.y = bilinear_byte_norm(in_normal, bid, 1, uv_src.x, uv_src.y, norm_inv, 0.0f) + decode_off; + s.z = bilinear_byte_norm(in_normal, bid, 2, uv_src.x, uv_src.y, norm_inv, 0.0f) + decode_off; + float sl = length(s); + // The pose is unchanged, so a camera-frame normal needs no rotation. + if (s.x + s.y + s.z > -2.366f && sl > 1e-8f) + n = s / sl; + } + out_normal.at(bid, j, i, 0) = n.x; + out_normal.at(bid, j, i, 1) = n.y; + out_normal.at(bid, j, i, 2) = n.z; +} + + +// ---- Host launchers ------------------------------------------------------ + +namespace { + +TensorView _rd_f32(float* p, int B, int H, int W, int C) { + TensorView v; + v.data = p; + v.shape[0] = B; v.shape[1] = H; v.shape[2] = W; v.shape[3] = C; + long s3 = C, s2 = (long)W * s3, s1 = (long)H * s2; + v.strides[0] = s1; v.strides[1] = s2; v.strides[2] = s3; v.strides[3] = 1; + return v; +} + +template +TensorView _rd_in(const T* p, int B, int H, int W, int C) { + TensorView v; + v.data = const_cast(p); + v.shape[0] = B; v.shape[1] = H; v.shape[2] = W; v.shape[3] = C; + long s3 = C, s2 = (long)W * s3, s1 = (long)H * s2; + v.strides[0] = s1; v.strides[1] = s2; v.strides[2] = s3; v.strides[3] = 1; + return v; +} + +} // namespace + +/*[AutoHeaderGeneratorExport]*/ +void launch_redistort_byte_to_float( + std::string camera_model, + std::string distortion, + const float* d_intrins, // [B, 4] fitted + const float* d_dist_coeffs, // [B, 8] (nullable -> zeros) + const int* d_source_models, // [B] + const float* d_source_params, // [B, 16] + const void* d_byte, bool input_is_u16, + int B, int in_H, int in_W, int C, + float* d_float_out, int out_H, int out_W, + int ref_H, int ref_W, + float invalid) +{ + CameraModelType cm = cmt(camera_model); + CameraDistortionCoeffsBuffer dcb(const_cast(d_dist_coeffs)); + const float4* intr = (const float4*)d_intrins; + auto out = _rd_f32(d_float_out, B, out_H, out_W, C); + + #define _RD_LAUNCH(D) \ + if (input_is_u16) \ + redistort_image_kernel \ + <<<_LAUNCH_ARGS_3D(out_W, out_H, B, 16, 16, 1)>>>( \ + cm, intr, dcb, d_source_models, d_source_params, \ + _rd_in((const uint16_t*)d_byte, B, in_H, in_W, C), out, \ + ref_H, ref_W, 1.0f / 65535.0f, invalid); \ + else \ + redistort_image_kernel \ + <<<_LAUNCH_ARGS_3D(out_W, out_H, B, 16, 16, 1)>>>( \ + cm, intr, dcb, d_source_models, d_source_params, \ + _rd_in((const uint8_t*)d_byte, B, in_H, in_W, C), out, \ + ref_H, ref_W, 1.0f / 255.0f, invalid); + _SS_DISPATCH_DISTORTION(distortion, _RD_LAUNCH); + #undef _RD_LAUNCH + CHECK_DEVICE_ERROR(cudaGetLastError()); +} + +/*[AutoHeaderGeneratorExport]*/ +void launch_redistort_depth( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const void* d_in, uint32_t elem_size, // 2 = uint16 raw counts, 4 = float + int B, int in_H, int in_W, int C, + float* d_float_out, int out_H, int out_W, + int ref_H, int ref_W, + float invalid) +{ + CameraModelType cm = cmt(camera_model); + CameraDistortionCoeffsBuffer dcb(const_cast(d_dist_coeffs)); + const float4* intr = (const float4*)d_intrins; + auto out = _rd_f32(d_float_out, B, out_H, out_W, C); + + // Depth is raw counts either way, so norm_inv stays 1 -- same convention as + // the wide warp. + #define _RD_LAUNCH(D) \ + if (elem_size == 2) \ + redistort_image_kernel \ + <<<_LAUNCH_ARGS_3D(out_W, out_H, B, 16, 16, 1)>>>( \ + cm, intr, dcb, d_source_models, d_source_params, \ + _rd_in((const uint16_t*)d_in, B, in_H, in_W, C), out, \ + ref_H, ref_W, 1.0f, invalid); \ + else \ + redistort_image_kernel \ + <<<_LAUNCH_ARGS_3D(out_W, out_H, B, 16, 16, 1)>>>( \ + cm, intr, dcb, d_source_models, d_source_params, \ + _rd_in((const float*)d_in, B, in_H, in_W, C), out, \ + ref_H, ref_W, 1.0f, invalid); + _SS_DISPATCH_DISTORTION(distortion, _RD_LAUNCH); + #undef _RD_LAUNCH + CHECK_DEVICE_ERROR(cudaGetLastError()); +} + +/*[AutoHeaderGeneratorExport]*/ +void launch_redistort_mask( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const uint8_t* d_byte_mask, + int B, int in_H, int in_W, + uint8_t* d_byte_out, int out_H, int out_W, + int ref_H, int ref_W) +{ + CameraModelType cm = cmt(camera_model); + CameraDistortionCoeffsBuffer dcb(const_cast(d_dist_coeffs)); + const float4* intr = (const float4*)d_intrins; + auto in_v = _rd_in(d_byte_mask, B, in_H, in_W, 1); + auto out_v = _rd_in((const uint8_t*)d_byte_out, B, out_H, out_W, 1); + + #define _RD_LAUNCH(D) \ + redistort_mask_kernel<<<_LAUNCH_ARGS_3D(out_W, out_H, B, 16, 16, 1)>>>( \ + cm, intr, dcb, d_source_models, d_source_params, \ + in_v, out_v, ref_H, ref_W); + _SS_DISPATCH_DISTORTION(distortion, _RD_LAUNCH); + #undef _RD_LAUNCH + CHECK_DEVICE_ERROR(cudaGetLastError()); +} + +/*[AutoHeaderGeneratorExport]*/ +void launch_redistort_normal( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const void* d_in, bool input_is_float, + int B, int in_H, int in_W, + float* d_float_out, int out_H, int out_W, + int ref_H, int ref_W) +{ + CameraModelType cm = cmt(camera_model); + CameraDistortionCoeffsBuffer dcb(const_cast(d_dist_coeffs)); + const float4* intr = (const float4*)d_intrins; + auto out = _rd_f32(d_float_out, B, out_H, out_W, 3); + + #define _RD_LAUNCH(D) \ + if (input_is_float) \ + redistort_normal_kernel \ + <<<_LAUNCH_ARGS_3D(out_W, out_H, B, 16, 16, 1)>>>( \ + cm, intr, dcb, d_source_models, d_source_params, \ + _rd_in((const float*)d_in, B, in_H, in_W, 3), out, \ + ref_H, ref_W, 1.0f, 0.0f); \ + else \ + redistort_normal_kernel \ + <<<_LAUNCH_ARGS_3D(out_W, out_H, B, 16, 16, 1)>>>( \ + cm, intr, dcb, d_source_models, d_source_params, \ + _rd_in((const uint8_t*)d_in, B, in_H, in_W, 3), out, \ + ref_H, ref_W, 1.0f / 127.5f, -1.0f); + _SS_DISPATCH_DISTORTION(distortion, _RD_LAUNCH); + #undef _RD_LAUNCH + CHECK_DEVICE_ERROR(cudaGetLastError()); +} diff --git a/src/kernels/pixelwise/ImageWarp.cu b/src/kernels/pixelwise/ImageWarp.cu index f171444a..30571dc2 100644 --- a/src/kernels/pixelwise/ImageWarp.cu +++ b/src/kernels/pixelwise/ImageWarp.cu @@ -4,16 +4,19 @@ // Part of the PixelWise family -- see PixelWiseCommon.cuh. #include "kernels/pixelwise/BilinearSample.cuh" +#include "kernels/pixelwise/RedistortSource.cuh" // ================ // Warp / Unwarp // ================ -template +template __global__ void warp_image_wide_to_pinhole_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // [B, 4] const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const int *__restrict__ source_models, // [B], null unless from_source + const float *__restrict__ source_params, // [B, 16] TensorView wide_image, // [B, H, W, C] TensorView pinhole_images, // [B*K, H, W, C] const float* __restrict__ axes // [K, 3, 3] @@ -32,8 +35,8 @@ __global__ void warp_image_wide_to_pinhole_kernel( float tx = -1.0f + 2.0f * ((float)i + 0.5f) / (float)Wp; float ty = -1.0f + 2.0f * ((float)j + 0.5f) / (float)Hp; - float4 intrin = intrins[bid]; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto to_pixel = make_ray_to_pixel( + bid, camera_model, intrins, dist_coeffs_buffer, source_models, source_params); for (int ki = 0; ki < K; ++ki) { float3 axis_x = {axes[0], axes[1], axes[2]}; @@ -43,11 +46,7 @@ __global__ void warp_image_wide_to_pinhole_kernel( float3 raydir = axis_z + tx * axis_x + ty * axis_y; float2 uv; - bool valid = camera_model == CameraModelType::FISHEYE ? - SlangProjectionUtils::fisheye_proj_nav(raydir, intrin, dist_coeffs, &uv) : - camera_model == CameraModelType::EQUISOLID ? - SlangProjectionUtils::equisolid_proj_nav(raydir, intrin, dist_coeffs, &uv) : - SlangProjectionUtils::persp_proj_nav(raydir, intrin, dist_coeffs, &uv); + bool valid = to_pixel(raydir, &uv); if (valid) { for (int c = 0; c < C; c++) pinhole_images.at(bid, ki, j, i, c) = get_pixel_bilinear(wide_image, bid, c, uv.x, uv.y, 0.5f); @@ -62,8 +61,9 @@ __global__ void warp_image_wide_to_pinhole_kernel( /*[AutoHeaderGeneratorExport]*/ void warp_image_wide_to_pinhole_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView wide_image, // [B, H, W, C] (float) TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -91,11 +91,15 @@ void warp_image_wide_to_pinhole_tensor( return v; }; - warp_image_wide_to_pinhole_kernel<<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( - cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, - make_tv4(wide_image), make_tv5(pinhole_images), - (float*)std::get<0>(axes) - ); + #define LAUNCH(D) \ + warp_image_wide_to_pinhole_kernel \ + <<<_LAUNCH_ARGS_3D(out_w, out_h, b, 16, 16, 1)>>>( \ + cmt(camera_model), (float4*)std::get<0>(intrins), dist_coeffs, \ + nullptr, nullptr, \ + make_tv4(wide_image), make_tv5(pinhole_images), \ + (float*)std::get<0>(axes)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -194,11 +198,13 @@ void warp_image_equirectangular_to_pinhole_tensor( // Wide -> pinhole, fused byte->float. Output is [B*K, H_out, W_out, C] // laid out as [B, K, H_out, W_out, C] -- flatten via stride math. -template +template __global__ void warp_image_wide_to_pinhole_byte_to_float_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, // [B, 4] const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const int *__restrict__ source_models, + const float *__restrict__ source_params, TensorView wide_image, // [B, H, W, C] TensorView pinhole_images, // [B, K, H_out, W_out, C] const float* __restrict__ axes, // [K, 3, 3] @@ -217,8 +223,8 @@ __global__ void warp_image_wide_to_pinhole_byte_to_float_kernel( float tx = -1.0f + 2.0f * ((float)i + 0.5f) / (float)Wp; float ty = -1.0f + 2.0f * ((float)j + 0.5f) / (float)Hp; - float4 intrin = intrins[bid]; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto to_pixel = make_ray_to_pixel( + bid, camera_model, intrins, dist_coeffs_buffer, source_models, source_params); for (int ki = 0; ki < K; ++ki) { float3 axis_x = {axes[9*ki + 0], axes[9*ki + 1], axes[9*ki + 2]}; @@ -226,11 +232,7 @@ __global__ void warp_image_wide_to_pinhole_byte_to_float_kernel( float3 axis_z = {axes[9*ki + 6], axes[9*ki + 7], axes[9*ki + 8]}; float3 raydir = axis_z + tx * axis_x + ty * axis_y; float2 uv; - bool valid = camera_model == CameraModelType::FISHEYE ? - SlangProjectionUtils::fisheye_proj_nav(raydir, intrin, dist_coeffs, &uv) : - camera_model == CameraModelType::EQUISOLID ? - SlangProjectionUtils::equisolid_proj_nav(raydir, intrin, dist_coeffs, &uv) : - SlangProjectionUtils::persp_proj_nav(raydir, intrin, dist_coeffs, &uv); + bool valid = to_pixel(raydir, &uv); if (valid) { for (int c = 0; c < C; c++) pinhole_images.at(bid, ki, j, i, c) = @@ -285,10 +287,13 @@ __global__ void warp_image_equirectangular_to_pinhole_byte_to_float_kernel( // Nearest-neighbor mask warps. Mask is bool; we read uint8 (0 / nonzero) // and emit uint8 0/1 at the post-split resolution. Camera-model dispatch // matches the RGB kernels. +template __global__ void warp_mask_wide_to_pinhole_kernel( CameraModelType camera_model, const float4 *__restrict__ intrins, const CameraDistortionCoeffsBuffer dist_coeffs_buffer, + const int *__restrict__ source_models, + const float *__restrict__ source_params, TensorView wide_mask, // [B, H, W, 1] TensorView pinhole_masks, // [B, K, H_out, W_out, 1] const float* __restrict__ axes @@ -306,8 +311,8 @@ __global__ void warp_mask_wide_to_pinhole_kernel( float tx = -1.0f + 2.0f * ((float)i + 0.5f) / (float)Wp; float ty = -1.0f + 2.0f * ((float)j + 0.5f) / (float)Hp; - float4 intrin = intrins[bid]; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto to_pixel = make_ray_to_pixel( + bid, camera_model, intrins, dist_coeffs_buffer, source_models, source_params); for (int ki = 0; ki < K; ++ki) { float3 axis_x = {axes[9*ki + 0], axes[9*ki + 1], axes[9*ki + 2]}; @@ -315,11 +320,7 @@ __global__ void warp_mask_wide_to_pinhole_kernel( float3 axis_z = {axes[9*ki + 6], axes[9*ki + 7], axes[9*ki + 8]}; float3 raydir = axis_z + tx * axis_x + ty * axis_y; float2 uv; - bool valid = camera_model == CameraModelType::FISHEYE ? - SlangProjectionUtils::fisheye_proj_nav(raydir, intrin, dist_coeffs, &uv) : - camera_model == CameraModelType::EQUISOLID ? - SlangProjectionUtils::equisolid_proj_nav(raydir, intrin, dist_coeffs, &uv) : - SlangProjectionUtils::persp_proj_nav(raydir, intrin, dist_coeffs, &uv); + bool valid = to_pixel(raydir, &uv); uint8_t out = 0; if (valid) { int xs = (int)floorf(uv.x + 0.5f); @@ -375,8 +376,11 @@ __global__ void warp_mask_equirectangular_to_pinhole_kernel( /*[AutoHeaderGeneratorExport]*/ void launch_warp_byte_to_float_wide( std::string camera_model, + std::string distortion, const float* d_intrins, // [B, 4] - const float* d_dist_coeffs, // [B, 10] (nullable -> all-zeros) + const float* d_dist_coeffs, // [B, 8] (nullable -> all-zeros) + const int* d_source_models, // [B] (null unless re-distorting) + const float* d_source_params, // [B, 16] const void* d_byte, bool input_is_u16, int B, int Hin, int Win, int C, float* d_float_out, int K, int Hout, int Wout, @@ -409,19 +413,22 @@ void launch_warp_byte_to_float_wide( CameraModelType cm = cmt(camera_model); CameraDistortionCoeffsBuffer dcb(const_cast(d_dist_coeffs)); const float4* intrins_f4 = (const float4*)d_intrins; - if (input_is_u16) { - warp_image_wide_to_pinhole_byte_to_float_kernel - <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( - cm, intrins_f4, dcb, - make_4_u16((const uint16_t*)d_byte), make_5(d_float_out), - d_axes, 1.0f / 65535.0f); - } else { - warp_image_wide_to_pinhole_byte_to_float_kernel - <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( - cm, intrins_f4, dcb, - make_4_u8((const uint8_t*)d_byte), make_5(d_float_out), - d_axes, 1.0f / 255.0f); - } + #define LAUNCH(D, FROM) \ + if (input_is_u16) { \ + warp_image_wide_to_pinhole_byte_to_float_kernel \ + <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( \ + cm, intrins_f4, dcb, d_source_models, d_source_params, \ + make_4_u16((const uint16_t*)d_byte), make_5(d_float_out), \ + d_axes, 1.0f / 65535.0f); \ + } else { \ + warp_image_wide_to_pinhole_byte_to_float_kernel \ + <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( \ + cm, intrins_f4, dcb, d_source_models, d_source_params, \ + make_4_u8((const uint8_t*)d_byte), make_5(d_float_out), \ + d_axes, 1.0f / 255.0f); \ + } + _SS_DISPATCH_SOURCE(distortion, d_source_models != nullptr, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -473,8 +480,11 @@ void launch_warp_byte_to_float_equi( /*[AutoHeaderGeneratorExport]*/ void launch_warp_mask_wide( std::string camera_model, + std::string distortion, const float* d_intrins, // [B, 4] - const float* d_dist_coeffs, // [B, 10] (nullable) + const float* d_dist_coeffs, // [B, 8] (nullable) + const int* d_source_models, // [B] (null unless re-distorting) + const float* d_source_params, // [B, 16] const uint8_t* d_byte_mask, int B, int Hin, int Win, uint8_t* d_byte_out, int K, int Hout, int Wout, @@ -494,8 +504,13 @@ void launch_warp_mask_wide( CameraModelType cm = cmt(camera_model); CameraDistortionCoeffsBuffer dcb(const_cast(d_dist_coeffs)); const float4* intrins_f4 = (const float4*)d_intrins; - warp_mask_wide_to_pinhole_kernel<<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( - cm, intrins_f4, dcb, in_v, out_v, d_axes); + #define LAUNCH(D, FROM) \ + warp_mask_wide_to_pinhole_kernel \ + <<<_LAUNCH_ARGS_3D(Wout, Hout, B, 16, 16, 1)>>>( \ + cm, intrins_f4, dcb, d_source_models, d_source_params, \ + in_v, out_v, d_axes) + _SS_DISPATCH_SOURCE(distortion, d_source_models != nullptr, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } diff --git a/src/kernels/pixelwise/PixelWise.cuh b/src/kernels/pixelwise/PixelWise.cuh index 99946f0d..1d1510fe 100644 --- a/src/kernels/pixelwise/PixelWise.cuh +++ b/src/kernels/pixelwise/PixelWise.cuh @@ -188,8 +188,9 @@ void overexposure_grad_add( void depth_to_points_forward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D out_points // [B, H, W, 3] @@ -198,8 +199,9 @@ void depth_to_points_forward( void depth_to_points_backward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D in_depths, // [B, H, W, 1] DeviceTensor3D v_out_points,// [B, H, W, 3] @@ -209,8 +211,9 @@ void depth_to_points_backward( void depth_to_normal_forward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D normals // [B, H, W, 3] @@ -219,8 +222,9 @@ void depth_to_normal_forward( void depth_to_normal_backward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D v_normals, // [B, H, W, 3] @@ -230,6 +234,7 @@ void depth_to_normal_backward( void depth_to_normal_forward_tv( std::string camera_model, + std::string distortion, TorchTensorView intrins, TorchTensorView dist_coeffs, bool is_ray_depth, @@ -240,6 +245,7 @@ void depth_to_normal_forward_tv( void depth_to_normal_backward_tv( std::string camera_model, + std::string distortion, TorchTensorView intrins, TorchTensorView dist_coeffs, bool is_ray_depth, @@ -251,8 +257,9 @@ void depth_to_normal_backward_tv( void depth_normal_loss_forward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D gt_normals, // [B, H, W, 3] @@ -262,8 +269,9 @@ void depth_normal_loss_forward( void depth_normal_loss_backward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] bool is_ray_depth, DeviceTensor3D depths, // [B, H, W, 1] DeviceTensor3D gt_normals, // [B, H, W, 3] @@ -275,8 +283,9 @@ void depth_normal_loss_backward( void ray_depth_to_linear_depth_forward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView depths, // [B, H, W, 1] TorchTensorView out_depths // [B, H, W, 1] ); @@ -284,8 +293,9 @@ void ray_depth_to_linear_depth_forward( void ray_depth_to_linear_depth_backward( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView v_out_depths, // [B, H, W, 1] TorchTensorView v_in_depths // [B, H, W, 1] ); @@ -293,8 +303,9 @@ void ray_depth_to_linear_depth_backward( void linear_depth_to_ray_depth_inplace( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] at image resolution - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] int image_width, int image_height, DeviceTensor3D depths // [B, Hd, Wd, 1] in/out ); @@ -302,8 +313,9 @@ void linear_depth_to_ray_depth_inplace( void distort_image_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView in_image, // [B, H, W, C] float TorchTensorView out_image // [B, H, W, C] float (must be pre-zeroed) ); @@ -311,8 +323,9 @@ void distort_image_tensor( void undistort_image_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView in_image, // [B, H, W, C] float TorchTensorView out_image // [B, H, W, C] float (must be pre-zeroed) ); @@ -320,8 +333,9 @@ void undistort_image_tensor( void warp_image_wide_to_pinhole_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView wide_image, // [B, H, W, C] (float) TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -339,8 +353,11 @@ void warp_image_equirectangular_to_pinhole_tensor( void launch_warp_byte_to_float_wide( std::string camera_model, + std::string distortion, const float* d_intrins, // [B, 4] - const float* d_dist_coeffs, // [B, 10] (nullable -> all-zeros) + const float* d_dist_coeffs, // [B, 8] (nullable -> all-zeros) + const int* d_source_models, // [B] (null unless re-distorting) + const float* d_source_params, // [B, 16] const void* d_byte, bool input_is_u16, int B, int Hin, int Win, int C, float* d_float_out, int K, int Hout, int Wout, @@ -356,8 +373,11 @@ void launch_warp_byte_to_float_equi( void launch_warp_mask_wide( std::string camera_model, + std::string distortion, const float* d_intrins, // [B, 4] - const float* d_dist_coeffs, // [B, 10] (nullable) + const float* d_dist_coeffs, // [B, 8] (nullable) + const int* d_source_models, // [B] (null unless re-distorting) + const float* d_source_params, // [B, 16] const uint8_t* d_byte_mask, int B, int Hin, int Win, uint8_t* d_byte_out, int K, int Hout, int Wout, @@ -371,10 +391,67 @@ void launch_warp_mask_equi( const float* d_axes); -void launch_warp_depth_wide( +void launch_redistort_byte_to_float( std::string camera_model, + std::string distortion, + const float* d_intrins, // [B, 4] fitted + const float* d_dist_coeffs, // [B, 8] (nullable -> zeros) + const int* d_source_models, // [B] + const float* d_source_params, // [B, 16] + const void* d_byte, bool input_is_u16, + int B, int in_H, int in_W, int C, + float* d_float_out, int out_H, int out_W, + int ref_H, int ref_W, + float invalid); + + +void launch_redistort_depth( + std::string camera_model, + std::string distortion, const float* d_intrins, const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const void* d_in, uint32_t elem_size, // 2 = uint16 raw counts, 4 = float + int B, int in_H, int in_W, int C, + float* d_float_out, int out_H, int out_W, + int ref_H, int ref_W, + float invalid); + + +void launch_redistort_mask( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const uint8_t* d_byte_mask, + int B, int in_H, int in_W, + uint8_t* d_byte_out, int out_H, int out_W, + int ref_H, int ref_W); + + +void launch_redistort_normal( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, + const void* d_in, bool input_is_float, + int B, int in_H, int in_W, + float* d_float_out, int out_H, int out_W, + int ref_H, int ref_W); + + +void launch_warp_depth_wide( + std::string camera_model, + std::string distortion, + const float* d_intrins, + const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, const void* d_depth, uint32_t elem_size, int B, int Hin, int Win, int in_H, int in_W, @@ -391,8 +468,11 @@ void launch_warp_depth_equi( void launch_warp_normal_wide( std::string camera_model, + std::string distortion, const float* d_intrins, const float* d_dist_coeffs, + const int* d_source_models, + const float* d_source_params, const void* d_normal, uint32_t elem_size, int B, int Hin, int Win, int in_H, int in_W, @@ -409,8 +489,9 @@ void launch_warp_normal_equi( void warp_image_pinhole_to_wide_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, C] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -420,8 +501,9 @@ void warp_image_pinhole_to_wide_tensor( void warp_linear_depth_pinhole_to_wide_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, 1] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -431,8 +513,9 @@ void warp_linear_depth_pinhole_to_wide_tensor( void warp_ray_depth_pinhole_to_wide_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, 1] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -442,8 +525,9 @@ void warp_ray_depth_pinhole_to_wide_tensor( void warp_points_pinhole_to_wide_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, 3] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, @@ -453,8 +537,9 @@ void warp_points_pinhole_to_wide_tensor( void warp_depth_pinhole_to_wide_scale_matrix_tensor( std::string camera_model, + std::string distortion, TorchTensorView intrins, // [B, 4] - TorchTensorView dist_coeffs, // [B, 10] + TorchTensorView dist_coeffs, // [B, 8] TorchTensorView pinhole_images, // [B, K, H, W, 1] TorchTensorView axes, // [K, 3, 3] int out_w, int out_h, diff --git a/src/kernels/pixelwise/PixelWiseCommon.cuh b/src/kernels/pixelwise/PixelWiseCommon.cuh index cd8bb52f..7bdf9fe7 100644 --- a/src/kernels/pixelwise/PixelWiseCommon.cuh +++ b/src/kernels/pixelwise/PixelWiseCommon.cuh @@ -35,9 +35,106 @@ namespace SlangPPISP { #include "generated/set_namespace.cuh" #include "generated/ppisp.cuh" } +namespace SlangCameraSource { +#include "generated/set_namespace.cuh" +#include "generated/camera_source.cuh" +} #endif #include "core/Common.cuh" +#include "core/CameraDistortion.cuh" + +#ifdef __CUDACC__ + +// Per-tier pixel_wise exports, same shape as SlangDistortion in +// core/CameraDistortion.cuh (slangc cannot export a generic). +template +struct SlangPixelWiseDist; + +#define _SS_DEF_SLANG_PIXEL_WISE(TIER, SUFFIX) \ +template<> \ +struct SlangPixelWiseDist { \ + using Coeffs = CameraDistortionCoeffsT; \ + \ + static __device__ __forceinline__ \ + float3 generate_ray_d2n(float2 pix_pos, float4 intrins, const Coeffs& c, \ + int camera_model, bool is_ray_depth) { \ + return SlangPixelWise::generate_ray_d2n##SUFFIX( \ + pix_pos, intrins, c.v, camera_model, is_ray_depth); \ + } \ + static __device__ __forceinline__ \ + float3 depth_to_point(float2 pix_pos, float4 intrins, const Coeffs& c, \ + int camera_model, bool is_ray_depth, float depth) { \ + return SlangPixelWise::depth_to_point##SUFFIX( \ + pix_pos, intrins, c.v, camera_model, is_ray_depth, depth); \ + } \ + static __device__ __forceinline__ \ + float depth_to_point_vjp(float2 pix_pos, float4 intrins, const Coeffs& c, \ + int camera_model, bool is_ray_depth, \ + float depth, float3 v_point) { \ + return SlangPixelWise::depth_to_point_vjp##SUFFIX( \ + pix_pos, intrins, c.v, camera_model, is_ray_depth, depth, v_point); \ + } \ + static __device__ __forceinline__ \ + float3 depth_to_normal(float2 pix_center, float4 intrins, const Coeffs& c, \ + int camera_model, bool is_ray_depth, float4 depths) { \ + return SlangPixelWise::depth_to_normal##SUFFIX( \ + pix_center, intrins, c.v, camera_model, is_ray_depth, depths); \ + } \ + static __device__ __forceinline__ \ + void depth_to_normal_vjp(float2 pix_center, float4 intrins, const Coeffs& c, \ + int camera_model, bool is_ray_depth, float4 depths, \ + float3 v_normal, float4* v_depths) { \ + SlangPixelWise::depth_to_normal_vjp##SUFFIX( \ + pix_center, intrins, c.v, camera_model, is_ray_depth, depths, \ + v_normal, v_depths); \ + } \ + static __device__ __forceinline__ \ + float ray_depth_to_linear_depth_factor(float2 pix_center, float4 intrins, \ + const Coeffs& c, int camera_model) { \ + return SlangPixelWise::ray_depth_to_linear_depth_factor##SUFFIX( \ + pix_center, intrins, c.v, camera_model); \ + } \ + static __device__ __forceinline__ \ + float depth_normal_loss(float2 pix_center, float4 intrins, const Coeffs& c, \ + int camera_model, bool is_ray_depth, float4 depths, \ + float3 gt_normal) { \ + return SlangPixelWise::depth_normal_loss##SUFFIX( \ + pix_center, intrins, c.v, camera_model, is_ray_depth, depths, \ + gt_normal); \ + } \ + static __device__ __forceinline__ \ + void depth_normal_loss_vjp(float2 pix_center, float4 intrins, const Coeffs& c, \ + int camera_model, bool is_ray_depth, float4 depths, \ + float3 gt_normal, float v_loss, \ + float4* v_depths, float3* v_gt_normal) { \ + SlangPixelWise::depth_normal_loss_vjp##SUFFIX( \ + pix_center, intrins, c.v, camera_model, is_ray_depth, depths, \ + gt_normal, v_loss, v_depths, v_gt_normal); \ + } \ +}; + +_SS_DEF_SLANG_PIXEL_WISE(None, _none) +_SS_DEF_SLANG_PIXEL_WISE(OpenCV, _opencv) +_SS_DEF_SLANG_PIXEL_WISE(ThinPrism, _prism) +_SS_DEF_SLANG_PIXEL_WISE(Rational, _rational) + +#undef _SS_DEF_SLANG_PIXEL_WISE + +#endif // __CUDACC__ + + +// Run BODY(tier) for the tier `name` spells; the camera model stays runtime, +// so all four tiers are reachable for every model. +#define _SS_DISPATCH_DISTORTION(name, BODY) \ + do { switch (cdt(name)) { \ + case CameraDistortionType::None: BODY(CameraDistortionType::None); break; \ + case CameraDistortionType::OpenCV: BODY(CameraDistortionType::OpenCV); break; \ + case CameraDistortionType::ThinPrism: BODY(CameraDistortionType::ThinPrism); break; \ + case CameraDistortionType::Rational: BODY(CameraDistortionType::Rational); break; \ + default: throw std::runtime_error( \ + "Unknown camera distortion: " + std::string(name)); \ + } } while (0) static inline TensorView _bhw1_view(const TorchTensorView& tv) { diff --git a/src/kernels/pixelwise/RedistortSource.cuh b/src/kernels/pixelwise/RedistortSource.cuh new file mode 100644 index 00000000..70b980b8 --- /dev/null +++ b/src/kernels/pixelwise/RedistortSource.cuh @@ -0,0 +1,83 @@ +#pragma once + +// Ray -> input-image pixel, for the two ways a GT image can be resampled. +// +// `kFromSource == false` is the ordinary path: the input image belongs to a +// camera the engine can project directly. `kFromSource == true` is a camera +// whose lens model no distortion tier represents (COLMAP FOV / DIVISION / +// EUCM / RAD_TAN_THIN_PRISM_FISHEYE); the parser fitted it onto a tier, and the +// pixels have to come from the TRUE source projection, not from the fit. +// +// Both warps take this as a template argument so an ordinary dataset pays +// neither the branch nor the 16 registers the source parameters occupy. + +#include "core/Common.cuh" +#include "core/CameraDistortion.cuh" + +#ifdef __CUDACC__ + +template +struct RayToPixel { + CameraModelType camera_model; + float4 intrin; + typename SlangDistortion::Coeffs coeffs; + int source_model = -1; + const float* __restrict__ source_params = nullptr; // [16], this image's row + + __device__ __forceinline__ bool operator()(float3 raydir, float2* uv) const { + if constexpr (kFromSource) { + FixedArray p; + #pragma unroll + for (int i = 0; i < 16; i++) p[i] = source_params[i]; + return SlangCameraSource::source_project(source_model, p, raydir, uv); + } else { + return camera_proj_nav(camera_model, raydir, intrin, coeffs, uv); + } + } +}; + +// Build one for image `bid`. `source_models` / `source_params` are null on the +// ordinary path. +template +__device__ __forceinline__ RayToPixel make_ray_to_pixel( + long bid, + CameraModelType camera_model, + const float4* __restrict__ intrins, + const CameraDistortionCoeffsBuffer& dist_coeffs_buffer, + const int* __restrict__ source_models, + const float* __restrict__ source_params +) { + RayToPixel m; + m.camera_model = camera_model; + if constexpr (kFromSource) { + m.source_model = source_models[bid]; + m.source_params = source_params + 16 * bid; + } else { + m.intrin = intrins[bid]; + m.coeffs = dist_coeffs_buffer.load(bid); + } + return m; +} + +// _SS_DISPATCH_DISTORTION with the source axis folded in; BODY takes +// (tier, from_source). Defined here rather than in PixelWiseCommon.cuh so a TU +// that never re-distorts does not see it. +#define _SS_DISPATCH_SOURCE_CASE(BODY, TIER, HAS) \ + case CameraDistortionType::TIER: \ + /* braced: BODY is itself an if/else in the depth and normal warps */ \ + if (HAS) { BODY(CameraDistortionType::TIER, true); } \ + else { BODY(CameraDistortionType::TIER, false); } \ + break; + +#define _SS_DISPATCH_SOURCE(name, has_source, BODY) \ + do { const bool _ss_has = (has_source); \ + switch (cdt(name)) { \ + _SS_DISPATCH_SOURCE_CASE(BODY, None, _ss_has) \ + _SS_DISPATCH_SOURCE_CASE(BODY, OpenCV, _ss_has) \ + _SS_DISPATCH_SOURCE_CASE(BODY, ThinPrism, _ss_has) \ + _SS_DISPATCH_SOURCE_CASE(BODY, Rational, _ss_has) \ + default: throw std::runtime_error( \ + "Unknown camera distortion: " + std::string(name)); \ + } } while (0) + +#endif // __CUDACC__ diff --git a/src/kernels/projection/CameraVariants.cuh b/src/kernels/projection/CameraVariants.cuh new file mode 100644 index 00000000..c7ac89a5 --- /dev/null +++ b/src/kernels/projection/CameraVariants.cuh @@ -0,0 +1,22 @@ +#pragma once + +// The (camera model, distortion tier) pairs the CUDA kernels are instantiated +// for, as an X-macro so every launcher's dispatch chain stays in step. Must +// match camera_distortion_is_compiled() in core/CameraModel.h, kCameraVariants +// in tools/codegen/generate_kernel_instantiation.py and the export list in +// shaders/primitive_3dgs.slang. +// +// F takes the unqualified enumerator names, e.g. +// #define _DISPATCH(M, D) if (m == CameraModelType::M && d == CameraDistortionType::D) ... +#define SS_FOR_EACH_CAMERA_VARIANT(F) \ + F(PINHOLE, None) \ + F(PINHOLE, OpenCV) \ + F(PINHOLE, ThinPrism) \ + F(PINHOLE, Rational) \ + F(FISHEYE, None) \ + F(FISHEYE, OpenCV) \ + F(FISHEYE, ThinPrism) \ + F(EQUISOLID, None) \ + F(EQUISOLID, OpenCV) \ + F(EQUISOLID, ThinPrism) \ + F(EQUIRECTANGULAR, None) diff --git a/src/kernels/projection/ProjectionBwd.cu b/src/kernels/projection/ProjectionBwd.cu index 181dca68..b2c51f9e 100644 --- a/src/kernels/projection/ProjectionBwd.cu +++ b/src/kernels/projection/ProjectionBwd.cu @@ -1,5 +1,7 @@ #include "kernels/projection/ProjectionBwd.cuh" +#include "kernels/projection/CameraVariants.cuh" + #include #include @@ -9,7 +11,8 @@ namespace cg = cooperative_groups; template< typename SplatPrimitive, - CameraModelType camera_model + CameraModelType camera_model, + CameraDistortionType distortion > void projection_fused_bwd_kernel_wrapper( cudaStream_t stream, @@ -51,6 +54,7 @@ inline void launch_projection_projection_fused_bwd_kernel( const uint32_t image_width, const uint32_t image_height, const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, // fwd outputs const DeviceVector camera_ids, // [nnz] or null @@ -106,16 +110,13 @@ inline void launch_projection_projection_fused_bwd_kernel( sh_bounds_stride \ ) - if (camera_model == CameraModelType::PINHOLE) - projection_fused_bwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::FISHEYE) - projection_fused_bwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUISOLID) - projection_fused_bwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUIRECTANGULAR) - projection_fused_bwd_kernel_wrapper _LAUNCH_ARGS; - else - throw std::runtime_error("Unsupported camera model"); + #define _DISPATCH(M, D) \ + if (camera_model == CameraModelType::M && distortion == CameraDistortionType::D) \ + projection_fused_bwd_kernel_wrapper _LAUNCH_ARGS; else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("Unsupported camera model / distortion tier"); + #undef _DISPATCH CHECK_DEVICE_ERROR(cudaGetLastError()); #undef _LAUNCH_ARGS @@ -140,6 +141,7 @@ void projection_3dgs_backward( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, // fwd outputs const DeviceVector camera_ids, // [nnz] or null @@ -166,7 +168,7 @@ void projection_3dgs_backward( ? (const float2*)std::get<0>(sh_value_bounds.value()) : nullptr; #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_projection_fused_bwd_kernel>( \ - num_splats, splats_world, viewmats, intrins, image_width, image_height, cmt(camera_model), dist_coeffs, \ + num_splats, splats_world, viewmats, intrins, image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, \ camera_ids, gaussian_ids, aabb, v_splats_screen, \ v_splats_world, v_viewmats, \ vp, vb, num_sh_buffer, sh_value_bits, sh_bounds_stride); @@ -190,6 +192,7 @@ void projection_mip_backward( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, // fwd outputs const DeviceVector camera_ids, // [nnz] or null @@ -216,7 +219,7 @@ void projection_mip_backward( ? (const float2*)std::get<0>(sh_value_bounds.value()) : nullptr; #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_projection_fused_bwd_kernel>( \ - num_splats, splats_world, viewmats, intrins, image_width, image_height, cmt(camera_model), dist_coeffs, \ + num_splats, splats_world, viewmats, intrins, image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, \ camera_ids, gaussian_ids, aabb, v_splats_screen, \ v_splats_world, v_viewmats, \ vp, vb, num_sh_buffer, sh_value_bits, sh_bounds_stride); @@ -241,6 +244,7 @@ void projection_3dgut_backward( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, // fwd outputs const DeviceVector camera_ids, // [nnz] or null @@ -267,7 +271,7 @@ void projection_3dgut_backward( ? (const float2*)std::get<0>(sh_value_bounds.value()) : nullptr; #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_projection_fused_bwd_kernel>( \ - num_splats, splats_world, viewmats, intrins, image_width, image_height, cmt(camera_model), dist_coeffs, \ + num_splats, splats_world, viewmats, intrins, image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, \ camera_ids, gaussian_ids, aabb, v_splats_screen, \ v_splats_world, v_viewmats, \ vp, vb, num_sh_buffer, sh_value_bits, sh_bounds_stride); diff --git a/src/kernels/projection/ProjectionBwd.cuh b/src/kernels/projection/ProjectionBwd.cuh index d74541fa..0c5e6464 100644 --- a/src/kernels/projection/ProjectionBwd.cuh +++ b/src/kernels/projection/ProjectionBwd.cuh @@ -25,6 +25,7 @@ void projection_3dgs_backward( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, // fwd outputs const DeviceVector camera_ids, // [nnz] or null @@ -55,6 +56,7 @@ void projection_mip_backward( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, // fwd outputs const DeviceVector camera_ids, // [nnz] or null @@ -85,6 +87,7 @@ void projection_3dgut_backward( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, // fwd outputs const DeviceVector camera_ids, // [nnz] or null diff --git a/src/kernels/projection/ProjectionBwdQuantGrad.cu b/src/kernels/projection/ProjectionBwdQuantGrad.cu index 1c086e8f..01c94ed4 100644 --- a/src/kernels/projection/ProjectionBwdQuantGrad.cu +++ b/src/kernels/projection/ProjectionBwdQuantGrad.cu @@ -1,5 +1,7 @@ #include "kernels/projection/ProjectionBwdQuantGrad.cuh" +#include "kernels/projection/CameraVariants.cuh" + #include #include @@ -12,11 +14,13 @@ namespace cg = cooperative_groups; #include -// Thin per-(primitive, camera_model) launcher, defined by the codegen'd -// instantiations in ins/*.cu (extern here). Dispatches VALUE_BITS internally. +// Thin per-(primitive, camera model, distortion tier) launcher, defined by the +// codegen'd instantiations in ins/*.cu (extern here). Dispatches VALUE_BITS +// internally. template< typename SplatPrimitive, - CameraModelType camera_model + CameraModelType camera_model, + CameraDistortionType distortion > void projection_bwd_quantgrad_kernel_wrapper( cudaStream_t stream, @@ -74,6 +78,7 @@ static inline void launch_projection_bwd_quantgrad( const uint32_t image_width, const uint32_t image_height, const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -141,16 +146,13 @@ static inline void launch_projection_bwd_quantgrad( v_splats_world, v_splats_screen, gq, \ sh_value_packed, sh_value_bounds, sh_value_bounds_stride, sh_value_bits ) - if (camera_model == CameraModelType::PINHOLE) - projection_bwd_quantgrad_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::FISHEYE) - projection_bwd_quantgrad_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUISOLID) - projection_bwd_quantgrad_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUIRECTANGULAR) - projection_bwd_quantgrad_kernel_wrapper _LAUNCH_ARGS; - else - throw std::runtime_error("Unsupported camera model"); + #define _DISPATCH(M, D) \ + if (camera_model == CameraModelType::M && distortion == CameraDistortionType::D) \ + projection_bwd_quantgrad_kernel_wrapper _LAUNCH_ARGS; else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("Unsupported camera model / distortion tier"); + #undef _DISPATCH CHECK_DEVICE_ERROR(cudaGetLastError()); #undef _LAUNCH_ARGS } @@ -168,6 +170,7 @@ static inline void _projection_bwd_quantgrad_dispatch( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -188,7 +191,7 @@ static inline void _projection_bwd_quantgrad_dispatch( #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_bwd_quantgrad>( \ num_splats, num_sh_buffer, splats_world, viewmats, intrins, \ - image_width, image_height, cmt(camera_model), dist_coeffs, \ + image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, \ camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, \ gq, vp, vb, sh_value_bounds_stride, sh_value_bits); LAUNCH(3) LAUNCH(2) LAUNCH(1) LAUNCH(0) LAUNCH(4) @@ -206,6 +209,7 @@ void projection_3dgs_backward_quantgrad( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -221,7 +225,7 @@ void projection_3dgs_backward_quantgrad( ) { _projection_bwd_quantgrad_dispatch( num_splats, max_sh_degree, splats_world, viewmats, intrins, - image_width, image_height, camera_model, dist_coeffs, + image_width, image_height, camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, gq, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_value_bounds_stride); } @@ -237,6 +241,7 @@ void projection_mip_backward_quantgrad( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -252,7 +257,7 @@ void projection_mip_backward_quantgrad( ) { _projection_bwd_quantgrad_dispatch( num_splats, max_sh_degree, splats_world, viewmats, intrins, - image_width, image_height, camera_model, dist_coeffs, + image_width, image_height, camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, gq, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_value_bounds_stride); } @@ -268,6 +273,7 @@ void projection_3dgut_backward_quantgrad( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -283,7 +289,7 @@ void projection_3dgut_backward_quantgrad( ) { _projection_bwd_quantgrad_dispatch( num_splats, max_sh_degree, splats_world, viewmats, intrins, - image_width, image_height, camera_model, dist_coeffs, + image_width, image_height, camera_model, distortion, dist_coeffs, camera_ids, gaussian_ids, aabb, v_splats_screen, v_splats_world, gq, sh_value_packed, sh_value_bounds, num_sh_buffer, sh_value_bits, sh_value_bounds_stride); } diff --git a/src/kernels/projection/ProjectionBwdQuantGrad.cuh b/src/kernels/projection/ProjectionBwdQuantGrad.cuh index 2c9bd0d4..877d63a5 100644 --- a/src/kernels/projection/ProjectionBwdQuantGrad.cuh +++ b/src/kernels/projection/ProjectionBwdQuantGrad.cuh @@ -40,6 +40,7 @@ void projection_3dgs_backward_quantgrad( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -64,6 +65,7 @@ void projection_mip_backward_quantgrad( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, @@ -88,6 +90,7 @@ void projection_3dgut_backward_quantgrad( const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, const DeviceVector camera_ids, const DeviceVector gaussian_ids, diff --git a/src/kernels/projection/ProjectionBwdQuantGrad_kernel.cuh b/src/kernels/projection/ProjectionBwdQuantGrad_kernel.cuh index 0fbb972e..8fb7214f 100644 --- a/src/kernels/projection/ProjectionBwdQuantGrad_kernel.cuh +++ b/src/kernels/projection/ProjectionBwdQuantGrad_kernel.cuh @@ -45,6 +45,7 @@ namespace cg = cooperative_groups; template< typename SplatPrimitive, CameraModelType camera_model, + CameraDistortionType distortion, int VALUE_BITS = 32, int BLOCK_SIZE = 256 > @@ -117,24 +118,24 @@ __global__ void __launch_bounds__(BLOCK_SIZE) projection_bwd_quantgrad_kernel( viewmats[cid*16+8], viewmats[cid*16+9], viewmats[cid*16+10], }; float3 t = { viewmats[cid*16+3], viewmats[cid*16+7], viewmats[cid*16+11] }; - ProjCamera cam = { + ProjCameraT cam = { R, t, intrin.x, intrin.y, intrin.z, intrin.w, image_width, image_height, }; - cam.dist_coeffs = dist_coeffs_buffer.load(cid); + cam.dist_coeffs = dist_coeffs_buffer.load(cid); typename SplatPrimitive::Screen v_screen; v_screen.load(v_splats_screen, idx); if constexpr (VALUE_BITS == 32) { - splat_world.template project_vjp( + splat_world.template project_vjp( cam, v_screen, v, v_R, v_t); } else { const int64_t sh_base_vjp = (int64_t)3 * (int64_t)num_sh_buffer * (int64_t)gid; const int64_t sh_stride_vjp = (sh_value_bounds_stride > 0) ? sh_value_bounds_stride : (int64_t)256 * 3 * (int64_t)num_sh_buffer; - splat_world.template project_vjp( + splat_world.template project_vjp( cam, v_screen, v, v_R, v_t, const_cast(sh_value_packed), const_cast(sh_value_bounds), @@ -209,11 +210,13 @@ __global__ void __launch_bounds__(BLOCK_SIZE) projection_bwd_quantgrad_kernel( } -// Thin per-(primitive, camera_model) launcher; dispatches VALUE_BITS at runtime -// (mirrors projection_fused_bwd_kernel_wrapper in ProjectionBwd_kernel.cuh). +// Thin per-(primitive, camera model, distortion tier) launcher; dispatches +// VALUE_BITS at runtime (mirrors projection_fused_bwd_kernel_wrapper in +// ProjectionBwd_kernel.cuh). template< typename SplatPrimitive, - CameraModelType camera_model + CameraModelType camera_model, + CameraDistortionType distortion > void projection_bwd_quantgrad_kernel_wrapper( cudaStream_t stream, @@ -242,7 +245,8 @@ void projection_bwd_quantgrad_kernel_wrapper( const uint32_t grid = (N + BLOCK - 1) / BLOCK; if (grid == 0) return; #define _QG_LAUNCH(VB) \ - projection_bwd_quantgrad_kernel \ + projection_bwd_quantgrad_kernel \ <<>>( \ C, N, num_sh_buffer, splats_world, viewmats, intrins, \ dist_coeffs_buffer, image_width, image_height, \ diff --git a/src/kernels/projection/ProjectionBwd_kernel.cuh b/src/kernels/projection/ProjectionBwd_kernel.cuh index 861f3036..75fe26e5 100644 --- a/src/kernels/projection/ProjectionBwd_kernel.cuh +++ b/src/kernels/projection/ProjectionBwd_kernel.cuh @@ -16,6 +16,7 @@ namespace cg = cooperative_groups; template< typename SplatPrimitive, CameraModelType camera_model, + CameraDistortionType distortion, int VALUE_BITS = 32 > __global__ void projection_fused_bwd_kernel( @@ -71,11 +72,11 @@ __global__ void projection_fused_bwd_kernel( }; float3 t = { viewmats[3], viewmats[7], viewmats[11] }; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - ProjCamera cam = { + ProjCameraT cam = { R, t, fx, fy, cx, cy, image_width, image_height, }; - cam.dist_coeffs = dist_coeffs_buffer.load(cid); + cam.dist_coeffs = dist_coeffs_buffer.load(cid); // Load splat typename SplatPrimitive::World splat_world; @@ -88,14 +89,14 @@ __global__ void projection_fused_bwd_kernel( float3x3 v_R = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; float3 v_t = {0.f, 0.f, 0.f}; if constexpr (VALUE_BITS == 32) { - splat_world.template project_vjp( + splat_world.template project_vjp( cam, v_splat_screen, v_splat_world, v_R, v_t); } else { const int64_t sh_base = (int64_t)3 * (int64_t)num_sh_buffer * gid; const int64_t stride = (sh_bounds_stride > 0) ? sh_bounds_stride : (int64_t)256 * 3 * (int64_t)num_sh_buffer; - splat_world.template project_vjp( + splat_world.template project_vjp( cam, v_splat_screen, v_splat_world, v_R, v_t, const_cast(sh_value_packed), const_cast(sh_value_bounds), @@ -130,7 +131,8 @@ __global__ void projection_fused_bwd_kernel( template< typename SplatPrimitive, - CameraModelType camera_model + CameraModelType camera_model, + CameraDistortionType distortion > void projection_fused_bwd_kernel_wrapper( cudaStream_t stream, @@ -162,7 +164,7 @@ void projection_fused_bwd_kernel_wrapper( ) { constexpr uint block = 128; #define _LAUNCH(VB) \ - projection_fused_bwd_kernel \ + projection_fused_bwd_kernel \ <<<_CEIL_DIV(C*N, block), block, 0, stream>>>( \ C, N, \ splats_world, viewmats, intrins, dist_coeffs_buffer, \ diff --git a/src/kernels/projection/ProjectionFwd.cu b/src/kernels/projection/ProjectionFwd.cu index e206c1d4..6eec6b74 100644 --- a/src/kernels/projection/ProjectionFwd.cu +++ b/src/kernels/projection/ProjectionFwd.cu @@ -1,12 +1,15 @@ #include "kernels/projection/ProjectionFwd.cuh" +#include "kernels/projection/CameraVariants.cuh" + #include #include namespace cg = cooperative_groups; -template +template void projection_fused_fwd_kernel_wrapper( cudaStream_t stream, const uint32_t C, @@ -48,6 +51,7 @@ inline std::tuple< const uint32_t image_width, const uint32_t image_height, const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, DeviceVector radii, // SH VALUE-quant: packed bytes + per-cell-block bounds. When sh_value_bits @@ -77,16 +81,13 @@ inline std::tuple< sh_bounds_stride \ ) - if (camera_model == CameraModelType::PINHOLE) - projection_fused_fwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::FISHEYE) - projection_fused_fwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUISOLID) - projection_fused_fwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUIRECTANGULAR) - projection_fused_fwd_kernel_wrapper _LAUNCH_ARGS; - else - throw std::runtime_error("Unsupported camera model"); + #define _DISPATCH(M, D) \ + if (camera_model == CameraModelType::M && distortion == CameraDistortionType::D) \ + projection_fused_fwd_kernel_wrapper _LAUNCH_ARGS; else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("Unsupported camera model / distortion tier"); + #undef _DISPATCH CHECK_DEVICE_ERROR(cudaGetLastError()); #undef _LAUNCH_ARGS @@ -107,7 +108,8 @@ std::tuple< const std::vector &in_splats, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string camera_model, const TorchTensorView dist_coeffs, + const std::string camera_model, const std::string distortion, + const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, const std::optional sh_value_bounds, @@ -129,7 +131,7 @@ std::tuple< ? (const float2*)std::get<0>(sh_value_bounds.value()) : nullptr; #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_fused_fwd_kernel>( \ - num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), dist_coeffs, radii, \ + num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, radii, \ vp, vb, num_sh_buffer, sh_value_bits, sh_bounds_stride); LAUNCH(3) LAUNCH(2) LAUNCH(1) LAUNCH(0) LAUNCH(4) #undef LAUNCH @@ -149,7 +151,8 @@ std::tuple< const std::vector &in_splats, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string camera_model, const TorchTensorView dist_coeffs, + const std::string camera_model, const std::string distortion, + const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, const std::optional sh_value_bounds, @@ -171,7 +174,7 @@ std::tuple< ? (const float2*)std::get<0>(sh_value_bounds.value()) : nullptr; #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_fused_fwd_kernel>( \ - num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), dist_coeffs, radii, \ + num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, radii, \ vp, vb, num_sh_buffer, sh_value_bits, sh_bounds_stride); LAUNCH(3) LAUNCH(2) LAUNCH(1) LAUNCH(0) LAUNCH(4) #undef LAUNCH @@ -192,7 +195,8 @@ std::tuple< const std::vector &in_splats, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string camera_model, const TorchTensorView dist_coeffs, + const std::string camera_model, const std::string distortion, + const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, const std::optional sh_value_bounds, @@ -214,7 +218,7 @@ std::tuple< ? (const float2*)std::get<0>(sh_value_bounds.value()) : nullptr; #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_fused_fwd_kernel>( \ - num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), dist_coeffs, radii, \ + num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, radii, \ vp, vb, num_sh_buffer, sh_value_bits, sh_bounds_stride); LAUNCH(3) LAUNCH(2) LAUNCH(1) LAUNCH(0) LAUNCH(4) #undef LAUNCH diff --git a/src/kernels/projection/ProjectionFwd.cuh b/src/kernels/projection/ProjectionFwd.cuh index 2ce9c529..3515acac 100644 --- a/src/kernels/projection/ProjectionFwd.cuh +++ b/src/kernels/projection/ProjectionFwd.cuh @@ -22,7 +22,8 @@ std::tuple< const std::vector &in_splats, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string camera_model, const TorchTensorView dist_coeffs, + const std::string camera_model, const std::string distortion, + const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, const std::optional sh_value_bounds, @@ -42,7 +43,8 @@ std::tuple< const std::vector &in_splats, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string camera_model, const TorchTensorView dist_coeffs, + const std::string camera_model, const std::string distortion, + const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, const std::optional sh_value_bounds, @@ -62,7 +64,8 @@ std::tuple< const std::vector &in_splats, TorchTensorView viewmats, TorchTensorView intrins, const uint32_t image_width, const uint32_t image_height, - const std::string camera_model, const TorchTensorView dist_coeffs, + const std::string camera_model, const std::string distortion, + const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, const std::optional sh_value_bounds, diff --git a/src/kernels/projection/ProjectionFwd_kernel.cuh b/src/kernels/projection/ProjectionFwd_kernel.cuh index a44775c3..ab42ff76 100644 --- a/src/kernels/projection/ProjectionFwd_kernel.cuh +++ b/src/kernels/projection/ProjectionFwd_kernel.cuh @@ -12,7 +12,8 @@ namespace cg = cooperative_groups; -template +template __global__ void projection_fused_fwd_kernel( const uint32_t C, const uint32_t N, @@ -57,11 +58,11 @@ __global__ void projection_fused_fwd_kernel( }; float3 t = { viewmats[3], viewmats[7], viewmats[11] }; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - ProjCamera cam = { + ProjCameraT cam = { R, t, fx, fy, cx, cy, image_width, image_height, }; - cam.dist_coeffs = dist_coeffs_buffer.load(cid); + cam.dist_coeffs = dist_coeffs_buffer.load(cid); // Load splat typename SplatPrimitive::World splat_world; @@ -79,14 +80,14 @@ __global__ void projection_fused_fwd_kernel( float radius = 0.0f; typename SplatPrimitive::Screen splat_screen; if constexpr (VALUE_BITS == 32) { - splat_world.template project( + splat_world.template project( cam, splat_screen, aabb, sorting_depth, radius); } else { const int64_t sh_base = (int64_t)3 * (int64_t)num_sh_buffer * gid; const int64_t stride = (sh_bounds_stride > 0) ? sh_bounds_stride : (int64_t)256 * 3 * (int64_t)num_sh_buffer; - splat_world.template project( + splat_world.template project( cam, splat_screen, aabb, sorting_depth, radius, const_cast(sh_value_packed), const_cast(sh_value_bounds), @@ -110,7 +111,8 @@ __global__ void projection_fused_fwd_kernel( } -template +template void projection_fused_fwd_kernel_wrapper( cudaStream_t stream, const uint32_t C, @@ -138,7 +140,7 @@ void projection_fused_fwd_kernel_wrapper( ) { constexpr uint block = 128; #define _LAUNCH(VB) \ - projection_fused_fwd_kernel \ + projection_fused_fwd_kernel \ <<<_CEIL_DIV(C*N, block), block, 0, stream>>>( \ C, N, \ splats_world, viewmats, intrins, dist_coeffs_buffer, \ diff --git a/src/kernels/projection/ProjectionPackedFwd.cu b/src/kernels/projection/ProjectionPackedFwd.cu index 1ee6efd6..7252dbca 100644 --- a/src/kernels/projection/ProjectionPackedFwd.cu +++ b/src/kernels/projection/ProjectionPackedFwd.cu @@ -1,5 +1,7 @@ #include "kernels/projection/ProjectionPackedFwd.cuh" +#include "kernels/projection/CameraVariants.cuh" + #include #include @@ -10,7 +12,8 @@ namespace cg = cooperative_groups; #include -template +template void projection_packed_mask_kernel_wrapper( cudaStream_t stream, const uint32_t C, @@ -30,7 +33,8 @@ void projection_packed_mask_kernel_wrapper( const int64_t sh_bounds_stride ); -template +template void projection_packed_fwd_kernel_wrapper( cudaStream_t stream, const uint32_t C, @@ -73,6 +77,7 @@ inline std::tuple< const uint32_t image_width, const uint32_t image_height, const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, DeviceVector radii, const uint8_t* sh_value_packed, @@ -97,16 +102,13 @@ inline std::tuple< sh_bounds_stride \ ) - if (camera_model == CameraModelType::PINHOLE) - projection_packed_mask_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::FISHEYE) - projection_packed_mask_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUISOLID) - projection_packed_mask_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUIRECTANGULAR) - projection_packed_mask_kernel_wrapper _LAUNCH_ARGS; - else - throw std::runtime_error("Unsupported camera model"); + #define _DISPATCH(M, D) \ + if (camera_model == CameraModelType::M && distortion == CameraDistortionType::D) \ + projection_packed_mask_kernel_wrapper _LAUNCH_ARGS; else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("Unsupported camera model / distortion tier"); + #undef _DISPATCH CHECK_DEVICE_ERROR(cudaGetLastError()); #undef _LAUNCH_ARGS @@ -141,16 +143,13 @@ inline std::tuple< sh_bounds_stride \ ) - if (camera_model == CameraModelType::PINHOLE) - projection_packed_fwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::FISHEYE) - projection_packed_fwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUISOLID) - projection_packed_fwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUIRECTANGULAR) - projection_packed_fwd_kernel_wrapper _LAUNCH_ARGS; - else - throw std::runtime_error("Unsupported camera model"); + #define _DISPATCH(M, D) \ + if (camera_model == CameraModelType::M && distortion == CameraDistortionType::D) \ + projection_packed_fwd_kernel_wrapper _LAUNCH_ARGS; else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("Unsupported camera model / distortion tier"); + #undef _DISPATCH CHECK_DEVICE_ERROR(cudaGetLastError()); #undef _LAUNCH_ARGS @@ -176,6 +175,7 @@ std::tuple< const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, @@ -195,7 +195,7 @@ std::tuple< ? (const float2*)std::get<0>(sh_value_bounds.value()) : nullptr; #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_packed_fwd_kernel>( \ - num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), dist_coeffs, radii, \ + num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, radii, \ vp, vb, num_sh_buffer, sh_value_bits, sh_bounds_stride); LAUNCH(3) LAUNCH(2) LAUNCH(1) LAUNCH(0) LAUNCH(4) #undef LAUNCH @@ -220,6 +220,7 @@ std::tuple< const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, @@ -239,7 +240,7 @@ std::tuple< ? (const float2*)std::get<0>(sh_value_bounds.value()) : nullptr; #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_packed_fwd_kernel>( \ - num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), dist_coeffs, radii, \ + num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, radii, \ vp, vb, num_sh_buffer, sh_value_bits, sh_bounds_stride); LAUNCH(3) LAUNCH(2) LAUNCH(1) LAUNCH(0) LAUNCH(4) #undef LAUNCH @@ -265,6 +266,7 @@ std::tuple< const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, @@ -284,7 +286,7 @@ std::tuple< ? (const float2*)std::get<0>(sh_value_bounds.value()) : nullptr; #define LAUNCH(n) if (sh_degree == (n)) \ return launch_projection_packed_fwd_kernel>( \ - num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), dist_coeffs, radii, \ + num_splats, in_splats, vm, intr, C, image_width, image_height, cmt(camera_model), cdt(distortion), dist_coeffs, radii, \ vp, vb, num_sh_buffer, sh_value_bits, sh_bounds_stride); LAUNCH(3) LAUNCH(2) LAUNCH(1) LAUNCH(0) LAUNCH(4) #undef LAUNCH diff --git a/src/kernels/projection/ProjectionPackedFwd.cuh b/src/kernels/projection/ProjectionPackedFwd.cuh index 4d890b8e..792c6a37 100644 --- a/src/kernels/projection/ProjectionPackedFwd.cuh +++ b/src/kernels/projection/ProjectionPackedFwd.cuh @@ -27,6 +27,7 @@ std::tuple< const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, @@ -49,6 +50,7 @@ std::tuple< const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, @@ -71,6 +73,7 @@ std::tuple< const uint32_t image_width, const uint32_t image_height, const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceVector radii, const std::optional sh_value_packed, diff --git a/src/kernels/projection/ProjectionPackedFwd_kernel.cuh b/src/kernels/projection/ProjectionPackedFwd_kernel.cuh index 44b88d9e..3339a4a0 100644 --- a/src/kernels/projection/ProjectionPackedFwd_kernel.cuh +++ b/src/kernels/projection/ProjectionPackedFwd_kernel.cuh @@ -13,7 +13,8 @@ namespace cg = cooperative_groups; -template +template __global__ void projection_packed_mask_kernel( const uint32_t C, const uint32_t N, @@ -51,11 +52,11 @@ __global__ void projection_packed_mask_kernel( }; float3 t = { viewmats[3], viewmats[7], viewmats[11] }; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - ProjCamera cam = { + ProjCameraT cam = { R, t, fx, fy, cx, cy, image_width, image_height, }; - cam.dist_coeffs = dist_coeffs_buffer.load(cid); + cam.dist_coeffs = dist_coeffs_buffer.load(cid); // Load splat // TODO: verify that SH is not loaded after compiler optimization @@ -68,14 +69,14 @@ __global__ void projection_packed_mask_kernel( float radius; typename SplatPrimitive::Screen splat_screen; if constexpr (VALUE_BITS == 32) { - splat_world.template project( + splat_world.template project( cam, splat_screen, aabb, sorting_depth, radius); } else { const int64_t sh_base = (int64_t)3 * (int64_t)num_sh_buffer * gid; const int64_t stride = (sh_bounds_stride > 0) ? sh_bounds_stride : (int64_t)256 * 3 * (int64_t)num_sh_buffer; - splat_world.template project( + splat_world.template project( cam, splat_screen, aabb, sorting_depth, radius, const_cast(sh_value_packed), const_cast(sh_value_bounds), @@ -91,7 +92,8 @@ __global__ void projection_packed_mask_kernel( } -template +template __global__ void projection_packed_fwd_kernel( const uint32_t C, const uint32_t N, @@ -138,12 +140,11 @@ __global__ void projection_packed_fwd_kernel( }; float3 t = { viewmats[3], viewmats[7], viewmats[11] }; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - ProjCamera cam = { + ProjCameraT cam = { R, t, fx, fy, cx, cy, image_width, image_height, - }; - cam.dist_coeffs = dist_coeffs_buffer.load(cid); + cam.dist_coeffs = dist_coeffs_buffer.load(cid); // Load splat typename SplatPrimitive::World splat_world; @@ -155,14 +156,14 @@ __global__ void projection_packed_fwd_kernel( float radius = 0.0f; typename SplatPrimitive::Screen splat_screen; if constexpr (VALUE_BITS == 32) { - splat_world.template project( + splat_world.template project( cam, splat_screen, aabb, sorting_depth, radius); } else { const int64_t sh_base = (int64_t)3 * (int64_t)num_sh_buffer * gid; const int64_t stride = (sh_bounds_stride > 0) ? sh_bounds_stride : (int64_t)256 * 3 * (int64_t)num_sh_buffer; - splat_world.template project( + splat_world.template project( cam, splat_screen, aabb, sorting_depth, radius, const_cast(sh_value_packed), const_cast(sh_value_bounds), @@ -183,7 +184,8 @@ __global__ void projection_packed_fwd_kernel( } -template +template void projection_packed_mask_kernel_wrapper( cudaStream_t stream, const uint32_t C, @@ -204,7 +206,7 @@ void projection_packed_mask_kernel_wrapper( ) { constexpr uint block = 128; #define _LAUNCH(VB) \ - projection_packed_mask_kernel \ + projection_packed_mask_kernel \ <<<_CEIL_DIV(C*N, block), block, 0, stream>>>( \ C, N, \ splats_world, viewmats, intrins, dist_coeffs_buffer, \ @@ -217,7 +219,8 @@ void projection_packed_mask_kernel_wrapper( #undef _LAUNCH } -template +template void projection_packed_fwd_kernel_wrapper( cudaStream_t stream, const uint32_t C, @@ -244,7 +247,7 @@ void projection_packed_fwd_kernel_wrapper( ) { constexpr uint block = 128; #define _LAUNCH(VB) \ - projection_packed_fwd_kernel \ + projection_packed_fwd_kernel \ <<<_CEIL_DIV(C*N, block), block, 0, stream>>>( \ C, N, \ splats_world, viewmats, intrins, dist_coeffs_buffer, \ diff --git a/src/kernels/raster/RasterizationEval3DBwd.cu b/src/kernels/raster/RasterizationEval3DBwd.cu index b81a65fb..e3fb9f5d 100644 --- a/src/kernels/raster/RasterizationEval3DBwd.cu +++ b/src/kernels/raster/RasterizationEval3DBwd.cu @@ -1,5 +1,7 @@ #include "kernels/raster/RasterizationEval3DBwd.cuh" +#include "kernels/projection/CameraVariants.cuh" + #include @@ -7,6 +9,7 @@ template < typename SplatPrimitive, CameraModelType camera_model, + CameraDistortionType distortion, DistortionType dist_type, bool output_viewmat_grad, bool output_accum_weight, @@ -61,6 +64,7 @@ inline void launch_rasterize_to_pixels_eval3d_bwd_kernel( TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB, for sub-tile culling // image size @@ -123,40 +127,20 @@ inline void launch_rasterize_to_pixels_eval3d_bwd_kernel( v_viewmats.data_ptr() \ ) - if (camera_model == CameraModelType::PINHOLE) { - if (v_viewmats.data_ptr() != nullptr) - rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; - else - rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; - } - else if (camera_model == CameraModelType::FISHEYE) { - if (v_viewmats.data_ptr() != nullptr) - rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; - else - rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; - } - else if (camera_model == CameraModelType::EQUISOLID) { - if (v_viewmats.data_ptr() != nullptr) - rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; - else - rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; - } - else if (camera_model == CameraModelType::EQUIRECTANGULAR) { - if (v_viewmats.data_ptr() != nullptr) - rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; - else - rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; - } - else - throw std::runtime_error("Unsupported camera model"); + #define _DISPATCH(M, D) \ + if (camera_model == CameraModelType::M && distortion == CameraDistortionType::D) { \ + if (v_viewmats.data_ptr() != nullptr) \ + rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; \ + else \ + rasterize_to_pixels_eval3d_bwd_kernel_wrapper _LAUNCH_ARGS; \ + } else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("Unsupported camera model / distortion tier"); + #undef _DISPATCH CHECK_DEVICE_ERROR(cudaGetLastError()); #undef _LAUNCH_ARGS @@ -177,6 +161,7 @@ inline std::tuple< TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB, for sub-tile culling // image size @@ -236,7 +221,7 @@ inline std::tuple< launch_rasterize_to_pixels_eval3d_bwd_kernel( num_splats, splats_w, splats_s, gaussian_ids, - viewmats, intrins, camera_model, dist_coeffs, aabb, + viewmats, intrins, camera_model, distortion, dist_coeffs, aabb, image_width, image_height, tile_offsets, flatten_ids, render_Ts, last_ids, render_outputs, distortion_fwd_outputs, loss_map, accum_weight_map, @@ -269,6 +254,7 @@ inline std::tuple< TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB, for sub-tile culling // image size @@ -297,7 +283,7 @@ inline std::tuple< _rasterize_to_pixels_eval3d_bwd_tensor ( num_splats, splats_w, splats_s, gaussian_ids, - viewmats, intrins, camera_model, dist_coeffs, aabb, + viewmats, intrins, camera_model, distortion, dist_coeffs, aabb, image_width, image_height, tile_offsets, flatten_ids, render_Ts, last_ids, render_outputs, distortion_fwd_outputs, loss_map, accum_weight_map, v_render_outputs, v_render_Ts, v_median, v_distortion_outputs, v_splats_w, v_splats_s, @@ -325,6 +311,7 @@ std::tuple< TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB, for sub-tile culling // image size @@ -368,7 +355,7 @@ std::tuple< return funcs[di][accum_weight_map.data_ptr() != nullptr] [v_median.data_ptr() != nullptr]( num_splats, splats_w, splats_s, gaussian_ids, - viewmats, intrins, cmt(camera_model), dist_coeffs, aabb, + viewmats, intrins, cmt(camera_model), cdt(distortion), dist_coeffs, aabb, image_width, image_height, tile_offsets, flatten_ids, render_Ts, last_ids, render_outputs, distortion_fwd_outputs, loss_map, accum_weight_map, v_render_outputs, v_render_Ts, v_median, v_distortion_outputs, v_splats_w, v_splats_s, diff --git a/src/kernels/raster/RasterizationEval3DBwd.cuh b/src/kernels/raster/RasterizationEval3DBwd.cuh index 5210f54d..ebd4b0be 100644 --- a/src/kernels/raster/RasterizationEval3DBwd.cuh +++ b/src/kernels/raster/RasterizationEval3DBwd.cuh @@ -27,6 +27,7 @@ std::tuple< TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB, for sub-tile culling // image size diff --git a/src/kernels/raster/RasterizationEval3DBwd_kernel.cuh b/src/kernels/raster/RasterizationEval3DBwd_kernel.cuh index 8d4008a5..20e3c485 100644 --- a/src/kernels/raster/RasterizationEval3DBwd_kernel.cuh +++ b/src/kernels/raster/RasterizationEval3DBwd_kernel.cuh @@ -25,6 +25,8 @@ namespace SlangProjectionUtils { } #endif +#include "core/CameraDistortion.cuh" + #include @@ -47,6 +49,7 @@ template < typename SplatPrimitive, #if IS_EVAL3D CameraModelType camera_model, + CameraDistortionType distortion, #endif DistortionType dist_type, #if IS_EVAL3D @@ -123,7 +126,7 @@ __global__ void rasterize_to_pixels_bwd_kernel( }; float3 t = { viewmats[3], viewmats[7], viewmats[11] }; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(image_id); + CameraDistortionCoeffsT dist_coeffs = dist_coeffs_buffer.load(image_id); #endif constexpr uint BLOCK_SIZE = TILE_SIZE_DX * TILE_SIZE_DY; @@ -188,7 +191,7 @@ __global__ void rasterize_to_pixels_bwd_kernel( const float px = (float)pix_x + 0.5f; const float py = (float)pix_y + 0.5f; float3 raydir; - inside &= SlangProjectionUtils::generate_ray( + inside &= SlangDistortion::generate_ray( {(px-cx)/fx, (py-cy)/fy}, (int)camera_model, dist_coeffs, &raydir @@ -620,6 +623,7 @@ template < typename SplatPrimitive, #if IS_EVAL3D CameraModelType camera_model, + CameraDistortionType distortion, #endif DistortionType dist_type, #if IS_EVAL3D @@ -690,7 +694,7 @@ void rasterize_to_pixels_bwd_kernel_wrapper( #endif SplatPrimitive, #if IS_EVAL3D - camera_model, + camera_model, distortion, #endif dist_type, #if IS_EVAL3D diff --git a/src/kernels/raster/RasterizationEval3DFwd.cu b/src/kernels/raster/RasterizationEval3DFwd.cu index ed34746a..4ff44751 100644 --- a/src/kernels/raster/RasterizationEval3DFwd.cu +++ b/src/kernels/raster/RasterizationEval3DFwd.cu @@ -1,5 +1,7 @@ #include "kernels/raster/RasterizationEval3DFwd.cuh" +#include "kernels/projection/CameraVariants.cuh" + #include @@ -9,6 +11,7 @@ template< typename SplatPrimitive, CameraModelType camera_model, + CameraDistortionType distortion, DistortionType dist_type, bool output_median > @@ -48,6 +51,7 @@ inline void launch_rasterize_to_pixels_eval3d_fwd_kernel( TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB, for sub-tile culling // image size @@ -87,20 +91,14 @@ inline void launch_rasterize_to_pixels_eval3d_fwd_kernel( output_median ? render_median.data_ptr() : nullptr \ ) - if (camera_model == CameraModelType::PINHOLE) - rasterize_to_pixels_eval3d_fwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::FISHEYE) - rasterize_to_pixels_eval3d_fwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUISOLID) - rasterize_to_pixels_eval3d_fwd_kernel_wrapper _LAUNCH_ARGS; - else if (camera_model == CameraModelType::EQUIRECTANGULAR) - rasterize_to_pixels_eval3d_fwd_kernel_wrapper _LAUNCH_ARGS; - else - throw std::runtime_error("Unsupported camera model"); + #define _DISPATCH(M, D) \ + if (camera_model == CameraModelType::M && distortion == CameraDistortionType::D) \ + rasterize_to_pixels_eval3d_fwd_kernel_wrapper _LAUNCH_ARGS; else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("Unsupported camera model / distortion tier"); + #undef _DISPATCH CHECK_DEVICE_ERROR(cudaGetLastError()); #undef _LAUNCH_ARGS @@ -123,6 +121,7 @@ inline std::tuple< TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const CameraModelType camera_model, + const CameraDistortionType distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB, for sub-tile culling // image size @@ -153,7 +152,7 @@ inline std::tuple< launch_rasterize_to_pixels_eval3d_fwd_kernel( num_splats, splats_w, splats_s, gaussian_ids, - viewmats, intrins, camera_model, dist_coeffs, aabb, + viewmats, intrins, camera_model, distortion, dist_coeffs, aabb, image_width, image_height, tile_offsets, flatten_ids, renders, render_Ts, render_last_ids, distortions, render_median ); @@ -186,6 +185,7 @@ std::tuple< TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB, for sub-tile culling // image size @@ -212,7 +212,7 @@ std::tuple< return dispatch( num_splats, splats_w, splats_s, gaussian_ids, - viewmats, intrins, cmt(camera_model), dist_coeffs, aabb, + viewmats, intrins, cmt(camera_model), cdt(distortion), dist_coeffs, aabb, image_width, image_height, tile_offsets, flatten_ids ); diff --git a/src/kernels/raster/RasterizationEval3DFwd.cuh b/src/kernels/raster/RasterizationEval3DFwd.cuh index c2b86f00..ce5dc1b3 100644 --- a/src/kernels/raster/RasterizationEval3DFwd.cuh +++ b/src/kernels/raster/RasterizationEval3DFwd.cuh @@ -29,6 +29,7 @@ std::tuple< TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const std::string camera_model, + const std::string distortion, const TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB, for sub-tile culling // image size diff --git a/src/kernels/raster/RasterizationEval3DFwd_kernel.cuh b/src/kernels/raster/RasterizationEval3DFwd_kernel.cuh index 406b8c69..72488361 100644 --- a/src/kernels/raster/RasterizationEval3DFwd_kernel.cuh +++ b/src/kernels/raster/RasterizationEval3DFwd_kernel.cuh @@ -26,6 +26,8 @@ namespace SlangProjectionUtils { } #endif +#include "core/CameraDistortion.cuh" + #include #include "primitives/Primitive.cuh" @@ -47,6 +49,7 @@ template< typename SplatPrimitive, #if IS_EVAL3D CameraModelType camera_model, + CameraDistortionType distortion, #endif DistortionType dist_type, bool output_median @@ -106,7 +109,7 @@ __global__ void rasterize_to_pixels_fwd_kernel( }; float3 t = { viewmats[3], viewmats[7], viewmats[11] }; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(image_id); + CameraDistortionCoeffsT dist_coeffs = dist_coeffs_buffer.load(image_id); float3 ray_o = SlangProjectionUtils::transform_ray_o(R, t); #endif @@ -121,7 +124,7 @@ __global__ void rasterize_to_pixels_fwd_kernel( #if IS_EVAL3D float3 raydir; - inside &= SlangProjectionUtils::generate_ray( + inside &= SlangDistortion::generate_ray( {(px-cx)/fx, (py-cy)/fy}, (int)camera_model, dist_coeffs, &raydir @@ -313,6 +316,7 @@ template< typename SplatPrimitive, #if IS_EVAL3D CameraModelType camera_model, + CameraDistortionType distortion, #endif DistortionType dist_type, bool output_median @@ -359,7 +363,7 @@ void rasterize_to_pixels_fwd_kernel_wrapper( #endif SplatPrimitive, #if IS_EVAL3D - camera_model, + camera_model, distortion, #endif dist_type, output_median diff --git a/src/kernels/raster/RasterizationMomentsFwd.cu b/src/kernels/raster/RasterizationMomentsFwd.cu index 2de8b0ee..9ccaa83a 100644 --- a/src/kernels/raster/RasterizationMomentsFwd.cu +++ b/src/kernels/raster/RasterizationMomentsFwd.cu @@ -21,6 +21,9 @@ namespace SlangProjectionUtils { #include "generated/projection_utils.cuh" } +#include "core/CameraDistortion.cuh" +#include "kernels/projection/CameraVariants.cuh" + #include #include "primitives/Primitive.cuh" #include "primitives/Primitive3DGUT.cuh" @@ -34,7 +37,7 @@ inline constexpr uint32_t TILE_AREA_M = TILE_SIZE_X * TILE_SIZE_Y; // One CUDA block per micro-tile (one thread per pixel); binning is at the // macro-tile granularity. Mirrors rasterize_to_pixels_eval3d_fwd_kernel. -template +template __global__ void moments_fwd_kernel( const uint32_t I, const uint32_t N, // zero if packed @@ -77,7 +80,7 @@ __global__ void moments_fwd_kernel( }; float3 cam_t = { viewmats[3], viewmats[7], viewmats[11] }; float fx = intrin.x, fy = intrin.y, cx = intrin.z, cy = intrin.w; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(image_id); + CameraDistortionCoeffsT dist_coeffs = dist_coeffs_buffer.load(image_id); float3 ray_o = SlangProjectionUtils::transform_ray_o(R, cam_t); @@ -89,7 +92,7 @@ __global__ void moments_fwd_kernel( bool inside = (i < image_height && j < image_width); float3 raydir; - inside &= SlangProjectionUtils::generate_ray( + inside &= SlangDistortion::generate_ray( {(px - cx) / fx, (py - cy) / fy}, (int)camera_model, dist_coeffs, &raydir); float3 ray_d = SlangProjectionUtils::transform_ray_d(R, raydir); @@ -208,7 +211,7 @@ __global__ void moments_fwd_kernel( } } -template +template void launch_moments( uint32_t I, uint32_t N, uint32_t n_isects, const uint32_t* gaussian_ids, @@ -221,7 +224,7 @@ void launch_moments( ) { dim3 threads = { TILE_AREA_M, 1, 1 }; dim3 grid = { I, th * MACRO_TILE_SIZE_Y, tw * MACRO_TILE_SIZE_X }; - moments_fwd_kernel<<>>( + moments_fwd_kernel<<>>( I, N, n_isects, gaussian_ids, wbuffer, sbuffer, viewmats, intrins, dist_buf, aabb, W, H, tw, th, tile_offsets, flatten_ids, @@ -239,6 +242,7 @@ void rasterize_moments_3dgut_fwd( TorchTensorView viewmats, TorchTensorView intrins, const std::string& camera_model, + const std::string& distortion, TorchTensorView dist_coeffs, DeviceTensor2D aabb, uint32_t image_width, @@ -264,6 +268,7 @@ void rasterize_moments_3dgut_fwd( const uint32_t* gids = (const uint32_t*)gaussian_ids.data_ptr(); CameraModelType cm = cmt(camera_model); + CameraDistortionType cd = cdt(distortion); #define _ARGS \ I, N, n_isects, gids, wbuffer, sbuffer, \ @@ -272,14 +277,12 @@ void rasterize_moments_3dgut_fwd( tile_offsets.data_ptr(), flatten_ids.data_ptr(), \ render_moments, render_rgb - if (cm == CameraModelType::PINHOLE) - launch_moments(_ARGS); - else if (cm == CameraModelType::FISHEYE) - launch_moments(_ARGS); - else if (cm == CameraModelType::EQUISOLID) - launch_moments(_ARGS); - else - throw std::runtime_error("rasterize_moments_3dgut_fwd: unsupported camera model"); + #define _DISPATCH(M, D) \ + if (cm == CameraModelType::M && cd == CameraDistortionType::D) \ + launch_moments(_ARGS); else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("rasterize_moments_3dgut_fwd: unsupported camera model / distortion tier"); + #undef _DISPATCH CHECK_DEVICE_ERROR(cudaGetLastError()); #undef _ARGS diff --git a/src/kernels/raster/RasterizationMomentsFwd.cuh b/src/kernels/raster/RasterizationMomentsFwd.cuh index 9a485e62..08d7e434 100644 --- a/src/kernels/raster/RasterizationMomentsFwd.cuh +++ b/src/kernels/raster/RasterizationMomentsFwd.cuh @@ -16,9 +16,9 @@ * where z_i is the Gaussian's ray depth (FragmentFwd::evaluate_color().depth). * The occupancy 1 - T(z) at depth z is then modeled as m0 * Phi((z-mean)/std). * - * Only 3DGUT (Vanilla3DGUT<0>) with the three supported camera models and no - * distortion output is instantiated -- all in this translation unit, so no - * generated ins/ entry is needed. + * Only 3DGUT (Vanilla3DGUT<0>) with no distortion output is instantiated, over + * the compiled (camera model, distortion tier) pairs -- all in this translation + * unit, so no generated ins/ entry is needed. */ #include @@ -37,6 +37,7 @@ void rasterize_moments_3dgut_fwd( TorchTensorView viewmats, // [..., C, 4, 4] TorchTensorView intrins, // [..., C, 4], fx, fy, cx, cy const std::string& camera_model, + const std::string& distortion, TorchTensorView dist_coeffs, DeviceTensor2D aabb, // [..., N] projected 2D AABB uint32_t image_width, diff --git a/src/kernels/tile/SplatTileIntersector.cu b/src/kernels/tile/SplatTileIntersector.cu index f4052dd8..72baace2 100644 --- a/src/kernels/tile/SplatTileIntersector.cu +++ b/src/kernels/tile/SplatTileIntersector.cu @@ -10,6 +10,9 @@ namespace SlangProjectionUtils { #include "generated/projection_utils.cuh" } +#include "core/CameraDistortion.cuh" +#include "kernels/projection/CameraVariants.cuh" + __device__ __forceinline__ float remapFunction(float x, float rel_scale) { @@ -59,13 +62,13 @@ __device__ bool getAABB( } -template +template struct Tile { float3 ro, rd; float3 n0, n1, n2, n3; __device__ bool init( - CameraDistortionCoeffs dist_coeffs, + CameraDistortionCoeffsT dist_coeffs, float x0, float x1, float y0, float y1, const float3 R0, const float3 R1, const float3 R2, // columns of R (world rotation) const float3 t // translation @@ -78,10 +81,11 @@ struct Tile { // TODO: better way to handle this in nonlinear and partially invalid case // May not matter in training with small tiles, but obvious artifact when rendering >180deg fisheye float3 e0_, e1_, e2_, e3_; - bool valid0 = SlangProjectionUtils::unproject_point({x0, y0}, (int)camera_model, dist_coeffs, &e0_); - bool valid1 = SlangProjectionUtils::unproject_point({x0, y1}, (int)camera_model, dist_coeffs, &e1_); - bool valid2 = SlangProjectionUtils::unproject_point({x1, y1}, (int)camera_model, dist_coeffs, &e2_); - bool valid3 = SlangProjectionUtils::unproject_point({x1, y0}, (int)camera_model, dist_coeffs, &e3_); + using Dist = SlangDistortion; + bool valid0 = Dist::unproject_point({x0, y0}, (int)camera_model, dist_coeffs, &e0_); + bool valid1 = Dist::unproject_point({x0, y1}, (int)camera_model, dist_coeffs, &e1_); + bool valid2 = Dist::unproject_point({x1, y1}, (int)camera_model, dist_coeffs, &e2_); + bool valid3 = Dist::unproject_point({x1, y0}, (int)camera_model, dist_coeffs, &e3_); if (!valid0 && valid3 && valid1 && valid2) e0_ = e3_ + e1_ - e2_, valid0 = true; if (!valid1 && valid0 && valid2 && valid3) @@ -139,9 +143,9 @@ struct Tile { }; -template -__device__ __forceinline__ Tile -loadTile(unsigned tileIdx, const TileBuffers buffers, bool& isActive) { +template +__device__ __forceinline__ Tile +loadTile(unsigned tileIdx, const TileBuffers buffers, bool& isActive) { // Row-major 4x4 view matrix: m[4*row + col]. Top-left 3x3 is the world rotation R, // right column is translation t. Columns of R are read across the row stride. const float* m = buffers.viewmats + 16 * tileIdx; @@ -156,9 +160,9 @@ loadTile(unsigned tileIdx, const TileBuffers buffers, bool& isActi float cx = intrin.z; float cy = intrin.w; - Tile res; + Tile res; isActive &= res.init( - buffers.dist_coeffs.load(tileIdx), + buffers.dist_coeffs.load(tileIdx), -cx / fx, (buffers.width - cx) / fx, -cy / fy, (buffers.height - cy) / fy, R0, R1, R2, t @@ -252,10 +256,10 @@ __global__ void fillTreeSubcells_initAABB( } -template +template __global__ void getTileSplatIntersections_brute( const long numSplats, - const TileBuffers tiles, + const TileBuffers tiles, const typename Primitive::WorldBuffer splatBuffer, uint32_t* __restrict__ intersect_counts, // to be filled or exclusive scan uint32_t* __restrict__ intersectionSplatID // nullptr or to be filled @@ -273,7 +277,7 @@ __global__ void getTileSplatIntersections_brute( uint32_t intersectCount = 0; bool isActive = true; - Tile tile = loadTile(tid, tiles, isActive); + Tile tile = loadTile(tid, tiles, isActive); if (!isActive) { if (isCountingPass) intersect_counts[tid] = 0; @@ -568,9 +572,9 @@ __global__ void computeLbvhAABB( } -template +template __global__ void getTileSplatIntersections_lbvh_warp( - const TileBuffers tiles, + const TileBuffers tiles, const typename Primitive::WorldBuffer splatBuffer, unsigned num_levels, const uint2* __restrict__ trees_ranges, @@ -593,7 +597,7 @@ __global__ void getTileSplatIntersections_lbvh_warp( } bool isActive = true; - Tile tile = loadTile(tileIdx, tiles, isActive); + Tile tile = loadTile(tileIdx, tiles, isActive); if (__ballot_sync(~0u, isActive) != ~0u) { if (isCountingPass) { if (laneIdx == 0) @@ -747,25 +751,25 @@ __forceinline__ DeviceVector exclusiveScan( -template -SplatTileIntersector::SplatTileIntersector( +template +SplatTileIntersector::SplatTileIntersector( const typename Primitive::WorldBuffer &splats, - const TileBuffers &tiles, + const TileBuffers &tiles, float rel_scale ) : tiles(tiles), splats(splats), rel_scale(rel_scale) { this->numSplats = splats.size(); } -template +template std::tuple, DeviceVector> -SplatTileIntersector::getIntersections_brute() { +SplatTileIntersector::getIntersections_brute() { constexpr unsigned warp = 32; DeviceVector intersection_count; intersection_count.resize(PoolSlot::StiBruteCount, tiles.size+1); intersection_count.zero(); - getTileSplatIntersections_brute<<<_LAUNCH_ARGS_1D(tiles.size, warp)>>>( + getTileSplatIntersections_brute<<<_LAUNCH_ARGS_1D(tiles.size, warp)>>>( numSplats, tiles, splats, (uint32_t*)intersection_count.data_ptr(), @@ -781,7 +785,7 @@ SplatTileIntersector::getIntersections_brute() { DeviceVector intersectionSplatID; intersectionSplatID.resize(PoolSlot::StiBruteIds, (int64_t)total_intersections); - getTileSplatIntersections_brute<<<_LAUNCH_ARGS_1D(tiles.size, warp)>>>( + getTileSplatIntersections_brute<<<_LAUNCH_ARGS_1D(tiles.size, warp)>>>( numSplats, tiles, splats, (uint32_t*)intersection_count_map.data_ptr(), @@ -793,9 +797,9 @@ SplatTileIntersector::getIntersections_brute() { } -template +template std::tuple, DeviceVector> -SplatTileIntersector::getIntersections_lbvh() { +SplatTileIntersector::getIntersections_lbvh() { // TODO: use a separate rotated AABB aligned with (1,1,1) for thin off-diagnoal Gaussians? constexpr uint MAX_NUM_LEVELS = 28; constexpr float BRANCH_FACTOR = 2.0f; @@ -916,7 +920,7 @@ SplatTileIntersector::getIntersections_lbvh() { DeviceVector intersection_count; intersection_count.resize(PoolSlot::StiLbvhCount, tiles.size+1); intersection_count.zero(); - getTileSplatIntersections_lbvh_warp<<>>( + getTileSplatIntersections_lbvh_warp<<>>( tiles, splats, MAX_NUM_LEVELS, (uint2*)tree_ranges.data_ptr(), (int2*)internal_nodes.data_ptr(), @@ -934,7 +938,7 @@ SplatTileIntersector::getIntersections_lbvh() { DeviceVector intersectionSplatID; intersectionSplatID.resize(PoolSlot::StiLbvhIds, (int64_t)total_intersections); - getTileSplatIntersections_lbvh_warp<<>>( + getTileSplatIntersections_lbvh_warp<<>>( tiles, splats, MAX_NUM_LEVELS, (uint2*)tree_ranges.data_ptr(), (int2*)internal_nodes.data_ptr(), @@ -957,7 +961,8 @@ intersect_splat_tile_3dgs( DeviceVector viewmats, // [C*16] row-major 4x4 DeviceVector intrins, // [C] const std::string& camera_model, - const DeviceTensor2D& dist_coeffs, // [C, 10] or null + const std::string& distortion, + const DeviceTensor2D& dist_coeffs, // [C, 8] or null float rel_scale ) { Vanilla3DGS<0>::WorldBuffer splats_tensor(splats_tuple); @@ -967,30 +972,18 @@ intersect_splat_tile_3dgs( float* dist_coeffs_ptr = dist_coeffs.data_ptr(); const long num_cams = intrins.size(); - if (cmt(camera_model) == CameraModelType::PINHOLE) { - TileBuffers tile_buffers( - width, height, viewmats_ptr, intrins_ptr, dist_coeffs_ptr, num_cams); - return SplatTileIntersector, CameraModelType::PINHOLE> - (splats_tensor, tile_buffers, rel_scale).getIntersections_lbvh(); - } - else if (cmt(camera_model) == CameraModelType::FISHEYE) { - TileBuffers tile_buffers( - width, height, viewmats_ptr, intrins_ptr, dist_coeffs_ptr, num_cams); - return SplatTileIntersector, CameraModelType::FISHEYE> - (splats_tensor, tile_buffers, rel_scale).getIntersections_lbvh(); - } - else if (cmt(camera_model) == CameraModelType::EQUISOLID) { - TileBuffers tile_buffers( - width, height, viewmats_ptr, intrins_ptr, dist_coeffs_ptr, num_cams); - return SplatTileIntersector, CameraModelType::EQUISOLID> - (splats_tensor, tile_buffers, rel_scale).getIntersections_lbvh(); - } - else if (cmt(camera_model) == CameraModelType::EQUIRECTANGULAR) { - TileBuffers tile_buffers( - width, height, viewmats_ptr, intrins_ptr, dist_coeffs_ptr, num_cams); - return SplatTileIntersector, CameraModelType::EQUIRECTANGULAR> - (splats_tensor, tile_buffers, rel_scale).getIntersections_lbvh(); - } - else - throw std::runtime_error("Unsupported camera model"); + const CameraModelType cm = cmt(camera_model); + const CameraDistortionType cd = cdt(distortion); + + #define _DISPATCH(M, D) \ + if (cm == CameraModelType::M && cd == CameraDistortionType::D) { \ + TileBuffers tile_buffers( \ + width, height, viewmats_ptr, intrins_ptr, dist_coeffs_ptr, num_cams); \ + return SplatTileIntersector, \ + CameraModelType::M, CameraDistortionType::D> \ + (splats_tensor, tile_buffers, rel_scale).getIntersections_lbvh(); \ + } else + SS_FOR_EACH_CAMERA_VARIANT(_DISPATCH) + throw std::runtime_error("Unsupported camera model / distortion tier"); + #undef _DISPATCH } diff --git a/src/kernels/tile/SplatTileIntersector.cuh b/src/kernels/tile/SplatTileIntersector.cuh index 4e167a1f..dea043db 100644 --- a/src/kernels/tile/SplatTileIntersector.cuh +++ b/src/kernels/tile/SplatTileIntersector.cuh @@ -9,7 +9,7 @@ #include "primitives/Primitive3DGS.cuh" -template +template struct TileBuffers { long size; float width, height; @@ -23,7 +23,7 @@ struct TileBuffers { unsigned height, const float* viewmats_ptr, // [B*16], row-major 4x4 const float4* intrins_ptr, // [B], fx, fy, cx, cy - float* dist_coeffs_ptr, // [B*10] or nullptr + float* dist_coeffs_ptr, // [B*8] or nullptr long size ) : size(size), @@ -33,17 +33,17 @@ struct TileBuffers { }; -template +template struct SplatTileIntersector { typename Primitive::WorldBuffer splats; long numSplats; float rel_scale; - TileBuffers tiles; + TileBuffers tiles; SplatTileIntersector( const typename Primitive::WorldBuffer &splats, - const TileBuffers &tiles, + const TileBuffers &tiles, float rel_scale ); @@ -62,6 +62,7 @@ intersect_splat_tile_3dgs( DeviceVector viewmats, // [C*16], row-major 4x4 per camera DeviceVector intrins, // [C] const std::string& camera_model, - const DeviceTensor2D& dist_coeffs, // [C, 10], may be null + const std::string& distortion, + const DeviceTensor2D& dist_coeffs, // [C, 8], may be null float rel_scale ); diff --git a/src/kernels/visualize/Visualizer.cu b/src/kernels/visualize/Visualizer.cu index bb25c7c1..db7db08e 100644 --- a/src/kernels/visualize/Visualizer.cu +++ b/src/kernels/visualize/Visualizer.cu @@ -11,6 +11,7 @@ namespace SlangProjectionUtils { #include #include +#include "core/CameraDistortion.cuh" #include "engine/EngineState.h" #include "engine/EngineCommon.h" #include "core/Interpolation.cuh" @@ -90,9 +91,23 @@ inline void default_stream_wait_viewer() { #define _LAUNCH_ARGS_2D_VS(nx,ny,bx,by) dim3(_CEIL_DIV(nx,bx),_CEIL_DIV(ny,by),1),dim3(bx,by),0,viewer_stream() +// Run BODY(tier) for the tier `name` spells. The camera model stays runtime -- +// per-camera for the dataset frusta, a plain argument for the view camera. +#define _SS_DISPATCH_DISTORTION(name, BODY) \ + do { switch (cdt(name)) { \ + case CameraDistortionType::None: BODY(CameraDistortionType::None); break; \ + case CameraDistortionType::OpenCV: BODY(CameraDistortionType::OpenCV); break; \ + case CameraDistortionType::ThinPrism: BODY(CameraDistortionType::ThinPrism); break; \ + case CameraDistortionType::Rational: BODY(CameraDistortionType::Rational); break; \ + default: throw std::runtime_error( \ + "Unknown camera distortion: " + std::string(name)); \ + } } while (0) + + inline constexpr int kNumFrustumSegments = 16; inline constexpr int kNumFrustumFaces = 8; +template __global__ void fill_frustum_segments_kernel( const float4* __restrict__ intrins, // [N, 4] const int32_t* __restrict__ widths, // [N] @@ -113,7 +128,7 @@ __global__ void fill_frustum_segments_kernel( float width = (float)widths[bid]; float height = (float)heights[bid]; CameraModelType camera_model = (CameraModelType)camera_models[bid]; - CameraDistortionCoeffs dist_coeffs = dist_coeffs_buffer.load(bid); + auto dist_coeffs = dist_coeffs_buffer.load(bid); float2 corners[4] = { {-cx / fx, -cy / fy}, {(width-cx) / fx, -cy / fy}, @@ -142,14 +157,14 @@ __global__ void fill_frustum_segments_kernel( float2 uv = corners[corner_idx] + (corners[(corner_idx+1)%4] - corners[corner_idx]) * ((float)(i % kNumFrustumSegments) / kNumFrustumSegments); float3 raydir = float3{NAN, NAN, NAN}; - bool valid = SlangProjectionUtils::generate_ray(uv, (int)camera_model, dist_coeffs, &raydir); + bool valid = SlangDistortion::generate_ray(uv, (int)camera_model, dist_coeffs, &raydir); if (!valid) { // binary search for valid float t0 = 0.0f, t1 = 1.0f; for (int iter = 0; iter < 12; ++iter) { float t = 0.5f*(t0+t1); float3 temp; - if (SlangProjectionUtils::generate_ray(uv*t, (int)camera_model, dist_coeffs, &temp)) + if (SlangDistortion::generate_ray(uv*t, (int)camera_model, dist_coeffs, &temp)) t0 = t, raydir = temp; else t1 = t; @@ -216,14 +231,14 @@ __global__ void fill_frustum_segments_kernel( corners[2] * u*v + corners[3] * (1.0f-u)*v; float3 raydir = float3{NAN, NAN, NAN}; - bool valid = SlangProjectionUtils::generate_ray(uv, (int)camera_model, dist_coeffs, &raydir); + bool valid = SlangDistortion::generate_ray(uv, (int)camera_model, dist_coeffs, &raydir); if (!valid) { // binary search for valid float t0 = 0.0f, t1 = 1.0f; for (int iter = 0; iter < 12; ++iter) { float t = 0.5f*(t0+t1); float3 temp; - if (SlangProjectionUtils::generate_ray(uv*t, (int)camera_model, dist_coeffs, &temp)) + if (SlangDistortion::generate_ray(uv*t, (int)camera_model, dist_coeffs, &temp)) t0 = t, raydir = temp; else t1 = t; @@ -621,6 +636,7 @@ inline __device__ bool ray_triangle_intersection( } +template __global__ void blit_aabb_bvh_kernel( TensorView render_rgbs, // [H, W, 3] const TensorView render_depths, // [H, W, 1] @@ -651,14 +667,14 @@ __global__ void blit_aabb_bvh_kernel( view_viewmat[8], view_viewmat[9], view_viewmat[10], // 3rd row }; float3 t = { view_viewmat[3], view_viewmat[7], view_viewmat[11] }; - CameraDistortionCoeffs dist_coeffs = view_dist_coeffs.load(0); + auto dist_coeffs = view_dist_coeffs.load(0); #pragma unroll for (int i = 0; i < MSAA*MSAA; ++i) { const float px = (float)pix_x + (i/MSAA + 0.5f) / (float)MSAA; const float py = (float)pix_y + (i%MSAA + 0.5f) / (float)MSAA; ray_o[i] = SlangProjectionUtils::transform_ray_o(R, t); - inside |= SlangProjectionUtils::generate_ray( + inside |= SlangDistortion::generate_ray( {(px-cx)/fx, (py-cy)/fy}, view_camera_model, dist_coeffs, &ray_d[i] @@ -823,6 +839,7 @@ inline __device__ float3 get_thumbnail_bilinear( }; } +template __global__ void blit_with_bvh_kernel( const TensorView render_rgbs, // [H, W, 3] const TensorView render_depths, // [H, W, 1] @@ -913,7 +930,7 @@ __global__ void blit_with_bvh_kernel( view_viewmat[8], view_viewmat[9], view_viewmat[10], // 3rd row }; float3 t = { view_viewmat[3], view_viewmat[7], view_viewmat[11] }; - CameraDistortionCoeffs dist_coeffs = view_dist_coeffs.load(0); + auto dist_coeffs = view_dist_coeffs.load(0); float alpha_final = 0.0f; float3 rgb_final = {0.0f, 0.0f, 0.0f}; @@ -926,7 +943,7 @@ __global__ void blit_with_bvh_kernel( float3 ray_o = SlangProjectionUtils::transform_ray_o(R, t); float3 ray_d; float2 uv = {(px-cx)/fx, (py-cy)/fy}; - bool inside = SlangProjectionUtils::generate_ray( + bool inside = SlangDistortion::generate_ray( uv, view_camera_model, dist_coeffs, &ray_d @@ -1198,7 +1215,7 @@ void engine_viewer_init( v.d_heights = _hv_to_dv(PoolSlot::ViewerHeights, heights); v.d_camera_models = _hv_to_dv(PoolSlot::ViewerCmodels, camera_models); v.d_dist_coeffs = _hv_to_dv(PoolSlot::ViewerDist, - TorchTensorView(std::get<0>(dist_coeffs), 4, {N * 10LL})); + TorchTensorView(std::get<0>(dist_coeffs), 4, {N * (int64_t)kCameraDistortionParams})); v.d_camera_to_worlds = _hv_to_dv(PoolSlot::ViewerC2w, TorchTensorView(std::get<0>(camera_to_worlds), 4, {N * 12LL})); @@ -1488,6 +1505,7 @@ namespace { // Build the BVH into engine().viewer.bvh_* pool slots. Runs the same kernel // dance as blit_train_cameras_tensor's show-cams branch but emits to // dedicated "viewer.*" keys so the buffers survive across calls. +template void _viewer_build_bvh() { auto& v = engine().viewer; @@ -1503,10 +1521,10 @@ void _viewer_build_bvh() float4* tri_buffer = DevicePool::global().acquire(PoolSlot::ViewerTri, (size_t)num_tri * 4); TorchTensorView dist_tv((uint64_t)v.d_dist_coeffs.data_ptr(), 4, - {(int64_t)n, 10LL}); + {(int64_t)n, (int64_t)kCameraDistortionParams}); CameraDistortionCoeffsBuffer dist_buf(dist_tv); - fill_frustum_segments_kernel + fill_frustum_segments_kernel <<<_LAUNCH_ARGS_1D(n * 4 * kNumFrustumSegments, 4 * kNumFrustumSegments)>>>( (const float4*)v.d_intrins.data_ptr(), v.d_widths.data_ptr(), @@ -1583,6 +1601,7 @@ void engine_blit_view( TorchTensorView render_depth, TorchTensorView render_alpha, int view_camera_model, + std::string distortion, TorchTensorView view_intrins, TorchTensorView view_viewmat, TorchTensorView view_dist_coeffs, @@ -1662,7 +1681,9 @@ void engine_blit_view( // buffers are populated relative to the default stream, so the // viewer stream must wait on the default stream once more before // the blit kernel reads them. - _viewer_build_bvh(); + #define BUILD(D) _viewer_build_bvh() + _SS_DISPATCH_DISTORTION(distortion, BUILD); + #undef BUILD viewer_stream_wait_default(); } lss_buffer = (const float4*)DevicePool::global().acquire( @@ -1680,24 +1701,26 @@ void engine_blit_view( } } - blit_with_bvh_kernel<<<_LAUNCH_ARGS_2D_VS(w, h, 8, 4)>>>( - tv_to_view(render_buffer), - tv_to_view(render_depth), - tv_to_view(render_alpha), - view_camera_model, (int)w, (int)h, - (float4*)std::get<0>(view_intrins), - (float*)std::get<0>(view_viewmat), - view_dist_coeffs, - lss_buffer, lss_nodes, lss_aabb, - tri_buffer, tri_nodes, tri_aabb, - (const float*)v.d_overlay_colors.data_ptr(), - v.bvh_num_cam_lss, - show_training_cameras, - show_overlay, - thumb_view, - min_max, - tv_to_view(out_rgb) - ); + #define LAUNCH(D) \ + blit_with_bvh_kernel<<<_LAUNCH_ARGS_2D_VS(w, h, 8, 4)>>>( \ + tv_to_view(render_buffer), \ + tv_to_view(render_depth), \ + tv_to_view(render_alpha), \ + view_camera_model, (int)w, (int)h, \ + (float4*)std::get<0>(view_intrins), \ + (float*)std::get<0>(view_viewmat), \ + view_dist_coeffs, \ + lss_buffer, lss_nodes, lss_aabb, \ + tri_buffer, tri_nodes, tri_aabb, \ + (const float*)v.d_overlay_colors.data_ptr(), \ + v.bvh_num_cam_lss, \ + show_training_cameras, \ + show_overlay, \ + thumb_view, \ + min_max, \ + tv_to_view(out_rgb)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); // Ensure the default stream (which the Python caller will use to read @@ -1712,6 +1735,7 @@ void blit_train_cameras_tensor( TorchTensorView render_depths, // [H, W, 1] float32 TorchTensorView render_alphas, // [H, W, 1] float32 const int view_camera_model, + std::string distortion, TorchTensorView view_intrins, // [1, 4] or [4] float32 TorchTensorView view_viewmat, // [4, 4] float32 TorchTensorView view_dist_coeffs, @@ -1744,21 +1768,23 @@ void blit_train_cameras_tensor( } if (!show_training_cameras) { - blit_with_bvh_kernel<<<_LAUNCH_ARGS_2D(w, h, 8, 4)>>>( - tv_to_view(render_rgbs), - tv_to_view(render_depths), - tv_to_view(render_alphas), - view_camera_model, w, h, - (float4*)std::get<0>(view_intrins), - (float*)std::get<0>(view_viewmat), - view_dist_coeffs, - nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, - nullptr, 0, false, false, - tv_to_view(thumbnails), - min_max, - tv_to_view(out_rgb) - ); + #define LAUNCH(D) \ + blit_with_bvh_kernel<<<_LAUNCH_ARGS_2D(w, h, 8, 4)>>>( \ + tv_to_view(render_rgbs), \ + tv_to_view(render_depths), \ + tv_to_view(render_alphas), \ + view_camera_model, w, h, \ + (float4*)std::get<0>(view_intrins), \ + (float*)std::get<0>(view_viewmat), \ + view_dist_coeffs, \ + nullptr, nullptr, nullptr, \ + nullptr, nullptr, nullptr, \ + nullptr, 0, false, false, \ + tv_to_view(thumbnails), \ + min_max, \ + tv_to_view(out_rgb)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); return; } @@ -1767,18 +1793,20 @@ void blit_train_cameras_tensor( uint32_t num_tri = (uint32_t)(n * 4 * kNumFrustumFaces * kNumFrustumFaces); float4* lss_buffer = DevicePool::global().acquire(PoolSlot::VisLss, (size_t)num_lss * 2); float4* tri_buffer = DevicePool::global().acquire(PoolSlot::VisTri, (size_t)num_tri * 4); - fill_frustum_segments_kernel - <<<_LAUNCH_ARGS_1D(n * 4 * kNumFrustumSegments, 4 * kNumFrustumSegments)>>>( - (float4*)std::get<0>(intrins), - (int32_t*)std::get<0>(widths), - (int32_t*)std::get<0>(heights), - (int32_t*)std::get<0>(camera_models), - dist_coeffs, - (float*)std::get<0>(camera_to_worlds), - camera_size, - lss_buffer, - tri_buffer - ); + #define LAUNCH(D) \ + fill_frustum_segments_kernel \ + <<<_LAUNCH_ARGS_1D(n * 4 * kNumFrustumSegments, 4 * kNumFrustumSegments)>>>( \ + (float4*)std::get<0>(intrins), \ + (int32_t*)std::get<0>(widths), \ + (int32_t*)std::get<0>(heights), \ + (int32_t*)std::get<0>(camera_models), \ + dist_coeffs, \ + (float*)std::get<0>(camera_to_worlds), \ + camera_size, \ + lss_buffer, \ + tri_buffer) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); float3* root_aabb = DevicePool::global().acquire(PoolSlot::VisRootAabb, 2); @@ -1811,24 +1839,26 @@ void blit_train_cameras_tensor( auto tri_bvh = build_bvh( num_tri, tri_buffer, rootAABBMin, rootAABBMax, "vis.tri_bvh"); - blit_with_bvh_kernel<<<_LAUNCH_ARGS_2D(w, h, 8, 4)>>>( - tv_to_view(render_rgbs), - tv_to_view(render_depths), - tv_to_view(render_alphas), - view_camera_model, w, h, - (float4*)std::get<0>(view_intrins), - (float*)std::get<0>(view_viewmat), - view_dist_coeffs, - lss_buffer, - lss_bvh.nodes, - lss_bvh.aabb, - tri_buffer, - tri_bvh.nodes, - tri_bvh.aabb, - nullptr, (int)num_lss, true, false, // no overlay in the legacy path - tv_to_view(thumbnails), - min_max, - tv_to_view(out_rgb) - ); + #define LAUNCH(D) \ + blit_with_bvh_kernel<<<_LAUNCH_ARGS_2D(w, h, 8, 4)>>>( \ + tv_to_view(render_rgbs), \ + tv_to_view(render_depths), \ + tv_to_view(render_alphas), \ + view_camera_model, w, h, \ + (float4*)std::get<0>(view_intrins), \ + (float*)std::get<0>(view_viewmat), \ + view_dist_coeffs, \ + lss_buffer, \ + lss_bvh.nodes, \ + lss_bvh.aabb, \ + tri_buffer, \ + tri_bvh.nodes, \ + tri_bvh.aabb, \ + nullptr, (int)num_lss, true, false, /* no overlay in the legacy path */ \ + tv_to_view(thumbnails), \ + min_max, \ + tv_to_view(out_rgb)) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } diff --git a/src/kernels/visualize/Visualizer.cuh b/src/kernels/visualize/Visualizer.cuh index 420c3cb6..027dd65d 100644 --- a/src/kernels/visualize/Visualizer.cuh +++ b/src/kernels/visualize/Visualizer.cuh @@ -15,6 +15,7 @@ void engine_blit_view( TorchTensorView render_depth, TorchTensorView render_alpha, int view_camera_model, + std::string distortion, TorchTensorView view_intrins, TorchTensorView view_viewmat, TorchTensorView view_dist_coeffs, @@ -32,6 +33,7 @@ void blit_train_cameras_tensor( TorchTensorView render_depths, // [H, W, 1] float32 TorchTensorView render_alphas, // [H, W, 1] float32 const int view_camera_model, + std::string distortion, TorchTensorView view_intrins, // [1, 4] or [4] float32 TorchTensorView view_viewmat, // [4, 4] float32 TorchTensorView view_dist_coeffs, diff --git a/src/mesh/Meshing.h b/src/mesh/Meshing.h index 5dc4cdb7..2cb776eb 100644 --- a/src/mesh/Meshing.h +++ b/src/mesh/Meshing.h @@ -105,15 +105,16 @@ struct MeshingConfig { // Full camera intrinsics/extrinsics for the rasterize-and-sample (dataset) // path. All host pointers; when !valid() the evaluator falls back to the static -// LBVH path. Distortion uses the engine [C,10] layout expected by the 3DGUT -// projection: k1,k2,p1,p2,k3,k4,k5,k6,sx1,sy1 (tail-padded with zeros). +// LBVH path. Coefficient rows are 8 wide; the per-tier order is documented in +// core/CameraModel.h. struct CameraParams { const float* viewmats = nullptr; // [C*16] row-major world->cam 4x4 const float* intrins = nullptr; // [C*4] fx, fy, cx, cy - const float* dist_coeffs = nullptr; // [C*10] (may be null => treated as 0) + const float* dist_coeffs = nullptr; // [C*8] (may be null => treated as 0) const int* widths = nullptr; // [C] per-camera image width const int* heights = nullptr; // [C] per-camera image height std::string camera_model; // engine name, e.g. "PINHOLE"/"FISHEYE" + std::string distortion = "NONE"; // tier name, e.g. "OPENCV"/"THIN_PRISM" bool valid() const { return viewmats && intrins && widths && heights; } diff --git a/src/mesh/MeshingDevice.h b/src/mesh/MeshingDevice.h index 89b6ff83..962c56bf 100644 --- a/src/mesh/MeshingDevice.h +++ b/src/mesh/MeshingDevice.h @@ -15,10 +15,10 @@ * * Same contract as src/backend/api/: this header must parse under * -DSS_BACKEND_VULKAN, so it stays CUDA-include-free. The camera model - * travels as a plain int (CameraModelType's value) rather than the enum, - * because that enum has two spellings -- Common.cuh's (CUDA translation - * units) and CameraModel.h's (portable ones) -- and no translation unit may - * see both. + * travels as a plain int (CameraModelType's value) rather than the enum, and + * so does the distortion tier (CameraDistortionType's value), because those + * enums have two spellings -- Common.cuh's (CUDA translation units) and + * CameraModel.h's (portable ones) -- and no translation unit may see both. * * Every launch below is asynchronous on the default stream unless noted; the * host synchronizes where it reads results back. @@ -156,7 +156,8 @@ void launch_colorize_fallback(const GpuScene& s, const float* verts, int n, void launch_sample_occ( const float* xyz, int n, const float* viewmat, const float* intrin, const float* dist, - int camera_model, const float3* moments, int W, int H, int k, + int camera_model, int distortion, + const float3* moments, int W, int H, int k, float* occ_kmin, int* cnt); // occ[i] = the k-th smallest sample (or the largest available when fewer @@ -168,7 +169,8 @@ void launch_finalize_occ(int n, const float* occ_kmin, const int* cnt, int k, void launch_sample_color( const float* xyz, int n, const float* viewmat, const float* intrin, const float* dist, - int camera_model, const float3* moments, const float3* rgb_img, + int camera_model, int distortion, + const float3* moments, const float3* rgb_img, int W, int H, float3* num, float* den); // rgb = num/den, or (-1,-1,-1) when no view contributed. @@ -179,7 +181,8 @@ void launch_finalize_color(int n, const float3* num, const float* den, void launch_sample_view_density( const float* xyz, int n, const float* viewmat, const float* intrin, const float* dist, - int camera_model, const float3* moments, int W, int H, float* dens); + int camera_model, int distortion, + const float3* moments, int W, int H, float* dens); // Per mesh triangle: leaf AABB + centroid Morton code + iota (the LBVH build // then reuses launch_lbvh_* above). @@ -195,7 +198,7 @@ void launch_tri_prep( void launch_cull( const float* verts, int nv, const int* faces, int nf, const float* viewmats, const float* intrins, const float* dist, - const int* Ws, const int* Hs, int camera_model, int C, + const int* Ws, const int* Hs, int camera_model, int distortion, int C, const float3* leafMin, const float3* leafMax, const int2* internal, const float3* nodeAABB, uint32_t* visible); diff --git a/src/mesh/MeshingRaster.cu b/src/mesh/MeshingRaster.cu index 485e8620..613cb737 100644 --- a/src/mesh/MeshingRaster.cu +++ b/src/mesh/MeshingRaster.cu @@ -26,8 +26,20 @@ namespace SlangProjectionUtils { #include "generated/set_namespace.cuh" #include "generated/projection_utils.cuh" } +#include "core/CameraDistortion.cuh" #endif +// Run BODY(tier) for the tier `value` names. The camera model stays runtime; +// the tier is one compile-time axis shared by every camera in the context. +#define _SS_DISPATCH_DISTORTION(value, BODY) \ + do { switch ((CameraDistortionType)(value)) { \ + case CameraDistortionType::None: BODY(CameraDistortionType::None); break; \ + case CameraDistortionType::OpenCV: BODY(CameraDistortionType::OpenCV); break; \ + case CameraDistortionType::ThinPrism: BODY(CameraDistortionType::ThinPrism); break; \ + case CameraDistortionType::Rational: BODY(CameraDistortionType::Rational); break; \ + default: throw std::runtime_error("Unknown camera distortion tier"); \ + } } while (0) + namespace meshing { // --------------------------------------------------------------------------- @@ -61,8 +73,10 @@ __device__ __forceinline__ float3 bilinear3( // the rasterizer's evaluate_color depth metric). Uses the same projection + // distortion model the occupancy/color images were rendered with, so the sample // lands on the pixel the splats were actually rasterized to. +template __device__ __forceinline__ bool project_point( - const float* viewmat, const float* intrin, const float* dist, + const float* viewmat, const float* intrin, + const CameraDistortionCoeffsBuffer& dist, int cam, int model, int W, int H, float px, float py, float pz, float& u, float& v, float& z ) { @@ -72,19 +86,13 @@ __device__ __forceinline__ bool project_point( float3 p_cam = make_float3(cx_, cy_, cz_); float4 intr = make_float4(intrin[0], intrin[1], intrin[2], intrin[3]); - CameraDistortionCoeffs dist_coeffs; - #pragma unroll - for (int t = 0; t < 10; ++t) dist_coeffs[t] = dist ? dist[t] : 0.0f; + auto dist_coeffs = dist.load(cam); // proj_nav handles the behind-camera / invalid-distortion cases and returns // pixel-space uv (already scaled by fx,fy and offset by cx,cy). float2 uv; - bool valid = - (model == (int)CameraModelType::FISHEYE) - ? SlangProjectionUtils::fisheye_proj_nav(p_cam, intr, dist_coeffs, &uv) : - (model == (int)CameraModelType::EQUISOLID) - ? SlangProjectionUtils::equisolid_proj_nav(p_cam, intr, dist_coeffs, &uv) : - SlangProjectionUtils::persp_proj_nav(p_cam, intr, dist_coeffs, &uv); + bool valid = camera_proj_nav( + (CameraModelType)model, p_cam, intr, dist_coeffs, &uv); if (!valid) return false; u = uv.x; v = uv.y; if (u < 0.0f || u >= (float)W || v < 0.0f || v >= (float)H) return false; @@ -137,10 +145,11 @@ __device__ __forceinline__ bool occ_bilinear( // --------------------------------------------------------------------------- // Occupancy sampling (k-th-smallest over the cameras that see the point) // --------------------------------------------------------------------------- +template __global__ void sample_occ_kernel( const float* __restrict__ xyz, int n, const float* __restrict__ viewmat, const float* __restrict__ intrin, - const float* __restrict__ dist, int model, + const CameraDistortionCoeffsBuffer dist, int model, const float3* __restrict__ moments, int W, int H, int k, float* __restrict__ occ_kmin, int* __restrict__ cnt @@ -148,7 +157,7 @@ __global__ void sample_occ_kernel( int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= n) return; float u, v, z; - if (!project_point(viewmat, intrin, dist, model, W, H, + if (!project_point(viewmat, intrin, dist, 0, model, W, H, xyz[3*i], xyz[3*i+1], xyz[3*i+2], u, v, z)) return; float occ; @@ -180,10 +189,11 @@ __global__ void finalize_occ_kernel( // --------------------------------------------------------------------------- // Color sampling (rendered DC color weighted by transmittance until the point) // --------------------------------------------------------------------------- +template __global__ void sample_color_kernel( const float* __restrict__ xyz, int n, const float* __restrict__ viewmat, const float* __restrict__ intrin, - const float* __restrict__ dist, int model, + const CameraDistortionCoeffsBuffer dist, int model, const float3* __restrict__ moments, const float3* __restrict__ rgb, int W, int H, float3* __restrict__ num, float* __restrict__ den @@ -191,7 +201,7 @@ __global__ void sample_color_kernel( int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= n) return; float u, v, z; - if (!project_point(viewmat, intrin, dist, model, W, H, + if (!project_point(viewmat, intrin, dist, 0, model, W, H, xyz[3*i], xyz[3*i+1], xyz[3*i+2], u, v, z)) return; float occ; @@ -239,17 +249,18 @@ __global__ void finalize_color_kernel( // --------------------------------------------------------------------------- // View texel density // --------------------------------------------------------------------------- +template __global__ void sample_view_density_kernel( const float* __restrict__ xyz, int n, const float* __restrict__ viewmat, const float* __restrict__ intrin, - const float* __restrict__ dist, int model, + const CameraDistortionCoeffsBuffer dist, int model, const float3* __restrict__ moments, int W, int H, float* __restrict__ dens ) { int i = blockIdx.x * blockDim.x + threadIdx.x; if (i >= n) return; float u, v, z; - if (!project_point(viewmat, intrin, dist, model, W, H, + if (!project_point(viewmat, intrin, dist, 0, model, W, H, xyz[3*i], xyz[3*i+1], xyz[3*i+2], u, v, z)) return; float occ; @@ -407,11 +418,12 @@ __global__ void tri_prep_kernel( iota[t] = t; } +template __global__ void cull_kernel( const float* __restrict__ verts, int nv, const int* __restrict__ faces, int nf, const float* __restrict__ viewmats, const float* __restrict__ intrins, - const float* __restrict__ dist, + const CameraDistortionCoeffsBuffer dist, const int* __restrict__ Ws, const int* __restrict__ Hs, int model, int C, const float3* __restrict__ leafMin, const float3* __restrict__ leafMax, @@ -424,8 +436,9 @@ __global__ void cull_kernel( for (int c = 0; c < C; ++c) { const float* vm = viewmats + (size_t)c * 16; float u, v, z; - if (!project_point(vm, intrins + (size_t)c*4, dist + (size_t)c*10, - model, Ws[c], Hs[c], p.x, p.y, p.z, u, v, z)) + if (!project_point( + vm, intrins + (size_t)c*4, dist, c, + model, Ws[c], Hs[c], p.x, p.y, p.z, u, v, z)) continue; // out of frame / behind camera // camera center in world: C = -R^T t (viewmat row-major world->cam 4x4) float3 cam = make_float3( @@ -450,13 +463,18 @@ __global__ void cull_kernel( void launch_sample_occ( const float* xyz, int n, const float* viewmat, const float* intrin, const float* dist, - int camera_model, const float3* moments, int W, int H, int k, + int camera_model, int distortion, + const float3* moments, int W, int H, int k, float* occ_kmin, int* cnt ) { if (n <= 0) return; - sample_occ_kernel<<<_LAUNCH_ARGS_1D(n, 256)>>>( - xyz, n, viewmat, intrin, dist, camera_model, moments, W, H, k, - occ_kmin, cnt); + const CameraDistortionCoeffsBuffer dcb(const_cast(dist)); + #define LAUNCH(D) \ + sample_occ_kernel<<<_LAUNCH_ARGS_1D(n, 256)>>>( \ + xyz, n, viewmat, intrin, dcb, camera_model, moments, W, H, k, \ + occ_kmin, cnt) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -470,13 +488,18 @@ void launch_finalize_occ(int n, const float* occ_kmin, const int* cnt, int k, void launch_sample_color( const float* xyz, int n, const float* viewmat, const float* intrin, const float* dist, - int camera_model, const float3* moments, const float3* rgb_img, + int camera_model, int distortion, + const float3* moments, const float3* rgb_img, int W, int H, float3* num, float* den ) { if (n <= 0) return; - sample_color_kernel<<<_LAUNCH_ARGS_1D(n, 256)>>>( - xyz, n, viewmat, intrin, dist, camera_model, moments, rgb_img, W, H, - num, den); + const CameraDistortionCoeffsBuffer dcb(const_cast(dist)); + #define LAUNCH(D) \ + sample_color_kernel<<<_LAUNCH_ARGS_1D(n, 256)>>>( \ + xyz, n, viewmat, intrin, dcb, camera_model, moments, rgb_img, W, H, \ + num, den) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -490,11 +513,16 @@ void launch_finalize_color(int n, const float3* num, const float* den, void launch_sample_view_density( const float* xyz, int n, const float* viewmat, const float* intrin, const float* dist, - int camera_model, const float3* moments, int W, int H, float* dens + int camera_model, int distortion, + const float3* moments, int W, int H, float* dens ) { if (n <= 0) return; - sample_view_density_kernel<<<_LAUNCH_ARGS_1D(n, 256)>>>( - xyz, n, viewmat, intrin, dist, camera_model, moments, W, H, dens); + const CameraDistortionCoeffsBuffer dcb(const_cast(dist)); + #define LAUNCH(D) \ + sample_view_density_kernel<<<_LAUNCH_ARGS_1D(n, 256)>>>( \ + xyz, n, viewmat, intrin, dcb, camera_model, moments, W, H, dens) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } @@ -512,15 +540,19 @@ void launch_tri_prep( void launch_cull( const float* verts, int nv, const int* faces, int nf, const float* viewmats, const float* intrins, const float* dist, - const int* Ws, const int* Hs, int camera_model, int C, + const int* Ws, const int* Hs, int camera_model, int distortion, int C, const float3* leafMin, const float3* leafMax, const int2* internal, const float3* nodeAABB, uint32_t* visible ) { if (nv <= 0) return; - cull_kernel<<<_LAUNCH_ARGS_1D(nv, 256)>>>( - verts, nv, faces, nf, viewmats, intrins, dist, Ws, Hs, camera_model, C, - leafMin, leafMax, internal, nodeAABB, visible); + const CameraDistortionCoeffsBuffer dcb(const_cast(dist)); + #define LAUNCH(D) \ + cull_kernel<<<_LAUNCH_ARGS_1D(nv, 256)>>>( \ + verts, nv, faces, nf, viewmats, intrins, dcb, Ws, Hs, camera_model, C, \ + leafMin, leafMax, internal, nodeAABB, visible) + _SS_DISPATCH_DISTORTION(distortion, LAUNCH); + #undef LAUNCH CHECK_DEVICE_ERROR(cudaGetLastError()); } diff --git a/src/mesh/MeshingRaster.h b/src/mesh/MeshingRaster.h index 7870ecac..1c1cf108 100644 --- a/src/mesh/MeshingRaster.h +++ b/src/mesh/MeshingRaster.h @@ -30,7 +30,7 @@ struct RenderContext; // params, [num_splats * {3,4,3,1,3}]; the projection activates them. // viewmats : [num_cameras*16] row-major world->cam 4x4 // intrins : [num_cameras*4] fx, fy, cx, cy -// dist : [num_cameras*10] engine distortion layout (may be null => zeros) +// dist : [num_cameras*8] distortion coefficients (may be null => zeros) // widths : [num_cameras] per-camera image width (HOST array) // heights : [num_cameras] per-camera image height (HOST array) // verbose : report per-camera progress on the long render loops. Each of @@ -42,7 +42,8 @@ RenderContext* render_context_create( const float* logit_opac, const float* features_dc, int num_splats, const float* viewmats, const float* intrins, const float* dist, int num_cameras, const int* widths, const int* heights, - const std::string& camera_model, int carve_k, bool verbose); + const std::string& camera_model, const std::string& distortion, + int carve_k, bool verbose); void render_context_destroy(RenderContext*); diff --git a/src/mesh/MeshingRasterHost.cpp b/src/mesh/MeshingRasterHost.cpp index e69676b3..edd5fbab 100644 --- a/src/mesh/MeshingRasterHost.cpp +++ b/src/mesh/MeshingRasterHost.cpp @@ -94,6 +94,7 @@ struct RenderContext { std::vector Ws, Hs; // per-camera image size int Wmax = 0, Hmax = 0; // max over cameras (scratch-buffer sizing) std::string model; + std::string distortion; // raw (un-activated) splat params on device DBuf d_means; @@ -105,7 +106,7 @@ struct RenderContext { // camera intrinsics on device (all cameras) DBuf d_viewmats; // [C*16] DBuf d_intrins; // [C*4] - DBuf d_dist; // [C*10] + DBuf d_dist; // [C*8] DeviceVector radii; // pool-backed scratch, size N @@ -137,7 +138,8 @@ RenderContext* render_context_create( const float* logit_opac, const float* features_dc, int num_splats, const float* viewmats, const float* intrins, const float* dist, int num_cameras, const int* widths, const int* heights, - const std::string& camera_model, int carve_k, bool verbose + const std::string& camera_model, const std::string& distortion, + int carve_k, bool verbose ) { RenderContext* ctx = new RenderContext(); ctx->verbose = verbose; @@ -150,6 +152,7 @@ RenderContext* render_context_create( ctx->Hmax = std::max(ctx->Hmax, ctx->Hs[c]); } ctx->model = camera_model; + ctx->distortion = distortion; ctx->carve_k = (carve_k < 1) ? 1 : carve_k; const size_t N = (size_t)num_splats; @@ -161,7 +164,7 @@ RenderContext* render_context_create( ctx->d_viewmats.alloc_copy(viewmats, (size_t)num_cameras * 16); ctx->d_intrins.alloc_copy(intrins, (size_t)num_cameras * 4); - ctx->d_dist.alloc_copy(dist, (size_t)num_cameras * 10); // null -> zeros + ctx->d_dist.alloc_copy(dist, (size_t)num_cameras * kCameraDistortionParams); // null -> zeros ctx->radii.resize(PoolSlot::MeshingRenderRadii, N); return ctx; @@ -179,14 +182,15 @@ static void render_one(RenderContext* ctx, int cam_idx, // per-camera views (single image, I=1) TorchTensorView viewmats = tv(ctx->d_viewmats.get() + (size_t)cam_idx * 16, {1, 4, 4}); TorchTensorView intrins = tv(ctx->d_intrins.get() + (size_t)cam_idx * 4, {1, 4}); - TorchTensorView dist = tv(ctx->d_dist.get() + (size_t)cam_idx * 10, {1, 10}); + TorchTensorView dist = tv(ctx->d_dist.get() + (size_t)cam_idx * kCameraDistortionParams, + {1, kCameraDistortionParams}); ctx->radii.zero(); // projection accumulates via atomicMax // --- projection (3DGUT, sh_degree = 0 -> DC color only) --- auto [aabb_2d, depths_2d, splats_s] = projection_3dgut_forward( (int64_t)ctx->N, /*max_sh_degree=*/0, in_splats, - viewmats, intrins, W, H, ctx->model, dist, + viewmats, intrins, W, H, ctx->model, ctx->distortion, dist, ctx->radii, std::nullopt, std::nullopt, /*num_sh_buffer=*/0, /*sh_value_bits=*/32, /*sh_bounds_stride=*/0); @@ -203,7 +207,7 @@ static void render_one(RenderContext* ctx, int cam_idx, // --- moment (+ rgb) rasterization --- rasterize_moments_3dgut_fwd( (int64_t)ctx->N, in_splats, splats_s, DeviceVector(), - viewmats, intrins, ctx->model, dist, + viewmats, intrins, ctx->model, ctx->distortion, dist, aabb_2d, W, H, tile_offsets, flatten_ids, d_moments, d_rgb); } @@ -241,6 +245,7 @@ void render_evaluate_occupancy( } const int cm = (int)cmt(ctx->model); + const int cd = (int)cdt(ctx->distortion); for (int ci = 0; ci < num_cams; ++ci) { int cam = cam_indices[ci]; render_one(ctx, cam, d_moments, nullptr); @@ -249,7 +254,7 @@ void render_evaluate_occupancy( d_xyz, n, ctx->d_viewmats.get() + (size_t)cam * 16, ctx->d_intrins.get() + (size_t)cam * 4, - ctx->d_dist.get() + (size_t)cam * 10, cm, + ctx->d_dist.get() + (size_t)cam * kCameraDistortionParams, cm, cd, d_moments, ctx->Ws[cam], ctx->Hs[cam], k, d_occ_kmin, d_cnt); } @@ -275,6 +280,7 @@ void render_evaluate_color( backend::memset_sync(d_den.get(), 0, (size_t)n * sizeof(float)); const int cm = (int)cmt(ctx->model); + const int cd = (int)cdt(ctx->distortion); for (int ci = 0; ci < num_cams; ++ci) { int cam = cam_indices[ci]; render_one(ctx, cam, d_moments, d_rgbimg); @@ -283,7 +289,7 @@ void render_evaluate_color( d_xyz, n, ctx->d_viewmats.get() + (size_t)cam * 16, ctx->d_intrins.get() + (size_t)cam * 4, - ctx->d_dist.get() + (size_t)cam * 10, cm, + ctx->d_dist.get() + (size_t)cam * kCameraDistortionParams, cm, cd, d_moments, d_rgbimg, ctx->Ws[cam], ctx->Hs[cam], d_num, d_den); } @@ -307,6 +313,7 @@ void render_evaluate_view_density( backend::memset_sync(d_dens, 0, (size_t)n * sizeof(float)); const int cm = (int)cmt(ctx->model); + const int cd = (int)cdt(ctx->distortion); for (int ci = 0; ci < num_cams; ++ci) { int cam = cam_indices[ci]; render_one(ctx, cam, d_moments, nullptr); @@ -315,7 +322,7 @@ void render_evaluate_view_density( d_xyz, n, ctx->d_viewmats.get() + (size_t)cam * 16, ctx->d_intrins.get() + (size_t)cam * 4, - ctx->d_dist.get() + (size_t)cam * 10, cm, + ctx->d_dist.get() + (size_t)cam * kCameraDistortionParams, cm, cd, d_moments, ctx->Ws[cam], ctx->Hs[cam], d_dens); } @@ -393,7 +400,7 @@ void render_cull_unseen_vertices( launch_cull(d_verts, nv, d_faces, nf, ctx->d_viewmats.get(), ctx->d_intrins.get(), ctx->d_dist.get(), - d_W, d_H, (int)cmt(ctx->model), ctx->C, + d_W, d_H, (int)cmt(ctx->model), (int)cdt(ctx->distortion), ctx->C, d_leafMin, d_leafMax, d_internal, d_nodeAABB, d_vis); backend::device_synchronize(); diff --git a/src/mesh/OccupancyEvaluator.cpp b/src/mesh/OccupancyEvaluator.cpp index 8c920f8d..04b0a9a8 100644 --- a/src/mesh/OccupancyEvaluator.cpp +++ b/src/mesh/OccupancyEvaluator.cpp @@ -18,6 +18,8 @@ #include "mesh/MeshingDevice.h" #include "mesh/MeshingRaster.h" +#include "core/CameraModel.h" // kCameraDistortionParams (portable spelling) + #include "backend/api/BackendRuntime.h" #include "backend/common/SortScan.h" @@ -176,7 +178,7 @@ struct OccupancyEvaluator::Impl { // is in use. std::vector cam_viewmats; // [C*16] row-major world->cam std::vector cam_intrins; // [C*4] fx, fy, cx, cy - std::vector cam_dist; // [C*10] engine distortion layout + std::vector cam_dist; // [C*8] distortion coefficients std::vector cam_widths; // [C] per-camera image width std::vector cam_heights; // [C] per-camera image height std::string cam_model; @@ -359,9 +361,10 @@ OccupancyEvaluator::OccupancyEvaluator( if (cams.valid() && num_cameras > 0) { impl_->cam_viewmats.assign(cams.viewmats, cams.viewmats + (size_t)num_cameras * 16); impl_->cam_intrins.assign(cams.intrins, cams.intrins + (size_t)num_cameras * 4); - impl_->cam_dist.assign((size_t)num_cameras * 10, 0.0f); + const size_t ndist = (size_t)num_cameras * kCameraDistortionParams; + impl_->cam_dist.assign(ndist, 0.0f); if (cams.dist_coeffs) - impl_->cam_dist.assign(cams.dist_coeffs, cams.dist_coeffs + (size_t)num_cameras * 10); + impl_->cam_dist.assign(cams.dist_coeffs, cams.dist_coeffs + ndist); impl_->cam_widths.assign(cams.widths, cams.widths + num_cameras); impl_->cam_heights.assign(cams.heights, cams.heights + num_cameras); impl_->cam_model = cams.camera_model; @@ -371,7 +374,7 @@ OccupancyEvaluator::OccupancyEvaluator( impl_->cam_viewmats.data(), impl_->cam_intrins.data(), impl_->cam_dist.empty() ? nullptr : impl_->cam_dist.data(), num_cameras, impl_->cam_widths.data(), impl_->cam_heights.data(), - cams.camera_model, cfg.carve_k, cfg.verbose); + cams.camera_model, cams.distortion, cfg.carve_k, cfg.verbose); if (cfg.verbose) { int w0 = impl_->cam_widths[0], h0 = impl_->cam_heights[0]; bool uniform = true; diff --git a/src/primitives/Primitive.cuh b/src/primitives/Primitive.cuh index 6c360afc..e4197962 100644 --- a/src/primitives/Primitive.cuh +++ b/src/primitives/Primitive.cuh @@ -349,12 +349,13 @@ template<> struct DistortionStore { #ifdef __CUDACC__ -struct ProjCamera { +template +struct ProjCameraT { float3x3 R; float3 t; float fx, fy, cx, cy; uint width, height; - CameraDistortionCoeffs dist_coeffs; + CameraDistortionCoeffsT dist_coeffs; }; #endif diff --git a/src/primitives/Primitive3DGS.cuh b/src/primitives/Primitive3DGS.cuh index 1c907863..6139b751 100644 --- a/src/primitives/Primitive3DGS.cuh +++ b/src/primitives/Primitive3DGS.cuh @@ -14,6 +14,7 @@ namespace SlangHarmonics { #include "primitives/Primitive.cuh" #include "primitives/PrimitiveBase3DGS.cuh" +#include "primitives/PrimitiveProjection.cuh" template @@ -50,48 +51,25 @@ struct _Base3DGS : public _BasePrimitive3DGS { // same code handles both layouts. // The codec read is dispatched via the matching sh{N}_to_color_q{8,16} // slang export, which decodes per-coef inside the SH eval loop. - template + template inline __device__ void project( - ProjCamera cam, + ProjCameraT cam, typename _Base3DGS::Screen& screen, float4& aabb, float& sorting_depth, float& radius, uint8_t* sh_packed = nullptr, float2* sh_bounds = nullptr, int64_t sh_base = 0, int64_t sh_bounds_stride = 256 ) { - if constexpr (camera_model == CameraModelType::PINHOLE) - Slang3DGS::projection_3dgs_persp( - antialiased, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, - cam.dist_coeffs, - cam.width, cam.height, - &aabb, &sorting_depth, &radius, &screen.xy, &screen.depth, &screen.conic, &screen.opac - ); - else if constexpr (camera_model == CameraModelType::FISHEYE) - Slang3DGS::projection_3dgs_fisheye( - antialiased, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - &aabb, &sorting_depth, &radius, &screen.xy, &screen.depth, &screen.conic, &screen.opac - ); - else if constexpr (camera_model == CameraModelType::EQUISOLID) - Slang3DGS::projection_3dgs_equisolid( - antialiased, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - &aabb, &sorting_depth, &radius, &screen.xy, &screen.depth, &screen.conic, &screen.opac - ); - else if constexpr (camera_model == CameraModelType::EQUIRECTANGULAR) - Slang3DGS::projection_3dgs_equirect( - antialiased, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - &aabb, &sorting_depth, &radius, &screen.xy, &screen.depth, &screen.conic, &screen.opac - ); + Slang3DGSProj::fwd_2d( + antialiased, + this->mean, this->quat, this->scale, this->opacity, + cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, + cam.dist_coeffs.v, + cam.width, cam.height, + &aabb, &sorting_depth, &radius, + &screen.xy, &screen.depth, &screen.conic, &screen.opac + ); if (aabb.z > aabb.x && aabb.w > aabb.y) { if constexpr (VALUE_BITS == 32) { // screen.rgb = SlangHarmonics::sh_coeffs_to_color( @@ -138,9 +116,10 @@ struct _Base3DGS : public _BasePrimitive3DGS { // buffer (`v_world.features_sh`) stays fp32 regardless of VALUE_BITS // -- gradients always live in fp32 inside engine().grad.features_sh. // Only the INPUT SH read (used for v_dir grads) goes through the codec. - template + template inline __device__ void project_vjp( - ProjCamera cam, + ProjCameraT cam, typename _Base3DGS::Screen v_screen, typename _Base3DGS::World& v_world, float3x3 &v_R, float3 &v_t, uint8_t* sh_packed = nullptr, @@ -148,46 +127,16 @@ struct _Base3DGS : public _BasePrimitive3DGS { int64_t sh_base = 0, int64_t sh_bounds_stride = 256 ) { - if constexpr (camera_model == CameraModelType::PINHOLE) - Slang3DGS::projection_3dgs_persp_vjp( - antialiased, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - v_screen.xy, v_screen.depth, v_screen.conic, v_screen.opac, - &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, - &v_R, &v_t - ); - else if constexpr (camera_model == CameraModelType::FISHEYE) - Slang3DGS::projection_3dgs_fisheye_vjp( - antialiased, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - v_screen.xy, v_screen.depth, v_screen.conic, v_screen.opac, - &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, - &v_R, &v_t - ); - else if constexpr (camera_model == CameraModelType::EQUISOLID) - Slang3DGS::projection_3dgs_equisolid_vjp( - antialiased, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - v_screen.xy, v_screen.depth, v_screen.conic, v_screen.opac, - &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, - &v_R, &v_t - ); - else if constexpr (camera_model == CameraModelType::EQUIRECTANGULAR) - Slang3DGS::projection_3dgs_equirect_vjp( - antialiased, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - v_screen.xy, v_screen.depth, v_screen.conic, v_screen.opac, - &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, - &v_R, &v_t - ); + Slang3DGSProj::vjp_2d( + antialiased, + this->mean, this->quat, this->scale, this->opacity, + cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, + cam.dist_coeffs.v, + cam.width, cam.height, + v_screen.xy, v_screen.depth, v_screen.conic, v_screen.opac, + &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, + &v_R, &v_t + ); // SH: atomic for global memory, add for local/shared memory #define _ARGS_F32 ( \ this->mean, cam.R, cam.t, this->features_dc, (float3*)this->features_sh, \ diff --git a/src/primitives/Primitive3DGUT.cuh b/src/primitives/Primitive3DGUT.cuh index 4b5eec60..720e1171 100644 --- a/src/primitives/Primitive3DGUT.cuh +++ b/src/primitives/Primitive3DGUT.cuh @@ -13,6 +13,7 @@ namespace SlangHarmonics { #endif #include "primitives/PrimitiveBase3DGS.cuh" +#include "primitives/PrimitiveProjection.cuh" template struct Vanilla3DGUT : public _BasePrimitive3DGUT { @@ -45,9 +46,10 @@ struct Vanilla3DGUT : public _BasePrimitive3DGUT { // See Primitive3DGS::project() for VALUE_BITS semantics. Identical // contract; the 3dgut path uses a different projection geometry but // shares the SH eval pipeline. - template + template inline __device__ void project( - ProjCamera cam, + ProjCameraT cam, Vanilla3DGUT::Screen& proj, float4& aabb, float& sorting_depth, float& radius, uint8_t* sh_packed = nullptr, float2* sh_bounds = nullptr, @@ -56,38 +58,14 @@ struct Vanilla3DGUT : public _BasePrimitive3DGUT { ) { float2 xy; float depth; - if constexpr (camera_model == CameraModelType::PINHOLE) - Slang3DGS::projection_3dgut_persp( - false, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - &aabb, &sorting_depth, &radius, &xy, &depth, &proj.scale, &proj.opacity - ); - else if constexpr (camera_model == CameraModelType::FISHEYE) - Slang3DGS::projection_3dgut_fisheye( - false, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - &aabb, &sorting_depth, &radius, &xy, &depth, &proj.scale, &proj.opacity - ); - else if constexpr (camera_model == CameraModelType::EQUISOLID) - Slang3DGS::projection_3dgut_equisolid( - false, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - &aabb, &sorting_depth, &radius, &xy, &depth, &proj.scale, &proj.opacity - ); - else if constexpr (camera_model == CameraModelType::EQUIRECTANGULAR) - Slang3DGS::projection_3dgut_equirect( - false, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - &aabb, &sorting_depth, &radius, &xy, &depth, &proj.scale, &proj.opacity - ); + Slang3DGSProj::fwd_3d( + false, + this->mean, this->quat, this->scale, this->opacity, + cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, + cam.dist_coeffs.v, + cam.width, cam.height, + &aabb, &sorting_depth, &radius, &xy, &depth, &proj.scale, &proj.opacity + ); if (aabb.z > aabb.x && aabb.w > aabb.y) { if constexpr (VALUE_BITS == 32) { if constexpr (sh_degree == 0) proj.rgb = SlangHarmonics::sh0_to_color @@ -126,9 +104,10 @@ struct Vanilla3DGUT : public _BasePrimitive3DGUT { } } - template + template inline __device__ void project_vjp( - ProjCamera cam, + ProjCameraT cam, Vanilla3DGUT::Screen v_proj, Vanilla3DGUT::World& v_world, float3x3 &v_R, float3 &v_t, uint8_t* sh_packed = nullptr, @@ -136,46 +115,16 @@ struct Vanilla3DGUT : public _BasePrimitive3DGUT { int64_t sh_base = 0, int64_t sh_bounds_stride = 256 ) { - if constexpr (camera_model == CameraModelType::PINHOLE) - Slang3DGS::projection_3dgut_persp_vjp( - false, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - make_float2(0), 0.0f, v_proj.scale, v_proj.opacity, - &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, - &v_R, &v_t - ); - else if constexpr (camera_model == CameraModelType::FISHEYE) - Slang3DGS::projection_3dgut_fisheye_vjp( - false, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - make_float2(0), 0.0f, v_proj.scale, v_proj.opacity, - &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, - &v_R, &v_t - ); - else if constexpr (camera_model == CameraModelType::EQUISOLID) - Slang3DGS::projection_3dgut_equisolid_vjp( - false, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - make_float2(0), 0.0f, v_proj.scale, v_proj.opacity, - &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, - &v_R, &v_t - ); - else if constexpr (camera_model == CameraModelType::EQUIRECTANGULAR) - Slang3DGS::projection_3dgut_equirect_vjp( - false, - this->mean, this->quat, this->scale, this->opacity, - cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, cam.dist_coeffs, - cam.width, cam.height, - make_float2(0), 0.0f, v_proj.scale, v_proj.opacity, - &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, - &v_R, &v_t - ); + Slang3DGSProj::vjp_3d( + false, + this->mean, this->quat, this->scale, this->opacity, + cam.R, cam.t, cam.fx, cam.fy, cam.cx, cam.cy, + cam.dist_coeffs.v, + cam.width, cam.height, + make_float2(0), 0.0f, v_proj.scale, v_proj.opacity, + &v_world.mean, &v_world.quat, &v_world.scale, &v_world.opacity, + &v_R, &v_t + ); // SH: atomic for global memory, add for local/shared memory #define _ARGS_F32 ( \ this->mean, cam.R, cam.t, this->features_dc, (float3*)this->features_sh, \ diff --git a/src/primitives/PrimitiveProjection.cuh b/src/primitives/PrimitiveProjection.cuh new file mode 100644 index 00000000..48d3fe4a --- /dev/null +++ b/src/primitives/PrimitiveProjection.cuh @@ -0,0 +1,73 @@ +#pragma once + +// (camera model, distortion tier) -> the matching projection_3dgs / 3dgut +// export in shaders/primitive_3dgs.slang. +// +// Only the pairs the CUDA build instantiates exist here; the set matches +// camera_distortion_is_compiled() in core/CameraModel.h, the export list in +// shaders/primitive_3dgs.slang and kCameraVariants in +// tools/codegen/generate_kernel_instantiation.py. A combination outside it is a +// compile error rather than a silent fallback, so the host promotion in +// bake_post_split cannot drift from what was built. +// +// INCLUDE ORDER: names Slang3DGS::* without opening it -- include after the +// TU's own `namespace Slang3DGS { ... }` block. + +#include "core/Common.cuh" +#include "primitives/Primitive.cuh" + +#ifdef __CUDACC__ + +template +struct Slang3DGSProj { + static_assert(sizeof(CameraDistortionCoeffsT) == 0, + "this (camera model, distortion tier) pair is not compiled -- " + "see camera_distortion_is_compiled() in core/CameraModel.h"); +}; + +#define _SS_DEF_3DGS_PROJ(MODEL, TIER, MODEL_SUFFIX, TIER_SUFFIX) \ +template<> \ +struct Slang3DGSProj { \ + using Coeffs = CameraDistortionCoeffsT; \ + \ + template \ + static __device__ __forceinline__ void fwd_2d( \ + bool antialiased, Args... args \ + ) { \ + Slang3DGS::projection_3dgs_##MODEL_SUFFIX##TIER_SUFFIX(antialiased, args...); \ + } \ + template \ + static __device__ __forceinline__ void fwd_3d( \ + bool antialiased, Args... args \ + ) { \ + Slang3DGS::projection_3dgut_##MODEL_SUFFIX##TIER_SUFFIX(antialiased, args...); \ + } \ + template \ + static __device__ __forceinline__ void vjp_2d( \ + bool antialiased, Args... args \ + ) { \ + Slang3DGS::projection_3dgs_##MODEL_SUFFIX##TIER_SUFFIX##_vjp(antialiased, args...); \ + } \ + template \ + static __device__ __forceinline__ void vjp_3d( \ + bool antialiased, Args... args \ + ) { \ + Slang3DGS::projection_3dgut_##MODEL_SUFFIX##TIER_SUFFIX##_vjp(antialiased, args...); \ + } \ +}; + +#define _SS_DEF_3DGS_PROJ_TIERS(MODEL, MODEL_SUFFIX) \ + _SS_DEF_3DGS_PROJ(MODEL, None, MODEL_SUFFIX, _none) \ + _SS_DEF_3DGS_PROJ(MODEL, OpenCV, MODEL_SUFFIX, _opencv)\ + _SS_DEF_3DGS_PROJ(MODEL, ThinPrism, MODEL_SUFFIX, _prism) + +_SS_DEF_3DGS_PROJ_TIERS(PINHOLE, persp) +_SS_DEF_3DGS_PROJ(PINHOLE, Rational, persp, _rational) +_SS_DEF_3DGS_PROJ_TIERS(FISHEYE, fisheye) +_SS_DEF_3DGS_PROJ_TIERS(EQUISOLID, equisolid) +_SS_DEF_3DGS_PROJ(EQUIRECTANGULAR, None, equirect, _none) + +#undef _SS_DEF_3DGS_PROJ_TIERS +#undef _SS_DEF_3DGS_PROJ + +#endif // __CUDACC__ diff --git a/src/sfm/ba/CpuCamera.h b/src/sfm/ba/CpuCamera.h index e9d31395..9faf0adf 100644 --- a/src/sfm/ba/CpuCamera.h +++ b/src/sfm/ba/CpuCamera.h @@ -245,7 +245,7 @@ struct FisheyeModel { }; struct FullOpenCVModel { - static constexpr int kNumIntr = 9; + static constexpr int kNumIntr = 12; template static void project(const T* c, const T p[3], T out[2]) { const T& fx = c[0]; const T& fy = c[1]; @@ -254,12 +254,16 @@ struct FullOpenCVModel { const T& p1 = c[4]; const T& p2 = c[5]; const T& k3 = c[6]; - const T& cx = c[7]; - const T& cy = c[8]; + const T& k4 = c[7]; + const T& k5 = c[8]; + const T& k6 = c[9]; + const T& cx = c[10]; + const T& cy = c[11]; T xp = p[0] / p[2]; T yp = p[1] / p[2]; T r2 = xp * xp + yp * yp; - T radial = T(1.0) + r2 * (k1 + r2 * (k2 + r2 * k3)); + T radial = (T(1.0) + r2 * (k1 + r2 * (k2 + r2 * k3))) / + (T(1.0) + r2 * (k4 + r2 * (k5 + r2 * k6))); T dx = xp * radial + 2.0 * p1 * xp * yp + p2 * (r2 + 2.0 * xp * xp); T dy = yp * radial + p1 * (r2 + 2.0 * yp * yp) + 2.0 * p2 * xp * yp; out[0] = fx * dx + cx; diff --git a/src/sfm/ba/Problem.h b/src/sfm/ba/Problem.h index 8fd96adf..a41b2356 100644 --- a/src/sfm/ba/Problem.h +++ b/src/sfm/ba/Problem.h @@ -34,12 +34,12 @@ static const ModelDesc kModels[] = { {"simple_pinhole", 3, "cost_simple_pinhole", "jac_simple_pinhole"}, // COLMAP SIMPLE_PINHOLE {"pinhole", 4, "cost_pinhole", "jac_pinhole"}, // COLMAP PINHOLE {"opencv_fisheye", 8, "cost_opencv_fisheye", "jac_opencv_fisheye"}, // COLMAP OPENCV_FISHEYE (D29-C) - {"full_opencv", 9, "cost_full_opencv", "jac_full_opencv"}, // COLMAP FULL_OPENCV, reduced (D34) + {"full_opencv", 12, "cost_full_opencv", "jac_full_opencv"}, // COLMAP FULL_OPENCV (D34) {"thin_prism_fisheye", 12, "cost_thin_prism_fisheye", "jac_thin_prism_fisheye"}, // COLMAP THIN_PRISM_FISHEYE (D34) {"equirect", 2, "cost_equirect", "jac_equirect"}, // COLMAP EQUIRECTANGULAR (D49) }; static const int kNumModels = sizeof(kModels) / sizeof(kModels[0]); -static const uint32_t kMaxCamDof = 18; // 6 pose + up to 12 intrinsics (thin-prism); must match ba.slang +static const uint32_t kMaxCamDof = 18; // 6 pose + up to 12 intrinsics; must match ba.slang struct BAProblem { uint32_t num_images = 0, num_points = 0, num_obs = 0; diff --git a/src/sfm/core/Camera.h b/src/sfm/core/Camera.h index e5b73bfc..c98b0373 100644 --- a/src/sfm/core/Camera.h +++ b/src/sfm/core/Camera.h @@ -47,7 +47,8 @@ struct Camera { double fx = 0, fy = 0, cx = 0, cy = 0; double k1 = 0, k2 = 0; // radial double p1 = 0, p2 = 0; // tangential (OpenCV / FullOpenCV / ThinPrismFisheye) - double k3 = 0, k4 = 0; // extra radial (FullOpenCV uses k3; fisheye uses k3,k4) + double k3 = 0, k4 = 0; // extra radial (fisheye k3,k4; FullOpenCV k3 + denominator k4) + double k5 = 0, k6 = 0; // FullOpenCV rational denominator (with k4) double sx1 = 0, sy1 = 0; // thin-prism (ThinPrismFisheye only) // How many of this camera's pixels one *measurement* pixel is worth: the @@ -151,7 +152,8 @@ struct Camera { } // Camera-frame 3D point -> pixel. - // - pinhole family (incl. FullOpenCV's k3): Brown-Conrady radial+tangential. + // - pinhole family: Brown-Conrady radial+tangential; FullOpenCV divides the + // radial term by the rational denominator 1 + k4 r^2 + k5 r^4 + k6 r^6. // - OpenCV_FISHEYE: Kannala-Brandt, radial-only in theta. // - THIN_PRISM_FISHEYE: KB radial + tangential + thin-prism, all in the // equidistant coords (uf,vf) = theta*(x,y)/r. @@ -185,7 +187,9 @@ struct Camera { } double xp = p.x / p.z, yp = p.y / p.z; double r2 = xp * xp + yp * yp; - double radial = 1.0 + r2 * (k1 + r2 * (k2 + r2 * k3)); // k3=0 except FullOpenCV + double radial = (model == CamModel::FullOpenCV) ? + (1.0 + r2 * (k1 + r2 * (k2 + r2 * k3))) / (1.0 + r2 * (k4 + r2 * (k5 + r2 * k6))) : + (1.0 + r2 * (k1 + r2 * (k2 + r2 * (k3 + r2 * k4)))); double dx = xp * radial + 2.0 * p1 * xp * yp + p2 * (r2 + 2.0 * xp * xp); double dy = yp * radial + p1 * (r2 + 2.0 * yp * yp) + 2.0 * p2 * xp * yp; return {fx * dx + cx, fy * dy + cy}; @@ -202,16 +206,21 @@ struct Camera { return {b.x / b.z, b.y / b.z}; } double u = (px.x - cx) / fx, v = (px.y - cy) / fy; - if (k1 == 0 && k2 == 0 && k3 == 0 && p1 == 0 && p2 == 0) return {u, v}; + if (k1 == 0 && k2 == 0 && k3 == 0 && k4 == 0 && k5 == 0 && k6 == 0 && + p1 == 0 && p2 == 0) + return {u, v}; // 5 fixed-point steps: a contraction for the distortion magnitudes we // see, and exactly what the radial-only path did before (so the RADIAL // model stays bit-identical -- the tangential/k3 terms are literally zero // there). Revisit the count only if a strongly-distorted camera shows // unconverged undistortion. + const bool rational = model == CamModel::FullOpenCV; double xu = u, yu = v; for (int i = 0; i < 5; i++) { double r2 = xu * xu + yu * yu; - double radial = 1.0 + r2 * (k1 + r2 * (k2 + r2 * k3)); + double radial = rational ? + (1.0 + r2 * (k1 + r2 * (k2 + r2 * k3))) / (1.0 + r2 * (k4 + r2 * (k5 + r2 * k6))) : + (1.0 + r2 * (k1 + r2 * (k2 + r2 * (k3 + r2 * k4)))); double dtx = 2.0 * p1 * xu * yu + p2 * (r2 + 2.0 * xu * xu); double dty = p1 * (r2 + 2.0 * yu * yu) + 2.0 * p2 * xu * yu; xu = (u - dtx) / radial; @@ -294,9 +303,6 @@ struct CamModelInfo { // 0 snavely, 1 snavely_f, 2 pinhole_radial, 3 opencv, 4 simple_pinhole, // 5 pinhole, 6 opencv_fisheye, 7 full_opencv, 8 thin_prism_fisheye, // 9 equirect -// ba_params == colmap_params for every model except FullOpenCV, which BA fits as -// a reduced rational model (k1,k2,k3 + p1,p2) but emits as COLMAP FULL_OPENCV -// with k4,k5,k6 = 0 (compatible with our parser). // // ba_pp is how many *trailing* BA parameters are the principal point, and // ba_refinable says whether BA may touch this model's parameters at all. The BA @@ -312,7 +318,7 @@ static constexpr CamModelInfo kCamModelInfo[] = { {CamModel::Radial, 3, 2, 5, 2, true, 5, "radial"}, {CamModel::OpenCV, 4, 3, 8, 2, true, 8, "opencv"}, {CamModel::OpenCVFisheye, 5, 6, 8, 2, true, 8, "opencv-fisheye"}, - {CamModel::FullOpenCV, 6, 7, 9, 2, true, 12, "full-opencv"}, + {CamModel::FullOpenCV, 6, 7, 12, 2, true, 12, "full-opencv"}, {CamModel::ThinPrismFisheye, 10, 8, 12, 2, true, 12, "thin-prism-fisheye"}, {CamModel::Equirect, 17, 9, 2, 0, false, 2, "equirectangular"}, }; @@ -378,8 +384,8 @@ inline void packIntrinsics(const Camera& c, double* d) { d[6] = c.cx; d[7] = c.cy; break; case CamModel::FullOpenCV: d[0] = c.fx; d[1] = c.fy; d[2] = c.k1; d[3] = c.k2; d[4] = c.p1; d[5] = c.p2; - d[6] = c.k3; - d[7] = c.cx; d[8] = c.cy; break; + d[6] = c.k3; d[7] = c.k4; d[8] = c.k5; d[9] = c.k6; + d[10] = c.cx; d[11] = c.cy; break; case CamModel::ThinPrismFisheye: d[0] = c.fx; d[1] = c.fy; d[2] = c.k1; d[3] = c.k2; d[4] = c.p1; d[5] = c.p2; @@ -391,7 +397,7 @@ inline void packIntrinsics(const Camera& c, double* d) { } } inline void unpackIntrinsics(Camera& c, const double* d) { // c.model set by caller - c.k1 = c.k2 = c.p1 = c.p2 = c.k3 = c.k4 = c.sx1 = c.sy1 = 0; + c.k1 = c.k2 = c.p1 = c.p2 = c.k3 = c.k4 = c.k5 = c.k6 = c.sx1 = c.sy1 = 0; switch (c.model) { case CamModel::SimplePinhole: c.setFocal(d[0]); c.cx = d[1]; c.cy = d[2]; break; @@ -407,8 +413,8 @@ inline void unpackIntrinsics(Camera& c, const double* d) { // c.model set by ca c.cx = d[6]; c.cy = d[7]; break; case CamModel::FullOpenCV: c.fx = d[0]; c.fy = d[1]; c.k1 = d[2]; c.k2 = d[3]; c.p1 = d[4]; c.p2 = d[5]; - c.k3 = d[6]; - c.cx = d[7]; c.cy = d[8]; break; + c.k3 = d[6]; c.k4 = d[7]; c.k5 = d[8]; c.k6 = d[9]; + c.cx = d[10]; c.cy = d[11]; break; case CamModel::ThinPrismFisheye: c.fx = d[0]; c.fy = d[1]; c.k1 = d[2]; c.k2 = d[3]; c.p1 = d[4]; c.p2 = d[5]; @@ -420,9 +426,7 @@ inline void unpackIntrinsics(Camera& c, const double* d) { // c.model set by ca } // Camera fields -> the *COLMAP* cameras.bin layout (camColmapParams slots): -// focal length(s), cx, cy, then the extra parameters. FULL_OPENCV's reduced BA -// params are its first 9, with the rational k4,k5,k6 emitted as 0 -// (dataset-parser compatibility, D34). +// focal length(s), cx, cy, then the extra parameters. inline void packColmap(const Camera& c, double* d) { switch (c.model) { case CamModel::SimplePinhole: d[0] = c.focal(); d[1] = c.cx; d[2] = c.cy; break; @@ -435,7 +439,7 @@ inline void packColmap(const Camera& c, double* d) { d[4] = c.k1; d[5] = c.k2; d[6] = c.k3; d[7] = c.k4; break; case CamModel::FullOpenCV: d[0] = c.fx; d[1] = c.fy; d[2] = c.cx; d[3] = c.cy; d[4] = c.k1; d[5] = c.k2; d[6] = c.p1; d[7] = c.p2; - d[8] = c.k3; d[9] = d[10] = d[11] = 0; break; // k4,k5,k6 + d[8] = c.k3; d[9] = c.k4; d[10] = c.k5; d[11] = c.k6; break; case CamModel::ThinPrismFisheye: d[0] = c.fx; d[1] = c.fy; d[2] = c.cx; d[3] = c.cy; d[4] = c.k1; d[5] = c.k2; d[6] = c.p1; d[7] = c.p2; @@ -443,10 +447,9 @@ inline void packColmap(const Camera& c, double* d) { case CamModel::Equirect: d[0] = 2.0 * M_PI * c.fx; d[1] = M_PI * c.fy; break; } } -// COLMAP layout -> fields. FULL_OPENCV's rational k4,k5,k6 tail is ignored (we -// do not model it). +// COLMAP layout -> fields. inline void unpackColmap(Camera& c, const double* d) { - c.k1 = c.k2 = c.p1 = c.p2 = c.k3 = c.k4 = c.sx1 = c.sy1 = 0; + c.k1 = c.k2 = c.p1 = c.p2 = c.k3 = c.k4 = c.k5 = c.k6 = c.sx1 = c.sy1 = 0; switch (c.model) { case CamModel::SimplePinhole: c.setFocal(d[0]); c.cx = d[1]; c.cy = d[2]; break; case CamModel::Pinhole: c.fx = d[0]; c.fy = d[1]; c.cx = d[2]; c.cy = d[3]; break; @@ -458,7 +461,7 @@ inline void unpackColmap(Camera& c, const double* d) { c.k1 = d[4]; c.k2 = d[5]; c.k3 = d[6]; c.k4 = d[7]; break; case CamModel::FullOpenCV: c.fx = d[0]; c.fy = d[1]; c.cx = d[2]; c.cy = d[3]; c.k1 = d[4]; c.k2 = d[5]; c.p1 = d[6]; c.p2 = d[7]; - c.k3 = d[8]; break; + c.k3 = d[8]; c.k4 = d[9]; c.k5 = d[10]; c.k6 = d[11]; break; case CamModel::ThinPrismFisheye: c.fx = d[0]; c.fy = d[1]; c.cx = d[2]; c.cy = d[3]; c.k1 = d[4]; c.k2 = d[5]; c.p1 = d[6]; c.p2 = d[7]; diff --git a/src/sfm/map/Mapper.h b/src/sfm/map/Mapper.h index 226bd8f9..90be9b6b 100644 --- a/src/sfm/map/Mapper.h +++ b/src/sfm/map/Mapper.h @@ -3567,7 +3567,10 @@ private: c.setFocal(d.focal()); fixed++; } - for (double* k : {&c.k1, &c.k2, &c.k3, &c.k4, &c.p1, &c.p2, &c.sx1, &c.sy1}) + // FullOpenCV's k4..k6 are the rational denominator, but in the same + // normalized-radius units as k1..k3, so one threshold covers both. + for (double* k : {&c.k1, &c.k2, &c.k3, &c.k4, &c.k5, &c.k6, &c.p1, &c.p2, + &c.sx1, &c.sy1}) if (std::fabs(*k) > opt_.max_extra_param) { *k = 0; fixed++; } // The mapper never has evidence to move the principal point far // from the center (COLMAP does not refine it at all during diff --git a/src/sfm/shaders/ba/ba.slang b/src/sfm/shaders/ba/ba.slang index e1aa9d5a..65635c1f 100644 --- a/src/sfm/shaders/ba/ba.slang +++ b/src/sfm/shaders/ba/ba.slang @@ -33,17 +33,14 @@ // Bounds on 6 + kNumIntr for the model-agnostic Schur kernels, which size // register arrays by a compile-time dof. These kernels are *not* per-model // (a point's observations may span groups with different models), so they take -// the dof as a generic value parameter MD and are instantiated at two tiers: -// compact -- covers every model up to RADIAL (dof 11); byte-identical to the -// pre-OpenCV kernels, so problems without OpenCV pay nothing. -// wide -- covers OpenCV (dof 14). +// the dof as a generic value parameter MD and are instantiated at three tiers, +// so a problem pays for only the widest camera it actually uses: +// compact 12 -- up to RADIAL (dof 11); byte-identical to the pre-OpenCV kernels +// mid 14 -- OpenCV / OpenCV_FISHEYE +// wide 18 -- FullOpenCV / ThinPrismFisheye // The host (sfm/ba/Solver.h) picks the tier from the problem's actual maximum dof. // Adding a model with dof > kDofWide means bumping kDofWide (and kMaxCamDof in -// sfm/ba/Problem.h). kDofCompact must stay >= the largest non-OpenCV model's dof. -// Three dof tiers so a problem pays for only the widest camera it actually uses: -// compact 12 -- up to RADIAL (dof 11); byte-identical to the pre-OpenCV kernels -// mid 14 -- OpenCV / OpenCV_FISHEYE (dof 14) -// wide 18 -- FullOpenCV (15) / ThinPrismFisheye (18) +// sfm/ba/Problem.h). static const int kDofCompact = 12; static const int kDofMid = 14; static const int kDofWide = 18; diff --git a/src/sfm/shaders/common/camera.slang b/src/sfm/shaders/common/camera.slang index bd2baf58..bc9f93f2 100644 --- a/src/sfm/shaders/common/camera.slang +++ b/src/sfm/shaders/common/camera.slang @@ -179,26 +179,28 @@ struct FisheyeModel : ICameraModel { } }; -// COLMAP FULL_OPENCV, reduced to the polynomial (non-rational) part: pinhole -// Brown-Conrady with three radial (k1,k2,k3) and two tangential (p1,p2) terms. -// Host mirror: sfm/core/Camera.h CamModel::FullOpenCV. Emitted as FULL_OPENCV with -// k4..k6 = 0. +// COLMAP FULL_OPENCV: pinhole Brown-Conrady with a rational radial term -- +// (1 + k1 r^2 + k2 r^4 + k3 r^6) / (1 + k4 r^2 + k5 r^4 + k6 r^6) -- plus the +// two tangential terms. Host mirror: sfm/core/Camera.h CamModel::FullOpenCV. struct FullOpenCVModel : ICameraModel { - static const int kNumIntr = 9; - Real fx; Real fy; Real cx; Real cy; Real k1; Real k2; Real p1; Real p2; Real k3; + static const int kNumIntr = 12; + Real fx; Real fy; Real cx; Real cy; + Real k1; Real k2; Real p1; Real p2; Real k3; Real k4; Real k5; Real k6; - [Differentiable] static FullOpenCVModel fromArray(Real v[9]) { + [Differentiable] static FullOpenCVModel fromArray(Real v[12]) { FullOpenCVModel m; m.fx = v[0]; m.fy = v[1]; - m.k1 = v[2]; m.k2 = v[3]; m.p1 = v[4]; m.p2 = v[5]; m.k3 = v[6]; - m.cx = v[7]; m.cy = v[8]; + m.k1 = v[2]; m.k2 = v[3]; m.p1 = v[4]; m.p2 = v[5]; + m.k3 = v[6]; m.k4 = v[7]; m.k5 = v[8]; m.k6 = v[9]; + m.cx = v[10]; m.cy = v[11]; return m; } [Differentiable] RVec2 project(RVec3 p) { Real xp = p.x / p.z; Real yp = p.y / p.z; Real r2 = xp * xp + yp * yp; - Real radial = Real(1.0) + r2 * (k1 + r2 * (k2 + r2 * k3)); + Real radial = (Real(1.0) + r2 * (k1 + r2 * (k2 + r2 * k3))) / + (Real(1.0) + r2 * (k4 + r2 * (k5 + r2 * k6))); Real dx = xp * radial + Real(2.0) * p1 * xp * yp + p2 * (r2 + Real(2.0) * xp * xp); Real dy = yp * radial + p1 * (r2 + Real(2.0) * yp * yp) + Real(2.0) * p2 * xp * yp; return rvec2(fx * dx + cx, fy * dy + cy); diff --git a/src/sfm/tests/sfm_ba_cpu_test.cpp b/src/sfm/tests/sfm_ba_cpu_test.cpp index 771bc00b..56fc0315 100644 --- a/src/sfm/tests/sfm_ba_cpu_test.cpp +++ b/src/sfm/tests/sfm_ba_cpu_test.cpp @@ -164,7 +164,8 @@ const double* defaultIntr(uint32_t model, int& n) { static const double simple[3] = {600.0, 320.0, 240.0}; static const double pinhole[4] = {600.0, 605.0, 320.0, 240.0}; static const double fisheye[8] = {300.0, 305.0, 0.01, -0.002, 3e-4, -1e-5, 320.0, 240.0}; - static const double full[9] = {600.0, 605.0, -0.02, 0.003, 1e-4, -2e-4, 1e-4, 320.0, 240.0}; + static const double full[12] = {600.0, 605.0, -0.02, 0.003, 1e-4, -2e-4, + 1e-4, 5e-3, -8e-4, 2e-5, 320.0, 240.0}; static const double prism[12] = {300.0, 305.0, 0.01, -0.002, 3e-4, -1e-5, 2e-4, -1e-6, 1e-4, -2e-4, 320.0, 240.0}; static const double equirect[2] = {640.0, 480.0}; @@ -176,7 +177,7 @@ const double* defaultIntr(uint32_t model, int& n) { case 4: n = 3; return simple; case 5: n = 4; return pinhole; case 6: n = 8; return fisheye; - case 7: n = 9; return full; + case 7: n = 12; return full; case 8: n = 12; return prism; default: n = 2; return equirect; } @@ -583,7 +584,7 @@ int run(int argc, char** argv) { } if (!quick) - for (uint32_t model : {3u, 6u, 8u}) + for (uint32_t model : {3u, 6u, 7u, 8u}) for (uint32_t groups : {1u, 12u}) testFullSolve(model, groups); printf("%s\n", g_fail ? "FAIL" : "PASS"); diff --git a/src/sfm/tests/sfm_sift_test.cpp b/src/sfm/tests/sfm_sift_test.cpp index 5ad83617..8ceeffa2 100644 --- a/src/sfm/tests/sfm_sift_test.cpp +++ b/src/sfm/tests/sfm_sift_test.cpp @@ -419,6 +419,26 @@ int cmdSelftest(int argc, char** argv) { projok ? "ok" : "BAD"); if (!projok) fails++; + // FULL_OPENCV adds the rational denominator (k4,k5,k6); the fixed-point + // undistortion must invert that form too. + { + Camera fc = cam; + fc.model = CamModel::FullOpenCV; + fc.k3 = 0.004; fc.k4 = 0.02; fc.k5 = -0.003; fc.k6 = 0.0005; + double err = 0; + for (int gy = 1; gy < 12; gy++) + for (int gx = 1; gx < 12; gx++) { + Vec2 px = {fc.cx + (gx - 6) * 100.0, fc.cy + (gy - 6) * 80.0}; + Vec2 xn = fc.unproject(px); + Vec2 back = fc.project({xn.x, xn.y, 1.0}); + err = std::max(err, std::hypot(back.x - px.x, back.y - px.y)); + } + bool rok = err < 1e-3; + printf(" camera project/unproject inverse (full-opencv rational): max %.2e px -> %s\n", + err, rok ? "ok" : "BAD"); + if (!rok) fails++; + } + // Both fisheye models: project(ray) then bearing() must recover the ray, // INCLUDING rays past 90 deg (z<0), which the pinhole family cannot // represent -- the whole point of D31's bearings + D29-C/D34. @@ -510,7 +530,8 @@ int cmdSelftest(int argc, char** argv) { Camera fe = Camera::defaultFor(5, 1920, 1920, 560.0, CamModel::OpenCVFisheye); fe.k1 = 0.02; fe.k2 = -0.01; fe.k3 = 0.003; fe.k4 = -0.001; Camera fo = Camera::defaultFor(6, 1600, 1200, 1300.0, CamModel::FullOpenCV); - fo.k1 = -0.11; fo.k2 = 0.02; fo.p1 = 0.001; fo.p2 = -0.0005; fo.k3 = 0.004; + fo.k1 = -0.11; fo.k2 = 0.02; fo.p1 = 0.001; fo.p2 = -0.0005; + fo.k3 = 0.004; fo.k4 = 0.021; fo.k5 = -0.003; fo.k6 = 0.0006; Camera tp = Camera::defaultFor(7, 1920, 1920, 560.0, CamModel::ThinPrismFisheye); tp.k1 = 0.02; tp.k2 = -0.005; tp.p1 = 0.001; tp.p2 = -0.0008; tp.k3 = 0.001; tp.k4 = -0.0003; tp.sx1 = 0.002; tp.sy1 = -0.0015; @@ -539,7 +560,8 @@ int cmdSelftest(int argc, char** argv) { eq(rr.cameras[5].k3, 0.003) && eq(rr.cameras[5].k4, -0.001) && rr.cameras[6].model == CamModel::FullOpenCV && eq(rr.cameras[6].k1, -0.11) && eq(rr.cameras[6].p1, 0.001) && - eq(rr.cameras[6].k3, 0.004) && + eq(rr.cameras[6].k3, 0.004) && eq(rr.cameras[6].k4, 0.021) && + eq(rr.cameras[6].k5, -0.003) && eq(rr.cameras[6].k6, 0.0006) && rr.cameras[7].model == CamModel::ThinPrismFisheye && eq(rr.cameras[7].k4, -0.0003) && eq(rr.cameras[7].sx1, 0.002) && eq(rr.cameras[7].sy1, -0.0015); @@ -563,7 +585,8 @@ int cmdSelftest(int argc, char** argv) { if (!(eq(back.fx, c.fx) && eq(back.fy, c.fy) && eq(back.cx, c.cx) && eq(back.cy, c.cy) && eq(back.k1, c.k1) && eq(back.k2, c.k2) && eq(back.p1, c.p1) && eq(back.p2, c.p2) && eq(back.k3, c.k3) && - eq(back.k4, c.k4) && eq(back.sx1, c.sx1) && eq(back.sy1, c.sy1))) + eq(back.k4, c.k4) && eq(back.k5, c.k5) && eq(back.k6, c.k6) && + eq(back.sx1, c.sx1) && eq(back.sy1, c.sy1))) ba_ok = false; const int n = camNumParams(c.model); const int nf = camNumFreeParams(c.model); @@ -579,8 +602,8 @@ int cmdSelftest(int argc, char** argv) { if (!ba_ok) fails++; } - // FULL_OPENCV must be emitted as COLMAP model 6 with 12 params, the - // rational k4,k5,k6 tail zeroed (dataset-parser compatibility, D34). + // FULL_OPENCV must be emitted as COLMAP model 6 with all 12 params in + // COLMAP's order (fx,fy,cx,cy,k1,k2,p1,p2,k3,k4,k5,k6). { std::ifstream cf(cdir + "/cameras.bin", std::ios::binary); bool full_ok = false, eq_ok = false; @@ -594,12 +617,14 @@ int cmdSelftest(int argc, char** argv) { double ps[12] = {0}; for (int k = 0; k < np; k++) cf.read((char*)&ps[k], 8); if (mdl == 6) // FULL_OPENCV - full_ok = np == 12 && ps[8] == 0.004 && ps[9] == 0 && ps[10] == 0 && ps[11] == 0; + full_ok = np == 12 && ps[4] == -0.11 && ps[5] == 0.02 && ps[6] == 0.001 && + ps[7] == -0.0005 && ps[8] == 0.004 && ps[9] == 0.021 && + ps[10] == -0.003 && ps[11] == 0.0006; if (mdl == 17) // EQUIRECTANGULAR: params are exactly (w, h) eq_ok = np == 2 && ps[0] == (double)cw && ps[1] == (double)ch && cw == 5760 && ch == 2880; } - printf(" FULL_OPENCV emit (12 params, k4-k6=0): %s\n", full_ok ? "ok" : "BAD"); + printf(" FULL_OPENCV emit (12 params, COLMAP order): %s\n", full_ok ? "ok" : "BAD"); if (!full_ok) fails++; printf(" EQUIRECTANGULAR emit (model 17, params = w,h): %s\n", eq_ok ? "ok" : "BAD"); if (!eq_ok) fails++; diff --git a/src/shaders/build.bash b/src/shaders/build.bash index 6b85a91e..17947318 100644 --- a/src/shaders/build.bash +++ b/src/shaders/build.bash @@ -15,6 +15,7 @@ mkdir -p "$out_dir" shaders=( "shaders/.slang:${out_dir}/slang.cu" "shaders/projection_utils.slang:${out_dir}/projection_utils.cu" + "shaders/camera_source.slang:${out_dir}/camera_source.cu" "shaders/per_pixel_losses.slang:${out_dir}/per_pixel_losses.cu" "shaders/per_splat_losses.slang:${out_dir}/per_splat_losses.cu" "shaders/pixel_wise.slang:${out_dir}/pixel_wise.cu" @@ -28,6 +29,7 @@ shaders=( mv_targets=( "${out_dir}/slang.cu" "${out_dir}/projection_utils.cu" + "${out_dir}/camera_source.cu" "${out_dir}/per_pixel_losses.cu" "${out_dir}/per_splat_losses.cu" "${out_dir}/pixel_wise.cu" diff --git a/src/shaders/camera_source.slang b/src/shaders/camera_source.slang new file mode 100644 index 00000000..19d867ce --- /dev/null +++ b/src/shaders/camera_source.slang @@ -0,0 +1,226 @@ +#pragma once +// ^ not working for [CudaDeviceExport] + +#ifndef _CAMERA_SOURCE_SLANG_INC + +#define _CAMERA_SOURCE_SLANG_INC + +// Forward projection of the camera models that no (camera model, distortion +// tier) pair represents. The parser fits those onto a pair and records the +// source here so the re-distort pass can resample from the TRUE source +// projection rather than from an approximation of it -- resampling through the +// fit would be a no-op. +// +// For a COLMAP model, `params` is COLMAP's own parameter array verbatim, so +// the host side copies `cameras.bin` through unchanged. Transcribed from +// colmap/src/colmap/sensor/models.h; the host mirror used by the fitter is +// srccam::project() in data/SourceCamera.cpp and the two must agree exactly or +// the fit is measured against a different camera than the images are resampled +// from. +// +// Kept out of projection_utils.slang deliberately: nothing on the training hot +// path calls this, and that header is included by every kernel TU. That also +// means the two fisheye mappings below are transcribed rather than shared; +// they must stay identical to fisheye_proj / equisolid_proj there. + +static const int kSourceMaxParams = 16; + +// COLMAP CameraModelId values. Only the ones with no exact tier appear. +static const int kSourceFOV = 7; +static const int kSourceRadTanThinPrismFisheye = 11; +static const int kSourceSimpleDivision = 12; +static const int kSourceDivision = 13; +static const int kSourceEUCM = 16; + +// Ours, numbered from 1000 so COLMAP can keep appending to its own enum +// (18, 19, ...) without ever colliding. +static const int kSourceSkewed = 1000; + +// kSourceSkewed's base camera, params[13]. +static const int kSkewBasePerspective = 0; +static const int kSkewBaseFisheye = 1; +static const int kSkewBaseEquisolid = 2; + +[ForceInline] +bool source_project_fov(float p[kSourceMaxParams], float3 ray, out float2 uv) { + uv = float2(0.0f); + if (ray.z < 1e-12f) + return false; + float x = ray.x / ray.z, y = ray.y / ray.z, omega = p[4]; + float r2 = x*x + y*y, om2 = omega * omega; + const float kEps = 1e-4f; + float factor; + if (om2 < kEps) { + factor = (om2 * r2) / 3.0f - om2 / 12.0f + 1.0f; + } else if (r2 < kEps) { + float t = tan(omega * 0.5f); + factor = (-2.0f * t * (4.0f * r2 * t * t - 3.0f)) / (3.0f * omega); + } else { + float r = sqrt(r2); + factor = atan(r * 2.0f * tan(omega * 0.5f)) / (r * omega); + } + uv = float2(p[0] * x * factor + p[2], p[1] * y * factor + p[3]); + return true; +} + +// Fitzgibbon division model. `simple` shares one focal length, which also +// shifts every later parameter down by one. +[ForceInline] +bool source_project_division(float p[kSourceMaxParams], bool simple, + float3 ray, out float2 uv) { + uv = float2(0.0f); + float fx = p[0], fy = simple ? p[0] : p[1]; + float cx = simple ? p[1] : p[2], cy = simple ? p[2] : p[3]; + float k = simple ? p[3] : p[4]; + float rho2 = ray.x*ray.x + ray.y*ray.y; + float disc = ray.z*ray.z - 4.0f * rho2 * k; + if (disc < 0.0f) + return false; + float r = 2.0f / (ray.z + sqrt(disc)); + uv = float2(fx * r * ray.x + cx, fy * r * ray.y + cy); + return true; +} + +[ForceInline] +bool source_project_eucm(float p[kSourceMaxParams], float3 ray, out float2 uv) { + uv = float2(0.0f); + if (ray.z < 1e-12f) + return false; + float alpha = p[4], beta = p[5]; + float rho2 = beta * (ray.x*ray.x + ray.y*ray.y) + ray.z*ray.z; + if (rho2 < 0.0f) + return false; + float den = alpha * sqrt(rho2) + (1.0f - alpha) * ray.z; + if (den < 1e-12f) + return false; + uv = float2(p[0] * ray.x / den + p[2], p[1] * ray.y / den + p[3]); + return true; +} + +// Aria Fisheye624. Unlike THIN_PRISM_FISHEYE, the tangential and thin-prism +// terms act on the ALREADY radially distorted point. +[ForceInline] +bool source_project_rad_tan_thin_prism(float p[kSourceMaxParams], float3 ray, + out float2 uv) { + uv = float2(0.0f); + if (ray.z < 1e-12f) + return false; + float xn = ray.x / ray.z, yn = ray.y / ray.z; + float r = sqrt(xn*xn + yn*yn); + float uu = xn, vv = yn; + if (r > 1e-12f) { + float th = atan(r); + uu *= th / r; vv *= th / r; + } + float th2 = uu*uu + vv*vv, pw = 1.0f, rad = 1.0f; + [ForceUnroll] for (int i = 0; i < 6; i++) { pw *= th2; rad += p[4 + i] * pw; } + float x = rad * uu, y = rad * vv; + float p0 = p[10], p1 = p[11]; + float s0 = p[12], s1 = p[13], s2 = p[14], s3 = p[15]; + float x2 = x*x, y2 = y*y, xy = x*y, r2 = x2 + y2, r4 = r2*r2; + float xd = x + 2.0f*p1*xy + p0*(r2 + 2.0f*x2) + s0*r2 + s1*r4; + float yd = y + 2.0f*p0*xy + p1*(r2 + 2.0f*y2) + s2*r2 + s3*r4; + uv = float2(p[0] * xd + p[2], p[1] * yd + p[3]); + return true; +} + +// Any supported camera plus a sensor skew, which no tier carries: Agisoft +// Metashape's b2. Its b1 is an fx correction and is already folded into +// params[0]; only the off-diagonal term needs re-distorting. +// +// p[0..3] fx fy cx cy +// p[4] skew -- pixels of u per unit distorted y +// p[5..12] coefficients, in DistThinPrism slot order (k1 k2 k3 k4 p1 p2 +// sx1 sy1) or, when p[14] is nonzero, DistRational's (k1..k6 p1 p2) +// p[13] base camera, kSkewBase* +// p[14] 0 = polynomial radial, 1 = rational radial +// +// The two radial forms and the two fisheye mappings repeat projection_utils' +// DistThinPrism / DistRational / fisheye_proj / equisolid_proj; a change there +// has to be made here too. +[ForceInline] +bool source_project_skewed(float p[kSourceMaxParams], float3 ray, out float2 uv) { + uv = float2(0.0f); + float2 q; + int base = (int)p[13]; + if (base == kSkewBasePerspective) { + if (ray.z < 1e-12f) + return false; + q = ray.xy / ray.z; + } else { + float r = length(ray.xy); + float theta = atan2(r, ray.z); + float k; + if (base == kSkewBaseFisheye) + k = theta < 1e-3f ? (1.0f - theta*theta/3.0f) / ray.z : theta / r; + else + k = r < 1e-6f ? (1.0f - theta*theta/24.0f) / ray.z + : (2.0f * sin(0.5f * theta)) / r; + q = ray.xy * k; + } + float u = q.x, v = q.y, r2 = u*u + v*v; + float dx, dy; + if (p[14] != 0.0f) { + float radial = (1.0f + r2*(p[5] + r2*(p[6] + r2*p[7]))) + / (1.0f + r2*(p[8] + r2*(p[9] + r2*p[10]))); + dx = u * radial + 2.0f*p[11]*u*v + p[12]*(r2 + 2.0f*u*u); + dy = v * radial + 2.0f*p[12]*u*v + p[11]*(r2 + 2.0f*v*v); + } else { + float radial = 1.0f + r2*(p[5] + r2*(p[6] + r2*(p[7] + r2*p[8]))); + dx = u * radial + 2.0f*p[9]*u*v + p[10]*(r2 + 2.0f*u*u) + p[11]*r2; + dy = v * radial + 2.0f*p[10]*u*v + p[9]*(r2 + 2.0f*v*v) + p[12]*r2; + } + uv = float2(p[0] * dx + p[4] * dy + p[2], p[1] * dy + p[3]); + return true; +} + +// The model's own formula, with no check that it still describes a lens. +[ForceInline] +bool source_project_raw(int model_id, float params[kSourceMaxParams], + float3 ray, out float2 uv) { + if (model_id == kSourceSkewed) + return source_project_skewed(params, ray, uv); + if (model_id == kSourceFOV) + return source_project_fov(params, ray, uv); + if (model_id == kSourceSimpleDivision) + return source_project_division(params, true, ray, uv); + if (model_id == kSourceDivision) + return source_project_division(params, false, ray, uv); + if (model_id == kSourceEUCM) + return source_project_eucm(params, ray, uv); + if (model_id == kSourceRadTanThinPrismFisheye) + return source_project_rad_tan_thin_prism(params, ray, uv); + uv = float2(0.0f); + return false; +} + +// Where the image stops growing outward the model has folded, and resampling +// past that mirrors the image instead of ending it at the lens border. Every +// model here is degree-0 homogeneous in the ray, so the test is the sign of +// the Jacobian taken in the ray's own tangent plane. +[ForceInline] +bool source_unfolded(int model_id, float params[kSourceMaxParams], float3 ray, + float2 uv) { + float3 n = normalize(ray); + float3 t = abs(n.x) < 0.9f ? float3(1.0f, 0.0f, 0.0f) : float3(0.0f, 1.0f, 0.0f); + float3 e1 = normalize(cross(t, n)); + float3 e2 = cross(n, e1); + const float kStep = 1e-3f; // radians; the models are smooth well below it + float2 a, b; + if (!source_project_raw(model_id, params, n + kStep * e1, a)) return false; + if (!source_project_raw(model_id, params, n + kStep * e2, b)) return false; + float2 j1 = a - uv, j2 = b - uv; + return j1.x * j2.y - j1.y * j2.x > 0.0f; +} + +// View-space direction (need not be normalized) -> source pixel. false where +// the source camera has no image for that direction. +[CudaDeviceExport] +bool source_project(int model_id, float params[kSourceMaxParams], + float3 ray, out float2 uv) { + if (!source_project_raw(model_id, params, ray, uv)) + return false; + return source_unfolded(model_id, params, ray, uv); +} + +#endif // _CAMERA_SOURCE_SLANG_INC diff --git a/src/shaders/pixel_wise.slang b/src/shaders/pixel_wise.slang index f26e4a28..aa55fdc2 100644 --- a/src/shaders/pixel_wise.slang +++ b/src/shaders/pixel_wise.slang @@ -179,54 +179,54 @@ float3 unproject_raydir( return raydir; } -[CudaDeviceExport] -float3 generate_ray_d2n( +[ForceInline] +float3 generate_ray_d2n( const no_diff float2 pix_pos, const no_diff float4 intrins, - const no_diff float[10] dist_coeffs, + const no_diff float dist_coeffs[D.kNumParams], const int camera_model, const bool is_ray_depth ) { float2 uv = (pix_pos - intrins.zw) / intrins.xy; float2 uv_u; - if (!undistort_point(uv, dist_coeffs, 12, uv_u)) { + if (!undistort_point(uv, dist_coeffs, 12, uv_u)) { return float3(0); } return unproject_raydir(uv_u, camera_model, is_ray_depth); } -[CudaDeviceExport] +[ForceInline] [Differentiable] -float3 depth_to_point( +float3 depth_to_point( const no_diff float2 pix_pos, const no_diff float4 intrins, // fx, fy, cx, cy - const no_diff float[10] dist_coeffs, + const no_diff float dist_coeffs[D.kNumParams], const int camera_model, const bool is_ray_depth, const float depth ) { float2 uv = (pix_pos - intrins.zw) / intrins.xy; float2 uv_u; - if (!no_diff undistort_point(uv, dist_coeffs, 12, uv_u)) { + if (!no_diff undistort_point(uv, dist_coeffs, 12, uv_u)) { return float3(0.0f); } return depth * unproject_raydir(uv_u, camera_model, is_ray_depth); } -[CudaDeviceExport] -float depth_to_point_vjp( +[ForceInline] +float depth_to_point_vjp( const no_diff float2 pix_pos, const no_diff float4 intrins, // fx, fy, cx, cy - const no_diff float[10] dist_coeffs, + const no_diff float dist_coeffs[D.kNumParams], const int camera_model, const bool is_ray_depth, const float depth, const float3 v_point ) { DifferentialPair dp_depth = diffPair(depth); - bwd_diff(depth_to_point)( + bwd_diff(depth_to_point)( pix_pos, intrins, dist_coeffs, camera_model, is_ray_depth, @@ -268,12 +268,12 @@ void points_to_normal_vjp( v_points = dp_points.d; } -[CudaDeviceExport] +[ForceInline] [Differentiable] -float3 depth_to_normal( +float3 depth_to_normal( const no_diff float2 pix_center, const no_diff float4 intrins, // fx, fy, cx, cy - const no_diff float[10] dist_coeffs, + const no_diff float dist_coeffs[D.kNumParams], const int camera_model, const bool is_ray_depth, const float4 depths // x-, x+, y-, y+ @@ -291,7 +291,7 @@ float3 depth_to_normal( float2 uv = (pix_pos - intrins.zw) / intrins.xy; float2 uv_u; - if (!no_diff undistort_point(uv, dist_coeffs, 12, uv_u)) { + if (!no_diff undistort_point(uv, dist_coeffs, 12, uv_u)) { return float3(0.0f); } @@ -307,11 +307,11 @@ float3 depth_to_normal( return normal; } -[CudaDeviceExport] -void depth_to_normal_vjp( +[ForceInline] +void depth_to_normal_vjp( const no_diff float2 pix_center, const no_diff float4 intrins, // fx, fy, cx, cy - const no_diff float[10] dist_coeffs, + const no_diff float dist_coeffs[D.kNumParams], const int camera_model, const bool is_ray_depth, const float4 depths, // x-, x+, y-, y+ @@ -319,7 +319,7 @@ void depth_to_normal_vjp( out float4 v_depths ) { DifferentialPair dp_depths = diffPair(depths); - bwd_diff(depth_to_normal)( + bwd_diff(depth_to_normal)( pix_center, intrins, dist_coeffs, camera_model, is_ray_depth, @@ -329,19 +329,19 @@ void depth_to_normal_vjp( } -[CudaDeviceExport] +[ForceInline] [Differentiable] -float ray_depth_to_linear_depth_factor( +float ray_depth_to_linear_depth_factor( const no_diff float2 pix_center, const no_diff float4 intrins, // fx, fy, cx, cy - const no_diff float[10] dist_coeffs, + const no_diff float dist_coeffs[D.kNumParams], const int camera_model ) { float2 uv = (pix_center - intrins.zw) / intrins.xy; float2 uv_u; - if (!no_diff undistort_point(uv, dist_coeffs, 12, uv_u)) + if (!no_diff undistort_point(uv, dist_coeffs, 12, uv_u)) return 0.0f; // ray scaled to z == 1; factor = linear_depth / ray_depth @@ -350,12 +350,12 @@ float ray_depth_to_linear_depth_factor( return sign(raydir.z) / length(raydir); } -[CudaDeviceExport] +[ForceInline] [Differentiable] -float depth_normal_loss( +float depth_normal_loss( const no_diff float2 pix_center, const no_diff float4 intrins, // fx, fy, cx, cy - const no_diff float[10] dist_coeffs, + const no_diff float dist_coeffs[D.kNumParams], const int camera_model, const bool is_ray_depth, const float4 depths, // x-, x+, y-, y+ @@ -372,7 +372,7 @@ float depth_normal_loss( float2 uv = (pix_pos - intrins.zw) / intrins.xy; float2 uv_u; - if (!no_diff undistort_point(uv, dist_coeffs, 12, uv_u)) { + if (!no_diff undistort_point(uv, dist_coeffs, 12, uv_u)) { return 0.0f; } @@ -396,11 +396,11 @@ float depth_normal_loss( return (num + eps) / (max(den, 0.0f) + eps); } -[CudaDeviceExport] -void depth_normal_loss_vjp( +[ForceInline] +void depth_normal_loss_vjp( const no_diff float2 pix_center, const no_diff float4 intrins, // fx, fy, cx, cy - const no_diff float[10] dist_coeffs, + const no_diff float dist_coeffs[D.kNumParams], const int camera_model, const bool is_ray_depth, const float4 depths, // x-, x+, y-, y+ @@ -411,7 +411,7 @@ void depth_normal_loss_vjp( ) { DifferentialPair dp_depths = diffPair(depths); DifferentialPair dp_gt_normal = diffPair(gt_normal); - bwd_diff(depth_normal_loss)( + bwd_diff(depth_normal_loss)( pix_center, intrins, dist_coeffs, camera_model, is_ray_depth, @@ -420,3 +420,88 @@ void depth_normal_loss_vjp( v_depths = dp_depths.d; v_gt_normal = dp_gt_normal.d; } + + +// ================ +// Per-tier CUDA exports +// ================ +// +// slangc cannot export a generic. These kernels take the camera model at +// runtime (one launch covers a whole batch) but the distortion tier at compile +// time, so there is one wrapper per tier and none per model. + +#define _DEF_PIXELWISE_DIST_ENTRIES(suffix, D, NC) \ + [CudaDeviceExport] \ + float3 generate_ray_d2n##suffix( \ + const float2 pix_pos, const float4 intrins, const float dist_coeffs[NC], \ + const int camera_model, const bool is_ray_depth \ + ) { \ + return generate_ray_d2n(pix_pos, intrins, dist_coeffs, camera_model, is_ray_depth); \ + } \ + [CudaDeviceExport] \ + float3 depth_to_point##suffix( \ + const float2 pix_pos, const float4 intrins, const float dist_coeffs[NC], \ + const int camera_model, const bool is_ray_depth, const float depth \ + ) { \ + return depth_to_point(pix_pos, intrins, dist_coeffs, camera_model, is_ray_depth, depth); \ + } \ + [CudaDeviceExport] \ + float depth_to_point_vjp##suffix( \ + const float2 pix_pos, const float4 intrins, const float dist_coeffs[NC], \ + const int camera_model, const bool is_ray_depth, const float depth, \ + const float3 v_point \ + ) { \ + return depth_to_point_vjp(pix_pos, intrins, dist_coeffs, camera_model, \ + is_ray_depth, depth, v_point); \ + } \ + [CudaDeviceExport] \ + float3 depth_to_normal##suffix( \ + const float2 pix_center, const float4 intrins, const float dist_coeffs[NC], \ + const int camera_model, const bool is_ray_depth, const float4 depths \ + ) { \ + return depth_to_normal(pix_center, intrins, dist_coeffs, camera_model, \ + is_ray_depth, depths); \ + } \ + [CudaDeviceExport] \ + void depth_to_normal_vjp##suffix( \ + const float2 pix_center, const float4 intrins, const float dist_coeffs[NC], \ + const int camera_model, const bool is_ray_depth, const float4 depths, \ + const float3 v_normal, out float4 v_depths \ + ) { \ + depth_to_normal_vjp(pix_center, intrins, dist_coeffs, camera_model, \ + is_ray_depth, depths, v_normal, v_depths); \ + } \ + [CudaDeviceExport] \ + float ray_depth_to_linear_depth_factor##suffix( \ + const float2 pix_center, const float4 intrins, const float dist_coeffs[NC], \ + const int camera_model \ + ) { \ + return ray_depth_to_linear_depth_factor(pix_center, intrins, dist_coeffs, camera_model); \ + } \ + [CudaDeviceExport] \ + float depth_normal_loss##suffix( \ + const float2 pix_center, const float4 intrins, const float dist_coeffs[NC], \ + const int camera_model, const bool is_ray_depth, const float4 depths, \ + const float3 gt_normal \ + ) { \ + return depth_normal_loss(pix_center, intrins, dist_coeffs, camera_model, \ + is_ray_depth, depths, gt_normal); \ + } \ + [CudaDeviceExport] \ + void depth_normal_loss_vjp##suffix( \ + const float2 pix_center, const float4 intrins, const float dist_coeffs[NC], \ + const int camera_model, const bool is_ray_depth, const float4 depths, \ + const float3 gt_normal, const float v_loss, \ + out float4 v_depths, out float3 v_gt_normal \ + ) { \ + depth_normal_loss_vjp(pix_center, intrins, dist_coeffs, camera_model, \ + is_ray_depth, depths, gt_normal, v_loss, \ + v_depths, v_gt_normal); \ + } + +_DEF_PIXELWISE_DIST_ENTRIES(_none, DistNone, 1) +_DEF_PIXELWISE_DIST_ENTRIES(_opencv, DistOpenCV, 4) +_DEF_PIXELWISE_DIST_ENTRIES(_prism, DistThinPrism, 8) +_DEF_PIXELWISE_DIST_ENTRIES(_rational, DistRational, 8) + +#undef _DEF_PIXELWISE_DIST_ENTRIES diff --git a/src/shaders/primitive_3dgs.slang b/src/shaders/primitive_3dgs.slang index 8ad89a6f..489f31a9 100644 --- a/src/shaders/primitive_3dgs.slang +++ b/src/shaders/primitive_3dgs.slang @@ -60,12 +60,12 @@ SigmaPoints world_gaussian_sigma_points( [ForceInline] [Differentiable] -bool persp_proj_3dgs( +bool persp_proj_3dgs( // inputs const float3 mean3d, const float3x3 cov3d, const float4 intrins, - const float[10] dist_coeffs, + const float dist_coeffs[D.kNumParams], const uint width, const uint height, // outputs @@ -75,11 +75,11 @@ bool persp_proj_3dgs( float fx = intrins.x, fy = intrins.y, cx = intrins.z, cy = intrins.w; cov2d = float2x2(0.0f); - bool valid = persp_proj(mean3d, intrins, dist_coeffs, mean2d); + bool valid = persp_proj(mean3d, intrins, dist_coeffs, mean2d); if (!assume_valid && !valid) return false; - float2x3 J = persp_proj_jac(mean3d, intrins, dist_coeffs); + float2x3 J = persp_proj_jac(mean3d, intrins, dist_coeffs); float lim_x_pos = width + 0.3f * (0.5f * width); float lim_x_neg = 0.3f * (0.5f * width); @@ -98,26 +98,12 @@ bool persp_proj_3dgs( return true; } -[CudaDeviceExport] -bool persp_proj_3dgs_nav( - const float3 mean3d, - const float3x3 cov3d, - const float4 intrins, - const float[10] dist_coeffs, - const uint width, - const uint height, - out float2x2 cov2d, - out float2 mean2d -) { - return persp_proj_3dgs(mean3d, cov3d, intrins, dist_coeffs, width, height, cov2d, mean2d); -} - [ForceInline] -bool persp_proj_3dgs_ut( +bool persp_proj_3dgs_ut( // inputs const SigmaPoints sigmas, const float4 intrins, - const float[10] dist_coeffs, + const float dist_coeffs[D.kNumParams], const uint width, const uint height, // outputs @@ -138,7 +124,7 @@ bool persp_proj_3dgs_ut( float2 proj_points[7]; bool all_valid = true; [ForceUnroll] for (int i = 0; i < 7; i++) - all_valid &= persp_proj(sigmas.p[i], intrins, dist_coeffs, proj_points[i]); + all_valid &= persp_proj(sigmas.p[i], intrins, dist_coeffs, proj_points[i]); if (!assume_valid && !all_valid) return false; @@ -161,111 +147,124 @@ bool persp_proj_3dgs_ut( [ForceInline] [Differentiable] -bool fisheye_proj_3dgs( +bool fisheye_proj_3dgs( // inputs const float3 mean3d, const float3x3 cov3d, const float4 intrins, - const float[10] dist_coeffs, + const float dist_coeffs[D.kNumParams], // outputs out float2x2 cov2d, out float2 mean2d ) { cov2d = float2x2(0.0f); - bool valid = fisheye_proj(mean3d, intrins, dist_coeffs, mean2d); + bool valid = fisheye_proj(mean3d, intrins, dist_coeffs, mean2d); if (!assume_valid && !valid) return false; - float2x3 J = fisheye_proj_jac(mean3d, intrins, dist_coeffs); + float2x3 J = fisheye_proj_jac(mean3d, intrins, dist_coeffs); cov2d = mul(mul(J, cov3d), transpose(J)); return true; } [ForceInline] [Differentiable] -bool equisolid_proj_3dgs( +bool equisolid_proj_3dgs( // inputs const float3 mean3d, const float3x3 cov3d, const float4 intrins, - const float[10] dist_coeffs, + const float dist_coeffs[D.kNumParams], // outputs out float2x2 cov2d, out float2 mean2d ) { cov2d = float2x2(0.0f); - bool valid = equisolid_proj(mean3d, intrins, dist_coeffs, mean2d); + bool valid = equisolid_proj(mean3d, intrins, dist_coeffs, mean2d); if (!assume_valid && !valid) return false; - float2x3 J = equisolid_proj_jac(mean3d, intrins, dist_coeffs); + float2x3 J = equisolid_proj_jac(mean3d, intrins, dist_coeffs); cov2d = mul(mul(J, cov3d), transpose(J)); return true; } [ForceInline] [Differentiable] -bool equirect_proj_3dgs( +bool equirect_proj_3dgs( // inputs const float3 mean3d, const float3x3 cov3d, const float4 intrins, - const float[10] dist_coeffs, + const float dist_coeffs[D.kNumParams], // outputs out float2x2 cov2d, out float2 mean2d ) { // Every direction is valid for equirectangular; equirect_proj always // succeeds. The covariance is pushed through the analytic angular Jacobian. - equirect_proj(mean3d, intrins, dist_coeffs, mean2d); + equirect_proj(mean3d, intrins, mean2d); - float2x3 J = equirect_proj_jac(mean3d, intrins, dist_coeffs); + float2x3 J = equirect_proj_jac(mean3d, intrins); cov2d = mul(mul(J, cov3d), transpose(J)); return true; } -[CudaDeviceExport] -bool fisheye_proj_3dgs_nav( - const float3 mean3d, - const float3x3 cov3d, - const float4 intrins, - const float[10] dist_coeffs, - out float2x2 cov2d, - out float2 mean2d -) { - return fisheye_proj_3dgs(mean3d, cov3d, intrins, dist_coeffs, cov2d, mean2d); -} +// Per-tier wrappers: slangc cannot export a generic. The CUDA side selects one +// at compile time through SlangPrimitive3DGS (core/CameraDistortion.cuh). +#define _DEF_proj_3dgs_nav(suffix, D, NC) \ + [CudaDeviceExport] \ + bool persp_proj_3dgs_nav##suffix( \ + const float3 mean3d, const float3x3 cov3d, const float4 intrins, \ + const float dist_coeffs[NC], const uint width, const uint height, \ + out float2x2 cov2d, out float2 mean2d \ + ) { \ + return persp_proj_3dgs( \ + mean3d, cov3d, intrins, dist_coeffs, width, height, cov2d, mean2d); \ + } \ + [CudaDeviceExport] \ + bool fisheye_proj_3dgs_nav##suffix( \ + const float3 mean3d, const float3x3 cov3d, const float4 intrins, \ + const float dist_coeffs[NC], out float2x2 cov2d, out float2 mean2d \ + ) { \ + return fisheye_proj_3dgs( \ + mean3d, cov3d, intrins, dist_coeffs, cov2d, mean2d); \ + } \ + [CudaDeviceExport] \ + bool equisolid_proj_3dgs_nav##suffix( \ + const float3 mean3d, const float3x3 cov3d, const float4 intrins, \ + const float dist_coeffs[NC], out float2x2 cov2d, out float2 mean2d \ + ) { \ + return equisolid_proj_3dgs( \ + mean3d, cov3d, intrins, dist_coeffs, cov2d, mean2d); \ + } -[CudaDeviceExport] -bool equisolid_proj_3dgs_nav( - const float3 mean3d, - const float3x3 cov3d, - const float4 intrins, - const float[10] dist_coeffs, - out float2x2 cov2d, - out float2 mean2d -) { - return equisolid_proj_3dgs(mean3d, cov3d, intrins, dist_coeffs, cov2d, mean2d); -} +_DEF_proj_3dgs_nav(_none, DistNone, 1) +_DEF_proj_3dgs_nav(_opencv, DistOpenCV, 4) +_DEF_proj_3dgs_nav(_prism, DistThinPrism, 8) +_DEF_proj_3dgs_nav(_rational, DistRational, 8) + +#undef _DEF_proj_3dgs_nav [CudaDeviceExport] bool equirect_proj_3dgs_nav( const float3 mean3d, const float3x3 cov3d, const float4 intrins, - const float[10] dist_coeffs, out float2x2 cov2d, out float2 mean2d ) { - return equirect_proj_3dgs(mean3d, cov3d, intrins, dist_coeffs, cov2d, mean2d); + const float dist_coeffs[1] = { 0.0f }; + return equirect_proj_3dgs( + mean3d, cov3d, intrins, dist_coeffs, cov2d, mean2d); } [ForceInline] -bool fisheye_proj_3dgs_ut( +bool fisheye_proj_3dgs_ut( // inputs const SigmaPoints sigmas, const float4 intrins, - const float[10] dist_coeffs, + const float dist_coeffs[D.kNumParams], // outputs out float2x2 cov2d, out float2 mean2d @@ -276,7 +275,7 @@ bool fisheye_proj_3dgs_ut( float2 proj_points[7]; bool all_valid = true; [ForceUnroll] for (int i = 0; i < 7; i++) - all_valid &= fisheye_proj(sigmas.p[i], intrins, dist_coeffs, proj_points[i]); + all_valid &= fisheye_proj(sigmas.p[i], intrins, dist_coeffs, proj_points[i]); if (!assume_valid && !all_valid) return false; @@ -308,11 +307,11 @@ bool fisheye_proj_3dgs_ut( } [ForceInline] -bool equisolid_proj_3dgs_ut( +bool equisolid_proj_3dgs_ut( // inputs const SigmaPoints sigmas, const float4 intrins, - const float[10] dist_coeffs, + const float dist_coeffs[D.kNumParams], // outputs out float2x2 cov2d, out float2 mean2d @@ -323,7 +322,7 @@ bool equisolid_proj_3dgs_ut( float2 proj_points[7]; bool all_valid = true; [ForceUnroll] for (int i = 0; i < 7; i++) - all_valid &= equisolid_proj(sigmas.p[i], intrins, dist_coeffs, proj_points[i]); + all_valid &= equisolid_proj(sigmas.p[i], intrins, dist_coeffs, proj_points[i]); if (!assume_valid && !all_valid) return false; @@ -355,11 +354,11 @@ bool equisolid_proj_3dgs_ut( } [ForceInline] -bool equirect_proj_3dgs_ut( +bool equirect_proj_3dgs_ut( // inputs const SigmaPoints sigmas, const float4 intrins, - const float[10] dist_coeffs, + const float dist_coeffs[D.kNumParams], // outputs out float2x2 cov2d, out float2 mean2d @@ -369,7 +368,7 @@ bool equirect_proj_3dgs_ut( float2 proj_points[7]; [ForceUnroll] for (int i = 0; i < 7; i++) - equirect_proj(sigmas.p[i], intrins, dist_coeffs, proj_points[i]); + equirect_proj(sigmas.p[i], intrins, proj_points[i]); // Unwrap longitude (u) of each sigma point relative to the center point so // a splat straddling the +-pi seam averages coherently instead of snapping @@ -406,19 +405,22 @@ float add_blur(const float eps2d, inout float2x2 covar, out float compensation) } -#define _projection_3dgs_ARGS \ +#define _projection_3dgs_ARGS(NC) \ const bool antialiased, \ const float3 mean, const float4 quat, const float3 scale, const float in_opacity, \ const float3x3 R, const float3 t, \ no_diff const float fx, no_diff const float fy, no_diff const float cx, no_diff const float cy, \ - no_diff const float[10] dist_coeffs, const uint image_width, const uint image_height, \ + no_diff const float dist_coeffs[NC], const uint image_width, const uint image_height, \ no_diff out float4 aabb_xyxy, no_diff out float sorting_depth, no_diff out float radius, \ out float2 mean2d, out float depth, out float3 conic, out float opacity [ForceInline] [Differentiable] -void projection_3dgs( - _projection_3dgs_ARGS +void projection_3dgs< + let camera_model: CameraModelType, D : ICameraDistortion, + let assume_valid: bool, let eval3d: bool +>( + _projection_3dgs_ARGS(D.kNumParams) ) { // Culled early returns leave every output at this "invalid" state // (aabb_xyxy == 0 is the marker consumers test). @@ -450,25 +452,25 @@ void projection_3dgs( + is_valid &= persp_proj_3dgs_ut( sigmas, intrins, dist_coeffs, image_width, image_height, covar2d, mean2d ); else if (camera_model == CameraModelType::FISHEYE) - is_valid &= fisheye_proj_3dgs_ut( + is_valid &= fisheye_proj_3dgs_ut( sigmas, intrins, dist_coeffs, covar2d, mean2d ); else if (camera_model == CameraModelType::EQUISOLID) - is_valid &= equisolid_proj_3dgs_ut( + is_valid &= equisolid_proj_3dgs_ut( sigmas, intrins, dist_coeffs, covar2d, mean2d ); else if (camera_model == CameraModelType::EQUIRECTANGULAR) - is_valid &= equirect_proj_3dgs_ut( + is_valid &= equirect_proj_3dgs_ut( sigmas, intrins, dist_coeffs, covar2d, mean2d @@ -486,25 +488,25 @@ void projection_3dgs( + is_valid &= persp_proj_3dgs( mean_c, covar_c, intrins, dist_coeffs, image_width, image_height, covar2d, mean2d ); else if (camera_model == CameraModelType::FISHEYE) - is_valid &= fisheye_proj_3dgs( + is_valid &= fisheye_proj_3dgs( mean_c, covar_c, intrins, dist_coeffs, covar2d, mean2d ); else if (camera_model == CameraModelType::EQUISOLID) - is_valid &= equisolid_proj_3dgs( + is_valid &= equisolid_proj_3dgs( mean_c, covar_c, intrins, dist_coeffs, covar2d, mean2d ); else if (camera_model == CameraModelType::EQUIRECTANGULAR) - is_valid &= equirect_proj_3dgs( + is_valid &= equirect_proj_3dgs( mean_c, covar_c, intrins, dist_coeffs, covar2d, mean2d @@ -577,12 +579,17 @@ void projection_3dgs( \ + void funname(_projection_3dgs_ARGS(NC)) { \ + return projection_3dgs( \ antialiased, \ mean, quat, scale, in_opacity, R, t, \ fx, fy, cx, cy, dist_coeffs, \ @@ -591,31 +598,40 @@ void projection_3dgs { [ForceInline] [Differentiable] - static void projection(_projection_3dgs_ARGS); + static void projection(_projection_3dgs_ARGS(NC)); }; -#define _DEF_projection_3dgs_interface(_InterfaceName, ...) \ - struct _InterfaceName : _DiffProjection3DGS { \ +#define _DEF_projection_3dgs_interface(_InterfaceName, MODEL, D, NC, AV, E3D) \ + struct _InterfaceName : _DiffProjection3DGS { \ [ForceInline] \ [Differentiable] \ - static void projection(_projection_3dgs_ARGS) { \ - return projection_3dgs<__VA_ARGS__>( \ + static void projection(_projection_3dgs_ARGS(NC)) { \ + return projection_3dgs( \ antialiased, \ mean, quat, scale, in_opacity, R, t, \ fx, fy, cx, cy, dist_coeffs, \ @@ -625,21 +641,29 @@ interface _DiffProjection3DGS } \ }; -_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgs_persp, CameraModelType::PINHOLE, true, false) -_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgs_fisheye, CameraModelType::FISHEYE, true, false) -_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgs_equisolid, CameraModelType::EQUISOLID, true, false) -_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgs_equirect, CameraModelType::EQUIRECTANGULAR, true, false) -_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgut_persp, CameraModelType::PINHOLE, true, true) -_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgut_fisheye, CameraModelType::FISHEYE, true, true) -_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgut_equisolid, CameraModelType::EQUISOLID, true, true) -_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgut_equirect, CameraModelType::EQUIRECTANGULAR, true, true) +#define _DEF_projection_3dgs_interface_tiers(base, MODEL, E3D) \ + _DEF_projection_3dgs_interface(base##_none, MODEL, DistNone, 1, true, E3D) \ + _DEF_projection_3dgs_interface(base##_opencv, MODEL, DistOpenCV, 4, true, E3D) \ + _DEF_projection_3dgs_interface(base##_prism, MODEL, DistThinPrism, 8, true, E3D) + +_DEF_projection_3dgs_interface_tiers(_DiffProjection3DGS_3dgs_persp, CameraModelType::PINHOLE, false) +_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgs_persp_rational, CameraModelType::PINHOLE, DistRational, 8, true, false) +_DEF_projection_3dgs_interface_tiers(_DiffProjection3DGS_3dgs_fisheye, CameraModelType::FISHEYE, false) +_DEF_projection_3dgs_interface_tiers(_DiffProjection3DGS_3dgs_equisolid, CameraModelType::EQUISOLID, false) +_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgs_equirect_none, CameraModelType::EQUIRECTANGULAR, DistNone, 1, true, false) + +_DEF_projection_3dgs_interface_tiers(_DiffProjection3DGS_3dgut_persp, CameraModelType::PINHOLE, true) +_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgut_persp_rational, CameraModelType::PINHOLE, DistRational, 8, true, true) +_DEF_projection_3dgs_interface_tiers(_DiffProjection3DGS_3dgut_fisheye, CameraModelType::FISHEYE, true) +_DEF_projection_3dgs_interface_tiers(_DiffProjection3DGS_3dgut_equisolid, CameraModelType::EQUISOLID, true) +_DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgut_equirect_none, CameraModelType::EQUIRECTANGULAR, DistNone, 1, true, true) -#define _projection_3dgs_vjp_ARGS \ +#define _projection_3dgs_vjp_ARGS(NC) \ const bool antialiased, \ const float3 mean, const float4 quat, const float3 scale, const float in_opacity, \ const float3x3 R, const float3 t, const float fx, const float fy, const float cx, const float cy, \ - const float[10] dist_coeffs, const uint image_width, const uint image_height, \ + const float dist_coeffs[NC], const uint image_width, const uint image_height, \ const float2 v_mean2d, const float v_depth, const float3 v_conic, const float v_opacity, \ inout float3 v_mean, inout float4 v_quat, inout float3 v_scale, inout float v_in_opacity, \ inout float3x3 v_R, inout float3 v_t @@ -649,8 +673,8 @@ _DEF_projection_3dgs_interface(_DiffProjection3DGS_3dgut_equirect, CameraModelTy // through an interface-typed VALUE parameter; the generic-constraint form // compiles on both 2026.2.1 (CUDA emission) and 2026.12 (SPIR-V). [ForceInline] -void _projection_3dgs_vjp( - _projection_3dgs_vjp_ARGS +void _projection_3dgs_vjp >( + _projection_3dgs_vjp_ARGS(NC) ) { DifferentialPair dp_mean = diffPair(mean); DifferentialPair dp_quat = diffPair(quat); @@ -673,12 +697,12 @@ void _projection_3dgs_vjp( v_t += dp_t.d; } -#define _DEF_projection_3dgs_vjp(funname, _InterfaceName, ...) \ +#define _DEF_projection_3dgs_vjp(funname, _InterfaceName, NC) \ [CudaDeviceExport] \ void funname( \ - _projection_3dgs_vjp_ARGS \ + _projection_3dgs_vjp_ARGS(NC) \ ) { \ - return _projection_3dgs_vjp<_InterfaceName>( \ + return _projection_3dgs_vjp( \ antialiased, \ mean, quat, scale, in_opacity, R, t, \ fx, fy, cx, cy, dist_coeffs, \ @@ -688,12 +712,20 @@ void _projection_3dgs_vjp( ); \ } -_DEF_projection_3dgs_vjp(projection_3dgs_persp_vjp, _DiffProjection3DGS_3dgs_persp) -_DEF_projection_3dgs_vjp(projection_3dgs_fisheye_vjp, _DiffProjection3DGS_3dgs_fisheye) -_DEF_projection_3dgs_vjp(projection_3dgs_equisolid_vjp, _DiffProjection3DGS_3dgs_equisolid) -_DEF_projection_3dgs_vjp(projection_3dgs_equirect_vjp, _DiffProjection3DGS_3dgs_equirect) -_DEF_projection_3dgs_vjp(projection_3dgut_persp_vjp, _DiffProjection3DGS_3dgut_persp) -_DEF_projection_3dgs_vjp(projection_3dgut_fisheye_vjp, _DiffProjection3DGS_3dgut_fisheye) -_DEF_projection_3dgs_vjp(projection_3dgut_equisolid_vjp, _DiffProjection3DGS_3dgut_equisolid) -_DEF_projection_3dgs_vjp(projection_3dgut_equirect_vjp, _DiffProjection3DGS_3dgut_equirect) +#define _DEF_projection_3dgs_vjp_tiers(base, iface) \ + _DEF_projection_3dgs_vjp(base##_none_vjp, iface##_none, 1) \ + _DEF_projection_3dgs_vjp(base##_opencv_vjp, iface##_opencv, 4) \ + _DEF_projection_3dgs_vjp(base##_prism_vjp, iface##_prism, 8) + +_DEF_projection_3dgs_vjp_tiers(projection_3dgs_persp, _DiffProjection3DGS_3dgs_persp) +_DEF_projection_3dgs_vjp(projection_3dgs_persp_rational_vjp, _DiffProjection3DGS_3dgs_persp_rational, 8) +_DEF_projection_3dgs_vjp_tiers(projection_3dgs_fisheye, _DiffProjection3DGS_3dgs_fisheye) +_DEF_projection_3dgs_vjp_tiers(projection_3dgs_equisolid, _DiffProjection3DGS_3dgs_equisolid) +_DEF_projection_3dgs_vjp(projection_3dgs_equirect_none_vjp, _DiffProjection3DGS_3dgs_equirect_none, 1) + +_DEF_projection_3dgs_vjp_tiers(projection_3dgut_persp, _DiffProjection3DGS_3dgut_persp) +_DEF_projection_3dgs_vjp(projection_3dgut_persp_rational_vjp, _DiffProjection3DGS_3dgut_persp_rational, 8) +_DEF_projection_3dgs_vjp_tiers(projection_3dgut_fisheye, _DiffProjection3DGS_3dgut_fisheye) +_DEF_projection_3dgs_vjp_tiers(projection_3dgut_equisolid, _DiffProjection3DGS_3dgut_equisolid) +_DEF_projection_3dgs_vjp(projection_3dgut_equirect_none_vjp, _DiffProjection3DGS_3dgut_equirect_none, 1) diff --git a/src/shaders/projection_utils.slang b/src/shaders/projection_utils.slang index d2312584..afb8b532 100644 --- a/src/shaders/projection_utils.slang +++ b/src/shaders/projection_utils.slang @@ -205,82 +205,122 @@ void sv_coeffs_to_color( color = total_c / total_w; } -[ForceInline] -[Differentiable] -float2 camera_distortion(float2 uv, no_diff float[10] dist_coeffs) { - float k1 = dist_coeffs[0], - k2 = dist_coeffs[1], - k3 = dist_coeffs[2], - k4 = dist_coeffs[3], - p1 = dist_coeffs[4], - p2 = dist_coeffs[5], - sx1 = dist_coeffs[6], - sy1 = dist_coeffs[7], - b1 = dist_coeffs[8], - b2 = dist_coeffs[9]; - float u = uv.x, v = uv.y; - float r2 = u*u+v*v; - float radial = 1.0 + r2*(k1 + r2*(k2 + r2*(k3 + r2*k4))); - float du = 2.0*p1*u*v + p2*(r2+2.0*u*u) + sx1*r2; - float dv = 2.0*p2*u*v + p1*(r2+2.0*v*v) + sy1*r2; - uv = uv * radial + float2(du, dv); - return uv + float2(b1 * uv.x + b2 * uv.y, 0.0); -} +// ================ +// Lens distortion tiers +// ================ +// +// The tier is a compile-time choice on both backends (CUDA template argument, +// Vulkan specialization constant) and is ORTHOGONAL to CameraModelType: it acts +// on whatever normalized coordinates the camera model produced -- (x/z, y/z) +// for PINHOLE, theta-space for FISHEYE / EQUISOLID -- which is the order COLMAP +// applies it in too. EQUIRECTANGULAR carries no lens distortion. +// +// Coefficient order is each tier's own; a slot index does NOT mean the same +// thing across tiers. Must match CameraDistortionType in core/CameraModel.h. +enum CameraDistortionType { + DIST_NONE = 0, + DIST_OPENCV = 1, + DIST_THIN_PRISM = 2, + DIST_RATIONAL = 3, +}; + +interface ICameraDistortion { + static const int kNumParams; + static const bool kIsIdentity; + [Differentiable] + static float2 distort(float2 uv, no_diff float coeffs[kNumParams]); +}; + +// Slang has no zero-length array, so the identity tier carries one unread slot. +struct DistNone : ICameraDistortion { + static const int kNumParams = 1; + static const bool kIsIdentity = true; + [Differentiable] + static float2 distort(float2 uv, no_diff float coeffs[1]) { return uv; } +}; + +// k1 k2 p1 p2 -- COLMAP OPENCV, and the radial-only models zero-extended into it. +struct DistOpenCV : ICameraDistortion { + static const int kNumParams = 4; + static const bool kIsIdentity = false; + [Differentiable] + static float2 distort(float2 uv, no_diff float coeffs[4]) { + float k1 = coeffs[0], k2 = coeffs[1], p1 = coeffs[2], p2 = coeffs[3]; + float u = uv.x, v = uv.y; + float r2 = u*u + v*v; + float radial = 1.0 + r2*(k1 + r2*k2); + return uv * radial + float2( + 2.0*p1*u*v + p2*(r2 + 2.0*u*u), + 2.0*p2*u*v + p1*(r2 + 2.0*v*v)); + } +}; + +// k1 k2 k3 k4 p1 p2 sx1 sy1 -- COLMAP THIN_PRISM_FISHEYE, radial-first +// (COLMAP's own file order interleaves p1,p2 between k2 and k3). +struct DistThinPrism : ICameraDistortion { + static const int kNumParams = 8; + static const bool kIsIdentity = false; + [Differentiable] + static float2 distort(float2 uv, no_diff float coeffs[8]) { + float k1 = coeffs[0], k2 = coeffs[1], k3 = coeffs[2], k4 = coeffs[3], + p1 = coeffs[4], p2 = coeffs[5], sx1 = coeffs[6], sy1 = coeffs[7]; + float u = uv.x, v = uv.y; + float r2 = u*u + v*v; + float radial = 1.0 + r2*(k1 + r2*(k2 + r2*(k3 + r2*k4))); + return uv * radial + float2( + 2.0*p1*u*v + p2*(r2 + 2.0*u*u) + sx1*r2, + 2.0*p2*u*v + p1*(r2 + 2.0*v*v) + sy1*r2); + } +}; + +// k1 k2 k3 k4 k5 k6 p1 p2 -- COLMAP FULL_OPENCV, i.e. OpenCV's 8-coefficient +// rational model. k4..k6 are DENOMINATOR terms, which is why they cannot be +// folded into the DistThinPrism slots of the same index. +struct DistRational : ICameraDistortion { + static const int kNumParams = 8; + static const bool kIsIdentity = false; + [Differentiable] + static float2 distort(float2 uv, no_diff float coeffs[8]) { + float k1 = coeffs[0], k2 = coeffs[1], k3 = coeffs[2], + k4 = coeffs[3], k5 = coeffs[4], k6 = coeffs[5], + p1 = coeffs[6], p2 = coeffs[7]; + float u = uv.x, v = uv.y; + float r2 = u*u + v*v; + float radial = (1.0 + r2*(k1 + r2*(k2 + r2*k3))) + / (1.0 + r2*(k4 + r2*(k5 + r2*k6))); + return uv * radial + float2( + 2.0*p1*u*v + p2*(r2 + 2.0*u*u), + 2.0*p2*u*v + p1*(r2 + 2.0*v*v)); + } +}; + [ForceInline] [Differentiable] -float2x2 camera_distortion_jac(float2 uv, no_diff float[10] dist_coeffs) { -#if 0 - DifferentialPair dp_uv_x = diffPair(uv); - bwd_diff(camera_distortion)(dp_uv_x, dist_coeffs, float2(1, 0)); - DifferentialPair dp_uv_y = diffPair(uv); - bwd_diff(camera_distortion)(dp_uv_y, dist_coeffs, float2(0, 1)); - return float2x2(dp_uv_x.d, dp_uv_y.d); -#else +float2x2 camera_distortion_jac( + float2 uv, no_diff float dist_coeffs[D.kNumParams] +) { DifferentialPair dp_uv_x = diffPair(uv, float2(1, 0)); - float2 j_x = fwd_diff(camera_distortion)(dp_uv_x, dist_coeffs).d; + float2 j_x = fwd_diff(D.distort)(dp_uv_x, dist_coeffs).d; DifferentialPair dp_uv_y = diffPair(uv, float2(0, 1)); - float2 j_y = fwd_diff(camera_distortion)(dp_uv_y, dist_coeffs).d; + float2 j_y = fwd_diff(D.distort)(dp_uv_y, dist_coeffs).d; return transpose(float2x2(j_x, j_y)); -#endif } [ForceInline] -[CudaDeviceExport] -bool is_valid_distortion(no_diff float2 uv, no_diff float[10] dist_coeffs) { +bool is_valid_distortion( + no_diff float2 uv, no_diff float dist_coeffs[D.kNumParams] +) { + if (D.kIsIdentity) + return true; // TODO: doesn't always work for more than 2 radial coeffs - float2x2 J = camera_distortion_jac(uv, dist_coeffs); - return min(determinant(J), min(J[0][0], J[1][1])) > 0.0; + float2x2 J = camera_distortion_jac(uv, dist_coeffs); + float Jdet = min(determinant(J), min(J[0][0], J[1][1])); + // return Jdet > 0.0f; + return Jdet > 0.25f && Jdet < 4.0f && dot(uv, D.distort(uv, dist_coeffs)) >= 0.0f; } -// [ForceInline] -[Differentiable] -float valid_distortion_log_barrier(float2 uv, no_diff float[10] dist_coeffs) { - // TODO: doesn't always work for more than 2 radial coeffs - float2x2 J = camera_distortion_jac(uv, dist_coeffs); - float val0 = min(determinant(J), min(J[0][0], J[1][1])); // positive if inside - return -log(val0); -} -#if 0 -[ForceInline] -[Differentiable] -float2 valid_distortion_log_barrier_grad(float2 uv, no_diff float[10] dist_coeffs) { - DifferentialPair dp_uv = diffPair(uv); - bwd_diff(valid_distortion_log_barrier)(dp_uv, dist_coeffs, 1.0f); - return dp_uv.d; -} - -[ForceInline] -[Differentiable] -float2x2 valid_distortion_log_barrier_hess(float2 uv, no_diff float[10] dist_coeffs) { - DifferentialPair dp_uv_x = diffPair(uv); - bwd_diff(valid_distortion_log_barrier_grad)(dp_uv_x, dist_coeffs, float2(1.0f, 0.0f)); - DifferentialPair dp_uv_y = diffPair(uv); - bwd_diff(valid_distortion_log_barrier_grad)(dp_uv_y, dist_coeffs, float2(0.0f, 1.0f)); - return float2x2(dp_uv_x.d, dp_uv_y.d); -} -#endif // Value-returning core (assume-valid path). The bool wrapper below and the // fwd_diff Jacobians both build on this: slangc crashes on bwd-of-fwd_diff @@ -288,11 +328,11 @@ float2x2 valid_distortion_log_barrier_hess(float2 uv, no_diff float[10] dist_coe // #11160), and the documented workaround is returning the value instead. [ForceInline] [Differentiable] -float2 persp_proj_uv( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs +float2 persp_proj_uv( + float3 p_view, no_diff float4 intrins, no_diff float dist_coeffs[D.kNumParams] ) { float2 uv = p_view.xy / p_view.z; - uv = camera_distortion(uv, dist_coeffs); + uv = D.distort(uv, dist_coeffs); float fx = intrins.x, fy = intrins.y, cx = intrins.z, cy = intrins.w; return float2( fx * uv.x + cx, @@ -302,52 +342,35 @@ float2 persp_proj_uv( [ForceInline] [Differentiable] -bool persp_proj( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs, +bool persp_proj( + float3 p_view, no_diff float4 intrins, no_diff float dist_coeffs[D.kNumParams], out float2 uv ) { if (!assume_valid) { float2 uv0 = p_view.xy / p_view.z; - if (p_view.z < 0.0 || !is_valid_distortion(uv0, dist_coeffs)) { + if (p_view.z < 0.0 || !is_valid_distortion(uv0, dist_coeffs)) { uv = uv0; return false; } } - uv = persp_proj_uv(p_view, intrins, dist_coeffs); + uv = persp_proj_uv(p_view, intrins, dist_coeffs); return true; } -[CudaDeviceExport] -bool persp_proj_nav( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs, - out float2 uv -) { - return persp_proj(p_view, intrins, dist_coeffs, uv); -} - [ForceInline] [Differentiable] -[CudaDeviceExport] -float2x3 persp_proj_jac(float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs) { +float2x3 persp_proj_jac( + float3 p_view, no_diff float4 intrins, no_diff float dist_coeffs[D.kNumParams] +) { float2x3 J; -#if 0 - [ForceUnroll] - for (int i = 0; i < 2; ++i) { - float2 seed = 0.0; seed[i] = 1.0; - DifferentialPair dp_p_view = diffPair(p_view); - bwd_diff(persp_proj)(dp_p_view, intrins, dist_coeffs, seed); - J[i] = dp_p_view.d; - } -#else [ForceUnroll] for (int i = 0; i < 3; ++i) { DifferentialPair dp_p_view = diffPair(p_view, float3(float(i == 0), float(i == 1), float(i == 2))); - float2 duv = fwd_diff(persp_proj_uv)(dp_p_view, intrins, dist_coeffs).d; + float2 duv = fwd_diff(persp_proj_uv)(dp_p_view, intrins, dist_coeffs).d; J[0][i] = duv.x; J[1][i] = duv.y; } -#endif return J; } @@ -374,11 +397,11 @@ float2 equisolid_proj(float3 p_view) { // Value-returning core; see persp_proj_uv for why (slang #11160). [ForceInline] [Differentiable] -float2 fisheye_proj_uv( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs +float2 fisheye_proj_uv( + float3 p_view, no_diff float4 intrins, no_diff float dist_coeffs[D.kNumParams] ) { float2 uv = fisheye_proj(p_view); - uv = camera_distortion(uv, dist_coeffs); + uv = D.distort(uv, dist_coeffs); float fx = intrins.x, fy = intrins.y, cx = intrins.z, cy = intrins.w; return float2( fx * uv.x + cx, @@ -388,29 +411,29 @@ float2 fisheye_proj_uv( [ForceInline] [Differentiable] -bool fisheye_proj( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs, +bool fisheye_proj( + float3 p_view, no_diff float4 intrins, no_diff float dist_coeffs[D.kNumParams], out float2 uv ) { if (!assume_valid) { float2 uv0 = fisheye_proj(p_view); - if (!is_valid_distortion(uv0, dist_coeffs)) { + if (!is_valid_distortion(uv0, dist_coeffs)) { uv = uv0; return false; } } - uv = fisheye_proj_uv(p_view, intrins, dist_coeffs); + uv = fisheye_proj_uv(p_view, intrins, dist_coeffs); return true; } // Value-returning core; see persp_proj_uv for why (slang #11160). [ForceInline] [Differentiable] -float2 equisolid_proj_uv( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs +float2 equisolid_proj_uv( + float3 p_view, no_diff float4 intrins, no_diff float dist_coeffs[D.kNumParams] ) { float2 uv = equisolid_proj(p_view); - uv = camera_distortion(uv, dist_coeffs); + uv = D.distort(uv, dist_coeffs); float fx = intrins.x, fy = intrins.y, cx = intrins.z, cy = intrins.w; return float2( fx * uv.x + cx, @@ -420,73 +443,49 @@ float2 equisolid_proj_uv( [ForceInline] [Differentiable] -bool equisolid_proj( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs, +bool equisolid_proj( + float3 p_view, no_diff float4 intrins, no_diff float dist_coeffs[D.kNumParams], out float2 uv ) { if (!assume_valid) { float2 uv0 = equisolid_proj(p_view); - if (!is_valid_distortion(uv0, dist_coeffs)) { + if (!is_valid_distortion(uv0, dist_coeffs)) { uv = uv0; return false; } } - uv = equisolid_proj_uv(p_view, intrins, dist_coeffs); + uv = equisolid_proj_uv(p_view, intrins, dist_coeffs); return true; } -[CudaDeviceExport] -bool fisheye_proj_nav( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs, - out float2 uv -) { - return fisheye_proj(p_view, intrins, dist_coeffs, uv); -} - -[CudaDeviceExport] -bool equisolid_proj_nav( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs, - out float2 uv -) { - return equisolid_proj(p_view, intrins, dist_coeffs, uv); -} - [ForceInline] [Differentiable] -[CudaDeviceExport] -float2x3 fisheye_proj_jac(float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs) { +float2x3 fisheye_proj_jac( + float3 p_view, no_diff float4 intrins, no_diff float dist_coeffs[D.kNumParams] +) { float2x3 J; -#if 0 - [ForceUnroll] - for (int i = 0; i < 2; ++i) { - float2 seed = 0.0; seed[i] = 1.0; - DifferentialPair dp_p_view = diffPair(p_view); - bwd_diff(fisheye_proj)(dp_p_view, intrins, dist_coeffs, seed); - J[i] = dp_p_view.d; - } -#else [ForceUnroll] for (int i = 0; i < 3; ++i) { DifferentialPair dp_p_view = diffPair(p_view, float3(float(i == 0), float(i == 1), float(i == 2))); - float2 duv = fwd_diff(fisheye_proj_uv)(dp_p_view, intrins, dist_coeffs).d; + float2 duv = fwd_diff(fisheye_proj_uv)(dp_p_view, intrins, dist_coeffs).d; J[0][i] = duv.x; J[1][i] = duv.y; } -#endif return J; } [ForceInline] [Differentiable] -[CudaDeviceExport] -float2x3 equisolid_proj_jac(float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs) { +float2x3 equisolid_proj_jac( + float3 p_view, no_diff float4 intrins, no_diff float dist_coeffs[D.kNumParams] +) { float2x3 J; [ForceUnroll] for (int i = 0; i < 3; ++i) { DifferentialPair dp_p_view = diffPair(p_view, float3(float(i == 0), float(i == 1), float(i == 2))); - float2 duv = fwd_diff(equisolid_proj_uv)(dp_p_view, intrins, dist_coeffs).d; + float2 duv = fwd_diff(equisolid_proj_uv)(dp_p_view, intrins, dist_coeffs).d; J[0][i] = duv.x; J[1][i] = duv.y; } @@ -497,9 +496,10 @@ float2x3 equisolid_proj_jac(float3 p_view, no_diff float4 intrins, no_diff float // Convention matches warp_image_equirectangular_to_pinhole_kernel in ImageWarp.cu: // lon = atan2(x, z), lat = atan2(y, hypot(x, z)), // u = fx*lon + cx, v = fy*lat + cy, with fx = fy = width/(2*pi), cx = w/2, cy = h/2. -// Assumes no lens distortion (dist_coeffs are ignored). Every viewing direction -// is valid, so the whole sphere projects; the atan2 seam at lon = +-pi and the -// poles at lat = +-pi/2 are the expected sources of nonlinearity/discontinuity. +// Carries no lens distortion, so unlike the other models it takes no +// coefficients. Every viewing direction is valid, so the whole sphere projects; +// the atan2 seam at lon = +-pi and the poles at lat = +-pi/2 are the expected +// sources of nonlinearity/discontinuity. [ForceInline] [Differentiable] float2 equirect_proj(float3 p_view) { @@ -511,9 +511,7 @@ float2 equirect_proj(float3 p_view) { // Value-returning core; see persp_proj_uv for why (slang #11160). [ForceInline] [Differentiable] -float2 equirect_proj_uv( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs -) { +float2 equirect_proj_uv(float3 p_view, no_diff float4 intrins) { float2 lonlat = equirect_proj(p_view); float fx = intrins.x, fy = intrins.y, cx = intrins.z, cy = intrins.w; return float2(fx * lonlat.x + cx, fy * lonlat.y + cy); @@ -522,32 +520,27 @@ float2 equirect_proj_uv( [ForceInline] [Differentiable] bool equirect_proj( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs, - out float2 uv + float3 p_view, no_diff float4 intrins, out float2 uv ) { - uv = equirect_proj_uv(p_view, intrins, dist_coeffs); - // full-sphere camera: no invalid region (dist_coeffs unused) + uv = equirect_proj_uv(p_view, intrins); return true; } [CudaDeviceExport] -bool equirect_proj_nav( - float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs, - out float2 uv -) { - return equirect_proj(p_view, intrins, dist_coeffs, uv); +bool equirect_proj_nav(float3 p_view, no_diff float4 intrins, out float2 uv) { + return equirect_proj(p_view, intrins, uv); } [ForceInline] [Differentiable] [CudaDeviceExport] -float2x3 equirect_proj_jac(float3 p_view, no_diff float4 intrins, no_diff float[10] dist_coeffs) { +float2x3 equirect_proj_jac(float3 p_view, no_diff float4 intrins) { float2x3 J; [ForceUnroll] for (int i = 0; i < 3; ++i) { DifferentialPair dp_p_view = diffPair(p_view, float3(float(i == 0), float(i == 1), float(i == 2))); - float2 duv = fwd_diff(equirect_proj_uv)(dp_p_view, intrins, dist_coeffs).d; + float2 duv = fwd_diff(equirect_proj_uv)(dp_p_view, intrins).d; J[0][i] = duv.x; J[1][i] = duv.y; } @@ -593,105 +586,41 @@ float2 _solve2x2(float2x2 A, float2 b) { } // find uv' s.t. distort(uv') = uv -bool undistort_point( - no_diff float2 uv, no_diff float[10] dist_coeffs, +bool undistort_point( + no_diff float2 uv, no_diff float dist_coeffs[D.kNumParams], int maxiter, out float2 uv_undist ) { + if (D.kIsIdentity) { + uv_undist = uv; + return true; + } + float2 q = uv; - float2 prev_q = q; - for (int i = 0; i < maxiter; i++) { - float2 qd = camera_distortion(q, dist_coeffs); + float2 qd = D.distort(q, dist_coeffs); float2 r = qd - uv; - float err = dot(r, r); - - // bool use_newton = err < 1e-2; - bool use_newton = true; - - if (use_newton) { - float2x2 J = camera_distortion_jac(q, dist_coeffs); - q -= _solve2x2(J, r); - } else { - // float step = 0.5; - float step = clamp(0.5 + 0.5 / (1.0 + dot(r, r) * 10.0), 0.1, 0.9); - q = q - step * r; - } - - prev_q = q; + float2x2 J = camera_distortion_jac(q, dist_coeffs); + q -= _solve2x2(J, r); } uv_undist = q; // TODO: better way to tell so - return is_valid_distortion(uv_undist, dist_coeffs) && - length(camera_distortion(uv_undist, dist_coeffs) - uv) < 1e-2; + return is_valid_distortion(uv_undist, dist_coeffs) && + length(D.distort(uv_undist, dist_coeffs) - uv) < 1e-2; } -#if 0 -// find uv' that minimizes (distort(uv') - uv)^2 s.t. is_valid_distortion_func(uv') < 0 -bool undistort_point_clipped( - no_diff float2 uv, no_diff float[10] dist_coeffs, - int maxiter, out float2 q -) { - q = uv; - for (int i = 0; i < 4; i++) { - if (is_valid_distortion(q, dist_coeffs)) - break; - q *= 0.618f; - } - if (!is_valid_distortion(q, dist_coeffs)) - return false; - - float weight_b = 0.0f; - for (int i = 0; i < maxiter; i++) { - float2 qd = camera_distortion(q, dist_coeffs); - float2 r = qd - uv; - if (length(r) < 1e-4) - break; - - float2x2 J = camera_distortion_jac(q, dist_coeffs); - float2 grad_f = mul(transpose(J), r); - float2x2 hess_f = mul(transpose(J), J); - - float2 grad_b = valid_distortion_log_barrier_grad(q, dist_coeffs); - float2x2 hess_b = valid_distortion_log_barrier_hess(q, dist_coeffs); - - if (i == 0) { - weight_b = 10.0f * length(grad_f) / (length(grad_b) + 1e-6f); - } - - bool valid_found = false; - for (int j = 0; j < 8; j++) { - float2 grad = grad_f + weight_b * grad_b; - float2x2 hess = hess_f + weight_b * hess_b; - float2 dq = _solve2x2(J, r); - float2 q1 = q - dq; - if (is_valid_distortion(q1, dist_coeffs)) { - valid_found = true; - q = q1; - weight_b *= 0.25f; - break; - } - else { - weight_b *= 1.618f; - } - } - if (!valid_found) - return false; - } - - // TODO: better way to tell so - return true; - // return length(camera_distortion(q, dist_coeffs) - uv) < 1e-2; -} -#endif -[CudaDeviceExport] +// The model-aware helpers below take the camera model as a RUNTIME int (the +// pixel-wise kernels dispatch per camera, not per launch); only the distortion +// tier is compile-time. + +[ForceInline] [Differentiable] -float2 distort_point( +float2 distort_point( no_diff float2 uv, no_diff int camera_model, - no_diff float[10] dist_coeffs + no_diff float dist_coeffs[D.kNumParams] ) { CameraModelType model = (CameraModelType)camera_model; @@ -712,15 +641,15 @@ float2 distort_point( uv *= k; } - return camera_distortion(uv, dist_coeffs); + return D.distort(uv, dist_coeffs); } -[CudaDeviceExport] +[ForceInline] [Differentiable] -bool undistort_point( +bool undistort_point_model( no_diff float2 uv, no_diff int camera_model, - no_diff float[10] dist_coeffs, + no_diff float dist_coeffs[D.kNumParams], out float2 uv_undist ) { CameraModelType model = (CameraModelType)camera_model; @@ -735,7 +664,7 @@ bool undistort_point( } float2 uv_u; - if (!no_diff undistort_point(uv, dist_coeffs, 8, uv_u)) + if (!no_diff undistort_point(uv, dist_coeffs, 8, uv_u)) return false; uv = uv_u; @@ -760,26 +689,25 @@ bool undistort_point( return true; } -[CudaDeviceExport] -bool unproject_point( +[ForceInline] +bool unproject_point( no_diff float2 uv, no_diff int camera_model, - no_diff float[10] dist_coeffs, + no_diff float dist_coeffs[D.kNumParams], out float3 raydir ) { CameraModelType model = (CameraModelType)camera_model; raydir = float3(0); - // Equirectangular: uv holds (lon, lat); map straight to a direction. No - // distortion inversion (dist_coeffs ignored). + // Equirectangular: uv holds (lon, lat); map straight to a direction. if (model == CameraModelType::EQUIRECTANGULAR) { raydir = equirect_unproj(uv); return true; } float2 uv_u; - if (!undistort_point(uv, dist_coeffs, 8, uv_u)) + if (!undistort_point(uv, dist_coeffs, 8, uv_u)) return false; uv = uv_u; @@ -802,12 +730,12 @@ bool unproject_point( return true; } -[CudaDeviceExport] +[ForceInline] [Differentiable] -bool generate_ray( +bool generate_ray( no_diff float2 uv, no_diff int camera_model, - no_diff float[10] dist_coeffs, + no_diff float dist_coeffs[D.kNumParams], out float3 raydir ) { CameraModelType model = (CameraModelType)camera_model; @@ -825,7 +753,7 @@ bool generate_ray( } float2 uv_u; - if (!no_diff undistort_point(uv, dist_coeffs, 8, uv_u)) { + if (!no_diff undistort_point(uv, dist_coeffs, 8, uv_u)) { raydir = float3(0); return false; } @@ -860,6 +788,69 @@ bool generate_ray( } +// ================ +// Per-tier CUDA exports +// ================ +// +// slangc cannot export a generic, so each tier gets a thin wrapper. The CUDA +// side selects one at compile time through SlangDistortion in +// core/CameraDistortion.cuh; the Vulkan side calls the generics directly and +// picks the tier with the kDistortion specialization constant. + +#define _DEF_DIST_ENTRIES(suffix, D, NC) \ + [CudaDeviceExport] \ + bool is_valid_distortion##suffix(float2 uv, float dist_coeffs[NC]) { \ + return is_valid_distortion(uv, dist_coeffs); \ + } \ + [CudaDeviceExport] \ + bool persp_proj_nav##suffix( \ + float3 p_view, float4 intrins, float dist_coeffs[NC], out float2 uv \ + ) { return persp_proj(p_view, intrins, dist_coeffs, uv); } \ + [CudaDeviceExport] \ + bool fisheye_proj_nav##suffix( \ + float3 p_view, float4 intrins, float dist_coeffs[NC], out float2 uv \ + ) { return fisheye_proj(p_view, intrins, dist_coeffs, uv); } \ + [CudaDeviceExport] \ + bool equisolid_proj_nav##suffix( \ + float3 p_view, float4 intrins, float dist_coeffs[NC], out float2 uv \ + ) { return equisolid_proj(p_view, intrins, dist_coeffs, uv); } \ + [CudaDeviceExport] \ + float2x3 persp_proj_jac##suffix( \ + float3 p_view, float4 intrins, float dist_coeffs[NC] \ + ) { return persp_proj_jac(p_view, intrins, dist_coeffs); } \ + [CudaDeviceExport] \ + float2x3 fisheye_proj_jac##suffix( \ + float3 p_view, float4 intrins, float dist_coeffs[NC] \ + ) { return fisheye_proj_jac(p_view, intrins, dist_coeffs); } \ + [CudaDeviceExport] \ + float2x3 equisolid_proj_jac##suffix( \ + float3 p_view, float4 intrins, float dist_coeffs[NC] \ + ) { return equisolid_proj_jac(p_view, intrins, dist_coeffs); } \ + [CudaDeviceExport] \ + float2 distort_point##suffix( \ + float2 uv, int camera_model, float dist_coeffs[NC] \ + ) { return distort_point(uv, camera_model, dist_coeffs); } \ + [CudaDeviceExport] \ + bool undistort_point##suffix( \ + float2 uv, int camera_model, float dist_coeffs[NC], out float2 uv_undist \ + ) { return undistort_point_model(uv, camera_model, dist_coeffs, uv_undist); } \ + [CudaDeviceExport] \ + bool unproject_point##suffix( \ + float2 uv, int camera_model, float dist_coeffs[NC], out float3 raydir \ + ) { return unproject_point(uv, camera_model, dist_coeffs, raydir); } \ + [CudaDeviceExport] \ + bool generate_ray##suffix( \ + float2 uv, int camera_model, float dist_coeffs[NC], out float3 raydir \ + ) { return generate_ray(uv, camera_model, dist_coeffs, raydir); } + +_DEF_DIST_ENTRIES(_none, DistNone, 1) +_DEF_DIST_ENTRIES(_opencv, DistOpenCV, 4) +_DEF_DIST_ENTRIES(_prism, DistThinPrism, 8) +_DEF_DIST_ENTRIES(_rational, DistRational, 8) + +#undef _DEF_DIST_ENTRIES + + [CudaDeviceExport] [Differentiable] float3 transform_ray_o(float3x3 R, float3 t) { diff --git a/tools/codegen/generate_headers.py b/tools/codegen/generate_headers.py index b678f7ce..ebbe63ab 100644 --- a/tools/codegen/generate_headers.py +++ b/tools/codegen/generate_headers.py @@ -143,6 +143,7 @@ HEADER_SOURCES["kernels/pixelwise/PixelWise"] = [ # ray <-> linear depth "kernels/pixelwise/ImageDistort.cu", # distort / undistort "kernels/pixelwise/ImageWarp.cu", # wide <-> pinhole warps, incl. byte-fused + "kernels/pixelwise/ImageRedistort.cu", # resample from an unrepresentable source lens "kernels/pixelwise/GtDepthNormalWarp.cu", # GT depth/normal wide -> pinhole warps "kernels/ppisp/Ppisp.cu", # per-pixel image signal processing ] diff --git a/tools/codegen/generate_kernel_instantiation.py b/tools/codegen/generate_kernel_instantiation.py index bfd029ef..e6622d8d 100644 --- a/tools/codegen/generate_kernel_instantiation.py +++ b/tools/codegen/generate_kernel_instantiation.py @@ -11,6 +11,35 @@ SRC_DIR = Path("src") DST_DIR = SRC_DIR / "instantiations" +# The (camera model, distortion tier) pairs the CUDA kernels are instantiated +# for. Must match camera_distortion_is_compiled() in src/core/CameraModel.h, +# SS_FOR_EACH_CAMERA_VARIANT in src/kernels/projection/CameraVariants.cuh and +# the export list in src/shaders/primitive_3dgs.slang. +kCameraVariants = [ + ("CameraModelType::PINHOLE", "CameraDistortionType::None"), + ("CameraModelType::PINHOLE", "CameraDistortionType::OpenCV"), + ("CameraModelType::PINHOLE", "CameraDistortionType::ThinPrism"), + ("CameraModelType::PINHOLE", "CameraDistortionType::Rational"), + ("CameraModelType::FISHEYE", "CameraDistortionType::None"), + ("CameraModelType::FISHEYE", "CameraDistortionType::OpenCV"), + ("CameraModelType::FISHEYE", "CameraDistortionType::ThinPrism"), + ("CameraModelType::EQUISOLID", "CameraDistortionType::None"), + ("CameraModelType::EQUISOLID", "CameraDistortionType::OpenCV"), + ("CameraModelType::EQUISOLID", "CameraDistortionType::ThinPrism"), + ("CameraModelType::EQUIRECTANGULAR", "CameraDistortionType::None"), +] + +# Interleaved [3DGS, Mip, 3DGUT] per SH degree; the `includes` lists below rely +# on that ordering to route each block to the right primitive header. +kPrimitives = [ + "Vanilla3DGS<0>", "MipSplatting<0>", "Vanilla3DGUT<0>", + "Vanilla3DGS<1>", "MipSplatting<1>", "Vanilla3DGUT<1>", + "Vanilla3DGS<2>", "MipSplatting<2>", "Vanilla3DGUT<2>", + "Vanilla3DGS<3>", "MipSplatting<3>", "Vanilla3DGUT<3>", + "Vanilla3DGS<4>", "MipSplatting<4>", "Vanilla3DGUT<4>", +] + + def extract_kernel_definition(header_src: Path, kernel_name: str): header_src = SRC_DIR / header_src src = open(header_src, "r").read() @@ -189,111 +218,76 @@ def generate_ProjectionFwd(): ("kernels/projection/ProjectionPackedFwd.cu", "kernels/projection/ProjectionPackedFwd_kernel.cuh", "ProjectionPackedFwd", "projection_packed_fwd_kernel_wrapper"), ]: definition = extract_kernel_definition(filename, wrapper_name) - map_header = ["typename SplatPrimitive", None] + map_header = ["typename SplatPrimitive", None, None] map_body = [ - *itertools.product( - [ - "Vanilla3DGS<0>", "MipSplatting<0>", "Vanilla3DGUT<0>", - "Vanilla3DGS<1>", "MipSplatting<1>", "Vanilla3DGUT<1>", - "Vanilla3DGS<2>", "MipSplatting<2>", "Vanilla3DGUT<2>", - "Vanilla3DGS<3>", "MipSplatting<3>", "Vanilla3DGUT<3>", - "Vanilla3DGS<4>", "MipSplatting<4>", "Vanilla3DGUT<4>", - ], - ["CameraModelType::PINHOLE", "CameraModelType::FISHEYE", "CameraModelType::EQUISOLID", "CameraModelType::EQUIRECTANGULAR"], - ) + (prim, cam, dist) + for prim in kPrimitives + for cam, dist in kCameraVariants ] + nv = len(kCameraVariants) includes = [*( - [("primitives/Primitive3DGS.cuh", kernel_filename)] * 8 + - [("primitives/Primitive3DGUT.cuh", kernel_filename)] * 4 + [("primitives/Primitive3DGS.cuh", kernel_filename)] * (2 * nv) + + [("primitives/Primitive3DGUT.cuh", kernel_filename)] * nv )] * 5 generate_kernel_instantiation(prefix, definition, map_header, map_body, includes) -def generate_ProjectionBwd(): - definition = extract_kernel_definition("kernels/projection/ProjectionBwd.cu", "projection_fused_bwd_kernel_wrapper") - map_header = ["typename SplatPrimitive", None] +def _generate_projection_bwd(prefix, source, wrapper_name, kernel_filename): + definition = extract_kernel_definition(source, wrapper_name) + map_header = ["typename SplatPrimitive", None, None] map_body = [ - *itertools.product( - [ - "Vanilla3DGS<0>", "MipSplatting<0>", "Vanilla3DGUT<0>", - "Vanilla3DGS<1>", "MipSplatting<1>", "Vanilla3DGUT<1>", - "Vanilla3DGS<2>", "MipSplatting<2>", "Vanilla3DGUT<2>", - "Vanilla3DGS<3>", "MipSplatting<3>", "Vanilla3DGUT<3>", - "Vanilla3DGS<4>", "MipSplatting<4>", "Vanilla3DGUT<4>", - ], - ["CameraModelType::PINHOLE", "CameraModelType::FISHEYE", "CameraModelType::EQUISOLID", "CameraModelType::EQUIRECTANGULAR"], - ) + (prim, cam, dist) + for prim in kPrimitives + for cam, dist in kCameraVariants ] + nv = len(kCameraVariants) includes = [*( - [("primitives/Primitive3DGS.cuh", "kernels/projection/ProjectionBwd_kernel.cuh")] * 8 + - [("primitives/Primitive3DGUT.cuh", "kernels/projection/ProjectionBwd_kernel.cuh")] * 4 + [("primitives/Primitive3DGS.cuh", kernel_filename)] * (2 * nv) + + [("primitives/Primitive3DGUT.cuh", kernel_filename)] * nv )] * 5 - generate_kernel_instantiation("ProjectionBwd", definition, map_header, map_body, includes) + generate_kernel_instantiation(prefix, definition, map_header, map_body, includes) + + +def generate_ProjectionBwd(): + _generate_projection_bwd( + "ProjectionBwd", "kernels/projection/ProjectionBwd.cu", + "projection_fused_bwd_kernel_wrapper", + "kernels/projection/ProjectionBwd_kernel.cuh") def generate_ProjectionBwdQuantGrad(): - definition = extract_kernel_definition("kernels/projection/ProjectionBwdQuantGrad.cu", "projection_bwd_quantgrad_kernel_wrapper") - map_header = ["typename SplatPrimitive", None] - map_body = [ - *itertools.product( - [ - "Vanilla3DGS<0>", "MipSplatting<0>", "Vanilla3DGUT<0>", - "Vanilla3DGS<1>", "MipSplatting<1>", "Vanilla3DGUT<1>", - "Vanilla3DGS<2>", "MipSplatting<2>", "Vanilla3DGUT<2>", - "Vanilla3DGS<3>", "MipSplatting<3>", "Vanilla3DGUT<3>", - "Vanilla3DGS<4>", "MipSplatting<4>", "Vanilla3DGUT<4>", - ], - ["CameraModelType::PINHOLE", "CameraModelType::FISHEYE", "CameraModelType::EQUISOLID", "CameraModelType::EQUIRECTANGULAR"], - ) - ] - includes = [*( - [("primitives/Primitive3DGS.cuh", "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh")] * 8 + - [("primitives/Primitive3DGUT.cuh", "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh")] * 4 - )] * 5 - - generate_kernel_instantiation("ProjectionBwdQuantGrad", definition, map_header, map_body, includes) + _generate_projection_bwd( + "ProjectionBwdQuantGrad", "kernels/projection/ProjectionBwdQuantGrad.cu", + "projection_bwd_quantgrad_kernel_wrapper", + "kernels/projection/ProjectionBwdQuantGrad_kernel.cuh") def generate_FusedProjectionBwdOptim(): definition = extract_kernel_definition("kernels/optim/FusedProjectionBwdOptim.cu", "fused_projection_bwd_optimizer_3dgs_kernel_wrapper") - # Six template args: SplatPrimitive, camera_model, - # hessian_diagonal_output_mode, use_scale_agnostic_mean, - # color_trust_linear, LEVEL. + # Six template args: SplatPrimitive, camera_model, distortion, + # use_scale_agnostic_mean, color_trust_linear, LEVEL. # # LEVEL collapses the prior (QUANT_BITS, VALUE_BITS) axes into 2 combos: # 0 = off (32-bit value, fp32 optim state) # 1 = light (16-bit value, 8-bit packed optim) # The wrapper derives BLOCK_SIZE / QUANT_BITS / VALUE_BITS internally via # constexpr, so each wrapper compiles ONE kernel specialization. - map_header = ["typename SplatPrimitive", None, None, None, None] - primitives = [ - "Vanilla3DGS<0>", "MipSplatting<0>", "Vanilla3DGUT<0>", - "Vanilla3DGS<1>", "MipSplatting<1>", "Vanilla3DGUT<1>", - "Vanilla3DGS<2>", "MipSplatting<2>", "Vanilla3DGUT<2>", - "Vanilla3DGS<3>", "MipSplatting<3>", "Vanilla3DGUT<3>", - "Vanilla3DGS<4>", "MipSplatting<4>", "Vanilla3DGUT<4>", - ] - cams = ["CameraModelType::PINHOLE", - "CameraModelType::FISHEYE", - "CameraModelType::EQUISOLID", - "CameraModelType::EQUIRECTANGULAR"] + map_header = ["typename SplatPrimitive", None, None, None, None, None] map_body = [ - (prim, cam, sam, ctl, level) - for prim in primitives - for cam in cams + (prim, cam, dist, sam, ctl, level) + for prim in kPrimitives + for cam, dist in kCameraVariants for sam in ("true", "false") for ctl in ("true", "false") for level in ("0", "1") ] - # Per primitive: 4 cams * 2 sam * 2 ctl * 2 levels = 32 instantiations. - # 15 primitives * 32 = 480 total. The `primitives` list interleaves - # [3DGS, Mip, 3DGUT] per SH degree, so per SH degree we get 2*32 - # Primitive3DGS entries (3DGS+Mip) followed by 32 Primitive3DGUT entries. + # Per primitive: len(kCameraVariants) * 2 sam * 2 ctl * 2 levels. + per_prim = len(kCameraVariants) * 8 includes = [*( - [("primitives/Primitive3DGS.cuh", "kernels/optim/FusedProjectionBwdOptim_kernel.cuh")] * (32 * 2) + - [("primitives/Primitive3DGUT.cuh", "kernels/optim/FusedProjectionBwdOptim_kernel.cuh")] * 32 + [("primitives/Primitive3DGS.cuh", "kernels/optim/FusedProjectionBwdOptim_kernel.cuh")] * (per_prim * 2) + + [("primitives/Primitive3DGUT.cuh", "kernels/optim/FusedProjectionBwdOptim_kernel.cuh")] * per_prim )] * 5 generate_kernel_instantiation("FusedProjectionBwdOptim", definition, map_header, map_body, includes) @@ -330,34 +324,32 @@ def generate_RasterizationBwd(): def generate_RasterizationEval3DFwd(): definition = extract_kernel_definition("kernels/raster/RasterizationEval3DFwd.cu", "rasterize_to_pixels_eval3d_fwd_kernel_wrapper") - map_header = ["typename SplatPrimitive", None, None, None] + map_header = ["typename SplatPrimitive", None, None, None, None] map_body = [ - *itertools.product( - ["Vanilla3DGUT<0>"], - ["CameraModelType::PINHOLE", "CameraModelType::FISHEYE", "CameraModelType::EQUISOLID", "CameraModelType::EQUIRECTANGULAR"], - ["DistortionType::None", "DistortionType::D", "DistortionType::RGB_D"], # dist_type - ["true", "false"], # output_median - ) + (prim, cam, dist, dt, median) + for prim in ["Vanilla3DGUT<0>"] + for cam, dist in kCameraVariants + for dt in ("DistortionType::None", "DistortionType::D", "DistortionType::RGB_D") + for median in ("true", "false") ] - includes = [("primitives/Primitive3DGUT.cuh", "kernels/raster/RasterizationEval3DFwd_kernel.cuh")] * 24 + includes = [("primitives/Primitive3DGUT.cuh", "kernels/raster/RasterizationEval3DFwd_kernel.cuh")] * len(map_body) generate_kernel_instantiation("RasterizationEval3DFwd", definition, map_header, map_body, includes) def generate_RasterizationEval3DBwd(): definition = extract_kernel_definition("kernels/raster/RasterizationEval3DBwd.cu", "rasterize_to_pixels_eval3d_bwd_kernel_wrapper") - map_header = ["typename SplatPrimitive", None, None, None, None, None] + map_header = ["typename SplatPrimitive", None, None, None, None, None, None] map_body = [ - *itertools.product( - ["Vanilla3DGUT<0>"], - ["CameraModelType::PINHOLE", "CameraModelType::FISHEYE", "CameraModelType::EQUISOLID", "CameraModelType::EQUIRECTANGULAR"], - ["DistortionType::None", "DistortionType::D", "DistortionType::RGB_D"], # dist_type - ['true', 'false'], # output_viewmat_grad - ['true', 'false'], # output_accum_weight - ['true', 'false'], # output_median - ) + (prim, cam, dist, dt, viewmat_grad, accum_weight, median) + for prim in ["Vanilla3DGUT<0>"] + for cam, dist in kCameraVariants + for dt in ("DistortionType::None", "DistortionType::D", "DistortionType::RGB_D") + for viewmat_grad in ("true", "false") + for accum_weight in ("true", "false") + for median in ("true", "false") ] - includes = [("primitives/Primitive3DGUT.cuh", "kernels/raster/RasterizationEval3DBwd_kernel.cuh")] * 96 + includes = [("primitives/Primitive3DGUT.cuh", "kernels/raster/RasterizationEval3DBwd_kernel.cuh")] * len(map_body) generate_kernel_instantiation("RasterizationEval3DBwd", definition, map_header, map_body, includes)