from_jt_dict

The APIs in this class are open-source APIs of the TorchRec and are not external APIs of the Rec SDK Torch. This section describes the parameter ranges supported by the TorchRec APIs called when the Rec SDK Torch is used.

Function

Creates a KeyedJaggedTensor through the JaggedTensor.

Prototype

1
def from_jt_dict(jt_dict: Dict[str, JaggedTensor]) -> "KeyedJaggedTensor"

Parameters

Parameter

Data Type

Mandatory/Optional

Description

jt_dict

Dict[str, JaggedTensor]

Mandatory

Dictionary consisting of the feature name and the corresponding JaggedTensor. The length cannot be 0. For details about the value range of JaggedTensor, see JaggedTensor (TorchRec).

Return Value

  • Success: KeyedJaggedTensor is returned.
  • Failure: An exception is thrown.

Sample

1
2
3
from torchrec import KeyedJaggedTensor, JaggedTensor
jt = JaggedTensor(values=[1, 3, 4], lengths=[1, 1, 1])
kjt = KeyedJaggedTensor.from_jt_dict({"feat0": jt})

See Also

For details about the API call sequence and example, see Porting and Training.