Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
265c0d94
提交
265c0d94
authored
2月 18, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
2月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix deprecated and unnecessary uses of np.sum
上级
458312ee
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
24 行增加
和
27 行删除
+24
-27
profiling.py
aesara/compile/profiling.py
+3
-3
op.py
aesara/scan/op.py
+6
-8
subtensor.py
aesara/tensor/subtensor.py
+2
-2
test_basic.py
tests/tensor/test_basic.py
+5
-6
test_basic_opt.py
tests/tensor/test_basic_opt.py
+2
-2
test_blas.py
tests/tensor/test_blas.py
+2
-2
test_math_opt.py
tests/tensor/test_math_opt.py
+2
-2
test_subtensor.py
tests/tensor/test_subtensor.py
+2
-2
没有找到文件。
aesara/compile/profiling.py
浏览文件 @
265c0d94
...
@@ -527,7 +527,7 @@ class ProfileStats:
...
@@ -527,7 +527,7 @@ class ProfileStats:
hs
+=
[
"<#apply>"
]
hs
+=
[
"<#apply>"
]
es
+=
[
"
%4
d "
]
es
+=
[
"
%4
d "
]
upto_length
=
np
.
sum
([
len
(
x
)
for
x
in
hs
]
)
+
len
(
hs
)
upto_length
=
sum
(
len
(
x
)
for
x
in
hs
)
+
len
(
hs
)
maxlen
=
max
(
self
.
line_width
-
upto_length
,
0
)
maxlen
=
max
(
self
.
line_width
-
upto_length
,
0
)
hs
+=
[
"<Class name>"
]
hs
+=
[
"<Class name>"
]
es
+=
[
"
%
s"
]
es
+=
[
"
%
s"
]
...
@@ -624,7 +624,7 @@ class ProfileStats:
...
@@ -624,7 +624,7 @@ class ProfileStats:
hs
+=
[
"<#apply>"
]
hs
+=
[
"<#apply>"
]
es
+=
[
"
%4
d "
]
es
+=
[
"
%4
d "
]
upto_length
=
np
.
sum
([
len
(
x
)
for
x
in
hs
]
)
+
len
(
hs
)
upto_length
=
sum
(
len
(
x
)
for
x
in
hs
)
+
len
(
hs
)
maxlen
=
max
(
self
.
line_width
-
upto_length
,
0
)
maxlen
=
max
(
self
.
line_width
-
upto_length
,
0
)
hs
+=
[
"<Op name>"
]
hs
+=
[
"<Op name>"
]
es
+=
[
"
%
s"
]
es
+=
[
"
%
s"
]
...
@@ -703,7 +703,7 @@ class ProfileStats:
...
@@ -703,7 +703,7 @@ class ProfileStats:
if
self
.
variable_shape
:
if
self
.
variable_shape
:
hs
+=
[
"<Mflops>"
,
"<Gflops/s>"
]
hs
+=
[
"<Mflops>"
,
"<Gflops/s>"
]
upto_length
=
np
.
sum
([
len
(
x
)
for
x
in
hs
]
)
+
len
(
hs
)
upto_length
=
sum
(
len
(
x
)
for
x
in
hs
)
+
len
(
hs
)
maxlen
=
max
(
self
.
line_width
-
upto_length
,
0
)
maxlen
=
max
(
self
.
line_width
-
upto_length
,
0
)
hs
+=
[
"<Apply name>"
]
hs
+=
[
"<Apply name>"
]
es
+=
[
"
%
s"
]
es
+=
[
"
%
s"
]
...
...
aesara/scan/op.py
浏览文件 @
265c0d94
...
@@ -3086,7 +3086,7 @@ class Scan(Op, ScanMethodsMixin, HasInnerGraph):
...
@@ -3086,7 +3086,7 @@ class Scan(Op, ScanMethodsMixin, HasInnerGraph):
b
=
e
b
=
e
e
=
e
+
self
.
n_mit_mot
e
=
e
+
self
.
n_mit_mot
ib
=
ie
ib
=
ie
ie
=
ie
+
int
(
np
.
sum
([
len
(
x
)
for
x
in
self
.
tap_array
[:
self
.
n_mit_mot
]
]))
ie
=
ie
+
int
(
sum
(
len
(
x
)
for
x
in
self
.
tap_array
[:
self
.
n_mit_mot
]))
clean_eval_points
=
[]
clean_eval_points
=
[]
for
inp
,
evp
in
zip
(
inputs
[
b
:
e
],
eval_points
[
b
:
e
]):
for
inp
,
evp
in
zip
(
inputs
[
b
:
e
],
eval_points
[
b
:
e
]):
if
evp
is
not
None
:
if
evp
is
not
None
:
...
@@ -3102,12 +3102,10 @@ class Scan(Op, ScanMethodsMixin, HasInnerGraph):
...
@@ -3102,12 +3102,10 @@ class Scan(Op, ScanMethodsMixin, HasInnerGraph):
e
=
e
+
self
.
n_mit_sot
e
=
e
+
self
.
n_mit_sot
ib
=
ie
ib
=
ie
ie
=
ie
+
int
(
ie
=
ie
+
int
(
np
.
sum
(
sum
(
[
len
(
x
)
len
(
x
)
for
x
in
self
.
tap_array
[
for
x
in
self
.
tap_array
[
self
.
n_mit_mot
:
self
.
n_mit_mot
+
self
.
n_mit_sot
self
.
n_mit_mot
:
self
.
n_mit_mot
+
self
.
n_mit_sot
]
]
]
)
)
)
)
...
@@ -3161,7 +3159,7 @@ class Scan(Op, ScanMethodsMixin, HasInnerGraph):
...
@@ -3161,7 +3159,7 @@ class Scan(Op, ScanMethodsMixin, HasInnerGraph):
inner_other
=
self_inputs
[
ie
:]
+
inner_eval_points
[
ib
:]
inner_other
=
self_inputs
[
ie
:]
+
inner_eval_points
[
ib
:]
# Outputs
# Outputs
n_mit_mot_outs
=
int
(
np
.
sum
([
len
(
x
)
for
x
in
self
.
mit_mot_out_slices
]
))
n_mit_mot_outs
=
int
(
sum
(
len
(
x
)
for
x
in
self
.
mit_mot_out_slices
))
b
=
0
b
=
0
e
=
n_mit_mot_outs
e
=
n_mit_mot_outs
...
...
aesara/tensor/subtensor.py
浏览文件 @
265c0d94
...
@@ -1598,8 +1598,8 @@ class IncSubtensor(COp):
...
@@ -1598,8 +1598,8 @@ class IncSubtensor(COp):
else
:
else
:
op_is_set
=
0
op_is_set
=
0
fail
=
sub
[
"fail"
]
fail
=
sub
[
"fail"
]
view_ndim
=
node
.
inputs
[
0
]
.
ndim
-
np
.
sum
(
view_ndim
=
node
.
inputs
[
0
]
.
ndim
-
sum
(
[
not
isinstance
(
idx
,
slice
)
for
idx
in
self
.
idx_list
]
not
isinstance
(
idx
,
slice
)
for
idx
in
self
.
idx_list
)
)
copy_of_x
=
self
.
copy_of_x
(
x
)
copy_of_x
=
self
.
copy_of_x
(
x
)
...
...
tests/tensor/test_basic.py
浏览文件 @
265c0d94
...
@@ -729,12 +729,11 @@ class TestAlloc:
...
@@ -729,12 +729,11 @@ class TestAlloc:
fgrad
=
aesara
.
function
([
some_vector
],
grad_derp
,
mode
=
self
.
mode
)
fgrad
=
aesara
.
function
([
some_vector
],
grad_derp
,
mode
=
self
.
mode
)
topo_obj
=
fobj
.
maker
.
fgraph
.
toposort
()
topo_obj
=
fobj
.
maker
.
fgraph
.
toposort
()
assert
np
.
sum
([
isinstance
(
node
.
op
,
type
(
alloc_
))
for
node
in
topo_obj
]
)
==
0
assert
sum
(
isinstance
(
node
.
op
,
type
(
alloc_
))
for
node
in
topo_obj
)
==
0
topo_grad
=
fgrad
.
maker
.
fgraph
.
toposort
()
topo_grad
=
fgrad
.
maker
.
fgraph
.
toposort
()
assert
(
assert
(
np
.
sum
([
isinstance
(
node
.
op
,
type
(
alloc_
))
for
node
in
topo_grad
])
sum
(
isinstance
(
node
.
op
,
type
(
alloc_
))
for
node
in
topo_grad
)
==
n_alloc
==
n_alloc
),
(
alloc_
,
subtensor
,
n_alloc
,
topo_grad
)
),
(
alloc_
,
subtensor
,
n_alloc
,
topo_grad
)
fobj
(
test_params
)
fobj
(
test_params
)
fgrad
(
test_params
)
fgrad
(
test_params
)
...
@@ -748,7 +747,7 @@ class TestAlloc:
...
@@ -748,7 +747,7 @@ class TestAlloc:
f
=
aesara
.
function
([],
out
,
mode
=
self
.
mode
)
f
=
aesara
.
function
([],
out
,
mode
=
self
.
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
np
.
sum
([
isinstance
(
node
.
op
,
type
(
alloc_
))
for
node
in
topo
]
)
==
1
assert
sum
(
isinstance
(
node
.
op
,
type
(
alloc_
))
for
node
in
topo
)
==
1
assert
not
isinstance
(
topo
[
0
]
.
op
,
DeepCopyOp
)
assert
not
isinstance
(
topo
[
0
]
.
op
,
DeepCopyOp
)
def
test_ones
(
self
):
def
test_ones
(
self
):
...
@@ -3610,7 +3609,7 @@ class TestDiag:
...
@@ -3610,7 +3609,7 @@ class TestDiag:
f
=
aesara
.
function
([
x
],
g
.
shape
)
f
=
aesara
.
function
([
x
],
g
.
shape
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
if
config
.
mode
!=
"FAST_COMPILE"
:
if
config
.
mode
!=
"FAST_COMPILE"
:
assert
np
.
sum
([
isinstance
(
node
.
op
,
AllocDiag
)
for
node
in
topo
]
)
==
0
assert
sum
(
isinstance
(
node
.
op
,
AllocDiag
)
for
node
in
topo
)
==
0
for
shp
in
[
5
,
0
,
1
]:
for
shp
in
[
5
,
0
,
1
]:
m
=
rng
.
random
(
shp
)
.
astype
(
self
.
floatX
)
m
=
rng
.
random
(
shp
)
.
astype
(
self
.
floatX
)
assert
(
f
(
m
)
==
np
.
diag
(
m
)
.
shape
)
.
all
()
assert
(
f
(
m
)
==
np
.
diag
(
m
)
.
shape
)
.
all
()
...
@@ -3620,7 +3619,7 @@ class TestDiag:
...
@@ -3620,7 +3619,7 @@ class TestDiag:
f
=
aesara
.
function
([
x
],
g
.
shape
)
f
=
aesara
.
function
([
x
],
g
.
shape
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
if
config
.
mode
!=
"FAST_COMPILE"
:
if
config
.
mode
!=
"FAST_COMPILE"
:
assert
np
.
sum
([
isinstance
(
node
.
op
,
ExtractDiag
)
for
node
in
topo
]
)
==
0
assert
sum
(
isinstance
(
node
.
op
,
ExtractDiag
)
for
node
in
topo
)
==
0
for
shp
in
[(
5
,
3
),
(
3
,
5
),
(
5
,
1
),
(
1
,
5
),
(
5
,
0
),
(
0
,
5
),
(
1
,
0
),
(
0
,
1
)]:
for
shp
in
[(
5
,
3
),
(
3
,
5
),
(
5
,
1
),
(
1
,
5
),
(
5
,
0
),
(
0
,
5
),
(
1
,
0
),
(
0
,
1
)]:
m
=
rng
.
random
(
shp
)
.
astype
(
self
.
floatX
)
m
=
rng
.
random
(
shp
)
.
astype
(
self
.
floatX
)
assert
(
f
(
m
)
==
np
.
diag
(
m
)
.
shape
)
.
all
()
assert
(
f
(
m
)
==
np
.
diag
(
m
)
.
shape
)
.
all
()
...
...
tests/tensor/test_basic_opt.py
浏览文件 @
265c0d94
...
@@ -1027,8 +1027,8 @@ class TestFusion:
...
@@ -1027,8 +1027,8 @@ class TestFusion:
# check that the number of input to the Composite
# check that the number of input to the Composite
# Elemwise is ok
# Elemwise is ok
if
len
(
set
(
g
.
owner
.
inputs
))
==
len
(
g
.
owner
.
inputs
):
if
len
(
set
(
g
.
owner
.
inputs
))
==
len
(
g
.
owner
.
inputs
):
expected_len_sym_inputs
=
np
.
sum
(
expected_len_sym_inputs
=
sum
(
[
not
isinstance
(
x
,
Constant
)
for
x
in
topo_
[
0
]
.
inputs
]
not
isinstance
(
x
,
Constant
)
for
x
in
topo_
[
0
]
.
inputs
)
)
assert
expected_len_sym_inputs
==
len
(
sym_inputs
)
assert
expected_len_sym_inputs
==
len
(
sym_inputs
)
...
...
tests/tensor/test_blas.py
浏览文件 @
265c0d94
...
@@ -862,7 +862,7 @@ def test_upcasting_scalar_nogemm():
...
@@ -862,7 +862,7 @@ def test_upcasting_scalar_nogemm():
f
=
function
([
w
,
v
,
t
,
alpha
],
rval
)
f
=
function
([
w
,
v
,
t
,
alpha
],
rval
)
t
=
f
.
maker
.
fgraph
.
toposort
()
t
=
f
.
maker
.
fgraph
.
toposort
()
assert
np
.
sum
([
isinstance
(
n
.
op
,
Gemm
)
for
n
in
t
]
)
==
0
assert
sum
(
isinstance
(
n
.
op
,
Gemm
)
for
n
in
t
)
==
0
# aesara.printing.debugprint(f, print_type=True)
# aesara.printing.debugprint(f, print_type=True)
v
=
fmatrix
(
"v"
)
v
=
fmatrix
(
"v"
)
...
@@ -875,7 +875,7 @@ def test_upcasting_scalar_nogemm():
...
@@ -875,7 +875,7 @@ def test_upcasting_scalar_nogemm():
f
=
function
([
w
,
v
,
t
,
alpha
],
rval
)
f
=
function
([
w
,
v
,
t
,
alpha
],
rval
)
t
=
f
.
maker
.
fgraph
.
toposort
()
t
=
f
.
maker
.
fgraph
.
toposort
()
assert
np
.
sum
([
isinstance
(
n
.
op
,
Gemm
)
for
n
in
t
]
)
==
0
assert
sum
(
isinstance
(
n
.
op
,
Gemm
)
for
n
in
t
)
==
0
# aesara.printing.debugprint(f, print_type=True)
# aesara.printing.debugprint(f, print_type=True)
...
...
tests/tensor/test_math_opt.py
浏览文件 @
265c0d94
...
@@ -1771,8 +1771,8 @@ class TestFusion:
...
@@ -1771,8 +1771,8 @@ class TestFusion:
# check that the number of input to the Composite
# check that the number of input to the Composite
# Elemwise is ok
# Elemwise is ok
if
len
(
set
(
g
.
owner
.
inputs
))
==
len
(
g
.
owner
.
inputs
):
if
len
(
set
(
g
.
owner
.
inputs
))
==
len
(
g
.
owner
.
inputs
):
expected_len_sym_inputs
=
np
.
sum
(
expected_len_sym_inputs
=
sum
(
[
not
isinstance
(
x
,
Constant
)
for
x
in
topo_
[
0
]
.
inputs
]
not
isinstance
(
x
,
Constant
)
for
x
in
topo_
[
0
]
.
inputs
)
)
assert
expected_len_sym_inputs
==
len
(
sym_inputs
)
assert
expected_len_sym_inputs
==
len
(
sym_inputs
)
...
...
tests/tensor/test_subtensor.py
浏览文件 @
265c0d94
...
@@ -788,8 +788,8 @@ class TestSubtensor(utt.OptimizationTestMixin):
...
@@ -788,8 +788,8 @@ class TestSubtensor(utt.OptimizationTestMixin):
topo_
=
[
node
for
node
in
topo
if
not
isinstance
(
node
.
op
,
DeepCopyOp
)]
topo_
=
[
node
for
node
in
topo
if
not
isinstance
(
node
.
op
,
DeepCopyOp
)]
if
not
self
.
fast_compile
:
if
not
self
.
fast_compile
:
assert
len
(
topo_
)
==
6
assert
len
(
topo_
)
==
6
assert
np
.
sum
([
isinstance
(
node
.
op
,
IncSubtensor
)
for
node
in
topo_
]
)
==
1
assert
sum
(
isinstance
(
node
.
op
,
IncSubtensor
)
for
node
in
topo_
)
==
1
assert
np
.
sum
([
isinstance
(
node
.
op
,
Subtensor
)
for
node
in
topo_
]
)
==
1
assert
sum
(
isinstance
(
node
.
op
,
Subtensor
)
for
node
in
topo_
)
==
1
gval
=
f
()
gval
=
f
()
good
=
np
.
zeros_like
(
data
)
good
=
np
.
zeros_like
(
data
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论