Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
861f95c2
提交
861f95c2
authored
11月 22, 2023
作者:
Ricardo Vieira
提交者:
Thomas Wiecki
11月 24, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test for Blockwise of COp with params
上级
35f0df96
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
7 行删除
+16
-7
test_blockwise.py
tests/tensor/test_blockwise.py
+16
-7
没有找到文件。
tests/tensor/test_blockwise.py
浏览文件 @
861f95c2
...
@@ -9,10 +9,10 @@ from pytensor import config, function
...
@@ -9,10 +9,10 @@ from pytensor import config, function
from
pytensor.gradient
import
grad
from
pytensor.gradient
import
grad
from
pytensor.graph
import
Apply
,
Op
from
pytensor.graph
import
Apply
,
Op
from
pytensor.graph.replace
import
vectorize_node
from
pytensor.graph.replace
import
vectorize_node
from
pytensor.raise_op
import
assert_op
from
pytensor.tensor
import
diagonal
,
log
,
tensor
from
pytensor.tensor
import
diagonal
,
log
,
tensor
from
pytensor.tensor.blockwise
import
Blockwise
from
pytensor.tensor.blockwise
import
Blockwise
from
pytensor.tensor.nlinalg
import
MatrixInverse
from
pytensor.tensor.nlinalg
import
MatrixInverse
from
pytensor.tensor.shape
import
Shape
from
pytensor.tensor.slinalg
import
Cholesky
,
Solve
,
cholesky
,
solve_triangular
from
pytensor.tensor.slinalg
import
Cholesky
,
Solve
,
cholesky
,
solve_triangular
from
pytensor.tensor.utils
import
_parse_gufunc_signature
from
pytensor.tensor.utils
import
_parse_gufunc_signature
...
@@ -362,11 +362,20 @@ def test_batched_mvnormal_logp_and_dlogp(mu_batch_shape, cov_batch_shape, benchm
...
@@ -362,11 +362,20 @@ def test_batched_mvnormal_logp_and_dlogp(mu_batch_shape, cov_batch_shape, benchm
benchmark
(
fn
,
*
test_values
)
benchmark
(
fn
,
*
test_values
)
def
test_op_with_params
():
def
test_cop_with_params
():
matrix_shape_blockwise
=
Blockwise
(
core_op
=
Shape
(),
signature
=
"(x1,x2)->(s)"
)
matrix_assert
=
Blockwise
(
core_op
=
assert_op
,
signature
=
"(x1,x2),()->(x1,x2)"
)
x
=
tensor
(
"x"
,
shape
=
(
5
,
None
,
None
),
dtype
=
"float64"
)
x
=
tensor
(
"x"
,
shape
=
(
5
,
None
,
None
),
dtype
=
"float64"
)
x_shape
=
matrix_shape_blockwise
(
x
)
x_shape
=
matrix_assert
(
x
,
(
x
>=
0
)
.
all
())
fn
=
pytensor
.
function
([
x
],
x_shape
)
fn
=
pytensor
.
function
([
x
],
x_shape
)
pytensor
.
dprint
(
fn
)
[
fn_out
]
=
fn
.
maker
.
fgraph
.
outputs
# Assert blockwise
assert
fn_out
.
owner
.
op
==
matrix_assert
,
"Blockwise should be in final graph"
print
(
fn
(
np
.
zeros
((
5
,
3
,
2
))))
np
.
testing
.
assert_allclose
(
fn
(
np
.
zeros
((
5
,
3
,
2
))),
np
.
zeros
((
5
,
3
,
2
)),
)
with
pytest
.
raises
(
AssertionError
):
fn
(
np
.
zeros
((
5
,
3
,
2
))
-
1
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论