Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0761b0b8
提交
0761b0b8
authored
5月 23, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make sure we are clean with the versions used on travis.
上级
65d88e32
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
64 行增加
和
60 行删除
+64
-60
debugmode.py
theano/compile/debugmode.py
+12
-12
function.py
theano/compile/function.py
+3
-3
function_module.py
theano/compile/function_module.py
+4
-4
io.py
theano/compile/io.py
+2
-1
mode.py
theano/compile/mode.py
+3
-3
pfunc.py
theano/compile/pfunc.py
+4
-6
profilemode.py
theano/compile/profilemode.py
+2
-1
sharedvalue.py
theano/compile/sharedvalue.py
+1
-2
sched.py
theano/gof/sched.py
+3
-3
test_utils.py
theano/gof/tests/test_utils.py
+6
-3
type.py
theano/gof/type.py
+2
-3
utils.py
theano/gof/utils.py
+3
-1
vm.py
theano/gof/vm.py
+12
-12
test_fftconv.py
theano/sandbox/cuda/tests/test_fftconv.py
+3
-3
_test_mpi_roundtrip.py
theano/tensor/tests/_test_mpi_roundtrip.py
+2
-1
disturb_mem.py
theano/tests/disturb_mem.py
+2
-2
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
0761b0b8
...
...
@@ -5,13 +5,12 @@
"""
from
__future__
import
print_function
__docformat__
=
"restructuredtext en"
import
copy
import
sys
import
copy_reg
import
gc
from
itertools
import
izip
import
logging
import
numpy
...
...
@@ -31,6 +30,8 @@ from theano.compile.function_module import (
from
theano.compile.mode
import
Mode
,
register_mode
from
theano.compile.ops
import
OutputGuard
__docformat__
=
"restructuredtext en"
AddConfigVar
(
'DebugMode.patience'
,
"Optimize graph this many times to detect inconsistency"
,
IntParam
(
10
,
lambda
i
:
i
>
0
),
...
...
@@ -96,7 +97,6 @@ AddConfigVar('DebugMode.check_preallocated_output_ndim',
IntParam
(
4
,
lambda
i
:
i
>
0
),
in_c_key
=
False
)
import
logging
_logger
=
logging
.
getLogger
(
"theano.compile.debugmode"
)
...
...
@@ -303,9 +303,9 @@ class BadOptimization(DebugModeError):
# N.B. the maximum(..., 1e-8) protects against div by 0 when
# nv == ov == 0
reldiff
=
(
abs_diff
/
numpy
.
m
aximum
(
numpy
.
absolute
(
nv
)
+
numpy
.
absolute
(
ov
),
1e-8
))
reldiff
=
(
abs_diff
/
numpy
.
ma
aximum
(
numpy
.
absolute
(
nv
)
+
numpy
.
absolute
(
ov
),
1e-8
))
print
(
" Max Rel Diff: "
,
numpy
.
max
(
reldiff
),
file
=
ssio
)
print
(
" Mean Rel Diff: "
,
numpy
.
mean
(
reldiff
),
file
=
ssio
)
print
(
" Median Rel Diff: "
,
numpy
.
median
(
reldiff
),
file
=
ssio
)
...
...
@@ -730,8 +730,8 @@ def _optcheck_fgraph(input_specs, output_specs, accept_inplace=False):
# We need to protect all immutable inputs from inplace operations.
fgraph
.
attach_feature
(
Supervisor
(
input
for
spec
,
input
in
zip
(
input_specs
,
fgraph
.
inputs
)
if
not
(
spec
.
mutable
or
(
hasattr
(
fgraph
,
'destroyers'
)
and
fgraph
.
destroyers
(
input
)))))
if
not
(
spec
.
mutable
or
(
hasattr
(
fgraph
,
'destroyers'
)
and
fgraph
.
destroyers
(
input
)))))
for
feature
in
std_fgraph
.
features
:
fgraph
.
attach_feature
(
feature
())
...
...
@@ -1340,9 +1340,9 @@ def _check_preallocated_output(node, thunk, prealloc_modes, def_val,
if
type
(
getattr
(
node
,
'op'
,
None
))
in
ops_with_inner_function
:
fn_attr_name
=
ops_with_inner_function
[
type
(
node
.
op
)]
fn
=
getattr
(
node
.
op
,
fn_attr_name
,
None
)
if
(
not
fn
or
not
hasattr
(
fn
,
'maker'
)
or
not
hasattr
(
fn
.
maker
,
'mode'
)):
if
(
not
fn
or
not
hasattr
(
fn
,
'maker'
)
or
not
hasattr
(
fn
.
maker
,
'mode'
)):
_logger
.
warn
(
'Expected theano function not found in
%
s.
%
s'
,
node
.
op
,
fn_attr_name
)
else
:
...
...
@@ -2251,7 +2251,7 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
inputs
=
[
inputs
]
# Wrap them in In or Out instances if needed.
inputs
=
map
(
self
.
wrap_in
,
inputs
)
,
inputs
=
map
(
self
.
wrap_in
,
inputs
)
outputs
=
map
(
self
.
wrap_out
,
outputs
)
_inputs
=
gof
.
graph
.
inputs
([
o
.
variable
for
o
in
outputs
]
+
[
i
.
update
for
i
in
inputs
...
...
theano/compile/function.py
浏览文件 @
0761b0b8
"""Define the `function` function
"""
__docformat__
=
"restructuredtext en"
import
cPickle
import
logging
_logger
=
logging
.
getLogger
(
'theano.compile.function'
)
import
traceback
as
tb
import
re
...
...
@@ -16,6 +13,9 @@ from numpy import any
import
warnings
from
theano
import
compat
__docformat__
=
"restructuredtext en"
_logger
=
logging
.
getLogger
(
'theano.compile.function'
)
def
function_dump
(
filename
,
inputs
,
outputs
=
None
,
mode
=
None
,
updates
=
None
,
givens
=
None
,
...
...
theano/compile/function_module.py
浏览文件 @
0761b0b8
...
...
@@ -2,8 +2,6 @@
"""
from
__future__
import
print_function
__docformat__
=
"restructuredtext en"
import
copy
import
copy_reg
import
cPickle
...
...
@@ -25,6 +23,8 @@ from theano.gof.op import ops_with_inner_function
import
logging
_logger
=
logging
.
getLogger
(
'theano.compile.function_module'
)
__docformat__
=
"restructuredtext en"
class
UnusedInputError
(
Exception
):
"""
...
...
@@ -1276,8 +1276,8 @@ class FunctionMaker(object):
# - variables that have to be provided (used_inputs)
# - shared variables that will be updated
used_inputs
=
gof
.
graph
.
ancestors
(
([
o
.
variable
for
o
in
outputs
]
+
[
i
.
update
for
i
in
inputs
if
getattr
(
i
,
'update'
,
False
)]),
([
o
.
variable
for
o
in
outputs
]
+
[
i
.
update
for
i
in
inputs
if
getattr
(
i
,
'update'
,
False
)]),
blockers
=
[
i
.
variable
for
i
in
inputs
])
msg
=
(
"theano.function was asked to create a function computing "
...
...
theano/compile/io.py
浏览文件 @
0761b0b8
"""Define `SymbolicInput`, `SymbolicOutput`, `In`, `Out` """
__docformat__
=
'restructuredtext en'
from
theano
import
gof
from
sharedvalue
import
SharedVariable
...
...
@@ -7,6 +6,8 @@ from sharedvalue import SharedVariable
import
logging
_logger
=
logging
.
getLogger
(
"theano.compile.io"
)
__docformat__
=
'restructuredtext en'
class
SymbolicInput
(
object
):
"""
...
...
theano/compile/mode.py
浏览文件 @
0761b0b8
...
...
@@ -48,9 +48,9 @@ def check_equal(x, y):
y
=
y
.
todense
()
if
isinstance
(
x
,
numpy
.
ndarray
)
and
isinstance
(
y
,
numpy
.
ndarray
):
if
(
x
.
dtype
!=
y
.
dtype
or
x
.
shape
!=
y
.
shape
or
numpy
.
any
(
abs
(
x
-
y
)
>
1e-10
)):
if
(
x
.
dtype
!=
y
.
dtype
or
x
.
shape
!=
y
.
shape
or
numpy
.
any
(
abs
(
x
-
y
)
>
1e-10
)):
raise
Exception
(
"Output mismatch."
,
{
'performlinker'
:
x
,
'clinker'
:
y
})
else
:
...
...
theano/compile/pfunc.py
浏览文件 @
0761b0b8
"""Provide a simple user friendly API """
__docformat__
=
'restructuredtext en'
from
theano
import
config
from
theano.compile
import
orig_function
,
In
,
Out
from
theano.compile
import
UnusedInputError
...
...
@@ -13,6 +9,8 @@ from theano.gof import Variable, Constant
import
logging
_logger
=
logging
.
getLogger
(
"theano.compile.pfunc"
)
__docformat__
=
'restructuredtext en'
def
rebuild_collect_shared
(
outputs
,
inputs
=
None
,
...
...
@@ -232,8 +230,8 @@ def rebuild_collect_shared(outputs,
cloned_outputs
.
append
(
Out
(
cloned_v
,
borrow
=
v
.
borrow
))
else
:
raise
TypeError
(
'Outputs must be theano Variable or '
'Out instances. Received '
+
str
(
v
)
+
' of type '
+
str
(
type
(
v
)))
'Out instances. Received '
+
str
(
v
)
+
' of type '
+
str
(
type
(
v
)))
# computed_list.append(cloned_v)
else
:
if
isinstance
(
outputs
,
Variable
):
...
...
theano/compile/profilemode.py
浏览文件 @
0761b0b8
...
...
@@ -12,12 +12,13 @@ from theano.compile.mode import (Mode, register_mode,
predefined_optimizers
)
from
theano.configparser
import
config
,
AddConfigVar
,
IntParam
,
BoolParam
from
theano.compile.function_module
import
FunctionMaker
run_cthunk
=
None
# Will be imported only when needed.
from
profiling
import
ProfileStats
run_cthunk
=
None
# Will be imported only when needed.
import_time
=
time
.
time
()
AddConfigVar
(
'ProfileMode.n_apply_to_print'
,
"Number of apply instances to print by default"
,
IntParam
(
15
,
lambda
i
:
i
>
0
),
...
...
theano/compile/sharedvalue.py
浏览文件 @
0761b0b8
"""Provide a simple user friendly API to Theano-managed memory"""
__docformat__
=
'restructuredtext en'
# Standard imports
import
copy
import
logging
...
...
@@ -12,6 +10,7 @@ import numpy
from
theano.gof
import
Container
,
Variable
,
generic
,
utils
_logger
=
logging
.
getLogger
(
'theano.compile.sharedvalue'
)
__docformat__
=
'restructuredtext en'
class
SharedVariable
(
Variable
):
...
...
theano/gof/sched.py
浏览文件 @
0761b0b8
...
...
@@ -39,9 +39,9 @@ def make_depends():
def
depends
(
pair
):
""" Returns True if a depends on b """
a
,
b
=
pair
return
(
any
(
bout
in
a
.
inputs
for
bout
in
b
.
outputs
)
or
any
(
depends
((
ainp
.
owner
,
b
))
for
ainp
in
a
.
inputs
if
ainp
.
owner
))
return
(
any
(
bout
in
a
.
inputs
for
bout
in
b
.
outputs
)
or
any
(
depends
((
ainp
.
owner
,
b
))
for
ainp
in
a
.
inputs
if
ainp
.
owner
))
return
depends
...
...
theano/gof/tests/test_utils.py
浏览文件 @
0761b0b8
...
...
@@ -36,8 +36,11 @@ def test_give_variables_names_small():
def
test_remove
():
even
=
lambda
x
:
x
%
2
==
0
odd
=
lambda
x
:
x
%
2
==
1
# The list are neede as with python 3, remove and filter return generators
def
even
(
x
):
return
x
%
2
==
0
def
odd
(
x
):
return
x
%
2
==
1
# The list are needed as with python 3, remove and filter return generators
# and we can't compare generators.
assert
list
(
remove
(
even
,
range
(
5
)))
==
list
(
filter
(
odd
,
range
(
5
)))
theano/gof/type.py
浏览文件 @
0761b0b8
"""WRITEME Defines the `Type` class."""
__docformat__
=
"restructuredtext en"
from
theano.compat
import
PY3
from
theano.gof
import
utils
...
...
@@ -13,6 +10,8 @@ from theano.gof import graph
########
from
theano.gof.op
import
CLinkerObject
__docformat__
=
"restructuredtext en"
class
CLinkerType
(
CLinkerObject
):
"""Interface specification for Types that can be arguments to a `CLinkerOp`.
...
...
theano/gof/utils.py
浏览文件 @
0761b0b8
...
...
@@ -405,7 +405,9 @@ def give_variables_names(variables):
This function is idempotent."""
names
=
map
(
lambda
var
:
var
.
name
,
variables
)
h
=
hist
(
names
)
bad_var
=
lambda
var
:
not
var
.
name
or
h
[
var
.
name
]
>
1
def
bad_var
(
var
):
return
not
var
.
name
or
h
[
var
.
name
]
>
1
for
i
,
var
in
enumerate
(
filter
(
bad_var
,
variables
)):
var
.
name
=
(
var
.
name
or
""
)
+
"_
%
d"
%
i
...
...
theano/gof/vm.py
浏览文件 @
0761b0b8
...
...
@@ -93,11 +93,11 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re,
for
ins
in
node
.
inputs
:
assert
not
(
ins
in
view_of
and
viewed_by
[
ins
])
if
(
getattr
(
ins
,
'ndim'
,
None
)
==
0
and
not
storage_map
[
ins
][
0
]
and
ins
not
in
fgraph
.
outputs
and
ins
.
owner
a
nd
a
ll
([
compute_map_re
[
v
][
0
]
for
v
in
dependencies
.
get
(
ins
,
[])])
and
ins
not
in
allocated
):
if
(
getattr
(
ins
,
'ndim'
,
None
)
==
0
and
not
storage_map
[
ins
][
0
]
and
ins
not
in
fgraph
.
outputs
and
ins
.
owner
and
all
([
compute_map_re
[
v
][
0
]
for
v
in
dependencies
.
get
(
ins
,
[])])
and
ins
not
in
allocated
):
# Constant Memory cannot be changed
# Constant and shared variables' storage_map value is not empty
reuse_out
=
None
...
...
@@ -526,9 +526,9 @@ class Stack(VM):
for
i
in
current_apply
.
inputs
:
# Garbage Collection -> check if anybody else uses
# this input
if
(
dependencies
[
i
]
and
i
.
owner
and
i
not
in
self
.
outputs
):
if
(
dependencies
[
i
]
and
i
.
owner
and
i
not
in
self
.
outputs
):
if
all
(
compute_map
[
v
][
0
]
for
v
in
dependencies
[
i
]):
storage_map
[
i
][
0
]
=
None
...
...
@@ -1034,10 +1034,10 @@ class VM_Linker(link.LocalLinker):
for
node
in
order
:
clear_after_this_thunk
=
[]
for
input
in
node
.
inputs
:
if
(
(
input
in
computed
)
and
(
input
not
in
fgraph
.
outputs
)
and
(
node
==
last_user
[
input
])
and
input
not
in
reallocated_info
.
keys
()):
if
(
input
in
computed
and
input
not
in
fgraph
.
outputs
and
node
==
last_user
[
input
]
and
input
not
in
reallocated_info
.
keys
()):
clear_after_this_thunk
.
append
(
storage_map
[
input
])
post_thunk_clear
.
append
(
clear_after_this_thunk
)
else
:
...
...
theano/sandbox/cuda/tests/test_fftconv.py
浏览文件 @
0761b0b8
...
...
@@ -7,13 +7,13 @@ from theano.tests import unittest_tools as utt
# Skip tests if cuda_ndarray is not available.
from
nose.plugins.skip
import
SkipTest
import
theano.sandbox.cuda
as
cuda_ndarray
if
not
cuda_ndarray
.
cuda_available
:
if
not
cuda_ndarray
.
cuda_available
:
# noqa
raise
SkipTest
(
'Optional package cuda not available'
)
from
theano.misc.pycuda_init
import
pycuda_available
if
not
pycuda_available
:
if
not
pycuda_available
:
# noqa
raise
SkipTest
(
'Optional package pycuda not available'
)
from
theano.sandbox.cuda.fftconv
import
scikits_cuda_available
if
not
scikits_cuda_available
:
if
not
scikits_cuda_available
:
# noqa
raise
SkipTest
(
'Optional package scikits.cuda not available'
)
from
theano.sandbox.cuda
import
float32_shared_constructor
as
shared
...
...
theano/tensor/tests/_test_mpi_roundtrip.py
浏览文件 @
0761b0b8
...
...
@@ -2,13 +2,14 @@
# mpiexec -np 2 python _test_mpi_roundtrip.py
from
mpi4py
import
MPI
comm
=
MPI
.
COMM_WORLD
import
theano
from
theano.tensor.io
import
send
,
recv
,
mpi_cmps
from
theano.gof.sched
import
sort_schedule_fn
import
numpy
as
np
from
sys
import
stdout
,
stderr
,
exit
comm
=
MPI
.
COMM_WORLD
rank
=
comm
.
Get_rank
()
size
=
comm
.
Get_size
()
...
...
theano/tests/disturb_mem.py
浏览文件 @
0761b0b8
from
datetime
import
datetime
__authors__
=
"Ian Goodfellow"
__credits__
=
[
"Ian Goodfellow"
]
__license__
=
"3-clause BSD"
__maintainer__
=
"Ian Goodfellow"
__email__
=
"goodfeli@iro"
from
datetime
import
datetime
def
disturb_mem
():
# Allocate a time-dependent amount of objects to increase
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论