Class: Gsplat::Ops::Multiply

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

Overview

Elementwise multiplication with VJPs for both inputs.

Class Method Summary collapse

Methods inherited from Autograd::Function

apply

Class Method Details

.backward(context, gradient) ⇒ Object



36
37
38
39
# File 'lib/gsplat/ops/tensor_value_ops.rb', line 36

def backward(context, gradient)
  left, right = context.saved_values
  [gradient * right, gradient * left]
end

.forward(context, left, right) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/gsplat/ops/tensor_value_ops.rb', line 27

def forward(context, left, right)
  unless left.shape == right.shape
    raise ShapeError, "multiply shape mismatch: #{left.shape.inspect} and #{right.shape.inspect}"
  end

  context.save(left, right)
  left * right
end