Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f4d876e9
提交
f4d876e9
authored
12月 18, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more and keep more values_eq_approx
上级
f4e42e17
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
2 行删除
+29
-2
opt.py
theano/gpuarray/opt.py
+5
-1
sort.py
theano/gpuarray/sort.py
+24
-1
没有找到文件。
theano/gpuarray/opt.py
浏览文件 @
f4d876e9
...
@@ -183,7 +183,11 @@ gpu_optimizer.register('local_remove_all_assert',
...
@@ -183,7 +183,11 @@ gpu_optimizer.register('local_remove_all_assert',
# in order to avoid introducin new CPU Ops, or useless ones.
# in order to avoid introducin new CPU Ops, or useless ones.
def
safe_to_gpu
(
x
,
ctx_name
):
def
safe_to_gpu
(
x
,
ctx_name
):
if
isinstance
(
x
.
type
,
tensor
.
TensorType
):
if
isinstance
(
x
.
type
,
tensor
.
TensorType
):
return
GpuFromHost
(
ctx_name
)(
x
)
ret
=
GpuFromHost
(
ctx_name
)(
x
)
values_eq_approx
=
getattr
(
x
.
tag
,
'values_eq_approx'
,
None
)
if
values_eq_approx
:
ret
.
tag
.
values_eq_approx
=
values_eq_approx
return
ret
else
:
else
:
return
x
return
x
...
...
theano/gpuarray/sort.py
浏览文件 @
f4d876e9
...
@@ -2,6 +2,9 @@ from __future__ import absolute_import, print_function, division
...
@@ -2,6 +2,9 @@ from __future__ import absolute_import, print_function, division
import
os
import
os
from
string
import
Template
from
string
import
Template
import
numpy
as
np
import
theano
from
theano
import
Apply
from
theano
import
Apply
from
theano.tensor
import
as_tensor_variable
from
theano.tensor
import
as_tensor_variable
from
theano.tensor.sort
import
TopKOp
from
theano.tensor.sort
import
TopKOp
...
@@ -333,6 +336,21 @@ class GpuTopKOp(GpuKernelBase, TopKOp):
...
@@ -333,6 +336,21 @@ class GpuTopKOp(GpuKernelBase, TopKOp):
return
node
.
inputs
[
0
]
.
type
.
context
return
node
.
inputs
[
0
]
.
type
.
context
class
ValuesEqApproxNoOrder
():
"""
We ignore the order of elements on a given axis during the comparison.
"""
def
__init__
(
self
,
axis
):
self
.
axis
=
axis
def
__call__
(
self
,
val1
,
val2
):
v1
=
np
.
sort
(
val1
,
axis
=
self
.
axis
)
v2
=
np
.
sort
(
val2
,
axis
=
self
.
axis
)
ret
=
theano
.
tensor
.
type
.
values_eq_approx
(
v1
,
v2
)
return
ret
@register_opt
(
'fast_compile'
)
@register_opt
(
'fast_compile'
)
@op_lifter
([
TopKOp
],
cuda_only
=
True
)
@op_lifter
([
TopKOp
],
cuda_only
=
True
)
@register_opt2
([
TopKOp
],
'fast_compile'
)
@register_opt2
([
TopKOp
],
'fast_compile'
)
...
@@ -350,5 +368,10 @@ def local_gpua_topkop(op, ctx_name, inputs, outputs):
...
@@ -350,5 +368,10 @@ def local_gpua_topkop(op, ctx_name, inputs, outputs):
idx_dtype
=
op
.
idx_dtype
,
idx_dtype
=
op
.
idx_dtype
,
return_values
=
rv
,
return_values
=
rv
,
return_indices
=
ri
)
return_indices
=
ri
)
rets
=
gpu_op
(
x
,
k
)
rets
=
gpu_op
(
x
,
k
,
return_list
=
True
)
c
=
ValuesEqApproxNoOrder
(
axis
)
if
rv
or
ri
:
rets
[
0
]
.
tag
.
values_eq_approx
=
c
if
rv
and
ri
:
rets
[
1
]
.
tag
.
values_eq_approx
=
c
return
rets
return
rets
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论