In pytorch torchscript, how to define mutiple entry point
Have a torch model as follow :
  MyModel
       update(self)    :  Update some params.
       predict(self,X) :  Predict with some input tensor.

When exporting to torchscript, is there a way to have 2 entry points:
One for  update()
One for predict()


Yes, you can define multiple entry points in a TorchScript model by using the @torch.jit.export decorator to specify which methods should be exported as entry points.
For example, given a PyTorch model defined as follows:
class MyModel(nn.Module):
def update(self):
    # Update some params.

def predict(self, X):
    # Predict with some input tensor.

You can use the @torch.jit.export decorator to specify that the update and predict methods should be exported as entry points in the resulting TorchScript module, like this:
class MyModel(nn.Module):
@torch.jit.export
def update(self):
    # Update some params.

@torch.jit.export
def predict(self, X):
    # Predict with some input tensor.

You can then export the MyModel class to TorchScript using the following code:
model = MyModel()
traced_model = torch.jit.script(model)

The resulting TorchScript module will have two entry points, update and predict, which you can use to call the corresponding methods of your model.
traced_model.update()
traced_model.predict(X)

Alternatively, you can also use the torch.jit.export decorator at the class level to specify that all of the methods in the class should be exported as entry points in the resulting TorchScript module. For example:
@torch.jit.export
class MyModel(nn.Module):
   def update(self):
       # Update some params.

   def predict(self, X):
       # Predict with some input tensor.

In this code, the @torch.jit.export decorator is applied to the MyModel class itself, which tells the torch.jit.script function to export all of the methods in the MyModel class as entry points in the resulting TorchScript module.
You can then export the MyModel class to TorchScript using the following code:
model = MyModel()
traced_model = torch.jit.script(model)

The resulting TorchScript module will have two entry points, update and predict, which you can use to call the corresponding methods of your model.
traced_model.update()
traced_model.predict(X)

