Improve compiler error messages of the op registration API (#18550)
authorSebastian Messmer <messmer@fb.com>
Tue, 2 Apr 2019 19:23:13 +0000 (12:23 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 2 Apr 2019 19:33:27 +0000 (12:33 -0700)
commit7a37e066e6d67ce6a79c9f80e00ec44fc90e2114
treeb0c7d2ca71c7cf5c13cf588518c82dac70fc404b
parentae1d13a06fc43688fcf79c8f04c437b8ac6b3f61
Improve compiler error messages of the op registration API (#18550)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18550

When the operator registration API is used wrongly, in most cases we should now get a nice compiler error
instead of weird template error messages.

This is done by making the enable_if conditions more broad so they also match error cases,
but then having static_asserts against these error cases inside the function.
Before that, since the function didn't match, the error message said something like "no function found to match your call",
now it will show the error message specified in the static_asserts.

Reviewed By: dzhulgakov

Differential Revision: D14659178

fbshipit-source-id: 7ca4fb72d9051eadf0a7e2717b962bf1213a52b2
aten/src/ATen/core/op_registration/kernel_function.h
aten/src/ATen/core/op_registration/kernel_functor.h
aten/src/ATen/core/op_registration/kernel_lambda.h
aten/src/ATen/core/op_registration/kernel_lambda_test.cpp
aten/src/ATen/core/op_registration/op_registration.h