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

Function initialize_beam_scores

src/decoding.cc:84–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83 template <typename T>
84 static void initialize_beam_scores(StorageView& scores,
85 const dim_t batch_size,
86 const dim_t beam_size) {
87 const dim_t size = batch_size * beam_size;
88 scores.resize({size});
89 auto* data = scores.data<T>();
90 for (dim_t i = 0; i < size; ++i) {
91 data[i] = (i % beam_size == 0 ? T(0) : std::numeric_limits<T>::lowest());
92 }
93 }
94
95 static StorageView unflatten_ids(StorageView& ids,
96 const dim_t beam_size,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected