# tensorplay.custom_fwd

Source: https://www.tensorplay.cn/docs/generated/tensorplay.custom_fwd.html

# tensorplay.custom_fwd

tensorplay.custom_fwd(fwd=None, *, device_type: [str](https://docs.python.org/3/library/stdtypes.html#str), cast_inputs=None)[[source]](../_modules/tensorplay/amp/autocast_mode.html#custom_fwd)

Create a helper decorator for forward methods of custom autograd functions.

Autograd functions are subclasses of tensorplay.autograd.Function.

Parameters:

- device_type ([str](https://docs.python.org/3/library/stdtypes.html#str)) – Device type to use. ‘cuda’, ‘cpu’. The type is the same as the type attribute of a [tensorplay.device](tensorplay.device.html#tensorplay.device). Thus, you may obtain the device type of a tensor using Tensor.device.type .

- cast_inputs ([tensorplay.dtype](tensorplay.dtype.html#tensorplay.dtype) or None, optional, default=None) – If not None , when forward runs in an autocast-enabled region, casts incoming floating-point Tensors to the target dtype (non-floating-point Tensors are not affected), then executes forward with autocast disabled. If None , forward ’s internal ops execute with the current autocast state.

Note

If the decorated forward is called outside an autocast-enabled region,
[custom_fwd](#tensorplay.custom_fwd) is a no-op and cast_inputs has no effect.
