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

Function restore_batch_ids_in_callback

include/ctranslate2/generation.h:120–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118
119 template <typename Options>
120 Options restore_batch_ids_in_callback(Options options, const std::vector<size_t>& example_index) {
121 if (options.callback) {
122 std::function<bool(GenerationStepResult)> wrapped_callback =
123 [&example_index, callback = std::move(options.callback)]
124 (GenerationStepResult step_result) {
125 step_result.batch_id = example_index[step_result.batch_id];
126 return callback(std::move(step_result));
127 };
128
129 options.callback = std::move(wrapped_callback);
130 }
131
132 return options;
133 }
134
135 class ResolveEndToken {
136 private:

Callers 2

generate_batch_asyncMethod · 0.85
run_translationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected