optimum/graphcore/trainer.py
def training_step(
        self, model: poptorch.PoplarExecutor, inputs: Dict[str, Union[torch.Tensor, Any]]
    ) -> torch.Tensor:
        """
        Perform a training step on a batch of inputs.

        Subclass and override to inject custom behavior.

        Args:
            model (:obj:`nn.Module`):
                The model to train.
            inputs (:obj:`Dict[str, Union[torch.Tensor, Any]]`):
                The inputs and targets of the model.

                The dictionary will be unpacked before being fed to the model. Most models expect the targets under the
                argument :obj:`labels`. Check your model's documentation for all accepted arguments.

        Return:
            :obj:`torch.Tensor`: The tensor with training loss on this batch.
        """
        inputs = self._prepare_inputs(inputs)
        loss = self.compute_loss(model, inputs)
        loss = loss.mean()
        return loss

        Perform a training step on a batch of inputs.

        Subclass and override to inject custom behavior.

        Args:
            model (:obj:`nn.Module`):
                The model to train.
            inputs (:obj:`Dict[str, Union[torch.Tensor, Any]]`):
                The inputs and targets of the model.

                The dictionary will be unpacked before being fed to the model. Most models expect the targets under the
                argument :obj:`labels`. Check your model's documentation for all accepted arguments.

        Return:
            :obj:`torch.Tensor`: The tensor with training loss on this batch.
        
Perform a training step on a batch of inputs.
Subclass and override to inject custom behavior.
Perform a training step on a batch of inputs . Subclass and override to inject custom behavior .
def training_step(
        self, model: poptorch.PoplarExecutor, inputs: Dict[str, Union[torch.Tensor, Any]]
    ) -> torch.Tensor:
        inputs = self._prepare_inputs(inputs)
        loss = self.compute_loss(model, inputs)
        loss = loss.mean()
        return loss
def training_step ( self , model : poptorch . PoplarExecutor , inputs : Dict [ str , Union [ torch . Tensor , Any ] ] ) -> torch . Tensor : inputs = self . _prepare_inputs ( inputs ) loss = self . compute_loss ( model , inputs ) loss = loss . mean ( ) return loss
Perform a training step on a batch of inputs.
Perform a training step on a batch of inputs .
"""
        Perform a training step on a batch of inputs.

        Subclass and override to inject custom behavior.

        Args:
            model (:obj:`nn.Module`):
                The model to train.
            inputs (:obj:`Dict[str, Union[torch.Tensor, Any]]`):
                The inputs and targets of the model.

                The dictionary will be unpacked before being fed to the model. Most models expect the targets under the
                argument :obj:`labels`. Check your model's documentation for all accepted arguments.

        Return:
            :obj:`torch.Tensor`: The tensor with training loss on this batch.
        """
self
model
poptorch.PoplarExecutor
inputs
Dict[str, Union[torch.Tensor, Any]]
model (
`nn.Module`):
The model to train.
` nn . Module ` ) : The model to train .
inputs (
`Dict[str, Union[torch.Tensor, Any]]`):
The inputs and targets of the model.

The dictionary will be unpacked before being fed to the model. Most models expect the targets under the
argument :obj:`labels`. Check your model's documentation for all accepted arguments.
` Dict [ str Union [ torch . Tensor Any ]] ` ) : The inputs and targets of the model . The dictionary will be unpacked before being fed to the model . Most models expect the targets under the argument : obj : ` labels ` . Check your model ' s documentation for all accepted arguments .