Define TORCH_LIBRARY#
Defined in File library.h
Define Documentation#
-
TORCH_LIBRARY(ns, m) static void TORCH_LIBRARY_init_##ns(torch::Library
&); \
static const
torch::detail::TorchLibraryInitTORCH_LIBRARY_static_init_##ns( \
torch::Library::DEF, \
&TORCH_LIBRARY_init_##ns, \
#ns, \
std::nullopt, \
__FILE__, \
__LINE__); \
void TORCH_LIBRARY_init_##ns(
torch::Library& m)# Macro for defining a function that will be run at static initialization time to define a library of operators in the namespace
ns
(must be a valid C++ identifier, no quotes).Use this macro when you want to define a new set of custom operators that do not already exist in PyTorch.
Example usage:
TORCH_LIBRARY(myops, m) { // m is a torch::Library; methods on it will define // operators in the myops namespace m.def("add", add_impl); }
The
m
argument is bound to a torch::Library that is used to register operators. There may only be one TORCH_LIBRARY() for any given namespace.