Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7b35af64
提交
7b35af64
authored
3月 28, 2017
作者:
Alexander Matyasko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add magma to theano config (by default not enabled)
上级
44cb1473
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
40 行增加
和
4 行删除
+40
-4
configdefaults.py
theano/configdefaults.py
+17
-0
linalg.py
theano/gpuarray/linalg.py
+19
-3
opt.py
theano/gpuarray/opt.py
+4
-1
没有找到文件。
theano/configdefaults.py
浏览文件 @
7b35af64
...
@@ -361,6 +361,23 @@ AddConfigVar('dnn.enabled',
...
@@ -361,6 +361,23 @@ AddConfigVar('dnn.enabled',
EnumStr
(
"auto"
,
"True"
,
"False"
,
"no_check"
),
EnumStr
(
"auto"
,
"True"
,
"False"
,
"no_check"
),
in_c_key
=
False
)
in_c_key
=
False
)
AddConfigVar
(
'magma.include_path'
,
"Location of the magma header"
,
StrParam
(
None
),
in_c_key
=
False
)
AddConfigVar
(
'magma.library_path'
,
"Location of the magma library"
,
StrParam
(
None
),
in_c_key
=
False
)
AddConfigVar
(
'magma.enabled'
,
" If True, use magma for matrix computation."
" If False, disable magma"
" If no_check, assume present and the version between header and library match (so less compilation at context init)"
,
BoolParam
(
False
),
in_c_key
=
False
)
# This flag determines whether or not to raise error/warning message if
# This flag determines whether or not to raise error/warning message if
# there is a CPU Op in the computational graph.
# there is a CPU Op in the computational graph.
AddConfigVar
(
AddConfigVar
(
...
...
theano/gpuarray/linalg.py
浏览文件 @
7b35af64
...
@@ -8,7 +8,7 @@ import pkg_resources
...
@@ -8,7 +8,7 @@ import pkg_resources
from
numpy.linalg.linalg
import
LinAlgError
from
numpy.linalg.linalg
import
LinAlgError
import
theano
import
theano
from
theano
import
Op
from
theano
import
Op
,
config
from
theano.gof
import
COp
from
theano.gof
import
COp
from
theano.gpuarray
import
GpuArrayType
from
theano.gpuarray
import
GpuArrayType
...
@@ -365,11 +365,19 @@ class GpuMagmaSVD(COp):
...
@@ -365,11 +365,19 @@ class GpuMagmaSVD(COp):
'gpuarray_helper.h'
,
'magma.h'
]
'gpuarray_helper.h'
,
'magma.h'
]
def
c_header_dirs
(
self
):
def
c_header_dirs
(
self
):
return
[
os
.
path
.
dirname
(
__file__
),
pygpu
.
get_include
()]
dirs
=
[
os
.
path
.
dirname
(
__file__
),
pygpu
.
get_include
()]
if
config
.
magma
.
include_path
:
dirs
.
append
(
config
.
magma
.
include_path
)
return
dirs
def
c_libraries
(
self
):
def
c_libraries
(
self
):
return
[
'magma'
]
return
[
'magma'
]
def
c_lib_dirs
(
self
):
if
config
.
magma
.
library_path
:
return
[
config
.
magma
.
library_path
]
return
[]
def
make_node
(
self
,
A
):
def
make_node
(
self
,
A
):
if
A
.
ndim
!=
2
:
if
A
.
ndim
!=
2
:
raise
LinAlgError
(
"Matrix rank error"
)
raise
LinAlgError
(
"Matrix rank error"
)
...
@@ -430,11 +438,19 @@ class GpuMagmaMatrixInverse(COp):
...
@@ -430,11 +438,19 @@ class GpuMagmaMatrixInverse(COp):
'gpuarray_helper.h'
,
'magma.h'
]
'gpuarray_helper.h'
,
'magma.h'
]
def
c_header_dirs
(
self
):
def
c_header_dirs
(
self
):
return
[
os
.
path
.
dirname
(
__file__
),
pygpu
.
get_include
()]
dirs
=
[
os
.
path
.
dirname
(
__file__
),
pygpu
.
get_include
()]
if
config
.
magma
.
include_path
:
dirs
.
append
(
config
.
magma
.
include_path
)
return
dirs
def
c_libraries
(
self
):
def
c_libraries
(
self
):
return
[
'magma'
]
return
[
'magma'
]
def
c_lib_dirs
(
self
):
if
config
.
magma
.
library_path
:
return
[
config
.
magma
.
library_path
]
return
[]
def
make_node
(
self
,
x
):
def
make_node
(
self
,
x
):
if
x
.
ndim
!=
2
:
if
x
.
ndim
!=
2
:
raise
LinAlgError
(
"Matrix rank error"
)
raise
LinAlgError
(
"Matrix rank error"
)
...
...
theano/gpuarray/opt.py
浏览文件 @
7b35af64
...
@@ -2010,6 +2010,8 @@ def local_inplace_cholesky(node):
...
@@ -2010,6 +2010,8 @@ def local_inplace_cholesky(node):
@op_lifter
([
nlinalg
.
MatrixInverse
])
@op_lifter
([
nlinalg
.
MatrixInverse
])
@register_opt2
([
theano
.
tensor
.
nlinalg
.
MatrixInverse
],
'magma'
,
'fast_compile'
)
@register_opt2
([
theano
.
tensor
.
nlinalg
.
MatrixInverse
],
'magma'
,
'fast_compile'
)
def
local_gpu_matrix_inverse
(
op
,
context_name
,
inputs
,
outputs
):
def
local_gpu_matrix_inverse
(
op
,
context_name
,
inputs
,
outputs
):
if
not
config
.
magma
.
enabled
:
return
return
GpuMagmaMatrixInverse
()
return
GpuMagmaMatrixInverse
()
...
@@ -2017,7 +2019,8 @@ def local_gpu_matrix_inverse(op, context_name, inputs, outputs):
...
@@ -2017,7 +2019,8 @@ def local_gpu_matrix_inverse(op, context_name, inputs, outputs):
@op_lifter
([
nlinalg
.
SVD
])
@op_lifter
([
nlinalg
.
SVD
])
@register_opt2
([
theano
.
tensor
.
nlinalg
.
SVD
],
'magma'
,
'fast_compile'
)
@register_opt2
([
theano
.
tensor
.
nlinalg
.
SVD
],
'magma'
,
'fast_compile'
)
def
local_gpu_svd
(
op
,
context_name
,
inputs
,
outputs
):
def
local_gpu_svd
(
op
,
context_name
,
inputs
,
outputs
):
import
pudb
;
pudb
.
set_trace
()
if
not
config
.
magma
.
enabled
:
return
return
GpuMagmaSVD
(
full_matrices
=
op
.
full_matrices
,
return
GpuMagmaSVD
(
full_matrices
=
op
.
full_matrices
,
compute_uv
=
op
.
compute_uv
)
compute_uv
=
op
.
compute_uv
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论