Module: Gsplat::NativeOps
- Defined in:
- lib/gsplat/native_ops.rb
Overview
Ruby-facing validation and fallback wrappers for native operations.
Class Method Summary collapse
- .isect_offset_encode(keys, camera_count, tile_width, tile_height) ⇒ Object
-
.isect_tiles(means2d, radii, depths, tile_size, tile_width, tile_height, sort:) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
.projection_forward(means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d:, near_plane:, far_plane:, radius_clip:, calc_compensations:, camera_model:, radial_coeffs: nil, tangential_coeffs: nil, thin_prism_coeffs: nil, global_z_order: true) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- .spherical_harmonics_forward(degree, directions, coefficients, masks: nil) ⇒ Object
Class Method Details
.isect_offset_encode(keys, camera_count, tile_width, tile_height) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/gsplat/native_ops.rb', line 94 def isect_offset_encode(keys, camera_count, tile_width, tile_height) Backend::RubyIsectTiles.send(:validate_grid!, camera_count, tile_width, tile_height) unless keys.is_a?(Numo::Int64) return Backend::RubyIsectTiles.offset_encode(keys, camera_count, tile_width, tile_height) end raise ShapeError, "expected isect_ids [M]" unless keys.ndim == 1 Native.isect_offset_encode_int64(keys.dup, camera_count, tile_width, tile_height) end |
.isect_tiles(means2d, radii, depths, tile_size, tile_width, tile_height, sort:) ⇒ Object
rubocop:disable Metrics/ParameterLists
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/gsplat/native_ops.rb', line 69 def isect_tiles(means2d, radii, depths, tile_size, tile_width, tile_height, sort:) # rubocop:enable Metrics/ParameterLists prepared = Backend::RubyIsectTiles.send( :validate_inputs, means2d, radii, depths, tile_size, tile_width, tile_height ) typed_means, typed_radii, typed_depths = prepared unless typed_means.is_a?(Numo::SFloat) return Backend::RubyIsectTiles.forward( means2d, radii, depths, tile_size, tile_width, tile_height, sort: sort ) end tile_bits = Backend::RubyIsectTiles.send(:tile_n_bits, tile_width, tile_height) Backend::RubyIsectTiles.send(:validate_key_width!, typed_means.shape[0], tile_bits) Native.isect_tiles_sfloat( typed_means.dup, typed_radii.dup, typed_depths.dup, tile_size, tile_width, tile_height, sort ) end |
.projection_forward(means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d:, near_plane:, far_plane:, radius_clip:, calc_compensations:, camera_model:, radial_coeffs: nil, tangential_coeffs: nil, thin_prism_coeffs: nil, global_z_order: true) ⇒ Object
rubocop:disable Metrics/ParameterLists
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/gsplat/native_ops.rb', line 29 def projection_forward(means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d:, near_plane:, far_plane:, radius_clip:, calc_compensations:, camera_model:, radial_coeffs: nil, tangential_coeffs: nil, thin_prism_coeffs: nil, global_z_order: true) # rubocop:enable Metrics/ParameterLists extended = camera_model.to_s == "fisheye" || [radial_coeffs, tangential_coeffs, thin_prism_coeffs].any? unless means.is_a?(Numo::SFloat) && !extended && global_z_order return Backend::RubyProjection.forward( means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d: eps2d, near_plane: near_plane, far_plane: far_plane, radius_clip: radius_clip, calc_compensations: calc_compensations, camera_model: camera_model, radial_coeffs: radial_coeffs, tangential_coeffs: tangential_coeffs, thin_prism_coeffs: thin_prism_coeffs, global_z_order: global_z_order ) end prepared = Backend::RubyProjection.send( :prepare_inputs, means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d, near_plane, far_plane, radius_clip, camera_model ) typed_means, typed_covars, typed_views, typed_intrinsics = prepared Native.projection_forward_sfloat( typed_means.dup, typed_covars.dup, typed_views.dup, typed_intrinsics.dup, width, height, eps2d, near_plane, far_plane, radius_clip, calc_compensations, camera_model.to_s == "ortho" ) end |
.spherical_harmonics_forward(degree, directions, coefficients, masks: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gsplat/native_ops.rb', line 11 def spherical_harmonics_forward(degree, directions, coefficients, masks: nil) prepared = Backend::RubySphericalHarmonics.send( :validate_inputs, degree, directions, coefficients, masks ) typed_directions, typed_coefficients, typed_masks, = prepared return Backend::RubySphericalHarmonics.forward(degree, directions, coefficients, masks: masks) if typed_masks unless typed_directions.is_a?(Numo::SFloat) return Backend::RubySphericalHarmonics.forward(degree, directions, coefficients, masks: masks) end Native.spherical_harmonics_forward_sfloat( degree, typed_directions.dup, typed_coefficients.dup ) end |