Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0145d609
提交
0145d609
authored
4月 05, 2024
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
2月 17, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changes for deprecations in numpy 2.0 C-API
- replace `->elsize` by `PyArray_ITEMSIZE` - don't use deprecated PyArray_MoveInto
上级
8f4d7b1f
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
69 行增加
和
69 行删除
+69
-69
basic.py
pytensor/sparse/basic.py
+10
-10
rewriting.py
pytensor/sparse/rewriting.py
+47
-47
blas.py
pytensor/tensor/blas.py
+7
-7
blas_headers.py
pytensor/tensor/blas_headers.py
+2
-2
test_debugmode.py
tests/compile/test_debugmode.py
+3
-3
没有找到文件。
pytensor/sparse/basic.py
浏览文件 @
0145d609
...
@@ -3610,7 +3610,7 @@ class StructuredDotGradCSC(COp):
...
@@ -3610,7 +3610,7 @@ class StructuredDotGradCSC(COp):
out
[
0
]
=
g_a_data
out
[
0
]
=
g_a_data
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
1
,)
return
(
2
,)
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
(
_indices
,
_indptr
,
_d
,
_g
)
=
inputs
(
_indices
,
_indptr
,
_d
,
_g
)
=
inputs
...
@@ -3647,11 +3647,11 @@ class StructuredDotGradCSC(COp):
...
@@ -3647,11 +3647,11 @@ class StructuredDotGradCSC(COp):
npy_intp nnz = PyArray_DIMS({_indices})[0];
npy_intp nnz = PyArray_DIMS({_indices})[0];
npy_intp N = PyArray_DIMS({_indptr})[0]-1; //TODO: error checking with this
npy_intp N = PyArray_DIMS({_indptr})[0]-1; //TODO: error checking with this
npy_intp Sindices = PyArray_STRIDES({_indices})[0]/PyArray_
DESCR({_indices})->elsize
;
npy_intp Sindices = PyArray_STRIDES({_indices})[0]/PyArray_
ITEMSIZE({_indices})
;
npy_intp Sindptr = PyArray_STRIDES({_indptr})[0]/PyArray_
DESCR({_indptr})->elsize
;
npy_intp Sindptr = PyArray_STRIDES({_indptr})[0]/PyArray_
ITEMSIZE({_indptr})
;
const npy_intp Sd1 = PyArray_STRIDES({_d})[1]/PyArray_
DESCR({_d})->elsize
;
const npy_intp Sd1 = PyArray_STRIDES({_d})[1]/PyArray_
ITEMSIZE({_d})
;
const npy_intp Sg1 = PyArray_STRIDES({_g})[1]/PyArray_
DESCR({_g})->elsize
;
const npy_intp Sg1 = PyArray_STRIDES({_g})[1]/PyArray_
ITEMSIZE({_g})
;
const npy_intp K = PyArray_DIMS({_d})[1];
const npy_intp K = PyArray_DIMS({_d})[1];
...
@@ -3744,7 +3744,7 @@ class StructuredDotGradCSR(COp):
...
@@ -3744,7 +3744,7 @@ class StructuredDotGradCSR(COp):
out
[
0
]
=
g_a_data
out
[
0
]
=
g_a_data
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
1
,)
return
(
2
,)
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
(
_indices
,
_indptr
,
_d
,
_g
)
=
inputs
(
_indices
,
_indptr
,
_d
,
_g
)
=
inputs
...
@@ -3782,11 +3782,11 @@ class StructuredDotGradCSR(COp):
...
@@ -3782,11 +3782,11 @@ class StructuredDotGradCSR(COp):
// extract number of rows
// extract number of rows
npy_intp N = PyArray_DIMS({_indptr})[0]-1; //TODO: error checking with this
npy_intp N = PyArray_DIMS({_indptr})[0]-1; //TODO: error checking with this
npy_intp Sindices = PyArray_STRIDES({_indices})[0]/PyArray_
DESCR({_indices})->elsize
;
npy_intp Sindices = PyArray_STRIDES({_indices})[0]/PyArray_
ITEMSIZE({_indices})
;
npy_intp Sindptr = PyArray_STRIDES({_indptr})[0]/PyArray_
DESCR({_indptr})->elsize
;
npy_intp Sindptr = PyArray_STRIDES({_indptr})[0]/PyArray_
ITEMSIZE({_indptr})
;
const npy_intp Sd1 = PyArray_STRIDES({_d})[1]/PyArray_
DESCR({_d})->elsize
;
const npy_intp Sd1 = PyArray_STRIDES({_d})[1]/PyArray_
ITEMSIZE({_d})
;
const npy_intp Sg1 = PyArray_STRIDES({_g})[1]/PyArray_
DESCR({_g})->elsize
;
const npy_intp Sg1 = PyArray_STRIDES({_g})[1]/PyArray_
ITEMSIZE({_g})
;
const npy_intp K = PyArray_DIMS({_d})[1];
const npy_intp K = PyArray_DIMS({_d})[1];
...
...
pytensor/sparse/rewriting.py
浏览文件 @
0145d609
...
@@ -158,8 +158,8 @@ class AddSD_ccode(_NoPythonCOp):
...
@@ -158,8 +158,8 @@ class AddSD_ccode(_NoPythonCOp):
dtype_{y}* ydata = (dtype_{y}*)PyArray_DATA({y});
dtype_{y}* ydata = (dtype_{y}*)PyArray_DATA({y});
dtype_{z}* zdata = (dtype_{z}*)PyArray_DATA({z});
dtype_{z}* zdata = (dtype_{z}*)PyArray_DATA({z});
npy_intp Yi = PyArray_STRIDES({y})[0]/PyArray_
DESCR({y})->elsize
;
npy_intp Yi = PyArray_STRIDES({y})[0]/PyArray_
ITEMSIZE({y})
;
npy_intp Yj = PyArray_STRIDES({y})[1]/PyArray_
DESCR({y})->elsize
;
npy_intp Yj = PyArray_STRIDES({y})[1]/PyArray_
ITEMSIZE({y})
;
npy_intp pos;
npy_intp pos;
if ({format} == 0){{
if ({format} == 0){{
...
@@ -186,7 +186,7 @@ class AddSD_ccode(_NoPythonCOp):
...
@@ -186,7 +186,7 @@ class AddSD_ccode(_NoPythonCOp):
return
[
shapes
[
3
]]
return
[
shapes
[
3
]]
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
2
,)
return
(
3
,)
@node_rewriter
([
sparse
.
AddSD
])
@node_rewriter
([
sparse
.
AddSD
])
...
@@ -361,13 +361,13 @@ class StructuredDotCSC(COp):
...
@@ -361,13 +361,13 @@ class StructuredDotCSC(COp):
{{PyErr_SetString(PyExc_NotImplementedError, "array too big (overflows int32 index)"); {fail};}}
{{PyErr_SetString(PyExc_NotImplementedError, "array too big (overflows int32 index)"); {fail};}}
// strides tell you how many bytes to skip to go to next column/row entry
// strides tell you how many bytes to skip to go to next column/row entry
npy_intp Szm = PyArray_STRIDES({z})[0] / PyArray_
DESCR({z})->elsize
;
npy_intp Szm = PyArray_STRIDES({z})[0] / PyArray_
ITEMSIZE({z})
;
npy_intp Szn = PyArray_STRIDES({z})[1] / PyArray_
DESCR({z})->elsize
;
npy_intp Szn = PyArray_STRIDES({z})[1] / PyArray_
ITEMSIZE({z})
;
//npy_intp Sbm = PyArray_STRIDES({b})[0] / PyArray_
DESCR({b})->elsize
;
//npy_intp Sbm = PyArray_STRIDES({b})[0] / PyArray_
ITEMSIZE({b})
;
npy_intp Sbn = PyArray_STRIDES({b})[1] / PyArray_
DESCR({b})->elsize
;
npy_intp Sbn = PyArray_STRIDES({b})[1] / PyArray_
ITEMSIZE({b})
;
npy_intp Sval = PyArray_STRIDES({a_val})[0] / PyArray_
DESCR({a_val})->elsize
;
npy_intp Sval = PyArray_STRIDES({a_val})[0] / PyArray_
ITEMSIZE({a_val})
;
npy_intp Sind = PyArray_STRIDES({a_ind})[0] / PyArray_
DESCR({a_ind})->elsize
;
npy_intp Sind = PyArray_STRIDES({a_ind})[0] / PyArray_
ITEMSIZE({a_ind})
;
npy_intp Sptr = PyArray_STRIDES({a_ptr})[0] / PyArray_
DESCR({a_ptr})->elsize
;
npy_intp Sptr = PyArray_STRIDES({a_ptr})[0] / PyArray_
ITEMSIZE({a_ptr})
;
// pointers to access actual data in the arrays passed as params.
// pointers to access actual data in the arrays passed as params.
dtype_{z}* __restrict__ Dz = (dtype_{z}*)PyArray_DATA({z});
dtype_{z}* __restrict__ Dz = (dtype_{z}*)PyArray_DATA({z});
...
@@ -436,7 +436,7 @@ class StructuredDotCSC(COp):
...
@@ -436,7 +436,7 @@ class StructuredDotCSC(COp):
return
rval
return
rval
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
3
,)
return
(
4
,)
sd_csc
=
StructuredDotCSC
()
sd_csc
=
StructuredDotCSC
()
...
@@ -555,13 +555,13 @@ class StructuredDotCSR(COp):
...
@@ -555,13 +555,13 @@ class StructuredDotCSR(COp):
{{PyErr_SetString(PyExc_NotImplementedError, "array too big (overflows int32 index)"); {fail};}}
{{PyErr_SetString(PyExc_NotImplementedError, "array too big (overflows int32 index)"); {fail};}}
// strides tell you how many bytes to skip to go to next column/row entry
// strides tell you how many bytes to skip to go to next column/row entry
npy_intp Szm = PyArray_STRIDES({z})[0] / PyArray_
DESCR({z})->elsize
;
npy_intp Szm = PyArray_STRIDES({z})[0] / PyArray_
ITEMSIZE({z})
;
npy_intp Szn = PyArray_STRIDES({z})[1] / PyArray_
DESCR({z})->elsize
;
npy_intp Szn = PyArray_STRIDES({z})[1] / PyArray_
ITEMSIZE({z})
;
npy_intp Sbm = PyArray_STRIDES({b})[0] / PyArray_
DESCR({b})->elsize
;
npy_intp Sbm = PyArray_STRIDES({b})[0] / PyArray_
ITEMSIZE({b})
;
npy_intp Sbn = PyArray_STRIDES({b})[1] / PyArray_
DESCR({b})->elsize
;
npy_intp Sbn = PyArray_STRIDES({b})[1] / PyArray_
ITEMSIZE({b})
;
npy_intp Sval = PyArray_STRIDES({a_val})[0] / PyArray_
DESCR({a_val})->elsize
;
npy_intp Sval = PyArray_STRIDES({a_val})[0] / PyArray_
ITEMSIZE({a_val})
;
npy_intp Sind = PyArray_STRIDES({a_ind})[0] / PyArray_
DESCR({a_ind})->elsize
;
npy_intp Sind = PyArray_STRIDES({a_ind})[0] / PyArray_
ITEMSIZE({a_ind})
;
npy_intp Sptr = PyArray_STRIDES({a_ptr})[0] / PyArray_
DESCR({a_ptr})->elsize
;
npy_intp Sptr = PyArray_STRIDES({a_ptr})[0] / PyArray_
ITEMSIZE({a_ptr})
;
// pointers to access actual data in the arrays passed as params.
// pointers to access actual data in the arrays passed as params.
dtype_{z}* __restrict__ Dz = (dtype_{z}*)PyArray_DATA({z});
dtype_{z}* __restrict__ Dz = (dtype_{z}*)PyArray_DATA({z});
...
@@ -614,7 +614,7 @@ class StructuredDotCSR(COp):
...
@@ -614,7 +614,7 @@ class StructuredDotCSR(COp):
"""
"""
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
2
,)
return
(
3
,)
sd_csr
=
StructuredDotCSR
()
sd_csr
=
StructuredDotCSR
()
...
@@ -845,12 +845,12 @@ class UsmmCscDense(_NoPythonCOp):
...
@@ -845,12 +845,12 @@ class UsmmCscDense(_NoPythonCOp):
const npy_int32 * __restrict__ Dptr = (npy_int32*)PyArray_DATA({x_ptr});
const npy_int32 * __restrict__ Dptr = (npy_int32*)PyArray_DATA({x_ptr});
const dtype_{alpha} alpha = ((dtype_{alpha}*)PyArray_DATA({alpha}))[0];
const dtype_{alpha} alpha = ((dtype_{alpha}*)PyArray_DATA({alpha}))[0];
npy_intp Sz = PyArray_STRIDES({z})[1] / PyArray_
DESCR({z})->elsize
;
npy_intp Sz = PyArray_STRIDES({z})[1] / PyArray_
ITEMSIZE({z})
;
npy_intp Szn = PyArray_STRIDES({zn})[1] / PyArray_
DESCR({zn})->elsize
;
npy_intp Szn = PyArray_STRIDES({zn})[1] / PyArray_
ITEMSIZE({zn})
;
npy_intp Sval = PyArray_STRIDES({x_val})[0] / PyArray_
DESCR({x_val})->elsize
;
npy_intp Sval = PyArray_STRIDES({x_val})[0] / PyArray_
ITEMSIZE({x_val})
;
npy_intp Sind = PyArray_STRIDES({x_ind})[0] / PyArray_
DESCR({x_ind})->elsize
;
npy_intp Sind = PyArray_STRIDES({x_ind})[0] / PyArray_
ITEMSIZE({x_ind})
;
npy_intp Sptr = PyArray_STRIDES({x_ptr})[0] / PyArray_
DESCR({x_ptr})->elsize
;
npy_intp Sptr = PyArray_STRIDES({x_ptr})[0] / PyArray_
ITEMSIZE({x_ptr})
;
npy_intp Sy = PyArray_STRIDES({y})[1] / PyArray_
DESCR({y})->elsize
;
npy_intp Sy = PyArray_STRIDES({y})[1] / PyArray_
ITEMSIZE({y})
;
// blas expects ints; convert here (rather than just making N etc ints) to avoid potential overflow in the negative-stride correction
// blas expects ints; convert here (rather than just making N etc ints) to avoid potential overflow in the negative-stride correction
if ((N > 0x7fffffffL)||(Sy > 0x7fffffffL)||(Szn > 0x7fffffffL)||(Sy < -0x7fffffffL)||(Szn < -0x7fffffffL))
if ((N > 0x7fffffffL)||(Sy > 0x7fffffffL)||(Szn > 0x7fffffffL)||(Sy < -0x7fffffffL)||(Szn < -0x7fffffffL))
...
@@ -896,7 +896,7 @@ class UsmmCscDense(_NoPythonCOp):
...
@@ -896,7 +896,7 @@ class UsmmCscDense(_NoPythonCOp):
return
rval
return
rval
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
3
,
blas
.
blas_header_version
())
return
(
4
,
blas
.
blas_header_version
())
usmm_csc_dense
=
UsmmCscDense
(
inplace
=
False
)
usmm_csc_dense
=
UsmmCscDense
(
inplace
=
False
)
...
@@ -1035,13 +1035,13 @@ class CSMGradC(_NoPythonCOp):
...
@@ -1035,13 +1035,13 @@ class CSMGradC(_NoPythonCOp):
npy_intp sp_dim = (M == a_dim_0)?a_dim_1:a_dim_0;
npy_intp sp_dim = (M == a_dim_0)?a_dim_1:a_dim_0;
// strides tell you how many bytes to skip to go to next column/row entry
// strides tell you how many bytes to skip to go to next column/row entry
npy_intp Sz = PyArray_STRIDES({z})[0] / PyArray_
DESCR({z})->elsize
;
npy_intp Sz = PyArray_STRIDES({z})[0] / PyArray_
ITEMSIZE({z})
;
npy_intp Sa_val = PyArray_STRIDES({a_val})[0] / PyArray_
DESCR({a_val})->elsize
;
npy_intp Sa_val = PyArray_STRIDES({a_val})[0] / PyArray_
ITEMSIZE({a_val})
;
npy_intp Sa_ind = PyArray_STRIDES({a_ind})[0] / PyArray_
DESCR({a_ind})->elsize
;
npy_intp Sa_ind = PyArray_STRIDES({a_ind})[0] / PyArray_
ITEMSIZE({a_ind})
;
npy_intp Sa_ptr = PyArray_STRIDES({a_ptr})[0] / PyArray_
DESCR({a_ptr})->elsize
;
npy_intp Sa_ptr = PyArray_STRIDES({a_ptr})[0] / PyArray_
ITEMSIZE({a_ptr})
;
npy_intp Sb_val = PyArray_STRIDES({b_val})[0] / PyArray_
DESCR({b_val})->elsize
;
npy_intp Sb_val = PyArray_STRIDES({b_val})[0] / PyArray_
ITEMSIZE({b_val})
;
npy_intp Sb_ind = PyArray_STRIDES({b_ind})[0] / PyArray_
DESCR({b_ind})->elsize
;
npy_intp Sb_ind = PyArray_STRIDES({b_ind})[0] / PyArray_
ITEMSIZE({b_ind})
;
npy_intp Sb_ptr = PyArray_STRIDES({b_ptr})[0] / PyArray_
DESCR({b_ptr})->elsize
;
npy_intp Sb_ptr = PyArray_STRIDES({b_ptr})[0] / PyArray_
ITEMSIZE({b_ptr})
;
// pointers to access actual data in the arrays passed as params.
// pointers to access actual data in the arrays passed as params.
dtype_{z}* __restrict__ Dz = (dtype_{z}*)PyArray_DATA({z});
dtype_{z}* __restrict__ Dz = (dtype_{z}*)PyArray_DATA({z});
...
@@ -1086,7 +1086,7 @@ class CSMGradC(_NoPythonCOp):
...
@@ -1086,7 +1086,7 @@ class CSMGradC(_NoPythonCOp):
"""
"""
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
3
,)
return
(
4
,)
csm_grad_c
=
CSMGradC
()
csm_grad_c
=
CSMGradC
()
...
@@ -1482,7 +1482,7 @@ class MulSVCSR(_NoPythonCOp):
...
@@ -1482,7 +1482,7 @@ class MulSVCSR(_NoPythonCOp):
)
)
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
2
,)
return
(
3
,)
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
(
(
...
@@ -1544,7 +1544,7 @@ class MulSVCSR(_NoPythonCOp):
...
@@ -1544,7 +1544,7 @@ class MulSVCSR(_NoPythonCOp):
dtype_{_zout} * const __restrict__ zout = (dtype_{_zout}*)PyArray_DATA({_zout});
dtype_{_zout} * const __restrict__ zout = (dtype_{_zout}*)PyArray_DATA({_zout});
const npy_intp Sb = PyArray_STRIDES({_b})[0] / PyArray_
DESCR({_b})->elsize
;
const npy_intp Sb = PyArray_STRIDES({_b})[0] / PyArray_
ITEMSIZE({_b})
;
// loop over rows
// loop over rows
for (npy_intp j = 0; j < N; ++j)
for (npy_intp j = 0; j < N; ++j)
...
@@ -1655,7 +1655,7 @@ class StructuredAddSVCSR(_NoPythonCOp):
...
@@ -1655,7 +1655,7 @@ class StructuredAddSVCSR(_NoPythonCOp):
)
)
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
3
,)
return
(
4
,)
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
(
(
...
@@ -1723,7 +1723,7 @@ class StructuredAddSVCSR(_NoPythonCOp):
...
@@ -1723,7 +1723,7 @@ class StructuredAddSVCSR(_NoPythonCOp):
dtype_{_zout} * const __restrict__ zout = (dtype_{_zout}*)PyArray_DATA({_zout});
dtype_{_zout} * const __restrict__ zout = (dtype_{_zout}*)PyArray_DATA({_zout});
const npy_intp Sb = PyArray_STRIDES({_b})[0] / PyArray_
DESCR({_b})->elsize
;
const npy_intp Sb = PyArray_STRIDES({_b})[0] / PyArray_
ITEMSIZE({_b})
;
// loop over columns
// loop over columns
for (npy_intp j = 0; j < N; ++j)
for (npy_intp j = 0; j < N; ++j)
...
@@ -1868,7 +1868,7 @@ class SamplingDotCSR(_NoPythonCOp):
...
@@ -1868,7 +1868,7 @@ class SamplingDotCSR(_NoPythonCOp):
)
)
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
4
,
blas
.
blas_header_version
())
return
(
5
,
blas
.
blas_header_version
())
def
c_support_code
(
self
,
**
kwargs
):
def
c_support_code
(
self
,
**
kwargs
):
return
blas
.
blas_header_text
()
return
blas
.
blas_header_text
()
...
@@ -1995,14 +1995,14 @@ PyErr_SetString(PyExc_NotImplementedError, "rank(y) != 2"); {fail};}}
...
@@ -1995,14 +1995,14 @@ PyErr_SetString(PyExc_NotImplementedError, "rank(y) != 2"); {fail};}}
dtype_{z_ind}* __restrict__ Dzi = (dtype_{z_ind}*)PyArray_DATA({z_ind});
dtype_{z_ind}* __restrict__ Dzi = (dtype_{z_ind}*)PyArray_DATA({z_ind});
dtype_{z_ptr}* __restrict__ Dzp = (dtype_{z_ptr}*)PyArray_DATA({z_ptr});
dtype_{z_ptr}* __restrict__ Dzp = (dtype_{z_ptr}*)PyArray_DATA({z_ptr});
const npy_intp Sdx = PyArray_STRIDES({x})[1]/PyArray_
DESCR({x})->elsize
;
const npy_intp Sdx = PyArray_STRIDES({x})[1]/PyArray_
ITEMSIZE({x})
;
const npy_intp Sdy = PyArray_STRIDES({y})[1]/PyArray_
DESCR({y})->elsize
;
const npy_intp Sdy = PyArray_STRIDES({y})[1]/PyArray_
ITEMSIZE({y})
;
const npy_intp Sdpd = PyArray_STRIDES({p_data})[0] / PyArray_
DESCR({p_data})->elsize
;
const npy_intp Sdpd = PyArray_STRIDES({p_data})[0] / PyArray_
ITEMSIZE({p_data})
;
const npy_intp Sdpi = PyArray_STRIDES({p_ind})[0] / PyArray_
DESCR({p_ind})->elsize
;
const npy_intp Sdpi = PyArray_STRIDES({p_ind})[0] / PyArray_
ITEMSIZE({p_ind})
;
const npy_intp Sdpp = PyArray_STRIDES({p_ptr})[0] / PyArray_
DESCR({p_ptr})->elsize
;
const npy_intp Sdpp = PyArray_STRIDES({p_ptr})[0] / PyArray_
ITEMSIZE({p_ptr})
;
const npy_intp Sdzd = PyArray_STRIDES({z_data})[0] / PyArray_
DESCR({z_data})->elsize
;
const npy_intp Sdzd = PyArray_STRIDES({z_data})[0] / PyArray_
ITEMSIZE({z_data})
;
const npy_intp Sdzi = PyArray_STRIDES({z_ind})[0] / PyArray_
DESCR({z_ind})->elsize
;
const npy_intp Sdzi = PyArray_STRIDES({z_ind})[0] / PyArray_
ITEMSIZE({z_ind})
;
const npy_intp Sdzp = PyArray_STRIDES({z_ptr})[0] / PyArray_
DESCR({z_ptr})->elsize
;
const npy_intp Sdzp = PyArray_STRIDES({z_ptr})[0] / PyArray_
ITEMSIZE({z_ptr})
;
memcpy(Dzi, Dpi, PyArray_DIMS({p_ind})[0]*sizeof(dtype_{p_ind}));
memcpy(Dzi, Dpi, PyArray_DIMS({p_ind})[0]*sizeof(dtype_{p_ind}));
memcpy(Dzp, Dpp, PyArray_DIMS({p_ptr})[0]*sizeof(dtype_{p_ptr}));
memcpy(Dzp, Dpp, PyArray_DIMS({p_ptr})[0]*sizeof(dtype_{p_ptr}));
...
...
pytensor/tensor/blas.py
浏览文件 @
0145d609
...
@@ -498,7 +498,7 @@ class GemmRelated(COp):
...
@@ -498,7 +498,7 @@ class GemmRelated(COp):
int unit = 0;
int unit = 0;
int type_num = PyArray_DESCR(
%(_x)
s)->type_num;
int type_num = PyArray_DESCR(
%(_x)
s)->type_num;
int type_size = PyArray_
DESCR(
%(_x)
s)->elsize
; // in bytes
int type_size = PyArray_
ITEMSIZE(
%(_x)
s)
; // in bytes
npy_intp* Nx = PyArray_DIMS(
%(_x)
s);
npy_intp* Nx = PyArray_DIMS(
%(_x)
s);
npy_intp* Ny = PyArray_DIMS(
%(_y)
s);
npy_intp* Ny = PyArray_DIMS(
%(_y)
s);
...
@@ -789,7 +789,7 @@ class GemmRelated(COp):
...
@@ -789,7 +789,7 @@ class GemmRelated(COp):
)
)
def
build_gemm_version
(
self
):
def
build_gemm_version
(
self
):
return
(
1
3
,
blas_header_version
())
return
(
1
4
,
blas_header_version
())
class
Gemm
(
GemmRelated
):
class
Gemm
(
GemmRelated
):
...
@@ -1030,7 +1030,7 @@ class Gemm(GemmRelated):
...
@@ -1030,7 +1030,7 @@ class Gemm(GemmRelated):
%(fail)
s
%(fail)
s
}
}
if(PyArray_
Move
Into(x_new,
%(_x)
s) == -1)
if(PyArray_
Copy
Into(x_new,
%(_x)
s) == -1)
{
{
%(fail)
s
%(fail)
s
}
}
...
@@ -1056,7 +1056,7 @@ class Gemm(GemmRelated):
...
@@ -1056,7 +1056,7 @@ class Gemm(GemmRelated):
%(fail)
s
%(fail)
s
}
}
if(PyArray_
Move
Into(y_new,
%(_y)
s) == -1)
if(PyArray_
Copy
Into(y_new,
%(_y)
s) == -1)
{
{
%(fail)
s
%(fail)
s
}
}
...
@@ -1102,7 +1102,7 @@ class Gemm(GemmRelated):
...
@@ -1102,7 +1102,7 @@ class Gemm(GemmRelated):
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
gv
=
self
.
build_gemm_version
()
gv
=
self
.
build_gemm_version
()
if
gv
:
if
gv
:
return
(
7
,
*
gv
)
return
(
8
,
*
gv
)
else
:
else
:
return
gv
return
gv
...
@@ -1538,7 +1538,7 @@ class BatchedDot(COp):
...
@@ -1538,7 +1538,7 @@ class BatchedDot(COp):
return
f
"""
return
f
"""
int type_num = PyArray_DESCR({_x})->type_num;
int type_num = PyArray_DESCR({_x})->type_num;
int type_size = PyArray_
DESCR({_x})->elsize
; // in bytes
int type_size = PyArray_
ITEMSIZE({_x})
; // in bytes
if (PyArray_NDIM({_x}) != 3) {{
if (PyArray_NDIM({_x}) != 3) {{
PyErr_Format(PyExc_NotImplementedError,
PyErr_Format(PyExc_NotImplementedError,
...
@@ -1598,7 +1598,7 @@ class BatchedDot(COp):
...
@@ -1598,7 +1598,7 @@ class BatchedDot(COp):
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
from
pytensor.tensor.blas_headers
import
blas_header_version
from
pytensor.tensor.blas_headers
import
blas_header_version
return
(
5
,
blas_header_version
())
return
(
6
,
blas_header_version
())
def
grad
(
self
,
inp
,
grads
):
def
grad
(
self
,
inp
,
grads
):
x
,
y
=
inp
x
,
y
=
inp
...
...
pytensor/tensor/blas_headers.py
浏览文件 @
0145d609
...
@@ -1053,7 +1053,7 @@ def openblas_threads_text():
...
@@ -1053,7 +1053,7 @@ def openblas_threads_text():
def
blas_header_version
():
def
blas_header_version
():
# Version for the base header
# Version for the base header
version
=
(
9
,)
version
=
(
10
,)
if
detect_macos_sdot_bug
():
if
detect_macos_sdot_bug
():
if
detect_macos_sdot_bug
.
fix_works
:
if
detect_macos_sdot_bug
.
fix_works
:
# Version with fix
# Version with fix
...
@@ -1071,7 +1071,7 @@ def ____gemm_code(check_ab, a_init, b_init):
...
@@ -1071,7 +1071,7 @@ def ____gemm_code(check_ab, a_init, b_init):
const char * error_string = NULL;
const char * error_string = NULL;
int type_num = PyArray_DESCR(_x)->type_num;
int type_num = PyArray_DESCR(_x)->type_num;
int type_size = PyArray_
DESCR(_x)->elsize
; // in bytes
int type_size = PyArray_
ITEMSIZE(_x)
; // in bytes
npy_intp* Nx = PyArray_DIMS(_x);
npy_intp* Nx = PyArray_DIMS(_x);
npy_intp* Ny = PyArray_DIMS(_y);
npy_intp* Ny = PyArray_DIMS(_y);
...
...
tests/compile/test_debugmode.py
浏览文件 @
0145d609
...
@@ -146,7 +146,7 @@ class WeirdBrokenOp(COp):
...
@@ -146,7 +146,7 @@ class WeirdBrokenOp(COp):
raise
ValueError
(
self
.
behaviour
)
raise
ValueError
(
self
.
behaviour
)
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
1
,)
return
(
2
,)
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
(
a
,)
=
inp
(
a
,)
=
inp
...
@@ -165,8 +165,8 @@ class WeirdBrokenOp(COp):
...
@@ -165,8 +165,8 @@ class WeirdBrokenOp(COp):
prep_vars
=
f
"""
prep_vars
=
f
"""
//the output array has size M x N
//the output array has size M x N
npy_intp M = PyArray_DIMS({a})[0];
npy_intp M = PyArray_DIMS({a})[0];
npy_intp Sa = PyArray_STRIDES({a})[0] / PyArray_
DESCR({a})->elsize
;
npy_intp Sa = PyArray_STRIDES({a})[0] / PyArray_
ITEMSIZE({a})
;
npy_intp Sz = PyArray_STRIDES({z})[0] / PyArray_
DESCR({z})->elsize
;
npy_intp Sz = PyArray_STRIDES({z})[0] / PyArray_
ITEMSIZE({z})
;
npy_double * Da = (npy_double*)PyArray_BYTES({a});
npy_double * Da = (npy_double*)PyArray_BYTES({a});
npy_double * Dz = (npy_double*)PyArray_BYTES({z});
npy_double * Dz = (npy_double*)PyArray_BYTES({z});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论