Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
82f6a14f
提交
82f6a14f
authored
10月 09, 2024
作者:
ricardoV94
提交者:
Ricardo Vieira
10月 29, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup Function.__call__
上级
f0a9ec25
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
23 行增加
和
36 行删除
+23
-36
types.py
pytensor/compile/function/types.py
+0
-0
gradient.py
pytensor/gradient.py
+0
-3
null_type.py
pytensor/graph/null_type.py
+0
-3
type.py
pytensor/graph/type.py
+1
-4
basic.py
pytensor/scalar/basic.py
+0
-7
type_other.py
pytensor/tensor/type_other.py
+0
-6
test_types.py
tests/compile/function/test_types.py
+22
-13
没有找到文件。
pytensor/compile/function/types.py
浏览文件 @
82f6a14f
差异被折叠。
点击展开。
pytensor/gradient.py
浏览文件 @
82f6a14f
...
...
@@ -128,9 +128,6 @@ class DisconnectedType(Type):
" a symbolic placeholder."
)
def
may_share_memory
(
a
,
b
):
return
False
def
value_eq
(
a
,
b
,
force_same_dtype
=
True
):
raise
AssertionError
(
"If you're assigning to a DisconnectedType you're"
...
...
pytensor/graph/null_type.py
浏览文件 @
82f6a14f
...
...
@@ -26,9 +26,6 @@ class NullType(Type):
def
filter_variable
(
self
,
other
,
allow_convert
=
True
):
raise
ValueError
(
"No values may be assigned to a NullType"
)
def
may_share_memory
(
a
,
b
):
return
False
def
values_eq
(
self
,
a
,
b
,
force_same_dtype
=
True
):
raise
ValueError
(
"NullType has no values to compare"
)
...
...
pytensor/graph/type.py
浏览文件 @
82f6a14f
...
...
@@ -48,10 +48,7 @@ class Type(MetaObject, Generic[D]):
unique element (i.e. it uses `self.__eq__`).
"""
if
self
==
otype
:
return
True
return
False
return
self
==
otype
def
is_super
(
self
,
otype
:
"Type"
)
->
bool
|
None
:
"""Determine if `self` is a supertype of `otype`.
...
...
pytensor/scalar/basic.py
浏览文件 @
82f6a14f
...
...
@@ -303,13 +303,6 @@ class ScalarType(CType, HasDataType, HasShape):
dtype
=
self
.
dtype
return
type
(
self
)(
dtype
)
@staticmethod
def
may_share_memory
(
a
,
b
):
# This class represent basic c type, represented in python
# with numpy.scalar. They are read only. So from python, they
# can never share memory.
return
False
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
py_type
=
self
.
dtype_specs
()[
0
]
if
strict
and
not
isinstance
(
data
,
py_type
):
...
...
pytensor/tensor/type_other.py
浏览文件 @
82f6a14f
...
...
@@ -126,12 +126,6 @@ class NoneTypeT(Generic):
else
:
raise
TypeError
(
"Expected None!"
)
@staticmethod
def
may_share_memory
(
a
,
b
):
# None never share memory between object, in the sense of DebugMode.
# Python None are singleton
return
False
none_type_t
=
NoneTypeT
()
...
...
tests/compile/function/test_types.py
浏览文件 @
82f6a14f
...
...
@@ -730,6 +730,8 @@ class TestFunction:
s1
=
shared
(
b
)
s2
=
shared
(
b
)
x1
=
vector
()
x2
=
vector
(
shape
=
(
3
,))
x3
=
vector
(
shape
=
(
1
,))
# Assert cases we should not check for aliased inputs
for
d
in
[
...
...
@@ -737,27 +739,29 @@ class TestFunction:
dict
(
outputs
=
[
s1
+
1
,
s2
+
3
]),
dict
(
outputs
=
[
s1
+
1
],
updates
=
[(
s2
,
s2
+
3
)]),
dict
(
inputs
=
[
x1
],
outputs
=
[
x1
+
1
],
updates
=
[(
s2
,
s2
+
3
)]),
dict
(
inputs
=
[
In
(
x1
,
mutable
=
True
)],
outputs
=
[
x1
+
1
],
updates
=
[(
s2
,
s2
+
3
)]
),
dict
(
inputs
=
[
In
(
x2
,
mutable
=
True
),
In
(
x3
,
mutable
=
True
)],
outputs
=
[
x2
+
2
,
x3
+
3
],
),
]:
if
"inputs"
not
in
d
:
d
[
"inputs"
]
=
[]
f
=
function
(
**
d
)
assert
not
f
.
_
check_for_aliased_input
s
,
d
assert
not
f
.
_
potential_aliased_input_group
s
,
d
# Assert cases we should check for aliased inputs
for
d
in
[
dict
(
inputs
=
[
In
(
x1
,
borrow
=
True
)],
outputs
=
[
x1
+
1
],
updates
=
[(
s2
,
s2
+
3
)],
),
dict
(
inputs
=
[
In
(
x1
,
borrow
=
True
,
mutable
=
True
)],
outputs
=
[
x1
+
1
],
inputs
=
[
In
(
x1
,
mutable
=
True
),
In
(
x2
,
mutable
=
True
)],
outputs
=
[
x1
+
1
,
x2
+
2
],
updates
=
[(
s2
,
s2
+
3
)],
),
dict
(
inputs
=
[
In
(
x1
,
mutable
=
True
)],
outputs
=
[
x1
+
1
],
inputs
=
[
In
(
x1
,
mutable
=
True
)
,
In
(
x3
,
mutable
=
True
)
],
outputs
=
[
x1
+
1
,
x3
+
3
],
updates
=
[(
s2
,
s2
+
3
)],
),
]:
...
...
@@ -765,7 +769,7 @@ class TestFunction:
d
[
"inputs"
]
=
[]
f
=
function
(
**
d
)
assert
f
.
_
check_for_aliased_input
s
,
d
assert
f
.
_
potential_aliased_input_group
s
,
d
def
test_output_dictionary
(
self
):
# Tests that function works when outputs is a dictionary
...
...
@@ -879,7 +883,7 @@ class TestPicklefunction:
f
=
function
(
[
x
,
In
(
a
,
value
=
1.0
,
name
=
"a"
),
In
(
a
,
value
=
1.0
,
name
=
"a"
,
mutable
=
True
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
),
],
s
+
a
*
x
,
...
...
@@ -901,7 +905,12 @@ class TestPicklefunction:
assert
x
not
in
g
.
container
assert
x
not
in
g
.
value
assert
len
(
f
.
defaults
)
==
len
(
g
.
defaults
)
assert
f
.
_check_for_aliased_inputs
is
g
.
_check_for_aliased_inputs
# Shared variable is the first input
assert
(
f
.
_potential_aliased_input_groups
==
g
.
_potential_aliased_input_groups
==
((
1
,
2
),)
)
assert
f
.
name
==
g
.
name
assert
f
.
maker
.
fgraph
.
name
==
g
.
maker
.
fgraph
.
name
# print(f"{f.defaults = }")
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论