Class: Gsplat::Ops::ConcatDepth
- Inherits:
-
Autograd::Function
- Object
- Autograd::Function
- Gsplat::Ops::ConcatDepth
- Defined in:
- lib/gsplat/ops/tensor_shape_ops.rb
Overview
Concatenates per-Gaussian features and depth.
Class Method Summary collapse
Methods inherited from Autograd::Function
Class Method Details
.backward(context, gradient) ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/gsplat/ops/tensor_shape_ops.rb', line 103 def backward(context, gradient) feature_count = context.saved_values.fetch(0) leading = Array.new(gradient.ndim - 1, true) [ gradient[*leading, 0...feature_count].dup, gradient[*leading, feature_count].reshape(*(gradient.shape[0...-1] + [1])) ] end |
.forward(context, features, depth_features) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/gsplat/ops/tensor_shape_ops.rb', line 86 def forward(context, features, depth_features) unless features.shape[0...-1] == depth_features.shape[0...-1] && depth_features.shape[-1] == 1 raise ShapeError, "expected features [...,D] and depths [...,1], " \ "got #{features.shape.inspect} and #{depth_features.shape.inspect}" end feature_count = features.shape[-1] output = features.class.zeros(*(features.shape[0...-1] + [feature_count + 1])) output[*Array.new(features.ndim - 1, true), 0...feature_count] = features output[*Array.new(features.ndim - 1, true), feature_count] = depth_features[ *Array.new(depth_features.ndim - 1, true), 0 ] context.save(feature_count) output end |