File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ class SampledSpectrum {
55
55
private:
56
56
Local<float > _samples;
57
57
58
+ private:
59
+ explicit SampledSpectrum (Local<float > &&samples) noexcept
60
+ : _samples{std::move (samples)} {}
61
+
58
62
public:
59
63
SampledSpectrum (uint n, Expr<float > value) noexcept : _samples{n} {
60
64
compute::outline ([&] {
@@ -84,6 +88,12 @@ class SampledSpectrum {
84
88
}
85
89
[[nodiscard]] Local<float > &values () noexcept { return _samples; }
86
90
[[nodiscard]] const Local<float > &values () const noexcept { return _samples; }
91
+
92
+ void requires_grad () const noexcept { _samples.requires_grad (); }
93
+ void backward () const noexcept { _samples.backward (); }
94
+ void backward (const SampledSpectrum &grad) const noexcept { _samples.backward (grad._samples ); }
95
+ [[nodiscard]] auto grad () const noexcept { return SampledSpectrum{_samples.grad ()}; }
96
+
87
97
[[nodiscard]] Float &operator [](Expr<uint> i) noexcept {
88
98
return dimension () == 1u ? _samples[0u ] : _samples[i];
89
99
}
@@ -179,7 +189,7 @@ class SampledSpectrum {
179
189
}); \
180
190
return *this ; \
181
191
} \
182
- auto &operator op##=(const SampledSpectrum &rhs) noexcept { \
192
+ auto &operator op##=(const SampledSpectrum & rhs) noexcept { \
183
193
LUISA_ASSERT (rhs.dimension () == 1u || dimension () == rhs.dimension (), \
184
194
" Invalid sampled spectrum dimension for operator" #op " =: {} vs {}." , \
185
195
dimension (), rhs.dimension ()); \
You can’t perform that action at this time.
0 commit comments