Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a6b9585e
提交
a6b9585e
authored
7月 09, 2024
作者:
Virgile Andreani
提交者:
Virgile Andreani
7月 12, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use implicit string concatenation instead of explicit
上级
f75434f3
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
33 行增加
和
47 行删除
+33
-47
pyproject.toml
pyproject.toml
+2
-2
pytensor_cache.py
pytensor/bin/pytensor_cache.py
+1
-3
debugmode.py
pytensor/compile/debugmode.py
+9
-17
gradient.py
pytensor/gradient.py
+5
-5
db.py
pytensor/graph/rewriting/db.py
+4
-4
cmodule.py
pytensor/link/c/cmodule.py
+2
-6
utils.py
pytensor/link/utils.py
+2
-2
basic.py
pytensor/scalar/basic.py
+2
-2
basic.py
pytensor/sparse/basic.py
+2
-2
abstract_conv.py
pytensor/tensor/conv/abstract_conv.py
+1
-1
fft.py
pytensor/tensor/fft.py
+1
-1
test_blas_c.py
tests/tensor/test_blas_c.py
+2
-2
没有找到文件。
pyproject.toml
浏览文件 @
a6b9585e
...
@@ -125,8 +125,8 @@ line-length = 88
...
@@ -125,8 +125,8 @@ line-length = 88
exclude
=
[
"doc/"
,
"pytensor/_version.py"
]
exclude
=
[
"doc/"
,
"pytensor/_version.py"
]
[tool.ruff.lint]
[tool.ruff.lint]
select
=
[
"C"
,
"E"
,
"F"
,
"I"
,
"UP"
,
"W"
,
"RUF"
,
"PERF"
,
"PTH"
]
select
=
[
"C"
,
"E"
,
"F"
,
"I"
,
"UP"
,
"W"
,
"RUF"
,
"PERF"
,
"PTH"
,
"ISC"
]
ignore
=
[
"C408"
,
"C901"
,
"E501"
,
"E741"
,
"RUF012"
,
"PERF203"
]
ignore
=
[
"C408"
,
"C901"
,
"E501"
,
"E741"
,
"RUF012"
,
"PERF203"
,
"ISC001"
]
[tool.ruff.lint.isort]
[tool.ruff.lint.isort]
...
...
pytensor/bin/pytensor_cache.py
浏览文件 @
a6b9585e
...
@@ -30,9 +30,7 @@ def print_help(exit_status):
...
@@ -30,9 +30,7 @@ def print_help(exit_status):
print
(
'Type "pytensor-cache clear" to erase the cache'
)
print
(
'Type "pytensor-cache clear" to erase the cache'
)
print
(
'Type "pytensor-cache list" to print the cache content'
)
print
(
'Type "pytensor-cache list" to print the cache content'
)
print
(
'Type "pytensor-cache unlock" to unlock the cache directory'
)
print
(
'Type "pytensor-cache unlock" to unlock the cache directory'
)
print
(
print
(
'Type "pytensor-cache cleanup" to delete keys in the old format/code version'
)
'Type "pytensor-cache cleanup" to delete keys in the old '
"format/code version"
)
print
(
'Type "pytensor-cache purge" to force deletion of the cache directory'
)
print
(
'Type "pytensor-cache purge" to force deletion of the cache directory'
)
print
(
print
(
'Type "pytensor-cache basecompiledir" '
'Type "pytensor-cache basecompiledir" '
...
...
pytensor/compile/debugmode.py
浏览文件 @
a6b9585e
...
@@ -1614,14 +1614,10 @@ class _Linker(LocalLinker):
...
@@ -1614,14 +1614,10 @@ class _Linker(LocalLinker):
opt
=
str
(
reason
[
0
][
0
])
opt
=
str
(
reason
[
0
][
0
])
msg
=
(
msg
=
(
f
"An optimization (probably {opt}) inserted an "
f
"An optimization (probably {opt}) inserted an "
"apply node that raise an error."
"apply node that raise an error.
\n
"
+
"
\n
The information we have about this "
"The information we have about this optimization is:"
"optimizations is:"
f
"{reason[0][1]}
\n
{reason[0][2]}
\n
"
+
str
(
reason
[
0
][
1
])
f
"
\n
The original exception:
\n
{e}"
+
"
\n
"
+
reason
[
0
][
2
]
+
"
\n\n
The original exception:
\n
"
+
str
(
e
)
)
)
new_e
=
e
.
__class__
(
msg
)
new_e
=
e
.
__class__
(
msg
)
exc_type
,
exc_value
,
exc_trace
=
sys
.
exc_info
()
exc_type
,
exc_value
,
exc_trace
=
sys
.
exc_info
()
...
@@ -1725,15 +1721,11 @@ class _Linker(LocalLinker):
...
@@ -1725,15 +1721,11 @@ class _Linker(LocalLinker):
raise
raise
opt
=
str
(
reason
[
0
][
0
])
opt
=
str
(
reason
[
0
][
0
])
msg
=
(
msg
=
(
f
"An optimization (probably {opt}) inserted "
f
"An optimization (probably {opt}) inserted an "
"an apply node that raise an error."
"apply node that raise an error.
\n
"
+
"
\n
The information we have about this "
"The information we have about this optimization is:"
"optimizations is:"
f
"{reason[0][1]}
\n
{reason[0][2]}
\n
"
+
str
(
reason
[
0
][
1
])
f
"
\n
The original exception:
\n
{e}"
+
"
\n
"
+
reason
[
0
][
2
]
+
"
\n\n
The original exception:
\n
"
+
str
(
e
)
)
)
new_e
=
e
.
__class__
(
msg
)
new_e
=
e
.
__class__
(
msg
)
exc_type
,
exc_value
,
exc_trace
=
sys
.
exc_info
()
exc_type
,
exc_value
,
exc_trace
=
sys
.
exc_info
()
...
...
pytensor/gradient.py
浏览文件 @
a6b9585e
...
@@ -802,20 +802,20 @@ def _node_to_pattern(node):
...
@@ -802,20 +802,20 @@ def _node_to_pattern(node):
if
not
isinstance
(
connection_pattern
,
list
):
if
not
isinstance
(
connection_pattern
,
list
):
raise
TypeError
(
raise
TypeError
(
"Op.connection_pattern should return "
"Op.connection_pattern should return "
+
f
"list of list of bool, but for Op={node.op}"
f
"list of list of bool, but for Op={node.op}"
+
f
"got {connection_pattern} with type {type(connection_pattern)}."
f
"got {connection_pattern} with type {type(connection_pattern)}."
)
)
if
len
(
connection_pattern
)
!=
len
(
node
.
inputs
):
if
len
(
connection_pattern
)
!=
len
(
node
.
inputs
):
raise
ValueError
(
raise
ValueError
(
f
"{node.op}.connection_pattern should have {len(node.inputs)}"
f
"{node.op}.connection_pattern should have {len(node.inputs)}"
+
f
" rows but has {len(connection_pattern)}."
f
" rows but has {len(connection_pattern)}."
)
)
for
ii
,
output_pattern
in
enumerate
(
connection_pattern
):
for
ii
,
output_pattern
in
enumerate
(
connection_pattern
):
if
not
isinstance
(
output_pattern
,
list
):
if
not
isinstance
(
output_pattern
,
list
):
raise
TypeError
(
raise
TypeError
(
f
"{node.op}.connection_pattern should return"
f
"{node.op}.connection_pattern should return"
+
f
" a list of lists, but element {int(ii)}"
f
" a list of lists, but element {int(ii)}"
+
f
"is {output_pattern} of type {type(output_pattern)}."
f
"is {output_pattern} of type {type(output_pattern)}."
)
)
else
:
else
:
connection_pattern
=
[[
True
for
output
in
node
.
outputs
]
for
ipt
in
node
.
inputs
]
connection_pattern
=
[[
True
for
output
in
node
.
outputs
]
for
ipt
in
node
.
inputs
]
...
...
pytensor/graph/rewriting/db.py
浏览文件 @
a6b9585e
...
@@ -229,10 +229,10 @@ class RewriteDatabaseQuery:
...
@@ -229,10 +229,10 @@ class RewriteDatabaseQuery:
def
__str__
(
self
):
def
__str__
(
self
):
return
(
return
(
"RewriteDatabaseQuery("
"RewriteDatabaseQuery("
+
f
"inc={self.include},ex={self.exclude},"
f
"inc={self.include},ex={self.exclude},"
+
f
"require={self.require},subquery={self.subquery},"
f
"require={self.require},subquery={self.subquery},"
+
f
"position_cutoff={self.position_cutoff},"
f
"position_cutoff={self.position_cutoff},"
+
f
"extra_rewrites={self.extra_rewrites})"
f
"extra_rewrites={self.extra_rewrites})"
)
)
def
__setstate__
(
self
,
state
):
def
__setstate__
(
self
,
state
):
...
...
pytensor/link/c/cmodule.py
浏览文件 @
a6b9585e
...
@@ -1744,9 +1744,7 @@ def std_lib_dirs_and_libs() -> tuple[list[str], ...] | None:
...
@@ -1744,9 +1744,7 @@ def std_lib_dirs_and_libs() -> tuple[list[str], ...] | None:
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
libdir
,
f
)):
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
libdir
,
f
)):
print
(
print
(
"Your Python version is from Canopy. "
"Your Python version is from Canopy. "
+
"You need to install the package '"
f
"You need to install the package '{lib}' from Canopy package manager."
+
lib
+
"' from Canopy package manager."
)
)
libdirs
=
[
libdirs
=
[
# Used in older Canopy
# Used in older Canopy
...
@@ -1763,9 +1761,7 @@ def std_lib_dirs_and_libs() -> tuple[list[str], ...] | None:
...
@@ -1763,9 +1761,7 @@ def std_lib_dirs_and_libs() -> tuple[list[str], ...] | None:
):
):
print
(
print
(
"Your Python version is from Canopy. "
"Your Python version is from Canopy. "
+
"You need to install the package '"
f
"You need to install the package '{lib}' from Canopy package manager."
+
lib
+
"' from Canopy package manager."
)
)
python_lib_dirs
.
insert
(
0
,
libdir
)
python_lib_dirs
.
insert
(
0
,
libdir
)
std_lib_dirs_and_libs
.
data
=
[
libname
],
python_lib_dirs
std_lib_dirs_and_libs
.
data
=
[
libname
],
python_lib_dirs
...
...
pytensor/link/utils.py
浏览文件 @
a6b9585e
...
@@ -351,8 +351,8 @@ def raise_with_op(
...
@@ -351,8 +351,8 @@ def raise_with_op(
clients
=
[[
c
[
0
]
for
c
in
fgraph
.
clients
[
var
]]
for
var
in
node
.
outputs
]
clients
=
[[
c
[
0
]
for
c
in
fgraph
.
clients
[
var
]]
for
var
in
node
.
outputs
]
detailed_err_msg
+=
(
detailed_err_msg
+=
(
f
"Inputs shapes: {shapes}"
f
"Inputs shapes: {shapes}"
+
f
"
\n
Inputs strides: {strides}"
f
"
\n
Inputs strides: {strides}"
+
f
"
\n
Inputs values: {scalar_values}"
f
"
\n
Inputs values: {scalar_values}"
)
)
if
verbosity
==
"high"
:
if
verbosity
==
"high"
:
inpts
=
[
inpts
=
[
...
...
pytensor/scalar/basic.py
浏览文件 @
a6b9585e
...
@@ -1753,7 +1753,7 @@ class ScalarMaximum(BinaryScalarOp):
...
@@ -1753,7 +1753,7 @@ class ScalarMaximum(BinaryScalarOp):
if
any
(
i
.
type
in
complex_types
for
i
in
node
.
inputs
):
if
any
(
i
.
type
in
complex_types
for
i
in
node
.
inputs
):
raise
NotImplementedError
()
raise
NotImplementedError
()
# Test for both y>x and x>=y to detect NaN
# Test for both y>x and x>=y to detect NaN
return
f
"{z} = (({y})>({x})? ({y}): "
f
'
(({x})>=({y})? ({x}): nan("")));'
return
f
'{z} = (({y})>({x})? ({y}):
(({x})>=({y})? ({x}): nan("")));'
def
L_op
(
self
,
inputs
,
outputs
,
gout
):
def
L_op
(
self
,
inputs
,
outputs
,
gout
):
(
x
,
y
)
=
inputs
(
x
,
y
)
=
inputs
...
@@ -1795,7 +1795,7 @@ class ScalarMinimum(BinaryScalarOp):
...
@@ -1795,7 +1795,7 @@ class ScalarMinimum(BinaryScalarOp):
(
z
,)
=
outputs
(
z
,)
=
outputs
if
any
(
i
.
type
in
complex_types
for
i
in
node
.
inputs
):
if
any
(
i
.
type
in
complex_types
for
i
in
node
.
inputs
):
raise
NotImplementedError
()
raise
NotImplementedError
()
return
f
"{z} = (({y})<({x})? ({y}): "
f
'
(({x})<=({y})? ({x}): nan("")));'
return
f
'{z} = (({y})<({x})? ({y}):
(({x})<=({y})? ({x}): nan("")));'
def
L_op
(
self
,
inputs
,
outputs
,
gout
):
def
L_op
(
self
,
inputs
,
outputs
,
gout
):
(
x
,
y
)
=
inputs
(
x
,
y
)
=
inputs
...
...
pytensor/sparse/basic.py
浏览文件 @
a6b9585e
...
@@ -1382,8 +1382,8 @@ class GetItem2d(Op):
...
@@ -1382,8 +1382,8 @@ class GetItem2d(Op):
isinstance
(
ind
,
Variable
)
and
getattr
(
ind
,
"ndim"
,
-
1
)
==
0
isinstance
(
ind
,
Variable
)
and
getattr
(
ind
,
"ndim"
,
-
1
)
==
0
)
or
np
.
isscalar
(
ind
):
)
or
np
.
isscalar
(
ind
):
raise
NotImplementedError
(
raise
NotImplementedError
(
"PyTensor has no sparse vector"
"PyTensor has no sparse vector
.
"
+
"Use X[a:b, c:d], X[a:b, c:c+1] or X[a:b] instead."
"Use X[a:b, c:d], X[a:b, c:c+1] or X[a:b] instead."
)
)
else
:
else
:
raise
ValueError
(
raise
ValueError
(
...
...
pytensor/tensor/conv/abstract_conv.py
浏览文件 @
a6b9585e
...
@@ -2284,7 +2284,7 @@ class BaseAbstractConv(Op):
...
@@ -2284,7 +2284,7 @@ class BaseAbstractConv(Op):
"""
"""
if
mode
not
in
(
"valid"
,
"full"
):
if
mode
not
in
(
"valid"
,
"full"
):
raise
ValueError
(
raise
ValueError
(
f
"invalid mode {mode}, which must be either "
'
"valid" or "full"'
f
'invalid mode {mode}, which must be either
"valid" or "full"'
)
)
if
isinstance
(
dilation
,
int
):
if
isinstance
(
dilation
,
int
):
dilation
=
(
dilation
,)
*
self
.
convdim
dilation
=
(
dilation
,)
*
self
.
convdim
...
...
pytensor/tensor/fft.py
浏览文件 @
a6b9585e
...
@@ -80,7 +80,7 @@ class IRFFTOp(Op):
...
@@ -80,7 +80,7 @@ class IRFFTOp(Op):
if
a
.
ndim
<
3
:
if
a
.
ndim
<
3
:
raise
TypeError
(
raise
TypeError
(
f
"{self.__class__.__name__}: input must have dimension >= 3, with "
f
"{self.__class__.__name__}: input must have dimension >= 3, with "
+
"first dimension batches and last real/imag parts"
"first dimension batches and last real/imag parts"
)
)
if
s
is
None
:
if
s
is
None
:
...
...
tests/tensor/test_blas_c.py
浏览文件 @
a6b9585e
...
@@ -196,8 +196,8 @@ class TestCGemv(OptimizationTestMixin):
...
@@ -196,8 +196,8 @@ class TestCGemv(OptimizationTestMixin):
if
check_force_gemv_init
():
if
check_force_gemv_init
():
warn
(
warn
(
"WARNING: The current BLAS requires PyTensor to initialize"
"WARNING: The current BLAS requires PyTensor to initialize"
+
" memory for some GEMV calls which will result in a minor"
" memory for some GEMV calls which will result in a minor"
+
" degradation in performance for such calls."
" degradation in performance for such calls."
)
)
def
t_gemv1
(
self
,
m_shp
):
def
t_gemv1
(
self
,
m_shp
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论