optimum/graphcore/trainer.py
def _compile_model(
        self,
        model: poptorch.PoplarExecutor,
        sample_batch: Union[Dict[str, torch.Tensor], Tuple[torch.Tensor]],
        log: bool = False,
    ):
        """
        Compiles the model with poptorch.

        Args:
            model: The model to compile (already wrapped).
            sample_batch: The inputs to use the compilation, this will set the input shapes that the compiled model
                can accept.
            log: Whether to log that compilation is happening or not.

        """
        # Skipping compilation if the model was already compiled.
        if model.isCompiled():
            return
        if log:
            logger.info("Compiling Model...")
        sample_batch = self._prepare_inputs(sample_batch)
        start_compile = time.perf_counter()
        if isinstance(sample_batch, tuple):
            model.compile(*sample_batch)
        else:
            model.compile(**sample_batch)
        duration_compilation = time.perf_counter() - start_compile
        if log:
            logger.info(f"Compiled/Loaded model in {duration_compilation} secs")

        Compiles the model with poptorch.

        Args:
            model: The model to compile (already wrapped).
            sample_batch: The inputs to use the compilation, this will set the input shapes that the compiled model
                can accept.
            log: Whether to log that compilation is happening or not.

        
Compiles the model with poptorch.
Compiles the model with poptorch .
def _compile_model(
        self,
        model: poptorch.PoplarExecutor,
        sample_batch: Union[Dict[str, torch.Tensor], Tuple[torch.Tensor]],
        log: bool = False,
    ):
        if model.isCompiled():
            return
        if log:
            logger.info("Compiling Model...")
        sample_batch = self._prepare_inputs(sample_batch)
        start_compile = time.perf_counter()
        if isinstance(sample_batch, tuple):
            model.compile(*sample_batch)
        else:
            model.compile(**sample_batch)
        duration_compilation = time.perf_counter() - start_compile
        if log:
            logger.info(f"Compiled/Loaded model in {duration_compilation} secs")
def _compile_model ( self , model : poptorch . PoplarExecutor , sample_batch : Union [ Dict [ str , torch . Tensor ] , Tuple [ torch . Tensor ] ] , log : bool = False , ) : if model . isCompiled ( ) : return if log : logger . info ( "Compiling Model..." ) sample_batch = self . _prepare_inputs ( sample_batch ) start_compile = time . perf_counter ( ) if isinstance ( sample_batch , tuple ) : model . compile ( * sample_batch ) else : model . compile ( ** sample_batch ) duration_compilation = time . perf_counter ( ) - start_compile if log : logger . info ( f"Compiled/Loaded model in {duration_compilation} secs" )
Compiles the model with poptorch.
Compiles the model with poptorch .
"""
        Compiles the model with poptorch.

        Args:
            model: The model to compile (already wrapped).
            sample_batch: The inputs to use the compilation, this will set the input shapes that the compiled model
                can accept.
            log: Whether to log that compilation is happening or not.

        """ # Skipping compilation if the model was already compiled.
self
model
poptorch.PoplarExecutor
The model to compile (already wrapped).
The model to compile ( already wrapped ) .
sample_batch
Union[Dict[str, torch.Tensor], Tuple[torch.Tensor]]
The inputs to use the compilation, this will set the input shapes that the compiled model
can accept.
The inputs to use the compilation this will set the input shapes that the compiled model can accept .
log
bool
Whether to log that compilation is happening or not.
Whether to log that compilation is happening or not .