Skip to content

Conversation

@li-roy
Copy link
Contributor

@li-roy li-roy commented Jun 4, 2019

Stack from ghstack:

Replace Type object based dispatch with a table of void*. This is bc breaking because it will break cpp extensions that extend Type.

This gives us a registration system that has a similar API to c10 dispatch. Backend extensions can be folded into use this API directly rather than having its own dispatch system. This also saves us a dispatch because Type dispatch was doing a dynamic dispatch and a vtable dispatch, while this table only does a dynamic dispatch.

As a follow up to this change, we can clean up a lot of code involving Type.

Outline of this change:

  • Create dispatcher to register functions and variable functions
  • Generate Type methods as static instead so that they can be registered on dispatcher
  • Generate VariableType methods as static, instead of storing baseType, Variable functions redispatch and on the redispatch, it will call the non variable method.
  • Change Functions.h and TensorMethods.h to call into the dispatcher rather than LegacyTypeDispatch.
  • Factory functions previously used getType to initialize backends. New dispatcher doesn't do this, so for now, make a call to legacyTypeDispatch() to initialize backends.

Benchmarks are a bit noisy because we're timing such a small op, but I ran benchmarks on a null op, with and without variable unwrapping.

a = torch.randn(1,1)
%timeit torch.null(a)
%timeit torch.null_with_backwards(a)

Before, without variable unwrapping: ~365ns
After, without variable unwrapping: ~330ns
Before, with variable unwrapping: ~450ns
After, with variable unwrapping: ~420ns

Differential Revision: D15637222

@pytorchbot pytorchbot added module: autograd Related to torch.autograd, and the autograd engine in general module: cpp-extensions Related to torch.utils.cpp_extension module: internals Related to internal abstractions in c10 and ATen labels Jun 4, 2019
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
@li-roy li-roy changed the title Replace Type dispatch with ATenDispatch [wip] Replace Type dispatch with ATenDispatch Jun 4, 2019
royboy added 3 commits June 4, 2019 01:14
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
@ezyang
Copy link
Contributor

ezyang commented Jun 5, 2019

Do you want initial review now or wait until it's not WIP?

@li-roy li-roy changed the title [wip] Replace Type dispatch with ATenDispatch [BC-BREAKING] Replace Type dispatch with ATenDispatch Jun 5, 2019
@li-roy
Copy link
Contributor Author

li-roy commented Jun 5, 2019

@ezyang sorry this is ready for review, i forgot to change the title.

@ezyang
Copy link
Contributor

ezyang commented Jun 5, 2019

cc @ailzhang What's the plan for coordinating this diff with XLA?

@ezyang
Copy link
Contributor

ezyang commented Jun 5, 2019

UBSAN seems to have caught an error:

