Module: Gsplat::Backend
- Defined in:
- lib/gsplat/backend.rb,
lib/gsplat/backend/ruby/accumulate.rb,
lib/gsplat/backend/ruby/projection.rb,
lib/gsplat/backend/ruby/isect_tiles.rb,
lib/gsplat/backend/ruby/tile_compositor.rb,
lib/gsplat/backend/ruby/eval3d_rasterizer.rb,
lib/gsplat/backend/ruby/accumulate_backward.rb,
lib/gsplat/backend/ruby/projection_backward.rb,
lib/gsplat/backend/ruby/rasterize_to_pixels.rb,
lib/gsplat/backend/ruby/spherical_harmonics.rb,
lib/gsplat/backend/ruby/projection_input_vjp.rb,
lib/gsplat/backend/ruby/tile_compositor_backward.rb,
lib/gsplat/backend/ruby/projection_covariance_vjp.rb,
lib/gsplat/backend/ruby/quat_scale_to_covar_preci.rb,
lib/gsplat/backend/ruby/rasterize_to_pixels_backward.rb,
lib/gsplat/backend/ruby/rasterize_to_indices_in_range.rb
Overview
Operation registry and runtime backend selector.
Defined Under Namespace
Modules: RubyAccumulate, RubyAccumulateBackward, RubyEval3dRasterizer, RubyIsectTiles, RubyProjection, RubyProjectionBackward, RubyQuatScaleToCovarPreci, RubyRasterizeToIndicesInRange, RubyRasterizeToPixels, RubyRasterizeToPixelsBackward, RubySphericalHarmonics, RubyTileCompositor, RubyTileCompositorBackward
Constant Summary collapse
- VALID_BACKENDS =
Backend names accepted by Gsplat.backend=.
%i[auto ruby native].freeze
Class Method Summary collapse
-
.dispatch(op_name) ⇒ Object
Dispatches an operation to the selected implementation.
-
.normalize_backend(backend, allow_auto: true) ⇒ Symbol
Validates and normalizes a backend name.
-
.register(op_name, backend, callable = nil) { ... } ⇒ #call
Registers an operation implementation.
Class Method Details
.dispatch(op_name) ⇒ Object
Dispatches an operation to the selected implementation.
34 35 36 37 38 |
# File 'lib/gsplat/backend.rb', line 34 def dispatch(op_name, ...) operation = op_name.to_sym implementation = implementation_for(operation) implementation.call(...) end |
.normalize_backend(backend, allow_auto: true) ⇒ Symbol
Validates and normalizes a backend name.
45 46 47 48 49 50 51 |
# File 'lib/gsplat/backend.rb', line 45 def normalize_backend(backend, allow_auto: true) normalized = backend.to_s.downcase.to_sym valid = allow_auto ? VALID_BACKENDS : VALID_BACKENDS.drop(1) return normalized if valid.include?(normalized) raise ArgumentError, "unknown backend #{backend.inspect}; expected one of #{valid.join(', ')}" end |
.register(op_name, backend, callable = nil) { ... } ⇒ #call
Registers an operation implementation.
21 22 23 24 25 26 27 28 |
# File 'lib/gsplat/backend.rb', line 21 def register(op_name, backend, callable = nil, &block) implementation = callable || block raise ArgumentError, "backend implementation must respond to #call" unless implementation.respond_to?(:call) backend = normalize_backend(backend, allow_auto: false) @mutex.synchronize { @registry[op_name.to_sym][backend] = implementation } implementation end |