Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
340c577a
提交
340c577a
authored
8月 29, 2017
作者:
notoraptor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add fallback implementation for BLAS [sd]gemv_.
上级
d66cefe7
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
35 行增加
和
36 行删除
+35
-36
blas_headers.py
theano/tensor/blas_headers.py
+18
-19
alt_blas_common.h
theano/tensor/c_code/alt_blas_common.h
+17
-0
alt_blas_template.c
theano/tensor/c_code/alt_blas_template.c
+0
-0
alt_gemm_common.c
theano/tensor/c_code/alt_gemm_common.c
+0
-17
没有找到文件。
theano/tensor/blas_headers.py
浏览文件 @
340c577a
...
...
@@ -731,29 +731,28 @@ def cblas_header_text():
def
blas_header_text
():
"""C header for the fortran blas interface"""
gemm
_code
=
""
blas
_code
=
""
const
=
"const"
if
not
config
.
blas
.
ldflags
:
# Include the Numpy version implementation of [sd]gemm_.
current_filedir
=
dirname
(
__file__
)
gemm_common_filepath
=
os
.
path
.
join
(
current_filedir
,
'c_code'
,
'alt_gemm_common.c
'
)
gemm_template_filepath
=
os
.
path
.
join
(
current_filedir
,
'c_code'
,
'alt_gemm
_template.c'
)
blas_common_filepath
=
os
.
path
.
join
(
current_filedir
,
'c_code'
,
'alt_blas_common.h
'
)
blas_template_filepath
=
os
.
path
.
join
(
current_filedir
,
'c_code'
,
'alt_blas
_template.c'
)
common_code
=
""
s
gemm
_code
=
""
d
gemm
_code
=
""
with
open
(
gemm
_common_filepath
)
as
code
:
s
blas
_code
=
""
d
blas
_code
=
""
with
open
(
blas
_common_filepath
)
as
code
:
common_code
=
code
.
read
()
with
open
(
gemm
_template_filepath
)
as
code
:
with
open
(
blas
_template_filepath
)
as
code
:
template_code
=
code
.
read
()
sgemm_code
=
template_code
%
{
"float_type"
:
"float"
,
"float_size"
:
4
,
"npy_float"
:
"NPY_FLOAT32"
,
"name"
:
"sgemm_"
}
dgemm_code
=
template_code
%
{
"float_type"
:
"double"
,
"float_size"
:
8
,
"npy_float"
:
"NPY_FLOAT64"
,
"name"
:
"dgemm_"
}
if
not
common_code
or
not
sgemm_code
:
raise
IOError
(
"Unable to load NumPy implementation of gemm code from C source files."
)
else
:
const
=
""
gemm_code
+=
common_code
gemm_code
+=
sgemm_code
gemm_code
+=
dgemm_code
sblas_code
=
template_code
%
{
"float_type"
:
"float"
,
"float_size"
:
4
,
"npy_float"
:
"NPY_FLOAT32"
,
"precision"
:
"s"
}
dblas_code
=
template_code
%
{
"float_type"
:
"double"
,
"float_size"
:
8
,
"npy_float"
:
"NPY_FLOAT64"
,
"precision"
:
"d"
}
if
not
common_code
or
not
template_code
:
raise
IOError
(
"Unable to load NumPy implementation of BLAS functions from C source files."
)
const
=
""
blas_code
+=
common_code
blas_code
+=
sblas_code
blas_code
+=
dblas_code
header
=
"""
extern "C"
...
...
@@ -834,7 +833,7 @@ def blas_header_text():
/* Single Precision */
void sgemv_(char*, const int*, const int*, const float *,
const float *, const int*, const
float *, const int*, const float *, float *, const int*);
void sgemv_(char*, const int*, const int*, const float *,
%(const)
s float *, const int*,
%(const)
s
float *, const int*, const float *, float *, const int*);
void sgbmv_(char*, const int*, const int*, const int*, const int*, const float *, const float *, const int*, const float *, const int*, const float *, float *, const int*);
void ssymv_(char*, const int*, const float *, const float *, const int*, const float *, const int*, const float *, float *, const int*);
void ssbmv_(char*, const int*, const int*, const float *, const float *, const int*, const float *, const int*, const float *, float *, const int*);
...
...
@@ -984,7 +983,7 @@ def blas_header_text():
}
"""
)
return
(
header
%
{
'const'
:
const
})
+
gemm
_code
return
(
header
%
{
'const'
:
const
})
+
blas
_code
def
mkl_threads_text
():
...
...
@@ -1032,7 +1031,7 @@ def openblas_threads_text():
def
blas_header_version
():
# Version for the base header
version
=
(
2
,)
version
=
(
3
,)
if
detect_macos_sdot_bug
():
if
detect_macos_sdot_bug
.
fix_works
:
# Version with fix
...
...
theano/tensor/c_code/alt_blas_common.h
0 → 100644
浏览文件 @
340c577a
/** C Implementation (with NumPy back-end) of BLAS functions used in Theano.
* Used instead of BLAS when Theano flag ``blas.ldflags`` is empty.
* This file contains some useful header code not templated.
* File alt_blas_template.c contains template code for [sd]gemm_ and [sd]gemv_. **/
#define alt_fatal_error(message) { if (PyErr_Occurred()) PyErr_Print(); if(message != NULL) fprintf(stderr, message); exit(-1); }
#define alt_trans_to_bool(trans) (*trans != 'N' && *trans != 'n')
/**Template code for BLAS functions follows in file alt_blas_template.c
* (as Python string to be used with old formatting).
* PARAMETERS:
* float_type: "float" or "double".
* float_size: 4 for float32 (sgemm_), 8 for float64 (dgemm_).
* npy_float: "NPY_FLOAT32" or "NPY_FLOAT64".
* precision: "s" for single, "d" for double.
* See blas_headers.py for current use.**/
theano/tensor/c_code/alt_
gemm
_template.c
→
theano/tensor/c_code/alt_
blas
_template.c
浏览文件 @
340c577a
差异被折叠。
点击展开。
theano/tensor/c_code/alt_gemm_common.c
deleted
100644 → 0
浏览文件 @
d66cefe7
/** C Implementation of [sd]gemm_ based on NumPy
* Used instead of blas when Theano config flag blas.ldflags is empty.
* This file contains the common code for [sd]gemm_.
* File alt_gemm_template.c contains template code for [sd]gemm_. **/
#define alt_fatal_error(message) { if(message != NULL) fprintf(stderr, message); exit(-1); }
#define alt_trans_to_bool(trans) (*trans != 'N' && *trans != 'n')
/**Template code for [sd]gemm_ follows in file alt_gemm_template.c
* (as Python string to be used with old formatting).
* PARAMETERS:
* float_type: "float" for sgemm_, "double" for dgemm_.
* float_size: 4 for float32 (sgemm_), 8 for float64 (dgemm_).
* npy_float: "NPY_FLOAT32" for sgemm_, "NPY_FLOAT64" for dgemm_.
* name: "sgemm_" for sgemm_, "dgemm_" for dgemm_.
* See blas_headers.py for current use.**/
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论