# Difference between TORCH\_LIBRARY() and RegisterOperators::op()

**URL:** <https://discuss.pytorch.org/t/difference-between-torch-library-and-registeroperators-op/92270>\
**Category:** C++\
**Created:** [August 10, 2020, 10:21am UTC](https://discuss.pytorch.org/t/difference-between-torch-library-and-registeroperators-op/92270 "2020-08-10T10:21:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ssapphire](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ssapphire/32/27449_2.png) [@Ssapphire](https://discuss.pytorch.org/u/Ssapphire)\
**Post date:** [August 10, 2020, 10:21am UTC](https://discuss.pytorch.org/t/difference-between-torch-library-and-registeroperators-op/92270/1 "2020-08-10T10:21:43Z")

</div>

I have been studying pytorch’s custom op registration. I noticed that there are these two classes used for registration. I am wondering why there isn’t a README for using TORCH\_LIBRARY(), and what is the difference betweening using TORCH\_LIBRARY(my\_ops,m) and static auto registry = torch::RegisterOperators()  
.op(“my\_ops::myrelu”, torch::RegisterOperators::options()  
.kernel\<decltype(myrelu), &myrelu\>(c10::DispatchKey::CPU));

---

<div class="post-metadata">

**Author:** ![ezyang](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ezyang/32/486_2.png) [@ezyang](https://discuss.pytorch.org/u/ezyang)\
**Post date:** [August 10, 2020, 8:03pm UTC](https://discuss.pytorch.org/t/difference-between-torch-library-and-registeroperators-op/92270/2 "2020-08-10T20:03:20Z")

</div>

Check out [https://pytorch.org/tutorials/advanced/torch\_script\_custom\_ops.html](https://pytorch.org/tutorials/advanced/torch_script_custom_ops.html) and [https://pytorch.org/tutorials/advanced/dispatcher.html](https://pytorch.org/tutorials/advanced/dispatcher.html)

Reference C++ docs at [https://pytorch.org/cppdocs/api/file\_torch\_library.h.html](https://pytorch.org/cppdocs/api/file_torch_library.h.html)

The APIs go into the same internal machinery, but the TORCH\_LIBRARY API is the newer one and you should use it instead.
