Open nikitaved opened 2 years ago
When the codegen sees this (from your PR https://github.com/pytorch/pytorch/pull/79201):
dispatch:
CPU, CUDA: foo
It interprets it as "there is a single at::native::foo
kernel, that can be re-used by both the CPU and CUDA backend".
Although in your PR it looks like you defined at::native::foo
twice, once in a cpp file and again in a cu file. I think I'd expect you to get a duplicate definition error? (But it sounds like you're not getting that, which seems strange)
Right, it compiles perfectly. And there are functions that have CPU, CUDA
dispatches specified in a single line with the same name. angle
, for example.
Perhaps no duplicate symbol error because the defs go in separate libraries and then get hidden visibility. Not sure if we can actually fix this.
Can't you have a static build in CI to trigger the duplicate symbol error?
I guess... not sure if the CI team would want to maintain it though
🐛 Describe the bug
It is possible to confuse device dispatcher to choose wrong path when device dispatches are specified in a single line in
native_functions.yaml
.To reproduce checkout the code from https://github.com/pytorch/pytorch/pull/79201 at https://github.com/pytorch/pytorch/pull/79201/commits/d03cfcfa406a75a5bcd11e0f6adeaa461b338e07. Then
When dispatch keys are on separate lines, line in https://github.com/pytorch/pytorch/pull/79201/commits/9caf9267ecc5e56444cd1ad380a783b30159ee22, everything is fine.
Versions
cc @malfet @seemethere @ezyang @bhosmer @bdhirsh