nir

Contents

nir#

This submodule provides the functionality to operate with NIR representation.

sinabs.nir.to_nir(module: Module, sample_data: Tensor, model_name: str = 'model') NIRNode[source]#

Generate a NIRGraph given a sinabs model.

Parameters:
  • module (torch.nn.Module) – The sinabs model to be converted to NIR graph

  • sample_data (torch.Tensor) – A sample data that can be used to extract various shapes and internal states.

  • model_name (str, optional) – The name of the top level model. Defaults to “model”.

Returns:

Returns the equivalent NIR object.

Return type:

nir.NIRNode

sinabs.nir.from_nir(node: NIRNode, batch_size: int = None, num_timesteps: int = None) Module[source]#

Load a sinabs model from an NIR model.

Parameters:
  • node (nir.NIRNode) – An NIR node/graph of the model

  • batch_size (int, optional) – batch size of the data that is expected to be fed to the model.Defaults to None.

  • num_timesteps (int, optional) – Number of time steps per data sample. Defaults to None.

Return type:

Module

Note

batch_size or num_timesteps has to be specified for the sinabs model to be instantiated correctly.

Returns:

Returns a sinabs model that is equivalent to the NIR graph specified.

Return type:

torch.nn.Module

Parameters:
  • node (NIRNode)

  • batch_size (int)

  • num_timesteps (int)