in_backward_optimizer_filter (TorchRec)

This API is an open-source API of the TorchRec and is not an external API 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

Filters out parameters that are specified as backward_optimizer.

Prototype

1
2
3
def in_backward_optimizer_filter(
    named_parameters: Iterator[Tuple[str, nn.Parameter]], include: bool = False
) -> Iterator[Tuple[str, nn.Parameter]]:

Parameters

Parameter

Type

Mandatory/Optional

Description

named_parameters

Iterator[Tuple[str, nn.Parameter]]

Mandatory

Model parameters.

You need to ensure that the variable is obtained by using named_parameters() of torch.nn.Module.

include

bool

Optional

If include is set to True, the returned result contains the parameter name of backward_optimizer. Otherwise, the returned result does not contain the parameter name of backward_optimizer. The default value is False.

  • True: included.
  • False: excluded.

Return Value

  • Success: The filtered parameters are returned.
  • Failure: An exception is thrown.

Example

1
2
from torchrec.optim.optimizers import in_backward_optimizer_filter
parameter = in_backward_optimizer_filter(model.named_parameters())

See Also

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