MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / instance_nvfuser_factory

Function instance_nvfuser_factory

monai/networks/layers/factories.py:259–283  ·  view source on GitHub ↗

`InstanceNorm3dNVFuser` is a faster version of InstanceNorm layer and implemented in `apex`. It only supports 3d tensors as the input. It also requires to use with CUDA and non-Windows OS. In this function, if the required library `apex.normalization.InstanceNorm3dNVFuser` does not exis

(dim)

Source from the content-addressed store, hash-verified

257
258@Norm.factory_function("instance_nvfuser")
259def instance_nvfuser_factory(dim):
260 """
261 `InstanceNorm3dNVFuser` is a faster version of InstanceNorm layer and implemented in `apex`.
262 It only supports 3d tensors as the input. It also requires to use with CUDA and non-Windows OS.
263 In this function, if the required library `apex.normalization.InstanceNorm3dNVFuser` does not exist,
264 `nn.InstanceNorm3d` will be returned instead.
265 This layer is based on a customized autograd function, which is not supported in TorchScript currently.
266 Please switch to use `nn.InstanceNorm3d` if TorchScript is necessary.
267
268 Please check the following link for more details about how to install `apex`:
269 https://github.com/NVIDIA/apex#installation
270
271 """
272
273 if dim != 3:
274 types = (nn.InstanceNorm1d, nn.InstanceNorm2d)
275 warnings.warn(f"`InstanceNorm3dNVFuser` only supports 3d cases, use {types[dim - 1]} instead.")
276 return types[dim - 1]
277
278 if not has_nvfuser_instance_norm():
279 warnings.warn(
280 "`apex.normalization.InstanceNorm3dNVFuser` is not installed properly, use nn.InstanceNorm3d instead."
281 )
282 return nn.InstanceNorm3d
283 return optional_import("apex.normalization", name="InstanceNorm3dNVFuser")[0]
284
285
286Norm.add_factory_class("group", nn.GroupNorm)

Callers

nothing calls this directly

Calls 2

optional_importFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…