out_dim.width(in_dim.channel());
}
- if (pooling_type == PoolingType::max) {
- max_idx.resize(out_dim.getDataLen());
- }
-
- if (pooling_type == PoolingType::global_max) {
- max_idx_global.resize(out_dim.getDataLen());
- }
-
return status;
}
hidden_ = Tensor(hidden_dim);
}
+ if (pooling_type == PoolingType::max) {
+ max_idx.resize(output_dim[0].getDataLen());
+ } else if (pooling_type == PoolingType::global_max) {
+ max_idx_global.resize(output_dim[0].getDataLen());
+ }
+
for (unsigned int b = 0; b < in_dim.batch(); ++b) {
Tensor in_padded;
zero_pad(b, input_, padding.data(), in_padded);
return status;
}
-void Pooling2DLayer::setBatch(unsigned int batch) {
- Layer::setBatch(batch);
-
- if (pooling_type == PoolingType::max) {
- max_idx.resize(output_dim[0].getDataLen());
- } else if (pooling_type == PoolingType::global_max) {
- max_idx_global.resize(output_dim[0].getDataLen());
- }
-}
-
void Pooling2DLayer::copy(std::shared_ptr<Layer> l) {
Layer::copy(l);
l.setInputBuffers(in_out);
}
}
- setBatchSize(batch_size);
+ setBatchSize();
+
// Allocate and initialize weights
manager->initializeWeights();
manager->setInferenceInOutMemoryOptimization(opt);
}
+ /**
+ * @brief Update batch size of the model as well as its layers/dataset
+ */
+ void setBatchSize() { setBatchSize(batch_size); }
+
/// @todo Make a more common class have this
/// Maybe appcontext can have this?
#ifdef PROFILE
*/
void setBatchSize(unsigned int batch) {
if (!in_outs.empty() && !in_outs[0].empty()) {
- max_derivative_size /= in_outs[0][0]->getDim().batch();
- max_shared_inout /= in_outs[0][0]->getDim().batch();
+ unsigned int prev_batch = in_outs[0][0]->getDim().batch();
+ max_derivative_size /= prev_batch;
+ max_shared_inout /= prev_batch;
max_derivative_size *= batch;
max_shared_inout *= batch;
}