MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / fill_batch_with_variable_increment

Method fill_batch_with_variable_increment

src/batch_reader.cc:60–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 }
59
60 std::vector<Example>
61 BatchReader::fill_batch_with_variable_increment(const size_t max_batch_size,
62 const BatchType batch_type) {
63 std::vector<Example> batch;
64 batch.reserve(max_batch_size);
65
66 size_t total_increment = 0;
67
68 while (!_next.empty()) {
69 const size_t cur_increment = get_batch_size_increment(_next, batch_type);
70 const size_t new_batch_size = total_increment + cur_increment;
71
72 if (!batch.empty() && new_batch_size > max_batch_size)
73 break;
74
75 batch.emplace_back(std::move(_next));
76 total_increment += cur_increment;
77 _next = get_next_example();
78 }
79 return batch;
80 }
81
82 std::vector<Example>
83 BatchReader::get_next(const size_t max_batch_size,

Callers

nothing calls this directly

Calls 2

get_batch_size_incrementFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected