Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
246714b6
提交
246714b6
authored
3月 25, 2025
作者:
ricardoV94
提交者:
Ricardo Vieira
4月 08, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug in Numba inplace vectorize code with multiple outputs
上级
477fbafb
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
25 行增加
和
3 行删除
+25
-3
vectorize_codegen.py
pytensor/link/numba/dispatch/vectorize_codegen.py
+1
-1
test_elemwise.py
tests/link/numba/test_elemwise.py
+24
-2
没有找到文件。
pytensor/link/numba/dispatch/vectorize_codegen.py
浏览文件 @
246714b6
...
...
@@ -265,7 +265,7 @@ def _vectorized(
ctx
.
nrt
.
incref
(
builder
,
sig
.
return_type
.
types
[
inplace_idx
],
outputs
[
inplace_idx
]
.
_get
_
value
(),
outputs
[
inplace_idx
]
.
_getvalue
(),
)
return
ctx
.
make_tuple
(
builder
,
sig
.
return_type
,
[
out
.
_getvalue
()
for
out
in
outputs
]
...
...
tests/link/numba/test_elemwise.py
浏览文件 @
246714b6
...
...
@@ -12,7 +12,7 @@ from pytensor import config, function
from
pytensor.compile
import
get_mode
from
pytensor.compile.ops
import
deep_copy_op
from
pytensor.gradient
import
grad
from
pytensor.scalar
import
float64
from
pytensor.scalar
import
Composite
,
float64
from
pytensor.tensor.elemwise
import
CAReduce
,
DimShuffle
,
Elemwise
from
pytensor.tensor.math
import
All
,
Any
,
Max
,
Min
,
Prod
,
ProdWithoutZeros
,
Sum
from
pytensor.tensor.special
import
LogSoftmax
,
Softmax
,
SoftmaxGrad
...
...
@@ -548,7 +548,7 @@ def test_Argmax(x, axes, exc):
)
def
test_elemwise_out_type
():
def
test_elemwise_
inplace_
out_type
():
# Create a graph with an elemwise
# Ravel failes if the elemwise output type is reported incorrectly
x
=
pt
.
matrix
()
...
...
@@ -563,6 +563,28 @@ def test_elemwise_out_type():
assert
func
(
x_val
)
.
shape
==
(
18
,)
def
test_elemwise_multiple_inplace_outs
():
x
=
pt
.
vector
()
y
=
pt
.
vector
()
x_
=
pt
.
scalar_from_tensor
(
x
[
0
])
y_
=
pt
.
scalar_from_tensor
(
y
[
0
])
out_
=
x_
+
1
,
y_
+
1
composite_op
=
Composite
([
x_
,
y_
],
out_
)
elemwise_op
=
Elemwise
(
composite_op
,
inplace_pattern
=
{
0
:
0
,
1
:
1
})
out
=
elemwise_op
(
x
,
y
)
fn
=
function
([
x
,
y
],
out
,
mode
=
"NUMBA"
,
accept_inplace
=
True
)
x_test
=
np
.
array
([
1
,
2
,
3
],
dtype
=
config
.
floatX
)
y_test
=
np
.
array
([
4
,
5
,
6
],
dtype
=
config
.
floatX
)
out1
,
out2
=
fn
(
x_test
,
y_test
)
assert
out1
is
x_test
assert
out2
is
y_test
np
.
testing
.
assert_allclose
(
out1
,
[
2
,
3
,
4
])
np
.
testing
.
assert_allclose
(
out2
,
[
5
,
6
,
7
])
def
test_scalar_loop
():
a
=
float64
(
"a"
)
scalar_loop
=
pytensor
.
scalar
.
ScalarLoop
([
a
],
[
a
+
a
])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论