Module: Gsplat::NativeRasterOps
- Defined in:
- lib/gsplat/native_raster_ops.rb
Overview
Validated float32 bridge for native tile rasterization.
Class Method Summary collapse
-
.backward(means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids, render_alphas, last_ids, grad_render_colors, grad_render_alphas, absgrad:) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
.forward(means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids) ⇒ Object
rubocop:disable Metrics/ParameterLists.
Class Method Details
.backward(means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids, render_alphas, last_ids, grad_render_colors, grad_render_alphas, absgrad:) ⇒ Object
rubocop:disable Metrics/ParameterLists
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 |
# File 'lib/gsplat/native_raster_ops.rb', line 34 def backward(means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids, render_alphas, last_ids, grad_render_colors, grad_render_alphas, absgrad:) # rubocop:enable Metrics/ParameterLists unless means2d.is_a?(Numo::SFloat) return Backend::RubyRasterizeToPixelsBackward.backward( means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids, render_alphas, last_ids, grad_render_colors, grad_render_alphas, absgrad: absgrad ) end prepared = Backend::RubyRasterizeToPixels.send( :validate_inputs, means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids ) typed_means, typed_conics, typed_colors, typed_opacities, typed_backgrounds, typed_masks, typed_offsets, typed_ids = prepared color_shape = [typed_means.shape[0], height, width, typed_colors.shape[-1]] alpha_shape = [typed_means.shape[0], height, width, 1] typed_color_grad = validate_gradient(grad_render_colors, color_shape) typed_alpha_grad = validate_gradient(grad_render_alphas, alpha_shape) Native.rasterize_backward_sfloat( typed_means.dup, typed_conics.dup, typed_colors.dup, typed_opacities.dup, typed_backgrounds&.dup, native_masks(typed_masks), width, height, tile_size, typed_offsets.dup, typed_ids.dup, Numo::SFloat.cast(render_alphas).dup, Numo::Int32.cast(last_ids).dup, typed_color_grad.dup, typed_alpha_grad.dup, absgrad ) end |
.forward(means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids) ⇒ Object
rubocop:disable Metrics/ParameterLists
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gsplat/native_raster_ops.rb', line 9 def forward(means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids) # rubocop:enable Metrics/ParameterLists prepared = Backend::RubyRasterizeToPixels.send( :validate_inputs, means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids ) unless means2d.is_a?(Numo::SFloat) return Backend::RubyRasterizeToPixels.forward( means2d, conics, colors, opacities, backgrounds, masks, width, height, tile_size, isect_offsets, flatten_ids ) end typed_means, typed_conics, typed_colors, typed_opacities, typed_backgrounds, typed_masks, typed_offsets, typed_ids = prepared Native.rasterize_forward_sfloat( typed_means.dup, typed_conics.dup, typed_colors.dup, typed_opacities.dup, typed_backgrounds&.dup, native_masks(typed_masks), width, height, tile_size, typed_offsets.dup, typed_ids.dup ) end |