Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2e9d502f
Unverified
提交
2e9d502f
authored
3月 24, 2025
作者:
Abhinav Khot
提交者:
GitHub
3月 24, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix `get_vector_length` incorrectly returning for shared variable without static shape (#1295)
上级
9e603cf4
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
10 行增加
和
9 行删除
+10
-9
sharedvar.py
pytensor/tensor/sharedvar.py
+0
-6
test_extra_ops.py
tests/tensor/test_extra_ops.py
+4
-2
test_sharedvar.py
tests/tensor/test_sharedvar.py
+6
-1
没有找到文件。
pytensor/tensor/sharedvar.py
浏览文件 @
2e9d502f
...
...
@@ -3,7 +3,6 @@ import warnings
import
numpy
as
np
from
pytensor.compile
import
SharedVariable
,
shared_constructor
from
pytensor.tensor
import
_get_vector_length
from
pytensor.tensor.type
import
TensorType
from
pytensor.tensor.variable
import
TensorVariable
...
...
@@ -51,11 +50,6 @@ class TensorSharedVariable(SharedVariable, TensorVariable):
self
.
container
.
value
=
0
*
self
.
container
.
value
@_get_vector_length.register
(
TensorSharedVariable
)
def
_get_vector_length_TensorSharedVariable
(
var_inst
,
var
):
return
len
(
var
.
get_value
(
borrow
=
True
))
@shared_constructor.register
(
np
.
ndarray
)
def
tensor_constructor
(
value
,
...
...
tests/tensor/test_extra_ops.py
浏览文件 @
2e9d502f
...
...
@@ -965,8 +965,10 @@ class TestUnravelIndex(utt.InferShapeTester):
f_array_array
=
fn
(
indices
,
shape_array
)
np
.
testing
.
assert_equal
(
ref
,
f_array_array
())
# shape given as an PyTensor variable
shape_symb
=
pytensor
.
shared
(
shape_array
)
# shape given as a shared PyTensor variable with static shape
shape_symb
=
pytensor
.
shared
(
shape_array
,
shape
=
shape_array
.
shape
,
strict
=
True
)
f_array_symb
=
fn
(
indices
,
shape_symb
)
np
.
testing
.
assert_equal
(
ref
,
f_array_symb
())
...
...
tests/tensor/test_sharedvar.py
浏览文件 @
2e9d502f
...
...
@@ -605,6 +605,7 @@ def makeSharedTester(
def
test_values_eq
(
self
):
# Test the type.values_eq[_approx] function
dtype
=
self
.
dtype
if
dtype
is
None
:
dtype
=
pytensor
.
config
.
floatX
...
...
@@ -691,9 +692,13 @@ def test_scalar_shared_deprecated():
def
test_get_vector_length
():
x
=
pytensor
.
shared
(
np
.
array
((
2
,
3
,
4
,
5
)))
arr
=
np
.
array
((
2
,
3
,
4
,
5
))
x
=
pytensor
.
shared
(
arr
,
shape
=
arr
.
shape
,
strict
=
True
)
assert
get_vector_length
(
x
)
==
4
with
pytest
.
raises
(
ValueError
):
get_vector_length
(
pytensor
.
shared
(
arr
))
def
test_shared_masked_array_not_implemented
():
x
=
np
.
ma
.
masked_greater
(
np
.
array
([
1
,
2
,
3
,
4
]),
3
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论