Skip to content

Commit

Permalink
Merge pull request #945 from longjon/fixtypes
Browse files Browse the repository at this point in the history
Fix types of SetUp, Forward, Backward, and gradient checker calls
  • Loading branch information
longjon committed Sep 19, 2014
2 parents 8fd17a3 + 31326a1 commit a47097d
Show file tree
Hide file tree
Showing 122 changed files with 1,199 additions and 1,197 deletions.
114 changes: 57 additions & 57 deletions include/caffe/common_layers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class ArgMaxLayer : public Layer<Dtype> {
explicit ArgMaxLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_ARGMAX;
Expand All @@ -62,10 +62,10 @@ class ArgMaxLayer : public Layer<Dtype> {
* @f$ (for @f$ K = 1 @f$).
*/
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
/// @brief Not implemented (non-differentiable function)
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom) {
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {
NOT_IMPLEMENTED;
}
bool out_max_val_;
Expand All @@ -82,9 +82,9 @@ class ConcatLayer : public Layer<Dtype> {
explicit ConcatLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_CONCAT;
Expand All @@ -110,9 +110,9 @@ class ConcatLayer : public Layer<Dtype> {
* @f$
*/
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

/**
* @brief Computes the error gradient w.r.t. the concatenate inputs.
Expand All @@ -137,9 +137,9 @@ class ConcatLayer : public Layer<Dtype> {
* @f$
*/
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);

Blob<Dtype> col_bob_;
int count_;
Expand All @@ -162,9 +162,9 @@ class EltwiseLayer : public Layer<Dtype> {
explicit EltwiseLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_ELTWISE;
Expand All @@ -174,13 +174,13 @@ class EltwiseLayer : public Layer<Dtype> {

protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);

EltwiseParameter_EltwiseOp op_;
vector<Dtype> coeffs_;
Expand All @@ -205,7 +205,7 @@ class FlattenLayer : public Layer<Dtype> {
explicit FlattenLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_FLATTEN;
Expand All @@ -223,9 +223,9 @@ class FlattenLayer : public Layer<Dtype> {
* the outputs -- i.e., the (virtually) copied, flattened inputs
*/
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

/**
* @brief Computes the error gradient w.r.t. the concatenate inputs.
Expand All @@ -237,9 +237,9 @@ class FlattenLayer : public Layer<Dtype> {
* gradient is (virtually) copied
*/
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);

int count_;
};
Expand All @@ -256,9 +256,9 @@ class InnerProductLayer : public Layer<Dtype> {
explicit InnerProductLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_INNER_PRODUCT;
Expand All @@ -268,13 +268,13 @@ class InnerProductLayer : public Layer<Dtype> {

protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);

int M_;
int K_;
Expand All @@ -294,7 +294,7 @@ class MVNLayer : public Layer<Dtype> {
explicit MVNLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_MVN;
Expand All @@ -304,13 +304,13 @@ class MVNLayer : public Layer<Dtype> {

protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);

Blob<Dtype> mean_, variance_, temp_;

Expand All @@ -328,7 +328,7 @@ class SilenceLayer : public Layer<Dtype> {
explicit SilenceLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top) {}
const vector<Blob<Dtype>*>& top) {}

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_SILENCE;
Expand All @@ -338,15 +338,15 @@ class SilenceLayer : public Layer<Dtype> {

protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top) {}
const vector<Blob<Dtype>*>& top) {}
// We can't define Forward_gpu here, since STUB_GPU will provide
// its own definition for CPU_ONLY mode.
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
};

/**
Expand All @@ -360,7 +360,7 @@ class SoftmaxLayer : public Layer<Dtype> {
explicit SoftmaxLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_SOFTMAX;
Expand All @@ -370,13 +370,13 @@ class SoftmaxLayer : public Layer<Dtype> {

protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);

/// sum_multiplier is used to carry out sum using BLAS
Blob<Dtype> sum_multiplier_;
Expand All @@ -395,16 +395,16 @@ class CuDNNSoftmaxLayer : public SoftmaxLayer<Dtype> {
explicit CuDNNSoftmaxLayer(const LayerParameter& param)
: SoftmaxLayer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual ~CuDNNSoftmaxLayer();

protected:
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);

cudnnHandle_t handle_;
cudnnTensor4dDescriptor_t bottom_desc_;
Expand All @@ -424,7 +424,7 @@ class SplitLayer : public Layer<Dtype> {
explicit SplitLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_SPLIT;
Expand All @@ -434,13 +434,13 @@ class SplitLayer : public Layer<Dtype> {

protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);

int count_;
};
Expand All @@ -457,9 +457,9 @@ class SliceLayer : public Layer<Dtype> {
explicit SliceLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);

virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_SLICE;
Expand All @@ -469,13 +469,13 @@ class SliceLayer : public Layer<Dtype> {

protected:
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
const vector<Blob<Dtype>*>& top);
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, vector<Blob<Dtype>*>* bottom);
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);

Blob<Dtype> col_bob_;
int count_;
Expand Down
Loading

0 comments on commit a47097d

Please sign in to comment.