Runtime Error: Decorator script does not work dynamically compiled function
维护者通常 4 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- numpy, python
调研方向
从 onnxscript/_internal/ast_utils.py 和 onnxscript/main.py 开始,重点关注 get_src_and_ast 以及为 conv 抛出错误的装饰器路径。在 PyCharm 的动态编译控制台和 .venv 中重现该示例,然后确定装饰器是否能够支持该执行上下文;当支持的行为或限制得到明确确定,并由适当的测试或文档覆盖时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
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?
import numpy as np
import onnx
import onnxruntime
import pandas as pd
from onnxscript import FLOAT
from onnxscript import opset20 as op
x = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13])
y = np.array(x[len(x) - 3: len(x)], dtype=np.float32)
z = np.array(x[len(x)-8: len(x)-3], dtype=np.float32)
x_coef = np.array([1.1, 1.5, 1.7, 1.9, 1.2, 3.1, 4.5, 5.2, 8.5, 9.0, 11.0]
y_coef = np.array([8.5, 9.0, 11.0])
z_coef = np.array([5,7,9,9,10,11])
t1 = len(x)
t2 = len(y)
t3 = len(z)
const_term = 2.37698
h1 = 1.5689
h2 = 1.799
@script()
def conv(a1: FLOAT, a2: FLOAT, a3: FLOAT, a4: FLOAT, a5: FLOAT) -> FLOAT:
const = op.Constant(value_float=const_term)
# Define constants
coeff1 = op.Constant(value_float=h1)
coeff2 = op.Constant(value_float=h2)
s = coeff1 * a1 + coeff2 * a2 - const
for inx in range(t1):
if a4 == x[inx]:
s = s + x_coef[inx]
for inx2 in range(t2):
if a5 == y[inx2]:
s = s + y_coef[inx2]
for inx3 in range(t3):
if a6 == z[inx3]:
s = s + z_coef[inx3]
return op.Exp(s)
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.
- 主要语言
- Python
- 星标
- 457
- 派生
- 149
- 平均合并
- 3 天 20 小时
- 30 天内合并 PR
- 22
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/onnxscript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/onnxscript#3155 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/onnxscript#3003 · 3 条评论 ·
维护者通常 4 天内回复
-
CI : Pin github actions to full commit SHA可能已有人在做 @Aniketsy 于 184 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/onnxscript#2903 · 6 条评论 ·
维护者通常 4 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
microsoft/onnxscript#3156 ·
维护者通常 4 天内回复
-
难度 4/5 3-5 天 新手友好度 68/100
microsoft/onnxscript#3154 ·
维护者通常 4 天内回复
查看 microsoft/onnxscript 的全部 Issue
相似的 Issue
-
Server mode OAuth2: 'NoneType' object is not subscriptable on every request after re-submitting the OAuth2 login while already logged in可能已有人在做 @Rarasinhoo 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
pgadmin-org/pgadmin4#10733 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
aws-samples/sample-per-model-bedrock#752 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
int-brain-lab/mpci#32 ·
-
area:docs priority:p2 type:docs
难度 2/5 1-3 小时 新手友好度 78/100
jejjohnson/geostack#120 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
sublimelsp/LSP-vue#203 · 1 个 reaction ·
维护者通常 1 天内回复