megengine.module.Module.register_forward_pre_hook

Module.register_forward_pre_hook(hook)[源代码]

Registers a hook to handle forward inputs. hook should be a function.

参数

hook (Callable) – a function that receive module and inputs, then return a modified inputs or None.

返回类型

HookHandler

返回

a handler with remove interface to delete the hook.