| 7 | namespace data { |
| 8 | namespace buffer { |
| 9 | Batch::Batch( |
| 10 | const std::shared_ptr<Buffer>& op, |
| 11 | int64_t batch_size, |
| 12 | const std::unordered_map<std::string, double>& pad_values, |
| 13 | const std::unordered_map<std::string, int>& batch_dims) |
| 14 | : op_(op), |
| 15 | batchSize_(batch_size), |
| 16 | padValues_(pad_values), |
| 17 | batchDims_(batch_dims) { |
| 18 | if (batch_size <= 0) { |
| 19 | throw std::runtime_error("Batch: batch size must be positive"); |
| 20 | } |
| 21 | size_ = op->size() / batch_size; |
| 22 | if (op->size() % batch_size) { |
| 23 | size_++; |
| 24 | } |
| 25 | } |
| 26 | Batch::Batch( |
| 27 | const std::shared_ptr<Buffer>& op, |
| 28 | const std::vector<int64_t>& batch_sizes, |