-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Closed
Labels
oncall: jitAdd this issue/PR to JIT oncall triage queueAdd this issue/PR to JIT oncall triage queue
Description
🐛 Bug
The following script doesn't work
@torch.jit.script
def b(x: Optional[Tuple[int, int]] = None):
if x is None:
x = (1, 2)
else:
x = torch.jit._unwrap_optional(x)
return x
But this works
@torch.jit.script
def b(x: Optional[int] = None):
if x is None:
x = 1
else:
x = torch.jit._unwrap_optional(x)
return x
I'm using torch.jit._unwrap_optional because the implicit optional unwrapper not working
Or this feature is not ready to be used yet?
To Reproduce
Steps to reproduce the behavior:
- Run the script above is enough to reproduce
Expected behavior
Running b with parameter such as b((1, 2)) leads to the following error
offset < args.size() ASSERT FAILED at /Users/soumith/mc3build/conda-bld/pytorch_1549593514549/work/torch/csrc/jit/argument_spec.h:99, please report a bug to PyTorch. (addInput at /Users/soumith/mc3build/conda-bld/pytorch_1549593514549/work/torch/csrc/jit/argument_spec.h:99)
frame #0: c10::Error::Error(c10::SourceLocation, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 64 (0x10d3ddff0 in libc10.dylib)
frame #1: torch::jit::ArgumentSpec::addInput(c10::IValue const&, unsigned long&, bool) + 1100 (0x115e1df9c in libtorch.1.dylib)
frame #2: torch::jit::ArgumentSpec::addInput(c10::IValue const&, unsigned long&, bool) + 401 (0x115e1dce1 in libtorch.1.dylib)
frame #3: torch::jit::ArgumentSpec::ArgumentSpec(bool, c10::ArrayRef<c10::IValue>, unsigned long) + 145 (0x115e1da01 in libtorch.1.dylib)
frame #4: torch::jit::GraphExecutorImpl::run(std::__1::vector<c10::IValue, std::__1::allocator<c10::IValue> >&) + 184 (0x115e145d8 in libtorch.1.dylib)
frame #5: torch::jit::script::Method::run(std::__1::vector<c10::IValue, std::__1::allocator<c10::IValue> >&) + 216 (0x109a6d908 in libtorch_python.dylib)
frame #6: torch::jit::invokeScriptMethodFromPython(torch::jit::script::Method&, torch::jit::tuple_slice, pybind11::kwargs) + 163 (0x109a6d773 in libtorch_python.dylib)
frame #7: void pybind11::cpp_function::initialize<torch::jit::script::initJitScriptBindings(_object*)::$_17, pybind11::object, pybind11::args, pybind11::kwargs, pybind11::name, pybind11::is_method, pybind11::sibling>(torch::jit::script::initJitScriptBindings(_object*)::$_17&&, pybind11::object (*)(pybind11::args, pybind11::kwargs), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::'lambda'(pybind11::detail::function_call&)::__invoke(pybind11::detail::function_call&) + 342 (0x109a6d3f6 in libtorch_python.dylib)
frame #8: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) + 3482 (0x1096b55fa in libtorch_python.dylib)
<omitting python frames>
But without parameter like b(), it runs fine.
The expected output of b((1, 2)) should be the same as b() (different in value but the same in type).
Environment
Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).
You can get the script and run it with:
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
- PyTorch Version (e.g., 1.0): 1.0.1.post2
- OS (e.g., Linux): Mac OSX Mojave
- How you installed PyTorch (
conda,pip, source): conda - Build command you used (if compiling from source):
- Python version: 3.6.7
- CUDA/cuDNN version:
- GPU models and configuration:
- Any other relevant information:
Additional context
Metadata
Metadata
Assignees
Labels
oncall: jitAdd this issue/PR to JIT oncall triage queueAdd this issue/PR to JIT oncall triage queue