un 05 03:14:01 [2/2] c++ complex_registration_extension.o -shared -o complex_registration_extension.so
Jun 05 03:14:01 /var/lib/jenkins/workspace/aten/src/ATen/core/LegacyTypeDispatch.h:86:70: runtime error: reference binding to null pointer of type 'const at::Type'
Jun 05 03:14:01     #0 0x7fbcb0d36b6f in at::LegacyTypeDispatch::getTypeRaw(c10::Backend, c10::ScalarType, bool) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch_python.so+0xf77b6f)
Jun 05 03:14:01     #1 0x7fbcb0d3698e in at::legacyTensorType(c10::TensorImpl const&) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch_python.so+0xf7798e)
Jun 05 03:14:01     #2 0x7fbcb0d36783 in at::Tensor::dispatch_type() const (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch_python.so+0xf77783)
Jun 05 03:14:01     #3 0x7fbcb0bd26aa in torch::autograd::THPVariable_type(_object*, _object*, _object*) (/opt/conda/lib/python3.6/site-packages/torch/lib/libtorch_python.so+0xe136aa)
Jun 05 03:14:01     #4 0x5565dc3a5743 in _PyCFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/methodobject.c:231
Jun 05 03:14:01     #5 0x5565dc42c42b in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4851
Jun 05 03:14:01     #6 0x5565dc451389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
Jun 05 03:14:01     #7 0x5565dc42653a in _PyFunction_FastCall /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
Jun 05 03:14:01     #8 0x5565dc42653a in fast_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4968
Jun 05 03:14:01     #9 0x5565dc42c504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
Jun 05 03:14:01     #10 0x5565dc451389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
Jun 05 03:14:01     #11 0x5565dc4258e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
Jun 05 03:14:01     #12 0x5565dc426e69 in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
Jun 05 03:14:01     #13 0x5565dc3a5b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
Jun 05 03:14:01     #14 0x5565dc3aa6a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
Jun 05 03:14:01     #15 0x5565dc3a554d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
Jun 05 03:14:01     #16 0x5565dc452a6b in do_call_core /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
Jun 05 03:14:01     #17 0x5565dc452a6b in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
Jun 05 03:14:01     #18 0x5565dc4258e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
Jun 05 03:14:01     #19 0x5565dc426c4b in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
Jun 05 03:14:01     #20 0x5565dc3a5b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
Jun 05 03:14:01     #21 0x5565dc3aa6a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
Jun 05 03:14:01     #22 0x5565dc3a554d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
Jun 05 03:14:01     #23 0x5565dc3ffa90 in slot_tp_call /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:6207
Jun 05 03:14:01     #24 0x5565dc3a592a in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2331
Jun 05 03:14:01     #25 0x5565dc42c57d in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4875
Jun 05 03:14:01     #26 0x5565dc451389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
Jun 05 03:14:01     #27 0x5565dc4258e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
Jun 05 03:14:01     #28 0x5565dc426e69 in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
Jun 05 03:14:01     #29 0x5565dc3a5b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
Jun 05 03:14:01     #30 0x5565dc3aa6a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
Jun 05 03:14:01     #31 0x5565dc3a554d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
Jun 05 03:14:01     #32 0x5565dc452a6b in do_call_core /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
Jun 05 03:14:01     #33 0x5565dc452a6b in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
Jun 05 03:14:01     #34 0x5565dc4258e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
Jun 05 03:14:01     #35 0x5565dc426c4b in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
Jun 05 03:14:01     #36 0x5565dc3a5b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
Jun 05 03:14:01     #37 0x5565dc3aa6a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
Jun 05 03:14:01     #38 0x5565dc3a554d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
Jun 05 03:14:01     #39 0x5565dc3ffa90 in slot_tp_call /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:6207
Jun 05 03:14:01     #40 0x5565dc3a592a in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2331
Jun 05 03:14:01     #41 0x5565dc42c57d in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4875
Jun 05 03:14:01     #42 0x5565dc451389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
Jun 05 03:14:01     #43 0x5565dc4258e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
Jun 05 03:14:01     #44 0x5565dc426e69 in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
Jun 05 03:14:01     #45 0x5565dc3a5b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
Jun 05 03:14:01     #46 0x5565dc3aa6a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
Jun 05 03:14:01     #47 0x5565dc3a554d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
Jun 05 03:14:01     #48 0x5565dc452a6b in do_call_core /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5120
Jun 05 03:14:01     #49 0x5565dc452a6b in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3404
Jun 05 03:14:01     #50 0x5565dc4258e3 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
Jun 05 03:14:01     #51 0x5565dc426c4b in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
Jun 05 03:14:01     #52 0x5565dc3a5b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
Jun 05 03:14:01     #53 0x5565dc3aa6a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
Jun 05 03:14:01     #54 0x5565dc3a554d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
Jun 05 03:14:01     #55 0x5565dc3ffa90 in slot_tp_call /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:6207
Jun 05 03:14:01     #56 0x5565dc3a592a in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2331
Jun 05 03:14:01     #57 0x5565dc42c57d in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4875
Jun 05 03:14:01     #58 0x5565dc451389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
Jun 05 03:14:01     #59 0x5565dc42653a in _PyFunction_FastCall /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
Jun 05 03:14:01     #60 0x5565dc42653a in fast_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4968
Jun 05 03:14:01     #61 0x5565dc42c504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
Jun 05 03:14:01     #62 0x5565dc451389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
Jun 05 03:14:01     #63 0x5565dc42653a in _PyFunction_FastCall /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
Jun 05 03:14:01     #64 0x5565dc42653a in fast_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4968
Jun 05 03:14:01     #65 0x5565dc42c504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
Jun 05 03:14:01     #66 0x5565dc451389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
Jun 05 03:14:01     #67 0x5565dc425d70 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
Jun 05 03:14:01     #68 0x5565dc426e69 in _PyFunction_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:5084
Jun 05 03:14:01     #69 0x5565dc3a5b0e in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2310
Jun 05 03:14:01     #70 0x5565dc3aa6a2 in _PyObject_Call_Prepend /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2373
Jun 05 03:14:01     #71 0x5565dc3a554d in PyObject_Call /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2261
Jun 05 03:14:01     #72 0x5565dc3ff0fa in slot_tp_init /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:6420
Jun 05 03:14:01     #73 0x5565dc42c766 in type_call /tmp/build/80754af9/python_1546130271559/work/Objects/typeobject.c:915
Jun 05 03:14:01     #74 0x5565dc3a592a in _PyObject_FastCallDict /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2331
Jun 05 03:14:01     #75 0x5565dc426a59 in _PyObject_FastCallKeywords /tmp/build/80754af9/python_1546130271559/work/Objects/abstract.c:2496
Jun 05 03:14:01     #76 0x5565dc42c57d in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4875
Jun 05 03:14:01     #77 0x5565dc452146 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3351
Jun 05 03:14:01     #78 0x5565dc3d422a in _PyFunction_FastCall /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4933
Jun 05 03:14:01     #79 0x5565dc42c504 in call_function /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4872
Jun 05 03:14:01     #80 0x5565dc451389 in _PyEval_EvalFrameDefault /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:3335
Jun 05 03:14:01     #81 0x5565dc427288 in _PyEval_EvalCodeWithName /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4166
Jun 05 03:14:01     #82 0x5565dc427288 in PyEval_EvalCodeEx /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:4187
Jun 05 03:14:01     #83 0x5565dc42801b in PyEval_EvalCode /tmp/build/80754af9/python_1546130271559/work/Python/ceval.c:731
Jun 05 03:14:01     #84 0x5565dc4aa3c3 in run_mod /tmp/build/80754af9/python_1546130271559/work/Python/pythonrun.c:1025
Jun 05 03:14:01     #85 0x5565dc4aa7c0 in PyRun_FileExFlags /tmp/build/80754af9/python_1546130271559/work/Python/pythonrun.c:978
Jun 05 03:14:01     #86 0x5565dc4aa9c2 in PyRun_SimpleFileExFlags /tmp/build/80754af9/python_1546130271559/work/Python/pythonrun.c:419
Jun 05 03:14:01     #87 0x5565dc4ae4b2 in run_file /tmp/build/80754af9/python_1546130271559/work/Modules/main.c:340
Jun 05 03:14:01     #88 0x5565dc4ae4b2 in Py_Main /tmp/build/80754af9/python_1546130271559/work/Modules/main.c:811
Jun 05 03:14:01     #89 0x5565dc37702d in main /tmp/build/80754af9/python_1546130271559/work/Programs/python.c:69
Jun 05 03:14:01     #90 0x7fbcc3d5282f in __libc_start_main /build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:291
Jun 05 03:14:01     #91 0x5565dc457e0d in _start /home/rdonnelly/mc/conda-bld/compilers_linux-64_1534865402226/work/.build/src/glibc-2.12.2/csu/../sysdeps/x86_64/elf/start.S:103
Jun 05 03:14:01 
Jun 05 03:14:01 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /var/lib/jenkins/workspace/aten/src/ATen/core/LegacyTypeDispatch.h:86:70 in 

