MCPcopy Create free account
hub / github.com/apple/axlearn / init_state

Method init_state

axlearn/common/decoding.py:300–311  ·  view source on GitHub ↗

Initializes prefix merger state. Args: tokens: The initial live sequences, of shape [batch_size, num_decodes, max_decode_len]. When prefilling the decoding cache, this consists of the decoding prefixes padded to `max_decode_len`. Returns:

(self, *, tokens: Tensor)

Source from the content-addressed store, hash-verified

298 """
299
300 def init_state(self, *, tokens: Tensor) -> NestedTensor:
301 """Initializes prefix merger state.
302
303 Args:
304 tokens: The initial live sequences, of shape [batch_size, num_decodes, max_decode_len].
305 When prefilling the decoding cache, this consists of the decoding prefixes padded to
306 `max_decode_len`.
307
308 Returns:
309 The initial state.
310 """
311 raise NotImplementedError(type(self))
312
313 def compute(self, state: NestedTensor) -> Tensor:
314 """Computes the merge matrix.

Callers 5

_beam_initFunction · 0.45
_compute_metricsFunction · 0.45
_compute_metricsFunction · 0.45
_compute_metricsFunction · 0.45
_compute_summariesMethod · 0.45

Calls

no outgoing calls

Tested by 4

_compute_metricsFunction · 0.36
_compute_metricsFunction · 0.36
_compute_metricsFunction · 0.36
_compute_summariesMethod · 0.36