Skip to content

Commit

Permalink
TransposedArray: Define virtual destructor in .cpp file
Browse files Browse the repository at this point in the history
This fixes compiler warnings from clang:

src/lstm/weightmatrix.h:33:7: warning:
 'TransposedArray' has no out-of-line virtual method definitions;
 its vtable will be emitted in every translation unit [-Wweak-vtables]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Sep 4, 2018
1 parent 94d227b commit c9d8e5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lstm/weightmatrix.cpp
Expand Up @@ -46,6 +46,11 @@ void TransposedArray::Transpose(const GENERIC_2D_ARRAY<double>& input) {
for (int t = 0; t < width; ++t) WriteStrided(t, input[t]);
}

// Destructor.
// It is defined here, so the compiler can create a single vtable
// instead of weak vtables in every compilation unit.
TransposedArray::~TransposedArray() = default;

// Sets up the network for training. Initializes weights using weights of
// scale `range` picked according to the random number generator `randomizer`.
int WeightMatrix::InitWeightsFloat(int no, int ni, bool use_adam,
Expand Down
1 change: 1 addition & 0 deletions src/lstm/weightmatrix.h
Expand Up @@ -36,6 +36,7 @@ class TransposedArray : public GENERIC_2D_ARRAY<double> {
void Transpose(const GENERIC_2D_ARRAY<double>& input);
// Writes a vector of data representing a timestep (gradients or sources).
// The data is assumed to be of size1 in size (the strided dimension).
virtual ~TransposedArray();
void WriteStrided(int t, const float* data) {
int size1 = dim1();
for (int i = 0; i < size1; ++i) put(i, t, data[i]);
Expand Down

0 comments on commit c9d8e5e

Please sign in to comment.