type_registry[static_cast<int>(b)] = std::move(t);
detail::getVariableHooks().registerVariableTypeFor(this, b);
}
private:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why'd this become public?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I'm calling this directly from Functions.h for all factory functions.

}
}

// example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's blocking removing Type.h entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few functions like unsafeTensorFromTH are still on Type and haven't found a new home yet.

}

Tensor & VariableType::detach_(Tensor & self) const {
Tensor & VariableType::detach_(Tensor & (*_op)(Tensor &), Tensor & self) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty weird, especially since you never actually call _op here. Are you sure this is the pattern you want for "Variable-only" operations?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine.

template<class FuncType>
ATenDispatch& registerOp(Backend backend, const char* schema, FuncType* fn) {
auto id = getSchemaId(schema);
function_table[static_cast<int64_t>(backend)][id] = reinterpret_cast<void*>(fn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need a reinterpret_cast to cast a pointer into a void pointer. (It's only needed the other way.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... no error checking, I guess?


if (is_variable) {
if (wrapper_table[id] == nullptr) {
AT_ERROR("No autograd wrapper is registered for ", name, ". Please report a bug to PyTorch.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is really a bug you should use TORCH_INTERNAL_ASSERT

int64_t getSchemaId(std::string schema) {
static std::unordered_map<std::string, int64_t> schema_to_id = {
${schema_to_id_pairs}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zdevito Do you know if a static variable like this takes a long time to compile? Also even though this isn't perf sensitive code, we should really avoid using std::unordered_map

Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
@li-roy li-roy requested review from dzhulgakov, ezyang and smessmer June 14, 2019 10:25
class CAFFE2_API ATenOpTable {
public:
ATenOpTable(std::string schema)
: schema_(schema) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: std::move(schema)

}
private:
void registerOp(Backend backend, void* fn) {
TORCH_CHECK(function_table_[static_cast<int64_t>(backend)] == nullptr,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internal asserts here? (I guess if you're going to expose directly to extensions an internal assert is not appropriate, but for internal use, this isn't a public API right)

Copy link
Contributor

@ezyang ezyang Jun 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no type checking in the registration API right now; as long as we don't have any type checking I have a pretty strong preference of NOT allowing external parties to poke this API. I don't know what the situation is with XLA and this diff at the moment. (The reason for this preference is that if XLA uses this directly, and we start changing the types of functions, they'll start segfaulting. Ick!)

void* getBaseOp(Backend backend) const {
if (function_table_[static_cast<int64_t>(backend)] == nullptr) {
TORCH_CHECK(function_table_[static_cast<int64_t>(Backend::Undefined)] != nullptr,
"No function is registered for schema ", schema_, " on backend ", toString(backend));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re error message: not only is no function not registered, but there is no undefined implementation registered either.

Actually, why are we dispatching to Undefined at all, at this point? Can't we just error out straight up at this point?


namespace at {

ATenDispatch & globalATenDispatch() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registering to the global table is not thread safe, right? Gotta be careful: library loads can happen in different threads.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to block landing this on account of lack of type checking, but if XLA is going to use this interface I would be veeeeery careful. But I don't know what the XLA plan is at the moment.

@dlibenzi
Copy link
Contributor

The current path to XLA is that there is an include file generated, which provides a matching between C++ signature, and the magic-string pytorch generates for table based registrations.
We then match our C++ signature with the C++ one in that file.
As long as pytorch does not allow us to register string signatures which are not known to it, it should be fine.

royboy added 4 commits June 18, 2019 09:52
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
royboy added 3 commits June 19, 2019 08:11
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
Replace Type dispatch with ATenDispatch

gh-metadata: pytorch pytorch 21320 gh/li-roy/25/head
@zou3519 zou3519 deleted the gh/li-roy/25/head branch June 19, 2019 22:49
zdevito pushed a commit to zdevito/ATen that referenced this pull request Jun 20, 2019
Summary:
Pull Request resolved: pytorch/pytorch#21320
ghimport-source-id: cc18f746a1c74df858cb0f6d8b7d4de4315683c7

Test Plan: Imported from OSS

Differential Revision: D15637222

Pulled By: li-roy

fbshipit-source-id: fcfaea0b5480ab966175341cce92e3aa0be7e3cb
@facebook-github-bot
Copy link
Contributor

@li-roy merged this pull request in 24a6c32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: autograd Related to torch.autograd, and the autograd engine in general module: cpp-extensions Related to torch.utils.cpp_extension module: internals Related to internal abstractions in c10 and ATen

Projects

None yet

Development

Successfully merging this pull request may close these issues.