torch.register_method
function register_method<Name extends string>(config: MethodConfig<Name>): MethodHandle<Name>function register_method<Name extends string>(name: Name, impl: (thisArg: TensorLike, ...args: unknown[]) => unknown, options?: RegisterMethodOptions): MethodHandle<Name>Register a custom Tensor method with full configuration object.
Parameters
configMethodConfig<Name>
Returns
MethodHandle<Name>Examples
torch.library.register_method({
name: 'conjugate',
dtypes: ['quaternion_f32'],
impl: (self) => {
// Return quaternion conjugate
},
});
// Usage: q.conjugate()