: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_ARGMAX;
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_CONCAT;
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_ELTWISE;
public:
explicit FlattenLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
- virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
virtual inline LayerParameter_LayerType type() const {
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_INNER_PRODUCT;
public:
explicit MVNLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
- virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
virtual inline LayerParameter_LayerType type() const {
public:
explicit SilenceLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
- virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top) {}
virtual inline LayerParameter_LayerType type() const {
public:
explicit SoftmaxLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
- virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
virtual inline LayerParameter_LayerType type() const {
: SoftmaxLayer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
virtual ~CuDNNSoftmaxLayer();
protected:
public:
explicit SplitLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
- virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
virtual inline LayerParameter_LayerType type() const {
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top);
+ virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top);
virtual inline LayerParameter_LayerType type() const {
return LayerParameter_LayerType_SLICE;
CHECK_GE(top_k_, 1) << " top k must not be less than 1.";
CHECK_LE(top_k_, bottom[0]->count() / bottom[0]->num())
<< "top_k must be less than or equal to the number of classes.";
+}
+
+template <typename Dtype>
+void ArgMaxLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top) {
if (out_max_val_) {
// Produces max_ind and max_val
(*top)[0]->Reshape(bottom[0]->num(), 2, top_k_, 1);
"concat_dim should be >= 0";
CHECK_LE(concat_dim_, 1) <<
"For now concat_dim <=1, it can only concat num and channels";
+}
+template <typename Dtype>
+void ConcatLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top) {
// Initialize with the first blob.
count_ = bottom[0]->count();
num_ = bottom[0]->num();
SoftmaxLayer<Dtype>::LayerSetUp(bottom, top);
// Initialize CUDNN.
CUDNN_CHECK(cudnnCreate(&handle_));
+ cudnn::createTensor4dDesc<Dtype>(&bottom_desc_);
+ cudnn::createTensor4dDesc<Dtype>(&top_desc_);
+}
+
+template <typename Dtype>
+void CuDNNSoftmaxLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top) {
+ SoftmaxLayer<Dtype>::Reshape(bottom, top);
int N = bottom[0]->num();
int K = bottom[0]->channels();
int H = bottom[0]->height();
int W = bottom[0]->width();
- cudnn::createTensor4dDesc<Dtype>(&bottom_desc_, N, K, H, W);
- cudnn::createTensor4dDesc<Dtype>(&top_desc_, N, K, H, W);
+ cudnn::setTensor4dDesc<Dtype>(&bottom_desc_, N, K, H, W);
+ cudnn::setTensor4dDesc<Dtype>(&top_desc_, N, K, H, W);
}
template <typename Dtype>
== EltwiseParameter_EltwiseOp_PROD
&& this->layer_param().eltwise_param().coeff_size())) <<
"Eltwise layer only takes coefficients for summation.";
+ op_ = this->layer_param_.eltwise_param().operation();
+ // Blob-wise coefficients for the elementwise operation.
+ coeffs_ = vector<Dtype>(bottom.size(), 1);
+ if (this->layer_param().eltwise_param().coeff_size()) {
+ for (int i = 0; i < bottom.size(); ++i) {
+ coeffs_[i] = this->layer_param().eltwise_param().coeff(i);
+ }
+ }
+ stable_prod_grad_ = this->layer_param_.eltwise_param().stable_prod_grad();
+}
+
+template <typename Dtype>
+void EltwiseLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top) {
const int num = bottom[0]->num();
const int channels = bottom[0]->channels();
const int height = bottom[0]->height();
CHECK_EQ(width, bottom[i]->width());
}
(*top)[0]->Reshape(num, channels, height, width);
- op_ = this->layer_param_.eltwise_param().operation();
- // Blob-wise coefficients for the elementwise operation.
- coeffs_ = vector<Dtype>(bottom.size(), 1);
- if (this->layer_param().eltwise_param().coeff_size()) {
- for (int i = 0; i < bottom.size(); ++i) {
- coeffs_[i] = this->layer_param().eltwise_param().coeff(i);
- }
- }
- stable_prod_grad_ = this->layer_param_.eltwise_param().stable_prod_grad();
// If max operation, we will initialize the vector index part.
if (this->layer_param_.eltwise_param().operation() ==
EltwiseParameter_EltwiseOp_MAX && top->size() == 1) {
namespace caffe {
template <typename Dtype>
-void FlattenLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+void FlattenLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top) {
int channels_out = bottom[0]->channels() * bottom[0]->height()
* bottom[0]->width();
vector<Blob<Dtype>*>* top) {
const int num_output = this->layer_param_.inner_product_param().num_output();
bias_term_ = this->layer_param_.inner_product_param().bias_term();
- // Figure out the dimensions
- M_ = bottom[0]->num();
- K_ = bottom[0]->count() / bottom[0]->num();
N_ = num_output;
- (*top)[0]->Reshape(bottom[0]->num(), num_output, 1, 1);
+ K_ = bottom[0]->count() / bottom[0]->num();
// Check if we need to set up the weights
if (this->blobs_.size() > 0) {
LOG(INFO) << "Skipping parameter initialization";
bias_filler->Fill(this->blobs_[1].get());
}
} // parameter initialization
- // Setting up the bias multiplier
+ this->param_propagate_down_.resize(this->blobs_.size(), true);
+}
+
+template <typename Dtype>
+void InnerProductLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top) {
+ // Figure out the dimensions
+ M_ = bottom[0]->num();
+ CHECK_EQ(bottom[0]->count() / bottom[0]->num(), K_) << "Input size "
+ "incompatible with inner product parameters.";
+ (*top)[0]->Reshape(bottom[0]->num(), N_, 1, 1);
+ // Set up the bias multiplier
if (bias_term_) {
bias_multiplier_.Reshape(1, 1, 1, M_);
caffe_set(M_, Dtype(1), bias_multiplier_.mutable_cpu_data());
}
- this->param_propagate_down_.resize(this->blobs_.size(), true);
}
template <typename Dtype>
namespace caffe {
template <typename Dtype>
-void MVNLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+void MVNLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top) {
(*top)[0]->Reshape(bottom[0]->num(), bottom[0]->channels(),
bottom[0]->height(), bottom[0]->width());
std::copy(slice_param.slice_point().begin(),
slice_param.slice_point().end(),
std::back_inserter(slice_point_));
+}
+
+template <typename Dtype>
+void SliceLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
+ vector<Blob<Dtype>*>* top) {
count_ = 0;
num_ = bottom[0]->num();
channels_ = bottom[0]->channels();
count_ += (*top)[i]->count();
}
}
-
} else {
if (slice_dim_ == 0) {
CHECK_EQ(num_ % top->size(), 0)
namespace caffe {
template <typename Dtype>
-void SoftmaxLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+void SoftmaxLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top) {
(*top)[0]->Reshape(bottom[0]->num(), bottom[0]->channels(),
bottom[0]->height(), bottom[0]->width());
namespace caffe {
template <typename Dtype>
-void SplitLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
+void SplitLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
vector<Blob<Dtype>*>* top) {
count_ = bottom[0]->count();
for (int i = 0; i < top->size(); ++i) {