Skip to content

Commit

Permalink
Use more override specifiers
Browse files Browse the repository at this point in the history
Now all methods which override Network methods use the override specifier.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed May 3, 2018
1 parent bf9b72c commit dc3d28c
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 65 deletions.
18 changes: 9 additions & 9 deletions src/lstm/convolve.h
Expand Up @@ -37,29 +37,29 @@ class Convolve : public Network {
Convolve(const STRING& name, int ni, int half_x, int half_y);
virtual ~Convolve();

virtual STRING spec() const {
STRING spec() const override {
STRING spec;
spec.add_str_int("C", half_x_ * 2 + 1);
spec.add_str_int(",", half_y_ * 2 + 1);
return spec;
}

// Writes to the given file. Returns false in case of error.
virtual bool Serialize(TFile* fp) const;
bool Serialize(TFile* fp) const override;
// Reads from the given file. Returns false in case of error.
virtual bool DeSerialize(TFile* fp);
bool DeSerialize(TFile* fp) override;

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

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

protected:
// Serialized data.
Expand Down
26 changes: 13 additions & 13 deletions src/lstm/input.h
Expand Up @@ -31,7 +31,7 @@ class Input : public Network {
Input(const STRING& name, const StaticShape& shape);
virtual ~Input();

virtual STRING spec() const {
STRING spec() const override {
STRING spec;
spec.add_str_int("", shape_.batch());
spec.add_str_int(",", shape_.height());
Expand All @@ -41,41 +41,41 @@ class Input : public Network {
}

// Returns the required shape input to the network.
virtual StaticShape InputShape() const { return shape_; }
StaticShape InputShape() const override { return shape_; }
// Returns the shape output from the network given an input shape (which may
// be partially unknown ie zero).
virtual StaticShape OutputShape(const StaticShape& input_shape) const {
StaticShape OutputShape(const StaticShape& input_shape) const override {
return shape_;
}
// Writes to the given file. Returns false in case of error.
// Should be overridden by subclasses, but called by their Serialize.
virtual bool Serialize(TFile* fp) const;
bool Serialize(TFile* fp) const override;
// Reads from the given file. Returns false in case of error.
virtual bool DeSerialize(TFile* fp);
bool DeSerialize(TFile* fp) override;

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

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

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

// Runs backward propagation of errors on the deltas line.
// See Network for a detailed discussion of the arguments.
virtual bool Backward(bool debug, const NetworkIO& fwd_deltas,
NetworkScratch* scratch,
NetworkIO* back_deltas);
bool Backward(bool debug, const NetworkIO& fwd_deltas,
NetworkScratch* scratch,
NetworkIO* back_deltas) override;
// Creates and returns a Pix of appropriate size for the network from the
// image_data. If non-null, *image_scale returns the image scale factor used.
// Returns nullptr on error.
Expand Down
16 changes: 8 additions & 8 deletions src/lstm/maxpool.h
Expand Up @@ -32,27 +32,27 @@ class Maxpool : public Reconfig {
virtual ~Maxpool();

// Accessors.
virtual STRING spec() const {
STRING spec() const override {
STRING spec;
spec.add_str_int("Mp", y_scale_);
spec.add_str_int(",", x_scale_);
return spec;
}

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

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

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

private:
// Memory of which input was the max.
Expand Down
16 changes: 8 additions & 8 deletions src/lstm/parallel.h
Expand Up @@ -32,9 +32,9 @@ class Parallel : public Plumbing {

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

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

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

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

private:
// If *this is a NT_REPLICATED, then it feeds a replicated network with
Expand Down
22 changes: 11 additions & 11 deletions src/lstm/reconfig.h
Expand Up @@ -37,9 +37,9 @@ class Reconfig : public Network {

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

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

// Writes to the given file. Returns false in case of error.
virtual bool Serialize(TFile* fp) const;
bool Serialize(TFile* fp) const override;
// Reads from the given file. Returns false in case of error.
virtual bool DeSerialize(TFile* fp);
bool DeSerialize(TFile* fp) override;

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

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

protected:
// Non-serialized data used to store parameters between forward and back.
Expand Down
16 changes: 8 additions & 8 deletions src/lstm/reversed.h
Expand Up @@ -32,9 +32,9 @@ class Reversed : public Plumbing {

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

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

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

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

private:
// Copies src to *dest with the reversal according to type_.
Expand Down
16 changes: 8 additions & 8 deletions src/lstm/tfnetwork.h
Expand Up @@ -39,14 +39,14 @@ class TFNetwork : public Network {
virtual ~TFNetwork();

// Returns the required shape input to the network.
virtual StaticShape InputShape() const { return input_shape_; }
StaticShape InputShape() const override { return input_shape_; }
// Returns the shape output from the network given an input shape (which may
// be partially unknown ie zero).
virtual StaticShape OutputShape(const StaticShape& input_shape) const {
StaticShape OutputShape(const StaticShape& input_shape) const override {
return output_shape_;
}

virtual STRING spec() const { return spec_.c_str(); }
STRING spec() const override { return spec_.c_str(); }

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

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

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

private:
int InitFromProto();
Expand Down

0 comments on commit dc3d28c

Please sign in to comment.