Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5c576b65
提交
5c576b65
authored
2月 06, 2012
作者:
lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #420 from nouiz/mixed
Mixed
上级
375e47a0
e1f91d0c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
46 行增加
和
22 行删除
+46
-22
compiledir.py
theano/gof/compiledir.py
+43
-22
basic.py
theano/sparse/basic.py
+3
-0
没有找到文件。
theano/gof/compiledir.py
浏览文件 @
5c576b65
...
@@ -39,27 +39,28 @@ def filter_compiledir(path):
...
@@ -39,27 +39,28 @@ def filter_compiledir(path):
# 2. The path is stable w.r.t. e.g. symlinks (which makes it easier
# 2. The path is stable w.r.t. e.g. symlinks (which makes it easier
# to re-use compiled modules).
# to re-use compiled modules).
path
=
os
.
path
.
realpath
(
path
)
path
=
os
.
path
.
realpath
(
path
)
valid
=
True
if
os
.
access
(
path
,
os
.
F_OK
):
# Do it exist?
if
not
os
.
access
(
path
,
os
.
R_OK
|
os
.
W_OK
):
if
not
os
.
access
(
path
,
os
.
R_OK
|
os
.
W_OK
|
os
.
X_OK
):
# If it exist we need read, write and listing access
raise
ValueError
(
"compiledir '
%
s' exists but you don't have read, write"
" or listing permissions."
%
path
)
else
:
try
:
try
:
os
.
makedirs
(
path
,
0770
)
# read-write-execute for user and group
os
.
makedirs
(
path
,
0770
)
# read-write-execute for user and group
except
OSError
,
e
:
except
OSError
,
e
:
# Maybe another parallel execution of theano was trying to create
# Maybe another parallel execution of theano was trying to create
# the same directory at the same time.
# the same directory at the same time.
if
e
.
errno
!=
errno
.
EEXIST
:
if
e
.
errno
!=
errno
.
EEXIST
:
valid
=
False
raise
ValueError
(
"Unable to create to create the compiledir directory"
" '
%
s'. Check the permissions."
%
path
)
if
valid
:
# PROBLEM: sometimes the initial approach based on
try
:
# os.system('touch') returned -1 for an unknown reason; the
# PROBLEM: sometimes the initial approach based on
# alternate approach here worked in all cases... it was weird.
# os.system('touch') returned -1 for an unknown reason; the
# No error should happen as we checked the permissions.
# alternate approach here worked in all cases... it was weird.
open
(
os
.
path
.
join
(
path
,
'__init__.py'
),
'w'
)
.
close
()
open
(
os
.
path
.
join
(
path
,
'__init__.py'
),
'w'
)
.
close
()
except
:
valid
=
False
if
not
valid
:
raise
ValueError
(
'Invalid value for compiledir:
%
s'
%
path
)
return
path
return
path
...
@@ -116,11 +117,9 @@ def print_compiledir_content():
...
@@ -116,11 +117,9 @@ def print_compiledir_content():
return
[
a
]
return
[
a
]
compiledir
=
theano
.
config
.
compiledir
compiledir
=
theano
.
config
.
compiledir
print
"List compiled ops in this theano cache:"
,
compiledir
print
"sub directory/Op/Associated Type"
print
table
=
[]
table
=
[]
more_then_one_ops
=
0
zeros_op
=
0
for
dir
in
os
.
listdir
(
compiledir
):
for
dir
in
os
.
listdir
(
compiledir
):
file
=
None
file
=
None
try
:
try
:
...
@@ -129,16 +128,38 @@ def print_compiledir_content():
...
@@ -129,16 +128,38 @@ def print_compiledir_content():
keydata
=
cPickle
.
load
(
file
)
keydata
=
cPickle
.
load
(
file
)
ops
=
list
(
set
([
x
for
x
in
flatten
(
keydata
.
keys
)
ops
=
list
(
set
([
x
for
x
in
flatten
(
keydata
.
keys
)
if
isinstance
(
x
,
theano
.
gof
.
Op
)]))
if
isinstance
(
x
,
theano
.
gof
.
Op
)]))
assert
len
(
ops
)
==
1
if
len
(
ops
)
==
0
:
types
=
list
(
set
([
x
for
x
in
flatten
(
keydata
.
keys
)
zeros_op
+=
1
if
isinstance
(
x
,
theano
.
gof
.
Type
)]))
elif
len
(
ops
)
>
1
:
table
.
append
((
dir
,
ops
[
0
],
types
))
more_then_one_ops
+=
1
else
:
types
=
list
(
set
([
x
for
x
in
flatten
(
keydata
.
keys
)
if
isinstance
(
x
,
theano
.
gof
.
Type
)]))
table
.
append
((
dir
,
ops
[
0
],
types
))
except
IOError
:
except
IOError
:
pass
pass
finally
:
finally
:
if
file
is
not
None
:
if
file
is
not
None
:
file
.
close
()
file
.
close
()
print
"List
%
d compiled individual op in this theano cache
%
s:"
%
(
len
(
table
),
compiledir
)
print
"sub directory/Op/a set of the different associated Theano type"
table
=
sorted
(
table
,
key
=
lambda
t
:
str
(
t
[
1
]))
table
=
sorted
(
table
,
key
=
lambda
t
:
str
(
t
[
1
]))
table_op_class
=
{}
for
dir
,
op
,
types
in
table
:
for
dir
,
op
,
types
in
table
:
print
dir
,
op
,
types
print
dir
,
op
,
types
table_op_class
.
setdefault
(
op
.
__class__
,
0
)
table_op_class
[
op
.
__class__
]
+=
1
print
print
"List
%
d of individual compiled Op class and"
%
(
len
(
table_op_class
)),
print
" the number of time it got compiled"
table_op_class
=
sorted
(
table_op_class
.
iteritems
(),
key
=
lambda
t
:
t
[
1
])
for
op_class
,
nb
in
table_op_class
:
print
op_class
,
nb
print
(
"Skipped
%
d files that contained more then"
" 1 op (was compiled with the c linker)"
%
(
more_then_one_ops
))
print
(
"Skipped
%
d files that contained 0 op"
"(Are they always theano.scalar ops?)"
%
(
more_then_one_ops
))
theano/sparse/basic.py
浏览文件 @
5c576b65
...
@@ -720,6 +720,9 @@ dense_from_sparse = DenseFromSparse()
...
@@ -720,6 +720,9 @@ dense_from_sparse = DenseFromSparse()
class
SparseFromDense
(
gof
.
op
.
Op
):
class
SparseFromDense
(
gof
.
op
.
Op
):
"""
Convert an `ndarray` matrix to a sparse matrix.
"""
def
__init__
(
self
,
format
):
def
__init__
(
self
,
format
):
self
.
format
=
format
self
.
format
=
format
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论