19
19
from torch .autograd import Function
20
20
from torch .nn import Module
21
21
from torch .optim import Optimizer
22
- from torch .utils .data import DataLoader , Dataset
22
+ from torch .utils .data import Dataset
23
23
24
- # from monai.transforms.transform import Transform
25
24
from monai .utils import ensure_tuple , optional_import
26
25
27
26
_nvtx , _ = optional_import ("torch._C._nvtx" , descriptor = "NVTX is not installed. Are you sure you have a CUDA build?" )
@@ -40,7 +39,7 @@ class Range:
40
39
methods: (only when used as decorator) the name of a method (or a list of the name of the methods)
41
40
to be wrapped by NVTX range.
42
41
If None (default), the method(s) will be inferred based on the object's type for various MONAI components,
43
- such as Networks, Losses, Optimizers, Functions, Transforms, Datasets, and Dataloaders .
42
+ such as Networks, Losses, Functions, Transforms, and Datasets .
44
43
Otherwise, it look up predefined methods: "forward", "__call__", "__next__", "__getitem__"
45
44
append_method_name: if append the name of the methods to be decorated to the range's name
46
45
If None (default), it appends the method's name only if we are annotating more than one method.
@@ -114,15 +113,13 @@ def range_wrapper(*args, **kwargs):
114
113
115
114
def _get_method (self , obj : Any ) -> tuple :
116
115
if isinstance (obj , Module ):
117
- method_list = ["forward" , "__call__" ]
116
+ method_list = ["forward" ]
118
117
elif isinstance (obj , Optimizer ):
119
118
method_list = ["step" ]
120
119
elif isinstance (obj , Function ):
121
120
method_list = ["forward" , "backward" ]
122
121
elif isinstance (obj , Dataset ):
123
122
method_list = ["__getitem__" ]
124
- elif isinstance (obj , DataLoader ):
125
- method_list = ["_next_data" ]
126
123
else :
127
124
default_methods = ["forward" , "__call__" , "__next__" , "__getitem__" ]
128
125
method_list = []
0 commit comments