Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6d5cc513
提交
6d5cc513
authored
7月 03, 2023
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
7月 11, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename get_unique_value to get_unique_constant_value
上级
5c87d741
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
11 行增加
和
7 行删除
+11
-7
rewriting.py
pytensor/scan/rewriting.py
+2
-2
basic.py
pytensor/tensor/basic.py
+6
-2
math.py
pytensor/tensor/rewriting/math.py
+2
-2
var.py
pytensor/tensor/var.py
+1
-1
没有找到文件。
pytensor/scan/rewriting.py
浏览文件 @
6d5cc513
...
@@ -69,7 +69,7 @@ from pytensor.tensor.subtensor import (
...
@@ -69,7 +69,7 @@ from pytensor.tensor.subtensor import (
get_slice_elements
,
get_slice_elements
,
set_subtensor
,
set_subtensor
,
)
)
from
pytensor.tensor.var
import
TensorConstant
,
get_unique_value
from
pytensor.tensor.var
import
TensorConstant
,
get_unique_
constant_
value
list_opt_slice
=
[
list_opt_slice
=
[
...
@@ -136,7 +136,7 @@ def remove_constants_and_unused_inputs_scan(fgraph, node):
...
@@ -136,7 +136,7 @@ def remove_constants_and_unused_inputs_scan(fgraph, node):
node_inp
=
node
.
inputs
[
idx
+
1
]
node_inp
=
node
.
inputs
[
idx
+
1
]
if
(
if
(
isinstance
(
node_inp
,
TensorConstant
)
isinstance
(
node_inp
,
TensorConstant
)
and
get_unique_value
(
node_inp
)
is
not
None
and
get_unique_
constant_
value
(
node_inp
)
is
not
None
):
):
try
:
try
:
# This works if input is a constant that has all entries
# This works if input is a constant that has all entries
...
...
pytensor/tensor/basic.py
浏览文件 @
6d5cc513
...
@@ -62,7 +62,11 @@ from pytensor.tensor.type import (
...
@@ -62,7 +62,11 @@ from pytensor.tensor.type import (
uint_dtypes
,
uint_dtypes
,
values_eq_approx_always_true
,
values_eq_approx_always_true
,
)
)
from
pytensor.tensor.var
import
TensorConstant
,
TensorVariable
,
get_unique_value
from
pytensor.tensor.var
import
(
TensorConstant
,
TensorVariable
,
get_unique_constant_value
,
)
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
...
@@ -323,7 +327,7 @@ def get_underlying_scalar_constant_value(
...
@@ -323,7 +327,7 @@ def get_underlying_scalar_constant_value(
raise
NotScalarConstantError
()
raise
NotScalarConstantError
()
if
isinstance
(
v
,
Constant
):
if
isinstance
(
v
,
Constant
):
unique_value
=
get_unique_value
(
v
)
unique_value
=
get_unique_
constant_
value
(
v
)
if
unique_value
is
not
None
:
if
unique_value
is
not
None
:
data
=
unique_value
data
=
unique_value
else
:
else
:
...
...
pytensor/tensor/rewriting/math.py
浏览文件 @
6d5cc513
...
@@ -101,7 +101,7 @@ from pytensor.tensor.type import (
...
@@ -101,7 +101,7 @@ from pytensor.tensor.type import (
values_eq_approx_remove_inf_nan
,
values_eq_approx_remove_inf_nan
,
values_eq_approx_remove_nan
,
values_eq_approx_remove_nan
,
)
)
from
pytensor.tensor.var
import
TensorConstant
,
get_unique_value
from
pytensor.tensor.var
import
TensorConstant
,
get_unique_
constant_
value
def
scalarconsts_rest
(
inputs
,
elemwise
=
True
,
only_process_constants
=
False
):
def
scalarconsts_rest
(
inputs
,
elemwise
=
True
,
only_process_constants
=
False
):
...
@@ -133,7 +133,7 @@ def get_constant(v):
...
@@ -133,7 +133,7 @@ def get_constant(v):
"""
"""
if
isinstance
(
v
,
Constant
):
if
isinstance
(
v
,
Constant
):
unique_value
=
get_unique_value
(
v
)
unique_value
=
get_unique_
constant_
value
(
v
)
if
unique_value
is
not
None
:
if
unique_value
is
not
None
:
data
=
unique_value
data
=
unique_value
else
:
else
:
...
...
pytensor/tensor/var.py
浏览文件 @
6d5cc513
...
@@ -986,7 +986,7 @@ class TensorConstantSignature(tuple):
...
@@ -986,7 +986,7 @@ class TensorConstantSignature(tuple):
return
self
.
_no_nan
return
self
.
_no_nan
def
get_unique_value
(
x
:
TensorVariable
)
->
Optional
[
Number
]:
def
get_unique_
constant_
value
(
x
:
TensorVariable
)
->
Optional
[
Number
]:
"""Return the unique value of a tensor, if there is one"""
"""Return the unique value of a tensor, if there is one"""
if
isinstance
(
x
,
Constant
):
if
isinstance
(
x
,
Constant
):
data
=
x
.
data
data
=
x
.
data
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论