Skip to content

Commit dc3d28c

Browse files
committed
Use more override specifiers
Now all methods which override Network methods use the override specifier. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent bf9b72c commit dc3d28c

File tree

7 files changed

+65
-65
lines changed

7 files changed

+65
-65
lines changed

src/lstm/convolve.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,29 @@ class Convolve : public Network {
3737
Convolve(const STRING& name, int ni, int half_x, int half_y);
3838
virtual ~Convolve();
3939

40-
virtual STRING spec() const {
40+
STRING spec() const override {
4141
STRING spec;
4242
spec.add_str_int("C", half_x_ * 2 + 1);
4343
spec.add_str_int(",", half_y_ * 2 + 1);
4444
return spec;
4545
}
4646

4747
// Writes to the given file. Returns false in case of error.
48-
virtual bool Serialize(TFile* fp) const;
48+
bool Serialize(TFile* fp) const override;
4949
// Reads from the given file. Returns false in case of error.
50-
virtual bool DeSerialize(TFile* fp);
50+
bool DeSerialize(TFile* fp) override;
5151

5252
// Runs forward propagation of activations on the input line.
5353
// See Network for a detailed discussion of the arguments.
54-
virtual void Forward(bool debug, const NetworkIO& input,
55-
const TransposedArray* input_transpose,
56-
NetworkScratch* scratch, NetworkIO* output);
54+
void Forward(bool debug, const NetworkIO& input,
55+
const TransposedArray* input_transpose,
56+
NetworkScratch* scratch, NetworkIO* output) override;
5757

5858
// Runs backward propagation of errors on the deltas line.
5959
// See Network for a detailed discussion of the arguments.
60-
virtual bool Backward(bool debug, const NetworkIO& fwd_deltas,
61-
NetworkScratch* scratch,
62-
NetworkIO* back_deltas);
60+
bool Backward(bool debug, const NetworkIO& fwd_deltas,
61+
NetworkScratch* scratch,
62+
NetworkIO* back_deltas) override;
6363

6464
protected:
6565
// Serialized data.

src/lstm/input.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Input : public Network {
3131
Input(const STRING& name, const StaticShape& shape);
3232
virtual ~Input();
3333

34-
virtual STRING spec() const {
34+
STRING spec() const override {
3535
STRING spec;
3636
spec.add_str_int("", shape_.batch());
3737
spec.add_str_int(",", shape_.height());
@@ -41,41 +41,41 @@ class Input : public Network {
4141
}
4242

4343
// Returns the required shape input to the network.
44-
virtual StaticShape InputShape() const { return shape_; }
44+
StaticShape InputShape() const override { return shape_; }
4545
// Returns the shape output from the network given an input shape (which may
4646
// be partially unknown ie zero).
47-
virtual StaticShape OutputShape(const StaticShape& input_shape) const {
47+
StaticShape OutputShape(const StaticShape& input_shape) const override {
4848
return shape_;
4949
}
5050
// Writes to the given file. Returns false in case of error.
5151
// Should be overridden by subclasses, but called by their Serialize.
52-
virtual bool Serialize(TFile* fp) const;
52+
bool Serialize(TFile* fp) const override;
5353
// Reads from the given file. Returns false in case of error.
54-
virtual bool DeSerialize(TFile* fp);
54+
bool DeSerialize(TFile* fp) override;
5555

5656
// Returns an integer reduction factor that the network applies to the
5757
// time sequence. Assumes that any 2-d is already eliminated. Used for
5858
// scaling bounding boxes of truth data.
5959
// WARNING: if GlobalMinimax is used to vary the scale, this will return
6060
// the last used scale factor. Call it before any forward, and it will return
6161
// the minimum scale factor of the paths through the GlobalMinimax.
62-
virtual int XScaleFactor() const;
62+
int XScaleFactor() const override;
6363

6464
// Provides the (minimum) x scale factor to the network (of interest only to
6565
// input units) so they can determine how to scale bounding boxes.
66-
virtual void CacheXScaleFactor(int factor);
66+
void CacheXScaleFactor(int factor) override;
6767

6868
// Runs forward propagation of activations on the input line.
6969
// See Network for a detailed discussion of the arguments.
70-
virtual void Forward(bool debug, const NetworkIO& input,
71-
const TransposedArray* input_transpose,
72-
NetworkScratch* scratch, NetworkIO* output);
70+
void Forward(bool debug, const NetworkIO& input,
71+
const TransposedArray* input_transpose,
72+
NetworkScratch* scratch, NetworkIO* output) override;
7373

7474
// Runs backward propagation of errors on the deltas line.
7575
// See Network for a detailed discussion of the arguments.
76-
virtual bool Backward(bool debug, const NetworkIO& fwd_deltas,
77-
NetworkScratch* scratch,
78-
NetworkIO* back_deltas);
76+
bool Backward(bool debug, const NetworkIO& fwd_deltas,
77+
NetworkScratch* scratch,
78+
NetworkIO* back_deltas) override;
7979
// Creates and returns a Pix of appropriate size for the network from the
8080
// image_data. If non-null, *image_scale returns the image scale factor used.
8181
// Returns nullptr on error.

src/lstm/maxpool.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,27 @@ class Maxpool : public Reconfig {
3232
virtual ~Maxpool();
3333

3434
// Accessors.
35-
virtual STRING spec() const {
35+
STRING spec() const override {
3636
STRING spec;
3737
spec.add_str_int("Mp", y_scale_);
3838
spec.add_str_int(",", x_scale_);
3939
return spec;
4040
}
4141

4242
// Reads from the given file. Returns false in case of error.
43-
virtual bool DeSerialize(TFile* fp);
43+
bool DeSerialize(TFile* fp) override;
4444

4545
// Runs forward propagation of activations on the input line.
4646
// See Network for a detailed discussion of the arguments.
47-
virtual void Forward(bool debug, const NetworkIO& input,
48-
const TransposedArray* input_transpose,
49-
NetworkScratch* scratch, NetworkIO* output);
47+
void Forward(bool debug, const NetworkIO& input,
48+
const TransposedArray* input_transpose,
49+
NetworkScratch* scratch, NetworkIO* output) override;
5050

5151
// Runs backward propagation of errors on the deltas line.
5252
// See Network for a detailed discussion of the arguments.
53-
virtual bool Backward(bool debug, const NetworkIO& fwd_deltas,
54-
NetworkScratch* scratch,
55-
NetworkIO* back_deltas);
53+
bool Backward(bool debug, const NetworkIO& fwd_deltas,
54+
NetworkScratch* scratch,
55+
NetworkIO* back_deltas) override;
5656

5757
private:
5858
// Memory of which input was the max.

src/lstm/parallel.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class Parallel : public Plumbing {
3232

3333
// Returns the shape output from the network given an input shape (which may
3434
// be partially unknown ie zero).
35-
virtual StaticShape OutputShape(const StaticShape& input_shape) const;
35+
StaticShape OutputShape(const StaticShape& input_shape) const override;
3636

37-
virtual STRING spec() const {
37+
STRING spec() const override {
3838
STRING spec;
3939
if (type_ == NT_PAR_2D_LSTM) {
4040
// We have 4 LSTMs operating in parallel here, so the size of each is
@@ -63,15 +63,15 @@ class Parallel : public Plumbing {
6363

6464
// Runs forward propagation of activations on the input line.
6565
// See Network for a detailed discussion of the arguments.
66-
virtual void Forward(bool debug, const NetworkIO& input,
67-
const TransposedArray* input_transpose,
68-
NetworkScratch* scratch, NetworkIO* output);
66+
void Forward(bool debug, const NetworkIO& input,
67+
const TransposedArray* input_transpose,
68+
NetworkScratch* scratch, NetworkIO* output) override;
6969

7070
// Runs backward propagation of errors on the deltas line.
7171
// See Network for a detailed discussion of the arguments.
72-
virtual bool Backward(bool debug, const NetworkIO& fwd_deltas,
73-
NetworkScratch* scratch,
74-
NetworkIO* back_deltas);
72+
bool Backward(bool debug, const NetworkIO& fwd_deltas,
73+
NetworkScratch* scratch,
74+
NetworkIO* back_deltas) override;
7575

7676
private:
7777
// If *this is a NT_REPLICATED, then it feeds a replicated network with

src/lstm/reconfig.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class Reconfig : public Network {
3737

3838
// Returns the shape output from the network given an input shape (which may
3939
// be partially unknown ie zero).
40-
virtual StaticShape OutputShape(const StaticShape& input_shape) const;
40+
StaticShape OutputShape(const StaticShape& input_shape) const override;
4141

42-
virtual STRING spec() const {
42+
STRING spec() const override {
4343
STRING spec;
4444
spec.add_str_int("S", y_scale_);
4545
spec.add_str_int(",", x_scale_);
@@ -52,24 +52,24 @@ class Reconfig : public Network {
5252
// WARNING: if GlobalMinimax is used to vary the scale, this will return
5353
// the last used scale factor. Call it before any forward, and it will return
5454
// the minimum scale factor of the paths through the GlobalMinimax.
55-
virtual int XScaleFactor() const;
55+
int XScaleFactor() const override;
5656

5757
// Writes to the given file. Returns false in case of error.
58-
virtual bool Serialize(TFile* fp) const;
58+
bool Serialize(TFile* fp) const override;
5959
// Reads from the given file. Returns false in case of error.
60-
virtual bool DeSerialize(TFile* fp);
60+
bool DeSerialize(TFile* fp) override;
6161

6262
// Runs forward propagation of activations on the input line.
6363
// See Network for a detailed discussion of the arguments.
64-
virtual void Forward(bool debug, const NetworkIO& input,
65-
const TransposedArray* input_transpose,
66-
NetworkScratch* scratch, NetworkIO* output);
64+
void Forward(bool debug, const NetworkIO& input,
65+
const TransposedArray* input_transpose,
66+
NetworkScratch* scratch, NetworkIO* output) override;
6767

6868
// Runs backward propagation of errors on the deltas line.
6969
// See Network for a detailed discussion of the arguments.
70-
virtual bool Backward(bool debug, const NetworkIO& fwd_deltas,
71-
NetworkScratch* scratch,
72-
NetworkIO* back_deltas);
70+
bool Backward(bool debug, const NetworkIO& fwd_deltas,
71+
NetworkScratch* scratch,
72+
NetworkIO* back_deltas) override;
7373

7474
protected:
7575
// Non-serialized data used to store parameters between forward and back.

src/lstm/reversed.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class Reversed : public Plumbing {
3232

3333
// Returns the shape output from the network given an input shape (which may
3434
// be partially unknown ie zero).
35-
virtual StaticShape OutputShape(const StaticShape& input_shape) const;
35+
StaticShape OutputShape(const StaticShape& input_shape) const override;
3636

37-
virtual STRING spec() const {
37+
STRING spec() const override {
3838
STRING spec(type_ == NT_XREVERSED ? "Rx"
3939
: (type_ == NT_YREVERSED ? "Ry" : "Txy"));
4040
// For most simple cases, we will output Rx<net> or Ry<net> where <net> is
@@ -69,15 +69,15 @@ class Reversed : public Plumbing {
6969

7070
// Runs forward propagation of activations on the input line.
7171
// See Network for a detailed discussion of the arguments.
72-
virtual void Forward(bool debug, const NetworkIO& input,
73-
const TransposedArray* input_transpose,
74-
NetworkScratch* scratch, NetworkIO* output);
72+
void Forward(bool debug, const NetworkIO& input,
73+
const TransposedArray* input_transpose,
74+
NetworkScratch* scratch, NetworkIO* output) override;
7575

7676
// Runs backward propagation of errors on the deltas line.
7777
// See Network for a detailed discussion of the arguments.
78-
virtual bool Backward(bool debug, const NetworkIO& fwd_deltas,
79-
NetworkScratch* scratch,
80-
NetworkIO* back_deltas);
78+
bool Backward(bool debug, const NetworkIO& fwd_deltas,
79+
NetworkScratch* scratch,
80+
NetworkIO* back_deltas) override;
8181

8282
private:
8383
// Copies src to *dest with the reversal according to type_.

src/lstm/tfnetwork.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ class TFNetwork : public Network {
3939
virtual ~TFNetwork();
4040

4141
// Returns the required shape input to the network.
42-
virtual StaticShape InputShape() const { return input_shape_; }
42+
StaticShape InputShape() const override { return input_shape_; }
4343
// Returns the shape output from the network given an input shape (which may
4444
// be partially unknown ie zero).
45-
virtual StaticShape OutputShape(const StaticShape& input_shape) const {
45+
StaticShape OutputShape(const StaticShape& input_shape) const override {
4646
return output_shape_;
4747
}
4848

49-
virtual STRING spec() const { return spec_.c_str(); }
49+
STRING spec() const override { return spec_.c_str(); }
5050

5151
// Deserializes *this from a serialized TFNetwork proto. Returns 0 if failed,
5252
// otherwise the global step of the serialized graph.
@@ -57,16 +57,16 @@ class TFNetwork : public Network {
5757

5858
// Writes to the given file. Returns false in case of error.
5959
// Should be overridden by subclasses, but called by their Serialize.
60-
virtual bool Serialize(TFile* fp) const;
60+
bool Serialize(TFile* fp) const override;
6161
// Reads from the given file. Returns false in case of error.
6262
// Should be overridden by subclasses, but NOT called by their DeSerialize.
63-
virtual bool DeSerialize(TFile* fp);
63+
bool DeSerialize(TFile* fp) override;
6464

6565
// Runs forward propagation of activations on the input line.
6666
// See Network for a detailed discussion of the arguments.
67-
virtual void Forward(bool debug, const NetworkIO& input,
68-
const TransposedArray* input_transpose,
69-
NetworkScratch* scratch, NetworkIO* output);
67+
void Forward(bool debug, const NetworkIO& input,
68+
const TransposedArray* input_transpose,
69+
NetworkScratch* scratch, NetworkIO* output) override;
7070

7171
private:
7272
int InitFromProto();

0 commit comments

Comments
 (0)