Put TORCH_LIBRARY in torch/library.h; add custom class API#36742
Put TORCH_LIBRARY in torch/library.h; add custom class API#36742ezyang wants to merge 13 commits intogh/ezyang/728/basefrom
Conversation
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom_class_detail.h/custom_class.h were moved to ATen/core, there are
some modifications in custom_class.h: the definition of Library::class_
is in the bottom of that header because I need all of the class_
constructors available, but there is a circular dependency between the
two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
[ghstack-poisoned]
💊 Build failures summary and remediationsAs of commit 41a88fc (more details on the Dr. CI page):
XLA failureJob pytorch_xla_linux_bionic_py3_6_clang9_build is failing. Please create an issue with title prefixed by This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker. This comment has been revised 48 times. |
| } // namespace jit | ||
|
|
||
| } // namespace torch | ||
| #include <ATen/core/op_registration/custom_class.h> |
There was a problem hiding this comment.
Do we really need to move all this? custom_class.h was meant to be easily accessible and readable for libtorch users and I don't like the indirection this is introducing
There was a problem hiding this comment.
I'm not sure. The operant question is whether or not I can include torch/ base directory from ATen/core. I can probably make it work if I push on the build system enough, but my default assumption is it will require a bit of finagling. (Maybe less finagling since custom_class.h already works on mobile, though?)
There was a problem hiding this comment.
Should we ask if the same accessibility concerns apply to the new API as to custom_class.h? Maybe this is a symptom of the new stuff being too buried.
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom_class_detail.h/custom_class.h were moved to ATen/core, there are
some modifications in custom_class.h: the definition of Library::class_
is in the bottom of that header because I need all of the class_
constructors available, but there is a circular dependency between the
two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom_class_detail.h/custom_class.h were moved to ATen/core, there are
some modifications in custom_class.h: the definition of Library::class_
is in the bottom of that header because I need all of the class_
constructors available, but there is a circular dependency between the
two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom_class_detail.h/custom_class.h were moved to ATen/core, there are
some modifications in custom_class.h: the definition of Library::class_
is in the bottom of that header because I need all of the class_
constructors available, but there is a circular dependency between the
two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
ghstack-source-id: 3236e79
Pull Request resolved: #36742
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom_class_detail.h/custom_class.h were moved to ATen/core, there are
some modifications in custom_class.h: the definition of Library::class_
is in the bottom of that header because I need all of the class_
constructors available, but there is a circular dependency between the
two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom_class_detail.h/custom_class.h were moved to ATen/core, there are
some modifications in custom_class.h: the definition of Library::class_
is in the bottom of that header because I need all of the class_
constructors available, but there is a circular dependency between the
two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom_class_detail.h/custom_class.h were moved to ATen/core, there are
some modifications in custom_class.h: the definition of Library::class_
is in the bottom of that header because I need all of the class_
constructors available, but there is a circular dependency between the
two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: [D21089648](https://our.internmc.facebook.com/intern/diff/D21089648)
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom class API previously lived in torch/ folder and in torch
namespace, so for consistency, the new TORCH_LIBRARY also got
moved to torch/library.h The definition of Library::class_ is in the
bottom of that header because I need all of the class_ constructors
available, but there is a circular dependency between the two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: [D21089648](https://our.internmc.facebook.com/intern/diff/D21089648)
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom class API previously lived in torch/ folder and in torch
namespace, so for consistency, the new TORCH_LIBRARY also got
moved to torch/library.h The definition of Library::class_ is in the
bottom of that header because I need all of the class_ constructors
available, but there is a circular dependency between the two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: [D21089648](https://our.internmc.facebook.com/intern/diff/D21089648)
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom class API previously lived in torch/ folder and in torch
namespace, so for consistency, the new TORCH_LIBRARY also got
moved to torch/library.h The definition of Library::class_ is in the
bottom of that header because I need all of the class_ constructors
available, but there is a circular dependency between the two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: [D21089648](https://our.internmc.facebook.com/intern/diff/D21089648)
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom class API previously lived in torch/ folder and in torch
namespace, so for consistency, the new TORCH_LIBRARY also got
moved to torch/library.h The definition of Library::class_ is in the
bottom of that header because I need all of the class_ constructors
available, but there is a circular dependency between the two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: [D21089648](https://our.internmc.facebook.com/intern/diff/D21089648)
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom class API previously lived in torch/ folder and in torch
namespace, so for consistency, the new TORCH_LIBRARY also got
moved to torch/library.h The definition of Library::class_ is in the
bottom of that header because I need all of the class_ constructors
available, but there is a circular dependency between the two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
ghstack-source-id: 0cfaae8
Pull Request resolved: #36742
|
@jamesr66a OK, PR is updated so that |
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom class API previously lived in torch/ folder and in torch
namespace, so for consistency, the new TORCH_LIBRARY also got
moved to torch/library.h The definition of Library::class_ is in the
bottom of that header because I need all of the class_ constructors
available, but there is a circular dependency between the two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: [D21089648](https://our.internmc.facebook.com/intern/diff/D21089648)
[ghstack-poisoned]
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom class API previously lived in torch/ folder and in torch
namespace, so for consistency, the new TORCH_LIBRARY also got
moved to torch/library.h The definition of Library::class_ is in the
bottom of that header because I need all of the class_ constructors
available, but there is a circular dependency between the two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: [D21089648](https://our.internmc.facebook.com/intern/diff/D21089648)
[ghstack-poisoned]
Companion to pytorch/pytorch#36742 Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
```
static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo);
```
you write
```
TORCH_LIBRARY(Namespace, m) {
m.class_<Class>("Class")
.def("foo", foo);
}
```
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom class API previously lived in torch/ folder and in torch
namespace, so for consistency, the new TORCH_LIBRARY also got
moved to torch/library.h The definition of Library::class_ is in the
bottom of that header because I need all of the class_ constructors
available, but there is a circular dependency between the two headers.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Differential Revision: [D21089648](https://our.internmc.facebook.com/intern/diff/D21089648)
[ghstack-poisoned]
* Update include path to torch/library.h Companion to pytorch/pytorch#36742 Signed-off-by: Edward Z. Yang <ezyang@fb.com> * Delete .torch_pin
|
Reverting due to master-only breakage of pytorch_linux_xenial_py3_clang5_mobile_code_analysis (see https://app.circleci.com/jobs/github/pytorch/pytorch/5207707) To Run: |
…6742) Summary: Pull Request resolved: pytorch#36742 Now, you can define a custom class inside a TORCH_LIBRARY block. It looks very similar to what you did before. Instead of ``` static auto m = torch::class_<Class>("Namespace", "Class").def("foo", foo); ``` you write ``` TORCH_LIBRARY(Namespace, m) { m.class_<Class>("Class") .def("foo", foo); } ``` All the old usages still work, but at some point we should start updating the tutorials when we're ready to go 100% live with the new pybind11 style API. custom class API previously lived in torch/ folder and in torch namespace, so for consistency, the new TORCH_LIBRARY also got moved to torch/library.h The definition of Library::class_ is in the bottom of that header because I need all of the class_ constructors available, but there is a circular dependency between the two headers. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Differential Revision: D21089648 Test Plan: Imported from OSS Pulled By: ezyang fbshipit-source-id: 8d54329c125242605336c22fa1642aae6940b507
…ustom class API" (pytorch#37019) Summary: This reverts commit c062dd8. Original PR: pytorch#36742 Pull Request resolved: pytorch#37019 Differential Revision: D21161361 Pulled By: ezyang fbshipit-source-id: dca4192d3f7be25a34bbe3d57ddce3afc1c2558c
Stack from ghstack:
Now, you can define a custom class inside a TORCH_LIBRARY block.
It looks very similar to what you did before. Instead of
you write
All the old usages still work, but at some point we should start
updating the tutorials when we're ready to go 100% live with the
new pybind11 style API.
custom class API previously lived in torch/ folder and in torch
namespace, so for consistency, the new TORCH_LIBRARY also got
moved to torch/library.h The definition of Library::class_ is in the
bottom of that header because I need all of the class_ constructors
available, but there is a circular dependency between the two headers.
Signed-off-by: Edward Z. Yang ezyang@fb.com
Differential Revision: D21089648