Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a1d07eb8
提交
a1d07eb8
authored
9月 29, 2025
作者:
Virgile Andreani
提交者:
Ricardo Vieira
10月 07, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove npy<2 compatibility for NPY_RAVEL_AXIS value
上级
05f69852
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
13 行增加
和
17 行删除
+13
-17
npy_2_compat.py
pytensor/npy_2_compat.py
+0
-8
extra_ops.py
pytensor/tensor/extra_ops.py
+3
-7
math.py
pytensor/tensor/math.py
+2
-2
utils.py
pytensor/utils.py
+8
-0
没有找到文件。
pytensor/npy_2_compat.py
浏览文件 @
a1d07eb8
...
@@ -16,14 +16,6 @@ else:
...
@@ -16,14 +16,6 @@ else:
ndarray_c_version
=
np
.
core
.
_multiarray_umath
.
_get_ndarray_c_version
()
# type: ignore[attr-defined]
ndarray_c_version
=
np
.
core
.
_multiarray_umath
.
_get_ndarray_c_version
()
# type: ignore[attr-defined]
# to patch up some of the C code, we need to use these special values...
if
using_numpy_2
:
numpy_axis_is_none_flag
=
np
.
iinfo
(
np
.
int32
)
.
min
# the value of "NPY_RAVEL_AXIS"
else
:
# 32 is the value used to mark axis = None in Numpy C-API prior to version 2.0
numpy_axis_is_none_flag
=
32
# function that replicates np.unique from numpy < 2.0
# function that replicates np.unique from numpy < 2.0
def
old_np_unique
(
def
old_np_unique
(
arr
,
return_index
=
False
,
return_inverse
=
False
,
return_counts
=
False
,
axis
=
None
arr
,
return_index
=
False
,
return_inverse
=
False
,
return_counts
=
False
,
axis
=
None
...
...
pytensor/tensor/extra_ops.py
浏览文件 @
a1d07eb8
...
@@ -18,11 +18,7 @@ from pytensor.graph.replace import _vectorize_node
...
@@ -18,11 +18,7 @@ from pytensor.graph.replace import _vectorize_node
from
pytensor.link.c.op
import
COp
from
pytensor.link.c.op
import
COp
from
pytensor.link.c.params_type
import
ParamsType
from
pytensor.link.c.params_type
import
ParamsType
from
pytensor.link.c.type
import
EnumList
,
Generic
from
pytensor.link.c.type
import
EnumList
,
Generic
from
pytensor.npy_2_compat
import
(
from
pytensor.npy_2_compat
import
npy_2_compat_header
,
old_np_unique
npy_2_compat_header
,
numpy_axis_is_none_flag
,
old_np_unique
,
)
from
pytensor.raise_op
import
Assert
from
pytensor.raise_op
import
Assert
from
pytensor.scalar
import
int64
as
int_t
from
pytensor.scalar
import
int64
as
int_t
from
pytensor.scalar
import
upcast
from
pytensor.scalar
import
upcast
...
@@ -51,7 +47,7 @@ from pytensor.tensor.subtensor import advanced_inc_subtensor1, set_subtensor
...
@@ -51,7 +47,7 @@ from pytensor.tensor.subtensor import advanced_inc_subtensor1, set_subtensor
from
pytensor.tensor.type
import
TensorType
,
dvector
,
int_dtypes
,
integer_dtypes
,
vector
from
pytensor.tensor.type
import
TensorType
,
dvector
,
int_dtypes
,
integer_dtypes
,
vector
from
pytensor.tensor.utils
import
normalize_reduce_axis
from
pytensor.tensor.utils
import
normalize_reduce_axis
from
pytensor.tensor.variable
import
TensorVariable
from
pytensor.tensor.variable
import
TensorVariable
from
pytensor.utils
import
LOCAL_BITWIDTH
,
PYTHON_INT_BITWIDTH
from
pytensor.utils
import
LOCAL_BITWIDTH
,
NPY_RAVEL_AXIS
,
PYTHON_INT_BITWIDTH
class
CpuContiguous
(
COp
):
class
CpuContiguous
(
COp
):
...
@@ -308,7 +304,7 @@ class CumOp(COp):
...
@@ -308,7 +304,7 @@ class CumOp(COp):
@property
@property
def
c_axis
(
self
)
->
int
:
def
c_axis
(
self
)
->
int
:
if
self
.
axis
is
None
:
if
self
.
axis
is
None
:
return
numpy_axis_is_none_flag
return
NPY_RAVEL_AXIS
return
self
.
axis
return
self
.
axis
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
...
...
pytensor/tensor/math.py
浏览文件 @
a1d07eb8
...
@@ -14,7 +14,7 @@ from pytensor.graph.op import Op
...
@@ -14,7 +14,7 @@ from pytensor.graph.op import Op
from
pytensor.graph.replace
import
_vectorize_node
from
pytensor.graph.replace
import
_vectorize_node
from
pytensor.link.c.op
import
COp
from
pytensor.link.c.op
import
COp
from
pytensor.link.c.params_type
import
ParamsType
from
pytensor.link.c.params_type
import
ParamsType
from
pytensor.npy_2_compat
import
npy_2_compat_header
,
numpy_axis_is_none_flag
from
pytensor.npy_2_compat
import
npy_2_compat_header
from
pytensor.printing
import
pprint
from
pytensor.printing
import
pprint
from
pytensor.raise_op
import
Assert
from
pytensor.raise_op
import
Assert
from
pytensor.scalar.basic
import
BinaryScalarOp
from
pytensor.scalar.basic
import
BinaryScalarOp
...
@@ -162,7 +162,7 @@ class Argmax(COp):
...
@@ -162,7 +162,7 @@ class Argmax(COp):
c_axis
=
np
.
int64
(
self
.
axis
[
0
])
c_axis
=
np
.
int64
(
self
.
axis
[
0
])
else
:
else
:
# The value here doesn't matter, it won't be used
# The value here doesn't matter, it won't be used
c_axis
=
numpy_axis_is_none_flag
c_axis
=
0
return
self
.
params_type
.
get_params
(
c_axis
=
c_axis
)
return
self
.
params_type
.
get_params
(
c_axis
=
c_axis
)
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
...
...
pytensor/utils.py
浏览文件 @
a1d07eb8
...
@@ -10,6 +10,8 @@ from collections.abc import Iterable, Sequence
...
@@ -10,6 +10,8 @@ from collections.abc import Iterable, Sequence
from
functools
import
partial
from
functools
import
partial
from
pathlib
import
Path
from
pathlib
import
Path
import
numpy
as
np
__all__
=
[
__all__
=
[
"get_unbound_function"
,
"get_unbound_function"
,
...
@@ -19,6 +21,7 @@ __all__ = [
...
@@ -19,6 +21,7 @@ __all__ = [
"output_subprocess_Popen"
,
"output_subprocess_Popen"
,
"LOCAL_BITWIDTH"
,
"LOCAL_BITWIDTH"
,
"PYTHON_INT_BITWIDTH"
,
"PYTHON_INT_BITWIDTH"
,
"NPY_RAVEL_AXIS"
,
"NoDuplicateOptWarningFilter"
,
"NoDuplicateOptWarningFilter"
,
]
]
...
@@ -46,6 +49,11 @@ Note that it can be different from the size of a memory pointer.
...
@@ -46,6 +49,11 @@ Note that it can be different from the size of a memory pointer.
'l' denotes a C long int, and the size is expressed in bytes.
'l' denotes a C long int, and the size is expressed in bytes.
"""
"""
NPY_RAVEL_AXIS
=
np
.
iinfo
(
np
.
int32
)
.
min
"""
The value of the numpy C API NPY_RAVEL_AXIS.
"""
def
__call_excepthooks
(
type
,
value
,
trace
):
def
__call_excepthooks
(
type
,
value
,
trace
):
"""
"""
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论