MCPcopy Create free account
hub / github.com/pytorch/tutorials / jagged_to_padded

Function jagged_to_padded

unstable_source/nestedtensor.py:299–303  ·  view source on GitHub ↗
(jt, padding_val)

Source from the content-addressed store, hash-verified

297######################################################################
298# Generate padded forms of query, key, value for comparison
299def jagged_to_padded(jt, padding_val):
300 # TODO: do jagged -> padded directly when this is supported
301 return torch.nested.to_padded_tensor(
302 torch.nested.nested_tensor(list(jt.unbind())),
303 padding_val)
304
305padded_query, padded_key, padded_value = (
306 jagged_to_padded(t, 0.0) for t in (query, key, value)

Callers 1

nestedtensor.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected