Class: Gsplat::Ops::Accumulate

Inherits:
Autograd::Function show all
Defined in:
lib/gsplat/ops/accumulate.rb

Overview

Differentiable reference alpha compositor.

Class Method Summary collapse

Methods inherited from Autograd::Function

apply

Class Method Details

.backward(context, grad_render_colors, grad_render_alphas) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Propagates color and alpha gradients through the reference compositor.



35
36
37
38
39
40
41
42
43
44
# File 'lib/gsplat/ops/accumulate.rb', line 35

def backward(context, grad_render_colors, grad_render_alphas)
  saved = context.saved_values
  gradients = Backend.dispatch(
    :accumulate_backward,
    *saved,
    grad_render_colors,
    grad_render_alphas
  )
  [*gradients, nil, nil]
end

.forward(context, means2d, conics, opacities, colors, backgrounds, width, height) ⇒ Object

rubocop:disable Metrics/ParameterLists



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gsplat/ops/accumulate.rb', line 14

def forward(context, means2d, conics, opacities, colors, backgrounds, width, height)
  # rubocop:enable Metrics/ParameterLists
  render_colors, render_alphas, last_ids = Backend.dispatch(
    :accumulate_forward,
    means2d,
    conics,
    opacities,
    colors,
    backgrounds,
    width,
    height
  )
  context.save(
    means2d, conics, opacities, colors, backgrounds, width, height,
    render_alphas, last_ids
  )
  [render_colors, render_alphas]
end