Module: Gsplat::Autograd

Defined in:
lib/gsplat/autograd/context.rb,
lib/gsplat/autograd/function.rb,
lib/gsplat/autograd/variable.rb

Overview

Lightweight reverse-mode differentiation for coarse gsplat operations.

Defined Under Namespace

Classes: Context, Function, GraphNode, Variable

Constant Summary collapse

GRAD_ENABLED_KEY =

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

Thread-local key used to suspend graph recording.

:gsplat_autograd_grad_enabled

Class Method Summary collapse

Class Method Details

.grad_enabled?Boolean

Whether new operations should attach backward nodes.

Returns:

  • (Boolean)


56
57
58
# File 'lib/gsplat/autograd/context.rb', line 56

def grad_enabled?
  Thread.current.thread_variable_get(GRAD_ENABLED_KEY) != false
end

.no_gradObject

Runs a block without recording an autograd graph.

Yield Returns:

  • (Object)


44
45
46
47
48
49
50
51
# File 'lib/gsplat/autograd/context.rb', line 44

def no_grad
  thread = Thread.current
  previous = thread.thread_variable_get(GRAD_ENABLED_KEY)
  thread.thread_variable_set(GRAD_ENABLED_KEY, false)
  yield
ensure
  thread.thread_variable_set(GRAD_ENABLED_KEY, previous)
end