mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: This does 6 things: - add c10/util/Registry.h as the unified registry util - cleaned up some APIs such as export condition - fully remove aten/core/registry.h - fully remove caffe2/core/registry.h - remove a bogus aten/registry.h - unifying all macros - set up registry testing in c10 Also, an important note that we used to mark the templated Registry class as EXPORT - this should not happen, because one should almost never export a template class. This PR fixes that. Pull Request resolved: https://github.com/pytorch/pytorch/pull/12077 Reviewed By: ezyang Differential Revision: D10050771 Pulled By: Yangqing fbshipit-source-id: 417b249b49fed6a67956e7c6b6d22374bcee24cf
31 lines
1021 B
C++
31 lines
1021 B
C++
#pragma once
|
|
|
|
#include <pybind11/pybind11.h>
|
|
#include "c10/util/Registry.h"
|
|
|
|
namespace caffe2 {
|
|
namespace python {
|
|
|
|
namespace py = pybind11;
|
|
|
|
struct PybindAddition {
|
|
PybindAddition() {}
|
|
PybindAddition(py::module&) {}
|
|
virtual ~PybindAddition(){};
|
|
};
|
|
|
|
C10_DECLARE_REGISTRY(PybindAdditionRegistry, PybindAddition, py::module&);
|
|
|
|
#define REGISTER_PYBIND_ADDITION(funcname) \
|
|
namespace { \
|
|
struct funcname##Impl : public PybindAddition { \
|
|
funcname##Impl(py::module& m) { \
|
|
funcname(m); \
|
|
} \
|
|
}; \
|
|
C10_REGISTER_CLASS(PybindAdditionRegistry, funcname##Impl, funcname##Impl); \
|
|
}
|
|
|
|
} // namespace python
|
|
} // namespace caffe2
|