Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8d809317
提交
8d809317
authored
1月 26, 2017
作者:
Benjamin Scellier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
file theano/gpuarray/subtensor.py
上级
671275d9
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
21 行删除
+21
-21
subtensor.py
theano/gpuarray/subtensor.py
+21
-21
没有找到文件。
theano/gpuarray/subtensor.py
浏览文件 @
8d809317
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
import
os
import
os
import
numpy
import
numpy
as
np
from
six
import
integer_types
from
six
import
integer_types
from
six.moves
import
StringIO
from
six.moves
import
StringIO
...
@@ -128,7 +128,7 @@ class GpuSubtensor(HideC, Subtensor):
...
@@ -128,7 +128,7 @@ class GpuSubtensor(HideC, Subtensor):
def
fix_idx
(
idx
):
def
fix_idx
(
idx
):
if
idx
is
None
:
if
idx
is
None
:
return
"0"
,
1
return
"0"
,
1
elif
isinstance
(
idx
,
(
n
umpy
.
integer
,
integer_types
)):
elif
isinstance
(
idx
,
(
n
p
.
integer
,
integer_types
)):
return
str
(
idx
),
0
return
str
(
idx
),
0
elif
isinstance
(
idx
,
gof
.
Type
):
elif
isinstance
(
idx
,
gof
.
Type
):
return
indices
.
pop
(
0
),
0
return
indices
.
pop
(
0
),
0
...
@@ -155,7 +155,7 @@ class GpuSubtensor(HideC, Subtensor):
...
@@ -155,7 +155,7 @@ class GpuSubtensor(HideC, Subtensor):
else
:
else
:
if
isinstance
(
idx
,
gof
.
Type
):
if
isinstance
(
idx
,
gof
.
Type
):
start
=
indices
.
pop
(
0
)
start
=
indices
.
pop
(
0
)
elif
isinstance
(
idx
,
(
n
umpy
.
integer
,
integer_types
)):
elif
isinstance
(
idx
,
(
n
p
.
integer
,
integer_types
)):
start
=
idx
start
=
idx
else
:
else
:
assert
0
,
idx
assert
0
,
idx
...
@@ -511,7 +511,7 @@ class GpuAdvancedSubtensor(HideC, tensor.AdvancedSubtensor):
...
@@ -511,7 +511,7 @@ class GpuAdvancedSubtensor(HideC, tensor.AdvancedSubtensor):
# if there are more than one (narray > 1) it should be ignored.
# if there are more than one (narray > 1) it should be ignored.
ap
=
0
ap
=
0
for
k
,
i
in
enumerate
(
list
(
nidx
)):
for
k
,
i
in
enumerate
(
list
(
nidx
)):
if
(
isinstance
(
i
,
n
umpy
.
ndarray
)
and
if
(
isinstance
(
i
,
n
p
.
ndarray
)
and
i
.
ndim
!=
0
):
i
.
ndim
!=
0
):
transp
.
remove
(
k
)
transp
.
remove
(
k
)
transp
.
insert
(
p
,
k
)
transp
.
insert
(
p
,
k
)
...
@@ -545,7 +545,7 @@ class GpuAdvancedSubtensor(HideC, tensor.AdvancedSubtensor):
...
@@ -545,7 +545,7 @@ class GpuAdvancedSubtensor(HideC, tensor.AdvancedSubtensor):
x
=
x
.
__getitem__
(
idx_
)
x
=
x
.
__getitem__
(
idx_
)
# flatten the array-indexed dimensions
# flatten the array-indexed dimensions
shape
=
((
n
umpy
.
prod
(
x
.
shape
[
0
:
p
]),)
+
shape
=
((
n
p
.
prod
(
x
.
shape
[
0
:
p
]),)
+
x
.
shape
[
p
:])
x
.
shape
[
p
:])
input_flat
=
x
.
reshape
(
shape
)
input_flat
=
x
.
reshape
(
shape
)
...
@@ -644,7 +644,7 @@ class GpuAdvancedIncSubtensor1(Op):
...
@@ -644,7 +644,7 @@ class GpuAdvancedIncSubtensor1(Op):
# content to index x and y (This is because we serve as
# content to index x and y (This is because we serve as
# fallback for _dev20).
# fallback for _dev20).
if
isinstance
(
idx
,
gpuarray
.
GpuArray
):
if
isinstance
(
idx
,
gpuarray
.
GpuArray
):
idx
=
n
umpy
.
asarray
(
idx
)
idx
=
n
p
.
asarray
(
idx
)
# If `y` has as many dimensions as `x`, then we want to iterate
# If `y` has as many dimensions as `x`, then we want to iterate
# jointly on `x` and `y`. Otherwise, it means `y` should be
# jointly on `x` and `y`. Otherwise, it means `y` should be
...
@@ -877,10 +877,10 @@ if (GpuArray_vector_add_fast(%(out)s, %(y)s, %(ind)s, %(set_instead_of_inc)s)) {
...
@@ -877,10 +877,10 @@ if (GpuArray_vector_add_fast(%(out)s, %(y)s, %(ind)s, %(set_instead_of_inc)s)) {
dtype_y
=
node
.
inputs
[
1
]
.
dtype
dtype_y
=
node
.
inputs
[
1
]
.
dtype
dtype_ind
=
node
.
inputs
[
2
]
.
dtype
dtype_ind
=
node
.
inputs
[
2
]
.
dtype
dtype_out
=
node
.
outputs
[
0
]
.
dtype
dtype_out
=
node
.
outputs
[
0
]
.
dtype
itemsize_x
=
n
umpy
.
dtype
(
dtype_x
)
.
itemsize
itemsize_x
=
n
p
.
dtype
(
dtype_x
)
.
itemsize
itemsize_y
=
n
umpy
.
dtype
(
dtype_y
)
.
itemsize
itemsize_y
=
n
p
.
dtype
(
dtype_y
)
.
itemsize
itemsize_ind
=
n
umpy
.
dtype
(
dtype_ind
)
.
itemsize
itemsize_ind
=
n
p
.
dtype
(
dtype_ind
)
.
itemsize
itemsize_out
=
n
umpy
.
dtype
(
dtype_out
)
.
itemsize
itemsize_out
=
n
p
.
dtype
(
dtype_out
)
.
itemsize
flags
=
Kernel
.
get_flags
(
dtype_x
,
dtype_y
,
dtype_ind
)
flags
=
Kernel
.
get_flags
(
dtype_x
,
dtype_y
,
dtype_ind
)
type_x
=
gpuarray
.
dtype_to_ctype
(
dtype_x
)
type_x
=
gpuarray
.
dtype_to_ctype
(
dtype_x
)
type_y
=
gpuarray
.
dtype_to_ctype
(
dtype_y
)
type_y
=
gpuarray
.
dtype_to_ctype
(
dtype_y
)
...
@@ -1007,10 +1007,10 @@ __device__ ga_half atomicExch(ga_half *addr, ga_half val) {
...
@@ -1007,10 +1007,10 @@ __device__ ga_half atomicExch(ga_half *addr, ga_half val) {
dtype_y
=
node
.
inputs
[
1
]
.
dtype
dtype_y
=
node
.
inputs
[
1
]
.
dtype
dtype_ind
=
node
.
inputs
[
2
]
.
dtype
dtype_ind
=
node
.
inputs
[
2
]
.
dtype
dtype_out
=
node
.
outputs
[
0
]
.
dtype
dtype_out
=
node
.
outputs
[
0
]
.
dtype
itemsize_x
=
n
umpy
.
dtype
(
dtype_x
)
.
itemsize
itemsize_x
=
n
p
.
dtype
(
dtype_x
)
.
itemsize
itemsize_y
=
n
umpy
.
dtype
(
dtype_y
)
.
itemsize
itemsize_y
=
n
p
.
dtype
(
dtype_y
)
.
itemsize
itemsize_ind
=
n
umpy
.
dtype
(
dtype_ind
)
.
itemsize
itemsize_ind
=
n
p
.
dtype
(
dtype_ind
)
.
itemsize
itemsize_out
=
n
umpy
.
dtype
(
dtype_out
)
.
itemsize
itemsize_out
=
n
p
.
dtype
(
dtype_out
)
.
itemsize
k_var
=
"k_vector_add_fast_"
+
nodename
k_var
=
"k_vector_add_fast_"
+
nodename
return
super
(
GpuAdvancedIncSubtensor1_dev20
,
self
)
.
c_support_code_struct
(
node
,
nodename
)
+
"""
return
super
(
GpuAdvancedIncSubtensor1_dev20
,
self
)
.
c_support_code_struct
(
node
,
nodename
)
+
"""
...
@@ -1112,7 +1112,7 @@ class GpuDiagonal(Subtensor):
...
@@ -1112,7 +1112,7 @@ class GpuDiagonal(Subtensor):
if
x
.
size
==
0
:
if
x
.
size
==
0
:
out_shape
=
[
d
for
i
,
d
in
enumerate
(
x
.
shape
)
out_shape
=
[
d
for
i
,
d
in
enumerate
(
x
.
shape
)
if
i
not
in
(
self
.
axis1
,
self
.
axis2
)]
if
i
not
in
(
self
.
axis1
,
self
.
axis2
)]
diag_size
=
n
umpy
.
min
((
x
.
shape
[
self
.
axis1
],
x
.
shape
[
self
.
axis2
]))
diag_size
=
n
p
.
min
((
x
.
shape
[
self
.
axis1
],
x
.
shape
[
self
.
axis2
]))
out_shape
.
append
(
diag_size
)
out_shape
.
append
(
diag_size
)
z
[
0
]
=
node
.
outputs
[
0
]
.
type
.
value_zeros
(
tuple
(
out_shape
))
z
[
0
]
=
node
.
outputs
[
0
]
.
type
.
value_zeros
(
tuple
(
out_shape
))
return
return
...
@@ -1128,15 +1128,15 @@ class GpuDiagonal(Subtensor):
...
@@ -1128,15 +1128,15 @@ class GpuDiagonal(Subtensor):
if
x
.
shape
[
stride_axis
]
<
x
.
shape
[
slice_axis
]:
if
x
.
shape
[
stride_axis
]
<
x
.
shape
[
slice_axis
]:
# in the bigger triangle
# in the bigger triangle
numstride
=
small_axis
-
n
umpy
.
max
((
numstride
=
small_axis
-
n
p
.
max
((
0
,
small_axis
+
n
umpy
.
abs
(
self
.
offset
)
-
large_axis
))
0
,
small_axis
+
n
p
.
abs
(
self
.
offset
)
-
large_axis
))
else
:
else
:
# in the smaller triangle
# in the smaller triangle
numstride
=
small_axis
-
n
umpy
.
abs
(
self
.
offset
)
numstride
=
small_axis
-
n
p
.
abs
(
self
.
offset
)
slicer
=
[
n
umpy
.
s_
[:],
]
*
x
.
ndim
slicer
=
[
n
p
.
s_
[:],
]
*
x
.
ndim
slicer
[
stride_axis
]
=
n
umpy
.
s_
[:
numstride
]
slicer
[
stride_axis
]
=
n
p
.
s_
[:
numstride
]
slicer
[
slice_axis
]
=
n
umpy
.
abs
(
self
.
offset
)
slicer
[
slice_axis
]
=
n
p
.
abs
(
self
.
offset
)
slicer
=
tuple
(
slicer
)
slicer
=
tuple
(
slicer
)
# step 2) Swap stride_axis to the last dim because we want the dim on
# step 2) Swap stride_axis to the last dim because we want the dim on
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论