Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9b4531d4
提交
9b4531d4
authored
2月 16, 2022
作者:
lucianopaz
提交者:
Ricardo Vieira
2月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use _props_dict instead of _props in random_make_inplace
上级
71962518
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
45 行增加
和
2 行删除
+45
-2
opt.py
aesara/tensor/random/opt.py
+3
-2
test_opt.py
tests/tensor/random/test_opt.py
+42
-0
没有找到文件。
aesara/tensor/random/opt.py
浏览文件 @
9b4531d4
...
@@ -44,8 +44,9 @@ def random_make_inplace(fgraph, node):
...
@@ -44,8 +44,9 @@ def random_make_inplace(fgraph, node):
op
=
node
.
op
op
=
node
.
op
if
isinstance
(
op
,
RandomVariable
)
and
not
op
.
inplace
:
if
isinstance
(
op
,
RandomVariable
)
and
not
op
.
inplace
:
name
,
ndim_supp
,
ndims_params
,
dtype
,
_
=
op
.
_props
()
props
=
op
.
_props_dict
()
new_op
=
type
(
op
)(
name
,
ndim_supp
,
ndims_params
,
dtype
,
True
)
props
[
"inplace"
]
=
True
new_op
=
type
(
op
)(
**
props
)
return
new_op
.
make_node
(
*
node
.
inputs
)
.
outputs
return
new_op
.
make_node
(
*
node
.
inputs
)
.
outputs
return
False
return
False
...
...
tests/tensor/random/test_opt.py
浏览文件 @
9b4531d4
...
@@ -87,6 +87,48 @@ def test_inplace_optimization():
...
@@ -87,6 +87,48 @@ def test_inplace_optimization():
assert
np
.
array_equal
(
new_out
.
owner
.
inputs
[
1
]
.
data
,
[])
assert
np
.
array_equal
(
new_out
.
owner
.
inputs
[
1
]
.
data
,
[])
def
test_inplace_optimization_extra_props
():
class
Test
(
RandomVariable
):
name
=
"test"
ndim_supp
=
0
ndims_params
=
[
0
]
__props__
=
(
"name"
,
"ndim_supp"
,
"ndims_params"
,
"dtype"
,
"inplace"
,
"extra"
)
dtype
=
"floatX"
_print_name
=
(
"Test"
,
"
\\
operatorname{Test}"
)
def
__init__
(
self
,
extra
,
*
args
,
**
kwargs
):
self
.
extra
=
extra
super
()
.
__init__
(
*
args
,
**
kwargs
)
def
make_node
(
self
,
rng
,
size
,
dtype
,
sigma
):
return
super
()
.
make_node
(
rng
,
size
,
dtype
,
sigma
)
def
rng_fn
(
self
,
rng
,
sigma
,
size
):
return
rng
.
normal
(
scale
=
sigma
,
size
=
size
)
out
=
Test
(
extra
=
"some value"
)(
1
)
out
.
owner
.
inputs
[
0
]
.
default_update
=
out
.
owner
.
outputs
[
0
]
assert
out
.
owner
.
op
.
inplace
is
False
f
=
function
(
[],
out
,
mode
=
"FAST_RUN"
,
)
(
new_out
,
new_rng
)
=
f
.
maker
.
fgraph
.
outputs
assert
new_out
.
type
==
out
.
type
assert
isinstance
(
new_out
.
owner
.
op
,
type
(
out
.
owner
.
op
))
assert
new_out
.
owner
.
op
.
inplace
is
True
assert
new_out
.
owner
.
op
.
extra
==
out
.
owner
.
op
.
extra
assert
all
(
np
.
array_equal
(
a
.
data
,
b
.
data
)
for
a
,
b
in
zip
(
new_out
.
owner
.
inputs
[
2
:],
out
.
owner
.
inputs
[
2
:])
)
assert
np
.
array_equal
(
new_out
.
owner
.
inputs
[
1
]
.
data
,
[])
@config.change_flags
(
compute_test_value
=
"raise"
)
@config.change_flags
(
compute_test_value
=
"raise"
)
@pytest.mark.parametrize
(
@pytest.mark.parametrize
(
"dist_op, dist_params, size"
,
"dist_op, dist_params, size"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论