Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
36b6c2d1
提交
36b6c2d1
authored
9月 03, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implementations for In, Out, Mode
上级
85dbd796
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
113 行增加
和
18 行删除
+113
-18
compile.py
compile.py
+112
-18
tensor_random.py
tensor_random.py
+1
-0
没有找到文件。
compile.py
浏览文件 @
36b6c2d1
...
@@ -8,6 +8,118 @@ from copy import copy
...
@@ -8,6 +8,118 @@ from copy import copy
import
tensor_opt
import
tensor_opt
predefined_linkers
=
{
'py'
:
gof
.
PerformLinker
(),
'c'
:
gof
.
CLinker
(),
'c|py'
:
gof
.
OpWiseCLinker
(),
'c&py'
:
gof
.
DualLinker
(
checker
=
check_equal
)
}
default_linker
=
'c|py'
predefined_optimizers
=
{
None
:
lambda
env
:
None
,
'merge'
:
gof
.
MergeOptimizer
(),
'math'
:
gof
.
MergeOptMerge
(
tensor_opt
.
math_optimizer
)
}
default_optimizer
=
'merge'
class
Mode
(
object
):
def
__init__
(
self
,
linker
=
default_linker
,
optimizer
=
default_optimizer
):
self
.
provided_linker
=
linker
self
.
provided_optimizer
=
optimizer
if
isinstance
(
linker
,
str
)
or
linker
is
None
:
linker
=
predefined_linkers
[
linker
]
self
.
linker
=
linker
if
isinstance
(
optimizer
,
str
)
or
optimizer
is
None
:
linker
=
predefined_optimizers
[
optimizer
]
self
.
optimizer
=
optimizer
def
__str__
(
self
):
return
"Mode(linker =
%
s, optimizer =
%
s)"
%
(
self
.
provided_linker
,
self
.
provided_optimizer
)
predefined_modes
=
{
'SANITY_CHECK'
:
Mode
(
'c&py'
,
'math'
),
'FAST_COMPILE'
:
Mode
(
'py'
,
None
),
'FAST_RUN'
:
Mode
(
'c|py'
,
'math'
),
'EXPENSIVE_OPTIMIZATIONS'
:
Mode
(
'c|py'
,
'math'
)
}
default_mode
=
'FAST_RUN'
class
In
(
object
):
def
__init__
(
self
,
result
,
name
=
None
,
value
=
None
,
update
=
None
,
mutable
=
False
,
autoname
=
True
):
"""
result: a Result instance.
This will be assigned a value before running the function,
not computed from its owner.
name: Any type. (If autoname=True, defaults to result.name).
If name is a valid Python identifier, this input can be set by kwarg, and its value
can be accessed by self.<name>.
value: literal or Container
This is the default value of the Input.
update: Result instance
value (see previous) will be replaced with this expression result after each function call.
mutable: Bool (requires value)
True: permit the compiled function to modify the python object being used as the default value.
False: do not permit the compiled function to modify the python object being used as the default value.
autoname: Bool
See the name option.
"""
self
.
result
=
result
self
.
name
=
result
.
name
if
(
autoname
and
name
is
None
)
else
name
self
.
value
=
value
self
.
update
=
update
self
.
mutable
=
mutable
class
Out
(
object
):
def
__init__
(
self
,
result
,
borrow
=
False
):
"""
borrow: set this to True to indicate that a reference to
function's internal storage is OK. A value returned
for this output might be clobbered by running the
function again, but the function might be faster.
"""
self
.
result
=
result
self
.
borrow
=
borrow
# class Supervisor:
# class Supervisor:
...
@@ -103,24 +215,6 @@ import tensor_opt
...
@@ -103,24 +215,6 @@ import tensor_opt
# predefined_linkers = {
# 'py' : gof.PerformLinker(),
# 'c' : gof.CLinker(),
# 'c|py' : gof.OpWiseCLinker(),
# 'c&py' : gof.DualLinker(checker = check_equal)
# }
# default_linker = 'c|py'
# predefined_optimizers = {
# None : lambda env: None,
# 'merge' : gof.MergeOptimizer(),
# 'math' : gof.MergeOptMerge(tensor_opt.math_optimizer)
# }
# default_optimizer = 'merge'
# class FunctionFactory:
# class FunctionFactory:
...
...
tensor_random.py
浏览文件 @
36b6c2d1
...
@@ -100,6 +100,7 @@ normal = random_function(RS.normal, 'float64', 0.0, 1.0)
...
@@ -100,6 +100,7 @@ normal = random_function(RS.normal, 'float64', 0.0, 1.0)
random_integers
=
random_function
(
RS
.
random_integers
,
'int64'
,
0
,
1
)
random_integers
=
random_function
(
RS
.
random_integers
,
'int64'
,
0
,
1
)
# T = tensor
# T = tensor
# import compile
# import compile
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论