TensorPlay

Latest development documentation · Updated 2026-09-08. A documentation snapshot for package 1.0.0.dev20260909 is not available.

On this page

Functions 7

#

register_module_buffer_registration_hook

functionFull reference ↗
tensorplay.nn.modules.module.register_module_buffer_registration_hook(hook: Callable[[...], None]) RemovableHandle[source]

Register a buffer registration hook common to all modules.

Warning

This adds global state to the nn.Module module

The hook will be called every time register_buffer() is invoked. It should have the following signature:

hook(module, name, buffer) -> None or new buffer

The hook can modify the input or return a single modified value in the hook.

Returns:

a handle that can be used to remove the added hook by calling handle.remove()

Return type:

tensorplay.utils.hooks.RemovableHandle

#

register_module_forward_hook

functionFull reference ↗
tensorplay.nn.modules.module.register_module_forward_hook(hook: Callable[[...], None], *, with_kwargs: bool = False, always_call: bool = False) RemovableHandle[source]

Register a global forward hook for all the modules.

Warning

This adds global state to the nn.module module and it is only intended for debugging/profiling purposes.

The hook will be called every time after forward() has computed an output. It should have the following signature:

hook(module, input, output) -> None or modified output

The input contains only the positional arguments given to the module. Keyword arguments won’t be passed to the hooks and only to the forward. You can optionally modify the output of the module by returning a new value that will replace the output from the forward() function.

Parameters:
  • hook (Callable) – The user defined hook to be registered.

  • always_call (bool) – If True the hook will be run regardless of whether an exception is raised while calling the Module. Default: False

Returns:

a handle that can be used to remove the added hook by calling handle.remove()

Return type:

tensorplay.utils.hooks.RemovableHandle

This hook will be executed before specific module hooks registered with register_forward_hook.

#

register_module_forward_pre_hook

functionFull reference ↗
tensorplay.nn.modules.module.register_module_forward_pre_hook(hook: Callable[[...], None]) RemovableHandle[source]

Register a forward pre-hook common to all modules.

Warning

This adds global state to the nn.module module and it is only intended for debugging/profiling purposes.

The hook will be called every time before forward() is invoked. It should have the following signature:

hook(module, input) -> None or modified input

The input contains only the positional arguments given to the module. Keyword arguments won’t be passed to the hooks and only to the forward. The hook can modify the input. User can either return a tuple or a single modified value in the hook. We will wrap the value into a tuple if a single value is returned(unless that value is already a tuple).

This hook has precedence over the specific module hooks registered with register_forward_pre_hook.

Returns:

a handle that can be used to remove the added hook by calling handle.remove()

Return type:

tensorplay.utils.hooks.RemovableHandle

#

register_module_full_backward_hook

functionFull reference ↗
tensorplay.nn.modules.module.register_module_full_backward_hook(hook: Callable[[Module, tuple[TensorBase, ...] | TensorBase, tuple[TensorBase, ...] | TensorBase], None | tuple[TensorBase, ...] | TensorBase]) RemovableHandle[source]

Register a backward hook common to all the modules.

Warning

This adds global state to the nn.module module and it is only intended for debugging/profiling purposes.

Hooks registered using this function behave in the same way as those registered by tensorplay.nn.Module.register_full_backward_hook(). Refer to its documentation for more details.

Hooks registered using this function will be called before hooks registered using tensorplay.nn.Module.register_full_backward_hook().

Returns:

a handle that can be used to remove the added hook by calling handle.remove()

Return type:

tensorplay.utils.hooks.RemovableHandle

#

register_module_full_backward_pre_hook

functionFull reference ↗
tensorplay.nn.modules.module.register_module_full_backward_pre_hook(hook: Callable[[Module, tuple[TensorBase, ...] | TensorBase], None | tuple[TensorBase, ...] | TensorBase]) RemovableHandle[source]

Register a backward pre-hook common to all the modules.

Warning

This adds global state to the nn.module module and it is only intended for debugging/profiling purposes.

Hooks registered using this function behave in the same way as those registered by tensorplay.nn.Module.register_full_backward_pre_hook(). Refer to its documentation for more details.

Hooks registered using this function will be called before hooks registered using tensorplay.nn.Module.register_full_backward_pre_hook().

Returns:

a handle that can be used to remove the added hook by calling handle.remove()

Return type:

tensorplay.utils.hooks.RemovableHandle

#

register_module_module_registration_hook

functionFull reference ↗
tensorplay.nn.modules.module.register_module_module_registration_hook(hook: Callable[[...], None]) RemovableHandle[source]

Register a module registration hook common to all modules.

Warning

This adds global state to the nn.Module module

The hook will be called every time register_module() is invoked. It should have the following signature:

hook(module, name, submodule) -> None or new submodule

The hook can modify the input or return a single modified value in the hook.

Returns:

a handle that can be used to remove the added hook by calling handle.remove()

Return type:

tensorplay.utils.hooks.RemovableHandle

#

register_module_parameter_registration_hook

functionFull reference ↗
tensorplay.nn.modules.module.register_module_parameter_registration_hook(hook: Callable[[...], None]) RemovableHandle[source]

Register a parameter registration hook common to all modules.

Warning

This adds global state to the nn.Module module

The hook will be called every time register_parameter() is invoked. It should have the following signature:

hook(module, name, param) -> None or new parameter

The hook can modify the input or return a single modified value in the hook.

Returns:

a handle that can be used to remove the added hook by calling handle.remove()

Return type:

tensorplay.utils.hooks.RemovableHandle

Search documentation

Search all 1,743 documentation pages.

Keyboard shortcuts

Global

  • /Focus search
  • ?This dialog
  • ,Open settings
  • jAI assistant

Search

  • Navigate results
  • Open result
  • escClose

Package

  • mMain information
  • dDocs
  • .Code
  • -Changelog
  • tTimeline
  • sStats
  • vVersions