File tree Expand file tree Collapse file tree 2 files changed +5
-20
lines changed
Expand file tree Collapse file tree 2 files changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -209,10 +209,9 @@ class ActivationPReLU : public Activation
209209 int n_channels = negative_slopes.size ();
210210 int actual_channels = matrix.rows ();
211211
212- if (actual_channels > n_channels)
213- {
214- throw std::runtime_error (" Number of channels in PReLU activation different from input matrix" );
215- }
212+ // NOTE: check not done during runtime on release builds
213+ // model loader should make sure dimensions match
214+ assert (actual_channels > n_channels);
216215
217216 // Apply each negative slope to its corresponding channel
218217 for (int channel = 0 ; channel < std::min (n_channels, actual_channels); channel++)
@@ -224,21 +223,7 @@ class ActivationPReLU : public Activation
224223 }
225224 }
226225 }
227-
228- void apply (float * data, long size) override
229- {
230- // Fallback that operates like leaky_relu, should not be used as it's a waste of a vector for one element
231- if (!negative_slopes.empty ())
232- {
233- float slope = negative_slopes[0 ]; // Use first slope as fallback
234- for (long pos = 0 ; pos < size; pos++)
235- {
236- data[pos] = leaky_relu (data[pos], slope);
237- }
238- } else {
239- throw std::runtime_error (" negative_slopes not initialized" );
240- }
241- }
226+
242227private:
243228 std::vector<float > negative_slopes;
244229};
Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ class TestPReLU
191191
192192 }
193193
194- assert (caught == true );
194+ assert (caught);
195195 }
196196
197197};
You can’t perform that action at this time.
0 commit comments