-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime Error: Decorator script does not work dynamically compiled function #1969
Comments
@justinchuby @gramalingam @xadupre @titaiwangms Could either of you please help take a look at this problem? |
x, x_coef, ... appear to be global variables. That's not allowed. They should become inputs or constant declared in the function body. |
@xadupre Thank you very much for your quick reply. I tried both ways but the same error still appeared. I am not sure if the actual cause is because the @script() decorator was placed inside another function (e.g.
|
I created PR #1970. I fixed your example to make it work. The conversion to onnx works with the main branch. I suggest you install onnxscript from github. I fixed a bug when your function is called in eager mode. onnxscript is very strict about types. In your example, x = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13]) # missing: , dtype=np.float32 |
@xadupre Thank you very much for your input. Regarding the installation of onnxscript: I used Pycharm as my IDE, and I install onnxscript via
But when I tried the same script in another environment except the version of From that same environment with the same script above with Also, the |
I used onnxscript from github, main branch. I did not check mypy. That's another topic. About opsml? I need more details. Onnxscript==1.17, you mean onnx? I don't how it is used in opset but i don't see why a more recent version would not work. |
@xadupre Thank you very much. I guess the topic related to When I looked over the problem that I encountered, it was a bit different from the above: the above script worked well when I put it into a new fresh environment in Pycharm, while it did not work when I put it into an existing environment (even when all the package versions of |
@xadupre I hope your weekend went great! I'm sorry for having to touch base with you again. Just wonder if you have any idea on the root cause of the issue I described in the previous comment? I noticed that the |
Would it be possible to run the command line from the the terminal and not inside PyCharm? Sometimes, those editors run your script from another script to intercept the standard output and it may alter the filenames. |
A quick response: I haven't had a chance to look into the details yet. But I remember not being able to use the script decorator in a REPL interpreter. The onnxscript translator needs the source, and it can't get it (as the above error messages imply). You could try putting the script function inside a python file and importing it. (Not sure about your IDE however) |
Hi everyone, I get the Runtime Error when running the function below in Poetry environment with Python 3.11 and Pycharm IDE. I was able to run it successfully from Virtual Environment (the
.venv
). Can someone offer help on how to fix it?Error Message
Traceback (most recent call last):
File "[File_path]/lib/python3.11/site-packages/onnxscript/_internal/ast_utils.py", line 18, in get_src_and_ast
src = inspect.getsource(func)
^^^^^^^^^^^^^^^^^^^^^^^
File "[file_path]/.asdf/python/3.11.9/lib/python3.11/inspect.py", line 1258, in getsource
lines, lnum = getsourcelines(object)
^^^^^^^^^^^^^^^^^^^^^^
File "[file_path]/.asdf/installs/python/3.11.9/lib/python3.11/inspect.py", line 1240, in getsourcelines
lines, lnum = findsource(object)
^^^^^^^^^^^^^^^^^^
File "[file_path]/.asdf/installs/python/3.11.9/lib/python3.11/inspect.py", line 1077, in findsource
raise OSError('could not get source code')
OSError: could not get source code
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevconsole.py", line 364, in runcode
coro = func()
^^^^^^
File "", line 1, in
File "", line 67, in [module_name]
File "[path]/lib/python3.11/site-packages/onnxscript/main.py", line 82, in transform
src, f_ast = ast_utils.get_src_and_ast(f)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[path]/lib/python3.11/site-packages/onnxscript/_internal/ast_utils.py", line 20, in get_src_and_ast
raise RuntimeError(
RuntimeError: Decorator script does not work on dynamically compiled function conv.
The text was updated successfully, but these errors were encountered: