Skip to content

Commit

Permalink
Activitions incorrectly applied to row-based blocks in Wavnet.
Browse files Browse the repository at this point in the history
  • Loading branch information
rerdavies committed Oct 19, 2024
1 parent 172a7fe commit 102968f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions NAM/activations.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,24 @@ class Activation
Activation() = default;
virtual ~Activation() = default;
virtual void apply(Eigen::MatrixXf& matrix) { apply(matrix.data(), matrix.rows() * matrix.cols()); }
virtual void apply(Eigen::Block<Eigen::MatrixXf> block) { apply(block.data(), block.rows() * block.cols()); }
virtual void apply(Eigen::Block<Eigen::MatrixXf, -1, -1, true> block)
{
apply(block.data(), block.rows() * block.cols());


virtual void apply(Eigen::Block<Eigen::MatrixXf, -1, -1, true> block) {
// true -> A set of columns in column major order, or a set of rows in row major order. All data is contiguous.
this->apply(block.data(),(long)(block.rows()*block.cols()));
}

virtual void apply(Eigen::Block<Eigen::MatrixXf> block) {
// Overload for non-contiguous blocks. Apply column by column
for (int c = 0; c < block.cols(); ++c)
{
float *mem = &block.coeffRef(0,c);
this->apply(mem,(long)block.rows());
}
}



virtual void apply(float* data, long size) {}

static Activation* get_activation(const std::string name);
Expand Down

0 comments on commit 102968f

Please sign in to comment.