Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e752fc3d
提交
e752fc3d
authored
8月 04, 2024
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
8月 21, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CAReduce loop reordering C-impl
上级
00a8a883
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
18 行增加
和
13 行删除
+18
-13
elemwise.py
pytensor/tensor/elemwise.py
+0
-0
elemwise_cgen.py
pytensor/tensor/elemwise_cgen.py
+0
-0
math.py
pytensor/tensor/math.py
+18
-13
没有找到文件。
pytensor/tensor/elemwise.py
浏览文件 @
e752fc3d
差异被折叠。
点击展开。
pytensor/tensor/elemwise_cgen.py
浏览文件 @
e752fc3d
差异被折叠。
点击展开。
pytensor/tensor/math.py
浏览文件 @
e752fc3d
import
builtins
import
builtins
import
warnings
import
warnings
from
collections.abc
import
Sequence
from
collections.abc
import
Sequence
from
textwrap
import
dedent
from
typing
import
TYPE_CHECKING
,
Optional
from
typing
import
TYPE_CHECKING
,
Optional
import
numpy
as
np
import
numpy
as
np
...
@@ -361,12 +362,14 @@ class FixedOpCAReduce(CAReduce):
...
@@ -361,12 +362,14 @@ class FixedOpCAReduce(CAReduce):
class
NonZeroDimsCAReduce
(
FixedOpCAReduce
):
class
NonZeroDimsCAReduce
(
FixedOpCAReduce
):
def
_c_all
(
self
,
node
,
name
,
inames
,
onames
,
sub
):
def
_c_all
(
self
,
node
,
name
,
input_names
,
output_names
,
sub
):
decl
,
checks
,
alloc
,
loop
,
end
=
super
()
.
_c_all
(
node
,
name
,
inames
,
onames
,
sub
)
setup
,
alloc
,
loop
,
cast
=
super
()
.
_c_all
(
node
,
name
,
input_names
,
output_names
,
sub
)
# We add an additional check for zero-sized dimensions (This seems like
# We add an additional check for zero-sized dimensions (This seems like
# something that could enabled in `elemwise_cgen.make_checks`.)
# something that could enabled in `elemwise_cgen.make_checks`.)
iname
=
inames
[
0
]
[
iname
]
=
input_names
axis
=
self
.
axis
axis
=
self
.
axis
if
axis
is
None
:
if
axis
is
None
:
...
@@ -378,17 +381,19 @@ class NonZeroDimsCAReduce(FixedOpCAReduce):
...
@@ -378,17 +381,19 @@ class NonZeroDimsCAReduce(FixedOpCAReduce):
pattern_
=
str
(
pattern
)[
1
:
-
1
]
pattern_
=
str
(
pattern
)[
1
:
-
1
]
decl
+=
f
"""int tosum[]={{{pattern_}}};"""
setup
=
f
"int tosum[]={{{pattern_}}};"
+
setup
alloc
+=
f
"""
alloc
+=
dedent
(
for(int i=0;i<PyArray_NDIM({iname});i++){{
f
"""
if(PyArray_DIMS({iname})[i]==0 && tosum[i]
){{
for(int i=0;i<PyArray_NDIM({iname});i++
){{
PyErr_Format(PyExc_ValueError,
if(PyArray_DIMS({iname})[i]==0 && tosum[i]){{
"Input of CAReduce{{{node.op.scalar_op}}} has zero-size on axis
%%
d",i);
PyErr_Format(PyExc_ValueError,
{sub["fail"]}
;
"Input of CAReduce{{{node.op.scalar_op}}} has zero-size on axis
%%
d",i)
;
}}
{sub["fail"]};
}}
}}
"""
}}
return
decl
,
checks
,
alloc
,
loop
,
end
"""
)
return
setup
,
alloc
,
loop
,
cast
class
Max
(
NonZeroDimsCAReduce
):
class
Max
(
NonZeroDimsCAReduce
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论