Skip to content

MONAI Transforms inherit torch.nn.Module #2883

Description

@bhashemian

Is your feature request related to a problem? Please describe.
MONAI array transforms are all derived from Transform base class by implementing __call__ method, and similar to torchvision transform can be chained using Compose. However, in torchvision transforms without losing any backward compatibility are inherited fromnn.Module (since v0.8.0). This has some obvious benefits:

  1. They can be used torchscripted with torch.jit.script
  2. They can be chained using nn.Sequential. This will allow the transforms be chained with the model as well and let them run on the same device that model is being run.

Describe the solution you'd like

  1. Derive all transform from torch.nn.Module instead of Transform
  2. Implement forward for all transforms instead of __call__
  3. Make them work with torch.Tensors (Default to using Pytorch APIs for monai.transforms (ETA TBD) #2231)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions