Skip to content

Commit c9d8e5e

Browse files
committed
TransposedArray: Define virtual destructor in .cpp file
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 <[email protected]>
1 parent 94d227b commit c9d8e5e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/lstm/weightmatrix.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ void TransposedArray::Transpose(const GENERIC_2D_ARRAY<double>& input) {
4646
for (int t = 0; t < width; ++t) WriteStrided(t, input[t]);
4747
}
4848

49+
// Destructor.
50+
// It is defined here, so the compiler can create a single vtable
51+
// instead of weak vtables in every compilation unit.
52+
TransposedArray::~TransposedArray() = default;
53+
4954
// Sets up the network for training. Initializes weights using weights of
5055
// scale `range` picked according to the random number generator `randomizer`.
5156
int WeightMatrix::InitWeightsFloat(int no, int ni, bool use_adam,

src/lstm/weightmatrix.h

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class TransposedArray : public GENERIC_2D_ARRAY<double> {
3636
void Transpose(const GENERIC_2D_ARRAY<double>& input);
3737
// Writes a vector of data representing a timestep (gradients or sources).
3838
// The data is assumed to be of size1 in size (the strided dimension).
39+
virtual ~TransposedArray();
3940
void WriteStrided(int t, const float* data) {
4041
int size1 = dim1();
4142
for (int i = 0; i < size1; ++i) put(i, t, data[i]);

0 commit comments

Comments
 (0)