With the PyTorch 1.2, I have noticed that any alias specification when registering an operator would cause a crash (tried on Win64).
So I had to change
"some_op(Tensor(a) t) -> Tensor(a)"
to
"some_op(Tensor t) -> Tensor"
to make it work again.
Is there an alternative?
Do you have a minimal code example reproducing the crash? And what is the error message you’re seeing exactly?
The error message is simply:
OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed
I have created a repo for it:
https://github.com/leowalkling/pytorch_register_op_minimal
I’m using scikit-build to easily generate a solution file but the compilation flags are taken from torch.utils.cpp_extension
.
I found out, that in PyTorch 1.2, the default behavior is not to allow alias specifications, leading to a segfault.
This can be changed, but alias specifications are not allowed for third-party extensions as stated in the error message:
RuntimeError: node->kind().is_prim() || node->kind().is_aten() INTERNAL ASSERT FAILED at ..\torch\csrc\jit\passes\alias_analysis.cpp:392, please report a bug to PyTorch. The current code base should only have AliasAnalysisKind::FROM_SCHEMA for aten:: and prim:: ops but we found it for tp::broadcast_tensors. We want to open this up though. (analyzeImpl at ..\torch\csrc\jit\passes\alias_analysis.cpp:392)
(no backtrace available)
To get this error message, I passed an Options struct as a third (optional) argument to RegisterOperators.op(), i.e.:
torch::RegisterOperators()
.op(
"some_op(Tensor(a) t) -> Tensor(a)",
&some_op,
torch::RegisterOperators::options().aliasAnalysis(c10::AliasAnalysisKind::FROM_SCHEMA))