Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9d5ab765
提交
9d5ab765
authored
10月 20, 2022
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
10月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove TensorType.value_zeros
上级
2cf617d5
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
13 行增加
和
26 行删除
+13
-26
debugmode.py
aesara/compile/debugmode.py
+4
-3
op.py
aesara/scan/op.py
+7
-5
type.py
aesara/sparse/type.py
+0
-8
type.py
aesara/tensor/type.py
+0
-7
test_debugmode.py
tests/compile/test_debugmode.py
+2
-2
test_type.py
tests/tensor/test_type.py
+0
-1
没有找到文件。
aesara/compile/debugmode.py
浏览文件 @
9d5ab765
...
@@ -807,7 +807,7 @@ def _get_preallocated_maps(
...
@@ -807,7 +807,7 @@ def _get_preallocated_maps(
for
r
in
considered_outputs
:
for
r
in
considered_outputs
:
if
isinstance
(
r
.
type
,
TensorType
):
if
isinstance
(
r
.
type
,
TensorType
):
# Build a C-contiguous buffer
# Build a C-contiguous buffer
new_buf
=
r
.
type
.
value_zeros
(
r_vals
[
r
]
.
sha
pe
)
new_buf
=
np
.
empty
(
r_vals
[
r
]
.
shape
,
dtype
=
r
.
type
.
dty
pe
)
assert
new_buf
.
flags
[
"C_CONTIGUOUS"
]
assert
new_buf
.
flags
[
"C_CONTIGUOUS"
]
new_buf
[
...
]
=
np
.
asarray
(
def_val
)
.
astype
(
r
.
type
.
dtype
)
new_buf
[
...
]
=
np
.
asarray
(
def_val
)
.
astype
(
r
.
type
.
dtype
)
...
@@ -875,7 +875,8 @@ def _get_preallocated_maps(
...
@@ -875,7 +875,8 @@ def _get_preallocated_maps(
buf_shape
.
append
(
s
)
buf_shape
.
append
(
s
)
else
:
else
:
buf_shape
.
append
(
s
*
2
)
buf_shape
.
append
(
s
*
2
)
new_buf
=
r
.
type
.
value_zeros
(
buf_shape
)
new_buf
=
np
.
empty
(
buf_shape
,
dtype
=
r
.
type
.
dtype
)
new_buf
[
...
]
=
np
.
asarray
(
def_val
)
.
astype
(
r
.
type
.
dtype
)
new_buf
[
...
]
=
np
.
asarray
(
def_val
)
.
astype
(
r
.
type
.
dtype
)
init_strided
[
r
]
=
new_buf
init_strided
[
r
]
=
new_buf
...
@@ -950,7 +951,7 @@ def _get_preallocated_maps(
...
@@ -950,7 +951,7 @@ def _get_preallocated_maps(
max
((
s
+
sd
),
0
)
max
((
s
+
sd
),
0
)
for
s
,
sd
in
zip
(
r_vals
[
r
]
.
shape
,
r_shape_diff
)
for
s
,
sd
in
zip
(
r_vals
[
r
]
.
shape
,
r_shape_diff
)
]
]
new_buf
=
r
.
type
.
value_zeros
(
out_sha
pe
)
new_buf
=
np
.
empty
(
out_shape
,
dtype
=
r
.
type
.
dty
pe
)
new_buf
[
...
]
=
np
.
asarray
(
def_val
)
.
astype
(
r
.
type
.
dtype
)
new_buf
[
...
]
=
np
.
asarray
(
def_val
)
.
astype
(
r
.
type
.
dtype
)
wrong_size
[
r
]
=
new_buf
wrong_size
[
r
]
=
new_buf
...
...
aesara/scan/op.py
浏览文件 @
9d5ab765
...
@@ -1380,11 +1380,13 @@ class Scan(Op, ScanMethodsMixin, HasInnerGraph):
...
@@ -1380,11 +1380,13 @@ class Scan(Op, ScanMethodsMixin, HasInnerGraph):
# the output value, possibly inplace, at the end of the
# the output value, possibly inplace, at the end of the
# function execution. Also, since an update is defined,
# function execution. Also, since an update is defined,
# a default value must also be (this is verified by
# a default value must also be (this is verified by
# DebugMode). Use an array of size 0 with the correct
# DebugMode).
# ndim and dtype (use a shape of 1 on broadcastable
# TODO FIXME: Why do we need a "default value" here?
# dimensions, and 0 on the others).
# This sounds like a serious design issue.
default_shape
=
[
1
if
_b
else
0
for
_b
in
inp
.
broadcastable
]
default_shape
=
tuple
(
default_val
=
inp
.
type
.
value_zeros
(
default_shape
)
s
if
s
is
not
None
else
0
for
s
in
inp
.
type
.
shape
)
default_val
=
np
.
empty
(
default_shape
,
dtype
=
inp
.
type
.
dtype
)
wrapped_inp
=
In
(
wrapped_inp
=
In
(
variable
=
inp
,
variable
=
inp
,
value
=
default_val
,
value
=
default_val
,
...
...
aesara/sparse/type.py
浏览文件 @
9d5ab765
...
@@ -224,14 +224,6 @@ class SparseTensorType(TensorType, HasDataType):
...
@@ -224,14 +224,6 @@ class SparseTensorType(TensorType, HasDataType):
+
(
shape_info
[
2
]
+
shape_info
[
3
])
*
np
.
dtype
(
"int32"
)
.
itemsize
+
(
shape_info
[
2
]
+
shape_info
[
3
])
*
np
.
dtype
(
"int32"
)
.
itemsize
)
)
def
value_zeros
(
self
,
shape
):
matrix_constructor
=
self
.
format_cls
.
get
(
self
.
format
)
if
matrix_constructor
is
None
:
raise
ValueError
(
f
"Sparse matrix type {self.format} not found in SciPy"
)
return
matrix_constructor
(
shape
,
dtype
=
self
.
dtype
)
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
res
=
super
()
.
__eq__
(
other
)
res
=
super
()
.
__eq__
(
other
)
...
...
aesara/tensor/type.py
浏览文件 @
9d5ab765
...
@@ -331,13 +331,6 @@ class TensorType(CType[np.ndarray], HasDataType, HasShape):
...
@@ -331,13 +331,6 @@ class TensorType(CType[np.ndarray], HasDataType, HasShape):
# `specify_shape` will combine the more precise shapes of the two types
# `specify_shape` will combine the more precise shapes of the two types
return
aesara
.
tensor
.
specify_shape
(
var
,
self
.
shape
)
return
aesara
.
tensor
.
specify_shape
(
var
,
self
.
shape
)
def
value_zeros
(
self
,
shape
):
"""Create an numpy ndarray full of 0 values.
TODO: Remove this trivial method.
"""
return
np
.
zeros
(
shape
,
dtype
=
self
.
dtype
)
@staticmethod
@staticmethod
def
values_eq
(
a
,
b
,
force_same_dtype
=
True
):
def
values_eq
(
a
,
b
,
force_same_dtype
=
True
):
# TODO: check to see if the shapes must match; for now, we err on safe
# TODO: check to see if the shapes must match; for now, we err on safe
...
...
tests/compile/test_debugmode.py
浏览文件 @
9d5ab765
...
@@ -725,10 +725,10 @@ class VecAsRowAndCol(Op):
...
@@ -725,10 +725,10 @@ class VecAsRowAndCol(Op):
r
,
c
=
out
r
,
c
=
out
lv
=
v
.
shape
[
0
]
lv
=
v
.
shape
[
0
]
if
(
r
[
0
]
is
None
)
or
(
r
[
0
]
.
shape
!=
(
1
,
lv
)):
if
(
r
[
0
]
is
None
)
or
(
r
[
0
]
.
shape
!=
(
1
,
lv
)):
r
[
0
]
=
n
ode
.
outputs
[
0
]
.
type
.
value_zeros
((
1
,
lv
)
)
r
[
0
]
=
n
p
.
empty
((
1
,
lv
),
dtype
=
node
.
outputs
[
0
]
.
type
.
dtype
)
if
(
c
[
0
]
is
None
)
or
(
c
[
0
]
.
shape
!=
(
lv
,
1
)):
if
(
c
[
0
]
is
None
)
or
(
c
[
0
]
.
shape
!=
(
lv
,
1
)):
c
[
0
]
=
n
ode
.
outputs
[
1
]
.
type
.
value_zeros
((
lv
,
1
)
)
c
[
0
]
=
n
p
.
empty
((
lv
,
1
),
dtype
=
node
.
outputs
[
0
]
.
type
.
dtype
)
for
i
in
range
(
lv
):
for
i
in
range
(
lv
):
r
[
0
][
0
,
i
]
=
v
[
i
]
r
[
0
][
0
,
i
]
=
v
[
i
]
...
...
tests/tensor/test_type.py
浏览文件 @
9d5ab765
...
@@ -234,7 +234,6 @@ def test_fixed_shape_basic():
...
@@ -234,7 +234,6 @@ def test_fixed_shape_basic():
t1
=
TensorType
(
"float64"
,
(
2
,
3
))
t1
=
TensorType
(
"float64"
,
(
2
,
3
))
assert
t1
.
shape
==
(
2
,
3
)
assert
t1
.
shape
==
(
2
,
3
)
assert
t1
.
broadcastable
==
(
False
,
False
)
assert
t1
.
broadcastable
==
(
False
,
False
)
assert
t1
.
value_zeros
(
t1
.
shape
)
.
shape
==
t1
.
shape
assert
str
(
t1
)
==
"TensorType(float64, (2, 3))"
assert
str
(
t1
)
==
"TensorType(float64, (2, 3))"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论