Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a1e290b7
提交
a1e290b7
authored
7月 13, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3128 from harlouci/flake8_sparse
Flake8 sparse
上级
11a78c73
21887b7d
全部展开
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
17 行增加
和
14 行删除
+17
-14
basic.py
theano/sparse/basic.py
+0
-0
opt.py
theano/sparse/opt.py
+17
-11
type.py
theano/sparse/type.py
+0
-0
test_flake8.py
theano/tests/test_flake8.py
+0
-3
没有找到文件。
theano/sparse/basic.py
浏览文件 @
a1e290b7
差异被折叠。
点击展开。
theano/sparse/opt.py
浏览文件 @
a1e290b7
...
@@ -12,6 +12,7 @@ from theano.sparse import (CSC, CSR, csm_properties,
...
@@ -12,6 +12,7 @@ from theano.sparse import (CSC, CSR, csm_properties,
from
theano.sparse
import
basic
as
sparse
from
theano.sparse
import
basic
as
sparse
_is_sparse_variable
=
sparse
.
_is_sparse_variable
_is_sparse_variable
=
sparse
.
_is_sparse_variable
_is_dense
=
sparse
.
_is_dense
# This is tested in tests/test_opt.py:test_local_csm_properties_csm
# This is tested in tests/test_opt.py:test_local_csm_properties_csm
...
@@ -47,7 +48,8 @@ def local_inplace_remove0(node):
...
@@ -47,7 +48,8 @@ def local_inplace_remove0(node):
return
[
new_node
]
return
[
new_node
]
return
False
return
False
theano
.
compile
.
optdb
.
register
(
'local_inplace_remove0'
,
theano
.
compile
.
optdb
.
register
(
'local_inplace_remove0'
,
gof
.
TopoOptimizer
(
local_inplace_remove0
,
gof
.
TopoOptimizer
(
local_inplace_remove0
,
failure_callback
=
gof
.
TopoOptimizer
.
warn_inplace
),
failure_callback
=
gof
.
TopoOptimizer
.
warn_inplace
),
60
,
'fast_run'
,
'inplace'
)
60
,
'fast_run'
,
'inplace'
)
...
@@ -174,7 +176,8 @@ def local_inplace_addsd_ccode(node):
...
@@ -174,7 +176,8 @@ def local_inplace_addsd_ccode(node):
inplace
=
True
)(
*
node
.
inputs
)
inplace
=
True
)(
*
node
.
inputs
)
return
[
new_node
]
return
[
new_node
]
return
False
return
False
theano
.
compile
.
optdb
.
register
(
'local_inplace_addsd_ccode'
,
theano
.
compile
.
optdb
.
register
(
'local_inplace_addsd_ccode'
,
gof
.
TopoOptimizer
(
local_inplace_addsd_ccode
,
gof
.
TopoOptimizer
(
local_inplace_addsd_ccode
,
failure_callback
=
gof
.
TopoOptimizer
.
warn_inplace
),
failure_callback
=
gof
.
TopoOptimizer
.
warn_inplace
),
60
,
'fast_run'
,
'inplace'
)
60
,
'fast_run'
,
'inplace'
)
...
@@ -234,7 +237,8 @@ class StructuredDotCSC(gof.Op):
...
@@ -234,7 +237,8 @@ class StructuredDotCSC(gof.Op):
def
make_node
(
self
,
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
):
def
make_node
(
self
,
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
):
dtype_out
=
scalar
.
upcast
(
a_val
.
type
.
dtype
,
b
.
type
.
dtype
)
dtype_out
=
scalar
.
upcast
(
a_val
.
type
.
dtype
,
b
.
type
.
dtype
)
r
=
gof
.
Apply
(
self
,
[
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
],
r
=
gof
.
Apply
(
self
,
[
a_val
,
a_ind
,
a_ptr
,
a_nrows
,
b
],
[
tensor
.
tensor
(
dtype_out
,
(
False
,
b
.
type
.
broadcastable
[
1
]))])
[
tensor
.
tensor
(
dtype_out
,
(
False
,
b
.
type
.
broadcastable
[
1
]))])
return
r
return
r
def
perform
(
self
,
node
,
inputs
,
outputs
):
def
perform
(
self
,
node
,
inputs
,
outputs
):
...
@@ -243,7 +247,7 @@ class StructuredDotCSC(gof.Op):
...
@@ -243,7 +247,7 @@ class StructuredDotCSC(gof.Op):
a
=
scipy
.
sparse
.
csc_matrix
((
a_val
,
a_ind
,
a_ptr
),
a
=
scipy
.
sparse
.
csc_matrix
((
a_val
,
a_ind
,
a_ptr
),
(
a_nrows
,
b
.
shape
[
0
]),
(
a_nrows
,
b
.
shape
[
0
]),
copy
=
False
)
copy
=
False
)
#out[0] = a.dot(b)
#
out[0] = a.dot(b)
out
[
0
]
=
theano
.
_asarray
(
a
*
b
,
dtype
=
node
.
outputs
[
0
]
.
type
.
dtype
)
out
[
0
]
=
theano
.
_asarray
(
a
*
b
,
dtype
=
node
.
outputs
[
0
]
.
type
.
dtype
)
assert
_is_dense
(
out
[
0
])
# scipy 0.7 automatically converts to dense
assert
_is_dense
(
out
[
0
])
# scipy 0.7 automatically converts to dense
...
@@ -427,17 +431,18 @@ class StructuredDotCSR(gof.Op):
...
@@ -427,17 +431,18 @@ class StructuredDotCSR(gof.Op):
def
make_node
(
self
,
a_val
,
a_ind
,
a_ptr
,
b
):
def
make_node
(
self
,
a_val
,
a_ind
,
a_ptr
,
b
):
self
.
dtype_out
=
scalar
.
upcast
(
a_val
.
type
.
dtype
,
b
.
type
.
dtype
)
self
.
dtype_out
=
scalar
.
upcast
(
a_val
.
type
.
dtype
,
b
.
type
.
dtype
)
r
=
gof
.
Apply
(
self
,
[
a_val
,
a_ind
,
a_ptr
,
b
],
r
=
gof
.
Apply
(
self
,
[
a_val
,
a_ind
,
a_ptr
,
b
],
[
tensor
.
tensor
(
self
.
dtype_out
,
(
False
,
[
tensor
.
tensor
(
self
.
dtype_out
,
b
.
type
.
broadcastable
[
1
]))])
(
False
,
b
.
type
.
broadcastable
[
1
]))])
return
r
return
r
def
perform
(
self
,
node
,
inputs
,
outputs
):
def
perform
(
self
,
node
,
inputs
,
outputs
):
(
a_val
,
a_ind
,
a_ptr
,
b
)
=
inputs
(
a_val
,
a_ind
,
a_ptr
,
b
)
=
inputs
(
out
,)
=
outputs
(
out
,)
=
outputs
a
=
scipy
.
sparse
.
csr_matrix
((
a_val
,
a_ind
,
a_ptr
),
a
=
scipy
.
sparse
.
csr_matrix
(
(
a_val
,
a_ind
,
a_ptr
),
(
len
(
a_ptr
)
-
1
,
b
.
shape
[
0
]),
(
len
(
a_ptr
)
-
1
,
b
.
shape
[
0
]),
copy
=
True
)
# use view_map before setting this to False
copy
=
True
)
# use view_map before setting this to False
#out[0] = a.dot(b)
#
out[0] = a.dot(b)
out
[
0
]
=
a
*
b
out
[
0
]
=
a
*
b
# scipy 0.7 automatically converts to dense, but not .6 sometimes
# scipy 0.7 automatically converts to dense, but not .6 sometimes
assert
_is_dense
(
out
[
0
])
assert
_is_dense
(
out
[
0
])
...
@@ -653,7 +658,8 @@ class UsmmCscDense(gof.Op):
...
@@ -653,7 +658,8 @@ class UsmmCscDense(gof.Op):
if
dtype_out
!=
z
.
type
.
dtype
:
if
dtype_out
!=
z
.
type
.
dtype
:
z
=
tensor
.
cast
(
z
,
dtype_out
)
z
=
tensor
.
cast
(
z
,
dtype_out
)
r
=
gof
.
Apply
(
self
,
[
alpha
,
x_val
,
x_ind
,
x_ptr
,
x_nrows
,
y
,
z
],
r
=
gof
.
Apply
(
self
,
[
alpha
,
x_val
,
x_ind
,
x_ptr
,
x_nrows
,
y
,
z
],
[
tensor
.
tensor
(
dtype_out
,
(
False
,
y
.
type
.
broadcastable
[
1
]))])
[
tensor
.
tensor
(
dtype_out
,
(
False
,
y
.
type
.
broadcastable
[
1
]))])
return
r
return
r
...
@@ -1019,7 +1025,7 @@ def local_csm_grad_c(node):
...
@@ -1019,7 +1025,7 @@ def local_csm_grad_c(node):
return
[
csm_grad_c
(
*
node
.
inputs
)]
return
[
csm_grad_c
(
*
node
.
inputs
)]
return
False
return
False
# DISABLED AS IT IS BROKEN FOR UNSORTED INDICES!
# DISABLED AS IT IS BROKEN FOR UNSORTED INDICES!
#register_specialize(local_csm_grad_c, 'cxx_only')
#
register_specialize(local_csm_grad_c, 'cxx_only')
class
MulSDCSC
(
gof
.
Op
):
class
MulSDCSC
(
gof
.
Op
):
...
@@ -1572,7 +1578,7 @@ def local_structured_add_s_v(node):
...
@@ -1572,7 +1578,7 @@ def local_structured_add_s_v(node):
x
,
y
=
node
.
inputs
x
,
y
=
node
.
inputs
x_is_sparse_variable
=
_is_sparse_variable
(
x
)
x_is_sparse_variable
=
_is_sparse_variable
(
x
)
#y_is_sparse_variable = _is_sparse_variable(y)
#
y_is_sparse_variable = _is_sparse_variable(y)
if
x_is_sparse_variable
:
if
x_is_sparse_variable
:
svar
=
x
svar
=
x
...
...
theano/sparse/type.py
浏览文件 @
a1e290b7
theano/tests/test_flake8.py
浏览文件 @
a1e290b7
...
@@ -228,10 +228,7 @@ whitelist_flake8 = [
...
@@ -228,10 +228,7 @@ whitelist_flake8 = [
"misc/tests/test_pycuda_example.py"
,
"misc/tests/test_pycuda_example.py"
,
"misc/hooks/reindent.py"
,
"misc/hooks/reindent.py"
,
"misc/hooks/check_whitespace.py"
,
"misc/hooks/check_whitespace.py"
,
"sparse/type.py"
,
"sparse/__init__.py"
,
"sparse/__init__.py"
,
"sparse/opt.py"
,
"sparse/basic.py"
,
"sparse/tests/test_utils.py"
,
"sparse/tests/test_utils.py"
,
"sparse/tests/test_opt.py"
,
"sparse/tests/test_opt.py"
,
"sparse/tests/test_basic.py"
,
"sparse/tests/test_basic.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论