From d579cf8c755f475d43eebaf7e2f0874eb633e595 Mon Sep 17 00:00:00 2001 From: Harry Chen Date: Fri, 18 Sep 2026 02:16:32 -0400 Subject: [PATCH] hdr: tuning on exposure bracketed datasets --- docs/notes/color-transfer.md | 10 +- reference/scripts/downscale_images.py | 77 +- src/app/TrainerCore.cpp | 3 +- src/backend/tests/pwtrain_parity.cpp | 27 +- .../vulkan/kernels/PixelWiseRender.cpp | 11 +- src/backend/vulkan/kernels/PixelWiseTrain.cpp | 13 +- .../vulkan/shaders/pixel_wise_render.slang | 13 +- .../vulkan/shaders/pixel_wise_train.slang | 13 +- src/config/TrainConfig.h | 6 +- src/core/ColorSpace.h | 2 +- src/core/PoolSlots.h | 1 + src/engine/EngineBackground.cpp | 25 + src/engine/EngineConfig.h | 3 +- src/engine/EngineDataManager.cpp | 121 +- src/engine/EngineState.h | 9 + src/engine/EngineTrainStep.cpp | 1 + src/generated/pixel_wise.cuh | 6566 +++++++++-------- src/generated/ppisp.cuh | 252 +- src/i18n/catalog/TrainFields.h | 203 +- src/kernels/pixelwise/ImageColorOps.cu | 26 +- src/kernels/pixelwise/PixelWise.cuh | 4 + src/shaders/pixel_wise.slang | 15 +- 22 files changed, 3894 insertions(+), 3507 deletions(-) diff --git a/docs/notes/color-transfer.md b/docs/notes/color-transfer.md index 67a2a93f..8d995913 100644 --- a/docs/notes/color-transfer.md +++ b/docs/notes/color-transfer.md @@ -24,7 +24,7 @@ display = TONE( M · (is_linear ? c : EOTF_sRGB(c)) ) | value | display encode | |---|---| | `none` (unset) | image side: `srgb`. splat side: whatever the image side resolved to | -| `srgb` | sRGB OETF, unbounded — the default, and what matches a photograph | +| `srgb` | sRGB OETF, clipped at black and open above — the default, and what matches a photograph | | `srgb-clamped` | clipped to `[0,1]`, then the OETF | | `aces` | Narkowicz ACES fit, clipped, then the OETF | | `filmic` | Hejl / Burgess-Dawson (its gamma is baked in) | @@ -58,7 +58,7 @@ image side, which is what keeps the render matching the photographs. ## Why a tone curve is worth having -Under `srgb`, the OETF is monotone and unbounded, so a photograph whose pixel +Under `srgb`, the OETF is monotone and unbounded above, so a photograph whose pixel reads 0.99 is explained by a splat at linear 0.977 and nothing more. Every capture that nearly clipped is reconstructed as if it had not been bright. @@ -108,6 +108,12 @@ the only place the curves are not exact inverses of each other. `--convert-initial-point-cloud-color`). - **The noise background.** `--background-mode noise` draws in display space and inverts both halves per pixel, so mid-grey stays mid-grey on screen. + `--background-match-luminance` first raises the draw to a per-image power, + computed on the host each step from the photo's mean luma and its current + PPISP exposure (`_bg_luma_exponent`), that puts the draw's median on that + luma ahead of the exposure, so a night capture is not plugged with haze to + hide a mid-grey background. The draw's 0 and 1 are fixed points, so the + `pseudorandom` corners are unaffected once the warm-up is over. ## `none` is unset, everywhere diff --git a/reference/scripts/downscale_images.py b/reference/scripts/downscale_images.py index 45e9ed2d..1ef3bbc0 100644 --- a/reference/scripts/downscale_images.py +++ b/reference/scripts/downscale_images.py @@ -2,6 +2,7 @@ import argparse import os +import re from pathlib import Path from concurrent.futures import ThreadPoolExecutor from tqdm import tqdm @@ -10,6 +11,7 @@ import cv2 import numpy as np import OpenEXR import Imath +import piexif IMAGE_EXTENSIONS = { @@ -25,6 +27,9 @@ IMAGE_EXTENSIONS = { } EXR_EXTENSIONS = {".exr"} +JPEG_EXTENSIONS = {".jpg", ".jpeg"} +# Formats Pillow re-saves losslessly with an EXIF block attached. +PIL_EXIF_EXTENSIONS = {".png", ".tif", ".tiff"} _FLOAT_PT = Imath.PixelType(Imath.PixelType.FLOAT) @@ -49,6 +54,62 @@ def find_images(root: Path): ] +def read_exif(path: Path): + """The source's EXIF as a piexif dict, or None when it carries none.""" + try: + exif = piexif.load(str(path)) + except Exception: + try: + from PIL import Image + with Image.open(path) as im: + raw = im.info.get("exif") + exif = piexif.load(raw) if raw else None + except Exception: + exif = None + if exif and any(exif.get(k) for k in ("0th", "Exif", "GPS", "Interop")): + return exif + return None + + +def exif_bytes_for(exif: dict, w: int, h: int) -> bytes: + """Serialize `exif` with the pixel-dimension tags rewritten for a w x h image. + + Everything else is copied as is; a tag piexif cannot re-encode is dropped + rather than losing the whole block. + """ + exif = {k: (dict(v) if isinstance(v, dict) else v) for k, v in exif.items()} + zeroth, ex = exif.setdefault("0th", {}), exif.setdefault("Exif", {}) + if piexif.ImageIFD.ImageWidth in zeroth: + zeroth[piexif.ImageIFD.ImageWidth] = w + if piexif.ImageIFD.ImageLength in zeroth: + zeroth[piexif.ImageIFD.ImageLength] = h + if piexif.ExifIFD.PixelXDimension in ex: + ex[piexif.ExifIFD.PixelXDimension] = w + if piexif.ExifIFD.PixelYDimension in ex: + ex[piexif.ExifIFD.PixelYDimension] = h + while True: + try: + return piexif.dump(exif) + except ValueError as e: + # piexif reports an unencodable tag as " in IFD". + m = re.search(r"(\d+) in (\w+) IFD", str(e)) + if not m or int(m.group(1)) not in exif.get(m.group(2), {}): + raise + del exif[m.group(2)][int(m.group(1))] + + +def attach_exif(dst_path: Path, exif: dict, w: int, h: int, dtype): + ext = dst_path.suffix.lower() + if ext in JPEG_EXTENSIONS: + piexif.insert(exif_bytes_for(exif, w, h), str(dst_path)) + elif ext in PIL_EXIF_EXTENSIONS and dtype == np.uint8: + # Pillow truncates >8-bit color to 8 bits, hence the dtype guard. + from PIL import Image + with Image.open(dst_path) as im: + im.load() + im.save(dst_path, exif=exif_bytes_for(exif, w, h)) + + def read_exr(path: Path): """Return (HxWxC float32 array, channel_names, channel_types).""" exr = OpenEXR.InputFile(str(path)) @@ -84,15 +145,19 @@ def write_exr(path: Path, img: np.ndarray, channel_names: list, channel_types: l def save_image(dst_path: Path, image, jpeg_quality: int, - exr_channels=None, exr_types=None): + exr_channels=None, exr_types=None, exif=None): dst_path.parent.mkdir(parents=True, exist_ok=True) ext = dst_path.suffix.lower() if ext in EXR_EXTENSIONS: write_exr(dst_path, image, exr_channels, exr_types) - elif ext in (".jpg", ".jpeg"): + return + if ext in JPEG_EXTENSIONS: cv2.imwrite(str(dst_path), image, [cv2.IMWRITE_JPEG_QUALITY, jpeg_quality]) else: cv2.imwrite(str(dst_path), image) + if exif is not None: + h, w = image.shape[:2] + attach_exif(dst_path, exif, w, h, image.dtype) def process_image( @@ -105,14 +170,18 @@ def process_image( try: ext = src_path.suffix.lower() exr_channels = exr_types = None + exif = None if ext in EXR_EXTENSIONS: img, exr_channels, exr_types = read_exr(src_path) else: + # IMREAD_UNCHANGED leaves the pixels in stored orientation, so the + # EXIF Orientation tag stays valid for the copies. img = cv2.imread(str(src_path), cv2.IMREAD_UNCHANGED) if img is None: print(f"Failed to read: {src_path}") return + exif = read_exif(src_path) orig_h, orig_w = img.shape[:2] rel_path = src_path.relative_to(src_root) @@ -126,7 +195,7 @@ def process_image( new_h = max(1, orig_h // scale) resized = cv2.resize(prev_img, (new_w, new_h), interpolation=cv2.INTER_AREA) dst_path = dst_roots[scale] / rel_path - save_image(dst_path, resized, jpeg_quality, exr_channels, exr_types) + save_image(dst_path, resized, jpeg_quality, exr_channels, exr_types, exif) prev_img = resized except Exception as e: @@ -135,7 +204,7 @@ def process_image( def main(): parser = argparse.ArgumentParser( - description="Generate downscaled image pyramids." + description="Generate downscaled image pyramids, carrying EXIF over." ) parser.add_argument("work_folder", type=Path) diff --git a/src/app/TrainerCore.cpp b/src/app/TrainerCore.cpp index cbb739fa..ecb83f98 100644 --- a/src/app/TrainerCore.cpp +++ b/src/app/TrainerCore.cpp @@ -369,7 +369,7 @@ EngineStepConfig build_step_config(const TrainConfig& c, const RunState& st, int cfg.loss.loss_map_power = c.densify_loss_map_power; cfg.loss.loss_map_accum_mode = densify_accum_mode_int(c.densify_accum_mode); cfg.loss.saturation_threshold = c.loss_saturation_threshold; - cfg.loss.normalize_by_luminance = c.normalize_loss_by_luminance; + cfg.loss.luminance_normalization = c.loss_luminance_normalization; cfg.loss.overexposure_reg_weight = c.overexposure_reg; if (st.bilagrid_rgb_init || st.ppisp_init) { cfg.loss.color_shift_reg_weight = c.color_shift_reg_weight; @@ -497,6 +497,7 @@ EngineStepConfig build_step_config(const TrainConfig& c, const RunState& st, int float rw = std::min((float)step / std::max(c.background_noise_warmup, 1), 1.0f); cfg.background.randomize_weight = 1.0f - (1.0f - c.background_noise_pre_warmup) * (1.0f - rw); + cfg.background.match_luminance = c.background_match_luminance; } else if (c.background_mode == "sh") { cfg.background.lr_dc = scheduled_lr(step, max_steps_lr, c.background_dc_lr); cfg.background.lr_sh = scheduled_lr(step, max_steps_lr, c.background_sh_lr); diff --git a/src/backend/tests/pwtrain_parity.cpp b/src/backend/tests/pwtrain_parity.cpp index 75302a77..a0ae68c2 100644 --- a/src/backend/tests/pwtrain_parity.cpp +++ b/src/backend/tests/pwtrain_parity.cpp @@ -107,13 +107,38 @@ int main(int argc, char** argv) { float* d_vt = fresh1(); blend_background_noise_backward(xf, lin != 0, blocky != 0, block_px, t3(d_rgb), t1(d_T), 0.7f, - 1234u + xf, over, t3(d_vout), + 1234u + xf, nullptr, nullptr, + over, t3(d_vout), t3(d_vr), t1(d_vt)); backend::device_synchronize(); readback_f(acc, d_vr, PIX * 3); readback_f(acc, d_vt, PIX); } + // ---- the luma-matched draw: a per-slot power table and slot indices + { + const float* d_exp = upload({1.0f, 3.9f, 0.6f, 6.5f}); + const int32_t* d_cams = upload({3, 1}); + for (int xf : {0, 4}) for (int lin = 0; lin < 2; lin++) + for (int blocky = 0; blocky < 2; blocky++) + for (unsigned block_px : {0u, 4u}) { + float* d_out = fresh3(); + blend_background_noise_forward(xf, lin != 0, blocky != 0, block_px, + t3(d_rgb), t1(d_T), 0.7f, 77u + xf, + d_exp, d_cams, t3(d_out)); + float* d_vr = fresh3(); + float* d_vt = fresh1(); + blend_background_noise_backward(xf, lin != 0, blocky != 0, block_px, + t3(d_rgb), t1(d_T), 0.7f, 77u + xf, + d_exp, d_cams, 0.0f, t3(d_vout), + t3(d_vr), t1(d_vt)); + backend::device_synchronize(); + readback_f(acc, d_out, PIX * 3); + readback_f(acc, d_vr, PIX * 3); + readback_f(acc, d_vt, PIX); + } + } + // ---- blend_background_color_backward (reg off, then the fused one) ---- for (float over : {0.0f, 3.0f}) { float* d_vr = fresh3(); diff --git a/src/backend/vulkan/kernels/PixelWiseRender.cpp b/src/backend/vulkan/kernels/PixelWiseRender.cpp index d3c1bfff..82569b14 100644 --- a/src/backend/vulkan/kernels/PixelWiseRender.cpp +++ b/src/backend/vulkan/kernels/PixelWiseRender.cpp @@ -20,11 +20,11 @@ static_assert(sizeof(BlendBgParams) == 4 * 8 + 2 * 4, "layout"); // Mirrors BlendBgNoiseParams. struct BlendBgNoiseParams { - uint64_t rgb, transmittance, out_rgb; + uint64_t rgb, transmittance, out_rgb, exponent_by_cam, cam_indices; float randomize_weight; - uint32_t seed, HW, total, wgs_per_row, W, blocky, block_px; + uint32_t seed, HW, total, wgs_per_row, W, blocky, block_px, match_luma; }; -static_assert(sizeof(BlendBgNoiseParams) == 3 * 8 + 8 * 4, "layout"); +static_assert(sizeof(BlendBgNoiseParams) == 5 * 8 + 9 * 4 + 4 /*pad*/, "layout"); // Mirrors BlendBgColorParams. struct BlendBgColorParams { @@ -82,6 +82,8 @@ void blend_background_noise_forward( DeviceTensor3D transmittance, float randomize_weight, uint32_t seed, + const float* exponent_by_cam, + const int32_t* cam_indices, DeviceTensor3D out_rgb ) { const int64_t hw = rgb.size<1>() * rgb.size<2>(); @@ -90,6 +92,9 @@ void blend_background_noise_forward( p.rgb = (uint64_t)rgb.data_ptr(); p.transmittance = (uint64_t)transmittance.data_ptr(); p.out_rgb = (uint64_t)out_rgb.data_ptr(); + p.exponent_by_cam = (uint64_t)exponent_by_cam; + p.cam_indices = (uint64_t)cam_indices; + p.match_luma = exponent_by_cam ? 1u : 0u; p.randomize_weight = randomize_weight; p.seed = seed; p.HW = (uint32_t)hw; diff --git a/src/backend/vulkan/kernels/PixelWiseTrain.cpp b/src/backend/vulkan/kernels/PixelWiseTrain.cpp index 1ee4d845..afbb3c14 100644 --- a/src/backend/vulkan/kernels/PixelWiseTrain.cpp +++ b/src/backend/vulkan/kernels/PixelWiseTrain.cpp @@ -24,12 +24,12 @@ static_assert(sizeof(BlendBgBwdParams) == 7 * 8 + 3 * 4 + 4 /*pad*/, // Mirrors BlendBgNoiseBwdParams. struct BlendBgNoiseBwdParams { - uint64_t rgb, transmittance, v_out_rgb, v_rgb, v_transmittance; + uint64_t rgb, transmittance, v_out_rgb, v_rgb, v_transmittance, + exponent_by_cam, cam_indices; float overexposure_scale, randomize_weight; - uint32_t seed, HW, total, wgs_per_row, W, blocky, block_px; + uint32_t seed, HW, total, wgs_per_row, W, blocky, block_px, match_luma; }; -static_assert(sizeof(BlendBgNoiseBwdParams) == 5 * 8 + 9 * 4 + 4 /*pad*/, - "layout"); +static_assert(sizeof(BlendBgNoiseBwdParams) == 7 * 8 + 10 * 4, "layout"); // Mirrors BlendBgColorBwdParams. struct BlendBgColorBwdParams { @@ -138,6 +138,8 @@ void blend_background_noise_backward( DeviceTensor3D transmittance, float randomize_weight, uint32_t seed, + const float* exponent_by_cam, + const int32_t* cam_indices, float overexposure_weight, DeviceTensor3D v_out_rgb, DeviceTensor3D v_rgb, @@ -146,6 +148,9 @@ void blend_background_noise_backward( const int64_t hw = rgb.size<1>() * rgb.size<2>(); const int64_t total = rgb.size<0>() * hw; BlendBgNoiseBwdParams p{}; + p.exponent_by_cam = (uint64_t)exponent_by_cam; + p.cam_indices = (uint64_t)cam_indices; + p.match_luma = exponent_by_cam ? 1u : 0u; p.overexposure_scale = overexposure_scale( rgb.size<0>(), rgb.size<1>(), rgb.size<2>(), overexposure_weight); p.rgb = (uint64_t)rgb.data_ptr(); diff --git a/src/backend/vulkan/shaders/pixel_wise_render.slang b/src/backend/vulkan/shaders/pixel_wise_render.slang index b4c4a6a2..c34dfaf5 100644 --- a/src/backend/vulkan/shaders/pixel_wise_render.slang +++ b/src/backend/vulkan/shaders/pixel_wise_render.slang @@ -114,10 +114,12 @@ float3 _bg_sample(uint blocky, uint block_px, uint seed, uint gid, uint bid, float(hash_uint3(seed + 2, cid, bid)) * exp2(-31.0f) - 1.0f); } -struct BlendBgNoiseParams { // 56 bytes: pushed directly +struct BlendBgNoiseParams { // 80 bytes: pushed directly float* rgb; // [B,H,W,3] float* transmittance; // [B,H,W,1] float* out_rgb; // [B,H,W,3] + float* exponent_by_cam; // power per camera slot, read when match_luma != 0 + int* cam_indices; // [B] slot per image float randomize_weight; uint32_t seed; uint32_t HW; // H*W (hash uses per-image pixel id + batch id) @@ -126,8 +128,15 @@ struct BlendBgNoiseParams { // 56 bytes: pushed directly uint32_t W; uint32_t blocky; uint32_t block_px; + uint32_t match_luma; }; +// Mirrors _bg_exponent in kernels/pixelwise/ImageColorOps.cu. +float _bg_exponent(uint bid, uint match_luma, float* exponent_by_cam, + int* cam_indices) { + return match_luma != 0u ? exponent_by_cam[uint(cam_indices[bid])] : 1.0f; +} + [shader("compute")] [numthreads(128, 1, 1)] void blend_background_noise_fwd(uint3 wg: SV_GroupID, @@ -144,6 +153,8 @@ void blend_background_noise_fwd(uint3 wg: SV_GroupID, float3 background = _bg_sample(p.blocky, p.block_px, p.seed, gid, bid, p.W); background = 0.5f + 0.5f * p.randomize_weight * background; + background = background_apply_exponent(background, + _bg_exponent(bid, p.match_luma, p.exponent_by_cam, p.cam_indices)); background = display_to_working3(background, kTransfer, kIsLinear != 0); rgb = blend_background(rgb, T, background); diff --git a/src/backend/vulkan/shaders/pixel_wise_train.slang b/src/backend/vulkan/shaders/pixel_wise_train.slang index e488576c..bcafe244 100644 --- a/src/backend/vulkan/shaders/pixel_wise_train.slang +++ b/src/backend/vulkan/shaders/pixel_wise_train.slang @@ -131,12 +131,14 @@ float3 _bg_sample(uint blocky, uint block_px, uint seed, uint gid, uint bid, float(_pwt_hash_uint3(seed + 2, cid, bid)) * exp2(-31.0f) - 1.0f); } -struct BlendBgNoiseBwdParams { // 80 bytes: pushed directly +struct BlendBgNoiseBwdParams { // 96 bytes: pushed directly float* rgb; // PRE-blend float* transmittance; float* v_out_rgb; float* v_rgb; float* v_transmittance; + float* exponent_by_cam; // power per camera slot, read when match_luma != 0 + int* cam_indices; // [B] slot per image float overexposure_scale; float randomize_weight; uint32_t seed; @@ -146,8 +148,15 @@ struct BlendBgNoiseBwdParams { // 80 bytes: pushed directly uint32_t W; uint32_t blocky; uint32_t block_px; + uint32_t match_luma; }; +// Mirrors _bg_exponent in kernels/pixelwise/ImageColorOps.cu. +float _pwt_bg_exponent(uint bid, uint match_luma, float* exponent_by_cam, + int* cam_indices) { + return match_luma != 0u ? exponent_by_cam[uint(cam_indices[bid])] : 1.0f; +} + [shader("compute")] [numthreads(128, 1, 1)] void blend_bg_noise_bwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, @@ -163,6 +172,8 @@ void blend_bg_noise_bwd(uint3 wg: SV_GroupID, uint tid: SV_GroupThreadID, float3 background = _bg_sample(p.blocky, p.block_px, p.seed, gid, bid, p.W); background = 0.5f + 0.5f * p.randomize_weight * background; + background = background_apply_exponent(background, + _pwt_bg_exponent(bid, p.match_luma, p.exponent_by_cam, p.cam_indices)); background = display_to_working3(background, kTransfer, kIsLinear != 0); float3 v_out = float3(p.v_out_rgb[3 * idx], p.v_out_rgb[3 * idx + 1], diff --git a/src/config/TrainConfig.h b/src/config/TrainConfig.h index e8141b43..f2c84c18 100644 --- a/src/config/TrainConfig.h +++ b/src/config/TrainConfig.h @@ -152,6 +152,7 @@ inline int train_tier_rank(const char* tier) { X(int, background_sh_degree, 4, "splats", "basic", "") \ X(int, background_noise_warmup, 2000, "splats", "expert", "") \ X(float, background_noise_pre_warmup, 0.25f, "splats", "expert", "") \ + X(bool, background_match_luminance, false, "splats", "advanced", "") \ X(std::optional, scale_init, std::nullopt, "splats", "advanced", "") \ X(std::optional, opacity_init, std::nullopt, "splats", "advanced", "") \ X(bool, suppress_initial_scales, false, "splats", "expert", "") \ @@ -205,7 +206,7 @@ inline int train_tier_rank(const char* tier) { X(float, alpha_loss_weight, 0.1f, "loss", "basic", "") \ X(float, alpha_loss_weight_under, 0.0f, "loss", "basic", "") \ X(float, loss_saturation_threshold, -1.0f, "loss", "advanced", "") \ - X(bool, normalize_loss_by_luminance, false, "loss", "advanced", "") \ + X(float, loss_luminance_normalization, 0.0f, "loss", "advanced", "") \ \ /* ==== geometry -- how crisp the surfaces come out, and depth/normal guidance ==== */ \ X(std::string, floater_suppression, "off", "geometry", "basic", "off|mild|strong") \ @@ -433,9 +434,10 @@ inline bool train_apply_preset(TrainConfig& c, const std::string& name) { // c.ppisp_adagrad_lr = 0.25f; c.ppisp_exposure_from_exif = true; c.background_mode = "random"; + c.background_match_luminance = true; // c.depth_distortion_reg = 0.01f; c.loss_saturation_threshold = 0.98f; - c.normalize_loss_by_luminance = true; + // c.loss_luminance_normalization = 0.5f; c.dc_reg = 0.0f; c.max_screen_size = 0.15f; // c.features_dc_lr = 0.0015f; diff --git a/src/core/ColorSpace.h b/src/core/ColorSpace.h index 77d04ada..6e96717a 100644 --- a/src/core/ColorSpace.h +++ b/src/core/ColorSpace.h @@ -131,7 +131,7 @@ inline float tone_encode(float x, Transfer t) { return linear_to_srgb(std::min(tone_uncharted2(x), 1.0f)); case Transfer::SrgbClamped: return linear_to_srgb(std::min(std::max(x, 0.0f), 1.0f)); - default: return linear_to_srgb(x); + default: return linear_to_srgb(std::max(x, 0.0f)); } } diff --git a/src/core/PoolSlots.h b/src/core/PoolSlots.h index 8214d1e3..30c84bda 100644 --- a/src/core/PoolSlots.h +++ b/src/core/PoolSlots.h @@ -257,6 +257,7 @@ enum class SaveClass : uint8_t { X(EngBgSkyImage , "eng.bg_sky.image", Appearance, Never) \ X(EngBgSkyRgbPost , "eng.bg_sky.rgb_post", Appearance, Never) \ X(EngBgSkyVTsScratch , "eng.bg_sky.v_Ts_scratch", Appearance, Never) \ + X(EngBgExponentByCam , "eng.bg.exponent_by_cam", Appearance, Never) \ X(EngBgSkyVBg , "eng.bg_sky.v_bg", Appearance, Never) \ X(EngBgSkyVSh , "eng.bg_sky.v_sh", Appearance, Never) \ /* ---- PPISP ---- */ \ diff --git a/src/engine/EngineBackground.cpp b/src/engine/EngineBackground.cpp index 5ca1ba4f..655c1e46 100644 --- a/src/engine/EngineBackground.cpp +++ b/src/engine/EngineBackground.cpp @@ -122,6 +122,21 @@ static unsigned _bg_block_px(const EngineBackground& bg, int H, int W) { return base << (std::mt19937(bg.cur_seed)() % levels); } +// The per-image power table for the blend kernels, or null for the plain +// draw. Decided by the forward and reused by the backward. +struct BgLumaViews { + const float* exponent = nullptr; + const int32_t* cams = nullptr; +}; + +static BgLumaViews _bg_luma_views(const EngineBackground& bg) { + BgLumaViews v; + if (!bg.cur_match_luma) return v; + v.exponent = bg.exponent_by_cam.data_ptr(); + v.cams = engine().bilagrid_cur_cam_indices.data_ptr(); + return v; +} + static void _ensure_bg_sh_optim_state() { auto& bg = engine().background; if (bg.sh_optim_initialized) return; @@ -199,6 +214,12 @@ void _engine_background_forward() { int W = engine().camera.width; if (C_batch <= 0) return; + // One-shot, so a viewer render between steps keeps the plain draw. + bg.cur_match_luma = bg.match_luma_pending && + bg.exponent_by_cam.size() > 0 && + engine().bilagrid_cur_cam_indices.size() >= C_batch; + bg.match_luma_pending = false; + auto& fwd_rgb_tensor = std::get<0>(engine().fwd.renders); auto& fwd_Ts_tensor = engine().fwd.render_Ts; if (fwd_rgb_tensor.data_ptr() == nullptr || fwd_Ts_tensor.data_ptr() == nullptr) @@ -221,12 +242,14 @@ void _engine_background_forward() { if (bg.mode != EngineBackground::Mode::Sh) { bg.cur_block_px = _bg_block_px(bg, H, W); + const BgLumaViews lv = _bg_luma_views(bg); blend_background_noise_forward( bg.splat_transfer, bg.splat_is_linear, bg.mode == EngineBackground::Mode::Pseudorandom, bg.cur_block_px, bg.fwd_pre_blend_rgb, Ts_in, bg.cur_randomize_weight, bg.cur_seed, + lv.exponent, lv.cams, post_rgb); fwd_rgb_tensor = post_rgb; return; @@ -298,12 +321,14 @@ void _engine_background_backward_hook( overexposure_reg_weight, v_out, v_rgb, v_Ts_scratch_dt); } else { + const BgLumaViews lv = _bg_luma_views(bg); blend_background_noise_backward( bg.splat_transfer, bg.splat_is_linear, bg.mode == EngineBackground::Mode::Pseudorandom, bg.cur_block_px, bg.fwd_pre_blend_rgb, Ts_in, bg.cur_randomize_weight, bg.cur_seed, + lv.exponent, lv.cams, overexposure_reg_weight, v_out, v_rgb, v_Ts_scratch_dt); } diff --git a/src/engine/EngineConfig.h b/src/engine/EngineConfig.h index 7758ff78..b3b343fc 100644 --- a/src/engine/EngineConfig.h +++ b/src/engine/EngineConfig.h @@ -60,7 +60,7 @@ struct LossConfig { // Divide the photometric weights (RGB / YUV supervision and SSIM) by // 0.5 / max(mean sRGB luma of this step's reference pixels, 1/255), so a // dark capture pulls on the splats as hard as a bright one. - bool normalize_by_luminance = false; + float luminance_normalization = 0.0f; // power on 0.5 / mean luma; 0 = off // Image-space overexposure regularization weight. When non-zero, a // dedicated kernel adds dL/dx of L = w * mean(max(-x, x-1, 0)^2) directly // into v_render_rgb (in the pre-bilagrid / pre-PPISP / pre-color-space @@ -265,6 +265,7 @@ struct BackgroundStepConfig { float lr_sh = 0.0f; float randomize_weight = 0.0f; uint32_t seed = 0; + bool match_luminance = false; // randomized draw ^ per-image power }; diff --git a/src/engine/EngineDataManager.cpp b/src/engine/EngineDataManager.cpp index fd242790..feb16b4e 100644 --- a/src/engine/EngineDataManager.cpp +++ b/src/engine/EngineDataManager.cpp @@ -165,36 +165,54 @@ static float _sampled_mean_luma(uint64_t base, int64_t n_px, int64_t width, } -// LossConfig::normalize_by_luminance: the photometric weights divided by -// 0.5 / max(mean sRGB luma, 1/255). Leaves them alone when the step carries -// no reference image to measure. -static void _normalize_weights_by_luminance(LossConfig& loss, const TrainStep& stp) { +static bool _sub_has_gt_rgb(const DecodedBatch& sub) { + const auto& shape = std::get<2>(sub.rgb_view); + return std::get<0>(sub.rgb_view) != 0 && shape.size() == 4 && + shape[3] == 3 && shape[1] * shape[2] > 0; +} + +// Mean display luma of row `j` of a sub-batch's reference images, through the +// per-camera cache when the rows are whole input images (indices per row). +static float _gt_row_luma(const DecodedBatch& sub, int64_t j) { + const TorchTensorView& rgb = sub.rgb_view; + const auto& shape = std::get<2>(rgb); + const int64_t px = shape[1] * shape[2]; + const uint32_t elem = std::get<1>(rgb); + auto compute = [&] { + return _sampled_mean_luma(std::get<0>(rgb) + (uint64_t)(j * px) * 3 * elem, + px, shape[2], elem); + }; + if ((int64_t)sub.indices.size() != shape[0]) return compute(); + const int32_t id = sub.indices[(size_t)j]; + if (id < 0) return compute(); std::vector& cache = engine().gt_mean_luma; + if ((size_t)id >= cache.size()) + cache.resize((size_t)id + 1, std::numeric_limits::quiet_NaN()); + if (std::isnan(cache[(size_t)id])) cache[(size_t)id] = compute(); + return cache[(size_t)id]; +} + +// LossConfig::luminance_normalization: the photometric weights times +// 1 - factor (1 - (0.5 / max(mean sRGB luma, 1/255))). Leaves them alone when the step +// carries no reference image to measure. +static void _normalize_weights_by_luminance(LossConfig& loss, const TrainStep& stp, + float factor) { double sum = 0.0, total_px = 0.0; for (const auto& sub : stp.subs) { - const TorchTensorView& rgb = sub->rgb_view; - const auto& shape = std::get<2>(rgb); - const uint64_t base = std::get<0>(rgb); - if (base == 0 || shape.size() != 4 || shape[3] != 3) continue; + if (!_sub_has_gt_rgb(*sub)) continue; + const auto& shape = std::get<2>(sub->rgb_view); const int64_t B = shape[0], px = shape[1] * shape[2]; - if (px <= 0 || (int64_t)sub->indices.size() != B) continue; - const uint32_t elem = std::get<1>(rgb); - + if ((int64_t)sub->indices.size() != B) continue; for (int64_t j = 0; j < B; j++) { - const int32_t id = sub->indices[(size_t)j]; - if (id < 0) continue; - if ((size_t)id >= cache.size()) - cache.resize((size_t)id + 1, std::numeric_limits::quiet_NaN()); - if (std::isnan(cache[(size_t)id])) - cache[(size_t)id] = _sampled_mean_luma( - base + (uint64_t)(j * px) * 3 * elem, px, shape[2], elem); - sum += (double)cache[(size_t)id] * (double)px; + if (sub->indices[(size_t)j] < 0) continue; + sum += (double)_gt_row_luma(*sub, j) * (double)px; total_px += (double)px; } } if (total_px <= 0.0) return; - const float scale = (float)(0.5 / std::max(sum / total_px, 1.0 / 255.0)); + const float scale = + 1.0f - factor * (1.0f - 0.5f / std::max((float)(sum / total_px), 1.0f / 255.0f)); constexpr LossWeightIndex photometric[] = { LossWeightIndex::RgbSupL1, LossWeightIndex::RgbSupL2, LossWeightIndex::YSupL1, LossWeightIndex::YSupL2, @@ -205,6 +223,62 @@ static void _normalize_weights_by_luminance(LossConfig& loss, const TrainStep& s } +// 0.5^p = luma / gain: the draw's median lands on the image's mean luma ahead +// of PPISP, whose 2^e scales display values, or linear light (2^(e/2.2) in +// display) when it runs before the encode. Clamped to [1/255, 1]: p in [0, 8]. +static float _bg_luma_exponent(float luma, float exposure_log2, + bool ppisp_before_color_space) { + const double e = ppisp_before_color_space ? exposure_log2 / 2.2 : exposure_log2; + const double target = std::min(std::max((double)luma * std::exp2(-e), 1.0 / 255.0), 1.0); + return (float)-std::log2(target); +} + +// BackgroundStepConfig::match_luminance: the per-slot power table the blend +// kernels read, recomputed for this step's slots from the cached luma and the +// current PPISP exposure, and re-uploaded whole (it is tiny). +static void _update_background_exponents(const TrainStep& stp, + bool ppisp_before_color_space) { + auto& bg = engine().background; + std::vector& luma = bg.luma_by_cam_host; + std::vector& expo = bg.exponent_by_cam_host; + + const auto& pp = engine().ppisp; + const int P = pp.num_params; + std::vector ppisp_host; + if (pp.enabled && pp.params.data_ptr() && P > 0) { + ppisp_host.resize((size_t)pp.params.size<0>() * P); + backend::memcpy_sync(ppisp_host.data(), pp.params.data_ptr(), + ppisp_host.size() * sizeof(float), + backend::MemcpyKind::DeviceToHost); + } + + bool any = false; + for (const auto& sub : stp.subs) { + if (!_sub_has_gt_rgb(*sub)) continue; + const int64_t B = std::get<2>(sub->rgb_view)[0]; + const int K = std::max(sub->K, 1); + if ((int64_t)sub->post_offsets.size() * K < B) continue; + for (int64_t j = 0; j < B; j++) { + const size_t slot = (size_t)sub->post_offsets[(size_t)(j / K)] + (size_t)(j % K); + if (slot >= luma.size()) { + luma.resize(slot + 1, std::numeric_limits::quiet_NaN()); + expo.resize(slot + 1, 1.0f); // the plain draw for slots never seen + } + luma[slot] = _gt_row_luma(*sub, j); + const float e = (slot + 1) * (size_t)P <= ppisp_host.size() + ? ppisp_host[slot * (size_t)P] : 0.0f; + expo[slot] = _bg_luma_exponent(luma[slot], e, ppisp_before_color_space); + any = true; + } + } + if (!any) return; + if (bg.exponent_by_cam.size() != (int64_t)expo.size()) + bg.exponent_by_cam.resize(PoolSlot::EngBgExponentByCam, (int64_t)expo.size()); + backend::memcpy_sync(bg.exponent_by_cam.data_ptr(), expo.data(), + expo.size() * sizeof(float), backend::MemcpyKind::HostToDevice); +} + + std::map engine_train_step_managed( int step, int max_steps, std::string primitive, @@ -229,8 +303,11 @@ std::map engine_train_step_managed( if (stp.subs.empty()) throw std::runtime_error("engine_train_step_managed: empty training step"); - if (cfg.loss.normalize_by_luminance) - _normalize_weights_by_luminance(cfg.loss, stp); + if (cfg.loss.luminance_normalization > 0.0f) + _normalize_weights_by_luminance(cfg.loss, stp, cfg.loss.luminance_normalization); + if (cfg.background.match_luminance && engine().background.enabled) + _update_background_exponents( + stp, cfg.ppisp.run_before_color_space && engine().color_space.splat_enabled); // Build a POST-split bilagrid cam-index buffer for one sub-batch. // bilagrid_cam_indices must be the POST-split camera id, not the input diff --git a/src/engine/EngineState.h b/src/engine/EngineState.h index 8cf7b3e6..f8544d2e 100644 --- a/src/engine/EngineState.h +++ b/src/engine/EngineState.h @@ -417,6 +417,15 @@ struct EngineBackground { // Resolved by the forward (it knows this batch's H/W) and read again by // the backward, which must reconstruct the same background. unsigned cur_block_px = 0; + + // Per post-split camera slot: the reference image's mean display luma and + // the power the randomized draw is raised to. Armed per training forward + // (never for a viewer render), consumed into cur_match_luma for the bwd. + std::vector luma_by_cam_host; + std::vector exponent_by_cam_host; + DeviceVector exponent_by_cam; + bool match_luma_pending = false; + bool cur_match_luma = false; }; // Linear / wide-gamut color space conversion. diff --git a/src/engine/EngineTrainStep.cpp b/src/engine/EngineTrainStep.cpp index 53dc9918..547f6658 100644 --- a/src/engine/EngineTrainStep.cpp +++ b/src/engine/EngineTrainStep.cpp @@ -137,6 +137,7 @@ static std::map _engine_step_fwd_bwd_only( cfg.ppisp.run_before_color_space && engine().color_space.splat_enabled; engine().ppisp.forward_pending = engine().ppisp.enabled && engine().ppisp.cur_run_before_color_space; + engine().background.match_luma_pending = cfg.background.match_luminance; forward_3dgs(primitive, sh_degree, packed, /*output_median=*/false, (int)dist_type); diff --git a/src/generated/pixel_wise.cuh b/src/generated/pixel_wise.cuh index 6e0ddb82..70f1cdbb 100644 --- a/src/generated/pixel_wise.cuh +++ b/src/generated/pixel_wise.cuh @@ -531,75 +531,76 @@ inline __device__ float tone_encode_0(float x_16, int transfer_0) } return _S43; } - if(x_16 < 0.00313080009073019f) + float _S47 = xfer_max0_0(x_16); + if(_S47 < 0.00313080009073019f) { - _S43 = x_16 * 12.92000007629394531f; + _S43 = _S47 * 12.92000007629394531f; } else { - _S43 = 1.0549999475479126f * (F32_pow((x_16), (0.4166666567325592f))) - 0.05499999970197678f; + _S43 = 1.0549999475479126f * (F32_pow((_S47), (0.4166666567325592f))) - 0.05499999970197678f; } return _S43; } inline __device__ float3 working_to_display(float3 rgb_2, Matrix color_matrix_0, int transfer_1, bool is_linear_0) { - float3 _S47; + float3 _S48; if(!is_linear_0) { - float _S48 = rgb_2.x; - float _S49; - if(_S48 < 0.04044999927282333f) + float _S49 = rgb_2.x; + float _S50; + if(_S49 < 0.04044999927282333f) { - _S49 = _S48 * 0.07739938050508499f; + _S50 = _S49 * 0.07739938050508499f; } else { - _S49 = (F32_pow((0.94786733388900757f * (_S48 + 0.05499999970197678f)), (2.40000009536743164f))); + _S50 = (F32_pow((0.94786733388900757f * (_S49 + 0.05499999970197678f)), (2.40000009536743164f))); } - float _S50 = rgb_2.y; - float _S51; - if(_S50 < 0.04044999927282333f) + float _S51 = rgb_2.y; + float _S52; + if(_S51 < 0.04044999927282333f) { - _S51 = _S50 * 0.07739938050508499f; + _S52 = _S51 * 0.07739938050508499f; } else { - _S51 = (F32_pow((0.94786733388900757f * (_S50 + 0.05499999970197678f)), (2.40000009536743164f))); + _S52 = (F32_pow((0.94786733388900757f * (_S51 + 0.05499999970197678f)), (2.40000009536743164f))); } - float _S52 = rgb_2.z; - float _S53; - if(_S52 < 0.04044999927282333f) + float _S53 = rgb_2.z; + float _S54; + if(_S53 < 0.04044999927282333f) { - _S53 = _S52 * 0.07739938050508499f; + _S54 = _S53 * 0.07739938050508499f; } else { - _S53 = (F32_pow((0.94786733388900757f * (_S52 + 0.05499999970197678f)), (2.40000009536743164f))); + _S54 = (F32_pow((0.94786733388900757f * (_S53 + 0.05499999970197678f)), (2.40000009536743164f))); } - _S47 = make_float3 (_S49, _S51, _S53); + _S48 = make_float3 (_S50, _S52, _S54); } else { - _S47 = rgb_2; + _S48 = rgb_2; } - float3 _S54 = mul_0(color_matrix_0, _S47); - return make_float3 (tone_encode_0(_S54.x, transfer_1), tone_encode_0(_S54.y, transfer_1), tone_encode_0(_S54.z, transfer_1)); + float3 _S55 = mul_0(color_matrix_0, _S48); + return make_float3 (tone_encode_0(_S55.x, transfer_1), tone_encode_0(_S55.y, transfer_1), tone_encode_0(_S55.z, transfer_1)); } -inline __device__ float s_primal_ctx_pow_0(float _S55, float _S56) +inline __device__ float s_primal_ctx_pow_0(float _S56, float _S57) { - return (F32_pow((_S55), (_S56))); + return (F32_pow((_S56), (_S57))); } -inline __device__ float3 s_primal_ctx_mul_0(Matrix _S57, float3 _S58) +inline __device__ float3 s_primal_ctx_mul_0(Matrix _S58, float3 _S59) { - return mul_0(_S57, _S58); + return mul_0(_S58, _S59); } -inline __device__ float s_primal_ctx_xfer_max0_0(float _S59) +inline __device__ float s_primal_ctx_xfer_max0_0(float _S60) { - return xfer_max0_0(_S59); + return xfer_max0_0(_S60); } inline __device__ float s_primal_ctx_xfer_aces_0(float dpx_4) @@ -607,15 +608,15 @@ inline __device__ float s_primal_ctx_xfer_aces_0(float dpx_4) return dpx_4 * (2.50999999046325684f * dpx_4 + 0.02999999932944775f) / (dpx_4 * (2.43000006675720215f * dpx_4 + 0.5899999737739563f) + 0.14000000059604645f); } -inline __device__ float s_primal_ctx_xfer_clamp01_0(float _S60) +inline __device__ float s_primal_ctx_xfer_clamp01_0(float _S61) { - return xfer_clamp01_0(_S60); + return xfer_clamp01_0(_S61); } inline __device__ float s_primal_ctx_xfer_hable_0(float dpx_5) { - float _S61 = 0.15000000596046448f * dpx_5; - return (dpx_5 * (_S61 + 0.05000000074505806f) + 0.00400000018998981f) / (dpx_5 * (_S61 + 0.5f) + 0.06000000238418579f) - 0.06666666269302368f; + float _S62 = 0.15000000596046448f * dpx_5; + return (dpx_5 * (_S62 + 0.05000000074505806f) + 0.00400000018998981f) / (dpx_5 * (_S62 + 0.5f) + 0.06000000238418579f) - 0.06666666269302368f; } inline __device__ float s_primal_ctx_xfer_uncharted2_0(float dpx_6) @@ -623,414 +624,410 @@ inline __device__ float s_primal_ctx_xfer_uncharted2_0(float dpx_6) return s_primal_ctx_xfer_hable_0(s_primal_ctx_xfer_max0_0(dpx_6)) / s_primal_ctx_xfer_hable_0(11.19999980926513672f); } -inline __device__ void s_bwd_prop_pow_0(DiffPair_float_0 * _S62, DiffPair_float_0 * _S63, float _S64) +inline __device__ void s_bwd_prop_pow_0(DiffPair_float_0 * _S63, DiffPair_float_0 * _S64, float _S65) { - _d_pow_0(_S62, _S63, _S64); + _d_pow_0(_S63, _S64, _S65); return; } -inline __device__ void s_bwd_prop_xfer_clamp01_0(DiffPair_float_0 * _S65, float _S66) +inline __device__ void s_bwd_prop_xfer_max0_0(DiffPair_float_0 * _S66, float _S67) { - xfer_pass_grad_0(_S65, _S66); + xfer_pass_grad_0(_S66, _S67); + return; +} + +inline __device__ void s_bwd_prop_xfer_clamp01_0(DiffPair_float_0 * _S68, float _S69) +{ + xfer_pass_grad_0(_S68, _S69); return; } inline __device__ void s_bwd_prop_xfer_hable_0(DiffPair_float_0 * dpx_7, float _s_dOut_1) { - float _S67 = 0.15000000596046448f * (*dpx_7).primal_0; - float _S68 = _S67 + 0.05000000074505806f; - float _S69 = _S67 + 0.5f; - float _S70 = (*dpx_7).primal_0 * _S69 + 0.06000000238418579f; - float _S71 = _s_dOut_1 / (_S70 * _S70); - float _S72 = ((*dpx_7).primal_0 * _S68 + 0.00400000018998981f) * - _S71; - float _S73 = _S70 * _S71; - float _S74 = _S69 * _S72 + _S68 * _S73 + 0.15000000596046448f * ((*dpx_7).primal_0 * _S72 + (*dpx_7).primal_0 * _S73); + float _S70 = 0.15000000596046448f * (*dpx_7).primal_0; + float _S71 = _S70 + 0.05000000074505806f; + float _S72 = _S70 + 0.5f; + float _S73 = (*dpx_7).primal_0 * _S72 + 0.06000000238418579f; + float _S74 = _s_dOut_1 / (_S73 * _S73); + float _S75 = ((*dpx_7).primal_0 * _S71 + 0.00400000018998981f) * - _S74; + float _S76 = _S73 * _S74; + float _S77 = _S72 * _S75 + _S71 * _S76 + 0.15000000596046448f * ((*dpx_7).primal_0 * _S75 + (*dpx_7).primal_0 * _S76); dpx_7->primal_0 = (*dpx_7).primal_0; - dpx_7->differential_0 = _S74; - return; -} - -inline __device__ void s_bwd_prop_xfer_max0_0(DiffPair_float_0 * _S75, float _S76) -{ - xfer_pass_grad_0(_S75, _S76); + dpx_7->differential_0 = _S77; return; } inline __device__ void s_bwd_prop_xfer_uncharted2_0(DiffPair_float_0 * dpx_8, float _s_dOut_2) { - float _S77 = s_primal_ctx_xfer_hable_0(11.19999980926513672f); - float _S78 = _S77 * (_s_dOut_2 / (_S77 * _S77)); - DiffPair_float_0 _S79; - (&_S79)->primal_0 = s_primal_ctx_xfer_max0_0((*dpx_8).primal_0); - (&_S79)->differential_0 = 0.0f; - s_bwd_prop_xfer_hable_0(&_S79, _S78); + float _S78 = s_primal_ctx_xfer_hable_0(11.19999980926513672f); + float _S79 = _S78 * (_s_dOut_2 / (_S78 * _S78)); DiffPair_float_0 _S80; - (&_S80)->primal_0 = (*dpx_8).primal_0; + (&_S80)->primal_0 = s_primal_ctx_xfer_max0_0((*dpx_8).primal_0); (&_S80)->differential_0 = 0.0f; - s_bwd_prop_xfer_max0_0(&_S80, _S79.differential_0); + s_bwd_prop_xfer_hable_0(&_S80, _S79); + DiffPair_float_0 _S81; + (&_S81)->primal_0 = (*dpx_8).primal_0; + (&_S81)->differential_0 = 0.0f; + s_bwd_prop_xfer_max0_0(&_S81, _S80.differential_0); dpx_8->primal_0 = (*dpx_8).primal_0; - dpx_8->differential_0 = _S80.differential_0; + dpx_8->differential_0 = _S81.differential_0; return; } inline __device__ void s_bwd_prop_xfer_aces_0(DiffPair_float_0 * dpx_9, float _s_dOut_3) { - float _S81 = 2.50999999046325684f * (*dpx_9).primal_0 + 0.02999999932944775f; - float _S82 = 2.43000006675720215f * (*dpx_9).primal_0 + 0.5899999737739563f; - float _S83 = (*dpx_9).primal_0 * _S82 + 0.14000000059604645f; - float _S84 = _s_dOut_3 / (_S83 * _S83); - float _S85 = (*dpx_9).primal_0 * _S81 * - _S84; - float _S86 = _S83 * _S84; - float _S87 = _S82 * _S85 + 2.43000006675720215f * ((*dpx_9).primal_0 * _S85) + _S81 * _S86 + 2.50999999046325684f * ((*dpx_9).primal_0 * _S86); + float _S82 = 2.50999999046325684f * (*dpx_9).primal_0 + 0.02999999932944775f; + float _S83 = 2.43000006675720215f * (*dpx_9).primal_0 + 0.5899999737739563f; + float _S84 = (*dpx_9).primal_0 * _S83 + 0.14000000059604645f; + float _S85 = _s_dOut_3 / (_S84 * _S84); + float _S86 = (*dpx_9).primal_0 * _S82 * - _S85; + float _S87 = _S84 * _S85; + float _S88 = _S83 * _S86 + 2.43000006675720215f * ((*dpx_9).primal_0 * _S86) + _S82 * _S87 + 2.50999999046325684f * ((*dpx_9).primal_0 * _S87); dpx_9->primal_0 = (*dpx_9).primal_0; - dpx_9->differential_0 = _S87; + dpx_9->differential_0 = _S88; return; } inline __device__ void s_bwd_prop_xfer_filmic_0(DiffPair_float_0 * dpx_10, float _s_dOut_4) { - float _S88 = (*dpx_10).primal_0 - 0.00400000018998981f; - float _S89 = s_primal_ctx_xfer_max0_0(_S88); - float _S90 = 6.19999980926513672f * _S89; - float _S91 = _S90 + 0.5f; - float _S92 = _S90 + 1.70000004768371582f; - float _S93 = _S89 * _S92 + 0.05999999865889549f; - float _S94 = _s_dOut_4 / (_S93 * _S93); - float _S95 = _S89 * _S91 * - _S94; - float _S96 = _S93 * _S94; - float _S97 = _S92 * _S95 + _S91 * _S96 + 6.19999980926513672f * (_S89 * _S95 + _S89 * _S96); - DiffPair_float_0 _S98; - (&_S98)->primal_0 = _S88; - (&_S98)->differential_0 = 0.0f; - s_bwd_prop_xfer_max0_0(&_S98, _S97); + float _S89 = (*dpx_10).primal_0 - 0.00400000018998981f; + float _S90 = s_primal_ctx_xfer_max0_0(_S89); + float _S91 = 6.19999980926513672f * _S90; + float _S92 = _S91 + 0.5f; + float _S93 = _S91 + 1.70000004768371582f; + float _S94 = _S90 * _S93 + 0.05999999865889549f; + float _S95 = _s_dOut_4 / (_S94 * _S94); + float _S96 = _S90 * _S92 * - _S95; + float _S97 = _S94 * _S95; + float _S98 = _S93 * _S96 + _S92 * _S97 + 6.19999980926513672f * (_S90 * _S96 + _S90 * _S97); + DiffPair_float_0 _S99; + (&_S99)->primal_0 = _S89; + (&_S99)->differential_0 = 0.0f; + s_bwd_prop_xfer_max0_0(&_S99, _S98); dpx_10->primal_0 = (*dpx_10).primal_0; - dpx_10->differential_0 = _S98.differential_0; + dpx_10->differential_0 = _S99.differential_0; return; } inline __device__ void s_bwd_prop_tone_encode_0(DiffPair_float_0 * dpx_11, int transfer_2, float _s_dOut_5) { - DiffPair_float_0 _S99 = *dpx_11; - bool _S100 = transfer_2 == int(3); - bool _S101 = !_S100; + DiffPair_float_0 _S100 = *dpx_11; + bool _S101 = transfer_2 == int(3); + bool _S102 = !_S101; bool _runFlag_0; bool _runFlag_1; bool _runFlag_2; - bool _S102; bool _S103; bool _S104; - float _S105; + bool _S105; float _S106; float _S107; float _S108; float _S109; float _S110; - if(_S101) + float _S111; + float _S112; + if(_S102) { - bool _S111 = transfer_2 == int(2); - if(_S111) + bool _S113 = transfer_2 == int(2); + if(_S113) { - float _S112 = s_primal_ctx_xfer_max0_0(_S99.primal_0); - float _S113 = s_primal_ctx_xfer_aces_0(_S112); - float _S114 = s_primal_ctx_xfer_clamp01_0(_S113); + float _S114 = s_primal_ctx_xfer_max0_0(_S100.primal_0); + float _S115 = s_primal_ctx_xfer_aces_0(_S114); + float _S116 = s_primal_ctx_xfer_clamp01_0(_S115); _runFlag_0 = false; - _S105 = _S114; - _S106 = _S113; - _S107 = _S112; + _S106 = _S116; + _S107 = _S115; + _S108 = _S114; } else { - _runFlag_0 = _S101; - _S105 = 0.0f; + _runFlag_0 = _S102; _S106 = 0.0f; _S107 = 0.0f; + _S108 = 0.0f; } if(_runFlag_0) { - bool _S115 = transfer_2 == int(4); - if(_S115) + bool _S117 = transfer_2 == int(4); + if(_S117) { - float _S116 = s_primal_ctx_xfer_uncharted2_0(_S99.primal_0); - float _S117 = s_primal_ctx_xfer_clamp01_0(_S116); + float _S118 = s_primal_ctx_xfer_uncharted2_0(_S100.primal_0); + float _S119 = s_primal_ctx_xfer_clamp01_0(_S118); _runFlag_1 = false; - _S108 = _S117; - _S109 = _S116; + _S109 = _S119; + _S110 = _S118; } else { _runFlag_1 = _runFlag_0; - _S108 = 0.0f; _S109 = 0.0f; + _S110 = 0.0f; } if(_runFlag_1) { - bool _S118 = transfer_2 == int(1); - if(_S118) + bool _S120 = transfer_2 == int(1); + if(_S120) { - float _S119 = s_primal_ctx_xfer_clamp01_0(_S99.primal_0); + float _S121 = s_primal_ctx_xfer_clamp01_0(_S100.primal_0); _runFlag_2 = false; - _S110 = _S119; + _S111 = _S121; } else { _runFlag_2 = _runFlag_1; - _S110 = 0.0f; + _S111 = 0.0f; } - _S102 = _S118; + if(_runFlag_2) + { + _S112 = s_primal_ctx_xfer_max0_0(_S100.primal_0); + } + else + { + _S112 = 0.0f; + } + float _S122 = _S111; + _S111 = _S112; + _S103 = _S120; + _S112 = _S122; } else { _runFlag_2 = false; - _S102 = false; - _S110 = 0.0f; + _S111 = 0.0f; + _S103 = false; + _S112 = 0.0f; } - float _S120 = _S108; - float _S121 = _S109; - _S108 = _S110; - _S103 = _S115; - _S109 = _S120; - _S110 = _S121; + float _S123 = _S109; + float _S124 = _S110; + _S109 = _S111; + _S110 = _S112; + _S104 = _S117; + _S111 = _S123; + _S112 = _S124; } else { _runFlag_1 = false; _runFlag_2 = false; - _S102 = false; - _S108 = 0.0f; - _S103 = false; _S109 = 0.0f; + _S103 = false; _S110 = 0.0f; + _S104 = false; + _S111 = 0.0f; + _S112 = 0.0f; } - float _S122 = _S105; - float _S123 = _S106; - float _S124 = _S107; - _S105 = _S108; + float _S125 = _S106; + float _S126 = _S107; + float _S127 = _S108; _S106 = _S109; _S107 = _S110; - _S104 = _S111; - _S108 = _S122; - _S109 = _S123; - _S110 = _S124; + _S108 = _S111; + _S109 = _S112; + _S105 = _S113; + _S110 = _S125; + _S111 = _S126; + _S112 = _S127; } else { _runFlag_0 = false; _runFlag_1 = false; _runFlag_2 = false; - _S102 = false; - _S105 = 0.0f; - _S103 = false; _S106 = 0.0f; + _S103 = false; _S107 = 0.0f; _S104 = false; _S108 = 0.0f; _S109 = 0.0f; + _S105 = false; _S110 = 0.0f; + _S111 = 0.0f; + _S112 = 0.0f; } - if(_S101) + if(_S102) { if(_runFlag_0) { - float _S125; if(_runFlag_1) { - float _S126; + float _S128; if(_runFlag_2) { - if((_S99.primal_0) < 0.00313080009073019f) + if(_S106 < 0.00313080009073019f) { - _S125 = 12.92000007629394531f * _s_dOut_5; + _S106 = 12.92000007629394531f * _s_dOut_5; } else { - float _S127 = 1.0549999475479126f * _s_dOut_5; - DiffPair_float_0 _S128; - (&_S128)->primal_0 = _S99.primal_0; - (&_S128)->differential_0 = 0.0f; - DiffPair_float_0 _S129; - (&_S129)->primal_0 = 0.4166666567325592f; - (&_S129)->differential_0 = 0.0f; - s_bwd_prop_pow_0(&_S128, &_S129, _S127); - _S125 = _S128.differential_0; + float _S129 = 1.0549999475479126f * _s_dOut_5; + DiffPair_float_0 _S130; + (&_S130)->primal_0 = _S106; + (&_S130)->differential_0 = 0.0f; + DiffPair_float_0 _S131; + (&_S131)->primal_0 = 0.4166666567325592f; + (&_S131)->differential_0 = 0.0f; + s_bwd_prop_pow_0(&_S130, &_S131, _S129); + _S106 = _S130.differential_0; } - float _S130 = _S125; - _S125 = 0.0f; - _S126 = _S130; + DiffPair_float_0 _S132; + (&_S132)->primal_0 = _S100.primal_0; + (&_S132)->differential_0 = 0.0f; + s_bwd_prop_xfer_max0_0(&_S132, _S106); + _S106 = 0.0f; + _S128 = _S132.differential_0; } else { - _S125 = _s_dOut_5; - _S126 = 0.0f; + _S106 = _s_dOut_5; + _S128 = 0.0f; } - if(_S102) + if(_S103) { - if(_S105 < 0.00313080009073019f) + if(_S107 < 0.00313080009073019f) { - _S105 = 12.92000007629394531f * _S125; + _S106 = 12.92000007629394531f * _S106; } else { - float _S131 = 1.0549999475479126f * _S125; - DiffPair_float_0 _S132; - (&_S132)->primal_0 = _S105; - (&_S132)->differential_0 = 0.0f; - DiffPair_float_0 _S133; - (&_S133)->primal_0 = 0.4166666567325592f; - (&_S133)->differential_0 = 0.0f; - s_bwd_prop_pow_0(&_S132, &_S133, _S131); - _S105 = _S132.differential_0; + float _S133 = 1.0549999475479126f * _S106; + DiffPair_float_0 _S134; + (&_S134)->primal_0 = _S107; + (&_S134)->differential_0 = 0.0f; + DiffPair_float_0 _S135; + (&_S135)->primal_0 = 0.4166666567325592f; + (&_S135)->differential_0 = 0.0f; + s_bwd_prop_pow_0(&_S134, &_S135, _S133); + _S106 = _S134.differential_0; } - DiffPair_float_0 _S134; - (&_S134)->primal_0 = _S99.primal_0; - (&_S134)->differential_0 = 0.0f; - s_bwd_prop_xfer_clamp01_0(&_S134, _S105); - float _S135 = _S134.differential_0 + _S126; - _S105 = 0.0f; - _S125 = _S135; + DiffPair_float_0 _S136; + (&_S136)->primal_0 = _S100.primal_0; + (&_S136)->differential_0 = 0.0f; + s_bwd_prop_xfer_clamp01_0(&_S136, _S106); + float _S137 = _S136.differential_0 + _S128; + _S106 = 0.0f; + _S107 = _S137; } else { - _S105 = _S125; - _S125 = _S126; + _S107 = _S128; } } else { - _S105 = _s_dOut_5; - _S125 = 0.0f; + _S106 = _s_dOut_5; + _S107 = 0.0f; } - if(_S103) + if(_S104) { - if(_S106 < 0.00313080009073019f) + if(_S108 < 0.00313080009073019f) { - _S105 = 12.92000007629394531f * _S105; + _S106 = 12.92000007629394531f * _S106; } else { - float _S136 = 1.0549999475479126f * _S105; - DiffPair_float_0 _S137; - (&_S137)->primal_0 = _S106; - (&_S137)->differential_0 = 0.0f; - DiffPair_float_0 _S138; - (&_S138)->primal_0 = 0.4166666567325592f; - (&_S138)->differential_0 = 0.0f; - s_bwd_prop_pow_0(&_S137, &_S138, _S136); - _S105 = _S137.differential_0; + float _S138 = 1.0549999475479126f * _S106; + DiffPair_float_0 _S139; + (&_S139)->primal_0 = _S108; + (&_S139)->differential_0 = 0.0f; + DiffPair_float_0 _S140; + (&_S140)->primal_0 = 0.4166666567325592f; + (&_S140)->differential_0 = 0.0f; + s_bwd_prop_pow_0(&_S139, &_S140, _S138); + _S106 = _S139.differential_0; } - DiffPair_float_0 _S139; - (&_S139)->primal_0 = _S107; - (&_S139)->differential_0 = 0.0f; - s_bwd_prop_xfer_clamp01_0(&_S139, _S105); - DiffPair_float_0 _S140; - (&_S140)->primal_0 = _S99.primal_0; - (&_S140)->differential_0 = 0.0f; - s_bwd_prop_xfer_uncharted2_0(&_S140, _S139.differential_0); - float _S141 = _S140.differential_0 + _S125; - _S105 = 0.0f; - _S106 = _S141; - } - else - { - _S106 = _S125; + DiffPair_float_0 _S141; + (&_S141)->primal_0 = _S109; + (&_S141)->differential_0 = 0.0f; + s_bwd_prop_xfer_clamp01_0(&_S141, _S106); + DiffPair_float_0 _S142; + (&_S142)->primal_0 = _S100.primal_0; + (&_S142)->differential_0 = 0.0f; + s_bwd_prop_xfer_uncharted2_0(&_S142, _S141.differential_0); + float _S143 = _S142.differential_0 + _S107; + _S106 = 0.0f; + _S107 = _S143; } } else { - _S105 = _s_dOut_5; - _S106 = 0.0f; + _S106 = _s_dOut_5; + _S107 = 0.0f; } - if(_S104) + if(_S105) { - if(_S108 < 0.00313080009073019f) + if(_S110 < 0.00313080009073019f) { - _S105 = 12.92000007629394531f * _S105; + _S106 = 12.92000007629394531f * _S106; } else { - float _S142 = 1.0549999475479126f * _S105; - DiffPair_float_0 _S143; - (&_S143)->primal_0 = _S108; - (&_S143)->differential_0 = 0.0f; - DiffPair_float_0 _S144; - (&_S144)->primal_0 = 0.4166666567325592f; - (&_S144)->differential_0 = 0.0f; - s_bwd_prop_pow_0(&_S143, &_S144, _S142); - _S105 = _S143.differential_0; + float _S144 = 1.0549999475479126f * _S106; + DiffPair_float_0 _S145; + (&_S145)->primal_0 = _S110; + (&_S145)->differential_0 = 0.0f; + DiffPair_float_0 _S146; + (&_S146)->primal_0 = 0.4166666567325592f; + (&_S146)->differential_0 = 0.0f; + s_bwd_prop_pow_0(&_S145, &_S146, _S144); + _S106 = _S145.differential_0; } - DiffPair_float_0 _S145; - (&_S145)->primal_0 = _S109; - (&_S145)->differential_0 = 0.0f; - s_bwd_prop_xfer_clamp01_0(&_S145, _S105); - DiffPair_float_0 _S146; - (&_S146)->primal_0 = _S110; - (&_S146)->differential_0 = 0.0f; - s_bwd_prop_xfer_aces_0(&_S146, _S145.differential_0); DiffPair_float_0 _S147; - (&_S147)->primal_0 = _S99.primal_0; + (&_S147)->primal_0 = _S111; (&_S147)->differential_0 = 0.0f; - s_bwd_prop_xfer_max0_0(&_S147, _S146.differential_0); - float _S148 = _S147.differential_0 + _S106; - _S105 = 0.0f; - _S106 = _S148; + s_bwd_prop_xfer_clamp01_0(&_S147, _S106); + DiffPair_float_0 _S148; + (&_S148)->primal_0 = _S112; + (&_S148)->differential_0 = 0.0f; + s_bwd_prop_xfer_aces_0(&_S148, _S147.differential_0); + DiffPair_float_0 _S149; + (&_S149)->primal_0 = _S100.primal_0; + (&_S149)->differential_0 = 0.0f; + s_bwd_prop_xfer_max0_0(&_S149, _S148.differential_0); + float _S150 = _S149.differential_0 + _S107; + _S106 = 0.0f; + _S107 = _S150; } } else { - _S105 = _s_dOut_5; - _S106 = 0.0f; + _S106 = _s_dOut_5; + _S107 = 0.0f; } - if(_S100) + if(_S101) { - DiffPair_float_0 _S149; - (&_S149)->primal_0 = _S99.primal_0; - (&_S149)->differential_0 = 0.0f; - s_bwd_prop_xfer_filmic_0(&_S149, _S105); - _S105 = _S149.differential_0 + _S106; + DiffPair_float_0 _S151; + (&_S151)->primal_0 = _S100.primal_0; + (&_S151)->differential_0 = 0.0f; + s_bwd_prop_xfer_filmic_0(&_S151, _S106); + _S106 = _S151.differential_0 + _S107; } else { - _S105 = _S106; + _S106 = _S107; } dpx_11->primal_0 = (*dpx_11).primal_0; - dpx_11->differential_0 = _S105; + dpx_11->differential_0 = _S106; return; } -inline __device__ void s_bwd_prop_mul_0(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S150, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S151, float3 _S152) +inline __device__ void s_bwd_prop_mul_0(DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 * _S152, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S153, float3 _S154) { - _d_mul_0(_S150, _S151, _S152); + _d_mul_0(_S152, _S153, _S154); return; } inline __device__ void s_bwd_prop_working_to_display_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dprgb_0, Matrix color_matrix_1, int transfer_3, bool is_linear_1, float3 _s_dOut_6) { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S153 = *dprgb_0; - bool _S154 = !is_linear_1; - float _S155; - float _S156; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S155 = *dprgb_0; + bool _S156 = !is_linear_1; float _S157; - float3 _S158; - if(_S154) + float _S158; + float _S159; + float3 _S160; + if(_S156) { - float _S159 = _S153.primal_0.x; - if(_S159 < 0.04044999927282333f) - { - _S155 = _S159 * 0.07739938050508499f; - } - else - { - _S155 = s_primal_ctx_pow_0(0.94786733388900757f * (_S159 + 0.05499999970197678f), 2.40000009536743164f); - } - float _S160 = _S153.primal_0.y; - if(_S160 < 0.04044999927282333f) - { - _S156 = _S160 * 0.07739938050508499f; - } - else - { - _S156 = s_primal_ctx_pow_0(0.94786733388900757f * (_S160 + 0.05499999970197678f), 2.40000009536743164f); - } - float _S161 = _S153.primal_0.z; + float _S161 = _S155.primal_0.x; if(_S161 < 0.04044999927282333f) { _S157 = _S161 * 0.07739938050508499f; @@ -1039,97 +1036,67 @@ inline __device__ void s_bwd_prop_working_to_display_0(DiffPair_vectorx3Cfloatx2 { _S157 = s_primal_ctx_pow_0(0.94786733388900757f * (_S161 + 0.05499999970197678f), 2.40000009536743164f); } - _S158 = make_float3 (_S155, _S156, _S157); - _S155 = _S161; - _S156 = _S160; - _S157 = _S159; + float _S162 = _S155.primal_0.y; + if(_S162 < 0.04044999927282333f) + { + _S158 = _S162 * 0.07739938050508499f; + } + else + { + _S158 = s_primal_ctx_pow_0(0.94786733388900757f * (_S162 + 0.05499999970197678f), 2.40000009536743164f); + } + float _S163 = _S155.primal_0.z; + if(_S163 < 0.04044999927282333f) + { + _S159 = _S163 * 0.07739938050508499f; + } + else + { + _S159 = s_primal_ctx_pow_0(0.94786733388900757f * (_S163 + 0.05499999970197678f), 2.40000009536743164f); + } + _S160 = make_float3 (_S157, _S158, _S159); + _S157 = _S163; + _S158 = _S162; + _S159 = _S161; } else { - _S158 = _S153.primal_0; - _S155 = 0.0f; - _S156 = 0.0f; + _S160 = _S155.primal_0; _S157 = 0.0f; + _S158 = 0.0f; + _S159 = 0.0f; } - float3 _S162 = s_primal_ctx_mul_0(color_matrix_1, _S158); - float _S163 = _S162.x; - float _S164 = _S162.y; - float _S165 = _S162.z; - DiffPair_float_0 _S166; - (&_S166)->primal_0 = _S165; - (&_S166)->differential_0 = 0.0f; - s_bwd_prop_tone_encode_0(&_S166, transfer_3, _s_dOut_6.z); - DiffPair_float_0 _S167; - (&_S167)->primal_0 = _S164; - (&_S167)->differential_0 = 0.0f; - s_bwd_prop_tone_encode_0(&_S167, transfer_3, _s_dOut_6.y); + float3 _S164 = s_primal_ctx_mul_0(color_matrix_1, _S160); + float _S165 = _S164.x; + float _S166 = _S164.y; + float _S167 = _S164.z; DiffPair_float_0 _S168; - (&_S168)->primal_0 = _S163; + (&_S168)->primal_0 = _S167; (&_S168)->differential_0 = 0.0f; - s_bwd_prop_tone_encode_0(&_S168, transfer_3, _s_dOut_6.x); - float3 _S169 = make_float3 (_S168.differential_0, _S167.differential_0, _S166.differential_0); - Matrix _S170 = makeMatrix (0.0f); - DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S171; - (&_S171)->primal_0 = color_matrix_1; - (&_S171)->differential_0 = _S170; - float3 _S172 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S173; - (&_S173)->primal_0 = _S158; + s_bwd_prop_tone_encode_0(&_S168, transfer_3, _s_dOut_6.z); + DiffPair_float_0 _S169; + (&_S169)->primal_0 = _S166; + (&_S169)->differential_0 = 0.0f; + s_bwd_prop_tone_encode_0(&_S169, transfer_3, _s_dOut_6.y); + DiffPair_float_0 _S170; + (&_S170)->primal_0 = _S165; + (&_S170)->differential_0 = 0.0f; + s_bwd_prop_tone_encode_0(&_S170, transfer_3, _s_dOut_6.x); + float3 _S171 = make_float3 (_S170.differential_0, _S169.differential_0, _S168.differential_0); + Matrix _S172 = makeMatrix (0.0f); + DiffPair_matrixx3Cfloatx2C3x2C3x3E_0 _S173; + (&_S173)->primal_0 = color_matrix_1; (&_S173)->differential_0 = _S172; - s_bwd_prop_mul_0(&_S171, &_S173, _S169); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S174 = _S173; - if(_S154) + float3 _S174 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S175; + (&_S175)->primal_0 = _S160; + (&_S175)->differential_0 = _S174; + s_bwd_prop_mul_0(&_S173, &_S175, _S171); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S176 = _S175; + if(_S156) { - bool _S175 = _S155 < 0.04044999927282333f; - if(_S175) - { - _S155 = 0.0f; - } - else - { - _S155 = 0.94786733388900757f * (_S155 + 0.05499999970197678f); - } - if(_S175) - { - _S155 = 0.07739938050508499f * _S174.differential_0.z; - } - else - { - DiffPair_float_0 _S176; - (&_S176)->primal_0 = _S155; - (&_S176)->differential_0 = 0.0f; - DiffPair_float_0 _S177; - (&_S177)->primal_0 = 2.40000009536743164f; - (&_S177)->differential_0 = 0.0f; - s_bwd_prop_pow_0(&_S176, &_S177, _S174.differential_0.z); - _S155 = 0.94786733388900757f * _S176.differential_0; - } - bool _S178 = _S156 < 0.04044999927282333f; - if(_S178) - { - _S156 = 0.0f; - } - else - { - _S156 = 0.94786733388900757f * (_S156 + 0.05499999970197678f); - } - if(_S178) - { - _S156 = 0.07739938050508499f * _S174.differential_0.y; - } - else - { - DiffPair_float_0 _S179; - (&_S179)->primal_0 = _S156; - (&_S179)->differential_0 = 0.0f; - DiffPair_float_0 _S180; - (&_S180)->primal_0 = 2.40000009536743164f; - (&_S180)->differential_0 = 0.0f; - s_bwd_prop_pow_0(&_S179, &_S180, _S174.differential_0.y); - _S156 = 0.94786733388900757f * _S179.differential_0; - } - bool _S181 = _S157 < 0.04044999927282333f; - if(_S181) + bool _S177 = _S157 < 0.04044999927282333f; + if(_S177) { _S157 = 0.0f; } @@ -1137,62 +1104,110 @@ inline __device__ void s_bwd_prop_working_to_display_0(DiffPair_vectorx3Cfloatx2 { _S157 = 0.94786733388900757f * (_S157 + 0.05499999970197678f); } - if(_S181) + if(_S177) { - _S157 = 0.07739938050508499f * _S174.differential_0.x; + _S157 = 0.07739938050508499f * _S176.differential_0.z; } else { - DiffPair_float_0 _S182; - (&_S182)->primal_0 = _S157; - (&_S182)->differential_0 = 0.0f; - DiffPair_float_0 _S183; - (&_S183)->primal_0 = 2.40000009536743164f; - (&_S183)->differential_0 = 0.0f; - s_bwd_prop_pow_0(&_S182, &_S183, _S174.differential_0.x); - _S157 = 0.94786733388900757f * _S182.differential_0; + DiffPair_float_0 _S178; + (&_S178)->primal_0 = _S157; + (&_S178)->differential_0 = 0.0f; + DiffPair_float_0 _S179; + (&_S179)->primal_0 = 2.40000009536743164f; + (&_S179)->differential_0 = 0.0f; + s_bwd_prop_pow_0(&_S178, &_S179, _S176.differential_0.z); + _S157 = 0.94786733388900757f * _S178.differential_0; } - _S158 = make_float3 (_S157, _S156, _S155); + bool _S180 = _S158 < 0.04044999927282333f; + if(_S180) + { + _S158 = 0.0f; + } + else + { + _S158 = 0.94786733388900757f * (_S158 + 0.05499999970197678f); + } + if(_S180) + { + _S158 = 0.07739938050508499f * _S176.differential_0.y; + } + else + { + DiffPair_float_0 _S181; + (&_S181)->primal_0 = _S158; + (&_S181)->differential_0 = 0.0f; + DiffPair_float_0 _S182; + (&_S182)->primal_0 = 2.40000009536743164f; + (&_S182)->differential_0 = 0.0f; + s_bwd_prop_pow_0(&_S181, &_S182, _S176.differential_0.y); + _S158 = 0.94786733388900757f * _S181.differential_0; + } + bool _S183 = _S159 < 0.04044999927282333f; + if(_S183) + { + _S159 = 0.0f; + } + else + { + _S159 = 0.94786733388900757f * (_S159 + 0.05499999970197678f); + } + if(_S183) + { + _S159 = 0.07739938050508499f * _S176.differential_0.x; + } + else + { + DiffPair_float_0 _S184; + (&_S184)->primal_0 = _S159; + (&_S184)->differential_0 = 0.0f; + DiffPair_float_0 _S185; + (&_S185)->primal_0 = 2.40000009536743164f; + (&_S185)->differential_0 = 0.0f; + s_bwd_prop_pow_0(&_S184, &_S185, _S176.differential_0.x); + _S159 = 0.94786733388900757f * _S184.differential_0; + } + _S160 = make_float3 (_S159, _S158, _S157); } else { - _S158 = _S174.differential_0; + _S160 = _S176.differential_0; } dprgb_0->primal_0 = (*dprgb_0).primal_0; - dprgb_0->differential_0 = _S158; + dprgb_0->differential_0 = _S160; return; } -inline __device__ void s_bwd_working_to_display_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S184, Matrix _S185, int _S186, bool _S187, float3 _S188) +inline __device__ void s_bwd_working_to_display_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S186, Matrix _S187, int _S188, bool _S189, float3 _S190) { - s_bwd_prop_working_to_display_0(_S184, _S185, _S186, _S187, _S188); + s_bwd_prop_working_to_display_0(_S186, _S187, _S188, _S189, _S190); return; } inline __device__ float3 working_to_display_bwd(float3 rgb_3, Matrix color_matrix_2, int transfer_4, bool is_linear_2, float3 v_out_rgb_1) { - float3 _S189 = make_float3 (0.0f); + float3 _S191 = make_float3 (0.0f); DiffPair_vectorx3Cfloatx2C3x3E_0 p_rgb_1; (&p_rgb_1)->primal_0 = rgb_3; - (&p_rgb_1)->differential_0 = _S189; + (&p_rgb_1)->differential_0 = _S191; s_bwd_working_to_display_0(&p_rgb_1, color_matrix_2, transfer_4, is_linear_2, v_out_rgb_1); return p_rgb_1.differential_0; } inline __device__ void _d_sqrt_0(DiffPair_float_0 * dpx_12, float dOut_4) { - float _S190 = 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), ((*dpx_12).primal_0)))))) * dOut_4; + float _S192 = 0.5f / (F32_sqrt(((F32_max((1.00000001168609742e-07f), ((*dpx_12).primal_0)))))) * dOut_4; dpx_12->primal_0 = (*dpx_12).primal_0; - dpx_12->differential_0 = _S190; + dpx_12->differential_0 = _S192; return; } inline __device__ float xfer_filmic_inv_0(float y_4) { - float _S191 = (F32_min((y_4), (xfer_filmic_0(11.19999980926513672f)))); - float a_0 = 6.19999980926513672f * (1.0f - _S191); - float b_0 = 0.5f - 1.70000004768371582f * _S191; - return (- b_0 + (F32_sqrt(((F32_max((b_0 * b_0 - 4.0f * a_0 * (-0.05999999865889549f * _S191)), (0.0f))))))) / (2.0f * a_0) + 0.00400000018998981f; + float _S193 = (F32_min((y_4), (xfer_filmic_0(11.19999980926513672f)))); + float a_0 = 6.19999980926513672f * (1.0f - _S193); + float b_0 = 0.5f - 1.70000004768371582f * _S193; + return (- b_0 + (F32_sqrt(((F32_max((b_0 * b_0 - 4.0f * a_0 * (-0.05999999865889549f * _S193)), (0.0f))))))) / (2.0f * a_0) + 0.00400000018998981f; } inline __device__ float xfer_aces_inv_0(float y_5) @@ -1216,70 +1231,52 @@ inline __device__ float tone_decode_0(float d_0, int transfer_5) { return xfer_filmic_inv_0(d_0); } - float _S192; + float _S194; if(transfer_5 == int(2)) { if(d_0 < 0.04044999927282333f) { - _S192 = d_0 * 0.07739938050508499f; + _S194 = d_0 * 0.07739938050508499f; } else { - _S192 = (F32_pow((0.94786733388900757f * (d_0 + 0.05499999970197678f)), (2.40000009536743164f))); + _S194 = (F32_pow((0.94786733388900757f * (d_0 + 0.05499999970197678f)), (2.40000009536743164f))); } - return xfer_aces_inv_0(_S192); + return xfer_aces_inv_0(_S194); } if(transfer_5 == int(4)) { if(d_0 < 0.04044999927282333f) { - _S192 = d_0 * 0.07739938050508499f; + _S194 = d_0 * 0.07739938050508499f; } else { - _S192 = (F32_pow((0.94786733388900757f * (d_0 + 0.05499999970197678f)), (2.40000009536743164f))); + _S194 = (F32_pow((0.94786733388900757f * (d_0 + 0.05499999970197678f)), (2.40000009536743164f))); } - return xfer_uncharted2_inv_0(_S192); + return xfer_uncharted2_inv_0(_S194); } if(d_0 < 0.04044999927282333f) { - _S192 = d_0 * 0.07739938050508499f; + _S194 = d_0 * 0.07739938050508499f; } else { - _S192 = (F32_pow((0.94786733388900757f * (d_0 + 0.05499999970197678f)), (2.40000009536743164f))); + _S194 = (F32_pow((0.94786733388900757f * (d_0 + 0.05499999970197678f)), (2.40000009536743164f))); } - return _S192; + return _S194; } inline __device__ float3 display_to_working3(float3 rgb_4, int transfer_6, bool is_linear_3) { - float _S193 = tone_decode_0(rgb_4.x, transfer_6); - float _S194 = tone_decode_0(rgb_4.y, transfer_6); - float _S195 = tone_decode_0(rgb_4.z, transfer_6); - float3 lin_0 = make_float3 (_S193, _S194, _S195); + float _S195 = tone_decode_0(rgb_4.x, transfer_6); + float _S196 = tone_decode_0(rgb_4.y, transfer_6); + float _S197 = tone_decode_0(rgb_4.z, transfer_6); + float3 lin_0 = make_float3 (_S195, _S196, _S197); if(is_linear_3) { return lin_0; } - float _S196; - if(_S193 < 0.00313080009073019f) - { - _S196 = _S193 * 12.92000007629394531f; - } - else - { - _S196 = 1.0549999475479126f * (F32_pow((_S193), (0.4166666567325592f))) - 0.05499999970197678f; - } - float _S197; - if(_S194 < 0.00313080009073019f) - { - _S197 = _S194 * 12.92000007629394531f; - } - else - { - _S197 = 1.0549999475479126f * (F32_pow((_S194), (0.4166666567325592f))) - 0.05499999970197678f; - } float _S198; if(_S195 < 0.00313080009073019f) { @@ -1289,35 +1286,62 @@ inline __device__ float3 display_to_working3(float3 rgb_4, int transfer_6, boo { _S198 = 1.0549999475479126f * (F32_pow((_S195), (0.4166666567325592f))) - 0.05499999970197678f; } - return make_float3 (_S196, _S197, _S198); + float _S199; + if(_S196 < 0.00313080009073019f) + { + _S199 = _S196 * 12.92000007629394531f; + } + else + { + _S199 = 1.0549999475479126f * (F32_pow((_S196), (0.4166666567325592f))) - 0.05499999970197678f; + } + float _S200; + if(_S197 < 0.00313080009073019f) + { + _S200 = _S197 * 12.92000007629394531f; + } + else + { + _S200 = 1.0549999475479126f * (F32_pow((_S197), (0.4166666567325592f))) - 0.05499999970197678f; + } + return make_float3 (_S198, _S199, _S200); +} + +inline __device__ float3 background_apply_exponent(float3 display_0, float p_0) +{ + if(p_0 == 1.0f) + { + return display_0; + } + return make_float3 ((F32_pow(((F32_max((display_0.x), (0.0f)))), (p_0))), (F32_pow(((F32_max((display_0.y), (0.0f)))), (p_0))), (F32_pow(((F32_max((display_0.z), (0.0f)))), (p_0)))); } inline __device__ void _d_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * a_3, DiffPair_vectorx3Cfloatx2C3x3E_0 * b_3, float3 dOut_5) { - float _S199 = dOut_5.y; - float _S200 = dOut_5.z; - float _S201 = dOut_5.x; - float _S202 = (*a_3).primal_0.z * _S199 + - (*a_3).primal_0.y * _S200; - float _S203 = - (*a_3).primal_0.z * _S201 + (*a_3).primal_0.x * _S200; - float _S204 = (*a_3).primal_0.y * _S201 + - (*a_3).primal_0.x * _S199; - float3 _S205 = make_float3 (- (*b_3).primal_0.z * _S199 + (*b_3).primal_0.y * _S200, (*b_3).primal_0.z * _S201 + - (*b_3).primal_0.x * _S200, - (*b_3).primal_0.y * _S201 + (*b_3).primal_0.x * _S199); + float _S201 = dOut_5.y; + float _S202 = dOut_5.z; + float _S203 = dOut_5.x; + float _S204 = (*a_3).primal_0.z * _S201 + - (*a_3).primal_0.y * _S202; + float _S205 = - (*a_3).primal_0.z * _S203 + (*a_3).primal_0.x * _S202; + float _S206 = (*a_3).primal_0.y * _S203 + - (*a_3).primal_0.x * _S201; + float3 _S207 = make_float3 (- (*b_3).primal_0.z * _S201 + (*b_3).primal_0.y * _S202, (*b_3).primal_0.z * _S203 + - (*b_3).primal_0.x * _S202, - (*b_3).primal_0.y * _S203 + (*b_3).primal_0.x * _S201); a_3->primal_0 = (*a_3).primal_0; - a_3->differential_0 = _S205; - float3 _S206 = make_float3 (_S202, _S203, _S204); + a_3->differential_0 = _S207; + float3 _S208 = make_float3 (_S204, _S205, _S206); b_3->primal_0 = (*b_3).primal_0; - b_3->differential_0 = _S206; + b_3->differential_0 = _S208; return; } inline __device__ float3 cross_0(float3 left_2, float3 right_2) { - float _S207 = left_2.y; - float _S208 = right_2.z; - float _S209 = left_2.z; - float _S210 = right_2.y; - float _S211 = right_2.x; - float _S212 = left_2.x; - return make_float3 (_S207 * _S208 - _S209 * _S210, _S209 * _S211 - _S212 * _S208, _S212 * _S210 - _S207 * _S211); + float _S209 = left_2.y; + float _S210 = right_2.z; + float _S211 = left_2.z; + float _S212 = right_2.y; + float _S213 = right_2.x; + float _S214 = left_2.x; + return make_float3 (_S209 * _S210 - _S211 * _S212, _S211 * _S213 - _S214 * _S210, _S214 * _S212 - _S209 * _S213); } inline __device__ float length_0(float3 x_17) @@ -1332,36 +1356,36 @@ inline __device__ float length_1(float2 x_18) inline __device__ float3 points_to_normal(FixedArray points_0) { - float3 _S213 = points_0[int(0)]; - bool _S214; - if((dot_0(_S213, _S213)) == 0.0f) + float3 _S215 = points_0[int(0)]; + bool _S216; + if((dot_0(_S215, _S215)) == 0.0f) { - _S214 = true; + _S216 = true; } else { - float3 _S215 = points_0[int(1)]; - _S214 = (dot_0(_S215, _S215)) == 0.0f; + float3 _S217 = points_0[int(1)]; + _S216 = (dot_0(_S217, _S217)) == 0.0f; } - if(_S214) + if(_S216) { - _S214 = true; + _S216 = true; } else { - float3 _S216 = points_0[int(2)]; - _S214 = (dot_0(_S216, _S216)) == 0.0f; + float3 _S218 = points_0[int(2)]; + _S216 = (dot_0(_S218, _S218)) == 0.0f; } - if(_S214) + if(_S216) { - _S214 = true; + _S216 = true; } else { - float3 _S217 = points_0[int(3)]; - _S214 = (dot_0(_S217, _S217)) == 0.0f; + float3 _S219 = points_0[int(3)]; + _S216 = (dot_0(_S219, _S219)) == 0.0f; } - if(_S214) + if(_S216) { return make_float3 (0.0f); } @@ -1384,323 +1408,323 @@ struct DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 FixedArray differential_0; }; -inline __device__ float s_primal_ctx_dot_0(float3 _S218, float3 _S219) +inline __device__ float s_primal_ctx_dot_0(float3 _S220, float3 _S221) { - return dot_0(_S218, _S219); + return dot_0(_S220, _S221); } -inline __device__ float3 s_primal_ctx_cross_0(float3 _S220, float3 _S221) +inline __device__ float3 s_primal_ctx_cross_0(float3 _S222, float3 _S223) { - return cross_0(_S220, _S221); + return cross_0(_S222, _S223); } -inline __device__ void s_bwd_prop_sqrt_0(DiffPair_float_0 * _S222, float _S223) +inline __device__ void s_bwd_prop_sqrt_0(DiffPair_float_0 * _S224, float _S225) { - _d_sqrt_0(_S222, _S223); + _d_sqrt_0(_S224, _S225); return; } inline __device__ void s_bwd_prop_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_13, float _s_dOut_7) { - float _S224 = (*dpx_13).primal_0.x; - float _S225 = (*dpx_13).primal_0.y; - float _S226 = (*dpx_13).primal_0.z; - DiffPair_float_0 _S227; - (&_S227)->primal_0 = _S224 * _S224 + _S225 * _S225 + _S226 * _S226; - (&_S227)->differential_0 = 0.0f; - s_bwd_prop_sqrt_0(&_S227, _s_dOut_7); - float _S228 = (*dpx_13).primal_0.z * _S227.differential_0; - float _S229 = _S228 + _S228; - float _S230 = (*dpx_13).primal_0.y * _S227.differential_0; + float _S226 = (*dpx_13).primal_0.x; + float _S227 = (*dpx_13).primal_0.y; + float _S228 = (*dpx_13).primal_0.z; + DiffPair_float_0 _S229; + (&_S229)->primal_0 = _S226 * _S226 + _S227 * _S227 + _S228 * _S228; + (&_S229)->differential_0 = 0.0f; + s_bwd_prop_sqrt_0(&_S229, _s_dOut_7); + float _S230 = (*dpx_13).primal_0.z * _S229.differential_0; float _S231 = _S230 + _S230; - float _S232 = (*dpx_13).primal_0.x * _S227.differential_0; + float _S232 = (*dpx_13).primal_0.y * _S229.differential_0; float _S233 = _S232 + _S232; - float3 _S234 = make_float3 (0.0f); - *&((&_S234)->z) = _S229; - *&((&_S234)->y) = _S231; - *&((&_S234)->x) = _S233; + float _S234 = (*dpx_13).primal_0.x * _S229.differential_0; + float _S235 = _S234 + _S234; + float3 _S236 = make_float3 (0.0f); + *&((&_S236)->z) = _S231; + *&((&_S236)->y) = _S233; + *&((&_S236)->x) = _S235; dpx_13->primal_0 = (*dpx_13).primal_0; - dpx_13->differential_0 = _S234; + dpx_13->differential_0 = _S236; return; } -inline __device__ void s_bwd_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S235, float _S236) +inline __device__ void s_bwd_length_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S237, float _S238) { - s_bwd_prop_length_impl_0(_S235, _S236); + s_bwd_prop_length_impl_0(_S237, _S238); return; } -inline __device__ void s_bwd_prop_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S237, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S238, float _S239) +inline __device__ void s_bwd_prop_dot_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S239, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S240, float _S241) { - _d_dot_0(_S237, _S238, _S239); + _d_dot_0(_S239, _S240, _S241); return; } -inline __device__ void s_bwd_prop_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S240, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S241, float3 _S242) +inline __device__ void s_bwd_prop_cross_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S242, DiffPair_vectorx3Cfloatx2C3x3E_0 * _S243, float3 _S244) { - _d_cross_0(_S240, _S241, _S242); + _d_cross_0(_S242, _S243, _S244); return; } inline __device__ void s_bwd_prop_points_to_normal_0(DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 * dppoints_0, float3 _s_dOut_8) { - FixedArray _S243 = dppoints_0->primal_0; - float3 _S244 = make_float3 (0.0f); - float3 _S245 = dppoints_0->primal_0[int(0)]; - bool _S246 = (s_primal_ctx_dot_0(_S245, _S245)) == 0.0f; - bool _S247; - float3 _S248; - if(_S246) + FixedArray _S245 = dppoints_0->primal_0; + float3 _S246 = make_float3 (0.0f); + float3 _S247 = dppoints_0->primal_0[int(0)]; + bool _S248 = (s_primal_ctx_dot_0(_S247, _S247)) == 0.0f; + bool _S249; + float3 _S250; + if(_S248) { - _S247 = true; - _S248 = _S244; + _S249 = true; + _S250 = _S246; } else { - float3 _S249 = _S243[int(1)]; - _S247 = (s_primal_ctx_dot_0(_S249, _S249)) == 0.0f; - _S248 = _S243[int(1)]; + float3 _S251 = _S245[int(1)]; + _S249 = (s_primal_ctx_dot_0(_S251, _S251)) == 0.0f; + _S250 = _S245[int(1)]; } - bool _S250; - float3 _S251; - if(_S247) + bool _S252; + float3 _S253; + if(_S249) { - _S250 = true; - _S251 = _S244; + _S252 = true; + _S253 = _S246; } else { - float3 _S252 = _S243[int(2)]; - _S250 = (s_primal_ctx_dot_0(_S252, _S252)) == 0.0f; - _S251 = _S243[int(2)]; + float3 _S254 = _S245[int(2)]; + _S252 = (s_primal_ctx_dot_0(_S254, _S254)) == 0.0f; + _S253 = _S245[int(2)]; } - bool _S253; - float3 _S254; - if(_S250) + bool _S255; + float3 _S256; + if(_S252) { - _S253 = true; - _S254 = _S244; + _S255 = true; + _S256 = _S246; } else { - float3 _S255 = _S243[int(3)]; - _S253 = (s_primal_ctx_dot_0(_S255, _S255)) == 0.0f; - _S254 = _S243[int(3)]; + float3 _S257 = _S245[int(3)]; + _S255 = (s_primal_ctx_dot_0(_S257, _S257)) == 0.0f; + _S256 = _S245[int(3)]; } - bool _S256 = !_S253; - float3 _S257; - float3 _S258; + bool _S258 = !_S255; float3 _S259; float3 _S260; float3 _S261; - if(_S256) + float3 _S262; + float3 _S263; + if(_S258) { - float3 dx_0 = _S243[int(1)] - _S243[int(0)]; - float3 _S262 = - (_S243[int(3)] - _S243[int(2)]); - float3 _S263 = s_primal_ctx_cross_0(dx_0, _S262); - bool _S264 = (s_primal_ctx_dot_0(_S263, _S263)) != 0.0f; - if(_S264) + float3 dx_0 = _S245[int(1)] - _S245[int(0)]; + float3 _S264 = - (_S245[int(3)] - _S245[int(2)]); + float3 _S265 = s_primal_ctx_cross_0(dx_0, _S264); + bool _S266 = (s_primal_ctx_dot_0(_S265, _S265)) != 0.0f; + if(_S266) { - float _S265 = length_0(_S263); - float3 _S266 = make_float3 (_S265); - _S257 = make_float3 (_S265 * _S265); - _S258 = _S266; + float _S267 = length_0(_S265); + float3 _S268 = make_float3 (_S267); + _S259 = make_float3 (_S267 * _S267); + _S260 = _S268; } else { - _S257 = _S244; - _S258 = _S244; + _S259 = _S246; + _S260 = _S246; } - float3 _S267 = _S258; - _S253 = _S264; - _S258 = _S263; - _S259 = _S267; - _S260 = dx_0; - _S261 = _S262; + float3 _S269 = _S260; + _S255 = _S266; + _S260 = _S265; + _S261 = _S269; + _S262 = dx_0; + _S263 = _S264; } else { - _S253 = false; - _S257 = _S244; - _S258 = _S244; - _S259 = _S244; - _S260 = _S244; - _S261 = _S244; + _S255 = false; + _S259 = _S246; + _S260 = _S246; + _S261 = _S246; + _S262 = _S246; + _S263 = _S246; } - FixedArray _S268; - if(_S256) + FixedArray _S270; + if(_S258) { - if(_S253) + if(_S255) { - float3 _S269 = _s_dOut_8 / _S257; - float3 _S270 = _S258 * - _S269; - float3 _S271 = _S259 * _S269; - float _S272 = _S270.x + _S270.y + _S270.z; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S273; - (&_S273)->primal_0 = _S258; - (&_S273)->differential_0 = _S244; - s_bwd_length_impl_0(&_S273, _S272); - _S257 = _S271 + _S273.differential_0; + float3 _S271 = _s_dOut_8 / _S259; + float3 _S272 = _S260 * - _S271; + float3 _S273 = _S261 * _S271; + float _S274 = _S272.x + _S272.y + _S272.z; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S275; + (&_S275)->primal_0 = _S260; + (&_S275)->differential_0 = _S246; + s_bwd_length_impl_0(&_S275, _S274); + _S259 = _S273 + _S275.differential_0; } else { - _S257 = _s_dOut_8; + _S259 = _s_dOut_8; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S274; - (&_S274)->primal_0 = _S258; - (&_S274)->differential_0 = _S244; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S275; - (&_S275)->primal_0 = _S258; - (&_S275)->differential_0 = _S244; - s_bwd_prop_dot_0(&_S274, &_S275, 0.0f); - float3 _S276 = _S275.differential_0 + _S274.differential_0 + _S257; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S276; + (&_S276)->primal_0 = _S260; + (&_S276)->differential_0 = _S246; DiffPair_vectorx3Cfloatx2C3x3E_0 _S277; (&_S277)->primal_0 = _S260; - (&_S277)->differential_0 = _S244; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S278; - (&_S278)->primal_0 = _S261; - (&_S278)->differential_0 = _S244; - s_bwd_prop_cross_0(&_S277, &_S278, _S276); - float3 s_diff_dy_T_0 = - _S278.differential_0; - float3 _S279 = - s_diff_dy_T_0; - float3 _S280 = - _S277.differential_0; - FixedArray _S281; - _S281[int(0)] = _S244; - _S281[int(1)] = _S244; - _S281[int(2)] = _S244; - _S281[int(3)] = _S244; - _S281[int(2)] = _S279; - _S281[int(3)] = s_diff_dy_T_0; - _S281[int(1)] = _S277.differential_0; - _S268[int(0)] = _S281[int(0)]; - _S268[int(1)] = _S281[int(1)]; - _S268[int(2)] = _S281[int(2)]; - _S268[int(3)] = _S281[int(3)]; - _S257 = _S280; + (&_S277)->differential_0 = _S246; + s_bwd_prop_dot_0(&_S276, &_S277, 0.0f); + float3 _S278 = _S277.differential_0 + _S276.differential_0 + _S259; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S279; + (&_S279)->primal_0 = _S262; + (&_S279)->differential_0 = _S246; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S280; + (&_S280)->primal_0 = _S263; + (&_S280)->differential_0 = _S246; + s_bwd_prop_cross_0(&_S279, &_S280, _S278); + float3 s_diff_dy_T_0 = - _S280.differential_0; + float3 _S281 = - s_diff_dy_T_0; + float3 _S282 = - _S279.differential_0; + FixedArray _S283; + _S283[int(0)] = _S246; + _S283[int(1)] = _S246; + _S283[int(2)] = _S246; + _S283[int(3)] = _S246; + _S283[int(2)] = _S281; + _S283[int(3)] = s_diff_dy_T_0; + _S283[int(1)] = _S279.differential_0; + _S270[int(0)] = _S283[int(0)]; + _S270[int(1)] = _S283[int(1)]; + _S270[int(2)] = _S283[int(2)]; + _S270[int(3)] = _S283[int(3)]; + _S259 = _S282; } else { - _S268[int(0)] = _S244; - _S268[int(1)] = _S244; - _S268[int(2)] = _S244; - _S268[int(3)] = _S244; - _S257 = _S244; + _S270[int(0)] = _S246; + _S270[int(1)] = _S246; + _S270[int(2)] = _S246; + _S270[int(3)] = _S246; + _S259 = _S246; } - if(_S250) + if(_S252) { } else { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S282; - (&_S282)->primal_0 = _S254; - (&_S282)->differential_0 = _S244; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S283; - (&_S283)->primal_0 = _S254; - (&_S283)->differential_0 = _S244; - s_bwd_prop_dot_0(&_S282, &_S283, 0.0f); - float3 _S284 = _S283.differential_0 + _S282.differential_0; - FixedArray _S285; - _S285[int(0)] = _S244; - _S285[int(1)] = _S244; - _S285[int(2)] = _S244; - _S285[int(3)] = _S244; - _S285[int(3)] = _S284; - float3 _S286 = _S268[int(1)] + _S285[int(1)]; - float3 _S287 = _S268[int(2)] + _S285[int(2)]; - float3 _S288 = _S268[int(3)] + _S285[int(3)]; - _S268[int(0)] = _S268[int(0)] + _S285[int(0)]; - _S268[int(1)] = _S286; - _S268[int(2)] = _S287; - _S268[int(3)] = _S288; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S284; + (&_S284)->primal_0 = _S256; + (&_S284)->differential_0 = _S246; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S285; + (&_S285)->primal_0 = _S256; + (&_S285)->differential_0 = _S246; + s_bwd_prop_dot_0(&_S284, &_S285, 0.0f); + float3 _S286 = _S285.differential_0 + _S284.differential_0; + FixedArray _S287; + _S287[int(0)] = _S246; + _S287[int(1)] = _S246; + _S287[int(2)] = _S246; + _S287[int(3)] = _S246; + _S287[int(3)] = _S286; + float3 _S288 = _S270[int(1)] + _S287[int(1)]; + float3 _S289 = _S270[int(2)] + _S287[int(2)]; + float3 _S290 = _S270[int(3)] + _S287[int(3)]; + _S270[int(0)] = _S270[int(0)] + _S287[int(0)]; + _S270[int(1)] = _S288; + _S270[int(2)] = _S289; + _S270[int(3)] = _S290; } - if(_S247) + if(_S249) { } else { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S289; - (&_S289)->primal_0 = _S251; - (&_S289)->differential_0 = _S244; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S290; - (&_S290)->primal_0 = _S251; - (&_S290)->differential_0 = _S244; - s_bwd_prop_dot_0(&_S289, &_S290, 0.0f); - float3 _S291 = _S290.differential_0 + _S289.differential_0; - FixedArray _S292; - _S292[int(0)] = _S244; - _S292[int(1)] = _S244; - _S292[int(2)] = _S244; - _S292[int(3)] = _S244; - _S292[int(2)] = _S291; - float3 _S293 = _S268[int(1)] + _S292[int(1)]; - float3 _S294 = _S268[int(2)] + _S292[int(2)]; - float3 _S295 = _S268[int(3)] + _S292[int(3)]; - _S268[int(0)] = _S268[int(0)] + _S292[int(0)]; - _S268[int(1)] = _S293; - _S268[int(2)] = _S294; - _S268[int(3)] = _S295; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S291; + (&_S291)->primal_0 = _S253; + (&_S291)->differential_0 = _S246; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S292; + (&_S292)->primal_0 = _S253; + (&_S292)->differential_0 = _S246; + s_bwd_prop_dot_0(&_S291, &_S292, 0.0f); + float3 _S293 = _S292.differential_0 + _S291.differential_0; + FixedArray _S294; + _S294[int(0)] = _S246; + _S294[int(1)] = _S246; + _S294[int(2)] = _S246; + _S294[int(3)] = _S246; + _S294[int(2)] = _S293; + float3 _S295 = _S270[int(1)] + _S294[int(1)]; + float3 _S296 = _S270[int(2)] + _S294[int(2)]; + float3 _S297 = _S270[int(3)] + _S294[int(3)]; + _S270[int(0)] = _S270[int(0)] + _S294[int(0)]; + _S270[int(1)] = _S295; + _S270[int(2)] = _S296; + _S270[int(3)] = _S297; } - if(_S246) + if(_S248) { } else { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S296; - (&_S296)->primal_0 = _S248; - (&_S296)->differential_0 = _S244; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S297; - (&_S297)->primal_0 = _S248; - (&_S297)->differential_0 = _S244; - s_bwd_prop_dot_0(&_S296, &_S297, 0.0f); - float3 _S298 = _S297.differential_0 + _S296.differential_0; - FixedArray _S299; - _S299[int(0)] = _S244; - _S299[int(1)] = _S244; - _S299[int(2)] = _S244; - _S299[int(3)] = _S244; - _S299[int(1)] = _S298; - float3 _S300 = _S268[int(1)] + _S299[int(1)]; - float3 _S301 = _S268[int(2)] + _S299[int(2)]; - float3 _S302 = _S268[int(3)] + _S299[int(3)]; - _S268[int(0)] = _S268[int(0)] + _S299[int(0)]; - _S268[int(1)] = _S300; - _S268[int(2)] = _S301; - _S268[int(3)] = _S302; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S298; + (&_S298)->primal_0 = _S250; + (&_S298)->differential_0 = _S246; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S299; + (&_S299)->primal_0 = _S250; + (&_S299)->differential_0 = _S246; + s_bwd_prop_dot_0(&_S298, &_S299, 0.0f); + float3 _S300 = _S299.differential_0 + _S298.differential_0; + FixedArray _S301; + _S301[int(0)] = _S246; + _S301[int(1)] = _S246; + _S301[int(2)] = _S246; + _S301[int(3)] = _S246; + _S301[int(1)] = _S300; + float3 _S302 = _S270[int(1)] + _S301[int(1)]; + float3 _S303 = _S270[int(2)] + _S301[int(2)]; + float3 _S304 = _S270[int(3)] + _S301[int(3)]; + _S270[int(0)] = _S270[int(0)] + _S301[int(0)]; + _S270[int(1)] = _S302; + _S270[int(2)] = _S303; + _S270[int(3)] = _S304; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S303; - (&_S303)->primal_0 = _S243[int(0)]; - (&_S303)->differential_0 = _S244; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S304; - (&_S304)->primal_0 = _S243[int(0)]; - (&_S304)->differential_0 = _S244; - s_bwd_prop_dot_0(&_S303, &_S304, 0.0f); - float3 _S305 = _S304.differential_0 + _S303.differential_0 + _S257; - FixedArray _S306; - _S306[int(0)] = _S244; - _S306[int(1)] = _S244; - _S306[int(2)] = _S244; - _S306[int(3)] = _S244; - _S306[int(0)] = _S305; - FixedArray _S307 = { - _S268[int(0)] + _S306[int(0)], _S268[int(1)] + _S306[int(1)], _S268[int(2)] + _S306[int(2)], _S268[int(3)] + _S306[int(3)] + DiffPair_vectorx3Cfloatx2C3x3E_0 _S305; + (&_S305)->primal_0 = _S245[int(0)]; + (&_S305)->differential_0 = _S246; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S306; + (&_S306)->primal_0 = _S245[int(0)]; + (&_S306)->differential_0 = _S246; + s_bwd_prop_dot_0(&_S305, &_S306, 0.0f); + float3 _S307 = _S306.differential_0 + _S305.differential_0 + _S259; + FixedArray _S308; + _S308[int(0)] = _S246; + _S308[int(1)] = _S246; + _S308[int(2)] = _S246; + _S308[int(3)] = _S246; + _S308[int(0)] = _S307; + FixedArray _S309 = { + _S270[int(0)] + _S308[int(0)], _S270[int(1)] + _S308[int(1)], _S270[int(2)] + _S308[int(2)], _S270[int(3)] + _S308[int(3)] }; dppoints_0->primal_0 = dppoints_0->primal_0; - dppoints_0->differential_0 = _S307; + dppoints_0->differential_0 = _S309; return; } -inline __device__ void s_bwd_points_to_normal_0(DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 * _S308, float3 _S309) +inline __device__ void s_bwd_points_to_normal_0(DiffPair_arrayx3Cvectorx3Cfloatx2C3x3Ex2C4x3E_0 * _S310, float3 _S311) { - s_bwd_prop_points_to_normal_0(_S308, _S309); + s_bwd_prop_points_to_normal_0(_S310, _S311); return; } inline __device__ void points_to_normal_vjp(FixedArray points_1, float3 v_normal_0, FixedArray * v_points_0) { - FixedArray _S310 = { make_float3 (0.0f), make_float3 (0.0f), make_float3 (0.0f), make_float3 (0.0f) }; + FixedArray _S312 = { 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 = _S310; + (&dp_points_0)->differential_0 = _S312; s_bwd_points_to_normal_0(&dp_points_0, v_normal_0); *v_points_0 = (&dp_points_0)->differential_0; return; @@ -1768,20 +1792,20 @@ inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistOpenCV_distort_0(Di 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 _S311 = s_diff_u_0 * u_1; - float _S312 = s_diff_v_0 * v_1; + float _S313 = s_diff_u_0 * u_1; + float _S314 = s_diff_v_0 * v_1; float r2_1 = u_1 * u_1 + v_1 * v_1; - float s_diff_r2_0 = _S311 + _S311 + (_S312 + _S312); - float _S313 = (*coeffs_1)[int(0)] + r2_1 * (*coeffs_1)[int(1)]; - float radial_0 = 1.0f + r2_1 * _S313; - float _S314 = 2.0f * (*coeffs_1)[int(2)]; - float _S315 = _S314 * u_1; - float _S316 = 2.0f * u_1; - float _S317 = 2.0f * (*coeffs_1)[int(3)]; - float _S318 = _S317 * u_1; - float _S319 = 2.0f * v_1; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S320 = { dpuv_0->primal_0 * make_float2 (radial_0) + make_float2 (_S315 * v_1 + (*coeffs_1)[int(3)] * (r2_1 + _S316 * u_1), _S318 * v_1 + (*coeffs_1)[int(2)] * (r2_1 + _S319 * v_1)), dpuv_0->differential_0 * make_float2 (radial_0) + make_float2 (s_diff_r2_0 * _S313 + s_diff_r2_0 * (*coeffs_1)[int(1)] * r2_1) * dpuv_0->primal_0 + make_float2 (s_diff_u_0 * _S314 * v_1 + s_diff_v_0 * _S315 + (s_diff_r2_0 + (s_diff_u_0 * 2.0f * u_1 + s_diff_u_0 * _S316)) * (*coeffs_1)[int(3)], s_diff_u_0 * _S317 * v_1 + s_diff_v_0 * _S318 + (s_diff_r2_0 + (s_diff_v_0 * 2.0f * v_1 + s_diff_v_0 * _S319)) * (*coeffs_1)[int(2)]) }; - return _S320; + float s_diff_r2_0 = _S313 + _S313 + (_S314 + _S314); + float _S315 = (*coeffs_1)[int(0)] + r2_1 * (*coeffs_1)[int(1)]; + float radial_0 = 1.0f + r2_1 * _S315; + float _S316 = 2.0f * (*coeffs_1)[int(2)]; + float _S317 = _S316 * u_1; + float _S318 = 2.0f * u_1; + float _S319 = 2.0f * (*coeffs_1)[int(3)]; + float _S320 = _S319 * u_1; + float _S321 = 2.0f * v_1; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S322 = { dpuv_0->primal_0 * make_float2 (radial_0) + make_float2 (_S317 * v_1 + (*coeffs_1)[int(3)] * (r2_1 + _S318 * u_1), _S320 * v_1 + (*coeffs_1)[int(2)] * (r2_1 + _S321 * v_1)), dpuv_0->differential_0 * make_float2 (radial_0) + make_float2 (s_diff_r2_0 * _S315 + s_diff_r2_0 * (*coeffs_1)[int(1)] * r2_1) * dpuv_0->primal_0 + make_float2 (s_diff_u_0 * _S316 * v_1 + s_diff_v_0 * _S317 + (s_diff_r2_0 + (s_diff_u_0 * 2.0f * u_1 + s_diff_u_0 * _S318)) * (*coeffs_1)[int(3)], s_diff_u_0 * _S319 * v_1 + s_diff_v_0 * _S320 + (s_diff_r2_0 + (s_diff_v_0 * 2.0f * v_1 + s_diff_v_0 * _S321)) * (*coeffs_1)[int(2)]) }; + return _S322; } inline __device__ bool undistort_point_1(float2 uv_2, FixedArray * dist_coeffs_1, int maxiter_1, float2 * uv_undist_1) @@ -1797,67 +1821,67 @@ inline __device__ bool undistort_point_1(float2 uv_2, FixedArray * d { break; } - float2 _S321 = DistOpenCV_distort_0(q_0, dist_coeffs_1); - float2 r_2 = _S321 - uv_2; - float2 _S322 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S323; - (&_S323)->primal_0 = q_0; - (&_S323)->differential_0 = _S322; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S324 = s_fwd_DistOpenCV_distort_0(&_S323, dist_coeffs_1); - float2 _S325 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S326; - (&_S326)->primal_0 = q_0; - (&_S326)->differential_0 = _S325; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S327 = s_fwd_DistOpenCV_distort_0(&_S326, dist_coeffs_1); - Matrix _S328 = transpose_0(makeMatrix (_S324.differential_0, _S327.differential_0)); - float inv_det_0 = 1.0f / (_S328.rows[int(0)].x * _S328.rows[int(1)].y - _S328.rows[int(0)].y * _S328.rows[int(1)].x); - float _S329 = r_2.x; - float _S330 = r_2.y; - float2 q_1 = q_0 - make_float2 ((_S329 * _S328.rows[int(1)].y - _S330 * _S328.rows[int(0)].y) * inv_det_0, (- _S329 * _S328.rows[int(1)].x + _S330 * _S328.rows[int(0)].x) * inv_det_0); + float2 _S323 = DistOpenCV_distort_0(q_0, dist_coeffs_1); + float2 r_2 = _S323 - uv_2; + float2 _S324 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S325; + (&_S325)->primal_0 = q_0; + (&_S325)->differential_0 = _S324; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S326 = s_fwd_DistOpenCV_distort_0(&_S325, dist_coeffs_1); + float2 _S327 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S328; + (&_S328)->primal_0 = q_0; + (&_S328)->differential_0 = _S327; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S329 = s_fwd_DistOpenCV_distort_0(&_S328, dist_coeffs_1); + Matrix _S330 = transpose_0(makeMatrix (_S326.differential_0, _S329.differential_0)); + float inv_det_0 = 1.0f / (_S330.rows[int(0)].x * _S330.rows[int(1)].y - _S330.rows[int(0)].y * _S330.rows[int(1)].x); + float _S331 = r_2.x; + float _S332 = r_2.y; + float2 q_1 = q_0 - make_float2 ((_S331 * _S330.rows[int(1)].y - _S332 * _S330.rows[int(0)].y) * inv_det_0, (- _S331 * _S330.rows[int(1)].x + _S332 * _S330.rows[int(0)].x) * inv_det_0); i_5 = i_5 + int(1); q_0 = q_1; } *uv_undist_1 = q_0; - float2 _S331 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S332; - (&_S332)->primal_0 = q_0; - (&_S332)->differential_0 = _S331; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S333 = s_fwd_DistOpenCV_distort_0(&_S332, dist_coeffs_1); - float2 _S334 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S335; - (&_S335)->primal_0 = q_0; - (&_S335)->differential_0 = _S334; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S336 = s_fwd_DistOpenCV_distort_0(&_S335, dist_coeffs_1); - Matrix _S337 = transpose_0(makeMatrix (_S333.differential_0, _S336.differential_0)); - float _S338 = (F32_min((determinant_0(_S337)), ((F32_min((_S337.rows[int(0)].x), (_S337.rows[int(1)].y)))))); - bool _S339; - if(_S338 > 0.25f) + float2 _S333 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S334; + (&_S334)->primal_0 = q_0; + (&_S334)->differential_0 = _S333; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S335 = s_fwd_DistOpenCV_distort_0(&_S334, dist_coeffs_1); + float2 _S336 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S337; + (&_S337)->primal_0 = q_0; + (&_S337)->differential_0 = _S336; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S338 = s_fwd_DistOpenCV_distort_0(&_S337, dist_coeffs_1); + Matrix _S339 = transpose_0(makeMatrix (_S335.differential_0, _S338.differential_0)); + float _S340 = (F32_min((determinant_0(_S339)), ((F32_min((_S339.rows[int(0)].x), (_S339.rows[int(1)].y)))))); + bool _S341; + if(_S340 > 0.25f) { - _S339 = _S338 < 4.0f; + _S341 = _S340 < 4.0f; } else { - _S339 = false; + _S341 = false; } - if(_S339) + if(_S341) { - float2 _S340 = DistOpenCV_distort_0(q_0, dist_coeffs_1); - _S339 = (dot_1(q_0, _S340)) >= 0.0f; + float2 _S342 = DistOpenCV_distort_0(q_0, dist_coeffs_1); + _S341 = (dot_1(q_0, _S342)) >= 0.0f; } else { - _S339 = false; + _S341 = false; } - if(_S339) + if(_S341) { - float2 _S341 = DistOpenCV_distort_0(*uv_undist_1, dist_coeffs_1); - _S339 = (length_1(_S341 - uv_2)) < 0.00999999977648258f; + float2 _S343 = DistOpenCV_distort_0(*uv_undist_1, dist_coeffs_1); + _S341 = (length_1(_S343 - uv_2)) < 0.00999999977648258f; } else { - _S339 = false; + _S341 = false; } - return _S339; + return _S341; } inline __device__ float2 DistThinPrism_distort_0(float2 uv_3, FixedArray * coeffs_2) @@ -1874,22 +1898,22 @@ inline __device__ DiffPair_vectorx3Cfloatx2C2x3E_0 s_fwd_DistThinPrism_distort_0 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 _S342 = s_diff_u_1 * u_3; - float _S343 = s_diff_v_1 * v_3; + float _S344 = s_diff_u_1 * u_3; + float _S345 = s_diff_v_1 * v_3; float r2_3 = u_3 * u_3 + v_3 * v_3; - float s_diff_r2_1 = _S342 + _S342 + (_S343 + _S343); - float _S344 = (*coeffs_3)[int(2)] + r2_3 * (*coeffs_3)[int(3)]; - float _S345 = (*coeffs_3)[int(1)] + r2_3 * _S344; - float _S346 = (*coeffs_3)[int(0)] + r2_3 * _S345; - float radial_1 = 1.0f + r2_3 * _S346; - float _S347 = 2.0f * (*coeffs_3)[int(4)]; - float _S348 = _S347 * u_3; - float _S349 = 2.0f * u_3; - float _S350 = 2.0f * (*coeffs_3)[int(5)]; - float _S351 = _S350 * u_3; - float _S352 = 2.0f * v_3; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S353 = { dpuv_1->primal_0 * make_float2 (radial_1) + make_float2 (_S348 * v_3 + (*coeffs_3)[int(5)] * (r2_3 + _S349 * u_3) + (*coeffs_3)[int(6)] * r2_3, _S351 * v_3 + (*coeffs_3)[int(4)] * (r2_3 + _S352 * v_3) + (*coeffs_3)[int(7)] * r2_3), dpuv_1->differential_0 * make_float2 (radial_1) + make_float2 (s_diff_r2_1 * _S346 + (s_diff_r2_1 * _S345 + (s_diff_r2_1 * _S344 + s_diff_r2_1 * (*coeffs_3)[int(3)] * r2_3) * r2_3) * r2_3) * dpuv_1->primal_0 + make_float2 (s_diff_u_1 * _S347 * v_3 + s_diff_v_1 * _S348 + (s_diff_r2_1 + (s_diff_u_1 * 2.0f * u_3 + s_diff_u_1 * _S349)) * (*coeffs_3)[int(5)] + s_diff_r2_1 * (*coeffs_3)[int(6)], s_diff_u_1 * _S350 * v_3 + s_diff_v_1 * _S351 + (s_diff_r2_1 + (s_diff_v_1 * 2.0f * v_3 + s_diff_v_1 * _S352)) * (*coeffs_3)[int(4)] + s_diff_r2_1 * (*coeffs_3)[int(7)]) }; - return _S353; + float s_diff_r2_1 = _S344 + _S344 + (_S345 + _S345); + float _S346 = (*coeffs_3)[int(2)] + r2_3 * (*coeffs_3)[int(3)]; + float _S347 = (*coeffs_3)[int(1)] + r2_3 * _S346; + float _S348 = (*coeffs_3)[int(0)] + r2_3 * _S347; + float radial_1 = 1.0f + r2_3 * _S348; + float _S349 = 2.0f * (*coeffs_3)[int(4)]; + float _S350 = _S349 * u_3; + float _S351 = 2.0f * u_3; + float _S352 = 2.0f * (*coeffs_3)[int(5)]; + float _S353 = _S352 * u_3; + float _S354 = 2.0f * v_3; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S355 = { dpuv_1->primal_0 * make_float2 (radial_1) + make_float2 (_S350 * v_3 + (*coeffs_3)[int(5)] * (r2_3 + _S351 * u_3) + (*coeffs_3)[int(6)] * r2_3, _S353 * v_3 + (*coeffs_3)[int(4)] * (r2_3 + _S354 * v_3) + (*coeffs_3)[int(7)] * r2_3), dpuv_1->differential_0 * make_float2 (radial_1) + make_float2 (s_diff_r2_1 * _S348 + (s_diff_r2_1 * _S347 + (s_diff_r2_1 * _S346 + s_diff_r2_1 * (*coeffs_3)[int(3)] * r2_3) * r2_3) * r2_3) * dpuv_1->primal_0 + make_float2 (s_diff_u_1 * _S349 * v_3 + s_diff_v_1 * _S350 + (s_diff_r2_1 + (s_diff_u_1 * 2.0f * u_3 + s_diff_u_1 * _S351)) * (*coeffs_3)[int(5)] + s_diff_r2_1 * (*coeffs_3)[int(6)], s_diff_u_1 * _S352 * v_3 + s_diff_v_1 * _S353 + (s_diff_r2_1 + (s_diff_v_1 * 2.0f * v_3 + s_diff_v_1 * _S354)) * (*coeffs_3)[int(4)] + s_diff_r2_1 * (*coeffs_3)[int(7)]) }; + return _S355; } inline __device__ bool undistort_point_2(float2 uv_4, FixedArray * dist_coeffs_2, int maxiter_2, float2 * uv_undist_2) @@ -1905,67 +1929,67 @@ inline __device__ bool undistort_point_2(float2 uv_4, FixedArray * d { break; } - float2 _S354 = DistThinPrism_distort_0(q_2, dist_coeffs_2); - float2 r_3 = _S354 - uv_4; - float2 _S355 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S356; - (&_S356)->primal_0 = q_2; - (&_S356)->differential_0 = _S355; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S357 = s_fwd_DistThinPrism_distort_0(&_S356, dist_coeffs_2); - float2 _S358 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S359; - (&_S359)->primal_0 = q_2; - (&_S359)->differential_0 = _S358; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S360 = s_fwd_DistThinPrism_distort_0(&_S359, dist_coeffs_2); - Matrix _S361 = transpose_0(makeMatrix (_S357.differential_0, _S360.differential_0)); - float inv_det_1 = 1.0f / (_S361.rows[int(0)].x * _S361.rows[int(1)].y - _S361.rows[int(0)].y * _S361.rows[int(1)].x); - float _S362 = r_3.x; - float _S363 = r_3.y; - float2 q_3 = q_2 - make_float2 ((_S362 * _S361.rows[int(1)].y - _S363 * _S361.rows[int(0)].y) * inv_det_1, (- _S362 * _S361.rows[int(1)].x + _S363 * _S361.rows[int(0)].x) * inv_det_1); + float2 _S356 = DistThinPrism_distort_0(q_2, dist_coeffs_2); + float2 r_3 = _S356 - uv_4; + float2 _S357 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S358; + (&_S358)->primal_0 = q_2; + (&_S358)->differential_0 = _S357; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S359 = s_fwd_DistThinPrism_distort_0(&_S358, dist_coeffs_2); + float2 _S360 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S361; + (&_S361)->primal_0 = q_2; + (&_S361)->differential_0 = _S360; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S362 = s_fwd_DistThinPrism_distort_0(&_S361, dist_coeffs_2); + Matrix _S363 = transpose_0(makeMatrix (_S359.differential_0, _S362.differential_0)); + float inv_det_1 = 1.0f / (_S363.rows[int(0)].x * _S363.rows[int(1)].y - _S363.rows[int(0)].y * _S363.rows[int(1)].x); + float _S364 = r_3.x; + float _S365 = r_3.y; + float2 q_3 = q_2 - make_float2 ((_S364 * _S363.rows[int(1)].y - _S365 * _S363.rows[int(0)].y) * inv_det_1, (- _S364 * _S363.rows[int(1)].x + _S365 * _S363.rows[int(0)].x) * inv_det_1); i_6 = i_6 + int(1); q_2 = q_3; } *uv_undist_2 = q_2; - float2 _S364 = make_float2 (1.0f, 0.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S365; - (&_S365)->primal_0 = q_2; - (&_S365)->differential_0 = _S364; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S366 = s_fwd_DistThinPrism_distort_0(&_S365, dist_coeffs_2); - float2 _S367 = make_float2 (0.0f, 1.0f); - DiffPair_vectorx3Cfloatx2C2x3E_0 _S368; - (&_S368)->primal_0 = q_2; - (&_S368)->differential_0 = _S367; - DiffPair_vectorx3Cfloatx2C2x3E_0 _S369 = s_fwd_DistThinPrism_distort_0(&_S368, dist_coeffs_2); - Matrix _S370 = transpose_0(makeMatrix (_S366.differential_0, _S369.differential_0)); - float _S371 = (F32_min((determinant_0(_S370)), ((F32_min((_S370.rows[int(0)].x), (_S370.rows[int(1)].y)))))); - bool _S372; - if(_S371 > 0.25f) + float2 _S366 = make_float2 (1.0f, 0.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S367; + (&_S367)->primal_0 = q_2; + (&_S367)->differential_0 = _S366; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S368 = s_fwd_DistThinPrism_distort_0(&_S367, dist_coeffs_2); + float2 _S369 = make_float2 (0.0f, 1.0f); + DiffPair_vectorx3Cfloatx2C2x3E_0 _S370; + (&_S370)->primal_0 = q_2; + (&_S370)->differential_0 = _S369; + DiffPair_vectorx3Cfloatx2C2x3E_0 _S371 = s_fwd_DistThinPrism_distort_0(&_S370, dist_coeffs_2); + Matrix _S372 = transpose_0(makeMatrix (_S368.differential_0, _S371.differential_0)); + float _S373 = (F32_min((determinant_0(_S372)), ((F32_min((_S372.rows[int(0)].x), (_S372.rows[int(1)].y)))))); + bool _S374; + if(_S373 > 0.25f) { - _S372 = _S371 < 4.0f; + _S374 = _S373 < 4.0f; } else { - _S372 = false; + _S374 = false; } - if(_S372) + if(_S374) { - float2 _S373 = DistThinPrism_distort_0(q_2, dist_coeffs_2); - _S372 = (dot_1(q_2, _S373)) >= 0.0f; + float2 _S375 = DistThinPrism_distort_0(q_2, dist_coeffs_2); + _S374 = (dot_1(q_2, _S375)) >= 0.0f; } else { - _S372 = false; + _S374 = false; } - if(_S372) + if(_S374) { - float2 _S374 = DistThinPrism_distort_0(*uv_undist_2, dist_coeffs_2); - _S372 = (length_1(_S374 - uv_4)) < 0.00999999977648258f; + float2 _S376 = DistThinPrism_distort_0(*uv_undist_2, dist_coeffs_2); + _S374 = (length_1(_S376 - uv_4)) < 0.00999999977648258f; } else { - _S372 = false; + _S374 = false; } - return _S372; + return _S374; } inline __device__ float3 normalize_0(float3 x_20) @@ -1980,14 +2004,14 @@ inline __device__ float3 unproject_raydir_0(float2 uv_5, int camera_model_0, b if(camera_model_0 == int(1)) { float theta_0 = length_1(uv_5); - float3 _S375 = make_float3 ((uv_5 / make_float2 ((F32_max((theta_0), (1.00000001168609742e-07f)))) * make_float2 ((F32_sin((theta_0))))).x, (uv_5 / make_float2 ((F32_max((theta_0), (1.00000001168609742e-07f)))) * make_float2 ((F32_sin((theta_0))))).y, (F32_cos((theta_0)))); + float3 _S377 = make_float3 ((uv_5 / make_float2 ((F32_max((theta_0), (1.00000001168609742e-07f)))) * make_float2 ((F32_sin((theta_0))))).x, (uv_5 / 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 = _S375; + raydir_0 = _S377; } else { - bool _S376 = camera_model_0 == int(2); - if(_S376) + bool _S378 = camera_model_0 == int(2); + if(_S378) { float r_4 = length_1(uv_5); raydir_0 = make_float3 ((uv_5 * make_float2 ((F32_sqrt(((F32_max((0.0f), (1.0f - 0.25f * r_4 * r_4)))))))).x, (uv_5 * 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); @@ -1996,7 +2020,7 @@ inline __device__ float3 unproject_raydir_0(float2 uv_5, int camera_model_0, b { raydir_0 = make_float3 (uv_5.x, uv_5.y, 1.0f); } - is_unit_0 = _S376; + is_unit_0 = _S378; } if(is_ray_depth_0) { @@ -2017,65 +2041,65 @@ inline __device__ float3 unproject_raydir_0(float2 uv_5, int camera_model_0, b inline __device__ float3 generate_ray_d2n_none(float2 pix_pos_0, float4 intrins_0, FixedArray dist_coeffs_3, int camera_model_1, bool is_ray_depth_1) { - float3 _S377; + float3 _S379; for(;;) { float2 uv_6 = (pix_pos_0 - float2 {intrins_0.z, intrins_0.w}) / float2 {intrins_0.x, intrins_0.y}; - FixedArray _S378 = dist_coeffs_3; + FixedArray _S380 = dist_coeffs_3; float2 uv_u_0; - bool _S379 = undistort_point_0(uv_6, &_S378, int(12), &uv_u_0); - if(!_S379) + bool _S381 = undistort_point_0(uv_6, &_S380, int(12), &uv_u_0); + if(!_S381) { - int3 _S380 = make_int3 (int(0)); - float3 _S381 = make_float3 ((float)_S380.x, (float)_S380.y, (float)_S380.z); - _S377 = _S381; + int3 _S382 = make_int3 (int(0)); + float3 _S383 = make_float3 ((float)_S382.x, (float)_S382.y, (float)_S382.z); + _S379 = _S383; break; } - _S377 = unproject_raydir_0(uv_u_0, camera_model_1, is_ray_depth_1); + _S379 = unproject_raydir_0(uv_u_0, camera_model_1, is_ray_depth_1); break; } - return _S377; + return _S379; } inline __device__ float3 depth_to_point_none(float2 pix_pos_1, float4 intrins_1, FixedArray dist_coeffs_4, int camera_model_2, bool is_ray_depth_2, float depth_2) { - float3 _S382; + float3 _S384; for(;;) { float2 uv_7 = (pix_pos_1 - float2 {intrins_1.z, intrins_1.w}) / float2 {intrins_1.x, intrins_1.y}; - FixedArray _S383 = dist_coeffs_4; + FixedArray _S385 = dist_coeffs_4; float2 uv_u_1; - bool _S384 = undistort_point_0(uv_7, &_S383, int(12), &uv_u_1); - if(!_S384) + bool _S386 = undistort_point_0(uv_7, &_S385, int(12), &uv_u_1); + if(!_S386) { - _S382 = make_float3 (0.0f); + _S384 = make_float3 (0.0f); break; } - _S382 = make_float3 (depth_2) * unproject_raydir_0(uv_u_1, camera_model_2, is_ray_depth_2); + _S384 = make_float3 (depth_2) * unproject_raydir_0(uv_u_1, camera_model_2, is_ray_depth_2); break; } - return _S382; + return _S384; } struct s_bwd_prop_depth_to_point_Intermediates_0 { - float2 _S385; - bool _S386; + float2 _S387; + bool _S388; }; -inline __device__ float s_primal_ctx_sin_0(float _S387) +inline __device__ float s_primal_ctx_sin_0(float _S389) { - return (F32_sin((_S387))); + return (F32_sin((_S389))); } -inline __device__ float s_primal_ctx_cos_0(float _S388) +inline __device__ float s_primal_ctx_cos_0(float _S390) { - return (F32_cos((_S388))); + return (F32_cos((_S390))); } -inline __device__ float s_primal_ctx_sqrt_0(float _S389) +inline __device__ float s_primal_ctx_sqrt_0(float _S391) { - return (F32_sqrt((_S389))); + return (F32_sqrt((_S391))); } inline __device__ float3 s_primal_ctx_unproject_raydir_0(float2 dpuv_2, int camera_model_3, bool is_ray_depth_3) @@ -2084,24 +2108,24 @@ inline __device__ float3 s_primal_ctx_unproject_raydir_0(float2 dpuv_2, int ca bool is_unit_1; if(camera_model_3 == int(1)) { - float _S390 = length_1(dpuv_2); - float3 _S391 = make_float3 ((dpuv_2 / make_float2 ((F32_max((_S390), (1.00000001168609742e-07f)))) * make_float2 (s_primal_ctx_sin_0(_S390))).x, (dpuv_2 / make_float2 ((F32_max((_S390), (1.00000001168609742e-07f)))) * make_float2 (s_primal_ctx_sin_0(_S390))).y, s_primal_ctx_cos_0(_S390)); + float _S392 = length_1(dpuv_2); + float3 _S393 = make_float3 ((dpuv_2 / make_float2 ((F32_max((_S392), (1.00000001168609742e-07f)))) * make_float2 (s_primal_ctx_sin_0(_S392))).x, (dpuv_2 / make_float2 ((F32_max((_S392), (1.00000001168609742e-07f)))) * make_float2 (s_primal_ctx_sin_0(_S392))).y, s_primal_ctx_cos_0(_S392)); is_unit_1 = true; - raydir_1 = _S391; + raydir_1 = _S393; } else { - bool _S392 = camera_model_3 == int(2); - if(_S392) + bool _S394 = camera_model_3 == int(2); + if(_S394) { - float _S393 = length_1(dpuv_2); - raydir_1 = make_float3 ((dpuv_2 * make_float2 (s_primal_ctx_sqrt_0((F32_max((0.0f), (1.0f - 0.25f * _S393 * _S393)))))).x, (dpuv_2 * make_float2 (s_primal_ctx_sqrt_0((F32_max((0.0f), (1.0f - 0.25f * _S393 * _S393)))))).y, 1.0f - 0.5f * _S393 * _S393); + float _S395 = length_1(dpuv_2); + raydir_1 = make_float3 ((dpuv_2 * make_float2 (s_primal_ctx_sqrt_0((F32_max((0.0f), (1.0f - 0.25f * _S395 * _S395)))))).x, (dpuv_2 * make_float2 (s_primal_ctx_sqrt_0((F32_max((0.0f), (1.0f - 0.25f * _S395 * _S395)))))).y, 1.0f - 0.5f * _S395 * _S395); } else { raydir_1 = make_float3 (dpuv_2.x, dpuv_2.y, 1.0f); } - is_unit_1 = _S392; + is_unit_1 = _S394; } if(is_ray_depth_3) { @@ -2122,37 +2146,37 @@ inline __device__ float3 s_primal_ctx_unproject_raydir_0(float2 dpuv_2, int ca inline __device__ float depth_to_point_vjp_none(float2 pix_pos_2, float4 intrins_2, FixedArray dist_coeffs_5, int camera_model_4, bool is_ray_depth_4, float depth_3, float3 v_point_0) { - float2 _S394 = make_float2 (0.0f); - s_bwd_prop_depth_to_point_Intermediates_0 _S395; - (&_S395)->_S385 = _S394; - (&_S395)->_S386 = false; + float2 _S396 = make_float2 (0.0f); + s_bwd_prop_depth_to_point_Intermediates_0 _S397; + (&_S397)->_S387 = _S396; + (&_S397)->_S388 = false; float2 uv_8 = (pix_pos_2 - float2 {intrins_2.z, intrins_2.w}) / float2 {intrins_2.x, intrins_2.y}; - float2 _S396 = _S394; - FixedArray _S397 = dist_coeffs_5; - bool _S398 = undistort_point_0(uv_8, &_S397, int(12), &_S396); - (&_S395)->_S385 = _S396; - (&_S395)->_S386 = _S398; - s_bwd_prop_depth_to_point_Intermediates_0 _S399 = _S395; - float3 _S400 = make_float3 (0.0f); - bool _S401 = !!_S395._S386; - float3 _S402; - if(_S401) + float2 _S398 = _S396; + FixedArray _S399 = dist_coeffs_5; + bool _S400 = undistort_point_0(uv_8, &_S399, int(12), &_S398); + (&_S397)->_S387 = _S398; + (&_S397)->_S388 = _S400; + s_bwd_prop_depth_to_point_Intermediates_0 _S401 = _S397; + float3 _S402 = make_float3 (0.0f); + bool _S403 = !!_S397._S388; + float3 _S404; + if(_S403) { - _S402 = s_primal_ctx_unproject_raydir_0(_S399._S385, camera_model_4, is_ray_depth_4); + _S404 = s_primal_ctx_unproject_raydir_0(_S401._S387, camera_model_4, is_ray_depth_4); } else { - _S402 = _S400; + _S404 = _S402; } - if(_S401) + if(_S403) { - _S402 = _S402 * v_point_0; + _S404 = _S404 * v_point_0; } else { - _S402 = _S400; + _S404 = _S402; } - return _S402.x + _S402.y + _S402.z; + return _S404.x + _S404.y + _S404.z; } inline __device__ float3 depth_to_normal_none(float2 pix_center_0, float4 intrins_3, FixedArray dist_coeffs_6, int camera_model_5, bool is_ray_depth_5, float4 depths_0) @@ -2160,142 +2184,142 @@ inline __device__ float3 depth_to_normal_none(float2 pix_center_0, float4 int float3 normal_2; for(;;) { - bool _S403; + bool _S405; if((depths_0.x) == 0.0f) { - _S403 = true; + _S405 = true; } else { - _S403 = (depths_0.y) == 0.0f; + _S405 = (depths_0.y) == 0.0f; } - if(_S403) + if(_S405) { - _S403 = true; + _S405 = true; } else { - _S403 = (depths_0.z) == 0.0f; + _S405 = (depths_0.z) == 0.0f; } - if(_S403) + if(_S405) { - _S403 = true; + _S405 = true; } else { - _S403 = (depths_0.w) == 0.0f; + _S405 = (depths_0.w) == 0.0f; } - if(_S403) + if(_S405) { normal_2 = make_float3 (0.0f); break; } - float3 * _S404; - float3 * _S405; float3 * _S406; float3 * _S407; - int _S408; + float3 * _S408; + float3 * _S409; + int _S410; FixedArray points_2; for(;;) { - float2 _S409 = float2 {intrins_3.z, intrins_3.w}; - float2 _S410 = float2 {intrins_3.x, intrins_3.y}; - float2 uv_9 = (pix_center_0 + make_float2 (-1.0f, -0.0f) - _S409) / _S410; - FixedArray _S411 = dist_coeffs_6; + float2 _S411 = float2 {intrins_3.z, intrins_3.w}; + float2 _S412 = float2 {intrins_3.x, intrins_3.y}; + float2 uv_9 = (pix_center_0 + make_float2 (-1.0f, -0.0f) - _S411) / _S412; + FixedArray _S413 = dist_coeffs_6; float2 uv_u_2; - bool _S412 = undistort_point_0(uv_9, &_S411, int(12), &uv_u_2); - if(!_S412) + bool _S414 = undistort_point_0(uv_9, &_S413, int(12), &uv_u_2); + if(!_S414) { - float3 _S413 = make_float3 (0.0f); - _S408 = int(0); + float3 _S415 = make_float3 (0.0f); + _S410 = int(0); + _S409 = nullptr; + _S408 = nullptr; _S407 = nullptr; _S406 = nullptr; - _S405 = nullptr; - _S404 = nullptr; - normal_2 = _S413; + normal_2 = _S415; 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_10 = (pix_center_0 + make_float2 (1.0f, -0.0f) - _S409) / _S410; - FixedArray _S414 = dist_coeffs_6; + float2 uv_10 = (pix_center_0 + make_float2 (1.0f, -0.0f) - _S411) / _S412; + FixedArray _S416 = dist_coeffs_6; float2 uv_u_3; - bool _S415 = undistort_point_0(uv_10, &_S414, int(12), &uv_u_3); - if(!_S415) + bool _S417 = undistort_point_0(uv_10, &_S416, int(12), &uv_u_3); + if(!_S417) { - float3 _S416 = make_float3 (0.0f); - _S408 = int(0); - _S407 = nullptr; - normal_2 = _S416; + float3 _S418 = make_float3 (0.0f); + _S410 = int(0); + _S409 = nullptr; + normal_2 = _S418; break; } points_2[int(1)] = make_float3 (depths_0.y) * unproject_raydir_0(uv_u_3, camera_model_5, is_ray_depth_5); - _S408 = int(2); - _S407 = &points_2[int(1)]; + _S410 = int(2); + _S409 = &points_2[int(1)]; break; } - if(_S408 != int(2)) + if(_S410 != int(2)) { - _S406 = &points_2[int(0)]; - _S405 = nullptr; - _S404 = nullptr; + _S408 = &points_2[int(0)]; + _S407 = nullptr; + _S406 = nullptr; break; } - float2 uv_11 = (pix_center_0 + make_float2 (0.0f, -1.0f) - _S409) / _S410; - FixedArray _S417 = dist_coeffs_6; + float2 uv_11 = (pix_center_0 + make_float2 (0.0f, -1.0f) - _S411) / _S412; + FixedArray _S419 = dist_coeffs_6; float2 uv_u_4; - bool _S418 = undistort_point_0(uv_11, &_S417, int(12), &uv_u_4); - if(!_S418) + bool _S420 = undistort_point_0(uv_11, &_S419, int(12), &uv_u_4); + if(!_S420) { - float3 _S419 = make_float3 (0.0f); - _S408 = int(0); - _S406 = &points_2[int(0)]; - _S405 = nullptr; - _S404 = nullptr; - normal_2 = _S419; + float3 _S421 = make_float3 (0.0f); + _S410 = int(0); + _S408 = &points_2[int(0)]; + _S407 = nullptr; + _S406 = nullptr; + normal_2 = _S421; 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_12 = (pix_center_0 + make_float2 (0.0f, 1.0f) - _S409) / _S410; - FixedArray _S420 = dist_coeffs_6; + float2 uv_12 = (pix_center_0 + make_float2 (0.0f, 1.0f) - _S411) / _S412; + FixedArray _S422 = dist_coeffs_6; float2 uv_u_5; - bool _S421 = undistort_point_0(uv_12, &_S420, int(12), &uv_u_5); - if(!_S421) + bool _S423 = undistort_point_0(uv_12, &_S422, int(12), &uv_u_5); + if(!_S423) { - float3 _S422 = make_float3 (0.0f); - _S408 = int(0); - _S406 = nullptr; - normal_2 = _S422; + float3 _S424 = make_float3 (0.0f); + _S410 = int(0); + _S408 = nullptr; + normal_2 = _S424; break; } points_2[int(3)] = make_float3 (depths_0.w) * unproject_raydir_0(uv_u_5, camera_model_5, is_ray_depth_5); - _S408 = int(2); - _S406 = &points_2[int(3)]; + _S410 = int(2); + _S408 = &points_2[int(3)]; break; } - if(_S408 != int(2)) + if(_S410 != int(2)) { - float3 * _S423 = _S406; - _S406 = &points_2[int(0)]; - _S405 = _S423; - _S404 = &points_2[int(2)]; + float3 * _S425 = _S408; + _S408 = &points_2[int(0)]; + _S407 = _S425; + _S406 = &points_2[int(2)]; break; } - float3 * _S424 = _S406; - _S408 = int(1); - _S406 = &points_2[int(0)]; - _S405 = _S424; - _S404 = &points_2[int(2)]; + float3 * _S426 = _S408; + _S410 = int(1); + _S408 = &points_2[int(0)]; + _S407 = _S426; + _S406 = &points_2[int(2)]; break; } - if(_S408 != int(1)) + if(_S410 != int(1)) { break; } - float3 normal_3 = cross_0(*_S407 - *_S406, - (*_S405 - *_S404)); + float3 normal_3 = cross_0(*_S409 - *_S408, - (*_S407 - *_S406)); if((dot_0(normal_3, normal_3)) != 0.0f) { normal_2 = normal_3 / make_float3 (length_0(normal_3)); @@ -2311,39 +2335,39 @@ inline __device__ float3 depth_to_normal_none(float2 pix_center_0, float4 int struct s_bwd_prop_depth_to_normal_Intermediates_0 { - float2 _S425; - bool _S426; float2 _S427; bool _S428; float2 _S429; bool _S430; float2 _S431; bool _S432; + float2 _S433; + bool _S434; }; inline __device__ void depth_to_normal_vjp_none(float2 pix_center_1, float4 intrins_4, FixedArray dist_coeffs_7, int camera_model_6, bool is_ray_depth_6, float4 depths_1, float3 v_normal_1, float4 * v_depths_0) { - float2 _S433 = make_float2 (0.0f); - s_bwd_prop_depth_to_normal_Intermediates_0 _S434; - (&_S434)->_S425 = _S433; - (&_S434)->_S426 = false; - (&_S434)->_S427 = _S433; - (&_S434)->_S428 = false; - (&_S434)->_S429 = _S433; - (&_S434)->_S430 = false; - (&_S434)->_S431 = _S433; - (&_S434)->_S432 = false; - (&_S434)->_S425 = _S433; - (&_S434)->_S426 = false; - (&_S434)->_S427 = _S433; - (&_S434)->_S428 = false; - (&_S434)->_S429 = _S433; - (&_S434)->_S430 = false; - (&_S434)->_S431 = _S433; - (&_S434)->_S432 = false; - bool _S435 = (depths_1.x) == 0.0f; + float2 _S435 = make_float2 (0.0f); + s_bwd_prop_depth_to_normal_Intermediates_0 _S436; + (&_S436)->_S427 = _S435; + (&_S436)->_S428 = false; + (&_S436)->_S429 = _S435; + (&_S436)->_S430 = false; + (&_S436)->_S431 = _S435; + (&_S436)->_S432 = false; + (&_S436)->_S433 = _S435; + (&_S436)->_S434 = false; + (&_S436)->_S427 = _S435; + (&_S436)->_S428 = false; + (&_S436)->_S429 = _S435; + (&_S436)->_S430 = false; + (&_S436)->_S431 = _S435; + (&_S436)->_S432 = false; + (&_S436)->_S433 = _S435; + (&_S436)->_S434 = false; + bool _S437 = (depths_1.x) == 0.0f; bool _runFlag_3; - if(_S435) + if(_S437) { _runFlag_3 = true; } @@ -2367,69 +2391,69 @@ inline __device__ void depth_to_normal_vjp_none(float2 pix_center_1, float4 in { _runFlag_3 = (depths_1.w) == 0.0f; } - int _S436; + int _S438; if(!_runFlag_3) { - float2 _S437 = float2 {intrins_4.z, intrins_4.w}; - float2 _S438 = float2 {intrins_4.x, intrins_4.y}; - float2 uv_13 = (pix_center_1 + make_float2 (-1.0f, -0.0f) - _S437) / _S438; - float2 _S439 = _S433; - FixedArray _S440 = dist_coeffs_7; - bool _S441 = undistort_point_0(uv_13, &_S440, int(12), &_S439); - (&_S434)->_S425 = _S439; - (&_S434)->_S426 = _S441; - bool _S442 = !!_S441; - if(_S442) + float2 _S439 = float2 {intrins_4.z, intrins_4.w}; + float2 _S440 = float2 {intrins_4.x, intrins_4.y}; + float2 uv_13 = (pix_center_1 + make_float2 (-1.0f, -0.0f) - _S439) / _S440; + float2 _S441 = _S435; + FixedArray _S442 = dist_coeffs_7; + bool _S443 = undistort_point_0(uv_13, &_S442, int(12), &_S441); + (&_S436)->_S427 = _S441; + (&_S436)->_S428 = _S443; + bool _S444 = !!_S443; + if(_S444) { - float2 uv_14 = (pix_center_1 + make_float2 (1.0f, -0.0f) - _S437) / _S438; - float2 _S443 = _S433; - FixedArray _S444 = dist_coeffs_7; - bool _S445 = undistort_point_0(uv_14, &_S444, int(12), &_S443); - (&_S434)->_S427 = _S443; - (&_S434)->_S428 = _S445; - if(!!_S445) + float2 uv_14 = (pix_center_1 + make_float2 (1.0f, -0.0f) - _S439) / _S440; + float2 _S445 = _S435; + FixedArray _S446 = dist_coeffs_7; + bool _S447 = undistort_point_0(uv_14, &_S446, int(12), &_S445); + (&_S436)->_S429 = _S445; + (&_S436)->_S430 = _S447; + if(!!_S447) { - _S436 = int(2); + _S438 = int(2); } else { - _S436 = int(0); + _S438 = int(0); } - if(_S436 != int(2)) + if(_S438 != int(2)) { _runFlag_3 = false; } else { - _runFlag_3 = _S442; + _runFlag_3 = _S444; } if(_runFlag_3) { - float2 uv_15 = (pix_center_1 + make_float2 (0.0f, -1.0f) - _S437) / _S438; - float2 _S446 = _S433; - FixedArray _S447 = dist_coeffs_7; - bool _S448 = undistort_point_0(uv_15, &_S447, int(12), &_S446); - (&_S434)->_S429 = _S446; - (&_S434)->_S430 = _S448; - if(!_S448) + float2 uv_15 = (pix_center_1 + make_float2 (0.0f, -1.0f) - _S439) / _S440; + float2 _S448 = _S435; + FixedArray _S449 = dist_coeffs_7; + bool _S450 = undistort_point_0(uv_15, &_S449, int(12), &_S448); + (&_S436)->_S431 = _S448; + (&_S436)->_S432 = _S450; + if(!_S450) { _runFlag_3 = false; } if(_runFlag_3) { - float2 uv_16 = (pix_center_1 + make_float2 (0.0f, 1.0f) - _S437) / _S438; - float2 _S449 = _S433; - FixedArray _S450 = dist_coeffs_7; - bool _S451 = undistort_point_0(uv_16, &_S450, int(12), &_S449); - (&_S434)->_S431 = _S449; - (&_S434)->_S432 = _S451; + float2 uv_16 = (pix_center_1 + make_float2 (0.0f, 1.0f) - _S439) / _S440; + float2 _S451 = _S435; + FixedArray _S452 = dist_coeffs_7; + bool _S453 = undistort_point_0(uv_16, &_S452, int(12), &_S451); + (&_S436)->_S433 = _S451; + (&_S436)->_S434 = _S453; } } } } - s_bwd_prop_depth_to_normal_Intermediates_0 _S452 = _S434; - float3 _S453 = make_float3 (0.0f); - if(_S435) + s_bwd_prop_depth_to_normal_Intermediates_0 _S454 = _S436; + float3 _S455 = make_float3 (0.0f); + if(_S437) { _runFlag_3 = true; } @@ -2453,16 +2477,14 @@ inline __device__ void depth_to_normal_vjp_none(float2 pix_center_1, float4 in { _runFlag_3 = (depths_1.w) == 0.0f; } - bool _S454 = !_runFlag_3; + bool _S456 = !_runFlag_3; bool _runFlag_4; bool _runFlag_5; - bool _S455; - bool _runFlag_6; - bool _S456; bool _S457; + bool _runFlag_6; + bool _S458; + bool _S459; FixedArray points_3; - float3 _S458; - float3 _S459; float3 _S460; float3 _S461; float3 _S462; @@ -2470,49 +2492,51 @@ inline __device__ void depth_to_normal_vjp_none(float2 pix_center_1, float4 in float3 _S464; float3 _S465; float3 _S466; - if(_S454) + float3 _S467; + float3 _S468; + if(_S456) { - bool _S467 = !!_S452._S426; - if(_S467) + bool _S469 = !!_S454._S428; + if(_S469) { - float3 _S468 = s_primal_ctx_unproject_raydir_0(_S452._S425, camera_model_6, is_ray_depth_6); - float3 _S469 = make_float3 (depths_1.x) * _S468; - bool _S470 = !!_S452._S428; - if(_S470) + float3 _S470 = s_primal_ctx_unproject_raydir_0(_S454._S427, camera_model_6, is_ray_depth_6); + float3 _S471 = make_float3 (depths_1.x) * _S470; + bool _S472 = !!_S454._S430; + if(_S472) { - float3 _S471 = s_primal_ctx_unproject_raydir_0(_S452._S427, camera_model_6, is_ray_depth_6); - float3 _S472 = make_float3 (depths_1.y) * _S471; - _S436 = int(2); - points_3[int(0)] = _S469; - points_3[int(1)] = _S472; - points_3[int(2)] = _S453; - points_3[int(3)] = _S453; - _S458 = _S471; + float3 _S473 = s_primal_ctx_unproject_raydir_0(_S454._S429, camera_model_6, is_ray_depth_6); + float3 _S474 = make_float3 (depths_1.y) * _S473; + _S438 = int(2); + points_3[int(0)] = _S471; + points_3[int(1)] = _S474; + points_3[int(2)] = _S455; + points_3[int(3)] = _S455; + _S460 = _S473; } else { - _S436 = int(0); - points_3[int(0)] = _S469; - points_3[int(1)] = _S453; - points_3[int(2)] = _S453; - points_3[int(3)] = _S453; - _S458 = _S453; + _S438 = int(0); + points_3[int(0)] = _S471; + points_3[int(1)] = _S455; + points_3[int(2)] = _S455; + points_3[int(3)] = _S455; + _S460 = _S455; } - if(_S436 != int(2)) + if(_S438 != int(2)) { _runFlag_3 = false; } else { - _runFlag_3 = _S467; - _S436 = int(0); + _runFlag_3 = _S469; + _S438 = int(0); } if(_runFlag_3) { - if(!_S452._S430) + if(!_S454._S432) { _runFlag_4 = false; - _S436 = int(0); + _S438 = int(0); } else { @@ -2520,26 +2544,26 @@ inline __device__ void depth_to_normal_vjp_none(float2 pix_center_1, float4 in } if(_runFlag_4) { - float3 _S473 = s_primal_ctx_unproject_raydir_0(_S452._S429, camera_model_6, is_ray_depth_6); - points_3[int(2)] = make_float3 (depths_1.z) * _S473; - bool _S474 = !!_S452._S432; - int _S475; - if(_S474) + float3 _S475 = s_primal_ctx_unproject_raydir_0(_S454._S431, camera_model_6, is_ray_depth_6); + points_3[int(2)] = make_float3 (depths_1.z) * _S475; + bool _S476 = !!_S454._S434; + int _S477; + if(_S476) { - float3 _S476 = s_primal_ctx_unproject_raydir_0(_S452._S431, camera_model_6, is_ray_depth_6); - points_3[int(3)] = make_float3 (depths_1.w) * _S476; - _S475 = int(2); - _S459 = _S476; + float3 _S478 = s_primal_ctx_unproject_raydir_0(_S454._S433, camera_model_6, is_ray_depth_6); + points_3[int(3)] = make_float3 (depths_1.w) * _S478; + _S477 = int(2); + _S461 = _S478; } else { - _S475 = int(0); - _S459 = _S453; + _S477 = int(0); + _S461 = _S455; } - if(_S475 != int(2)) + if(_S477 != int(2)) { _runFlag_5 = false; - _S436 = _S475; + _S438 = _S477; } else { @@ -2547,437 +2571,437 @@ inline __device__ void depth_to_normal_vjp_none(float2 pix_center_1, float4 in } if(_runFlag_5) { - _S436 = int(1); + _S438 = int(1); } - _runFlag_5 = _S474; - _S460 = _S473; + _runFlag_5 = _S476; + _S462 = _S475; } else { _runFlag_5 = false; - _S459 = _S453; - _S460 = _S453; + _S461 = _S455; + _S462 = _S455; } } else { _runFlag_4 = false; _runFlag_5 = false; - _S459 = _S453; - _S460 = _S453; + _S461 = _S455; + _S462 = _S455; } - float3 _S477 = _S458; - _S458 = _S459; - _S459 = _S460; - _S455 = _S470; - _S460 = _S477; - _S461 = _S468; + float3 _S479 = _S460; + _S460 = _S461; + _S461 = _S462; + _S457 = _S472; + _S462 = _S479; + _S463 = _S470; } else { - _S436 = int(0); - points_3[int(0)] = _S453; - points_3[int(1)] = _S453; - points_3[int(2)] = _S453; - points_3[int(3)] = _S453; + _S438 = int(0); + points_3[int(0)] = _S455; + points_3[int(1)] = _S455; + points_3[int(2)] = _S455; + points_3[int(3)] = _S455; _runFlag_3 = false; _runFlag_4 = false; _runFlag_5 = false; - _S458 = _S453; - _S459 = _S453; - _S455 = false; - _S460 = _S453; - _S461 = _S453; + _S460 = _S455; + _S461 = _S455; + _S457 = false; + _S462 = _S455; + _S463 = _S455; } - if(_S436 != int(1)) + if(_S438 != int(1)) { _runFlag_6 = false; } else { - _runFlag_6 = _S454; + _runFlag_6 = _S456; } if(_runFlag_6) { float3 dx_1 = points_3[int(1)] - points_3[int(0)]; - float3 _S478 = - (points_3[int(3)] - points_3[int(2)]); - float3 _S479 = s_primal_ctx_cross_0(dx_1, _S478); - bool _S480 = (s_primal_ctx_dot_0(_S479, _S479)) != 0.0f; - if(_S480) + float3 _S480 = - (points_3[int(3)] - points_3[int(2)]); + float3 _S481 = s_primal_ctx_cross_0(dx_1, _S480); + bool _S482 = (s_primal_ctx_dot_0(_S481, _S481)) != 0.0f; + if(_S482) { - float _S481 = length_0(_S479); - float3 _S482 = make_float3 (_S481); - _S462 = make_float3 (_S481 * _S481); - _S463 = _S482; + float _S483 = length_0(_S481); + float3 _S484 = make_float3 (_S483); + _S464 = make_float3 (_S483 * _S483); + _S465 = _S484; } else { - _S462 = _S453; - _S463 = _S453; + _S464 = _S455; + _S465 = _S455; } - float3 _S483 = _S463; - _S456 = _S480; - _S463 = _S479; - _S464 = _S483; - _S465 = dx_1; - _S466 = _S478; + float3 _S485 = _S465; + _S458 = _S482; + _S465 = _S481; + _S466 = _S485; + _S467 = dx_1; + _S468 = _S480; } else { - _S456 = false; - _S462 = _S453; - _S463 = _S453; - _S464 = _S453; - _S465 = _S453; - _S466 = _S453; + _S458 = false; + _S464 = _S455; + _S465 = _S455; + _S466 = _S455; + _S467 = _S455; + _S468 = _S455; } - bool _S484 = _runFlag_3; - bool _S485 = _runFlag_4; - bool _S486 = _runFlag_5; - float3 _S487 = _S458; - float3 _S488 = _S459; - bool _S489 = _S455; - float3 _S490 = _S460; - float3 _S491 = _S461; + bool _S486 = _runFlag_3; + bool _S487 = _runFlag_4; + bool _S488 = _runFlag_5; + float3 _S489 = _S460; + float3 _S490 = _S461; + bool _S491 = _S457; + float3 _S492 = _S462; + float3 _S493 = _S463; _runFlag_3 = _runFlag_6; - _runFlag_4 = _S456; - _S458 = _S462; - _S459 = _S463; + _runFlag_4 = _S458; _S460 = _S464; _S461 = _S465; _S462 = _S466; - _runFlag_5 = _S467; - _S455 = _S484; - _runFlag_6 = _S485; - _S456 = _S486; - _S463 = _S487; - _S464 = _S488; - _S457 = _S489; - _S465 = _S490; - _S466 = _S491; + _S463 = _S467; + _S464 = _S468; + _runFlag_5 = _S469; + _S457 = _S486; + _runFlag_6 = _S487; + _S458 = _S488; + _S465 = _S489; + _S466 = _S490; + _S459 = _S491; + _S467 = _S492; + _S468 = _S493; } else { _runFlag_3 = false; _runFlag_4 = false; - _S458 = _S453; - _S459 = _S453; - _S460 = _S453; - _S461 = _S453; - _S462 = _S453; + _S460 = _S455; + _S461 = _S455; + _S462 = _S455; + _S463 = _S455; + _S464 = _S455; _runFlag_5 = false; - _S455 = false; - _runFlag_6 = false; - _S456 = false; - _S463 = _S453; - _S464 = _S453; _S457 = false; - _S465 = _S453; - _S466 = _S453; + _runFlag_6 = false; + _S458 = false; + _S465 = _S455; + _S466 = _S455; + _S459 = false; + _S467 = _S455; + _S468 = _S455; } - float4 _S492 = make_float4 (0.0f); - float4 _S493; - if(_S454) + float4 _S494 = make_float4 (0.0f); + float4 _S495; + if(_S456) { if(_runFlag_3) { if(_runFlag_4) { - float3 _S494 = v_normal_1 / _S458; - float3 _S495 = _S459 * - _S494; - float3 _S496 = _S460 * _S494; - float _S497 = _S495.x + _S495.y + _S495.z; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S498; - (&_S498)->primal_0 = _S459; - (&_S498)->differential_0 = _S453; - s_bwd_length_impl_0(&_S498, _S497); - _S458 = _S496 + _S498.differential_0; + float3 _S496 = v_normal_1 / _S460; + float3 _S497 = _S461 * - _S496; + float3 _S498 = _S462 * _S496; + float _S499 = _S497.x + _S497.y + _S497.z; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S500; + (&_S500)->primal_0 = _S461; + (&_S500)->differential_0 = _S455; + s_bwd_length_impl_0(&_S500, _S499); + _S460 = _S498 + _S500.differential_0; } else { - _S458 = v_normal_1; + _S460 = v_normal_1; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S499; - (&_S499)->primal_0 = _S459; - (&_S499)->differential_0 = _S453; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S500; - (&_S500)->primal_0 = _S459; - (&_S500)->differential_0 = _S453; - s_bwd_prop_dot_0(&_S499, &_S500, 0.0f); - float3 _S501 = _S500.differential_0 + _S499.differential_0 + _S458; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S501; + (&_S501)->primal_0 = _S461; + (&_S501)->differential_0 = _S455; DiffPair_vectorx3Cfloatx2C3x3E_0 _S502; (&_S502)->primal_0 = _S461; - (&_S502)->differential_0 = _S453; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S503; - (&_S503)->primal_0 = _S462; - (&_S503)->differential_0 = _S453; - s_bwd_prop_cross_0(&_S502, &_S503, _S501); - float3 s_diff_dy_T_1 = - _S503.differential_0; - float3 _S504 = - s_diff_dy_T_1; - float3 _S505 = - _S502.differential_0; - FixedArray _S506; - _S506[int(0)] = _S453; - _S506[int(1)] = _S453; - _S506[int(2)] = _S453; - _S506[int(3)] = _S453; - _S506[int(2)] = _S504; - _S506[int(3)] = s_diff_dy_T_1; - _S506[int(0)] = _S505; - _S506[int(1)] = _S502.differential_0; - points_3[int(0)] = _S506[int(0)]; - points_3[int(1)] = _S506[int(1)]; - points_3[int(2)] = _S506[int(2)]; - points_3[int(3)] = _S506[int(3)]; + (&_S502)->differential_0 = _S455; + s_bwd_prop_dot_0(&_S501, &_S502, 0.0f); + float3 _S503 = _S502.differential_0 + _S501.differential_0 + _S460; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S504; + (&_S504)->primal_0 = _S463; + (&_S504)->differential_0 = _S455; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S505; + (&_S505)->primal_0 = _S464; + (&_S505)->differential_0 = _S455; + s_bwd_prop_cross_0(&_S504, &_S505, _S503); + float3 s_diff_dy_T_1 = - _S505.differential_0; + float3 _S506 = - s_diff_dy_T_1; + float3 _S507 = - _S504.differential_0; + FixedArray _S508; + _S508[int(0)] = _S455; + _S508[int(1)] = _S455; + _S508[int(2)] = _S455; + _S508[int(3)] = _S455; + _S508[int(2)] = _S506; + _S508[int(3)] = s_diff_dy_T_1; + _S508[int(0)] = _S507; + _S508[int(1)] = _S504.differential_0; + points_3[int(0)] = _S508[int(0)]; + points_3[int(1)] = _S508[int(1)]; + points_3[int(2)] = _S508[int(2)]; + points_3[int(3)] = _S508[int(3)]; } else { - points_3[int(0)] = _S453; - points_3[int(1)] = _S453; - points_3[int(2)] = _S453; - points_3[int(3)] = _S453; + points_3[int(0)] = _S455; + points_3[int(1)] = _S455; + points_3[int(2)] = _S455; + points_3[int(3)] = _S455; } if(_runFlag_5) { - if(_S455) + if(_S457) { if(_runFlag_6) { - FixedArray _S507 = points_3; - FixedArray _S508 = points_3; FixedArray _S509 = points_3; FixedArray _S510 = points_3; - if(_S456) + FixedArray _S511 = points_3; + FixedArray _S512 = points_3; + if(_S458) { - float3 _S511 = _S463 * _S510[int(3)]; - float _S512 = _S511.x + _S511.y + _S511.z; - float4 _S513 = _S492; - *&((&_S513)->w) = _S512; - points_3[int(0)] = _S507[int(0)]; - points_3[int(1)] = _S508[int(1)]; - points_3[int(2)] = _S509[int(2)]; - points_3[int(3)] = _S453; - _S493 = _S513; + float3 _S513 = _S465 * _S512[int(3)]; + float _S514 = _S513.x + _S513.y + _S513.z; + float4 _S515 = _S494; + *&((&_S515)->w) = _S514; + points_3[int(0)] = _S509[int(0)]; + points_3[int(1)] = _S510[int(1)]; + points_3[int(2)] = _S511[int(2)]; + points_3[int(3)] = _S455; + _S495 = _S515; } else { - points_3[int(0)] = _S507[int(0)]; - points_3[int(1)] = _S508[int(1)]; - points_3[int(2)] = _S509[int(2)]; - points_3[int(3)] = _S510[int(3)]; - _S493 = _S492; + points_3[int(0)] = _S509[int(0)]; + points_3[int(1)] = _S510[int(1)]; + points_3[int(2)] = _S511[int(2)]; + points_3[int(3)] = _S512[int(3)]; + _S495 = _S494; } - float3 _S514 = _S464 * points_3[int(2)]; - float _S515 = _S514.x + _S514.y + _S514.z; - FixedArray _S516 = points_3; - FixedArray _S517 = points_3; - float4 _S518 = _S492; - *&((&_S518)->z) = _S515; - float4 _S519 = _S493 + _S518; + float3 _S516 = _S466 * points_3[int(2)]; + float _S517 = _S516.x + _S516.y + _S516.z; + FixedArray _S518 = points_3; + FixedArray _S519 = points_3; + float4 _S520 = _S494; + *&((&_S520)->z) = _S517; + float4 _S521 = _S495 + _S520; points_3[int(0)] = points_3[int(0)]; - points_3[int(1)] = _S516[int(1)]; - points_3[int(2)] = _S453; - points_3[int(3)] = _S517[int(3)]; - _S493 = _S519; + points_3[int(1)] = _S518[int(1)]; + points_3[int(2)] = _S455; + points_3[int(3)] = _S519[int(3)]; + _S495 = _S521; } else { - FixedArray _S520 = points_3; - FixedArray _S521 = points_3; FixedArray _S522 = points_3; + FixedArray _S523 = points_3; + FixedArray _S524 = points_3; points_3[int(0)] = points_3[int(0)]; - points_3[int(1)] = _S520[int(1)]; - points_3[int(2)] = _S521[int(2)]; - points_3[int(3)] = _S522[int(3)]; - _S493 = _S492; + points_3[int(1)] = _S522[int(1)]; + points_3[int(2)] = _S523[int(2)]; + points_3[int(3)] = _S524[int(3)]; + _S495 = _S494; } } else { - FixedArray _S523 = points_3; - FixedArray _S524 = points_3; FixedArray _S525 = points_3; - points_3[int(0)] = points_3[int(0)]; - points_3[int(1)] = _S523[int(1)]; - points_3[int(2)] = _S524[int(2)]; - points_3[int(3)] = _S525[int(3)]; - _S493 = _S492; - } - if(_S457) - { FixedArray _S526 = points_3; - float3 _S527 = _S465 * points_3[int(1)]; - float _S528 = _S527.x + _S527.y + _S527.z; - float4 _S529 = _S492; - *&((&_S529)->y) = _S528; - float4 _S530 = _S493 + _S529; - points_3[int(0)] = _S453; - points_3[int(1)] = _S453; - points_3[int(2)] = _S453; - points_3[int(3)] = _S453; - _S458 = _S526[int(0)]; - _S493 = _S530; + FixedArray _S527 = points_3; + points_3[int(0)] = points_3[int(0)]; + points_3[int(1)] = _S525[int(1)]; + points_3[int(2)] = _S526[int(2)]; + points_3[int(3)] = _S527[int(3)]; + _S495 = _S494; + } + if(_S459) + { + FixedArray _S528 = points_3; + float3 _S529 = _S467 * points_3[int(1)]; + float _S530 = _S529.x + _S529.y + _S529.z; + float4 _S531 = _S494; + *&((&_S531)->y) = _S530; + float4 _S532 = _S495 + _S531; + points_3[int(0)] = _S455; + points_3[int(1)] = _S455; + points_3[int(2)] = _S455; + points_3[int(3)] = _S455; + _S460 = _S528[int(0)]; + _S495 = _S532; } else { - FixedArray _S531 = points_3; - FixedArray _S532 = points_3; FixedArray _S533 = points_3; + FixedArray _S534 = points_3; + FixedArray _S535 = points_3; points_3[int(0)] = points_3[int(0)]; - points_3[int(1)] = _S531[int(1)]; - points_3[int(2)] = _S532[int(2)]; - points_3[int(3)] = _S533[int(3)]; - _S458 = _S453; + points_3[int(1)] = _S533[int(1)]; + points_3[int(2)] = _S534[int(2)]; + points_3[int(3)] = _S535[int(3)]; + _S460 = _S455; } - float3 _S534 = _S466 * (points_3[int(0)] + _S458); - float _S535 = _S534.x + _S534.y + _S534.z; - float4 _S536 = _S492; - *&((&_S536)->x) = _S535; - _S493 = _S493 + _S536; + float3 _S536 = _S468 * (points_3[int(0)] + _S460); + float _S537 = _S536.x + _S536.y + _S536.z; + float4 _S538 = _S494; + *&((&_S538)->x) = _S537; + _S495 = _S495 + _S538; } else { - _S493 = _S492; + _S495 = _S494; } } else { - _S493 = _S492; + _S495 = _S494; } - *v_depths_0 = _S493; + *v_depths_0 = _S495; return; } inline __device__ float ray_depth_to_linear_depth_factor_none(float2 pix_center_2, float4 intrins_5, FixedArray dist_coeffs_8, int camera_model_7) { - float _S537; + float _S539; for(;;) { float2 uv_17 = (pix_center_2 - float2 {intrins_5.z, intrins_5.w}) / float2 {intrins_5.x, intrins_5.y}; - FixedArray _S538 = dist_coeffs_8; + FixedArray _S540 = dist_coeffs_8; float2 uv_u_6; - bool _S539 = undistort_point_0(uv_17, &_S538, int(12), &uv_u_6); - if(!_S539) + bool _S541 = undistort_point_0(uv_17, &_S540, int(12), &uv_u_6); + if(!_S541) { - _S537 = 0.0f; + _S539 = 0.0f; break; } float3 raydir_2 = unproject_raydir_0(uv_u_6, camera_model_7, false); - _S537 = float((F32_sign((raydir_2.z)))) / length_0(raydir_2); + _S539 = float((F32_sign((raydir_2.z)))) / length_0(raydir_2); break; } - return _S537; + return _S539; } inline __device__ float depth_normal_loss_none(float2 pix_center_3, float4 intrins_6, FixedArray dist_coeffs_9, int camera_model_8, bool is_ray_depth_7, float4 depths_2, float3 gt_normal_0) { - float _S540; + float _S542; for(;;) { - float3 _S541; - float3 * _S542; - float3 * _S543; + float3 _S543; float3 * _S544; float3 * _S545; - int _S546; + float3 * _S546; + float3 * _S547; + int _S548; FixedArray points_4; for(;;) { - float2 _S547 = float2 {intrins_6.z, intrins_6.w}; - float2 _S548 = float2 {intrins_6.x, intrins_6.y}; - float2 uv_18 = (pix_center_3 + make_float2 (-1.0f, -0.0f) - _S547) / _S548; - FixedArray _S549 = dist_coeffs_9; + float2 _S549 = float2 {intrins_6.z, intrins_6.w}; + float2 _S550 = float2 {intrins_6.x, intrins_6.y}; + float2 uv_18 = (pix_center_3 + make_float2 (-1.0f, -0.0f) - _S549) / _S550; + FixedArray _S551 = dist_coeffs_9; float2 uv_u_7; - bool _S550 = undistort_point_0(uv_18, &_S549, int(12), &uv_u_7); - float3 _S551 = make_float3 (0.0f); - if(!_S550) + bool _S552 = undistort_point_0(uv_18, &_S551, int(12), &uv_u_7); + float3 _S553 = make_float3 (0.0f); + if(!_S552) { - _S546 = int(0); + _S548 = int(0); + _S547 = nullptr; + _S546 = nullptr; _S545 = nullptr; _S544 = nullptr; - _S543 = nullptr; - _S542 = nullptr; - _S541 = _S551; + _S543 = _S553; 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_19 = (pix_center_3 + make_float2 (1.0f, -0.0f) - _S547) / _S548; - FixedArray _S552 = dist_coeffs_9; + float2 uv_19 = (pix_center_3 + make_float2 (1.0f, -0.0f) - _S549) / _S550; + FixedArray _S554 = dist_coeffs_9; float2 uv_u_8; - bool _S553 = undistort_point_0(uv_19, &_S552, int(12), &uv_u_8); - if(!_S553) + bool _S555 = undistort_point_0(uv_19, &_S554, int(12), &uv_u_8); + if(!_S555) { - _S546 = int(0); + _S548 = int(0); + _S547 = nullptr; + _S546 = &points_4[int(0)]; _S545 = nullptr; - _S544 = &points_4[int(0)]; - _S543 = nullptr; - _S542 = nullptr; - _S541 = _S551; + _S544 = nullptr; + _S543 = _S553; 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_20 = (pix_center_3 + make_float2 (0.0f, -1.0f) - _S547) / _S548; - FixedArray _S554 = dist_coeffs_9; + float2 uv_20 = (pix_center_3 + make_float2 (0.0f, -1.0f) - _S549) / _S550; + FixedArray _S556 = dist_coeffs_9; float2 uv_u_9; - bool _S555 = undistort_point_0(uv_20, &_S554, int(12), &uv_u_9); - if(!_S555) + bool _S557 = undistort_point_0(uv_20, &_S556, int(12), &uv_u_9); + if(!_S557) { - _S546 = int(0); - _S545 = &points_4[int(1)]; - _S544 = &points_4[int(0)]; - _S543 = nullptr; - _S542 = nullptr; - _S541 = _S551; + _S548 = int(0); + _S547 = &points_4[int(1)]; + _S546 = &points_4[int(0)]; + _S545 = nullptr; + _S544 = nullptr; + _S543 = _S553; 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_21 = (pix_center_3 + make_float2 (0.0f, 1.0f) - _S547) / _S548; - FixedArray _S556 = dist_coeffs_9; + float2 uv_21 = (pix_center_3 + make_float2 (0.0f, 1.0f) - _S549) / _S550; + FixedArray _S558 = dist_coeffs_9; float2 uv_u_10; - bool _S557 = undistort_point_0(uv_21, &_S556, int(12), &uv_u_10); - if(!_S557) + bool _S559 = undistort_point_0(uv_21, &_S558, int(12), &uv_u_10); + if(!_S559) { - _S546 = int(0); - _S545 = &points_4[int(1)]; - _S544 = &points_4[int(0)]; - _S543 = nullptr; - _S542 = &points_4[int(2)]; - _S541 = _S551; + _S548 = int(0); + _S547 = &points_4[int(1)]; + _S546 = &points_4[int(0)]; + _S545 = nullptr; + _S544 = &points_4[int(2)]; + _S543 = _S553; 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_22 = (pix_center_3 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S547) / _S548; - FixedArray _S558 = dist_coeffs_9; + float2 uv_22 = (pix_center_3 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S549) / _S550; + FixedArray _S560 = dist_coeffs_9; float2 uv_u_11; - bool _S559 = undistort_point_0(uv_22, &_S558, int(12), &uv_u_11); - if(!_S559) + bool _S561 = undistort_point_0(uv_22, &_S560, int(12), &uv_u_11); + if(!_S561) { - _S546 = int(0); - _S545 = &points_4[int(1)]; - _S544 = &points_4[int(0)]; - _S543 = &points_4[int(3)]; - _S542 = &points_4[int(2)]; - _S541 = _S551; + _S548 = int(0); + _S547 = &points_4[int(1)]; + _S546 = &points_4[int(0)]; + _S545 = &points_4[int(3)]; + _S544 = &points_4[int(2)]; + _S543 = _S553; break; } float3 raydir_7 = unproject_raydir_0(uv_u_11, camera_model_8, is_ray_depth_7); - _S546 = int(1); - _S545 = &points_4[int(1)]; - _S544 = &points_4[int(0)]; - _S543 = &points_4[int(3)]; - _S542 = &points_4[int(2)]; - _S541 = raydir_7; + _S548 = int(1); + _S547 = &points_4[int(1)]; + _S546 = &points_4[int(0)]; + _S545 = &points_4[int(3)]; + _S544 = &points_4[int(2)]; + _S543 = raydir_7; break; } - if(_S546 != int(1)) + if(_S548 != int(1)) { - _S540 = 0.0f; + _S542 = 0.0f; break; } - float3 normal_4 = cross_0(*_S545 - *_S544, - (*_S543 - *_S542)); + float3 normal_4 = cross_0(*_S547 - *_S546, - (*_S545 - *_S544)); float3 normal_5; if((dot_0(normal_4, normal_4)) != 0.0f) { @@ -2987,25 +3011,23 @@ inline __device__ float depth_normal_loss_none(float2 pix_center_3, float4 int { normal_5 = normal_4; } - float3 _S560; + float3 _S562; if((dot_0(gt_normal_0, gt_normal_0)) != 0.0f) { - _S560 = normalize_0(gt_normal_0); + _S562 = normalize_0(gt_normal_0); } else { - _S560 = gt_normal_0; + _S562 = gt_normal_0; } - _S540 = (1.0f - dot_0(normal_5, _S560) + 0.00100000004749745f) / ((F32_max((dot_0(normal_5, - normalize_0(_S541))), (0.0f))) + 0.00100000004749745f); + _S542 = (1.0f - dot_0(normal_5, _S562) + 0.00100000004749745f) / ((F32_max((dot_0(normal_5, - normalize_0(_S543))), (0.0f))) + 0.00100000004749745f); break; } - return _S540; + return _S542; } struct s_bwd_prop_depth_normal_loss_Intermediates_0 { - float2 _S561; - bool _S562; float2 _S563; bool _S564; float2 _S565; @@ -3014,145 +3036,147 @@ struct s_bwd_prop_depth_normal_loss_Intermediates_0 bool _S568; float2 _S569; bool _S570; + float2 _S571; + bool _S572; }; inline __device__ void s_bwd_prop_normalize_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * dpx_14, float3 _s_dOut_9) { - float _S571 = length_0((*dpx_14).primal_0); - float3 _S572 = (*dpx_14).primal_0 * _s_dOut_9; - float3 _S573 = make_float3 (1.0f / _S571) * _s_dOut_9; - float _S574 = - ((_S572.x + _S572.y + _S572.z) / (_S571 * _S571)); - float3 _S575 = make_float3 (0.0f); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S576; - (&_S576)->primal_0 = (*dpx_14).primal_0; - (&_S576)->differential_0 = _S575; - s_bwd_length_impl_0(&_S576, _S574); - float3 _S577 = _S573 + _S576.differential_0; + float _S573 = length_0((*dpx_14).primal_0); + float3 _S574 = (*dpx_14).primal_0 * _s_dOut_9; + float3 _S575 = make_float3 (1.0f / _S573) * _s_dOut_9; + float _S576 = - ((_S574.x + _S574.y + _S574.z) / (_S573 * _S573)); + float3 _S577 = make_float3 (0.0f); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S578; + (&_S578)->primal_0 = (*dpx_14).primal_0; + (&_S578)->differential_0 = _S577; + s_bwd_length_impl_0(&_S578, _S576); + float3 _S579 = _S575 + _S578.differential_0; dpx_14->primal_0 = (*dpx_14).primal_0; - dpx_14->differential_0 = _S577; + dpx_14->differential_0 = _S579; return; } -inline __device__ void s_bwd_normalize_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S578, float3 _S579) +inline __device__ void s_bwd_normalize_impl_0(DiffPair_vectorx3Cfloatx2C3x3E_0 * _S580, float3 _S581) { - s_bwd_prop_normalize_impl_0(_S578, _S579); + s_bwd_prop_normalize_impl_0(_S580, _S581); return; } inline __device__ void depth_normal_loss_vjp_none(float2 pix_center_4, float4 intrins_7, FixedArray dist_coeffs_10, 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 _S580 = make_float2 (0.0f); - s_bwd_prop_depth_normal_loss_Intermediates_0 _S581; - (&_S581)->_S561 = _S580; - (&_S581)->_S562 = false; - (&_S581)->_S563 = _S580; - (&_S581)->_S564 = false; - (&_S581)->_S565 = _S580; - (&_S581)->_S566 = false; - (&_S581)->_S567 = _S580; - (&_S581)->_S568 = false; - (&_S581)->_S569 = _S580; - (&_S581)->_S570 = false; - (&_S581)->_S563 = _S580; - (&_S581)->_S564 = false; - (&_S581)->_S565 = _S580; - (&_S581)->_S566 = false; - (&_S581)->_S567 = _S580; - (&_S581)->_S568 = false; - (&_S581)->_S569 = _S580; - (&_S581)->_S570 = false; - float2 _S582 = float2 {intrins_7.z, intrins_7.w}; - float2 _S583 = float2 {intrins_7.x, intrins_7.y}; - float2 uv_23 = (pix_center_4 + make_float2 (-1.0f, -0.0f) - _S582) / _S583; - float2 _S584 = _S580; - FixedArray _S585 = dist_coeffs_10; - bool _S586 = undistort_point_0(uv_23, &_S585, int(12), &_S584); - (&_S581)->_S561 = _S584; - (&_S581)->_S562 = _S586; - bool _S587 = !!_S586; + float2 _S582 = make_float2 (0.0f); + s_bwd_prop_depth_normal_loss_Intermediates_0 _S583; + (&_S583)->_S563 = _S582; + (&_S583)->_S564 = false; + (&_S583)->_S565 = _S582; + (&_S583)->_S566 = false; + (&_S583)->_S567 = _S582; + (&_S583)->_S568 = false; + (&_S583)->_S569 = _S582; + (&_S583)->_S570 = false; + (&_S583)->_S571 = _S582; + (&_S583)->_S572 = false; + (&_S583)->_S565 = _S582; + (&_S583)->_S566 = false; + (&_S583)->_S567 = _S582; + (&_S583)->_S568 = false; + (&_S583)->_S569 = _S582; + (&_S583)->_S570 = false; + (&_S583)->_S571 = _S582; + (&_S583)->_S572 = false; + float2 _S584 = float2 {intrins_7.z, intrins_7.w}; + float2 _S585 = float2 {intrins_7.x, intrins_7.y}; + float2 uv_23 = (pix_center_4 + make_float2 (-1.0f, -0.0f) - _S584) / _S585; + float2 _S586 = _S582; + FixedArray _S587 = dist_coeffs_10; + bool _S588 = undistort_point_0(uv_23, &_S587, int(12), &_S586); + (&_S583)->_S563 = _S586; + (&_S583)->_S564 = _S588; + bool _S589 = !!_S588; bool _runFlag_7; - if(_S587) + if(_S589) { - float2 uv_24 = (pix_center_4 + make_float2 (1.0f, -0.0f) - _S582) / _S583; - float2 _S588 = _S580; - FixedArray _S589 = dist_coeffs_10; - bool _S590 = undistort_point_0(uv_24, &_S589, int(12), &_S588); - (&_S581)->_S563 = _S588; - (&_S581)->_S564 = _S590; - if(!_S590) + float2 uv_24 = (pix_center_4 + make_float2 (1.0f, -0.0f) - _S584) / _S585; + float2 _S590 = _S582; + FixedArray _S591 = dist_coeffs_10; + bool _S592 = undistort_point_0(uv_24, &_S591, int(12), &_S590); + (&_S583)->_S565 = _S590; + (&_S583)->_S566 = _S592; + if(!_S592) { _runFlag_7 = false; } else { - _runFlag_7 = _S587; + _runFlag_7 = _S589; } if(_runFlag_7) { - float2 uv_25 = (pix_center_4 + make_float2 (0.0f, -1.0f) - _S582) / _S583; - float2 _S591 = _S580; - FixedArray _S592 = dist_coeffs_10; - bool _S593 = undistort_point_0(uv_25, &_S592, int(12), &_S591); - (&_S581)->_S565 = _S591; - (&_S581)->_S566 = _S593; - if(!_S593) + float2 uv_25 = (pix_center_4 + make_float2 (0.0f, -1.0f) - _S584) / _S585; + float2 _S593 = _S582; + FixedArray _S594 = dist_coeffs_10; + bool _S595 = undistort_point_0(uv_25, &_S594, int(12), &_S593); + (&_S583)->_S567 = _S593; + (&_S583)->_S568 = _S595; + if(!_S595) { _runFlag_7 = false; } if(_runFlag_7) { - float2 uv_26 = (pix_center_4 + make_float2 (0.0f, 1.0f) - _S582) / _S583; - float2 _S594 = _S580; - FixedArray _S595 = dist_coeffs_10; - bool _S596 = undistort_point_0(uv_26, &_S595, int(12), &_S594); - (&_S581)->_S567 = _S594; - (&_S581)->_S568 = _S596; - if(!_S596) + float2 uv_26 = (pix_center_4 + make_float2 (0.0f, 1.0f) - _S584) / _S585; + float2 _S596 = _S582; + FixedArray _S597 = dist_coeffs_10; + bool _S598 = undistort_point_0(uv_26, &_S597, int(12), &_S596); + (&_S583)->_S569 = _S596; + (&_S583)->_S570 = _S598; + if(!_S598) { _runFlag_7 = false; } if(_runFlag_7) { - float2 uv_27 = (pix_center_4 - _S582) / _S583; - float2 _S597 = _S580; - FixedArray _S598 = dist_coeffs_10; - bool _S599 = undistort_point_0(uv_27, &_S598, int(12), &_S597); - (&_S581)->_S569 = _S597; - (&_S581)->_S570 = _S599; + float2 uv_27 = (pix_center_4 - _S584) / _S585; + float2 _S599 = _S582; + FixedArray _S600 = dist_coeffs_10; + bool _S601 = undistort_point_0(uv_27, &_S600, int(12), &_S599); + (&_S583)->_S571 = _S599; + (&_S583)->_S572 = _S601; } } } } - s_bwd_prop_depth_normal_loss_Intermediates_0 _S600 = _S581; - float3 _S601 = make_float3 (0.0f); - bool _S602 = !!_S581._S562; + s_bwd_prop_depth_normal_loss_Intermediates_0 _S602 = _S583; + float3 _S603 = make_float3 (0.0f); + bool _S604 = !!_S583._S564; bool _runFlag_8; bool _runFlag_9; bool _runFlag_10; - int _S603; + int _S605; float3 raydir_8; - float3 _S604; - float3 _S605; float3 _S606; float3 _S607; + float3 _S608; + float3 _S609; FixedArray points_5; - if(_S602) + if(_S604) { - float3 _S608 = s_primal_ctx_unproject_raydir_0(_S600._S561, camera_model_9, is_ray_depth_8); - float3 _S609 = make_float3 (depths_3.x) * _S608; - if(!_S600._S564) + float3 _S610 = s_primal_ctx_unproject_raydir_0(_S602._S563, camera_model_9, is_ray_depth_8); + float3 _S611 = make_float3 (depths_3.x) * _S610; + if(!_S602._S566) { _runFlag_7 = false; } else { - _runFlag_7 = _S602; + _runFlag_7 = _S604; } if(_runFlag_7) { - float3 _S610 = s_primal_ctx_unproject_raydir_0(_S600._S563, camera_model_9, is_ray_depth_8); - float3 _S611 = make_float3 (depths_3.y) * _S610; - if(!_S600._S566) + float3 _S612 = s_primal_ctx_unproject_raydir_0(_S602._S565, camera_model_9, is_ray_depth_8); + float3 _S613 = make_float3 (depths_3.y) * _S612; + if(!_S602._S568) { _runFlag_8 = false; } @@ -3162,9 +3186,9 @@ inline __device__ void depth_normal_loss_vjp_none(float2 pix_center_4, float4 } if(_runFlag_8) { - float3 _S612 = s_primal_ctx_unproject_raydir_0(_S600._S565, camera_model_9, is_ray_depth_8); - float3 _S613 = make_float3 (depths_3.z) * _S612; - if(!_S600._S568) + float3 _S614 = s_primal_ctx_unproject_raydir_0(_S602._S567, camera_model_9, is_ray_depth_8); + float3 _S615 = make_float3 (depths_3.z) * _S614; + if(!_S602._S570) { _runFlag_9 = false; } @@ -3174,9 +3198,9 @@ inline __device__ void depth_normal_loss_vjp_none(float2 pix_center_4, float4 } if(_runFlag_9) { - float3 _S614 = s_primal_ctx_unproject_raydir_0(_S600._S567, camera_model_9, is_ray_depth_8); - float3 _S615 = make_float3 (depths_3.w) * _S614; - if(!_S600._S570) + float3 _S616 = s_primal_ctx_unproject_raydir_0(_S602._S569, camera_model_9, is_ray_depth_8); + float3 _S617 = make_float3 (depths_3.w) * _S616; + if(!_S602._S572) { _runFlag_10 = false; } @@ -3186,256 +3210,256 @@ inline __device__ void depth_normal_loss_vjp_none(float2 pix_center_4, float4 } if(_runFlag_10) { - float3 _S616 = s_primal_ctx_unproject_raydir_0(_S600._S569, camera_model_9, is_ray_depth_8); - _S603 = int(1); - raydir_8 = _S616; + float3 _S618 = s_primal_ctx_unproject_raydir_0(_S602._S571, camera_model_9, is_ray_depth_8); + _S605 = int(1); + raydir_8 = _S618; } else { - _S603 = int(0); - raydir_8 = _S614; + _S605 = int(0); + raydir_8 = _S616; } - points_5[int(0)] = _S609; - points_5[int(1)] = _S611; - points_5[int(2)] = _S613; - points_5[int(3)] = _S615; - points_5[int(4)] = _S601; - _S604 = _S614; + points_5[int(0)] = _S611; + points_5[int(1)] = _S613; + points_5[int(2)] = _S615; + points_5[int(3)] = _S617; + points_5[int(4)] = _S603; + _S606 = _S616; } else { - _S603 = int(0); - raydir_8 = _S612; - points_5[int(0)] = _S609; - points_5[int(1)] = _S611; - points_5[int(2)] = _S613; - points_5[int(3)] = _S601; - points_5[int(4)] = _S601; - _S604 = _S601; + _S605 = int(0); + raydir_8 = _S614; + points_5[int(0)] = _S611; + points_5[int(1)] = _S613; + points_5[int(2)] = _S615; + points_5[int(3)] = _S603; + points_5[int(4)] = _S603; + _S606 = _S603; } - _S605 = _S612; + _S607 = _S614; } else { - _S603 = int(0); - raydir_8 = _S610; - points_5[int(0)] = _S609; - points_5[int(1)] = _S611; - points_5[int(2)] = _S601; - points_5[int(3)] = _S601; - points_5[int(4)] = _S601; + _S605 = int(0); + raydir_8 = _S612; + points_5[int(0)] = _S611; + points_5[int(1)] = _S613; + points_5[int(2)] = _S603; + points_5[int(3)] = _S603; + points_5[int(4)] = _S603; _runFlag_9 = false; - _S604 = _S601; - _S605 = _S601; + _S606 = _S603; + _S607 = _S603; } - _S606 = _S610; + _S608 = _S612; } else { - _S603 = int(0); - raydir_8 = _S608; - points_5[int(0)] = _S609; - points_5[int(1)] = _S601; - points_5[int(2)] = _S601; - points_5[int(3)] = _S601; - points_5[int(4)] = _S601; + _S605 = int(0); + raydir_8 = _S610; + points_5[int(0)] = _S611; + points_5[int(1)] = _S603; + points_5[int(2)] = _S603; + points_5[int(3)] = _S603; + points_5[int(4)] = _S603; _runFlag_8 = false; _runFlag_9 = false; - _S604 = _S601; - _S605 = _S601; - _S606 = _S601; + _S606 = _S603; + _S607 = _S603; + _S608 = _S603; } - _S607 = _S608; + _S609 = _S610; } else { - _S603 = int(0); - points_5[int(0)] = _S601; - points_5[int(1)] = _S601; - points_5[int(2)] = _S601; - points_5[int(3)] = _S601; - points_5[int(4)] = _S601; + _S605 = int(0); + points_5[int(0)] = _S603; + points_5[int(1)] = _S603; + points_5[int(2)] = _S603; + points_5[int(3)] = _S603; + points_5[int(4)] = _S603; _runFlag_7 = false; _runFlag_8 = false; _runFlag_9 = false; - _S604 = _S601; - _S605 = _S601; - _S606 = _S601; - _S607 = _S601; + _S606 = _S603; + _S607 = _S603; + _S608 = _S603; + _S609 = _S603; } - bool _S617 = !(_S603 != int(1)); - bool _S618; + bool _S619 = !(_S605 != int(1)); + bool _S620; float3 normal_6; - float3 _S619; - float3 _S620; float3 _S621; float3 _S622; - float _S623; - float _S624; + float3 _S623; + float3 _S624; float _S625; float _S626; - if(_S617) + float _S627; + float _S628; + if(_S619) { float3 dx_2 = points_5[int(1)] - points_5[int(0)]; - float3 _S627 = - (points_5[int(3)] - points_5[int(2)]); - float3 _S628 = s_primal_ctx_cross_0(dx_2, _S627); - bool _S629 = (s_primal_ctx_dot_0(_S628, _S628)) != 0.0f; - if(_S629) + float3 _S629 = - (points_5[int(3)] - points_5[int(2)]); + float3 _S630 = s_primal_ctx_cross_0(dx_2, _S629); + bool _S631 = (s_primal_ctx_dot_0(_S630, _S630)) != 0.0f; + if(_S631) { - normal_6 = normalize_0(_S628); + normal_6 = normalize_0(_S630); } else { - normal_6 = _S628; + normal_6 = _S630; } - bool _S630 = (s_primal_ctx_dot_0(gt_normal_1, gt_normal_1)) != 0.0f; - if(_S630) + bool _S632 = (s_primal_ctx_dot_0(gt_normal_1, gt_normal_1)) != 0.0f; + if(_S632) { - _S619 = normalize_0(gt_normal_1); + _S621 = normalize_0(gt_normal_1); } else { - _S619 = gt_normal_1; + _S621 = gt_normal_1; } - float3 _S631 = - normalize_0(raydir_8); - float _S632 = s_primal_ctx_dot_0(normal_6, _S631); - float _S633 = 1.0f - s_primal_ctx_dot_0(normal_6, _S619) + 0.00100000004749745f; - float _S634 = (F32_max((_S632), (0.0f))) + 0.00100000004749745f; - _S623 = _S634 * _S634; - _S624 = _S633; - _S625 = _S634; - _S626 = _S632; + float3 _S633 = - normalize_0(raydir_8); + float _S634 = s_primal_ctx_dot_0(normal_6, _S633); + float _S635 = 1.0f - s_primal_ctx_dot_0(normal_6, _S621) + 0.00100000004749745f; + float _S636 = (F32_max((_S634), (0.0f))) + 0.00100000004749745f; + _S625 = _S636 * _S636; + _S626 = _S635; + _S627 = _S636; + _S628 = _S634; raydir_8 = normal_6; - normal_6 = _S631; - _runFlag_10 = _S630; - _S618 = _S629; - _S620 = _S628; - _S621 = dx_2; - _S622 = _S627; + normal_6 = _S633; + _runFlag_10 = _S632; + _S620 = _S631; + _S622 = _S630; + _S623 = dx_2; + _S624 = _S629; } else { - _S623 = 0.0f; - _S624 = 0.0f; _S625 = 0.0f; _S626 = 0.0f; - raydir_8 = _S601; - normal_6 = _S601; - _S619 = _S601; + _S627 = 0.0f; + _S628 = 0.0f; + raydir_8 = _S603; + normal_6 = _S603; + _S621 = _S603; _runFlag_10 = false; - _S618 = false; - _S620 = _S601; - _S621 = _S601; - _S622 = _S601; + _S620 = false; + _S622 = _S603; + _S623 = _S603; + _S624 = _S603; } - float4 _S635 = make_float4 (0.0f); - if(_S617) + float4 _S637 = make_float4 (0.0f); + if(_S619) { - float _S636 = v_loss_0 / _S623; - float _S637 = _S624 * - _S636; - float s_diff_num_T_0 = _S625 * _S636; - DiffPair_float_0 _S638; - (&_S638)->primal_0 = _S626; - (&_S638)->differential_0 = 0.0f; - DiffPair_float_0 _S639; - (&_S639)->primal_0 = 0.0f; - (&_S639)->differential_0 = 0.0f; - _d_max_0(&_S638, &_S639, _S637); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S640; - (&_S640)->primal_0 = raydir_8; - (&_S640)->differential_0 = _S601; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S641; - (&_S641)->primal_0 = normal_6; - (&_S641)->differential_0 = _S601; - s_bwd_prop_dot_0(&_S640, &_S641, _S638.differential_0); - float _S642 = - s_diff_num_T_0; + float _S638 = v_loss_0 / _S625; + float _S639 = _S626 * - _S638; + float s_diff_num_T_0 = _S627 * _S638; + DiffPair_float_0 _S640; + (&_S640)->primal_0 = _S628; + (&_S640)->differential_0 = 0.0f; + DiffPair_float_0 _S641; + (&_S641)->primal_0 = 0.0f; + (&_S641)->differential_0 = 0.0f; + _d_max_0(&_S640, &_S641, _S639); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S642; + (&_S642)->primal_0 = raydir_8; + (&_S642)->differential_0 = _S603; DiffPair_vectorx3Cfloatx2C3x3E_0 _S643; - (&_S643)->primal_0 = raydir_8; - (&_S643)->differential_0 = _S601; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S644; - (&_S644)->primal_0 = _S619; - (&_S644)->differential_0 = _S601; - s_bwd_prop_dot_0(&_S643, &_S644, _S642); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S645 = _S644; - float3 _S646 = _S640.differential_0 + _S643.differential_0; + (&_S643)->primal_0 = normal_6; + (&_S643)->differential_0 = _S603; + s_bwd_prop_dot_0(&_S642, &_S643, _S640.differential_0); + float _S644 = - s_diff_num_T_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S645; + (&_S645)->primal_0 = raydir_8; + (&_S645)->differential_0 = _S603; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S646; + (&_S646)->primal_0 = _S621; + (&_S646)->differential_0 = _S603; + s_bwd_prop_dot_0(&_S645, &_S646, _S644); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S647 = _S646; + float3 _S648 = _S642.differential_0 + _S645.differential_0; if(_runFlag_10) { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S647; - (&_S647)->primal_0 = gt_normal_1; - (&_S647)->differential_0 = _S601; - s_bwd_normalize_impl_0(&_S647, _S645.differential_0); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S649; + (&_S649)->primal_0 = gt_normal_1; + (&_S649)->differential_0 = _S603; + s_bwd_normalize_impl_0(&_S649, _S647.differential_0); + raydir_8 = _S649.differential_0; + } + else + { raydir_8 = _S647.differential_0; } - else + DiffPair_vectorx3Cfloatx2C3x3E_0 _S650; + (&_S650)->primal_0 = gt_normal_1; + (&_S650)->differential_0 = _S603; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S651; + (&_S651)->primal_0 = gt_normal_1; + (&_S651)->differential_0 = _S603; + s_bwd_prop_dot_0(&_S650, &_S651, 0.0f); + float3 _S652 = _S651.differential_0 + _S650.differential_0 + raydir_8; + if(_S620) { - raydir_8 = _S645.differential_0; - } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S648; - (&_S648)->primal_0 = gt_normal_1; - (&_S648)->differential_0 = _S601; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S649; - (&_S649)->primal_0 = gt_normal_1; - (&_S649)->differential_0 = _S601; - s_bwd_prop_dot_0(&_S648, &_S649, 0.0f); - float3 _S650 = _S649.differential_0 + _S648.differential_0 + raydir_8; - if(_S618) - { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S651; - (&_S651)->primal_0 = _S620; - (&_S651)->differential_0 = _S601; - s_bwd_normalize_impl_0(&_S651, _S646); - raydir_8 = _S651.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S653; + (&_S653)->primal_0 = _S622; + (&_S653)->differential_0 = _S603; + s_bwd_normalize_impl_0(&_S653, _S648); + raydir_8 = _S653.differential_0; } else { - raydir_8 = _S646; + raydir_8 = _S648; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S652; - (&_S652)->primal_0 = _S620; - (&_S652)->differential_0 = _S601; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S653; - (&_S653)->primal_0 = _S620; - (&_S653)->differential_0 = _S601; - s_bwd_prop_dot_0(&_S652, &_S653, 0.0f); - float3 _S654 = _S653.differential_0 + _S652.differential_0 + raydir_8; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S654; + (&_S654)->primal_0 = _S622; + (&_S654)->differential_0 = _S603; DiffPair_vectorx3Cfloatx2C3x3E_0 _S655; - (&_S655)->primal_0 = _S621; - (&_S655)->differential_0 = _S601; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S656; - (&_S656)->primal_0 = _S622; - (&_S656)->differential_0 = _S601; - s_bwd_prop_cross_0(&_S655, &_S656, _S654); - float3 s_diff_dy_T_2 = - _S656.differential_0; - float3 _S657 = - s_diff_dy_T_2; - float3 _S658 = - _S655.differential_0; - FixedArray _S659; - _S659[int(0)] = _S601; - _S659[int(1)] = _S601; - _S659[int(2)] = _S601; - _S659[int(3)] = _S601; - _S659[int(4)] = _S601; - _S659[int(2)] = _S657; - _S659[int(3)] = s_diff_dy_T_2; - _S659[int(0)] = _S658; - _S659[int(1)] = _S655.differential_0; - points_5[int(0)] = _S659[int(0)]; - points_5[int(1)] = _S659[int(1)]; - points_5[int(2)] = _S659[int(2)]; - points_5[int(3)] = _S659[int(3)]; - points_5[int(4)] = _S659[int(4)]; - raydir_8 = _S650; + (&_S655)->primal_0 = _S622; + (&_S655)->differential_0 = _S603; + s_bwd_prop_dot_0(&_S654, &_S655, 0.0f); + float3 _S656 = _S655.differential_0 + _S654.differential_0 + raydir_8; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S657; + (&_S657)->primal_0 = _S623; + (&_S657)->differential_0 = _S603; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S658; + (&_S658)->primal_0 = _S624; + (&_S658)->differential_0 = _S603; + s_bwd_prop_cross_0(&_S657, &_S658, _S656); + float3 s_diff_dy_T_2 = - _S658.differential_0; + float3 _S659 = - s_diff_dy_T_2; + float3 _S660 = - _S657.differential_0; + FixedArray _S661; + _S661[int(0)] = _S603; + _S661[int(1)] = _S603; + _S661[int(2)] = _S603; + _S661[int(3)] = _S603; + _S661[int(4)] = _S603; + _S661[int(2)] = _S659; + _S661[int(3)] = s_diff_dy_T_2; + _S661[int(0)] = _S660; + _S661[int(1)] = _S657.differential_0; + points_5[int(0)] = _S661[int(0)]; + points_5[int(1)] = _S661[int(1)]; + points_5[int(2)] = _S661[int(2)]; + points_5[int(3)] = _S661[int(3)]; + points_5[int(4)] = _S661[int(4)]; + raydir_8 = _S652; } else { - points_5[int(0)] = _S601; - points_5[int(1)] = _S601; - points_5[int(2)] = _S601; - points_5[int(3)] = _S601; - points_5[int(4)] = _S601; - raydir_8 = _S601; + points_5[int(0)] = _S603; + points_5[int(1)] = _S603; + points_5[int(2)] = _S603; + points_5[int(3)] = _S603; + points_5[int(4)] = _S603; + raydir_8 = _S603; } - float4 _S660; - if(_S602) + float4 _S662; + if(_S604) { if(_runFlag_7) { @@ -3443,194 +3467,194 @@ inline __device__ void depth_normal_loss_vjp_none(float2 pix_center_4, float4 { if(_runFlag_9) { - FixedArray _S661 = points_5; - FixedArray _S662 = points_5; FixedArray _S663 = points_5; - float3 _S664 = _S604 * points_5[int(3)]; - float _S665 = _S664.x + _S664.y + _S664.z; - float4 _S666 = _S635; - *&((&_S666)->w) = _S665; - points_5[int(0)] = _S601; - points_5[int(1)] = _S601; - points_5[int(2)] = _S601; - points_5[int(3)] = _S601; - points_5[int(4)] = _S601; - _S604 = _S663[int(2)]; - normal_6 = _S661[int(0)]; - _S619 = _S662[int(1)]; - _S660 = _S666; + FixedArray _S664 = points_5; + FixedArray _S665 = points_5; + float3 _S666 = _S606 * points_5[int(3)]; + float _S667 = _S666.x + _S666.y + _S666.z; + float4 _S668 = _S637; + *&((&_S668)->w) = _S667; + points_5[int(0)] = _S603; + points_5[int(1)] = _S603; + points_5[int(2)] = _S603; + points_5[int(3)] = _S603; + points_5[int(4)] = _S603; + _S606 = _S665[int(2)]; + normal_6 = _S663[int(0)]; + _S621 = _S664[int(1)]; + _S662 = _S668; } else { - FixedArray _S667 = points_5; - FixedArray _S668 = points_5; FixedArray _S669 = points_5; FixedArray _S670 = points_5; + FixedArray _S671 = points_5; + FixedArray _S672 = 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)]; - _S604 = _S601; - normal_6 = _S601; - _S619 = _S601; - _S660 = _S635; + points_5[int(1)] = _S669[int(1)]; + points_5[int(2)] = _S670[int(2)]; + points_5[int(3)] = _S671[int(3)]; + points_5[int(4)] = _S672[int(4)]; + _S606 = _S603; + normal_6 = _S603; + _S621 = _S603; + _S662 = _S637; } - float3 _S671 = _S605 * (points_5[int(2)] + _S604); - float _S672 = _S671.x + _S671.y + _S671.z; - float3 _S673 = points_5[int(0)] + normal_6; - float3 _S674 = points_5[int(1)] + _S619; - float4 _S675 = _S635; - *&((&_S675)->z) = _S672; - float4 _S676 = _S660 + _S675; - points_5[int(0)] = _S601; - points_5[int(1)] = _S601; - points_5[int(2)] = _S601; - points_5[int(3)] = _S601; - points_5[int(4)] = _S601; - _S604 = _S674; - _S605 = _S673; - _S660 = _S676; + float3 _S673 = _S607 * (points_5[int(2)] + _S606); + float _S674 = _S673.x + _S673.y + _S673.z; + float3 _S675 = points_5[int(0)] + normal_6; + float3 _S676 = points_5[int(1)] + _S621; + float4 _S677 = _S637; + *&((&_S677)->z) = _S674; + float4 _S678 = _S662 + _S677; + points_5[int(0)] = _S603; + points_5[int(1)] = _S603; + points_5[int(2)] = _S603; + points_5[int(3)] = _S603; + points_5[int(4)] = _S603; + _S606 = _S676; + _S607 = _S675; + _S662 = _S678; } else { - FixedArray _S677 = points_5; - FixedArray _S678 = points_5; FixedArray _S679 = points_5; FixedArray _S680 = points_5; + FixedArray _S681 = points_5; + FixedArray _S682 = points_5; points_5[int(0)] = points_5[int(0)]; - points_5[int(1)] = _S677[int(1)]; - points_5[int(2)] = _S678[int(2)]; - points_5[int(3)] = _S679[int(3)]; - points_5[int(4)] = _S680[int(4)]; - _S604 = _S601; - _S605 = _S601; - _S660 = _S635; + points_5[int(1)] = _S679[int(1)]; + points_5[int(2)] = _S680[int(2)]; + points_5[int(3)] = _S681[int(3)]; + points_5[int(4)] = _S682[int(4)]; + _S606 = _S603; + _S607 = _S603; + _S662 = _S637; } - float3 _S681 = _S606 * (points_5[int(1)] + _S604); - float _S682 = _S681.x + _S681.y + _S681.z; - float3 _S683 = points_5[int(0)] + _S605; - float4 _S684 = _S635; - *&((&_S684)->y) = _S682; - float4 _S685 = _S660 + _S684; - points_5[int(0)] = _S601; - points_5[int(1)] = _S601; - points_5[int(2)] = _S601; - points_5[int(3)] = _S601; - points_5[int(4)] = _S601; - _S604 = _S683; - _S660 = _S685; + float3 _S683 = _S608 * (points_5[int(1)] + _S606); + float _S684 = _S683.x + _S683.y + _S683.z; + float3 _S685 = points_5[int(0)] + _S607; + float4 _S686 = _S637; + *&((&_S686)->y) = _S684; + float4 _S687 = _S662 + _S686; + points_5[int(0)] = _S603; + points_5[int(1)] = _S603; + points_5[int(2)] = _S603; + points_5[int(3)] = _S603; + points_5[int(4)] = _S603; + _S606 = _S685; + _S662 = _S687; } else { - FixedArray _S686 = points_5; - FixedArray _S687 = points_5; FixedArray _S688 = points_5; FixedArray _S689 = points_5; + FixedArray _S690 = points_5; + FixedArray _S691 = points_5; points_5[int(0)] = points_5[int(0)]; - points_5[int(1)] = _S686[int(1)]; - points_5[int(2)] = _S687[int(2)]; - points_5[int(3)] = _S688[int(3)]; - points_5[int(4)] = _S689[int(4)]; - _S604 = _S601; - _S660 = _S635; + points_5[int(1)] = _S688[int(1)]; + points_5[int(2)] = _S689[int(2)]; + points_5[int(3)] = _S690[int(3)]; + points_5[int(4)] = _S691[int(4)]; + _S606 = _S603; + _S662 = _S637; } - float3 _S690 = _S607 * (points_5[int(0)] + _S604); - float _S691 = _S690.x + _S690.y + _S690.z; - float4 _S692 = _S635; - *&((&_S692)->x) = _S691; - _S660 = _S660 + _S692; + float3 _S692 = _S609 * (points_5[int(0)] + _S606); + float _S693 = _S692.x + _S692.y + _S692.z; + float4 _S694 = _S637; + *&((&_S694)->x) = _S693; + _S662 = _S662 + _S694; } else { - _S660 = _S635; + _S662 = _S637; } - *v_depths_1 = _S660; + *v_depths_1 = _S662; *v_gt_normal_0 = raydir_8; return; } inline __device__ float3 generate_ray_d2n_opencv(float2 pix_pos_3, float4 intrins_8, FixedArray dist_coeffs_11, int camera_model_10, bool is_ray_depth_9) { - float3 _S693; + float3 _S695; for(;;) { float2 uv_28 = (pix_pos_3 - float2 {intrins_8.z, intrins_8.w}) / float2 {intrins_8.x, intrins_8.y}; - FixedArray _S694 = dist_coeffs_11; + FixedArray _S696 = dist_coeffs_11; float2 uv_u_12; - bool _S695 = undistort_point_1(uv_28, &_S694, int(12), &uv_u_12); - if(!_S695) + bool _S697 = undistort_point_1(uv_28, &_S696, int(12), &uv_u_12); + if(!_S697) { - int3 _S696 = make_int3 (int(0)); - float3 _S697 = make_float3 ((float)_S696.x, (float)_S696.y, (float)_S696.z); - _S693 = _S697; + int3 _S698 = make_int3 (int(0)); + float3 _S699 = make_float3 ((float)_S698.x, (float)_S698.y, (float)_S698.z); + _S695 = _S699; break; } - _S693 = unproject_raydir_0(uv_u_12, camera_model_10, is_ray_depth_9); + _S695 = unproject_raydir_0(uv_u_12, camera_model_10, is_ray_depth_9); break; } - return _S693; + return _S695; } inline __device__ float3 depth_to_point_opencv(float2 pix_pos_4, float4 intrins_9, FixedArray dist_coeffs_12, int camera_model_11, bool is_ray_depth_10, float depth_4) { - float3 _S698; + float3 _S700; for(;;) { float2 uv_29 = (pix_pos_4 - float2 {intrins_9.z, intrins_9.w}) / float2 {intrins_9.x, intrins_9.y}; - FixedArray _S699 = dist_coeffs_12; + FixedArray _S701 = dist_coeffs_12; float2 uv_u_13; - bool _S700 = undistort_point_1(uv_29, &_S699, int(12), &uv_u_13); - if(!_S700) + bool _S702 = undistort_point_1(uv_29, &_S701, int(12), &uv_u_13); + if(!_S702) { - _S698 = make_float3 (0.0f); + _S700 = make_float3 (0.0f); break; } - _S698 = make_float3 (depth_4) * unproject_raydir_0(uv_u_13, camera_model_11, is_ray_depth_10); + _S700 = make_float3 (depth_4) * unproject_raydir_0(uv_u_13, camera_model_11, is_ray_depth_10); break; } - return _S698; + return _S700; } struct s_bwd_prop_depth_to_point_Intermediates_1 { - float2 _S701; - bool _S702; + float2 _S703; + bool _S704; }; inline __device__ float depth_to_point_vjp_opencv(float2 pix_pos_5, float4 intrins_10, FixedArray dist_coeffs_13, int camera_model_12, bool is_ray_depth_11, float depth_5, float3 v_point_1) { - float2 _S703 = make_float2 (0.0f); - s_bwd_prop_depth_to_point_Intermediates_1 _S704; - (&_S704)->_S701 = _S703; - (&_S704)->_S702 = false; + float2 _S705 = make_float2 (0.0f); + s_bwd_prop_depth_to_point_Intermediates_1 _S706; + (&_S706)->_S703 = _S705; + (&_S706)->_S704 = false; float2 uv_30 = (pix_pos_5 - float2 {intrins_10.z, intrins_10.w}) / float2 {intrins_10.x, intrins_10.y}; - float2 _S705 = _S703; - FixedArray _S706 = dist_coeffs_13; - bool _S707 = undistort_point_1(uv_30, &_S706, int(12), &_S705); - (&_S704)->_S701 = _S705; - (&_S704)->_S702 = _S707; - s_bwd_prop_depth_to_point_Intermediates_1 _S708 = _S704; - float3 _S709 = make_float3 (0.0f); - bool _S710 = !!_S704._S702; - float3 _S711; - if(_S710) + float2 _S707 = _S705; + FixedArray _S708 = dist_coeffs_13; + bool _S709 = undistort_point_1(uv_30, &_S708, int(12), &_S707); + (&_S706)->_S703 = _S707; + (&_S706)->_S704 = _S709; + s_bwd_prop_depth_to_point_Intermediates_1 _S710 = _S706; + float3 _S711 = make_float3 (0.0f); + bool _S712 = !!_S706._S704; + float3 _S713; + if(_S712) { - _S711 = s_primal_ctx_unproject_raydir_0(_S708._S701, camera_model_12, is_ray_depth_11); + _S713 = s_primal_ctx_unproject_raydir_0(_S710._S703, camera_model_12, is_ray_depth_11); } else { - _S711 = _S709; + _S713 = _S711; } - if(_S710) + if(_S712) { - _S711 = _S711 * v_point_1; + _S713 = _S713 * v_point_1; } else { - _S711 = _S709; + _S713 = _S711; } - return _S711.x + _S711.y + _S711.z; + return _S713.x + _S713.y + _S713.z; } inline __device__ float3 depth_to_normal_opencv(float2 pix_center_5, float4 intrins_11, FixedArray dist_coeffs_14, int camera_model_13, bool is_ray_depth_12, float4 depths_4) @@ -3638,142 +3662,142 @@ inline __device__ float3 depth_to_normal_opencv(float2 pix_center_5, float4 i float3 normal_7; for(;;) { - bool _S712; + bool _S714; if((depths_4.x) == 0.0f) { - _S712 = true; + _S714 = true; } else { - _S712 = (depths_4.y) == 0.0f; + _S714 = (depths_4.y) == 0.0f; } - if(_S712) + if(_S714) { - _S712 = true; + _S714 = true; } else { - _S712 = (depths_4.z) == 0.0f; + _S714 = (depths_4.z) == 0.0f; } - if(_S712) + if(_S714) { - _S712 = true; + _S714 = true; } else { - _S712 = (depths_4.w) == 0.0f; + _S714 = (depths_4.w) == 0.0f; } - if(_S712) + if(_S714) { normal_7 = make_float3 (0.0f); break; } - float3 * _S713; - float3 * _S714; float3 * _S715; float3 * _S716; - int _S717; + float3 * _S717; + float3 * _S718; + int _S719; FixedArray points_6; for(;;) { - float2 _S718 = float2 {intrins_11.z, intrins_11.w}; - float2 _S719 = float2 {intrins_11.x, intrins_11.y}; - float2 uv_31 = (pix_center_5 + make_float2 (-1.0f, -0.0f) - _S718) / _S719; - FixedArray _S720 = dist_coeffs_14; + float2 _S720 = float2 {intrins_11.z, intrins_11.w}; + float2 _S721 = float2 {intrins_11.x, intrins_11.y}; + float2 uv_31 = (pix_center_5 + make_float2 (-1.0f, -0.0f) - _S720) / _S721; + FixedArray _S722 = dist_coeffs_14; float2 uv_u_14; - bool _S721 = undistort_point_1(uv_31, &_S720, int(12), &uv_u_14); - if(!_S721) + bool _S723 = undistort_point_1(uv_31, &_S722, int(12), &uv_u_14); + if(!_S723) { - float3 _S722 = make_float3 (0.0f); - _S717 = int(0); + float3 _S724 = make_float3 (0.0f); + _S719 = int(0); + _S718 = nullptr; + _S717 = nullptr; _S716 = nullptr; _S715 = nullptr; - _S714 = nullptr; - _S713 = nullptr; - normal_7 = _S722; + normal_7 = _S724; 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_32 = (pix_center_5 + make_float2 (1.0f, -0.0f) - _S718) / _S719; - FixedArray _S723 = dist_coeffs_14; + float2 uv_32 = (pix_center_5 + make_float2 (1.0f, -0.0f) - _S720) / _S721; + FixedArray _S725 = dist_coeffs_14; float2 uv_u_15; - bool _S724 = undistort_point_1(uv_32, &_S723, int(12), &uv_u_15); - if(!_S724) + bool _S726 = undistort_point_1(uv_32, &_S725, int(12), &uv_u_15); + if(!_S726) { - float3 _S725 = make_float3 (0.0f); - _S717 = int(0); - _S716 = nullptr; - normal_7 = _S725; + float3 _S727 = make_float3 (0.0f); + _S719 = int(0); + _S718 = nullptr; + normal_7 = _S727; break; } points_6[int(1)] = make_float3 (depths_4.y) * unproject_raydir_0(uv_u_15, camera_model_13, is_ray_depth_12); - _S717 = int(2); - _S716 = &points_6[int(1)]; + _S719 = int(2); + _S718 = &points_6[int(1)]; break; } - if(_S717 != int(2)) + if(_S719 != int(2)) { - _S715 = &points_6[int(0)]; - _S714 = nullptr; - _S713 = nullptr; + _S717 = &points_6[int(0)]; + _S716 = nullptr; + _S715 = nullptr; break; } - float2 uv_33 = (pix_center_5 + make_float2 (0.0f, -1.0f) - _S718) / _S719; - FixedArray _S726 = dist_coeffs_14; + float2 uv_33 = (pix_center_5 + make_float2 (0.0f, -1.0f) - _S720) / _S721; + FixedArray _S728 = dist_coeffs_14; float2 uv_u_16; - bool _S727 = undistort_point_1(uv_33, &_S726, int(12), &uv_u_16); - if(!_S727) + bool _S729 = undistort_point_1(uv_33, &_S728, int(12), &uv_u_16); + if(!_S729) { - float3 _S728 = make_float3 (0.0f); - _S717 = int(0); - _S715 = &points_6[int(0)]; - _S714 = nullptr; - _S713 = nullptr; - normal_7 = _S728; + float3 _S730 = make_float3 (0.0f); + _S719 = int(0); + _S717 = &points_6[int(0)]; + _S716 = nullptr; + _S715 = nullptr; + normal_7 = _S730; 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_34 = (pix_center_5 + make_float2 (0.0f, 1.0f) - _S718) / _S719; - FixedArray _S729 = dist_coeffs_14; + float2 uv_34 = (pix_center_5 + make_float2 (0.0f, 1.0f) - _S720) / _S721; + FixedArray _S731 = dist_coeffs_14; float2 uv_u_17; - bool _S730 = undistort_point_1(uv_34, &_S729, int(12), &uv_u_17); - if(!_S730) + bool _S732 = undistort_point_1(uv_34, &_S731, int(12), &uv_u_17); + if(!_S732) { - float3 _S731 = make_float3 (0.0f); - _S717 = int(0); - _S715 = nullptr; - normal_7 = _S731; + float3 _S733 = make_float3 (0.0f); + _S719 = int(0); + _S717 = nullptr; + normal_7 = _S733; break; } points_6[int(3)] = make_float3 (depths_4.w) * unproject_raydir_0(uv_u_17, camera_model_13, is_ray_depth_12); - _S717 = int(2); - _S715 = &points_6[int(3)]; + _S719 = int(2); + _S717 = &points_6[int(3)]; break; } - if(_S717 != int(2)) + if(_S719 != int(2)) { - float3 * _S732 = _S715; - _S715 = &points_6[int(0)]; - _S714 = _S732; - _S713 = &points_6[int(2)]; + float3 * _S734 = _S717; + _S717 = &points_6[int(0)]; + _S716 = _S734; + _S715 = &points_6[int(2)]; break; } - float3 * _S733 = _S715; - _S717 = int(1); - _S715 = &points_6[int(0)]; - _S714 = _S733; - _S713 = &points_6[int(2)]; + float3 * _S735 = _S717; + _S719 = int(1); + _S717 = &points_6[int(0)]; + _S716 = _S735; + _S715 = &points_6[int(2)]; break; } - if(_S717 != int(1)) + if(_S719 != int(1)) { break; } - float3 normal_8 = cross_0(*_S716 - *_S715, - (*_S714 - *_S713)); + float3 normal_8 = cross_0(*_S718 - *_S717, - (*_S716 - *_S715)); if((dot_0(normal_8, normal_8)) != 0.0f) { normal_7 = normal_8 / make_float3 (length_0(normal_8)); @@ -3789,39 +3813,39 @@ inline __device__ float3 depth_to_normal_opencv(float2 pix_center_5, float4 i struct s_bwd_prop_depth_to_normal_Intermediates_1 { - float2 _S734; - bool _S735; float2 _S736; bool _S737; float2 _S738; bool _S739; float2 _S740; bool _S741; + float2 _S742; + bool _S743; }; inline __device__ void depth_to_normal_vjp_opencv(float2 pix_center_6, float4 intrins_12, FixedArray dist_coeffs_15, int camera_model_14, bool is_ray_depth_13, float4 depths_5, float3 v_normal_2, float4 * v_depths_2) { - float2 _S742 = make_float2 (0.0f); - s_bwd_prop_depth_to_normal_Intermediates_1 _S743; - (&_S743)->_S734 = _S742; - (&_S743)->_S735 = false; - (&_S743)->_S736 = _S742; - (&_S743)->_S737 = false; - (&_S743)->_S738 = _S742; - (&_S743)->_S739 = false; - (&_S743)->_S740 = _S742; - (&_S743)->_S741 = false; - (&_S743)->_S734 = _S742; - (&_S743)->_S735 = false; - (&_S743)->_S736 = _S742; - (&_S743)->_S737 = false; - (&_S743)->_S738 = _S742; - (&_S743)->_S739 = false; - (&_S743)->_S740 = _S742; - (&_S743)->_S741 = false; - bool _S744 = (depths_5.x) == 0.0f; + float2 _S744 = make_float2 (0.0f); + s_bwd_prop_depth_to_normal_Intermediates_1 _S745; + (&_S745)->_S736 = _S744; + (&_S745)->_S737 = false; + (&_S745)->_S738 = _S744; + (&_S745)->_S739 = false; + (&_S745)->_S740 = _S744; + (&_S745)->_S741 = false; + (&_S745)->_S742 = _S744; + (&_S745)->_S743 = false; + (&_S745)->_S736 = _S744; + (&_S745)->_S737 = false; + (&_S745)->_S738 = _S744; + (&_S745)->_S739 = false; + (&_S745)->_S740 = _S744; + (&_S745)->_S741 = false; + (&_S745)->_S742 = _S744; + (&_S745)->_S743 = false; + bool _S746 = (depths_5.x) == 0.0f; bool _runFlag_11; - if(_S744) + if(_S746) { _runFlag_11 = true; } @@ -3845,69 +3869,69 @@ inline __device__ void depth_to_normal_vjp_opencv(float2 pix_center_6, float4 { _runFlag_11 = (depths_5.w) == 0.0f; } - int _S745; + int _S747; if(!_runFlag_11) { - float2 _S746 = float2 {intrins_12.z, intrins_12.w}; - float2 _S747 = float2 {intrins_12.x, intrins_12.y}; - float2 uv_35 = (pix_center_6 + make_float2 (-1.0f, -0.0f) - _S746) / _S747; - float2 _S748 = _S742; - FixedArray _S749 = dist_coeffs_15; - bool _S750 = undistort_point_1(uv_35, &_S749, int(12), &_S748); - (&_S743)->_S734 = _S748; - (&_S743)->_S735 = _S750; - bool _S751 = !!_S750; - if(_S751) + float2 _S748 = float2 {intrins_12.z, intrins_12.w}; + float2 _S749 = float2 {intrins_12.x, intrins_12.y}; + float2 uv_35 = (pix_center_6 + make_float2 (-1.0f, -0.0f) - _S748) / _S749; + float2 _S750 = _S744; + FixedArray _S751 = dist_coeffs_15; + bool _S752 = undistort_point_1(uv_35, &_S751, int(12), &_S750); + (&_S745)->_S736 = _S750; + (&_S745)->_S737 = _S752; + bool _S753 = !!_S752; + if(_S753) { - float2 uv_36 = (pix_center_6 + make_float2 (1.0f, -0.0f) - _S746) / _S747; - float2 _S752 = _S742; - FixedArray _S753 = dist_coeffs_15; - bool _S754 = undistort_point_1(uv_36, &_S753, int(12), &_S752); - (&_S743)->_S736 = _S752; - (&_S743)->_S737 = _S754; - if(!!_S754) + float2 uv_36 = (pix_center_6 + make_float2 (1.0f, -0.0f) - _S748) / _S749; + float2 _S754 = _S744; + FixedArray _S755 = dist_coeffs_15; + bool _S756 = undistort_point_1(uv_36, &_S755, int(12), &_S754); + (&_S745)->_S738 = _S754; + (&_S745)->_S739 = _S756; + if(!!_S756) { - _S745 = int(2); + _S747 = int(2); } else { - _S745 = int(0); + _S747 = int(0); } - if(_S745 != int(2)) + if(_S747 != int(2)) { _runFlag_11 = false; } else { - _runFlag_11 = _S751; + _runFlag_11 = _S753; } if(_runFlag_11) { - float2 uv_37 = (pix_center_6 + make_float2 (0.0f, -1.0f) - _S746) / _S747; - float2 _S755 = _S742; - FixedArray _S756 = dist_coeffs_15; - bool _S757 = undistort_point_1(uv_37, &_S756, int(12), &_S755); - (&_S743)->_S738 = _S755; - (&_S743)->_S739 = _S757; - if(!_S757) + float2 uv_37 = (pix_center_6 + make_float2 (0.0f, -1.0f) - _S748) / _S749; + float2 _S757 = _S744; + FixedArray _S758 = dist_coeffs_15; + bool _S759 = undistort_point_1(uv_37, &_S758, int(12), &_S757); + (&_S745)->_S740 = _S757; + (&_S745)->_S741 = _S759; + if(!_S759) { _runFlag_11 = false; } if(_runFlag_11) { - float2 uv_38 = (pix_center_6 + make_float2 (0.0f, 1.0f) - _S746) / _S747; - float2 _S758 = _S742; - FixedArray _S759 = dist_coeffs_15; - bool _S760 = undistort_point_1(uv_38, &_S759, int(12), &_S758); - (&_S743)->_S740 = _S758; - (&_S743)->_S741 = _S760; + float2 uv_38 = (pix_center_6 + make_float2 (0.0f, 1.0f) - _S748) / _S749; + float2 _S760 = _S744; + FixedArray _S761 = dist_coeffs_15; + bool _S762 = undistort_point_1(uv_38, &_S761, int(12), &_S760); + (&_S745)->_S742 = _S760; + (&_S745)->_S743 = _S762; } } } } - s_bwd_prop_depth_to_normal_Intermediates_1 _S761 = _S743; - float3 _S762 = make_float3 (0.0f); - if(_S744) + s_bwd_prop_depth_to_normal_Intermediates_1 _S763 = _S745; + float3 _S764 = make_float3 (0.0f); + if(_S746) { _runFlag_11 = true; } @@ -3931,16 +3955,14 @@ inline __device__ void depth_to_normal_vjp_opencv(float2 pix_center_6, float4 { _runFlag_11 = (depths_5.w) == 0.0f; } - bool _S763 = !_runFlag_11; + bool _S765 = !_runFlag_11; bool _runFlag_12; bool _runFlag_13; - bool _S764; - bool _runFlag_14; - bool _S765; bool _S766; + bool _runFlag_14; + bool _S767; + bool _S768; FixedArray points_7; - float3 _S767; - float3 _S768; float3 _S769; float3 _S770; float3 _S771; @@ -3948,49 +3970,51 @@ inline __device__ void depth_to_normal_vjp_opencv(float2 pix_center_6, float4 float3 _S773; float3 _S774; float3 _S775; - if(_S763) + float3 _S776; + float3 _S777; + if(_S765) { - bool _S776 = !!_S761._S735; - if(_S776) + bool _S778 = !!_S763._S737; + if(_S778) { - float3 _S777 = s_primal_ctx_unproject_raydir_0(_S761._S734, camera_model_14, is_ray_depth_13); - float3 _S778 = make_float3 (depths_5.x) * _S777; - bool _S779 = !!_S761._S737; - if(_S779) + float3 _S779 = s_primal_ctx_unproject_raydir_0(_S763._S736, camera_model_14, is_ray_depth_13); + float3 _S780 = make_float3 (depths_5.x) * _S779; + bool _S781 = !!_S763._S739; + if(_S781) { - float3 _S780 = s_primal_ctx_unproject_raydir_0(_S761._S736, camera_model_14, is_ray_depth_13); - float3 _S781 = make_float3 (depths_5.y) * _S780; - _S745 = int(2); - points_7[int(0)] = _S778; - points_7[int(1)] = _S781; - points_7[int(2)] = _S762; - points_7[int(3)] = _S762; - _S767 = _S780; + float3 _S782 = s_primal_ctx_unproject_raydir_0(_S763._S738, camera_model_14, is_ray_depth_13); + float3 _S783 = make_float3 (depths_5.y) * _S782; + _S747 = int(2); + points_7[int(0)] = _S780; + points_7[int(1)] = _S783; + points_7[int(2)] = _S764; + points_7[int(3)] = _S764; + _S769 = _S782; } else { - _S745 = int(0); - points_7[int(0)] = _S778; - points_7[int(1)] = _S762; - points_7[int(2)] = _S762; - points_7[int(3)] = _S762; - _S767 = _S762; + _S747 = int(0); + points_7[int(0)] = _S780; + points_7[int(1)] = _S764; + points_7[int(2)] = _S764; + points_7[int(3)] = _S764; + _S769 = _S764; } - if(_S745 != int(2)) + if(_S747 != int(2)) { _runFlag_11 = false; } else { - _runFlag_11 = _S776; - _S745 = int(0); + _runFlag_11 = _S778; + _S747 = int(0); } if(_runFlag_11) { - if(!_S761._S739) + if(!_S763._S741) { _runFlag_12 = false; - _S745 = int(0); + _S747 = int(0); } else { @@ -3998,26 +4022,26 @@ inline __device__ void depth_to_normal_vjp_opencv(float2 pix_center_6, float4 } if(_runFlag_12) { - float3 _S782 = s_primal_ctx_unproject_raydir_0(_S761._S738, camera_model_14, is_ray_depth_13); - points_7[int(2)] = make_float3 (depths_5.z) * _S782; - bool _S783 = !!_S761._S741; - int _S784; - if(_S783) + float3 _S784 = s_primal_ctx_unproject_raydir_0(_S763._S740, camera_model_14, is_ray_depth_13); + points_7[int(2)] = make_float3 (depths_5.z) * _S784; + bool _S785 = !!_S763._S743; + int _S786; + if(_S785) { - float3 _S785 = s_primal_ctx_unproject_raydir_0(_S761._S740, camera_model_14, is_ray_depth_13); - points_7[int(3)] = make_float3 (depths_5.w) * _S785; - _S784 = int(2); - _S768 = _S785; + float3 _S787 = s_primal_ctx_unproject_raydir_0(_S763._S742, camera_model_14, is_ray_depth_13); + points_7[int(3)] = make_float3 (depths_5.w) * _S787; + _S786 = int(2); + _S770 = _S787; } else { - _S784 = int(0); - _S768 = _S762; + _S786 = int(0); + _S770 = _S764; } - if(_S784 != int(2)) + if(_S786 != int(2)) { _runFlag_13 = false; - _S745 = _S784; + _S747 = _S786; } else { @@ -4025,437 +4049,437 @@ inline __device__ void depth_to_normal_vjp_opencv(float2 pix_center_6, float4 } if(_runFlag_13) { - _S745 = int(1); + _S747 = int(1); } - _runFlag_13 = _S783; - _S769 = _S782; + _runFlag_13 = _S785; + _S771 = _S784; } else { _runFlag_13 = false; - _S768 = _S762; - _S769 = _S762; + _S770 = _S764; + _S771 = _S764; } } else { _runFlag_12 = false; _runFlag_13 = false; - _S768 = _S762; - _S769 = _S762; + _S770 = _S764; + _S771 = _S764; } - float3 _S786 = _S767; - _S767 = _S768; - _S768 = _S769; - _S764 = _S779; - _S769 = _S786; - _S770 = _S777; + float3 _S788 = _S769; + _S769 = _S770; + _S770 = _S771; + _S766 = _S781; + _S771 = _S788; + _S772 = _S779; } else { - _S745 = int(0); - points_7[int(0)] = _S762; - points_7[int(1)] = _S762; - points_7[int(2)] = _S762; - points_7[int(3)] = _S762; + _S747 = int(0); + points_7[int(0)] = _S764; + points_7[int(1)] = _S764; + points_7[int(2)] = _S764; + points_7[int(3)] = _S764; _runFlag_11 = false; _runFlag_12 = false; _runFlag_13 = false; - _S767 = _S762; - _S768 = _S762; - _S764 = false; - _S769 = _S762; - _S770 = _S762; + _S769 = _S764; + _S770 = _S764; + _S766 = false; + _S771 = _S764; + _S772 = _S764; } - if(_S745 != int(1)) + if(_S747 != int(1)) { _runFlag_14 = false; } else { - _runFlag_14 = _S763; + _runFlag_14 = _S765; } if(_runFlag_14) { float3 dx_3 = points_7[int(1)] - points_7[int(0)]; - float3 _S787 = - (points_7[int(3)] - points_7[int(2)]); - float3 _S788 = s_primal_ctx_cross_0(dx_3, _S787); - bool _S789 = (s_primal_ctx_dot_0(_S788, _S788)) != 0.0f; - if(_S789) + float3 _S789 = - (points_7[int(3)] - points_7[int(2)]); + float3 _S790 = s_primal_ctx_cross_0(dx_3, _S789); + bool _S791 = (s_primal_ctx_dot_0(_S790, _S790)) != 0.0f; + if(_S791) { - float _S790 = length_0(_S788); - float3 _S791 = make_float3 (_S790); - _S771 = make_float3 (_S790 * _S790); - _S772 = _S791; + float _S792 = length_0(_S790); + float3 _S793 = make_float3 (_S792); + _S773 = make_float3 (_S792 * _S792); + _S774 = _S793; } else { - _S771 = _S762; - _S772 = _S762; + _S773 = _S764; + _S774 = _S764; } - float3 _S792 = _S772; - _S765 = _S789; - _S772 = _S788; - _S773 = _S792; - _S774 = dx_3; - _S775 = _S787; + float3 _S794 = _S774; + _S767 = _S791; + _S774 = _S790; + _S775 = _S794; + _S776 = dx_3; + _S777 = _S789; } else { - _S765 = false; - _S771 = _S762; - _S772 = _S762; - _S773 = _S762; - _S774 = _S762; - _S775 = _S762; + _S767 = false; + _S773 = _S764; + _S774 = _S764; + _S775 = _S764; + _S776 = _S764; + _S777 = _S764; } - bool _S793 = _runFlag_11; - bool _S794 = _runFlag_12; - bool _S795 = _runFlag_13; - float3 _S796 = _S767; - float3 _S797 = _S768; - bool _S798 = _S764; - float3 _S799 = _S769; - float3 _S800 = _S770; + bool _S795 = _runFlag_11; + bool _S796 = _runFlag_12; + bool _S797 = _runFlag_13; + float3 _S798 = _S769; + float3 _S799 = _S770; + bool _S800 = _S766; + float3 _S801 = _S771; + float3 _S802 = _S772; _runFlag_11 = _runFlag_14; - _runFlag_12 = _S765; - _S767 = _S771; - _S768 = _S772; + _runFlag_12 = _S767; _S769 = _S773; _S770 = _S774; _S771 = _S775; - _runFlag_13 = _S776; - _S764 = _S793; - _runFlag_14 = _S794; - _S765 = _S795; - _S772 = _S796; - _S773 = _S797; - _S766 = _S798; - _S774 = _S799; - _S775 = _S800; + _S772 = _S776; + _S773 = _S777; + _runFlag_13 = _S778; + _S766 = _S795; + _runFlag_14 = _S796; + _S767 = _S797; + _S774 = _S798; + _S775 = _S799; + _S768 = _S800; + _S776 = _S801; + _S777 = _S802; } else { _runFlag_11 = false; _runFlag_12 = false; - _S767 = _S762; - _S768 = _S762; - _S769 = _S762; - _S770 = _S762; - _S771 = _S762; + _S769 = _S764; + _S770 = _S764; + _S771 = _S764; + _S772 = _S764; + _S773 = _S764; _runFlag_13 = false; - _S764 = false; - _runFlag_14 = false; - _S765 = false; - _S772 = _S762; - _S773 = _S762; _S766 = false; - _S774 = _S762; - _S775 = _S762; + _runFlag_14 = false; + _S767 = false; + _S774 = _S764; + _S775 = _S764; + _S768 = false; + _S776 = _S764; + _S777 = _S764; } - float4 _S801 = make_float4 (0.0f); - float4 _S802; - if(_S763) + float4 _S803 = make_float4 (0.0f); + float4 _S804; + if(_S765) { if(_runFlag_11) { if(_runFlag_12) { - float3 _S803 = v_normal_2 / _S767; - float3 _S804 = _S768 * - _S803; - float3 _S805 = _S769 * _S803; - float _S806 = _S804.x + _S804.y + _S804.z; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S807; - (&_S807)->primal_0 = _S768; - (&_S807)->differential_0 = _S762; - s_bwd_length_impl_0(&_S807, _S806); - _S767 = _S805 + _S807.differential_0; + float3 _S805 = v_normal_2 / _S769; + float3 _S806 = _S770 * - _S805; + float3 _S807 = _S771 * _S805; + float _S808 = _S806.x + _S806.y + _S806.z; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S809; + (&_S809)->primal_0 = _S770; + (&_S809)->differential_0 = _S764; + s_bwd_length_impl_0(&_S809, _S808); + _S769 = _S807 + _S809.differential_0; } else { - _S767 = v_normal_2; + _S769 = v_normal_2; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S808; - (&_S808)->primal_0 = _S768; - (&_S808)->differential_0 = _S762; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S809; - (&_S809)->primal_0 = _S768; - (&_S809)->differential_0 = _S762; - s_bwd_prop_dot_0(&_S808, &_S809, 0.0f); - float3 _S810 = _S809.differential_0 + _S808.differential_0 + _S767; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S810; + (&_S810)->primal_0 = _S770; + (&_S810)->differential_0 = _S764; DiffPair_vectorx3Cfloatx2C3x3E_0 _S811; (&_S811)->primal_0 = _S770; - (&_S811)->differential_0 = _S762; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S812; - (&_S812)->primal_0 = _S771; - (&_S812)->differential_0 = _S762; - s_bwd_prop_cross_0(&_S811, &_S812, _S810); - float3 s_diff_dy_T_3 = - _S812.differential_0; - float3 _S813 = - s_diff_dy_T_3; - float3 _S814 = - _S811.differential_0; - FixedArray _S815; - _S815[int(0)] = _S762; - _S815[int(1)] = _S762; - _S815[int(2)] = _S762; - _S815[int(3)] = _S762; - _S815[int(2)] = _S813; - _S815[int(3)] = s_diff_dy_T_3; - _S815[int(0)] = _S814; - _S815[int(1)] = _S811.differential_0; - points_7[int(0)] = _S815[int(0)]; - points_7[int(1)] = _S815[int(1)]; - points_7[int(2)] = _S815[int(2)]; - points_7[int(3)] = _S815[int(3)]; + (&_S811)->differential_0 = _S764; + s_bwd_prop_dot_0(&_S810, &_S811, 0.0f); + float3 _S812 = _S811.differential_0 + _S810.differential_0 + _S769; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S813; + (&_S813)->primal_0 = _S772; + (&_S813)->differential_0 = _S764; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S814; + (&_S814)->primal_0 = _S773; + (&_S814)->differential_0 = _S764; + s_bwd_prop_cross_0(&_S813, &_S814, _S812); + float3 s_diff_dy_T_3 = - _S814.differential_0; + float3 _S815 = - s_diff_dy_T_3; + float3 _S816 = - _S813.differential_0; + FixedArray _S817; + _S817[int(0)] = _S764; + _S817[int(1)] = _S764; + _S817[int(2)] = _S764; + _S817[int(3)] = _S764; + _S817[int(2)] = _S815; + _S817[int(3)] = s_diff_dy_T_3; + _S817[int(0)] = _S816; + _S817[int(1)] = _S813.differential_0; + points_7[int(0)] = _S817[int(0)]; + points_7[int(1)] = _S817[int(1)]; + points_7[int(2)] = _S817[int(2)]; + points_7[int(3)] = _S817[int(3)]; } else { - points_7[int(0)] = _S762; - points_7[int(1)] = _S762; - points_7[int(2)] = _S762; - points_7[int(3)] = _S762; + points_7[int(0)] = _S764; + points_7[int(1)] = _S764; + points_7[int(2)] = _S764; + points_7[int(3)] = _S764; } if(_runFlag_13) { - if(_S764) + if(_S766) { if(_runFlag_14) { - FixedArray _S816 = points_7; - FixedArray _S817 = points_7; FixedArray _S818 = points_7; FixedArray _S819 = points_7; - if(_S765) + FixedArray _S820 = points_7; + FixedArray _S821 = points_7; + if(_S767) { - float3 _S820 = _S772 * _S819[int(3)]; - float _S821 = _S820.x + _S820.y + _S820.z; - float4 _S822 = _S801; - *&((&_S822)->w) = _S821; - points_7[int(0)] = _S816[int(0)]; - points_7[int(1)] = _S817[int(1)]; - points_7[int(2)] = _S818[int(2)]; - points_7[int(3)] = _S762; - _S802 = _S822; + float3 _S822 = _S774 * _S821[int(3)]; + float _S823 = _S822.x + _S822.y + _S822.z; + float4 _S824 = _S803; + *&((&_S824)->w) = _S823; + points_7[int(0)] = _S818[int(0)]; + points_7[int(1)] = _S819[int(1)]; + points_7[int(2)] = _S820[int(2)]; + points_7[int(3)] = _S764; + _S804 = _S824; } else { - points_7[int(0)] = _S816[int(0)]; - points_7[int(1)] = _S817[int(1)]; - points_7[int(2)] = _S818[int(2)]; - points_7[int(3)] = _S819[int(3)]; - _S802 = _S801; + points_7[int(0)] = _S818[int(0)]; + points_7[int(1)] = _S819[int(1)]; + points_7[int(2)] = _S820[int(2)]; + points_7[int(3)] = _S821[int(3)]; + _S804 = _S803; } - float3 _S823 = _S773 * points_7[int(2)]; - float _S824 = _S823.x + _S823.y + _S823.z; - FixedArray _S825 = points_7; - FixedArray _S826 = points_7; - float4 _S827 = _S801; - *&((&_S827)->z) = _S824; - float4 _S828 = _S802 + _S827; + float3 _S825 = _S775 * points_7[int(2)]; + float _S826 = _S825.x + _S825.y + _S825.z; + FixedArray _S827 = points_7; + FixedArray _S828 = points_7; + float4 _S829 = _S803; + *&((&_S829)->z) = _S826; + float4 _S830 = _S804 + _S829; points_7[int(0)] = points_7[int(0)]; - points_7[int(1)] = _S825[int(1)]; - points_7[int(2)] = _S762; - points_7[int(3)] = _S826[int(3)]; - _S802 = _S828; + points_7[int(1)] = _S827[int(1)]; + points_7[int(2)] = _S764; + points_7[int(3)] = _S828[int(3)]; + _S804 = _S830; } else { - FixedArray _S829 = points_7; - FixedArray _S830 = points_7; FixedArray _S831 = points_7; + FixedArray _S832 = points_7; + FixedArray _S833 = points_7; points_7[int(0)] = points_7[int(0)]; - points_7[int(1)] = _S829[int(1)]; - points_7[int(2)] = _S830[int(2)]; - points_7[int(3)] = _S831[int(3)]; - _S802 = _S801; + points_7[int(1)] = _S831[int(1)]; + points_7[int(2)] = _S832[int(2)]; + points_7[int(3)] = _S833[int(3)]; + _S804 = _S803; } } else { - FixedArray _S832 = points_7; - FixedArray _S833 = points_7; FixedArray _S834 = points_7; - points_7[int(0)] = points_7[int(0)]; - points_7[int(1)] = _S832[int(1)]; - points_7[int(2)] = _S833[int(2)]; - points_7[int(3)] = _S834[int(3)]; - _S802 = _S801; - } - if(_S766) - { FixedArray _S835 = points_7; - float3 _S836 = _S774 * points_7[int(1)]; - float _S837 = _S836.x + _S836.y + _S836.z; - float4 _S838 = _S801; - *&((&_S838)->y) = _S837; - float4 _S839 = _S802 + _S838; - points_7[int(0)] = _S762; - points_7[int(1)] = _S762; - points_7[int(2)] = _S762; - points_7[int(3)] = _S762; - _S767 = _S835[int(0)]; - _S802 = _S839; + FixedArray _S836 = points_7; + points_7[int(0)] = points_7[int(0)]; + points_7[int(1)] = _S834[int(1)]; + points_7[int(2)] = _S835[int(2)]; + points_7[int(3)] = _S836[int(3)]; + _S804 = _S803; + } + if(_S768) + { + FixedArray _S837 = points_7; + float3 _S838 = _S776 * points_7[int(1)]; + float _S839 = _S838.x + _S838.y + _S838.z; + float4 _S840 = _S803; + *&((&_S840)->y) = _S839; + float4 _S841 = _S804 + _S840; + points_7[int(0)] = _S764; + points_7[int(1)] = _S764; + points_7[int(2)] = _S764; + points_7[int(3)] = _S764; + _S769 = _S837[int(0)]; + _S804 = _S841; } else { - FixedArray _S840 = points_7; - FixedArray _S841 = points_7; FixedArray _S842 = points_7; + FixedArray _S843 = points_7; + FixedArray _S844 = points_7; points_7[int(0)] = points_7[int(0)]; - points_7[int(1)] = _S840[int(1)]; - points_7[int(2)] = _S841[int(2)]; - points_7[int(3)] = _S842[int(3)]; - _S767 = _S762; + points_7[int(1)] = _S842[int(1)]; + points_7[int(2)] = _S843[int(2)]; + points_7[int(3)] = _S844[int(3)]; + _S769 = _S764; } - float3 _S843 = _S775 * (points_7[int(0)] + _S767); - float _S844 = _S843.x + _S843.y + _S843.z; - float4 _S845 = _S801; - *&((&_S845)->x) = _S844; - _S802 = _S802 + _S845; + float3 _S845 = _S777 * (points_7[int(0)] + _S769); + float _S846 = _S845.x + _S845.y + _S845.z; + float4 _S847 = _S803; + *&((&_S847)->x) = _S846; + _S804 = _S804 + _S847; } else { - _S802 = _S801; + _S804 = _S803; } } else { - _S802 = _S801; + _S804 = _S803; } - *v_depths_2 = _S802; + *v_depths_2 = _S804; return; } inline __device__ float ray_depth_to_linear_depth_factor_opencv(float2 pix_center_7, float4 intrins_13, FixedArray dist_coeffs_16, int camera_model_15) { - float _S846; + float _S848; for(;;) { float2 uv_39 = (pix_center_7 - float2 {intrins_13.z, intrins_13.w}) / float2 {intrins_13.x, intrins_13.y}; - FixedArray _S847 = dist_coeffs_16; + FixedArray _S849 = dist_coeffs_16; float2 uv_u_18; - bool _S848 = undistort_point_1(uv_39, &_S847, int(12), &uv_u_18); - if(!_S848) + bool _S850 = undistort_point_1(uv_39, &_S849, int(12), &uv_u_18); + if(!_S850) { - _S846 = 0.0f; + _S848 = 0.0f; break; } float3 raydir_9 = unproject_raydir_0(uv_u_18, camera_model_15, false); - _S846 = float((F32_sign((raydir_9.z)))) / length_0(raydir_9); + _S848 = float((F32_sign((raydir_9.z)))) / length_0(raydir_9); break; } - return _S846; + return _S848; } inline __device__ float depth_normal_loss_opencv(float2 pix_center_8, float4 intrins_14, FixedArray dist_coeffs_17, int camera_model_16, bool is_ray_depth_14, float4 depths_6, float3 gt_normal_2) { - float _S849; + float _S851; for(;;) { - float3 _S850; - float3 * _S851; - float3 * _S852; + float3 _S852; float3 * _S853; float3 * _S854; - int _S855; + float3 * _S855; + float3 * _S856; + int _S857; FixedArray points_8; for(;;) { - float2 _S856 = float2 {intrins_14.z, intrins_14.w}; - float2 _S857 = float2 {intrins_14.x, intrins_14.y}; - float2 uv_40 = (pix_center_8 + make_float2 (-1.0f, -0.0f) - _S856) / _S857; - FixedArray _S858 = dist_coeffs_17; + float2 _S858 = float2 {intrins_14.z, intrins_14.w}; + float2 _S859 = float2 {intrins_14.x, intrins_14.y}; + float2 uv_40 = (pix_center_8 + make_float2 (-1.0f, -0.0f) - _S858) / _S859; + FixedArray _S860 = dist_coeffs_17; float2 uv_u_19; - bool _S859 = undistort_point_1(uv_40, &_S858, int(12), &uv_u_19); - float3 _S860 = make_float3 (0.0f); - if(!_S859) + bool _S861 = undistort_point_1(uv_40, &_S860, int(12), &uv_u_19); + float3 _S862 = make_float3 (0.0f); + if(!_S861) { - _S855 = int(0); + _S857 = int(0); + _S856 = nullptr; + _S855 = nullptr; _S854 = nullptr; _S853 = nullptr; - _S852 = nullptr; - _S851 = nullptr; - _S850 = _S860; + _S852 = _S862; 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_41 = (pix_center_8 + make_float2 (1.0f, -0.0f) - _S856) / _S857; - FixedArray _S861 = dist_coeffs_17; + float2 uv_41 = (pix_center_8 + make_float2 (1.0f, -0.0f) - _S858) / _S859; + FixedArray _S863 = dist_coeffs_17; float2 uv_u_20; - bool _S862 = undistort_point_1(uv_41, &_S861, int(12), &uv_u_20); - if(!_S862) + bool _S864 = undistort_point_1(uv_41, &_S863, int(12), &uv_u_20); + if(!_S864) { - _S855 = int(0); + _S857 = int(0); + _S856 = nullptr; + _S855 = &points_8[int(0)]; _S854 = nullptr; - _S853 = &points_8[int(0)]; - _S852 = nullptr; - _S851 = nullptr; - _S850 = _S860; + _S853 = nullptr; + _S852 = _S862; 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_42 = (pix_center_8 + make_float2 (0.0f, -1.0f) - _S856) / _S857; - FixedArray _S863 = dist_coeffs_17; + float2 uv_42 = (pix_center_8 + make_float2 (0.0f, -1.0f) - _S858) / _S859; + FixedArray _S865 = dist_coeffs_17; float2 uv_u_21; - bool _S864 = undistort_point_1(uv_42, &_S863, int(12), &uv_u_21); - if(!_S864) + bool _S866 = undistort_point_1(uv_42, &_S865, int(12), &uv_u_21); + if(!_S866) { - _S855 = int(0); - _S854 = &points_8[int(1)]; - _S853 = &points_8[int(0)]; - _S852 = nullptr; - _S851 = nullptr; - _S850 = _S860; + _S857 = int(0); + _S856 = &points_8[int(1)]; + _S855 = &points_8[int(0)]; + _S854 = nullptr; + _S853 = nullptr; + _S852 = _S862; 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_43 = (pix_center_8 + make_float2 (0.0f, 1.0f) - _S856) / _S857; - FixedArray _S865 = dist_coeffs_17; + float2 uv_43 = (pix_center_8 + make_float2 (0.0f, 1.0f) - _S858) / _S859; + FixedArray _S867 = dist_coeffs_17; float2 uv_u_22; - bool _S866 = undistort_point_1(uv_43, &_S865, int(12), &uv_u_22); - if(!_S866) + bool _S868 = undistort_point_1(uv_43, &_S867, int(12), &uv_u_22); + if(!_S868) { - _S855 = int(0); - _S854 = &points_8[int(1)]; - _S853 = &points_8[int(0)]; - _S852 = nullptr; - _S851 = &points_8[int(2)]; - _S850 = _S860; + _S857 = int(0); + _S856 = &points_8[int(1)]; + _S855 = &points_8[int(0)]; + _S854 = nullptr; + _S853 = &points_8[int(2)]; + _S852 = _S862; 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_44 = (pix_center_8 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S856) / _S857; - FixedArray _S867 = dist_coeffs_17; + float2 uv_44 = (pix_center_8 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S858) / _S859; + FixedArray _S869 = dist_coeffs_17; float2 uv_u_23; - bool _S868 = undistort_point_1(uv_44, &_S867, int(12), &uv_u_23); - if(!_S868) + bool _S870 = undistort_point_1(uv_44, &_S869, int(12), &uv_u_23); + if(!_S870) { - _S855 = int(0); - _S854 = &points_8[int(1)]; - _S853 = &points_8[int(0)]; - _S852 = &points_8[int(3)]; - _S851 = &points_8[int(2)]; - _S850 = _S860; + _S857 = int(0); + _S856 = &points_8[int(1)]; + _S855 = &points_8[int(0)]; + _S854 = &points_8[int(3)]; + _S853 = &points_8[int(2)]; + _S852 = _S862; break; } float3 raydir_14 = unproject_raydir_0(uv_u_23, camera_model_16, is_ray_depth_14); - _S855 = int(1); - _S854 = &points_8[int(1)]; - _S853 = &points_8[int(0)]; - _S852 = &points_8[int(3)]; - _S851 = &points_8[int(2)]; - _S850 = raydir_14; + _S857 = int(1); + _S856 = &points_8[int(1)]; + _S855 = &points_8[int(0)]; + _S854 = &points_8[int(3)]; + _S853 = &points_8[int(2)]; + _S852 = raydir_14; break; } - if(_S855 != int(1)) + if(_S857 != int(1)) { - _S849 = 0.0f; + _S851 = 0.0f; break; } - float3 normal_9 = cross_0(*_S854 - *_S853, - (*_S852 - *_S851)); + float3 normal_9 = cross_0(*_S856 - *_S855, - (*_S854 - *_S853)); float3 normal_10; if((dot_0(normal_9, normal_9)) != 0.0f) { @@ -4465,25 +4489,23 @@ inline __device__ float depth_normal_loss_opencv(float2 pix_center_8, float4 i { normal_10 = normal_9; } - float3 _S869; + float3 _S871; if((dot_0(gt_normal_2, gt_normal_2)) != 0.0f) { - _S869 = normalize_0(gt_normal_2); + _S871 = normalize_0(gt_normal_2); } else { - _S869 = gt_normal_2; + _S871 = gt_normal_2; } - _S849 = (1.0f - dot_0(normal_10, _S869) + 0.00100000004749745f) / ((F32_max((dot_0(normal_10, - normalize_0(_S850))), (0.0f))) + 0.00100000004749745f); + _S851 = (1.0f - dot_0(normal_10, _S871) + 0.00100000004749745f) / ((F32_max((dot_0(normal_10, - normalize_0(_S852))), (0.0f))) + 0.00100000004749745f); break; } - return _S849; + return _S851; } struct s_bwd_prop_depth_normal_loss_Intermediates_1 { - float2 _S870; - bool _S871; float2 _S872; bool _S873; float2 _S874; @@ -4492,122 +4514,124 @@ struct s_bwd_prop_depth_normal_loss_Intermediates_1 bool _S877; float2 _S878; bool _S879; + float2 _S880; + bool _S881; }; inline __device__ void depth_normal_loss_vjp_opencv(float2 pix_center_9, float4 intrins_15, FixedArray dist_coeffs_18, 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 _S880 = make_float2 (0.0f); - s_bwd_prop_depth_normal_loss_Intermediates_1 _S881; - (&_S881)->_S870 = _S880; - (&_S881)->_S871 = false; - (&_S881)->_S872 = _S880; - (&_S881)->_S873 = false; - (&_S881)->_S874 = _S880; - (&_S881)->_S875 = false; - (&_S881)->_S876 = _S880; - (&_S881)->_S877 = false; - (&_S881)->_S878 = _S880; - (&_S881)->_S879 = false; - (&_S881)->_S872 = _S880; - (&_S881)->_S873 = false; - (&_S881)->_S874 = _S880; - (&_S881)->_S875 = false; - (&_S881)->_S876 = _S880; - (&_S881)->_S877 = false; - (&_S881)->_S878 = _S880; - (&_S881)->_S879 = false; - float2 _S882 = float2 {intrins_15.z, intrins_15.w}; - float2 _S883 = float2 {intrins_15.x, intrins_15.y}; - float2 uv_45 = (pix_center_9 + make_float2 (-1.0f, -0.0f) - _S882) / _S883; - float2 _S884 = _S880; - FixedArray _S885 = dist_coeffs_18; - bool _S886 = undistort_point_1(uv_45, &_S885, int(12), &_S884); - (&_S881)->_S870 = _S884; - (&_S881)->_S871 = _S886; - bool _S887 = !!_S886; + float2 _S882 = make_float2 (0.0f); + s_bwd_prop_depth_normal_loss_Intermediates_1 _S883; + (&_S883)->_S872 = _S882; + (&_S883)->_S873 = false; + (&_S883)->_S874 = _S882; + (&_S883)->_S875 = false; + (&_S883)->_S876 = _S882; + (&_S883)->_S877 = false; + (&_S883)->_S878 = _S882; + (&_S883)->_S879 = false; + (&_S883)->_S880 = _S882; + (&_S883)->_S881 = false; + (&_S883)->_S874 = _S882; + (&_S883)->_S875 = false; + (&_S883)->_S876 = _S882; + (&_S883)->_S877 = false; + (&_S883)->_S878 = _S882; + (&_S883)->_S879 = false; + (&_S883)->_S880 = _S882; + (&_S883)->_S881 = false; + float2 _S884 = float2 {intrins_15.z, intrins_15.w}; + float2 _S885 = float2 {intrins_15.x, intrins_15.y}; + float2 uv_45 = (pix_center_9 + make_float2 (-1.0f, -0.0f) - _S884) / _S885; + float2 _S886 = _S882; + FixedArray _S887 = dist_coeffs_18; + bool _S888 = undistort_point_1(uv_45, &_S887, int(12), &_S886); + (&_S883)->_S872 = _S886; + (&_S883)->_S873 = _S888; + bool _S889 = !!_S888; bool _runFlag_15; - if(_S887) + if(_S889) { - float2 uv_46 = (pix_center_9 + make_float2 (1.0f, -0.0f) - _S882) / _S883; - float2 _S888 = _S880; - FixedArray _S889 = dist_coeffs_18; - bool _S890 = undistort_point_1(uv_46, &_S889, int(12), &_S888); - (&_S881)->_S872 = _S888; - (&_S881)->_S873 = _S890; - if(!_S890) + float2 uv_46 = (pix_center_9 + make_float2 (1.0f, -0.0f) - _S884) / _S885; + float2 _S890 = _S882; + FixedArray _S891 = dist_coeffs_18; + bool _S892 = undistort_point_1(uv_46, &_S891, int(12), &_S890); + (&_S883)->_S874 = _S890; + (&_S883)->_S875 = _S892; + if(!_S892) { _runFlag_15 = false; } else { - _runFlag_15 = _S887; + _runFlag_15 = _S889; } if(_runFlag_15) { - float2 uv_47 = (pix_center_9 + make_float2 (0.0f, -1.0f) - _S882) / _S883; - float2 _S891 = _S880; - FixedArray _S892 = dist_coeffs_18; - bool _S893 = undistort_point_1(uv_47, &_S892, int(12), &_S891); - (&_S881)->_S874 = _S891; - (&_S881)->_S875 = _S893; - if(!_S893) + float2 uv_47 = (pix_center_9 + make_float2 (0.0f, -1.0f) - _S884) / _S885; + float2 _S893 = _S882; + FixedArray _S894 = dist_coeffs_18; + bool _S895 = undistort_point_1(uv_47, &_S894, int(12), &_S893); + (&_S883)->_S876 = _S893; + (&_S883)->_S877 = _S895; + if(!_S895) { _runFlag_15 = false; } if(_runFlag_15) { - float2 uv_48 = (pix_center_9 + make_float2 (0.0f, 1.0f) - _S882) / _S883; - float2 _S894 = _S880; - FixedArray _S895 = dist_coeffs_18; - bool _S896 = undistort_point_1(uv_48, &_S895, int(12), &_S894); - (&_S881)->_S876 = _S894; - (&_S881)->_S877 = _S896; - if(!_S896) + float2 uv_48 = (pix_center_9 + make_float2 (0.0f, 1.0f) - _S884) / _S885; + float2 _S896 = _S882; + FixedArray _S897 = dist_coeffs_18; + bool _S898 = undistort_point_1(uv_48, &_S897, int(12), &_S896); + (&_S883)->_S878 = _S896; + (&_S883)->_S879 = _S898; + if(!_S898) { _runFlag_15 = false; } if(_runFlag_15) { - float2 uv_49 = (pix_center_9 - _S882) / _S883; - float2 _S897 = _S880; - FixedArray _S898 = dist_coeffs_18; - bool _S899 = undistort_point_1(uv_49, &_S898, int(12), &_S897); - (&_S881)->_S878 = _S897; - (&_S881)->_S879 = _S899; + float2 uv_49 = (pix_center_9 - _S884) / _S885; + float2 _S899 = _S882; + FixedArray _S900 = dist_coeffs_18; + bool _S901 = undistort_point_1(uv_49, &_S900, int(12), &_S899); + (&_S883)->_S880 = _S899; + (&_S883)->_S881 = _S901; } } } } - s_bwd_prop_depth_normal_loss_Intermediates_1 _S900 = _S881; - float3 _S901 = make_float3 (0.0f); - bool _S902 = !!_S881._S871; + s_bwd_prop_depth_normal_loss_Intermediates_1 _S902 = _S883; + float3 _S903 = make_float3 (0.0f); + bool _S904 = !!_S883._S873; bool _runFlag_16; bool _runFlag_17; bool _runFlag_18; - int _S903; + int _S905; float3 raydir_15; - float3 _S904; - float3 _S905; float3 _S906; float3 _S907; + float3 _S908; + float3 _S909; FixedArray points_9; - if(_S902) + if(_S904) { - float3 _S908 = s_primal_ctx_unproject_raydir_0(_S900._S870, camera_model_17, is_ray_depth_15); - float3 _S909 = make_float3 (depths_7.x) * _S908; - if(!_S900._S873) + float3 _S910 = s_primal_ctx_unproject_raydir_0(_S902._S872, camera_model_17, is_ray_depth_15); + float3 _S911 = make_float3 (depths_7.x) * _S910; + if(!_S902._S875) { _runFlag_15 = false; } else { - _runFlag_15 = _S902; + _runFlag_15 = _S904; } if(_runFlag_15) { - float3 _S910 = s_primal_ctx_unproject_raydir_0(_S900._S872, camera_model_17, is_ray_depth_15); - float3 _S911 = make_float3 (depths_7.y) * _S910; - if(!_S900._S875) + float3 _S912 = s_primal_ctx_unproject_raydir_0(_S902._S874, camera_model_17, is_ray_depth_15); + float3 _S913 = make_float3 (depths_7.y) * _S912; + if(!_S902._S877) { _runFlag_16 = false; } @@ -4617,9 +4641,9 @@ inline __device__ void depth_normal_loss_vjp_opencv(float2 pix_center_9, float4 } if(_runFlag_16) { - float3 _S912 = s_primal_ctx_unproject_raydir_0(_S900._S874, camera_model_17, is_ray_depth_15); - float3 _S913 = make_float3 (depths_7.z) * _S912; - if(!_S900._S877) + float3 _S914 = s_primal_ctx_unproject_raydir_0(_S902._S876, camera_model_17, is_ray_depth_15); + float3 _S915 = make_float3 (depths_7.z) * _S914; + if(!_S902._S879) { _runFlag_17 = false; } @@ -4629,9 +4653,9 @@ inline __device__ void depth_normal_loss_vjp_opencv(float2 pix_center_9, float4 } if(_runFlag_17) { - float3 _S914 = s_primal_ctx_unproject_raydir_0(_S900._S876, camera_model_17, is_ray_depth_15); - float3 _S915 = make_float3 (depths_7.w) * _S914; - if(!_S900._S879) + float3 _S916 = s_primal_ctx_unproject_raydir_0(_S902._S878, camera_model_17, is_ray_depth_15); + float3 _S917 = make_float3 (depths_7.w) * _S916; + if(!_S902._S881) { _runFlag_18 = false; } @@ -4641,256 +4665,256 @@ inline __device__ void depth_normal_loss_vjp_opencv(float2 pix_center_9, float4 } if(_runFlag_18) { - float3 _S916 = s_primal_ctx_unproject_raydir_0(_S900._S878, camera_model_17, is_ray_depth_15); - _S903 = int(1); - raydir_15 = _S916; + float3 _S918 = s_primal_ctx_unproject_raydir_0(_S902._S880, camera_model_17, is_ray_depth_15); + _S905 = int(1); + raydir_15 = _S918; } else { - _S903 = int(0); - raydir_15 = _S914; + _S905 = int(0); + raydir_15 = _S916; } - points_9[int(0)] = _S909; - points_9[int(1)] = _S911; - points_9[int(2)] = _S913; - points_9[int(3)] = _S915; - points_9[int(4)] = _S901; - _S904 = _S914; + points_9[int(0)] = _S911; + points_9[int(1)] = _S913; + points_9[int(2)] = _S915; + points_9[int(3)] = _S917; + points_9[int(4)] = _S903; + _S906 = _S916; } else { - _S903 = int(0); - raydir_15 = _S912; - points_9[int(0)] = _S909; - points_9[int(1)] = _S911; - points_9[int(2)] = _S913; - points_9[int(3)] = _S901; - points_9[int(4)] = _S901; - _S904 = _S901; + _S905 = int(0); + raydir_15 = _S914; + points_9[int(0)] = _S911; + points_9[int(1)] = _S913; + points_9[int(2)] = _S915; + points_9[int(3)] = _S903; + points_9[int(4)] = _S903; + _S906 = _S903; } - _S905 = _S912; + _S907 = _S914; } else { - _S903 = int(0); - raydir_15 = _S910; - points_9[int(0)] = _S909; - points_9[int(1)] = _S911; - points_9[int(2)] = _S901; - points_9[int(3)] = _S901; - points_9[int(4)] = _S901; + _S905 = int(0); + raydir_15 = _S912; + points_9[int(0)] = _S911; + points_9[int(1)] = _S913; + points_9[int(2)] = _S903; + points_9[int(3)] = _S903; + points_9[int(4)] = _S903; _runFlag_17 = false; - _S904 = _S901; - _S905 = _S901; + _S906 = _S903; + _S907 = _S903; } - _S906 = _S910; + _S908 = _S912; } else { - _S903 = int(0); - raydir_15 = _S908; - points_9[int(0)] = _S909; - points_9[int(1)] = _S901; - points_9[int(2)] = _S901; - points_9[int(3)] = _S901; - points_9[int(4)] = _S901; + _S905 = int(0); + raydir_15 = _S910; + points_9[int(0)] = _S911; + points_9[int(1)] = _S903; + points_9[int(2)] = _S903; + points_9[int(3)] = _S903; + points_9[int(4)] = _S903; _runFlag_16 = false; _runFlag_17 = false; - _S904 = _S901; - _S905 = _S901; - _S906 = _S901; + _S906 = _S903; + _S907 = _S903; + _S908 = _S903; } - _S907 = _S908; + _S909 = _S910; } else { - _S903 = int(0); - points_9[int(0)] = _S901; - points_9[int(1)] = _S901; - points_9[int(2)] = _S901; - points_9[int(3)] = _S901; - points_9[int(4)] = _S901; + _S905 = int(0); + points_9[int(0)] = _S903; + points_9[int(1)] = _S903; + points_9[int(2)] = _S903; + points_9[int(3)] = _S903; + points_9[int(4)] = _S903; _runFlag_15 = false; _runFlag_16 = false; _runFlag_17 = false; - _S904 = _S901; - _S905 = _S901; - _S906 = _S901; - _S907 = _S901; + _S906 = _S903; + _S907 = _S903; + _S908 = _S903; + _S909 = _S903; } - bool _S917 = !(_S903 != int(1)); - bool _S918; + bool _S919 = !(_S905 != int(1)); + bool _S920; float3 normal_11; - float3 _S919; - float3 _S920; float3 _S921; float3 _S922; - float _S923; - float _S924; + float3 _S923; + float3 _S924; float _S925; float _S926; - if(_S917) + float _S927; + float _S928; + if(_S919) { float3 dx_4 = points_9[int(1)] - points_9[int(0)]; - float3 _S927 = - (points_9[int(3)] - points_9[int(2)]); - float3 _S928 = s_primal_ctx_cross_0(dx_4, _S927); - bool _S929 = (s_primal_ctx_dot_0(_S928, _S928)) != 0.0f; - if(_S929) + float3 _S929 = - (points_9[int(3)] - points_9[int(2)]); + float3 _S930 = s_primal_ctx_cross_0(dx_4, _S929); + bool _S931 = (s_primal_ctx_dot_0(_S930, _S930)) != 0.0f; + if(_S931) { - normal_11 = normalize_0(_S928); + normal_11 = normalize_0(_S930); } else { - normal_11 = _S928; + normal_11 = _S930; } - bool _S930 = (s_primal_ctx_dot_0(gt_normal_3, gt_normal_3)) != 0.0f; - if(_S930) + bool _S932 = (s_primal_ctx_dot_0(gt_normal_3, gt_normal_3)) != 0.0f; + if(_S932) { - _S919 = normalize_0(gt_normal_3); + _S921 = normalize_0(gt_normal_3); } else { - _S919 = gt_normal_3; + _S921 = gt_normal_3; } - float3 _S931 = - normalize_0(raydir_15); - float _S932 = s_primal_ctx_dot_0(normal_11, _S931); - float _S933 = 1.0f - s_primal_ctx_dot_0(normal_11, _S919) + 0.00100000004749745f; - float _S934 = (F32_max((_S932), (0.0f))) + 0.00100000004749745f; - _S923 = _S934 * _S934; - _S924 = _S933; - _S925 = _S934; - _S926 = _S932; + float3 _S933 = - normalize_0(raydir_15); + float _S934 = s_primal_ctx_dot_0(normal_11, _S933); + float _S935 = 1.0f - s_primal_ctx_dot_0(normal_11, _S921) + 0.00100000004749745f; + float _S936 = (F32_max((_S934), (0.0f))) + 0.00100000004749745f; + _S925 = _S936 * _S936; + _S926 = _S935; + _S927 = _S936; + _S928 = _S934; raydir_15 = normal_11; - normal_11 = _S931; - _runFlag_18 = _S930; - _S918 = _S929; - _S920 = _S928; - _S921 = dx_4; - _S922 = _S927; + normal_11 = _S933; + _runFlag_18 = _S932; + _S920 = _S931; + _S922 = _S930; + _S923 = dx_4; + _S924 = _S929; } else { - _S923 = 0.0f; - _S924 = 0.0f; _S925 = 0.0f; _S926 = 0.0f; - raydir_15 = _S901; - normal_11 = _S901; - _S919 = _S901; + _S927 = 0.0f; + _S928 = 0.0f; + raydir_15 = _S903; + normal_11 = _S903; + _S921 = _S903; _runFlag_18 = false; - _S918 = false; - _S920 = _S901; - _S921 = _S901; - _S922 = _S901; + _S920 = false; + _S922 = _S903; + _S923 = _S903; + _S924 = _S903; } - float4 _S935 = make_float4 (0.0f); - if(_S917) + float4 _S937 = make_float4 (0.0f); + if(_S919) { - float _S936 = v_loss_1 / _S923; - float _S937 = _S924 * - _S936; - float s_diff_num_T_1 = _S925 * _S936; - DiffPair_float_0 _S938; - (&_S938)->primal_0 = _S926; - (&_S938)->differential_0 = 0.0f; - DiffPair_float_0 _S939; - (&_S939)->primal_0 = 0.0f; - (&_S939)->differential_0 = 0.0f; - _d_max_0(&_S938, &_S939, _S937); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S940; - (&_S940)->primal_0 = raydir_15; - (&_S940)->differential_0 = _S901; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S941; - (&_S941)->primal_0 = normal_11; - (&_S941)->differential_0 = _S901; - s_bwd_prop_dot_0(&_S940, &_S941, _S938.differential_0); - float _S942 = - s_diff_num_T_1; + float _S938 = v_loss_1 / _S925; + float _S939 = _S926 * - _S938; + float s_diff_num_T_1 = _S927 * _S938; + DiffPair_float_0 _S940; + (&_S940)->primal_0 = _S928; + (&_S940)->differential_0 = 0.0f; + DiffPair_float_0 _S941; + (&_S941)->primal_0 = 0.0f; + (&_S941)->differential_0 = 0.0f; + _d_max_0(&_S940, &_S941, _S939); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S942; + (&_S942)->primal_0 = raydir_15; + (&_S942)->differential_0 = _S903; DiffPair_vectorx3Cfloatx2C3x3E_0 _S943; - (&_S943)->primal_0 = raydir_15; - (&_S943)->differential_0 = _S901; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S944; - (&_S944)->primal_0 = _S919; - (&_S944)->differential_0 = _S901; - s_bwd_prop_dot_0(&_S943, &_S944, _S942); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S945 = _S944; - float3 _S946 = _S940.differential_0 + _S943.differential_0; + (&_S943)->primal_0 = normal_11; + (&_S943)->differential_0 = _S903; + s_bwd_prop_dot_0(&_S942, &_S943, _S940.differential_0); + float _S944 = - s_diff_num_T_1; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S945; + (&_S945)->primal_0 = raydir_15; + (&_S945)->differential_0 = _S903; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S946; + (&_S946)->primal_0 = _S921; + (&_S946)->differential_0 = _S903; + s_bwd_prop_dot_0(&_S945, &_S946, _S944); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S947 = _S946; + float3 _S948 = _S942.differential_0 + _S945.differential_0; if(_runFlag_18) { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S947; - (&_S947)->primal_0 = gt_normal_3; - (&_S947)->differential_0 = _S901; - s_bwd_normalize_impl_0(&_S947, _S945.differential_0); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S949; + (&_S949)->primal_0 = gt_normal_3; + (&_S949)->differential_0 = _S903; + s_bwd_normalize_impl_0(&_S949, _S947.differential_0); + raydir_15 = _S949.differential_0; + } + else + { raydir_15 = _S947.differential_0; } - else + DiffPair_vectorx3Cfloatx2C3x3E_0 _S950; + (&_S950)->primal_0 = gt_normal_3; + (&_S950)->differential_0 = _S903; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S951; + (&_S951)->primal_0 = gt_normal_3; + (&_S951)->differential_0 = _S903; + s_bwd_prop_dot_0(&_S950, &_S951, 0.0f); + float3 _S952 = _S951.differential_0 + _S950.differential_0 + raydir_15; + if(_S920) { - raydir_15 = _S945.differential_0; - } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S948; - (&_S948)->primal_0 = gt_normal_3; - (&_S948)->differential_0 = _S901; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S949; - (&_S949)->primal_0 = gt_normal_3; - (&_S949)->differential_0 = _S901; - s_bwd_prop_dot_0(&_S948, &_S949, 0.0f); - float3 _S950 = _S949.differential_0 + _S948.differential_0 + raydir_15; - if(_S918) - { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S951; - (&_S951)->primal_0 = _S920; - (&_S951)->differential_0 = _S901; - s_bwd_normalize_impl_0(&_S951, _S946); - raydir_15 = _S951.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S953; + (&_S953)->primal_0 = _S922; + (&_S953)->differential_0 = _S903; + s_bwd_normalize_impl_0(&_S953, _S948); + raydir_15 = _S953.differential_0; } else { - raydir_15 = _S946; + raydir_15 = _S948; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S952; - (&_S952)->primal_0 = _S920; - (&_S952)->differential_0 = _S901; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S953; - (&_S953)->primal_0 = _S920; - (&_S953)->differential_0 = _S901; - s_bwd_prop_dot_0(&_S952, &_S953, 0.0f); - float3 _S954 = _S953.differential_0 + _S952.differential_0 + raydir_15; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S954; + (&_S954)->primal_0 = _S922; + (&_S954)->differential_0 = _S903; DiffPair_vectorx3Cfloatx2C3x3E_0 _S955; - (&_S955)->primal_0 = _S921; - (&_S955)->differential_0 = _S901; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S956; - (&_S956)->primal_0 = _S922; - (&_S956)->differential_0 = _S901; - s_bwd_prop_cross_0(&_S955, &_S956, _S954); - float3 s_diff_dy_T_4 = - _S956.differential_0; - float3 _S957 = - s_diff_dy_T_4; - float3 _S958 = - _S955.differential_0; - FixedArray _S959; - _S959[int(0)] = _S901; - _S959[int(1)] = _S901; - _S959[int(2)] = _S901; - _S959[int(3)] = _S901; - _S959[int(4)] = _S901; - _S959[int(2)] = _S957; - _S959[int(3)] = s_diff_dy_T_4; - _S959[int(0)] = _S958; - _S959[int(1)] = _S955.differential_0; - points_9[int(0)] = _S959[int(0)]; - points_9[int(1)] = _S959[int(1)]; - points_9[int(2)] = _S959[int(2)]; - points_9[int(3)] = _S959[int(3)]; - points_9[int(4)] = _S959[int(4)]; - raydir_15 = _S950; + (&_S955)->primal_0 = _S922; + (&_S955)->differential_0 = _S903; + s_bwd_prop_dot_0(&_S954, &_S955, 0.0f); + float3 _S956 = _S955.differential_0 + _S954.differential_0 + raydir_15; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S957; + (&_S957)->primal_0 = _S923; + (&_S957)->differential_0 = _S903; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S958; + (&_S958)->primal_0 = _S924; + (&_S958)->differential_0 = _S903; + s_bwd_prop_cross_0(&_S957, &_S958, _S956); + float3 s_diff_dy_T_4 = - _S958.differential_0; + float3 _S959 = - s_diff_dy_T_4; + float3 _S960 = - _S957.differential_0; + FixedArray _S961; + _S961[int(0)] = _S903; + _S961[int(1)] = _S903; + _S961[int(2)] = _S903; + _S961[int(3)] = _S903; + _S961[int(4)] = _S903; + _S961[int(2)] = _S959; + _S961[int(3)] = s_diff_dy_T_4; + _S961[int(0)] = _S960; + _S961[int(1)] = _S957.differential_0; + points_9[int(0)] = _S961[int(0)]; + points_9[int(1)] = _S961[int(1)]; + points_9[int(2)] = _S961[int(2)]; + points_9[int(3)] = _S961[int(3)]; + points_9[int(4)] = _S961[int(4)]; + raydir_15 = _S952; } else { - points_9[int(0)] = _S901; - points_9[int(1)] = _S901; - points_9[int(2)] = _S901; - points_9[int(3)] = _S901; - points_9[int(4)] = _S901; - raydir_15 = _S901; + points_9[int(0)] = _S903; + points_9[int(1)] = _S903; + points_9[int(2)] = _S903; + points_9[int(3)] = _S903; + points_9[int(4)] = _S903; + raydir_15 = _S903; } - float4 _S960; - if(_S902) + float4 _S962; + if(_S904) { if(_runFlag_15) { @@ -4898,194 +4922,194 @@ inline __device__ void depth_normal_loss_vjp_opencv(float2 pix_center_9, float4 { if(_runFlag_17) { - FixedArray _S961 = points_9; - FixedArray _S962 = points_9; FixedArray _S963 = points_9; - float3 _S964 = _S904 * points_9[int(3)]; - float _S965 = _S964.x + _S964.y + _S964.z; - float4 _S966 = _S935; - *&((&_S966)->w) = _S965; - points_9[int(0)] = _S901; - points_9[int(1)] = _S901; - points_9[int(2)] = _S901; - points_9[int(3)] = _S901; - points_9[int(4)] = _S901; - _S904 = _S963[int(2)]; - normal_11 = _S961[int(0)]; - _S919 = _S962[int(1)]; - _S960 = _S966; + FixedArray _S964 = points_9; + FixedArray _S965 = points_9; + float3 _S966 = _S906 * points_9[int(3)]; + float _S967 = _S966.x + _S966.y + _S966.z; + float4 _S968 = _S937; + *&((&_S968)->w) = _S967; + points_9[int(0)] = _S903; + points_9[int(1)] = _S903; + points_9[int(2)] = _S903; + points_9[int(3)] = _S903; + points_9[int(4)] = _S903; + _S906 = _S965[int(2)]; + normal_11 = _S963[int(0)]; + _S921 = _S964[int(1)]; + _S962 = _S968; } else { - FixedArray _S967 = points_9; - FixedArray _S968 = points_9; FixedArray _S969 = points_9; FixedArray _S970 = points_9; + FixedArray _S971 = points_9; + FixedArray _S972 = 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)]; - _S904 = _S901; - normal_11 = _S901; - _S919 = _S901; - _S960 = _S935; + points_9[int(1)] = _S969[int(1)]; + points_9[int(2)] = _S970[int(2)]; + points_9[int(3)] = _S971[int(3)]; + points_9[int(4)] = _S972[int(4)]; + _S906 = _S903; + normal_11 = _S903; + _S921 = _S903; + _S962 = _S937; } - float3 _S971 = _S905 * (points_9[int(2)] + _S904); - float _S972 = _S971.x + _S971.y + _S971.z; - float3 _S973 = points_9[int(0)] + normal_11; - float3 _S974 = points_9[int(1)] + _S919; - float4 _S975 = _S935; - *&((&_S975)->z) = _S972; - float4 _S976 = _S960 + _S975; - points_9[int(0)] = _S901; - points_9[int(1)] = _S901; - points_9[int(2)] = _S901; - points_9[int(3)] = _S901; - points_9[int(4)] = _S901; - _S904 = _S974; - _S905 = _S973; - _S960 = _S976; + float3 _S973 = _S907 * (points_9[int(2)] + _S906); + float _S974 = _S973.x + _S973.y + _S973.z; + float3 _S975 = points_9[int(0)] + normal_11; + float3 _S976 = points_9[int(1)] + _S921; + float4 _S977 = _S937; + *&((&_S977)->z) = _S974; + float4 _S978 = _S962 + _S977; + points_9[int(0)] = _S903; + points_9[int(1)] = _S903; + points_9[int(2)] = _S903; + points_9[int(3)] = _S903; + points_9[int(4)] = _S903; + _S906 = _S976; + _S907 = _S975; + _S962 = _S978; } else { - FixedArray _S977 = points_9; - FixedArray _S978 = points_9; FixedArray _S979 = points_9; FixedArray _S980 = points_9; + FixedArray _S981 = points_9; + FixedArray _S982 = points_9; points_9[int(0)] = points_9[int(0)]; - points_9[int(1)] = _S977[int(1)]; - points_9[int(2)] = _S978[int(2)]; - points_9[int(3)] = _S979[int(3)]; - points_9[int(4)] = _S980[int(4)]; - _S904 = _S901; - _S905 = _S901; - _S960 = _S935; + points_9[int(1)] = _S979[int(1)]; + points_9[int(2)] = _S980[int(2)]; + points_9[int(3)] = _S981[int(3)]; + points_9[int(4)] = _S982[int(4)]; + _S906 = _S903; + _S907 = _S903; + _S962 = _S937; } - float3 _S981 = _S906 * (points_9[int(1)] + _S904); - float _S982 = _S981.x + _S981.y + _S981.z; - float3 _S983 = points_9[int(0)] + _S905; - float4 _S984 = _S935; - *&((&_S984)->y) = _S982; - float4 _S985 = _S960 + _S984; - points_9[int(0)] = _S901; - points_9[int(1)] = _S901; - points_9[int(2)] = _S901; - points_9[int(3)] = _S901; - points_9[int(4)] = _S901; - _S904 = _S983; - _S960 = _S985; + float3 _S983 = _S908 * (points_9[int(1)] + _S906); + float _S984 = _S983.x + _S983.y + _S983.z; + float3 _S985 = points_9[int(0)] + _S907; + float4 _S986 = _S937; + *&((&_S986)->y) = _S984; + float4 _S987 = _S962 + _S986; + points_9[int(0)] = _S903; + points_9[int(1)] = _S903; + points_9[int(2)] = _S903; + points_9[int(3)] = _S903; + points_9[int(4)] = _S903; + _S906 = _S985; + _S962 = _S987; } else { - FixedArray _S986 = points_9; - FixedArray _S987 = points_9; FixedArray _S988 = points_9; FixedArray _S989 = points_9; + FixedArray _S990 = points_9; + FixedArray _S991 = points_9; points_9[int(0)] = points_9[int(0)]; - points_9[int(1)] = _S986[int(1)]; - points_9[int(2)] = _S987[int(2)]; - points_9[int(3)] = _S988[int(3)]; - points_9[int(4)] = _S989[int(4)]; - _S904 = _S901; - _S960 = _S935; + points_9[int(1)] = _S988[int(1)]; + points_9[int(2)] = _S989[int(2)]; + points_9[int(3)] = _S990[int(3)]; + points_9[int(4)] = _S991[int(4)]; + _S906 = _S903; + _S962 = _S937; } - float3 _S990 = _S907 * (points_9[int(0)] + _S904); - float _S991 = _S990.x + _S990.y + _S990.z; - float4 _S992 = _S935; - *&((&_S992)->x) = _S991; - _S960 = _S960 + _S992; + float3 _S992 = _S909 * (points_9[int(0)] + _S906); + float _S993 = _S992.x + _S992.y + _S992.z; + float4 _S994 = _S937; + *&((&_S994)->x) = _S993; + _S962 = _S962 + _S994; } else { - _S960 = _S935; + _S962 = _S937; } - *v_depths_3 = _S960; + *v_depths_3 = _S962; *v_gt_normal_1 = raydir_15; return; } inline __device__ float3 generate_ray_d2n_prism(float2 pix_pos_6, float4 intrins_16, FixedArray dist_coeffs_19, int camera_model_18, bool is_ray_depth_16) { - float3 _S993; + float3 _S995; for(;;) { float2 uv_50 = (pix_pos_6 - float2 {intrins_16.z, intrins_16.w}) / float2 {intrins_16.x, intrins_16.y}; - FixedArray _S994 = dist_coeffs_19; + FixedArray _S996 = dist_coeffs_19; float2 uv_u_24; - bool _S995 = undistort_point_2(uv_50, &_S994, int(12), &uv_u_24); - if(!_S995) + bool _S997 = undistort_point_2(uv_50, &_S996, int(12), &uv_u_24); + if(!_S997) { - int3 _S996 = make_int3 (int(0)); - float3 _S997 = make_float3 ((float)_S996.x, (float)_S996.y, (float)_S996.z); - _S993 = _S997; + int3 _S998 = make_int3 (int(0)); + float3 _S999 = make_float3 ((float)_S998.x, (float)_S998.y, (float)_S998.z); + _S995 = _S999; break; } - _S993 = unproject_raydir_0(uv_u_24, camera_model_18, is_ray_depth_16); + _S995 = unproject_raydir_0(uv_u_24, camera_model_18, is_ray_depth_16); break; } - return _S993; + return _S995; } inline __device__ float3 depth_to_point_prism(float2 pix_pos_7, float4 intrins_17, FixedArray dist_coeffs_20, int camera_model_19, bool is_ray_depth_17, float depth_6) { - float3 _S998; + float3 _S1000; for(;;) { float2 uv_51 = (pix_pos_7 - float2 {intrins_17.z, intrins_17.w}) / float2 {intrins_17.x, intrins_17.y}; - FixedArray _S999 = dist_coeffs_20; + FixedArray _S1001 = dist_coeffs_20; float2 uv_u_25; - bool _S1000 = undistort_point_2(uv_51, &_S999, int(12), &uv_u_25); - if(!_S1000) + bool _S1002 = undistort_point_2(uv_51, &_S1001, int(12), &uv_u_25); + if(!_S1002) { - _S998 = make_float3 (0.0f); + _S1000 = make_float3 (0.0f); break; } - _S998 = make_float3 (depth_6) * unproject_raydir_0(uv_u_25, camera_model_19, is_ray_depth_17); + _S1000 = make_float3 (depth_6) * unproject_raydir_0(uv_u_25, camera_model_19, is_ray_depth_17); break; } - return _S998; + return _S1000; } struct s_bwd_prop_depth_to_point_Intermediates_2 { - float2 _S1001; - bool _S1002; + float2 _S1003; + bool _S1004; }; inline __device__ float depth_to_point_vjp_prism(float2 pix_pos_8, float4 intrins_18, FixedArray dist_coeffs_21, int camera_model_20, bool is_ray_depth_18, float depth_7, float3 v_point_2) { - float2 _S1003 = make_float2 (0.0f); - s_bwd_prop_depth_to_point_Intermediates_2 _S1004; - (&_S1004)->_S1001 = _S1003; - (&_S1004)->_S1002 = false; + float2 _S1005 = make_float2 (0.0f); + s_bwd_prop_depth_to_point_Intermediates_2 _S1006; + (&_S1006)->_S1003 = _S1005; + (&_S1006)->_S1004 = false; float2 uv_52 = (pix_pos_8 - float2 {intrins_18.z, intrins_18.w}) / float2 {intrins_18.x, intrins_18.y}; - float2 _S1005 = _S1003; - FixedArray _S1006 = dist_coeffs_21; - bool _S1007 = undistort_point_2(uv_52, &_S1006, int(12), &_S1005); - (&_S1004)->_S1001 = _S1005; - (&_S1004)->_S1002 = _S1007; - s_bwd_prop_depth_to_point_Intermediates_2 _S1008 = _S1004; - float3 _S1009 = make_float3 (0.0f); - bool _S1010 = !!_S1004._S1002; - float3 _S1011; - if(_S1010) + float2 _S1007 = _S1005; + FixedArray _S1008 = dist_coeffs_21; + bool _S1009 = undistort_point_2(uv_52, &_S1008, int(12), &_S1007); + (&_S1006)->_S1003 = _S1007; + (&_S1006)->_S1004 = _S1009; + s_bwd_prop_depth_to_point_Intermediates_2 _S1010 = _S1006; + float3 _S1011 = make_float3 (0.0f); + bool _S1012 = !!_S1006._S1004; + float3 _S1013; + if(_S1012) { - _S1011 = s_primal_ctx_unproject_raydir_0(_S1008._S1001, camera_model_20, is_ray_depth_18); + _S1013 = s_primal_ctx_unproject_raydir_0(_S1010._S1003, camera_model_20, is_ray_depth_18); } else { - _S1011 = _S1009; + _S1013 = _S1011; } - if(_S1010) + if(_S1012) { - _S1011 = _S1011 * v_point_2; + _S1013 = _S1013 * v_point_2; } else { - _S1011 = _S1009; + _S1013 = _S1011; } - return _S1011.x + _S1011.y + _S1011.z; + return _S1013.x + _S1013.y + _S1013.z; } inline __device__ float3 depth_to_normal_prism(float2 pix_center_10, float4 intrins_19, FixedArray dist_coeffs_22, int camera_model_21, bool is_ray_depth_19, float4 depths_8) @@ -5093,142 +5117,142 @@ inline __device__ float3 depth_to_normal_prism(float2 pix_center_10, float4 i float3 normal_12; for(;;) { - bool _S1012; + bool _S1014; if((depths_8.x) == 0.0f) { - _S1012 = true; + _S1014 = true; } else { - _S1012 = (depths_8.y) == 0.0f; + _S1014 = (depths_8.y) == 0.0f; } - if(_S1012) + if(_S1014) { - _S1012 = true; + _S1014 = true; } else { - _S1012 = (depths_8.z) == 0.0f; + _S1014 = (depths_8.z) == 0.0f; } - if(_S1012) + if(_S1014) { - _S1012 = true; + _S1014 = true; } else { - _S1012 = (depths_8.w) == 0.0f; + _S1014 = (depths_8.w) == 0.0f; } - if(_S1012) + if(_S1014) { normal_12 = make_float3 (0.0f); break; } - float3 * _S1013; - float3 * _S1014; float3 * _S1015; float3 * _S1016; - int _S1017; + float3 * _S1017; + float3 * _S1018; + int _S1019; FixedArray points_10; for(;;) { - float2 _S1018 = float2 {intrins_19.z, intrins_19.w}; - float2 _S1019 = float2 {intrins_19.x, intrins_19.y}; - float2 uv_53 = (pix_center_10 + make_float2 (-1.0f, -0.0f) - _S1018) / _S1019; - FixedArray _S1020 = dist_coeffs_22; + float2 _S1020 = float2 {intrins_19.z, intrins_19.w}; + float2 _S1021 = float2 {intrins_19.x, intrins_19.y}; + float2 uv_53 = (pix_center_10 + make_float2 (-1.0f, -0.0f) - _S1020) / _S1021; + FixedArray _S1022 = dist_coeffs_22; float2 uv_u_26; - bool _S1021 = undistort_point_2(uv_53, &_S1020, int(12), &uv_u_26); - if(!_S1021) + bool _S1023 = undistort_point_2(uv_53, &_S1022, int(12), &uv_u_26); + if(!_S1023) { - float3 _S1022 = make_float3 (0.0f); - _S1017 = int(0); + float3 _S1024 = make_float3 (0.0f); + _S1019 = int(0); + _S1018 = nullptr; + _S1017 = nullptr; _S1016 = nullptr; _S1015 = nullptr; - _S1014 = nullptr; - _S1013 = nullptr; - normal_12 = _S1022; + normal_12 = _S1024; 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_54 = (pix_center_10 + make_float2 (1.0f, -0.0f) - _S1018) / _S1019; - FixedArray _S1023 = dist_coeffs_22; + float2 uv_54 = (pix_center_10 + make_float2 (1.0f, -0.0f) - _S1020) / _S1021; + FixedArray _S1025 = dist_coeffs_22; float2 uv_u_27; - bool _S1024 = undistort_point_2(uv_54, &_S1023, int(12), &uv_u_27); - if(!_S1024) + bool _S1026 = undistort_point_2(uv_54, &_S1025, int(12), &uv_u_27); + if(!_S1026) { - float3 _S1025 = make_float3 (0.0f); - _S1017 = int(0); - _S1016 = nullptr; - normal_12 = _S1025; + float3 _S1027 = make_float3 (0.0f); + _S1019 = int(0); + _S1018 = nullptr; + normal_12 = _S1027; break; } points_10[int(1)] = make_float3 (depths_8.y) * unproject_raydir_0(uv_u_27, camera_model_21, is_ray_depth_19); - _S1017 = int(2); - _S1016 = &points_10[int(1)]; + _S1019 = int(2); + _S1018 = &points_10[int(1)]; break; } - if(_S1017 != int(2)) + if(_S1019 != int(2)) { - _S1015 = &points_10[int(0)]; - _S1014 = nullptr; - _S1013 = nullptr; + _S1017 = &points_10[int(0)]; + _S1016 = nullptr; + _S1015 = nullptr; break; } - float2 uv_55 = (pix_center_10 + make_float2 (0.0f, -1.0f) - _S1018) / _S1019; - FixedArray _S1026 = dist_coeffs_22; + float2 uv_55 = (pix_center_10 + make_float2 (0.0f, -1.0f) - _S1020) / _S1021; + FixedArray _S1028 = dist_coeffs_22; float2 uv_u_28; - bool _S1027 = undistort_point_2(uv_55, &_S1026, int(12), &uv_u_28); - if(!_S1027) + bool _S1029 = undistort_point_2(uv_55, &_S1028, int(12), &uv_u_28); + if(!_S1029) { - float3 _S1028 = make_float3 (0.0f); - _S1017 = int(0); - _S1015 = &points_10[int(0)]; - _S1014 = nullptr; - _S1013 = nullptr; - normal_12 = _S1028; + float3 _S1030 = make_float3 (0.0f); + _S1019 = int(0); + _S1017 = &points_10[int(0)]; + _S1016 = nullptr; + _S1015 = nullptr; + normal_12 = _S1030; 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_56 = (pix_center_10 + make_float2 (0.0f, 1.0f) - _S1018) / _S1019; - FixedArray _S1029 = dist_coeffs_22; + float2 uv_56 = (pix_center_10 + make_float2 (0.0f, 1.0f) - _S1020) / _S1021; + FixedArray _S1031 = dist_coeffs_22; float2 uv_u_29; - bool _S1030 = undistort_point_2(uv_56, &_S1029, int(12), &uv_u_29); - if(!_S1030) + bool _S1032 = undistort_point_2(uv_56, &_S1031, int(12), &uv_u_29); + if(!_S1032) { - float3 _S1031 = make_float3 (0.0f); - _S1017 = int(0); - _S1015 = nullptr; - normal_12 = _S1031; + float3 _S1033 = make_float3 (0.0f); + _S1019 = int(0); + _S1017 = nullptr; + normal_12 = _S1033; break; } points_10[int(3)] = make_float3 (depths_8.w) * unproject_raydir_0(uv_u_29, camera_model_21, is_ray_depth_19); - _S1017 = int(2); - _S1015 = &points_10[int(3)]; + _S1019 = int(2); + _S1017 = &points_10[int(3)]; break; } - if(_S1017 != int(2)) + if(_S1019 != int(2)) { - float3 * _S1032 = _S1015; - _S1015 = &points_10[int(0)]; - _S1014 = _S1032; - _S1013 = &points_10[int(2)]; + float3 * _S1034 = _S1017; + _S1017 = &points_10[int(0)]; + _S1016 = _S1034; + _S1015 = &points_10[int(2)]; break; } - float3 * _S1033 = _S1015; - _S1017 = int(1); - _S1015 = &points_10[int(0)]; - _S1014 = _S1033; - _S1013 = &points_10[int(2)]; + float3 * _S1035 = _S1017; + _S1019 = int(1); + _S1017 = &points_10[int(0)]; + _S1016 = _S1035; + _S1015 = &points_10[int(2)]; break; } - if(_S1017 != int(1)) + if(_S1019 != int(1)) { break; } - float3 normal_13 = cross_0(*_S1016 - *_S1015, - (*_S1014 - *_S1013)); + float3 normal_13 = cross_0(*_S1018 - *_S1017, - (*_S1016 - *_S1015)); if((dot_0(normal_13, normal_13)) != 0.0f) { normal_12 = normal_13 / make_float3 (length_0(normal_13)); @@ -5244,39 +5268,39 @@ inline __device__ float3 depth_to_normal_prism(float2 pix_center_10, float4 i struct s_bwd_prop_depth_to_normal_Intermediates_2 { - float2 _S1034; - bool _S1035; float2 _S1036; bool _S1037; float2 _S1038; bool _S1039; float2 _S1040; bool _S1041; + float2 _S1042; + bool _S1043; }; inline __device__ void depth_to_normal_vjp_prism(float2 pix_center_11, float4 intrins_20, FixedArray dist_coeffs_23, int camera_model_22, bool is_ray_depth_20, float4 depths_9, float3 v_normal_3, float4 * v_depths_4) { - float2 _S1042 = make_float2 (0.0f); - s_bwd_prop_depth_to_normal_Intermediates_2 _S1043; - (&_S1043)->_S1034 = _S1042; - (&_S1043)->_S1035 = false; - (&_S1043)->_S1036 = _S1042; - (&_S1043)->_S1037 = false; - (&_S1043)->_S1038 = _S1042; - (&_S1043)->_S1039 = false; - (&_S1043)->_S1040 = _S1042; - (&_S1043)->_S1041 = false; - (&_S1043)->_S1034 = _S1042; - (&_S1043)->_S1035 = false; - (&_S1043)->_S1036 = _S1042; - (&_S1043)->_S1037 = false; - (&_S1043)->_S1038 = _S1042; - (&_S1043)->_S1039 = false; - (&_S1043)->_S1040 = _S1042; - (&_S1043)->_S1041 = false; - bool _S1044 = (depths_9.x) == 0.0f; + float2 _S1044 = make_float2 (0.0f); + s_bwd_prop_depth_to_normal_Intermediates_2 _S1045; + (&_S1045)->_S1036 = _S1044; + (&_S1045)->_S1037 = false; + (&_S1045)->_S1038 = _S1044; + (&_S1045)->_S1039 = false; + (&_S1045)->_S1040 = _S1044; + (&_S1045)->_S1041 = false; + (&_S1045)->_S1042 = _S1044; + (&_S1045)->_S1043 = false; + (&_S1045)->_S1036 = _S1044; + (&_S1045)->_S1037 = false; + (&_S1045)->_S1038 = _S1044; + (&_S1045)->_S1039 = false; + (&_S1045)->_S1040 = _S1044; + (&_S1045)->_S1041 = false; + (&_S1045)->_S1042 = _S1044; + (&_S1045)->_S1043 = false; + bool _S1046 = (depths_9.x) == 0.0f; bool _runFlag_19; - if(_S1044) + if(_S1046) { _runFlag_19 = true; } @@ -5300,69 +5324,69 @@ inline __device__ void depth_to_normal_vjp_prism(float2 pix_center_11, float4 { _runFlag_19 = (depths_9.w) == 0.0f; } - int _S1045; + int _S1047; if(!_runFlag_19) { - float2 _S1046 = float2 {intrins_20.z, intrins_20.w}; - float2 _S1047 = float2 {intrins_20.x, intrins_20.y}; - float2 uv_57 = (pix_center_11 + make_float2 (-1.0f, -0.0f) - _S1046) / _S1047; - float2 _S1048 = _S1042; - FixedArray _S1049 = dist_coeffs_23; - bool _S1050 = undistort_point_2(uv_57, &_S1049, int(12), &_S1048); - (&_S1043)->_S1034 = _S1048; - (&_S1043)->_S1035 = _S1050; - bool _S1051 = !!_S1050; - if(_S1051) + float2 _S1048 = float2 {intrins_20.z, intrins_20.w}; + float2 _S1049 = float2 {intrins_20.x, intrins_20.y}; + float2 uv_57 = (pix_center_11 + make_float2 (-1.0f, -0.0f) - _S1048) / _S1049; + float2 _S1050 = _S1044; + FixedArray _S1051 = dist_coeffs_23; + bool _S1052 = undistort_point_2(uv_57, &_S1051, int(12), &_S1050); + (&_S1045)->_S1036 = _S1050; + (&_S1045)->_S1037 = _S1052; + bool _S1053 = !!_S1052; + if(_S1053) { - float2 uv_58 = (pix_center_11 + make_float2 (1.0f, -0.0f) - _S1046) / _S1047; - float2 _S1052 = _S1042; - FixedArray _S1053 = dist_coeffs_23; - bool _S1054 = undistort_point_2(uv_58, &_S1053, int(12), &_S1052); - (&_S1043)->_S1036 = _S1052; - (&_S1043)->_S1037 = _S1054; - if(!!_S1054) + float2 uv_58 = (pix_center_11 + make_float2 (1.0f, -0.0f) - _S1048) / _S1049; + float2 _S1054 = _S1044; + FixedArray _S1055 = dist_coeffs_23; + bool _S1056 = undistort_point_2(uv_58, &_S1055, int(12), &_S1054); + (&_S1045)->_S1038 = _S1054; + (&_S1045)->_S1039 = _S1056; + if(!!_S1056) { - _S1045 = int(2); + _S1047 = int(2); } else { - _S1045 = int(0); + _S1047 = int(0); } - if(_S1045 != int(2)) + if(_S1047 != int(2)) { _runFlag_19 = false; } else { - _runFlag_19 = _S1051; + _runFlag_19 = _S1053; } if(_runFlag_19) { - float2 uv_59 = (pix_center_11 + make_float2 (0.0f, -1.0f) - _S1046) / _S1047; - float2 _S1055 = _S1042; - FixedArray _S1056 = dist_coeffs_23; - bool _S1057 = undistort_point_2(uv_59, &_S1056, int(12), &_S1055); - (&_S1043)->_S1038 = _S1055; - (&_S1043)->_S1039 = _S1057; - if(!_S1057) + float2 uv_59 = (pix_center_11 + make_float2 (0.0f, -1.0f) - _S1048) / _S1049; + float2 _S1057 = _S1044; + FixedArray _S1058 = dist_coeffs_23; + bool _S1059 = undistort_point_2(uv_59, &_S1058, int(12), &_S1057); + (&_S1045)->_S1040 = _S1057; + (&_S1045)->_S1041 = _S1059; + if(!_S1059) { _runFlag_19 = false; } if(_runFlag_19) { - float2 uv_60 = (pix_center_11 + make_float2 (0.0f, 1.0f) - _S1046) / _S1047; - float2 _S1058 = _S1042; - FixedArray _S1059 = dist_coeffs_23; - bool _S1060 = undistort_point_2(uv_60, &_S1059, int(12), &_S1058); - (&_S1043)->_S1040 = _S1058; - (&_S1043)->_S1041 = _S1060; + float2 uv_60 = (pix_center_11 + make_float2 (0.0f, 1.0f) - _S1048) / _S1049; + float2 _S1060 = _S1044; + FixedArray _S1061 = dist_coeffs_23; + bool _S1062 = undistort_point_2(uv_60, &_S1061, int(12), &_S1060); + (&_S1045)->_S1042 = _S1060; + (&_S1045)->_S1043 = _S1062; } } } } - s_bwd_prop_depth_to_normal_Intermediates_2 _S1061 = _S1043; - float3 _S1062 = make_float3 (0.0f); - if(_S1044) + s_bwd_prop_depth_to_normal_Intermediates_2 _S1063 = _S1045; + float3 _S1064 = make_float3 (0.0f); + if(_S1046) { _runFlag_19 = true; } @@ -5386,16 +5410,14 @@ inline __device__ void depth_to_normal_vjp_prism(float2 pix_center_11, float4 { _runFlag_19 = (depths_9.w) == 0.0f; } - bool _S1063 = !_runFlag_19; + bool _S1065 = !_runFlag_19; bool _runFlag_20; bool _runFlag_21; - bool _S1064; - bool _runFlag_22; - bool _S1065; bool _S1066; + bool _runFlag_22; + bool _S1067; + bool _S1068; FixedArray points_11; - float3 _S1067; - float3 _S1068; float3 _S1069; float3 _S1070; float3 _S1071; @@ -5403,49 +5425,51 @@ inline __device__ void depth_to_normal_vjp_prism(float2 pix_center_11, float4 float3 _S1073; float3 _S1074; float3 _S1075; - if(_S1063) + float3 _S1076; + float3 _S1077; + if(_S1065) { - bool _S1076 = !!_S1061._S1035; - if(_S1076) + bool _S1078 = !!_S1063._S1037; + if(_S1078) { - float3 _S1077 = s_primal_ctx_unproject_raydir_0(_S1061._S1034, camera_model_22, is_ray_depth_20); - float3 _S1078 = make_float3 (depths_9.x) * _S1077; - bool _S1079 = !!_S1061._S1037; - if(_S1079) + float3 _S1079 = s_primal_ctx_unproject_raydir_0(_S1063._S1036, camera_model_22, is_ray_depth_20); + float3 _S1080 = make_float3 (depths_9.x) * _S1079; + bool _S1081 = !!_S1063._S1039; + if(_S1081) { - float3 _S1080 = s_primal_ctx_unproject_raydir_0(_S1061._S1036, camera_model_22, is_ray_depth_20); - float3 _S1081 = make_float3 (depths_9.y) * _S1080; - _S1045 = int(2); - points_11[int(0)] = _S1078; - points_11[int(1)] = _S1081; - points_11[int(2)] = _S1062; - points_11[int(3)] = _S1062; - _S1067 = _S1080; + float3 _S1082 = s_primal_ctx_unproject_raydir_0(_S1063._S1038, camera_model_22, is_ray_depth_20); + float3 _S1083 = make_float3 (depths_9.y) * _S1082; + _S1047 = int(2); + points_11[int(0)] = _S1080; + points_11[int(1)] = _S1083; + points_11[int(2)] = _S1064; + points_11[int(3)] = _S1064; + _S1069 = _S1082; } else { - _S1045 = int(0); - points_11[int(0)] = _S1078; - points_11[int(1)] = _S1062; - points_11[int(2)] = _S1062; - points_11[int(3)] = _S1062; - _S1067 = _S1062; + _S1047 = int(0); + points_11[int(0)] = _S1080; + points_11[int(1)] = _S1064; + points_11[int(2)] = _S1064; + points_11[int(3)] = _S1064; + _S1069 = _S1064; } - if(_S1045 != int(2)) + if(_S1047 != int(2)) { _runFlag_19 = false; } else { - _runFlag_19 = _S1076; - _S1045 = int(0); + _runFlag_19 = _S1078; + _S1047 = int(0); } if(_runFlag_19) { - if(!_S1061._S1039) + if(!_S1063._S1041) { _runFlag_20 = false; - _S1045 = int(0); + _S1047 = int(0); } else { @@ -5453,26 +5477,26 @@ inline __device__ void depth_to_normal_vjp_prism(float2 pix_center_11, float4 } if(_runFlag_20) { - float3 _S1082 = s_primal_ctx_unproject_raydir_0(_S1061._S1038, camera_model_22, is_ray_depth_20); - points_11[int(2)] = make_float3 (depths_9.z) * _S1082; - bool _S1083 = !!_S1061._S1041; - int _S1084; - if(_S1083) + float3 _S1084 = s_primal_ctx_unproject_raydir_0(_S1063._S1040, camera_model_22, is_ray_depth_20); + points_11[int(2)] = make_float3 (depths_9.z) * _S1084; + bool _S1085 = !!_S1063._S1043; + int _S1086; + if(_S1085) { - float3 _S1085 = s_primal_ctx_unproject_raydir_0(_S1061._S1040, camera_model_22, is_ray_depth_20); - points_11[int(3)] = make_float3 (depths_9.w) * _S1085; - _S1084 = int(2); - _S1068 = _S1085; + float3 _S1087 = s_primal_ctx_unproject_raydir_0(_S1063._S1042, camera_model_22, is_ray_depth_20); + points_11[int(3)] = make_float3 (depths_9.w) * _S1087; + _S1086 = int(2); + _S1070 = _S1087; } else { - _S1084 = int(0); - _S1068 = _S1062; + _S1086 = int(0); + _S1070 = _S1064; } - if(_S1084 != int(2)) + if(_S1086 != int(2)) { _runFlag_21 = false; - _S1045 = _S1084; + _S1047 = _S1086; } else { @@ -5480,437 +5504,437 @@ inline __device__ void depth_to_normal_vjp_prism(float2 pix_center_11, float4 } if(_runFlag_21) { - _S1045 = int(1); + _S1047 = int(1); } - _runFlag_21 = _S1083; - _S1069 = _S1082; + _runFlag_21 = _S1085; + _S1071 = _S1084; } else { _runFlag_21 = false; - _S1068 = _S1062; - _S1069 = _S1062; + _S1070 = _S1064; + _S1071 = _S1064; } } else { _runFlag_20 = false; _runFlag_21 = false; - _S1068 = _S1062; - _S1069 = _S1062; + _S1070 = _S1064; + _S1071 = _S1064; } - float3 _S1086 = _S1067; - _S1067 = _S1068; - _S1068 = _S1069; - _S1064 = _S1079; - _S1069 = _S1086; - _S1070 = _S1077; + float3 _S1088 = _S1069; + _S1069 = _S1070; + _S1070 = _S1071; + _S1066 = _S1081; + _S1071 = _S1088; + _S1072 = _S1079; } else { - _S1045 = int(0); - points_11[int(0)] = _S1062; - points_11[int(1)] = _S1062; - points_11[int(2)] = _S1062; - points_11[int(3)] = _S1062; + _S1047 = int(0); + points_11[int(0)] = _S1064; + points_11[int(1)] = _S1064; + points_11[int(2)] = _S1064; + points_11[int(3)] = _S1064; _runFlag_19 = false; _runFlag_20 = false; _runFlag_21 = false; - _S1067 = _S1062; - _S1068 = _S1062; - _S1064 = false; - _S1069 = _S1062; - _S1070 = _S1062; + _S1069 = _S1064; + _S1070 = _S1064; + _S1066 = false; + _S1071 = _S1064; + _S1072 = _S1064; } - if(_S1045 != int(1)) + if(_S1047 != int(1)) { _runFlag_22 = false; } else { - _runFlag_22 = _S1063; + _runFlag_22 = _S1065; } if(_runFlag_22) { float3 dx_5 = points_11[int(1)] - points_11[int(0)]; - float3 _S1087 = - (points_11[int(3)] - points_11[int(2)]); - float3 _S1088 = s_primal_ctx_cross_0(dx_5, _S1087); - bool _S1089 = (s_primal_ctx_dot_0(_S1088, _S1088)) != 0.0f; - if(_S1089) + float3 _S1089 = - (points_11[int(3)] - points_11[int(2)]); + float3 _S1090 = s_primal_ctx_cross_0(dx_5, _S1089); + bool _S1091 = (s_primal_ctx_dot_0(_S1090, _S1090)) != 0.0f; + if(_S1091) { - float _S1090 = length_0(_S1088); - float3 _S1091 = make_float3 (_S1090); - _S1071 = make_float3 (_S1090 * _S1090); - _S1072 = _S1091; + float _S1092 = length_0(_S1090); + float3 _S1093 = make_float3 (_S1092); + _S1073 = make_float3 (_S1092 * _S1092); + _S1074 = _S1093; } else { - _S1071 = _S1062; - _S1072 = _S1062; + _S1073 = _S1064; + _S1074 = _S1064; } - float3 _S1092 = _S1072; - _S1065 = _S1089; - _S1072 = _S1088; - _S1073 = _S1092; - _S1074 = dx_5; - _S1075 = _S1087; + float3 _S1094 = _S1074; + _S1067 = _S1091; + _S1074 = _S1090; + _S1075 = _S1094; + _S1076 = dx_5; + _S1077 = _S1089; } else { - _S1065 = false; - _S1071 = _S1062; - _S1072 = _S1062; - _S1073 = _S1062; - _S1074 = _S1062; - _S1075 = _S1062; + _S1067 = false; + _S1073 = _S1064; + _S1074 = _S1064; + _S1075 = _S1064; + _S1076 = _S1064; + _S1077 = _S1064; } - bool _S1093 = _runFlag_19; - bool _S1094 = _runFlag_20; - bool _S1095 = _runFlag_21; - float3 _S1096 = _S1067; - float3 _S1097 = _S1068; - bool _S1098 = _S1064; - float3 _S1099 = _S1069; - float3 _S1100 = _S1070; + bool _S1095 = _runFlag_19; + bool _S1096 = _runFlag_20; + bool _S1097 = _runFlag_21; + float3 _S1098 = _S1069; + float3 _S1099 = _S1070; + bool _S1100 = _S1066; + float3 _S1101 = _S1071; + float3 _S1102 = _S1072; _runFlag_19 = _runFlag_22; - _runFlag_20 = _S1065; - _S1067 = _S1071; - _S1068 = _S1072; + _runFlag_20 = _S1067; _S1069 = _S1073; _S1070 = _S1074; _S1071 = _S1075; - _runFlag_21 = _S1076; - _S1064 = _S1093; - _runFlag_22 = _S1094; - _S1065 = _S1095; - _S1072 = _S1096; - _S1073 = _S1097; - _S1066 = _S1098; - _S1074 = _S1099; - _S1075 = _S1100; + _S1072 = _S1076; + _S1073 = _S1077; + _runFlag_21 = _S1078; + _S1066 = _S1095; + _runFlag_22 = _S1096; + _S1067 = _S1097; + _S1074 = _S1098; + _S1075 = _S1099; + _S1068 = _S1100; + _S1076 = _S1101; + _S1077 = _S1102; } else { _runFlag_19 = false; _runFlag_20 = false; - _S1067 = _S1062; - _S1068 = _S1062; - _S1069 = _S1062; - _S1070 = _S1062; - _S1071 = _S1062; + _S1069 = _S1064; + _S1070 = _S1064; + _S1071 = _S1064; + _S1072 = _S1064; + _S1073 = _S1064; _runFlag_21 = false; - _S1064 = false; - _runFlag_22 = false; - _S1065 = false; - _S1072 = _S1062; - _S1073 = _S1062; _S1066 = false; - _S1074 = _S1062; - _S1075 = _S1062; + _runFlag_22 = false; + _S1067 = false; + _S1074 = _S1064; + _S1075 = _S1064; + _S1068 = false; + _S1076 = _S1064; + _S1077 = _S1064; } - float4 _S1101 = make_float4 (0.0f); - float4 _S1102; - if(_S1063) + float4 _S1103 = make_float4 (0.0f); + float4 _S1104; + if(_S1065) { if(_runFlag_19) { if(_runFlag_20) { - float3 _S1103 = v_normal_3 / _S1067; - float3 _S1104 = _S1068 * - _S1103; - float3 _S1105 = _S1069 * _S1103; - float _S1106 = _S1104.x + _S1104.y + _S1104.z; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1107; - (&_S1107)->primal_0 = _S1068; - (&_S1107)->differential_0 = _S1062; - s_bwd_length_impl_0(&_S1107, _S1106); - _S1067 = _S1105 + _S1107.differential_0; + float3 _S1105 = v_normal_3 / _S1069; + float3 _S1106 = _S1070 * - _S1105; + float3 _S1107 = _S1071 * _S1105; + float _S1108 = _S1106.x + _S1106.y + _S1106.z; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1109; + (&_S1109)->primal_0 = _S1070; + (&_S1109)->differential_0 = _S1064; + s_bwd_length_impl_0(&_S1109, _S1108); + _S1069 = _S1107 + _S1109.differential_0; } else { - _S1067 = v_normal_3; + _S1069 = v_normal_3; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1108; - (&_S1108)->primal_0 = _S1068; - (&_S1108)->differential_0 = _S1062; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1109; - (&_S1109)->primal_0 = _S1068; - (&_S1109)->differential_0 = _S1062; - s_bwd_prop_dot_0(&_S1108, &_S1109, 0.0f); - float3 _S1110 = _S1109.differential_0 + _S1108.differential_0 + _S1067; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1110; + (&_S1110)->primal_0 = _S1070; + (&_S1110)->differential_0 = _S1064; DiffPair_vectorx3Cfloatx2C3x3E_0 _S1111; (&_S1111)->primal_0 = _S1070; - (&_S1111)->differential_0 = _S1062; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1112; - (&_S1112)->primal_0 = _S1071; - (&_S1112)->differential_0 = _S1062; - s_bwd_prop_cross_0(&_S1111, &_S1112, _S1110); - float3 s_diff_dy_T_5 = - _S1112.differential_0; - float3 _S1113 = - s_diff_dy_T_5; - float3 _S1114 = - _S1111.differential_0; - FixedArray _S1115; - _S1115[int(0)] = _S1062; - _S1115[int(1)] = _S1062; - _S1115[int(2)] = _S1062; - _S1115[int(3)] = _S1062; - _S1115[int(2)] = _S1113; - _S1115[int(3)] = s_diff_dy_T_5; - _S1115[int(0)] = _S1114; - _S1115[int(1)] = _S1111.differential_0; - points_11[int(0)] = _S1115[int(0)]; - points_11[int(1)] = _S1115[int(1)]; - points_11[int(2)] = _S1115[int(2)]; - points_11[int(3)] = _S1115[int(3)]; + (&_S1111)->differential_0 = _S1064; + s_bwd_prop_dot_0(&_S1110, &_S1111, 0.0f); + float3 _S1112 = _S1111.differential_0 + _S1110.differential_0 + _S1069; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1113; + (&_S1113)->primal_0 = _S1072; + (&_S1113)->differential_0 = _S1064; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1114; + (&_S1114)->primal_0 = _S1073; + (&_S1114)->differential_0 = _S1064; + s_bwd_prop_cross_0(&_S1113, &_S1114, _S1112); + float3 s_diff_dy_T_5 = - _S1114.differential_0; + float3 _S1115 = - s_diff_dy_T_5; + float3 _S1116 = - _S1113.differential_0; + FixedArray _S1117; + _S1117[int(0)] = _S1064; + _S1117[int(1)] = _S1064; + _S1117[int(2)] = _S1064; + _S1117[int(3)] = _S1064; + _S1117[int(2)] = _S1115; + _S1117[int(3)] = s_diff_dy_T_5; + _S1117[int(0)] = _S1116; + _S1117[int(1)] = _S1113.differential_0; + points_11[int(0)] = _S1117[int(0)]; + points_11[int(1)] = _S1117[int(1)]; + points_11[int(2)] = _S1117[int(2)]; + points_11[int(3)] = _S1117[int(3)]; } else { - points_11[int(0)] = _S1062; - points_11[int(1)] = _S1062; - points_11[int(2)] = _S1062; - points_11[int(3)] = _S1062; + points_11[int(0)] = _S1064; + points_11[int(1)] = _S1064; + points_11[int(2)] = _S1064; + points_11[int(3)] = _S1064; } if(_runFlag_21) { - if(_S1064) + if(_S1066) { if(_runFlag_22) { - FixedArray _S1116 = points_11; - FixedArray _S1117 = points_11; FixedArray _S1118 = points_11; FixedArray _S1119 = points_11; - if(_S1065) + FixedArray _S1120 = points_11; + FixedArray _S1121 = points_11; + if(_S1067) { - float3 _S1120 = _S1072 * _S1119[int(3)]; - float _S1121 = _S1120.x + _S1120.y + _S1120.z; - float4 _S1122 = _S1101; - *&((&_S1122)->w) = _S1121; - points_11[int(0)] = _S1116[int(0)]; - points_11[int(1)] = _S1117[int(1)]; - points_11[int(2)] = _S1118[int(2)]; - points_11[int(3)] = _S1062; - _S1102 = _S1122; + float3 _S1122 = _S1074 * _S1121[int(3)]; + float _S1123 = _S1122.x + _S1122.y + _S1122.z; + float4 _S1124 = _S1103; + *&((&_S1124)->w) = _S1123; + points_11[int(0)] = _S1118[int(0)]; + points_11[int(1)] = _S1119[int(1)]; + points_11[int(2)] = _S1120[int(2)]; + points_11[int(3)] = _S1064; + _S1104 = _S1124; } else { - points_11[int(0)] = _S1116[int(0)]; - points_11[int(1)] = _S1117[int(1)]; - points_11[int(2)] = _S1118[int(2)]; - points_11[int(3)] = _S1119[int(3)]; - _S1102 = _S1101; + points_11[int(0)] = _S1118[int(0)]; + points_11[int(1)] = _S1119[int(1)]; + points_11[int(2)] = _S1120[int(2)]; + points_11[int(3)] = _S1121[int(3)]; + _S1104 = _S1103; } - float3 _S1123 = _S1073 * points_11[int(2)]; - float _S1124 = _S1123.x + _S1123.y + _S1123.z; - FixedArray _S1125 = points_11; - FixedArray _S1126 = points_11; - float4 _S1127 = _S1101; - *&((&_S1127)->z) = _S1124; - float4 _S1128 = _S1102 + _S1127; + float3 _S1125 = _S1075 * points_11[int(2)]; + float _S1126 = _S1125.x + _S1125.y + _S1125.z; + FixedArray _S1127 = points_11; + FixedArray _S1128 = points_11; + float4 _S1129 = _S1103; + *&((&_S1129)->z) = _S1126; + float4 _S1130 = _S1104 + _S1129; points_11[int(0)] = points_11[int(0)]; - points_11[int(1)] = _S1125[int(1)]; - points_11[int(2)] = _S1062; - points_11[int(3)] = _S1126[int(3)]; - _S1102 = _S1128; + points_11[int(1)] = _S1127[int(1)]; + points_11[int(2)] = _S1064; + points_11[int(3)] = _S1128[int(3)]; + _S1104 = _S1130; } else { - FixedArray _S1129 = points_11; - FixedArray _S1130 = points_11; FixedArray _S1131 = points_11; + FixedArray _S1132 = points_11; + FixedArray _S1133 = points_11; points_11[int(0)] = points_11[int(0)]; - points_11[int(1)] = _S1129[int(1)]; - points_11[int(2)] = _S1130[int(2)]; - points_11[int(3)] = _S1131[int(3)]; - _S1102 = _S1101; + points_11[int(1)] = _S1131[int(1)]; + points_11[int(2)] = _S1132[int(2)]; + points_11[int(3)] = _S1133[int(3)]; + _S1104 = _S1103; } } else { - FixedArray _S1132 = points_11; - FixedArray _S1133 = points_11; FixedArray _S1134 = points_11; - points_11[int(0)] = points_11[int(0)]; - points_11[int(1)] = _S1132[int(1)]; - points_11[int(2)] = _S1133[int(2)]; - points_11[int(3)] = _S1134[int(3)]; - _S1102 = _S1101; - } - if(_S1066) - { FixedArray _S1135 = points_11; - float3 _S1136 = _S1074 * points_11[int(1)]; - float _S1137 = _S1136.x + _S1136.y + _S1136.z; - float4 _S1138 = _S1101; - *&((&_S1138)->y) = _S1137; - float4 _S1139 = _S1102 + _S1138; - points_11[int(0)] = _S1062; - points_11[int(1)] = _S1062; - points_11[int(2)] = _S1062; - points_11[int(3)] = _S1062; - _S1067 = _S1135[int(0)]; - _S1102 = _S1139; + FixedArray _S1136 = points_11; + points_11[int(0)] = points_11[int(0)]; + points_11[int(1)] = _S1134[int(1)]; + points_11[int(2)] = _S1135[int(2)]; + points_11[int(3)] = _S1136[int(3)]; + _S1104 = _S1103; + } + if(_S1068) + { + FixedArray _S1137 = points_11; + float3 _S1138 = _S1076 * points_11[int(1)]; + float _S1139 = _S1138.x + _S1138.y + _S1138.z; + float4 _S1140 = _S1103; + *&((&_S1140)->y) = _S1139; + float4 _S1141 = _S1104 + _S1140; + points_11[int(0)] = _S1064; + points_11[int(1)] = _S1064; + points_11[int(2)] = _S1064; + points_11[int(3)] = _S1064; + _S1069 = _S1137[int(0)]; + _S1104 = _S1141; } else { - FixedArray _S1140 = points_11; - FixedArray _S1141 = points_11; FixedArray _S1142 = points_11; + FixedArray _S1143 = points_11; + FixedArray _S1144 = points_11; points_11[int(0)] = points_11[int(0)]; - points_11[int(1)] = _S1140[int(1)]; - points_11[int(2)] = _S1141[int(2)]; - points_11[int(3)] = _S1142[int(3)]; - _S1067 = _S1062; + points_11[int(1)] = _S1142[int(1)]; + points_11[int(2)] = _S1143[int(2)]; + points_11[int(3)] = _S1144[int(3)]; + _S1069 = _S1064; } - float3 _S1143 = _S1075 * (points_11[int(0)] + _S1067); - float _S1144 = _S1143.x + _S1143.y + _S1143.z; - float4 _S1145 = _S1101; - *&((&_S1145)->x) = _S1144; - _S1102 = _S1102 + _S1145; + float3 _S1145 = _S1077 * (points_11[int(0)] + _S1069); + float _S1146 = _S1145.x + _S1145.y + _S1145.z; + float4 _S1147 = _S1103; + *&((&_S1147)->x) = _S1146; + _S1104 = _S1104 + _S1147; } else { - _S1102 = _S1101; + _S1104 = _S1103; } } else { - _S1102 = _S1101; + _S1104 = _S1103; } - *v_depths_4 = _S1102; + *v_depths_4 = _S1104; return; } inline __device__ float ray_depth_to_linear_depth_factor_prism(float2 pix_center_12, float4 intrins_21, FixedArray dist_coeffs_24, int camera_model_23) { - float _S1146; + float _S1148; for(;;) { float2 uv_61 = (pix_center_12 - float2 {intrins_21.z, intrins_21.w}) / float2 {intrins_21.x, intrins_21.y}; - FixedArray _S1147 = dist_coeffs_24; + FixedArray _S1149 = dist_coeffs_24; float2 uv_u_30; - bool _S1148 = undistort_point_2(uv_61, &_S1147, int(12), &uv_u_30); - if(!_S1148) + bool _S1150 = undistort_point_2(uv_61, &_S1149, int(12), &uv_u_30); + if(!_S1150) { - _S1146 = 0.0f; + _S1148 = 0.0f; break; } float3 raydir_16 = unproject_raydir_0(uv_u_30, camera_model_23, false); - _S1146 = float((F32_sign((raydir_16.z)))) / length_0(raydir_16); + _S1148 = float((F32_sign((raydir_16.z)))) / length_0(raydir_16); break; } - return _S1146; + return _S1148; } inline __device__ float depth_normal_loss_prism(float2 pix_center_13, float4 intrins_22, FixedArray dist_coeffs_25, int camera_model_24, bool is_ray_depth_21, float4 depths_10, float3 gt_normal_4) { - float _S1149; + float _S1151; for(;;) { - float3 _S1150; - float3 * _S1151; - float3 * _S1152; + float3 _S1152; float3 * _S1153; float3 * _S1154; - int _S1155; + float3 * _S1155; + float3 * _S1156; + int _S1157; FixedArray points_12; for(;;) { - float2 _S1156 = float2 {intrins_22.z, intrins_22.w}; - float2 _S1157 = float2 {intrins_22.x, intrins_22.y}; - float2 uv_62 = (pix_center_13 + make_float2 (-1.0f, -0.0f) - _S1156) / _S1157; - FixedArray _S1158 = dist_coeffs_25; + float2 _S1158 = float2 {intrins_22.z, intrins_22.w}; + float2 _S1159 = float2 {intrins_22.x, intrins_22.y}; + float2 uv_62 = (pix_center_13 + make_float2 (-1.0f, -0.0f) - _S1158) / _S1159; + FixedArray _S1160 = dist_coeffs_25; float2 uv_u_31; - bool _S1159 = undistort_point_2(uv_62, &_S1158, int(12), &uv_u_31); - float3 _S1160 = make_float3 (0.0f); - if(!_S1159) + bool _S1161 = undistort_point_2(uv_62, &_S1160, int(12), &uv_u_31); + float3 _S1162 = make_float3 (0.0f); + if(!_S1161) { - _S1155 = int(0); + _S1157 = int(0); + _S1156 = nullptr; + _S1155 = nullptr; _S1154 = nullptr; _S1153 = nullptr; - _S1152 = nullptr; - _S1151 = nullptr; - _S1150 = _S1160; + _S1152 = _S1162; 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_63 = (pix_center_13 + make_float2 (1.0f, -0.0f) - _S1156) / _S1157; - FixedArray _S1161 = dist_coeffs_25; + float2 uv_63 = (pix_center_13 + make_float2 (1.0f, -0.0f) - _S1158) / _S1159; + FixedArray _S1163 = dist_coeffs_25; float2 uv_u_32; - bool _S1162 = undistort_point_2(uv_63, &_S1161, int(12), &uv_u_32); - if(!_S1162) + bool _S1164 = undistort_point_2(uv_63, &_S1163, int(12), &uv_u_32); + if(!_S1164) { - _S1155 = int(0); + _S1157 = int(0); + _S1156 = nullptr; + _S1155 = &points_12[int(0)]; _S1154 = nullptr; - _S1153 = &points_12[int(0)]; - _S1152 = nullptr; - _S1151 = nullptr; - _S1150 = _S1160; + _S1153 = nullptr; + _S1152 = _S1162; 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_64 = (pix_center_13 + make_float2 (0.0f, -1.0f) - _S1156) / _S1157; - FixedArray _S1163 = dist_coeffs_25; + float2 uv_64 = (pix_center_13 + make_float2 (0.0f, -1.0f) - _S1158) / _S1159; + FixedArray _S1165 = dist_coeffs_25; float2 uv_u_33; - bool _S1164 = undistort_point_2(uv_64, &_S1163, int(12), &uv_u_33); - if(!_S1164) + bool _S1166 = undistort_point_2(uv_64, &_S1165, int(12), &uv_u_33); + if(!_S1166) { - _S1155 = int(0); - _S1154 = &points_12[int(1)]; - _S1153 = &points_12[int(0)]; - _S1152 = nullptr; - _S1151 = nullptr; - _S1150 = _S1160; + _S1157 = int(0); + _S1156 = &points_12[int(1)]; + _S1155 = &points_12[int(0)]; + _S1154 = nullptr; + _S1153 = nullptr; + _S1152 = _S1162; 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_65 = (pix_center_13 + make_float2 (0.0f, 1.0f) - _S1156) / _S1157; - FixedArray _S1165 = dist_coeffs_25; + float2 uv_65 = (pix_center_13 + make_float2 (0.0f, 1.0f) - _S1158) / _S1159; + FixedArray _S1167 = dist_coeffs_25; float2 uv_u_34; - bool _S1166 = undistort_point_2(uv_65, &_S1165, int(12), &uv_u_34); - if(!_S1166) + bool _S1168 = undistort_point_2(uv_65, &_S1167, int(12), &uv_u_34); + if(!_S1168) { - _S1155 = int(0); - _S1154 = &points_12[int(1)]; - _S1153 = &points_12[int(0)]; - _S1152 = nullptr; - _S1151 = &points_12[int(2)]; - _S1150 = _S1160; + _S1157 = int(0); + _S1156 = &points_12[int(1)]; + _S1155 = &points_12[int(0)]; + _S1154 = nullptr; + _S1153 = &points_12[int(2)]; + _S1152 = _S1162; 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_66 = (pix_center_13 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S1156) / _S1157; - FixedArray _S1167 = dist_coeffs_25; + float2 uv_66 = (pix_center_13 + make_float2 (0.0f) * make_float2 (0.0f, 3.0f) - _S1158) / _S1159; + FixedArray _S1169 = dist_coeffs_25; float2 uv_u_35; - bool _S1168 = undistort_point_2(uv_66, &_S1167, int(12), &uv_u_35); - if(!_S1168) + bool _S1170 = undistort_point_2(uv_66, &_S1169, int(12), &uv_u_35); + if(!_S1170) { - _S1155 = int(0); - _S1154 = &points_12[int(1)]; - _S1153 = &points_12[int(0)]; - _S1152 = &points_12[int(3)]; - _S1151 = &points_12[int(2)]; - _S1150 = _S1160; + _S1157 = int(0); + _S1156 = &points_12[int(1)]; + _S1155 = &points_12[int(0)]; + _S1154 = &points_12[int(3)]; + _S1153 = &points_12[int(2)]; + _S1152 = _S1162; break; } float3 raydir_21 = unproject_raydir_0(uv_u_35, camera_model_24, is_ray_depth_21); - _S1155 = int(1); - _S1154 = &points_12[int(1)]; - _S1153 = &points_12[int(0)]; - _S1152 = &points_12[int(3)]; - _S1151 = &points_12[int(2)]; - _S1150 = raydir_21; + _S1157 = int(1); + _S1156 = &points_12[int(1)]; + _S1155 = &points_12[int(0)]; + _S1154 = &points_12[int(3)]; + _S1153 = &points_12[int(2)]; + _S1152 = raydir_21; break; } - if(_S1155 != int(1)) + if(_S1157 != int(1)) { - _S1149 = 0.0f; + _S1151 = 0.0f; break; } - float3 normal_14 = cross_0(*_S1154 - *_S1153, - (*_S1152 - *_S1151)); + float3 normal_14 = cross_0(*_S1156 - *_S1155, - (*_S1154 - *_S1153)); float3 normal_15; if((dot_0(normal_14, normal_14)) != 0.0f) { @@ -5920,25 +5944,23 @@ inline __device__ float depth_normal_loss_prism(float2 pix_center_13, float4 i { normal_15 = normal_14; } - float3 _S1169; + float3 _S1171; if((dot_0(gt_normal_4, gt_normal_4)) != 0.0f) { - _S1169 = normalize_0(gt_normal_4); + _S1171 = normalize_0(gt_normal_4); } else { - _S1169 = gt_normal_4; + _S1171 = gt_normal_4; } - _S1149 = (1.0f - dot_0(normal_15, _S1169) + 0.00100000004749745f) / ((F32_max((dot_0(normal_15, - normalize_0(_S1150))), (0.0f))) + 0.00100000004749745f); + _S1151 = (1.0f - dot_0(normal_15, _S1171) + 0.00100000004749745f) / ((F32_max((dot_0(normal_15, - normalize_0(_S1152))), (0.0f))) + 0.00100000004749745f); break; } - return _S1149; + return _S1151; } struct s_bwd_prop_depth_normal_loss_Intermediates_2 { - float2 _S1170; - bool _S1171; float2 _S1172; bool _S1173; float2 _S1174; @@ -5947,122 +5969,124 @@ struct s_bwd_prop_depth_normal_loss_Intermediates_2 bool _S1177; float2 _S1178; bool _S1179; + float2 _S1180; + bool _S1181; }; inline __device__ void depth_normal_loss_vjp_prism(float2 pix_center_14, float4 intrins_23, FixedArray dist_coeffs_26, 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 _S1180 = make_float2 (0.0f); - s_bwd_prop_depth_normal_loss_Intermediates_2 _S1181; - (&_S1181)->_S1170 = _S1180; - (&_S1181)->_S1171 = false; - (&_S1181)->_S1172 = _S1180; - (&_S1181)->_S1173 = false; - (&_S1181)->_S1174 = _S1180; - (&_S1181)->_S1175 = false; - (&_S1181)->_S1176 = _S1180; - (&_S1181)->_S1177 = false; - (&_S1181)->_S1178 = _S1180; - (&_S1181)->_S1179 = false; - (&_S1181)->_S1172 = _S1180; - (&_S1181)->_S1173 = false; - (&_S1181)->_S1174 = _S1180; - (&_S1181)->_S1175 = false; - (&_S1181)->_S1176 = _S1180; - (&_S1181)->_S1177 = false; - (&_S1181)->_S1178 = _S1180; - (&_S1181)->_S1179 = false; - float2 _S1182 = float2 {intrins_23.z, intrins_23.w}; - float2 _S1183 = float2 {intrins_23.x, intrins_23.y}; - float2 uv_67 = (pix_center_14 + make_float2 (-1.0f, -0.0f) - _S1182) / _S1183; - float2 _S1184 = _S1180; - FixedArray _S1185 = dist_coeffs_26; - bool _S1186 = undistort_point_2(uv_67, &_S1185, int(12), &_S1184); - (&_S1181)->_S1170 = _S1184; - (&_S1181)->_S1171 = _S1186; - bool _S1187 = !!_S1186; + float2 _S1182 = make_float2 (0.0f); + s_bwd_prop_depth_normal_loss_Intermediates_2 _S1183; + (&_S1183)->_S1172 = _S1182; + (&_S1183)->_S1173 = false; + (&_S1183)->_S1174 = _S1182; + (&_S1183)->_S1175 = false; + (&_S1183)->_S1176 = _S1182; + (&_S1183)->_S1177 = false; + (&_S1183)->_S1178 = _S1182; + (&_S1183)->_S1179 = false; + (&_S1183)->_S1180 = _S1182; + (&_S1183)->_S1181 = false; + (&_S1183)->_S1174 = _S1182; + (&_S1183)->_S1175 = false; + (&_S1183)->_S1176 = _S1182; + (&_S1183)->_S1177 = false; + (&_S1183)->_S1178 = _S1182; + (&_S1183)->_S1179 = false; + (&_S1183)->_S1180 = _S1182; + (&_S1183)->_S1181 = false; + float2 _S1184 = float2 {intrins_23.z, intrins_23.w}; + float2 _S1185 = float2 {intrins_23.x, intrins_23.y}; + float2 uv_67 = (pix_center_14 + make_float2 (-1.0f, -0.0f) - _S1184) / _S1185; + float2 _S1186 = _S1182; + FixedArray _S1187 = dist_coeffs_26; + bool _S1188 = undistort_point_2(uv_67, &_S1187, int(12), &_S1186); + (&_S1183)->_S1172 = _S1186; + (&_S1183)->_S1173 = _S1188; + bool _S1189 = !!_S1188; bool _runFlag_23; - if(_S1187) + if(_S1189) { - float2 uv_68 = (pix_center_14 + make_float2 (1.0f, -0.0f) - _S1182) / _S1183; - float2 _S1188 = _S1180; - FixedArray _S1189 = dist_coeffs_26; - bool _S1190 = undistort_point_2(uv_68, &_S1189, int(12), &_S1188); - (&_S1181)->_S1172 = _S1188; - (&_S1181)->_S1173 = _S1190; - if(!_S1190) + float2 uv_68 = (pix_center_14 + make_float2 (1.0f, -0.0f) - _S1184) / _S1185; + float2 _S1190 = _S1182; + FixedArray _S1191 = dist_coeffs_26; + bool _S1192 = undistort_point_2(uv_68, &_S1191, int(12), &_S1190); + (&_S1183)->_S1174 = _S1190; + (&_S1183)->_S1175 = _S1192; + if(!_S1192) { _runFlag_23 = false; } else { - _runFlag_23 = _S1187; + _runFlag_23 = _S1189; } if(_runFlag_23) { - float2 uv_69 = (pix_center_14 + make_float2 (0.0f, -1.0f) - _S1182) / _S1183; - float2 _S1191 = _S1180; - FixedArray _S1192 = dist_coeffs_26; - bool _S1193 = undistort_point_2(uv_69, &_S1192, int(12), &_S1191); - (&_S1181)->_S1174 = _S1191; - (&_S1181)->_S1175 = _S1193; - if(!_S1193) + float2 uv_69 = (pix_center_14 + make_float2 (0.0f, -1.0f) - _S1184) / _S1185; + float2 _S1193 = _S1182; + FixedArray _S1194 = dist_coeffs_26; + bool _S1195 = undistort_point_2(uv_69, &_S1194, int(12), &_S1193); + (&_S1183)->_S1176 = _S1193; + (&_S1183)->_S1177 = _S1195; + if(!_S1195) { _runFlag_23 = false; } if(_runFlag_23) { - float2 uv_70 = (pix_center_14 + make_float2 (0.0f, 1.0f) - _S1182) / _S1183; - float2 _S1194 = _S1180; - FixedArray _S1195 = dist_coeffs_26; - bool _S1196 = undistort_point_2(uv_70, &_S1195, int(12), &_S1194); - (&_S1181)->_S1176 = _S1194; - (&_S1181)->_S1177 = _S1196; - if(!_S1196) + float2 uv_70 = (pix_center_14 + make_float2 (0.0f, 1.0f) - _S1184) / _S1185; + float2 _S1196 = _S1182; + FixedArray _S1197 = dist_coeffs_26; + bool _S1198 = undistort_point_2(uv_70, &_S1197, int(12), &_S1196); + (&_S1183)->_S1178 = _S1196; + (&_S1183)->_S1179 = _S1198; + if(!_S1198) { _runFlag_23 = false; } if(_runFlag_23) { - float2 uv_71 = (pix_center_14 - _S1182) / _S1183; - float2 _S1197 = _S1180; - FixedArray _S1198 = dist_coeffs_26; - bool _S1199 = undistort_point_2(uv_71, &_S1198, int(12), &_S1197); - (&_S1181)->_S1178 = _S1197; - (&_S1181)->_S1179 = _S1199; + float2 uv_71 = (pix_center_14 - _S1184) / _S1185; + float2 _S1199 = _S1182; + FixedArray _S1200 = dist_coeffs_26; + bool _S1201 = undistort_point_2(uv_71, &_S1200, int(12), &_S1199); + (&_S1183)->_S1180 = _S1199; + (&_S1183)->_S1181 = _S1201; } } } } - s_bwd_prop_depth_normal_loss_Intermediates_2 _S1200 = _S1181; - float3 _S1201 = make_float3 (0.0f); - bool _S1202 = !!_S1181._S1171; + s_bwd_prop_depth_normal_loss_Intermediates_2 _S1202 = _S1183; + float3 _S1203 = make_float3 (0.0f); + bool _S1204 = !!_S1183._S1173; bool _runFlag_24; bool _runFlag_25; bool _runFlag_26; - int _S1203; + int _S1205; float3 raydir_22; - float3 _S1204; - float3 _S1205; float3 _S1206; float3 _S1207; + float3 _S1208; + float3 _S1209; FixedArray points_13; - if(_S1202) + if(_S1204) { - float3 _S1208 = s_primal_ctx_unproject_raydir_0(_S1200._S1170, camera_model_25, is_ray_depth_22); - float3 _S1209 = make_float3 (depths_11.x) * _S1208; - if(!_S1200._S1173) + float3 _S1210 = s_primal_ctx_unproject_raydir_0(_S1202._S1172, camera_model_25, is_ray_depth_22); + float3 _S1211 = make_float3 (depths_11.x) * _S1210; + if(!_S1202._S1175) { _runFlag_23 = false; } else { - _runFlag_23 = _S1202; + _runFlag_23 = _S1204; } if(_runFlag_23) { - float3 _S1210 = s_primal_ctx_unproject_raydir_0(_S1200._S1172, camera_model_25, is_ray_depth_22); - float3 _S1211 = make_float3 (depths_11.y) * _S1210; - if(!_S1200._S1175) + float3 _S1212 = s_primal_ctx_unproject_raydir_0(_S1202._S1174, camera_model_25, is_ray_depth_22); + float3 _S1213 = make_float3 (depths_11.y) * _S1212; + if(!_S1202._S1177) { _runFlag_24 = false; } @@ -6072,9 +6096,9 @@ inline __device__ void depth_normal_loss_vjp_prism(float2 pix_center_14, float4 } if(_runFlag_24) { - float3 _S1212 = s_primal_ctx_unproject_raydir_0(_S1200._S1174, camera_model_25, is_ray_depth_22); - float3 _S1213 = make_float3 (depths_11.z) * _S1212; - if(!_S1200._S1177) + float3 _S1214 = s_primal_ctx_unproject_raydir_0(_S1202._S1176, camera_model_25, is_ray_depth_22); + float3 _S1215 = make_float3 (depths_11.z) * _S1214; + if(!_S1202._S1179) { _runFlag_25 = false; } @@ -6084,9 +6108,9 @@ inline __device__ void depth_normal_loss_vjp_prism(float2 pix_center_14, float4 } if(_runFlag_25) { - float3 _S1214 = s_primal_ctx_unproject_raydir_0(_S1200._S1176, camera_model_25, is_ray_depth_22); - float3 _S1215 = make_float3 (depths_11.w) * _S1214; - if(!_S1200._S1179) + float3 _S1216 = s_primal_ctx_unproject_raydir_0(_S1202._S1178, camera_model_25, is_ray_depth_22); + float3 _S1217 = make_float3 (depths_11.w) * _S1216; + if(!_S1202._S1181) { _runFlag_26 = false; } @@ -6096,256 +6120,256 @@ inline __device__ void depth_normal_loss_vjp_prism(float2 pix_center_14, float4 } if(_runFlag_26) { - float3 _S1216 = s_primal_ctx_unproject_raydir_0(_S1200._S1178, camera_model_25, is_ray_depth_22); - _S1203 = int(1); - raydir_22 = _S1216; + float3 _S1218 = s_primal_ctx_unproject_raydir_0(_S1202._S1180, camera_model_25, is_ray_depth_22); + _S1205 = int(1); + raydir_22 = _S1218; } else { - _S1203 = int(0); - raydir_22 = _S1214; + _S1205 = int(0); + raydir_22 = _S1216; } - points_13[int(0)] = _S1209; - points_13[int(1)] = _S1211; - points_13[int(2)] = _S1213; - points_13[int(3)] = _S1215; - points_13[int(4)] = _S1201; - _S1204 = _S1214; + points_13[int(0)] = _S1211; + points_13[int(1)] = _S1213; + points_13[int(2)] = _S1215; + points_13[int(3)] = _S1217; + points_13[int(4)] = _S1203; + _S1206 = _S1216; } else { - _S1203 = int(0); - raydir_22 = _S1212; - points_13[int(0)] = _S1209; - points_13[int(1)] = _S1211; - points_13[int(2)] = _S1213; - points_13[int(3)] = _S1201; - points_13[int(4)] = _S1201; - _S1204 = _S1201; + _S1205 = int(0); + raydir_22 = _S1214; + points_13[int(0)] = _S1211; + points_13[int(1)] = _S1213; + points_13[int(2)] = _S1215; + points_13[int(3)] = _S1203; + points_13[int(4)] = _S1203; + _S1206 = _S1203; } - _S1205 = _S1212; + _S1207 = _S1214; } else { - _S1203 = int(0); - raydir_22 = _S1210; - points_13[int(0)] = _S1209; - points_13[int(1)] = _S1211; - points_13[int(2)] = _S1201; - points_13[int(3)] = _S1201; - points_13[int(4)] = _S1201; + _S1205 = int(0); + raydir_22 = _S1212; + points_13[int(0)] = _S1211; + points_13[int(1)] = _S1213; + points_13[int(2)] = _S1203; + points_13[int(3)] = _S1203; + points_13[int(4)] = _S1203; _runFlag_25 = false; - _S1204 = _S1201; - _S1205 = _S1201; + _S1206 = _S1203; + _S1207 = _S1203; } - _S1206 = _S1210; + _S1208 = _S1212; } else { - _S1203 = int(0); - raydir_22 = _S1208; - points_13[int(0)] = _S1209; - points_13[int(1)] = _S1201; - points_13[int(2)] = _S1201; - points_13[int(3)] = _S1201; - points_13[int(4)] = _S1201; + _S1205 = int(0); + raydir_22 = _S1210; + points_13[int(0)] = _S1211; + points_13[int(1)] = _S1203; + points_13[int(2)] = _S1203; + points_13[int(3)] = _S1203; + points_13[int(4)] = _S1203; _runFlag_24 = false; _runFlag_25 = false; - _S1204 = _S1201; - _S1205 = _S1201; - _S1206 = _S1201; + _S1206 = _S1203; + _S1207 = _S1203; + _S1208 = _S1203; } - _S1207 = _S1208; + _S1209 = _S1210; } else { - _S1203 = int(0); - points_13[int(0)] = _S1201; - points_13[int(1)] = _S1201; - points_13[int(2)] = _S1201; - points_13[int(3)] = _S1201; - points_13[int(4)] = _S1201; + _S1205 = int(0); + points_13[int(0)] = _S1203; + points_13[int(1)] = _S1203; + points_13[int(2)] = _S1203; + points_13[int(3)] = _S1203; + points_13[int(4)] = _S1203; _runFlag_23 = false; _runFlag_24 = false; _runFlag_25 = false; - _S1204 = _S1201; - _S1205 = _S1201; - _S1206 = _S1201; - _S1207 = _S1201; + _S1206 = _S1203; + _S1207 = _S1203; + _S1208 = _S1203; + _S1209 = _S1203; } - bool _S1217 = !(_S1203 != int(1)); - bool _S1218; + bool _S1219 = !(_S1205 != int(1)); + bool _S1220; float3 normal_16; - float3 _S1219; - float3 _S1220; float3 _S1221; float3 _S1222; - float _S1223; - float _S1224; + float3 _S1223; + float3 _S1224; float _S1225; float _S1226; - if(_S1217) + float _S1227; + float _S1228; + if(_S1219) { float3 dx_6 = points_13[int(1)] - points_13[int(0)]; - float3 _S1227 = - (points_13[int(3)] - points_13[int(2)]); - float3 _S1228 = s_primal_ctx_cross_0(dx_6, _S1227); - bool _S1229 = (s_primal_ctx_dot_0(_S1228, _S1228)) != 0.0f; - if(_S1229) + float3 _S1229 = - (points_13[int(3)] - points_13[int(2)]); + float3 _S1230 = s_primal_ctx_cross_0(dx_6, _S1229); + bool _S1231 = (s_primal_ctx_dot_0(_S1230, _S1230)) != 0.0f; + if(_S1231) { - normal_16 = normalize_0(_S1228); + normal_16 = normalize_0(_S1230); } else { - normal_16 = _S1228; + normal_16 = _S1230; } - bool _S1230 = (s_primal_ctx_dot_0(gt_normal_5, gt_normal_5)) != 0.0f; - if(_S1230) + bool _S1232 = (s_primal_ctx_dot_0(gt_normal_5, gt_normal_5)) != 0.0f; + if(_S1232) { - _S1219 = normalize_0(gt_normal_5); + _S1221 = normalize_0(gt_normal_5); } else { - _S1219 = gt_normal_5; + _S1221 = gt_normal_5; } - float3 _S1231 = - normalize_0(raydir_22); - float _S1232 = s_primal_ctx_dot_0(normal_16, _S1231); - float _S1233 = 1.0f - s_primal_ctx_dot_0(normal_16, _S1219) + 0.00100000004749745f; - float _S1234 = (F32_max((_S1232), (0.0f))) + 0.00100000004749745f; - _S1223 = _S1234 * _S1234; - _S1224 = _S1233; - _S1225 = _S1234; - _S1226 = _S1232; + float3 _S1233 = - normalize_0(raydir_22); + float _S1234 = s_primal_ctx_dot_0(normal_16, _S1233); + float _S1235 = 1.0f - s_primal_ctx_dot_0(normal_16, _S1221) + 0.00100000004749745f; + float _S1236 = (F32_max((_S1234), (0.0f))) + 0.00100000004749745f; + _S1225 = _S1236 * _S1236; + _S1226 = _S1235; + _S1227 = _S1236; + _S1228 = _S1234; raydir_22 = normal_16; - normal_16 = _S1231; - _runFlag_26 = _S1230; - _S1218 = _S1229; - _S1220 = _S1228; - _S1221 = dx_6; - _S1222 = _S1227; + normal_16 = _S1233; + _runFlag_26 = _S1232; + _S1220 = _S1231; + _S1222 = _S1230; + _S1223 = dx_6; + _S1224 = _S1229; } else { - _S1223 = 0.0f; - _S1224 = 0.0f; _S1225 = 0.0f; _S1226 = 0.0f; - raydir_22 = _S1201; - normal_16 = _S1201; - _S1219 = _S1201; + _S1227 = 0.0f; + _S1228 = 0.0f; + raydir_22 = _S1203; + normal_16 = _S1203; + _S1221 = _S1203; _runFlag_26 = false; - _S1218 = false; - _S1220 = _S1201; - _S1221 = _S1201; - _S1222 = _S1201; + _S1220 = false; + _S1222 = _S1203; + _S1223 = _S1203; + _S1224 = _S1203; } - float4 _S1235 = make_float4 (0.0f); - if(_S1217) + float4 _S1237 = make_float4 (0.0f); + if(_S1219) { - float _S1236 = v_loss_2 / _S1223; - float _S1237 = _S1224 * - _S1236; - float s_diff_num_T_2 = _S1225 * _S1236; - DiffPair_float_0 _S1238; - (&_S1238)->primal_0 = _S1226; - (&_S1238)->differential_0 = 0.0f; - DiffPair_float_0 _S1239; - (&_S1239)->primal_0 = 0.0f; - (&_S1239)->differential_0 = 0.0f; - _d_max_0(&_S1238, &_S1239, _S1237); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1240; - (&_S1240)->primal_0 = raydir_22; - (&_S1240)->differential_0 = _S1201; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1241; - (&_S1241)->primal_0 = normal_16; - (&_S1241)->differential_0 = _S1201; - s_bwd_prop_dot_0(&_S1240, &_S1241, _S1238.differential_0); - float _S1242 = - s_diff_num_T_2; + float _S1238 = v_loss_2 / _S1225; + float _S1239 = _S1226 * - _S1238; + float s_diff_num_T_2 = _S1227 * _S1238; + DiffPair_float_0 _S1240; + (&_S1240)->primal_0 = _S1228; + (&_S1240)->differential_0 = 0.0f; + DiffPair_float_0 _S1241; + (&_S1241)->primal_0 = 0.0f; + (&_S1241)->differential_0 = 0.0f; + _d_max_0(&_S1240, &_S1241, _S1239); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1242; + (&_S1242)->primal_0 = raydir_22; + (&_S1242)->differential_0 = _S1203; DiffPair_vectorx3Cfloatx2C3x3E_0 _S1243; - (&_S1243)->primal_0 = raydir_22; - (&_S1243)->differential_0 = _S1201; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1244; - (&_S1244)->primal_0 = _S1219; - (&_S1244)->differential_0 = _S1201; - s_bwd_prop_dot_0(&_S1243, &_S1244, _S1242); - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1245 = _S1244; - float3 _S1246 = _S1240.differential_0 + _S1243.differential_0; + (&_S1243)->primal_0 = normal_16; + (&_S1243)->differential_0 = _S1203; + s_bwd_prop_dot_0(&_S1242, &_S1243, _S1240.differential_0); + float _S1244 = - s_diff_num_T_2; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1245; + (&_S1245)->primal_0 = raydir_22; + (&_S1245)->differential_0 = _S1203; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1246; + (&_S1246)->primal_0 = _S1221; + (&_S1246)->differential_0 = _S1203; + s_bwd_prop_dot_0(&_S1245, &_S1246, _S1244); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1247 = _S1246; + float3 _S1248 = _S1242.differential_0 + _S1245.differential_0; if(_runFlag_26) { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1247; - (&_S1247)->primal_0 = gt_normal_5; - (&_S1247)->differential_0 = _S1201; - s_bwd_normalize_impl_0(&_S1247, _S1245.differential_0); + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1249; + (&_S1249)->primal_0 = gt_normal_5; + (&_S1249)->differential_0 = _S1203; + s_bwd_normalize_impl_0(&_S1249, _S1247.differential_0); + raydir_22 = _S1249.differential_0; + } + else + { raydir_22 = _S1247.differential_0; } - else + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1250; + (&_S1250)->primal_0 = gt_normal_5; + (&_S1250)->differential_0 = _S1203; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1251; + (&_S1251)->primal_0 = gt_normal_5; + (&_S1251)->differential_0 = _S1203; + s_bwd_prop_dot_0(&_S1250, &_S1251, 0.0f); + float3 _S1252 = _S1251.differential_0 + _S1250.differential_0 + raydir_22; + if(_S1220) { - raydir_22 = _S1245.differential_0; - } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1248; - (&_S1248)->primal_0 = gt_normal_5; - (&_S1248)->differential_0 = _S1201; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1249; - (&_S1249)->primal_0 = gt_normal_5; - (&_S1249)->differential_0 = _S1201; - s_bwd_prop_dot_0(&_S1248, &_S1249, 0.0f); - float3 _S1250 = _S1249.differential_0 + _S1248.differential_0 + raydir_22; - if(_S1218) - { - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1251; - (&_S1251)->primal_0 = _S1220; - (&_S1251)->differential_0 = _S1201; - s_bwd_normalize_impl_0(&_S1251, _S1246); - raydir_22 = _S1251.differential_0; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1253; + (&_S1253)->primal_0 = _S1222; + (&_S1253)->differential_0 = _S1203; + s_bwd_normalize_impl_0(&_S1253, _S1248); + raydir_22 = _S1253.differential_0; } else { - raydir_22 = _S1246; + raydir_22 = _S1248; } - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1252; - (&_S1252)->primal_0 = _S1220; - (&_S1252)->differential_0 = _S1201; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1253; - (&_S1253)->primal_0 = _S1220; - (&_S1253)->differential_0 = _S1201; - s_bwd_prop_dot_0(&_S1252, &_S1253, 0.0f); - float3 _S1254 = _S1253.differential_0 + _S1252.differential_0 + raydir_22; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1254; + (&_S1254)->primal_0 = _S1222; + (&_S1254)->differential_0 = _S1203; DiffPair_vectorx3Cfloatx2C3x3E_0 _S1255; - (&_S1255)->primal_0 = _S1221; - (&_S1255)->differential_0 = _S1201; - DiffPair_vectorx3Cfloatx2C3x3E_0 _S1256; - (&_S1256)->primal_0 = _S1222; - (&_S1256)->differential_0 = _S1201; - s_bwd_prop_cross_0(&_S1255, &_S1256, _S1254); - float3 s_diff_dy_T_6 = - _S1256.differential_0; - float3 _S1257 = - s_diff_dy_T_6; - float3 _S1258 = - _S1255.differential_0; - FixedArray _S1259; - _S1259[int(0)] = _S1201; - _S1259[int(1)] = _S1201; - _S1259[int(2)] = _S1201; - _S1259[int(3)] = _S1201; - _S1259[int(4)] = _S1201; - _S1259[int(2)] = _S1257; - _S1259[int(3)] = s_diff_dy_T_6; - _S1259[int(0)] = _S1258; - _S1259[int(1)] = _S1255.differential_0; - points_13[int(0)] = _S1259[int(0)]; - points_13[int(1)] = _S1259[int(1)]; - points_13[int(2)] = _S1259[int(2)]; - points_13[int(3)] = _S1259[int(3)]; - points_13[int(4)] = _S1259[int(4)]; - raydir_22 = _S1250; + (&_S1255)->primal_0 = _S1222; + (&_S1255)->differential_0 = _S1203; + s_bwd_prop_dot_0(&_S1254, &_S1255, 0.0f); + float3 _S1256 = _S1255.differential_0 + _S1254.differential_0 + raydir_22; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1257; + (&_S1257)->primal_0 = _S1223; + (&_S1257)->differential_0 = _S1203; + DiffPair_vectorx3Cfloatx2C3x3E_0 _S1258; + (&_S1258)->primal_0 = _S1224; + (&_S1258)->differential_0 = _S1203; + s_bwd_prop_cross_0(&_S1257, &_S1258, _S1256); + float3 s_diff_dy_T_6 = - _S1258.differential_0; + float3 _S1259 = - s_diff_dy_T_6; + float3 _S1260 = - _S1257.differential_0; + FixedArray _S1261; + _S1261[int(0)] = _S1203; + _S1261[int(1)] = _S1203; + _S1261[int(2)] = _S1203; + _S1261[int(3)] = _S1203; + _S1261[int(4)] = _S1203; + _S1261[int(2)] = _S1259; + _S1261[int(3)] = s_diff_dy_T_6; + _S1261[int(0)] = _S1260; + _S1261[int(1)] = _S1257.differential_0; + points_13[int(0)] = _S1261[int(0)]; + points_13[int(1)] = _S1261[int(1)]; + points_13[int(2)] = _S1261[int(2)]; + points_13[int(3)] = _S1261[int(3)]; + points_13[int(4)] = _S1261[int(4)]; + raydir_22 = _S1252; } else { - points_13[int(0)] = _S1201; - points_13[int(1)] = _S1201; - points_13[int(2)] = _S1201; - points_13[int(3)] = _S1201; - points_13[int(4)] = _S1201; - raydir_22 = _S1201; + points_13[int(0)] = _S1203; + points_13[int(1)] = _S1203; + points_13[int(2)] = _S1203; + points_13[int(3)] = _S1203; + points_13[int(4)] = _S1203; + raydir_22 = _S1203; } - float4 _S1260; - if(_S1202) + float4 _S1262; + if(_S1204) { if(_runFlag_23) { @@ -6353,109 +6377,109 @@ inline __device__ void depth_normal_loss_vjp_prism(float2 pix_center_14, float4 { if(_runFlag_25) { - FixedArray _S1261 = points_13; - FixedArray _S1262 = points_13; FixedArray _S1263 = points_13; - float3 _S1264 = _S1204 * points_13[int(3)]; - float _S1265 = _S1264.x + _S1264.y + _S1264.z; - float4 _S1266 = _S1235; - *&((&_S1266)->w) = _S1265; - points_13[int(0)] = _S1201; - points_13[int(1)] = _S1201; - points_13[int(2)] = _S1201; - points_13[int(3)] = _S1201; - points_13[int(4)] = _S1201; - _S1204 = _S1263[int(2)]; - normal_16 = _S1261[int(0)]; - _S1219 = _S1262[int(1)]; - _S1260 = _S1266; + FixedArray _S1264 = points_13; + FixedArray _S1265 = points_13; + float3 _S1266 = _S1206 * points_13[int(3)]; + float _S1267 = _S1266.x + _S1266.y + _S1266.z; + float4 _S1268 = _S1237; + *&((&_S1268)->w) = _S1267; + points_13[int(0)] = _S1203; + points_13[int(1)] = _S1203; + points_13[int(2)] = _S1203; + points_13[int(3)] = _S1203; + points_13[int(4)] = _S1203; + _S1206 = _S1265[int(2)]; + normal_16 = _S1263[int(0)]; + _S1221 = _S1264[int(1)]; + _S1262 = _S1268; } else { - FixedArray _S1267 = points_13; - FixedArray _S1268 = points_13; FixedArray _S1269 = points_13; FixedArray _S1270 = points_13; + FixedArray _S1271 = points_13; + FixedArray _S1272 = 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)]; - _S1204 = _S1201; - normal_16 = _S1201; - _S1219 = _S1201; - _S1260 = _S1235; + points_13[int(1)] = _S1269[int(1)]; + points_13[int(2)] = _S1270[int(2)]; + points_13[int(3)] = _S1271[int(3)]; + points_13[int(4)] = _S1272[int(4)]; + _S1206 = _S1203; + normal_16 = _S1203; + _S1221 = _S1203; + _S1262 = _S1237; } - float3 _S1271 = _S1205 * (points_13[int(2)] + _S1204); - float _S1272 = _S1271.x + _S1271.y + _S1271.z; - float3 _S1273 = points_13[int(0)] + normal_16; - float3 _S1274 = points_13[int(1)] + _S1219; - float4 _S1275 = _S1235; - *&((&_S1275)->z) = _S1272; - float4 _S1276 = _S1260 + _S1275; - points_13[int(0)] = _S1201; - points_13[int(1)] = _S1201; - points_13[int(2)] = _S1201; - points_13[int(3)] = _S1201; - points_13[int(4)] = _S1201; - _S1204 = _S1274; - _S1205 = _S1273; - _S1260 = _S1276; + float3 _S1273 = _S1207 * (points_13[int(2)] + _S1206); + float _S1274 = _S1273.x + _S1273.y + _S1273.z; + float3 _S1275 = points_13[int(0)] + normal_16; + float3 _S1276 = points_13[int(1)] + _S1221; + float4 _S1277 = _S1237; + *&((&_S1277)->z) = _S1274; + float4 _S1278 = _S1262 + _S1277; + points_13[int(0)] = _S1203; + points_13[int(1)] = _S1203; + points_13[int(2)] = _S1203; + points_13[int(3)] = _S1203; + points_13[int(4)] = _S1203; + _S1206 = _S1276; + _S1207 = _S1275; + _S1262 = _S1278; } else { - FixedArray _S1277 = points_13; - FixedArray _S1278 = points_13; FixedArray _S1279 = points_13; FixedArray _S1280 = points_13; + FixedArray _S1281 = points_13; + FixedArray _S1282 = points_13; points_13[int(0)] = points_13[int(0)]; - points_13[int(1)] = _S1277[int(1)]; - points_13[int(2)] = _S1278[int(2)]; - points_13[int(3)] = _S1279[int(3)]; - points_13[int(4)] = _S1280[int(4)]; - _S1204 = _S1201; - _S1205 = _S1201; - _S1260 = _S1235; + points_13[int(1)] = _S1279[int(1)]; + points_13[int(2)] = _S1280[int(2)]; + points_13[int(3)] = _S1281[int(3)]; + points_13[int(4)] = _S1282[int(4)]; + _S1206 = _S1203; + _S1207 = _S1203; + _S1262 = _S1237; } - float3 _S1281 = _S1206 * (points_13[int(1)] + _S1204); - float _S1282 = _S1281.x + _S1281.y + _S1281.z; - float3 _S1283 = points_13[int(0)] + _S1205; - float4 _S1284 = _S1235; - *&((&_S1284)->y) = _S1282; - float4 _S1285 = _S1260 + _S1284; - points_13[int(0)] = _S1201; - points_13[int(1)] = _S1201; - points_13[int(2)] = _S1201; - points_13[int(3)] = _S1201; - points_13[int(4)] = _S1201; - _S1204 = _S1283; - _S1260 = _S1285; + float3 _S1283 = _S1208 * (points_13[int(1)] + _S1206); + float _S1284 = _S1283.x + _S1283.y + _S1283.z; + float3 _S1285 = points_13[int(0)] + _S1207; + float4 _S1286 = _S1237; + *&((&_S1286)->y) = _S1284; + float4 _S1287 = _S1262 + _S1286; + points_13[int(0)] = _S1203; + points_13[int(1)] = _S1203; + points_13[int(2)] = _S1203; + points_13[int(3)] = _S1203; + points_13[int(4)] = _S1203; + _S1206 = _S1285; + _S1262 = _S1287; } else { - FixedArray _S1286 = points_13; - FixedArray _S1287 = points_13; FixedArray _S1288 = points_13; FixedArray _S1289 = points_13; + FixedArray _S1290 = points_13; + FixedArray _S1291 = points_13; points_13[int(0)] = points_13[int(0)]; - points_13[int(1)] = _S1286[int(1)]; - points_13[int(2)] = _S1287[int(2)]; - points_13[int(3)] = _S1288[int(3)]; - points_13[int(4)] = _S1289[int(4)]; - _S1204 = _S1201; - _S1260 = _S1235; + points_13[int(1)] = _S1288[int(1)]; + points_13[int(2)] = _S1289[int(2)]; + points_13[int(3)] = _S1290[int(3)]; + points_13[int(4)] = _S1291[int(4)]; + _S1206 = _S1203; + _S1262 = _S1237; } - float3 _S1290 = _S1207 * (points_13[int(0)] + _S1204); - float _S1291 = _S1290.x + _S1290.y + _S1290.z; - float4 _S1292 = _S1235; - *&((&_S1292)->x) = _S1291; - _S1260 = _S1260 + _S1292; + float3 _S1292 = _S1209 * (points_13[int(0)] + _S1206); + float _S1293 = _S1292.x + _S1292.y + _S1292.z; + float4 _S1294 = _S1237; + *&((&_S1294)->x) = _S1293; + _S1262 = _S1262 + _S1294; } else { - _S1260 = _S1235; + _S1262 = _S1237; } - *v_depths_5 = _S1260; + *v_depths_5 = _S1262; *v_gt_normal_2 = raydir_22; return; } diff --git a/src/generated/ppisp.cuh b/src/generated/ppisp.cuh index da8da48a..c6c94deb 100644 --- a/src/generated/ppisp.cuh +++ b/src/generated/ppisp.cuh @@ -2641,25 +2641,7 @@ inline __device__ void s_bwd_prop_apply_ppisp_0(DiffPair_vectorx3Cfloatx2C3x3E_0 _S645[int(33)] = 0.0f; _S645[int(34)] = 0.0f; _S645[int(35)] = 0.0f; - _S645[int(35)] = _S618; - _S645[int(34)] = _S619; - _S645[int(33)] = _S620; - _S645[int(32)] = _S621; - _S645[int(31)] = _S622; - _S645[int(30)] = _S623; - _S645[int(29)] = _S624; - _S645[int(28)] = _S625; - _S645[int(27)] = _S626; - _S645[int(26)] = _S627; - _S645[int(25)] = _S628; - _S645[int(24)] = _S629; - _S645[int(23)] = _S617.color_params_3.n_0.y; - _S645[int(22)] = _S617.color_params_3.n_0.x; - _S645[int(21)] = _S617.color_params_3.g_0.y; - _S645[int(20)] = _S617.color_params_3.g_0.x; - _S645[int(19)] = _S617.color_params_3.r_0.y; - _S645[int(18)] = _S617.color_params_3.r_0.x; - _S645[int(17)] = _S617.color_params_3.b_0.y; + _S645[int(8)] = _S637; _S645[int(16)] = _S617.color_params_3.b_0.x; _S645[int(15)] = _S630; _S645[int(14)] = _S631; @@ -2668,7 +2650,7 @@ inline __device__ void s_bwd_prop_apply_ppisp_0(DiffPair_vectorx3Cfloatx2C3x3E_0 _S645[int(11)] = _S634; _S645[int(10)] = _S635; _S645[int(9)] = _S636; - _S645[int(8)] = _S637; + _S645[int(17)] = _S617.color_params_3.b_0.y; _S645[int(7)] = _S638; _S645[int(6)] = _S639; _S645[int(5)] = _S640; @@ -2677,6 +2659,24 @@ inline __device__ void s_bwd_prop_apply_ppisp_0(DiffPair_vectorx3Cfloatx2C3x3E_0 _S645[int(2)] = _S643; _S645[int(1)] = _S644; _S645[int(0)] = _S201.exposure_3; + _S645[int(26)] = _S627; + _S645[int(34)] = _S619; + _S645[int(33)] = _S620; + _S645[int(32)] = _S621; + _S645[int(31)] = _S622; + _S645[int(30)] = _S623; + _S645[int(29)] = _S624; + _S645[int(28)] = _S625; + _S645[int(27)] = _S626; + _S645[int(35)] = _S618; + _S645[int(25)] = _S628; + _S645[int(24)] = _S629; + _S645[int(23)] = _S617.color_params_3.n_0.y; + _S645[int(22)] = _S617.color_params_3.n_0.x; + _S645[int(21)] = _S617.color_params_3.g_0.y; + _S645[int(20)] = _S617.color_params_3.g_0.x; + _S645[int(19)] = _S617.color_params_3.r_0.y; + _S645[int(18)] = _S617.color_params_3.r_0.x; dpparams_0->primal_0 = dpparams_0->primal_0; dpparams_0->differential_0 = _S645; dprgb_in_0->primal_0 = (*dprgb_in_0).primal_0; @@ -3908,26 +3908,7 @@ inline __device__ void s_bwd_prop_apply_ppisp_rqs_0(DiffPair_vectorx3Cfloatx2C3x _S1185[int(36)] = 0.0f; _S1185[int(37)] = 0.0f; _S1185[int(38)] = 0.0f; - _S1185[int(38)] = _S1155; - _S1185[int(37)] = _S1156; - _S1185[int(36)] = _S1157; - _S1185[int(35)] = _S1158; - _S1185[int(34)] = _S1159; - _S1185[int(33)] = _S1160; - _S1185[int(32)] = _S1161; - _S1185[int(31)] = _S1162; - _S1185[int(30)] = _S1163; - _S1185[int(29)] = _S1164; - _S1185[int(28)] = _S1165; - _S1185[int(27)] = _S1166; - _S1185[int(26)] = _S1167; - _S1185[int(25)] = _S1168; - _S1185[int(24)] = _S1169; - _S1185[int(23)] = _S1154.color_params_2.n_0.y; - _S1185[int(22)] = _S1154.color_params_2.n_0.x; - _S1185[int(21)] = _S1154.color_params_2.g_0.y; - _S1185[int(20)] = _S1154.color_params_2.g_0.x; - _S1185[int(19)] = _S1154.color_params_2.r_0.y; + _S1185[int(9)] = _S1176; _S1185[int(18)] = _S1154.color_params_2.r_0.x; _S1185[int(17)] = _S1154.color_params_2.b_0.y; _S1185[int(16)] = _S1154.color_params_2.b_0.x; @@ -3937,7 +3918,7 @@ inline __device__ void s_bwd_prop_apply_ppisp_rqs_0(DiffPair_vectorx3Cfloatx2C3x _S1185[int(12)] = _S1173; _S1185[int(11)] = _S1174; _S1185[int(10)] = _S1175; - _S1185[int(9)] = _S1176; + _S1185[int(19)] = _S1154.color_params_2.r_0.y; _S1185[int(8)] = _S1177; _S1185[int(7)] = _S1178; _S1185[int(6)] = _S1179; @@ -3947,6 +3928,25 @@ inline __device__ void s_bwd_prop_apply_ppisp_rqs_0(DiffPair_vectorx3Cfloatx2C3x _S1185[int(2)] = _S1183; _S1185[int(1)] = _S1184; _S1185[int(0)] = _S663.exposure_2; + _S1185[int(28)] = _S1165; + _S1185[int(37)] = _S1156; + _S1185[int(36)] = _S1157; + _S1185[int(35)] = _S1158; + _S1185[int(34)] = _S1159; + _S1185[int(33)] = _S1160; + _S1185[int(32)] = _S1161; + _S1185[int(31)] = _S1162; + _S1185[int(30)] = _S1163; + _S1185[int(29)] = _S1164; + _S1185[int(38)] = _S1155; + _S1185[int(27)] = _S1166; + _S1185[int(26)] = _S1167; + _S1185[int(25)] = _S1168; + _S1185[int(24)] = _S1169; + _S1185[int(23)] = _S1154.color_params_2.n_0.y; + _S1185[int(22)] = _S1154.color_params_2.n_0.x; + _S1185[int(21)] = _S1154.color_params_2.g_0.y; + _S1185[int(20)] = _S1154.color_params_2.g_0.x; dpparams_1->primal_0 = dpparams_1->primal_0; dpparams_1->differential_0 = _S1185; dprgb_in_1->primal_0 = (*dprgb_in_1).primal_0; @@ -4517,30 +4517,30 @@ inline __device__ void s_bwd_prop_apply_ppisp_no_crf_0(DiffPair_vectorx3Cfloatx2 _S1391[int(21)] = 0.0f; _S1391[int(22)] = 0.0f; _S1391[int(23)] = 0.0f; - _S1391[int(23)] = _S1375.color_params_1.n_0.y; - _S1391[int(22)] = _S1375.color_params_1.n_0.x; - _S1391[int(21)] = _S1375.color_params_1.g_0.y; - _S1391[int(20)] = _S1375.color_params_1.g_0.x; - _S1391[int(19)] = _S1375.color_params_1.r_0.y; - _S1391[int(18)] = _S1375.color_params_1.r_0.x; - _S1391[int(17)] = _S1375.color_params_1.b_0.y; - _S1391[int(16)] = _S1375.color_params_1.b_0.x; - _S1391[int(15)] = _S1376; - _S1391[int(14)] = _S1377; - _S1391[int(13)] = _S1378; - _S1391[int(12)] = _S1379; _S1391[int(11)] = _S1380; - _S1391[int(10)] = _S1381; - _S1391[int(9)] = _S1382; - _S1391[int(8)] = _S1383; - _S1391[int(7)] = _S1384; - _S1391[int(6)] = _S1385; - _S1391[int(5)] = _S1386; - _S1391[int(4)] = _S1387; - _S1391[int(3)] = _S1388; - _S1391[int(2)] = _S1389; - _S1391[int(1)] = _S1390; _S1391[int(0)] = _S1201.exposure_1; + _S1391[int(1)] = _S1390; + _S1391[int(2)] = _S1389; + _S1391[int(3)] = _S1388; + _S1391[int(4)] = _S1387; + _S1391[int(5)] = _S1386; + _S1391[int(6)] = _S1385; + _S1391[int(7)] = _S1384; + _S1391[int(8)] = _S1383; + _S1391[int(9)] = _S1382; + _S1391[int(10)] = _S1381; + _S1391[int(23)] = _S1375.color_params_1.n_0.y; + _S1391[int(12)] = _S1379; + _S1391[int(13)] = _S1378; + _S1391[int(14)] = _S1377; + _S1391[int(15)] = _S1376; + _S1391[int(16)] = _S1375.color_params_1.b_0.x; + _S1391[int(17)] = _S1375.color_params_1.b_0.y; + _S1391[int(18)] = _S1375.color_params_1.r_0.x; + _S1391[int(19)] = _S1375.color_params_1.r_0.y; + _S1391[int(20)] = _S1375.color_params_1.g_0.x; + _S1391[int(21)] = _S1375.color_params_1.g_0.y; + _S1391[int(22)] = _S1375.color_params_1.n_0.x; dpparams_2->primal_0 = dpparams_2->primal_0; dpparams_2->differential_0 = _S1391; dprgb_in_2->primal_0 = (*dprgb_in_2).primal_0; @@ -5691,25 +5691,7 @@ inline __device__ void s_bwd_prop_compute_raw_ppisp_regularization_loss_0(DiffPa _S1806[int(33)] = 0.0f; _S1806[int(34)] = 0.0f; _S1806[int(35)] = 0.0f; - _S1806[int(35)] = _S1779; - _S1806[int(34)] = _S1780; - _S1806[int(33)] = _S1781; - _S1806[int(32)] = _S1782; - _S1806[int(31)] = _S1783; - _S1806[int(30)] = _S1784; - _S1806[int(29)] = _S1785; - _S1806[int(28)] = _S1786; - _S1806[int(27)] = _S1787; - _S1806[int(26)] = _S1788; - _S1806[int(25)] = _S1789; - _S1806[int(24)] = _S1790; - _S1806[int(23)] = _S1778.color_params_3.n_0.y; - _S1806[int(22)] = _S1778.color_params_3.n_0.x; - _S1806[int(21)] = _S1778.color_params_3.g_0.y; - _S1806[int(20)] = _S1778.color_params_3.g_0.x; - _S1806[int(19)] = _S1778.color_params_3.r_0.y; - _S1806[int(18)] = _S1778.color_params_3.r_0.x; - _S1806[int(17)] = _S1778.color_params_3.b_0.y; + _S1806[int(8)] = _S1798; _S1806[int(16)] = _S1778.color_params_3.b_0.x; _S1806[int(15)] = _S1791; _S1806[int(14)] = _S1792; @@ -5718,7 +5700,7 @@ inline __device__ void s_bwd_prop_compute_raw_ppisp_regularization_loss_0(DiffPa _S1806[int(11)] = _S1795; _S1806[int(10)] = _S1796; _S1806[int(9)] = _S1797; - _S1806[int(8)] = _S1798; + _S1806[int(17)] = _S1778.color_params_3.b_0.y; _S1806[int(7)] = _S1799; _S1806[int(6)] = _S1800; _S1806[int(5)] = _S1801; @@ -5727,6 +5709,24 @@ inline __device__ void s_bwd_prop_compute_raw_ppisp_regularization_loss_0(DiffPa _S1806[int(2)] = _S1804; _S1806[int(1)] = _S1805; _S1806[int(0)] = _S1611.exposure_3; + _S1806[int(26)] = _S1788; + _S1806[int(34)] = _S1780; + _S1806[int(33)] = _S1781; + _S1806[int(32)] = _S1782; + _S1806[int(31)] = _S1783; + _S1806[int(30)] = _S1784; + _S1806[int(29)] = _S1785; + _S1806[int(28)] = _S1786; + _S1806[int(27)] = _S1787; + _S1806[int(35)] = _S1779; + _S1806[int(25)] = _S1789; + _S1806[int(24)] = _S1790; + _S1806[int(23)] = _S1778.color_params_3.n_0.y; + _S1806[int(22)] = _S1778.color_params_3.n_0.x; + _S1806[int(21)] = _S1778.color_params_3.g_0.y; + _S1806[int(20)] = _S1778.color_params_3.g_0.x; + _S1806[int(19)] = _S1778.color_params_3.r_0.y; + _S1806[int(18)] = _S1778.color_params_3.r_0.x; dpparams_4->primal_0 = dpparams_4->primal_0; dpparams_4->differential_0 = _S1806; return; @@ -6194,26 +6194,7 @@ inline __device__ void s_bwd_prop_compute_raw_ppisp_rqs_regularization_loss_0(Di _S2028[int(36)] = 0.0f; _S2028[int(37)] = 0.0f; _S2028[int(38)] = 0.0f; - _S2028[int(38)] = _S1998; - _S2028[int(37)] = _S1999; - _S2028[int(36)] = _S2000; - _S2028[int(35)] = _S2001; - _S2028[int(34)] = _S2002; - _S2028[int(33)] = _S2003; - _S2028[int(32)] = _S2004; - _S2028[int(31)] = _S2005; - _S2028[int(30)] = _S2006; - _S2028[int(29)] = _S2007; - _S2028[int(28)] = _S2008; - _S2028[int(27)] = _S2009; - _S2028[int(26)] = _S2010; - _S2028[int(25)] = _S2011; - _S2028[int(24)] = _S2012; - _S2028[int(23)] = _S1997.color_params_2.n_0.y; - _S2028[int(22)] = _S1997.color_params_2.n_0.x; - _S2028[int(21)] = _S1997.color_params_2.g_0.y; - _S2028[int(20)] = _S1997.color_params_2.g_0.x; - _S2028[int(19)] = _S1997.color_params_2.r_0.y; + _S2028[int(9)] = _S2019; _S2028[int(18)] = _S1997.color_params_2.r_0.x; _S2028[int(17)] = _S1997.color_params_2.b_0.y; _S2028[int(16)] = _S1997.color_params_2.b_0.x; @@ -6223,7 +6204,7 @@ inline __device__ void s_bwd_prop_compute_raw_ppisp_rqs_regularization_loss_0(Di _S2028[int(12)] = _S2016; _S2028[int(11)] = _S2017; _S2028[int(10)] = _S2018; - _S2028[int(9)] = _S2019; + _S2028[int(19)] = _S1997.color_params_2.r_0.y; _S2028[int(8)] = _S2020; _S2028[int(7)] = _S2021; _S2028[int(6)] = _S2022; @@ -6233,6 +6214,25 @@ inline __device__ void s_bwd_prop_compute_raw_ppisp_rqs_regularization_loss_0(Di _S2028[int(2)] = _S2026; _S2028[int(1)] = _S2027; _S2028[int(0)] = _S1819.exposure_2; + _S2028[int(28)] = _S2008; + _S2028[int(37)] = _S1999; + _S2028[int(36)] = _S2000; + _S2028[int(35)] = _S2001; + _S2028[int(34)] = _S2002; + _S2028[int(33)] = _S2003; + _S2028[int(32)] = _S2004; + _S2028[int(31)] = _S2005; + _S2028[int(30)] = _S2006; + _S2028[int(29)] = _S2007; + _S2028[int(38)] = _S1998; + _S2028[int(27)] = _S2009; + _S2028[int(26)] = _S2010; + _S2028[int(25)] = _S2011; + _S2028[int(24)] = _S2012; + _S2028[int(23)] = _S1997.color_params_2.n_0.y; + _S2028[int(22)] = _S1997.color_params_2.n_0.x; + _S2028[int(21)] = _S1997.color_params_2.g_0.y; + _S2028[int(20)] = _S1997.color_params_2.g_0.x; dpparams_5->primal_0 = dpparams_5->primal_0; dpparams_5->differential_0 = _S2028; return; @@ -6685,30 +6685,30 @@ inline __device__ void s_bwd_prop_compute_raw_ppisp_no_crf_regularization_loss_0 _S2202[int(21)] = 0.0f; _S2202[int(22)] = 0.0f; _S2202[int(23)] = 0.0f; - _S2202[int(23)] = _S2186.color_params_1.n_0.y; - _S2202[int(22)] = _S2186.color_params_1.n_0.x; - _S2202[int(21)] = _S2186.color_params_1.g_0.y; - _S2202[int(20)] = _S2186.color_params_1.g_0.x; - _S2202[int(19)] = _S2186.color_params_1.r_0.y; - _S2202[int(18)] = _S2186.color_params_1.r_0.x; - _S2202[int(17)] = _S2186.color_params_1.b_0.y; - _S2202[int(16)] = _S2186.color_params_1.b_0.x; - _S2202[int(15)] = _S2187; - _S2202[int(14)] = _S2188; - _S2202[int(13)] = _S2189; - _S2202[int(12)] = _S2190; _S2202[int(11)] = _S2191; - _S2202[int(10)] = _S2192; - _S2202[int(9)] = _S2193; - _S2202[int(8)] = _S2194; - _S2202[int(7)] = _S2195; - _S2202[int(6)] = _S2196; - _S2202[int(5)] = _S2197; - _S2202[int(4)] = _S2198; - _S2202[int(3)] = _S2199; - _S2202[int(2)] = _S2200; - _S2202[int(1)] = _S2201; _S2202[int(0)] = _S2063.exposure_1; + _S2202[int(1)] = _S2201; + _S2202[int(2)] = _S2200; + _S2202[int(3)] = _S2199; + _S2202[int(4)] = _S2198; + _S2202[int(5)] = _S2197; + _S2202[int(6)] = _S2196; + _S2202[int(7)] = _S2195; + _S2202[int(8)] = _S2194; + _S2202[int(9)] = _S2193; + _S2202[int(10)] = _S2192; + _S2202[int(23)] = _S2186.color_params_1.n_0.y; + _S2202[int(12)] = _S2190; + _S2202[int(13)] = _S2189; + _S2202[int(14)] = _S2188; + _S2202[int(15)] = _S2187; + _S2202[int(16)] = _S2186.color_params_1.b_0.x; + _S2202[int(17)] = _S2186.color_params_1.b_0.y; + _S2202[int(18)] = _S2186.color_params_1.r_0.x; + _S2202[int(19)] = _S2186.color_params_1.r_0.y; + _S2202[int(20)] = _S2186.color_params_1.g_0.x; + _S2202[int(21)] = _S2186.color_params_1.g_0.y; + _S2202[int(22)] = _S2186.color_params_1.n_0.x; dpparams_6->primal_0 = dpparams_6->primal_0; dpparams_6->differential_0 = _S2202; return; diff --git a/src/i18n/catalog/TrainFields.h b/src/i18n/catalog/TrainFields.h index edacf952..7fa55cd3 100644 --- a/src/i18n/catalog/TrainFields.h +++ b/src/i18n/catalog/TrainFields.h @@ -2744,6 +2744,70 @@ SS_MSG(background_noise_warmup_help, TR("Arka plan gürültüsünün tam güce ulaşması için gereken adım sayısı. Yalnızca " "`noise` / `pseudorandom` / `random` arka planlarıyla kullanılır.")); +SS_MSG(background_match_luminance, + EN("Match background to image brightness"), JA("背景を画像の明るさに合わせる"), + ZH_HANS("背景亮度匹配图像"), ZH_HANT("背景亮度匹配圖像"), + KO("배경을 이미지 밝기에 맞춤"), DE("Hintergrund an Bildhelligkeit anpassen"), + FR("Adapter le fond à la luminosité de l'image"), + ES("Ajustar el fondo al brillo de la imagen"), + PT("Ajustar o fundo ao brilho da imagem"), + IT("Adatta lo sfondo alla luminosità dell'immagine"), + NL("Achtergrond aan beeldhelderheid aanpassen"), + RU("Подогнать фон под яркость снимка"), + TR("Arka planı görüntü parlaklığına uydur")); +SS_MSG(background_match_luminance_help, + EN("Raises the randomized background to a power so its typical brightness lands " + "on each photo's mean brightness, corrected for that photo's exposure. Keeps " + "dark scenes from being plugged with haze to hide a bright background. Only " + "used with the `noise` / `pseudorandom` / `random` backgrounds."), + JA("ランダム背景をべき乗して、その典型的な明るさが各写真の平均の明るさ(露出補正済み)" + "になるようにします。暗いシーンで明るい背景を隠すためにもやが詰め込まれるのを防ぎ" + "ます。背景が `noise` / `pseudorandom` / `random` のときだけ使われます。"), + ZH_HANS("对随机背景做幂运算,使其典型亮度落在每张照片的平均亮度上(已按该照片的曝光" + "校正)。避免暗场景为了遮住明亮背景而被雾状泼溅填满。仅在背景为 `noise` / " + "`pseudorandom` / `random` 时使用。"), + ZH_HANT("對隨機背景做冪運算,使其典型亮度落在每張照片的平均亮度上(已按該照片的曝光" + "校正)。避免暗場景為了遮住明亮背景而被霧狀潑濺填滿。僅在背景為 `noise` / " + "`pseudorandom` / `random` 時使用。"), + KO("무작위 배경을 거듭제곱하여 그 전형적인 밝기가 각 사진의 평균 밝기(노출 보정 후)에 " + "오도록 합니다. 어두운 장면이 밝은 배경을 가리려고 안개로 채워지는 것을 막습니다. " + "배경이 `noise` / `pseudorandom` / `random`일 때만 쓰입니다."), + DE("Potenziert den zufälligen Hintergrund, sodass seine typische Helligkeit auf " + "der mittleren Helligkeit jedes Fotos landet, um dessen Belichtung korrigiert. " + "Verhindert, dass dunkle Szenen mit Dunst zugesetzt werden, um einen hellen " + "Hintergrund zu verbergen. Wird nur mit den Hintergründen `noise` / " + "`pseudorandom` / `random` verwendet."), + FR("Élève le fond aléatoire à une puissance pour que sa luminosité typique tombe " + "sur la luminosité moyenne de chaque photo, corrigée de son exposition. Évite " + "que les scènes sombres se remplissent de brume pour cacher un fond clair. " + "Utilisé uniquement avec les arrière-plans `noise` / `pseudorandom` / `random`."), + ES("Eleva el fondo aleatorio a una potencia para que su brillo típico coincida con " + "el brillo medio de cada foto, corregido por su exposición. Evita que las " + "escenas oscuras se rellenen de neblina para ocultar un fondo claro. Solo se " + "usa con los fondos `noise` / `pseudorandom` / `random`."), + PT("Eleva o fundo aleatório a uma potência para que o seu brilho típico caia no " + "brilho médio de cada foto, corrigido pela exposição dela. Evita que cenas " + "escuras sejam preenchidas com névoa para esconder um fundo claro. Só é usado " + "com os fundos `noise` / `pseudorandom` / `random`."), + IT("Eleva lo sfondo casuale a una potenza così che la sua luminosità tipica " + "coincida con la luminosità media di ogni foto, corretta per la sua " + "esposizione. Evita che le scene scure si riempiano di foschia per nascondere " + "uno sfondo chiaro. Usato solo con gli sfondi `noise` / `pseudorandom` / " + "`random`."), + NL("Verheft de willekeurige achtergrond tot een macht zodat zijn typische " + "helderheid op de gemiddelde helderheid van elke foto valt, gecorrigeerd voor " + "de belichting ervan. Voorkomt dat donkere scènes met waas worden dichtgezet om " + "een lichte achtergrond te verbergen. Wordt alleen bij de achtergronden " + "`noise` / `pseudorandom` / `random` gebruikt."), + RU("Возводит случайный фон в степень, чтобы его типичная яркость совпала со " + "средней яркостью каждого снимка с поправкой на его экспозицию. Не даёт тёмным " + "сценам забиваться дымкой, скрывающей яркий фон. Используется только с фонами " + "`noise` / `pseudorandom` / `random`."), + TR("Rastgele arka planı bir kuvvete yükselterek tipik parlaklığının her " + "fotoğrafın pozlamasına göre düzeltilmiş ortalama parlaklığına denk gelmesini " + "sağlar. Karanlık sahnelerin parlak bir arka planı gizlemek için pusla " + "dolmasını önler. Yalnızca `noise` / `pseudorandom` / `random` arka " + "planlarıyla kullanılır.")); SS_MSG(background_noise_pre_warmup, EN("Initial background noise"), JA("最初の背景ノイズの強さ"), ZH_HANS("初始背景噪声强度"), ZH_HANT("初始背景雜訊強度"), @@ -5391,73 +5455,86 @@ SS_MSG(loss_saturation_threshold_help, "ikisi de kırpılmıştır, oradaki hata gerçek değildir. Negatif (varsayılan) " "her pikseli tutar.")); -SS_MSG(normalize_loss_by_luminance, - EN("Scale color error by brightness"), JA("明るさで色の誤差を調整"), - ZH_HANS("按亮度缩放颜色误差"), ZH_HANT("依亮度縮放顏色誤差"), - KO("밝기로 색 오차 조정"), - DE("Farbfehler nach Helligkeit skalieren"), - FR("Mettre l'erreur de couleur à l'échelle de la luminosité"), - ES("Escalar el error de color según el brillo"), - PT("Escalar o erro de cor pelo brilho"), - IT("Scalare l'errore di colore con la luminosità"), - NL("Kleurfout schalen met de helderheid"), - RU("Масштабировать ошибку цвета по яркости"), - TR("Renk hatasını parlaklığa göre ölçekle")); -SS_MSG(normalize_loss_by_luminance_help, - EN("Scales the color-error weights (L1, L2 and SSIM) by twice the mean " - "brightness of the photo, measured in sRGB, so a dark capture counts for " - "as much as a bright one. It is meant for training in linear light, where " +SS_MSG(loss_luminance_normalization, + EN("Brightness normalization of color error"), JA("色の誤差の明るさ正規化"), + ZH_HANS("颜色误差的亮度归一化"), ZH_HANT("顏色誤差的亮度正規化"), + KO("색 오차의 밝기 정규화"), + DE("Helligkeitsnormierung des Farbfehlers"), + FR("Normalisation de l'erreur de couleur par la luminosité"), + ES("Normalización del error de color por el brillo"), + PT("Normalização do erro de cor pelo brilho"), + IT("Normalizzazione dell'errore di colore per luminosità"), + NL("Helderheidsnormalisatie van de kleurfout"), + RU("Нормировка ошибки цвета по яркости"), + TR("Renk hatasının parlaklık normalizasyonu")); +SS_MSG(loss_luminance_normalization_help, + EN("Divides the color-error weights (L1, L2 and SSIM) by twice the photo's " + "mean brightness, measured in sRGB, raised to this power: 0 leaves them " + "alone, 1 makes a dark capture count for as much as a bright one, and " + "values in between soften that. Meant for training in linear light, where " "the display curve already makes a dark pixel push harder."), JA("色の誤差の重み(L1, L2, SSIM)を, sRGB で測った写真の平均的な明るさの二" - "倍で調整します。暗い写真も明るい写真と同じだけ効くようになります。線形" - "の光での学習を想定しています。そこでは表示曲線のせいで暗い画素のほうが" - "強く効いてしまいます。"), - ZH_HANS("把颜色误差的权重(L1、L2 和 SSIM)乘以照片在 sRGB 下平均亮度的两" - "倍,让偏暗的照片和明亮的照片起同样的作用。它是为线性光下的训练准备" - "的:在那里显示曲线本来就让暗像素推得更用力。"), - ZH_HANT("把顏色誤差的權重(L1、L2 和 SSIM)乘以照片在 sRGB 下平均亮度的兩" - "倍,讓偏暗的照片和明亮的照片起同樣的作用。它是為線性光下的訓練準備" - "的:在那裡顯示曲線本來就讓暗像素推得更用力。"), - KO("색 오차 가중치(L1, L2, SSIM)에 sRGB로 잰 사진의 평균 밝기의 두 배를 곱" - "합니다. 어두운 사진도 밝은 사진만큼 힘을 냅니다. 선형 광에서 학습할 때" - "를 위한 것으로, 거기서는 표시 곡선 때문에 어두운 픽셀이 더 세게 밀어붙" - "입니다."), - DE("Skaliert die Gewichte des Farbfehlers (L1, L2 und SSIM) mit der " - "doppelten mittleren Helligkeit des Fotos, gemessen in sRGB, sodass eine " - "dunkle Aufnahme so viel zählt wie eine helle. Gedacht für das Training " - "in linearem Licht, wo die Anzeigekurve ein dunkles Pixel ohnehin stärker " - "drücken lässt."), - FR("Met les poids de l'erreur de couleur (L1, L2 et SSIM) à l'échelle du " - "double de la luminosité moyenne de la photo, mesurée en sRGB, pour qu'une " - "prise sombre compte autant qu'une prise claire. Prévu pour " - "l'entraînement en lumière linéaire, où la courbe d'affichage fait déjà " - "pousser un pixel sombre plus fort."), - ES("Escala los pesos del error de color (L1, L2 y SSIM) por el doble del " - "brillo medio de la foto, medido en sRGB, para que una toma oscura cuente " - "tanto como una clara. Está pensado para el entrenamiento en luz lineal, " - "donde la curva de pantalla ya hace que un píxel oscuro empuje más fuerte."), - PT("Escala os pesos do erro de cor (L1, L2 e SSIM) pelo dobro do brilho " - "médio da foto, medido em sRGB, para que uma captura escura conte tanto " - "quanto uma clara. Destina-se ao treino em luz linear, onde a curva de " - "exibição já faz um pixel escuro empurrar com mais força."), - IT("Scala i pesi dell'errore di colore (L1, L2 e SSIM) per il doppio della " - "luminosità media della foto, misurata in sRGB, così uno scatto scuro " - "conta quanto uno chiaro. È pensato per l'addestramento in luce lineare, " - "dove la curva di visualizzazione fa già spingere di più un pixel scuro."), - NL("Schaalt de gewichten van de kleurfout (L1, L2 en SSIM) met tweemaal de " - "gemiddelde helderheid van de foto, gemeten in sRGB, zodat een donkere " - "opname net zo zwaar telt als een lichte. Bedoeld voor training in " - "lineair licht, waar de weergavecurve een donkere pixel toch al harder " + "倍のこの値乗で割ります。0 では何もせず, 1 では暗い写真も明るい写真と同" + "じだけ効き, その間の値ではそれを弱めます。線形の光での学習を想定してい" + "ます。そこでは表示曲線のせいで暗い画素のほうが強く効いてしまいます。"), + ZH_HANS("把颜色误差的权重(L1、L2 和 SSIM)除以照片在 sRGB 下平均亮度两倍的" + "此值次幂:0 不做处理,1 让偏暗的照片和明亮的照片起同样的作用,中间" + "的值则减弱这种效果。它是为线性光下的训练准备的:在那里显示曲线本来" + "就让暗像素推得更用力。"), + ZH_HANT("把顏色誤差的權重(L1、L2 和 SSIM)除以照片在 sRGB 下平均亮度兩倍的" + "此值次冪:0 不做處理,1 讓偏暗的照片和明亮的照片起同樣的作用,中間" + "的值則減弱這種效果。它是為線性光下的訓練準備的:在那裡顯示曲線本來" + "就讓暗像素推得更用力。"), + KO("색 오차 가중치(L1, L2, SSIM)를 sRGB로 잰 사진의 평균 밝기의 두 배를 이 " + "값으로 거듭제곱한 수로 나눕니다. 0은 아무것도 하지 않고, 1은 어두운 사진" + "도 밝은 사진만큼 힘을 내게 하며, 그 사이 값은 이를 완화합니다. 선형 광에" + "서 학습할 때를 위한 것으로, 거기서는 표시 곡선 때문에 어두운 픽셀이 더 " + "세게 밀어붙입니다."), + DE("Teilt die Gewichte des Farbfehlers (L1, L2 und SSIM) durch die doppelte " + "mittlere Helligkeit des Fotos, gemessen in sRGB, hoch diesen Wert: 0 lässt " + "sie unverändert, 1 lässt eine dunkle Aufnahme so viel zählen wie eine " + "helle, Werte dazwischen mildern das. Gedacht für das Training in linearem " + "Licht, wo die Anzeigekurve ein dunkles Pixel ohnehin stärker drücken " + "lässt."), + FR("Divise les poids de l'erreur de couleur (L1, L2 et SSIM) par le double de " + "la luminosité moyenne de la photo, mesurée en sRGB, élevé à cette " + "puissance : 0 ne change rien, 1 fait compter une prise sombre autant " + "qu'une prise claire, et les valeurs intermédiaires adoucissent cela. Prévu " + "pour l'entraînement en lumière linéaire, où la courbe d'affichage fait " + "déjà pousser un pixel sombre plus fort."), + ES("Divide los pesos del error de color (L1, L2 y SSIM) por el doble del " + "brillo medio de la foto, medido en sRGB, elevado a esta potencia: 0 no " + "cambia nada, 1 hace que una toma oscura cuente tanto como una clara, y los " + "valores intermedios lo suavizan. Está pensado para el entrenamiento en luz " + "lineal, donde la curva de pantalla ya hace que un píxel oscuro empuje más " + "fuerte."), + PT("Divide os pesos do erro de cor (L1, L2 e SSIM) pelo dobro do brilho médio " + "da foto, medido em sRGB, elevado a esta potência: 0 não muda nada, 1 faz " + "uma captura escura contar tanto quanto uma clara, e valores intermédios " + "suavizam isso. Destina-se ao treino em luz linear, onde a curva de exibição " + "já faz um pixel escuro empurrar com mais força."), + IT("Divide i pesi dell'errore di colore (L1, L2 e SSIM) per il doppio della " + "luminosità media della foto, misurata in sRGB, elevato a questa potenza: 0 " + "non cambia nulla, 1 fa contare uno scatto scuro quanto uno chiaro, e i " + "valori intermedi lo attenuano. È pensato per l'addestramento in luce " + "lineare, dove la curva di visualizzazione fa già spingere di più un pixel " + "scuro."), + NL("Deelt de gewichten van de kleurfout (L1, L2 en SSIM) door tweemaal de " + "gemiddelde helderheid van de foto, gemeten in sRGB, tot deze macht " + "verheven: 0 verandert niets, 1 laat een donkere opname net zo zwaar tellen " + "als een lichte, en waarden ertussen verzachten dat. Bedoeld voor training " + "in lineair licht, waar de weergavecurve een donkere pixel toch al harder " "laat duwen."), - RU("Масштабирует веса ошибки цвета (L1, L2 и SSIM) на удвоенную среднюю " - "яркость снимка, измеренную в sRGB, чтобы тёмный кадр значил столько же, " - "сколько светлый. Предназначено для обучения в линейном свете, где кривая " + RU("Делит веса ошибки цвета (L1, L2 и SSIM) на удвоенную среднюю яркость " + "снимка, измеренную в sRGB, в этой степени: 0 ничего не меняет, 1 делает " + "тёмный кадр столь же весомым, как светлый, промежуточные значения " + "смягчают это. Предназначено для обучения в линейном свете, где кривая " "отображения и так заставляет тёмный пиксель давить сильнее."), - TR("Renk hatası ağırlıklarını, fotoğrafın sRGB'de ölçülen ortalama " - "parlaklığının iki katıyla ölçekler (L1, L2 ve SSIM); böylece karanlık bir " - "çekim aydınlık olan kadar sayılır. Doğrusal ışıkta eğitim için " - "düşünülmüştür; orada görüntüleme eğrisi karanlık pikseli zaten daha sert " - "ittirir.")); + TR("Renk hatası ağırlıklarını (L1, L2 ve SSIM), fotoğrafın sRGB'de ölçülen " + "ortalama parlaklığının iki katının bu kuvvetine böler: 0 hiçbir şey " + "değiştirmez, 1 karanlık bir çekimi aydınlık olan kadar saydırır, aradaki " + "değerler bunu yumuşatır. Doğrusal ışıkta eğitim için düşünülmüştür; orada " + "görüntüleme eğrisi karanlık pikseli zaten daha sert ittirir.")); // =========================================================================== diff --git a/src/kernels/pixelwise/ImageColorOps.cu b/src/kernels/pixelwise/ImageColorOps.cu index b1d4bedb..8cb1b988 100644 --- a/src/kernels/pixelwise/ImageColorOps.cu +++ b/src/kernels/pixelwise/ImageColorOps.cu @@ -169,13 +169,21 @@ __device__ __forceinline__ float3 _bg_sample(bool blocky, unsigned block_px, return u; } +// Per-image power on the display draw; 1 (identity) without a table. +__device__ __forceinline__ float _bg_exponent(unsigned bid, + const float* exponent_by_cam, + const int32_t* cam_indices) { + return exponent_by_cam ? exponent_by_cam[cam_indices[bid]] : 1.0f; +} + template __device__ __forceinline__ float3 _bg_color(bool blocky, unsigned block_px, uint32_t seed, unsigned bid, unsigned x, unsigned y, unsigned W, - float randomize_weight) { + float randomize_weight, float p) { float3 background = _bg_sample(blocky, block_px, seed, bid, x, y, W); background = 0.5 + 0.5*randomize_weight * background; + background = SlangPixelWise::background_apply_exponent(background, p); return SlangPixelWise::display_to_working3(background, Transfer, IsLinear); } @@ -187,6 +195,8 @@ __global__ void blend_background_noise_forward_kernel( const uint32_t seed, const bool blocky, const unsigned block_px, + const float* __restrict__ exponent_by_cam, + const int32_t* __restrict__ cam_indices, TensorView out_rgb ) { unsigned gid = blockIdx.x * blockDim.x + threadIdx.x; @@ -201,7 +211,8 @@ __global__ void blend_background_noise_forward_kernel( float transmittance = in_transmittance.load1(bid, y, x); float3 background = _bg_color( - blocky, block_px, seed, bid, x, y, W, randomize_weight); + blocky, block_px, seed, bid, x, y, W, randomize_weight, + _bg_exponent(bid, exponent_by_cam, cam_indices)); rgb = SlangPixelWise::blend_background(rgb, transmittance, background); @@ -216,6 +227,8 @@ __global__ void blend_background_noise_backward_kernel( const uint32_t seed, const bool blocky, const unsigned block_px, + const float* __restrict__ exponent_by_cam, + const int32_t* __restrict__ cam_indices, const float overexposure_scale, const TensorView v_out_rgb, TensorView v_in_rgb, @@ -233,7 +246,8 @@ __global__ void blend_background_noise_backward_kernel( float transmittance = in_transmittance.load1(bid, y, x); float3 background = _bg_color( - blocky, block_px, seed, bid, x, y, W, randomize_weight); + blocky, block_px, seed, bid, x, y, W, randomize_weight, + _bg_exponent(bid, exponent_by_cam, cam_indices)); float3 v_out = v_out_rgb.load3(bid, y, x); @@ -258,6 +272,8 @@ void blend_background_noise_forward( DeviceTensor3D transmittance, // [B, H, W, 1] float randomize_weight, uint32_t seed, + const float* exponent_by_cam, // power per camera slot; null = 1 + const int32_t* cam_indices, // [B] slot per image DeviceTensor3D out_rgb // [B, H, W, 3] ) { long b = rgb.size<0>(), h = rgb.size<1>(), w = rgb.size<2>(); @@ -266,6 +282,7 @@ void blend_background_noise_forward( <<<_LAUNCH_ARGS_2D(h*w, b, 256, 1)>>>( _dt3d_to_tv4(rgb), _dt3d_to_tv4(transmittance), randomize_weight, seed, blocky, block_px, + exponent_by_cam, cam_indices, _dt3d_to_tv4(out_rgb) ); CHECK_DEVICE_ERROR(cudaGetLastError()); @@ -281,6 +298,8 @@ void blend_background_noise_backward( DeviceTensor3D transmittance, // [B, H, W, 1] float randomize_weight, uint32_t seed, + const float* exponent_by_cam, // as in the forward + const int32_t* cam_indices, float overexposure_weight, // fused image-space reg, 0 = off DeviceTensor3D v_out_rgb, // [B, H, W, 3] DeviceTensor3D v_rgb, // [B, H, W, 3] @@ -292,6 +311,7 @@ void blend_background_noise_backward( <<<_LAUNCH_ARGS_2D(h*w, b, 256, 1)>>>( _dt3d_to_tv4(rgb), _dt3d_to_tv4(transmittance), randomize_weight, seed, blocky, block_px, + exponent_by_cam, cam_indices, _overexposure_scale(b, h, w, overexposure_weight), _dt3d_to_tv4(v_out_rgb), _dt3d_to_tv4(v_rgb), _dt3d_to_tv4(v_transmittance) diff --git a/src/kernels/pixelwise/PixelWise.cuh b/src/kernels/pixelwise/PixelWise.cuh index e31bf085..c2f54369 100644 --- a/src/kernels/pixelwise/PixelWise.cuh +++ b/src/kernels/pixelwise/PixelWise.cuh @@ -211,6 +211,8 @@ void blend_background_noise_forward( DeviceTensor3D transmittance, // [B, H, W, 1] float randomize_weight, uint32_t seed, + const float* exponent_by_cam, // power per camera slot; null = 1 + const int32_t* cam_indices, // [B] slot per image DeviceTensor3D out_rgb // [B, H, W, 3] ); @@ -224,6 +226,8 @@ void blend_background_noise_backward( DeviceTensor3D transmittance, // [B, H, W, 1] float randomize_weight, uint32_t seed, + const float* exponent_by_cam, // as in the forward + const int32_t* cam_indices, float overexposure_weight, // fused image-space reg, 0 = off DeviceTensor3D v_out_rgb, // [B, H, W, 3] DeviceTensor3D v_rgb, // [B, H, W, 3] diff --git a/src/shaders/pixel_wise.slang b/src/shaders/pixel_wise.slang index f1f758a7..223e0ea5 100644 --- a/src/shaders/pixel_wise.slang +++ b/src/shaders/pixel_wise.slang @@ -239,7 +239,10 @@ float tone_encode(float x, no_diff int transfer) { return linear_rgb_to_srgb(xfer_clamp01(xfer_uncharted2(x))); if (transfer == kXferSrgbClamped) return linear_rgb_to_srgb(xfer_clamp01(x)); - return linear_rgb_to_srgb(x); + // Clipped at black, open above: a wide-gamut splat outside Rec.709 lands + // below zero here, and the PPISP chromaticity homography downstream has a + // pole there (measured: display values of 1e3..1e7 on an ACEScg run). + return linear_rgb_to_srgb(xfer_max0(x)); } float tone_decode(float d, int transfer) { @@ -287,6 +290,16 @@ float3 display_to_working3(float3 rgb, int transfer, bool is_linear) { linear_rgb_to_srgb(lin.z)); } +// The randomized background's display draw raised to a per-image power (the +// host's _bg_luma_exponent). p == 1 returns the draw untouched, so a run +// without the option is bit-exact. +[CudaDeviceExport] +float3 background_apply_exponent(float3 display, float p) { + if (p == 1.0f) return display; + return float3(pow(max(display.x, 0.0f), p), pow(max(display.y, 0.0f), p), + pow(max(display.z, 0.0f), p)); +} + // Unproject an undistorted, normalized image point to a ray direction. // Handles all camera models (PINHOLE / FISHEYE / EQUISOLID); EQUIRECTANGULAR // is currently unsupported and falls back to PINHOLE.