/** * @brief Implements common layer setup functionality. * * @param bottom the preshaped input blobs * @param top * the allocated but unshaped output blobs, to be shaped by Reshape * * Checks that the number of bottom and top blobs is correct. * Calls LayerSetUp to do special layer setup for individual layer types, * followed by Reshape to set up sizes of top blobs and internal buffers. * Sets up the loss weight multiplier blobs for any non-zero loss weights. * This method may not be overridden. */ void SetUp(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { CheckBlobCounts(bottom, top); LayerSetUp(bottom, top); Reshape(bottom, top); SetLossWeights(top); }
/** * @brief Implements common layer setup functionality. * * @param bottom the preshaped input blobs * @param top * the allocated but unshaped output blobs, to be shaped by Reshape * * Checks that the number of bottom and top blobs is correct. * Calls LayerSetUp to do special layer setup for individual layer types, * followed by Reshape to set up sizes of top blobs and internal buffers. * Sets up the loss weight multiplier blobs for any non-zero loss weights. * This method may not be overridden. */ void SetUp(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { InitMutex(); CheckBlobCounts(bottom, top); LayerSetUp(bottom, top); Reshape(bottom, top); SetLossWeights(top); #ifdef USE_MLSL MultinodeSetUp(bottom, top); #endif }
void BilateralFilterLayer<Dtype>::Reshape( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { CHECK_EQ(bottom[0]->num_axes(), bottom[1]->num_axes()); CHECK_GE(bottom[0]->num_axes(), 3); LayerSetUp(bottom, top); top[0]->ReshapeLike(*bottom[0]); const int nspatialch_wrt = create_spatial_dimension_features_ ? (bottom[1]->num_axes() - 2) : 0; const int nchannels_wrt = bottom[1]->shape(1) + nspatialch_wrt; if (stdv_color_ > 0.0f || stdv_space_ > 0.0f) { CHECK(stdv_color_ > 0.0f && stdv_space_ > 0.0f); CHECK(nchannels_wrt > nspatialch_wrt); stdv_widths_host_.resize(nchannels_wrt); for(int ii=0; ii<nspatialch_wrt; ++ii) stdv_widths_host_[ii] = stdv_space_; for(int ii=nspatialch_wrt; ii<nchannels_wrt; ++ii) stdv_widths_host_[ii] = stdv_color_; } switch (Caffe::mode()) { case Caffe::CPU: bilateral_interface_cpu_.reset(new PermutohedralOp_CPU<Dtype>(stdv_widths_host_)); break; #ifndef CPU_ONLY case Caffe::GPU: bilateral_interface_gpu_.reset(new_permutohedral_gpu_op<Dtype>(nchannels_wrt, stdv_widths_host_, create_spatial_dimension_features_)); break; #endif default: LOG(FATAL) << "Unknown caffe mode."; } }