Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0cbdf291
提交
0cbdf291
authored
5月 03, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Type.get_size() fct to help during profiling.
This add the size of the RandomType.
上级
25a45105
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
25 行增加
和
9 行删除
+25
-9
profiling.py
theano/compile/profiling.py
+3
-9
type.py
theano/sandbox/cuda/type.py
+3
-0
basic.py
theano/tensor/basic.py
+3
-0
raw_random.py
theano/tensor/raw_random.py
+16
-0
没有找到文件。
theano/compile/profiling.py
浏览文件 @
0cbdf291
...
@@ -603,12 +603,8 @@ class ProfileStats(object):
...
@@ -603,12 +603,8 @@ class ProfileStats(object):
sh
=
self
.
variable_shape
[
out
]
sh
=
self
.
variable_shape
[
out
]
if
isinstance
(
out
.
type
,
theano
.
sparse
.
SparseType
):
if
isinstance
(
out
.
type
,
theano
.
sparse
.
SparseType
):
v
=
"Sparse"
v
=
"Sparse"
elif
isinstance
(
out
.
type
,
elif
hasattr
(
out
.
type
,
'get_size'
):
(
theano
.
tensor
.
TensorType
,
v
=
out
.
type
.
get_size
(
sh
)
theano
.
sandbox
.
cuda
.
CudaNdarrayType
)):
v
=
numpy
.
prod
(
sh
)
dtype
=
str
(
out
.
dtype
)
v
*=
numpy
.
dtype
(
dtype
)
.
itemsize
sum_dense
+=
v
sum_dense
+=
v
else
:
else
:
v
=
"Unknow"
v
=
"Unknow"
...
@@ -746,9 +742,7 @@ class ProfileStats(object):
...
@@ -746,9 +742,7 @@ class ProfileStats(object):
if
any
([
isinstance
(
out
.
type
,
theano
.
sparse
.
SparseType
)
if
any
([
isinstance
(
out
.
type
,
theano
.
sparse
.
SparseType
)
for
out
in
node
.
outputs
]):
for
out
in
node
.
outputs
]):
size
=
"
%10
s"
%
"Sparse"
size
=
"
%10
s"
%
"Sparse"
elif
all
([
isinstance
(
out
.
type
,
elif
all
([
hasattr
(
out
.
type
,
'get_size'
)
(
theano
.
tensor
.
TensorType
,
theano
.
sandbox
.
cuda
.
CudaNdarrayType
))
for
out
in
node
.
outputs
]):
for
out
in
node
.
outputs
]):
size
=
"
%9
dB"
%
node_outputs_size
size
=
"
%9
dB"
%
node_outputs_size
else
:
else
:
...
...
theano/sandbox/cuda/type.py
浏览文件 @
0cbdf291
...
@@ -417,6 +417,9 @@ class CudaNdarrayType(Type):
...
@@ -417,6 +417,9 @@ class CudaNdarrayType(Type):
def
c_compile_args
(
self
):
def
c_compile_args
(
self
):
return
[]
return
[]
def
get_size
(
self
,
shape_info
):
return
numpy
.
prod
(
shape_info
,
dtype
=
int
)
*
numpy
.
dtype
(
self
.
dtype
)
.
itemsize
theano
.
compile
.
ops
.
expandable_types
+=
(
CudaNdarrayType
,)
theano
.
compile
.
ops
.
expandable_types
+=
(
CudaNdarrayType
,)
# Register C code for ViewOp on CudaNdarrayType
# Register C code for ViewOp on CudaNdarrayType
...
...
theano/tensor/basic.py
浏览文件 @
0cbdf291
...
@@ -1181,6 +1181,9 @@ class TensorType(Type):
...
@@ -1181,6 +1181,9 @@ class TensorType(Type):
"""
"""
return
numpy
.
zeros
(
shape
,
dtype
=
self
.
dtype
)
return
numpy
.
zeros
(
shape
,
dtype
=
self
.
dtype
)
def
get_size
(
self
,
shape_info
):
return
numpy
.
prod
(
shape_info
,
dtype
=
int
)
*
numpy
.
dtype
(
self
.
dtype
)
.
itemsize
theano
.
compile
.
ops
.
expandable_types
+=
(
TensorType
,)
theano
.
compile
.
ops
.
expandable_types
+=
(
TensorType
,)
# Register TensorType C code for ViewOp.
# Register TensorType C code for ViewOp.
...
...
theano/tensor/raw_random.py
浏览文件 @
0cbdf291
...
@@ -56,6 +56,22 @@ class RandomStateType(gof.Type):
...
@@ -56,6 +56,22 @@ class RandomStateType(gof.Type):
return
False
return
False
return
True
return
True
def
get_size
(
self
,
shape_info
):
# The size is the data, that have constant size.
state
=
numpy
.
random
.
RandomState
()
.
get_state
()
size
=
0
for
elem
in
state
:
if
isinstance
(
elem
,
str
):
size
+=
len
(
elem
)
elif
isinstance
(
elem
,
numpy
.
ndarray
):
size
+=
elem
.
size
*
elem
.
itemsize
elif
isinstance
(
elem
,
int
):
size
+=
numpy
.
dtype
(
"int"
)
.
itemsize
elif
isinstance
(
elem
,
float
):
size
+=
numpy
.
dtype
(
"float"
)
.
itemsize
else
:
raise
NotImplementedError
()
return
size
# Register RandomStateType's C code for ViewOp.
# Register RandomStateType's C code for ViewOp.
theano
.
compile
.
register_view_op_c_code
(
theano
.
compile
.
register_view_op_c_code
(
RandomStateType
,
RandomStateType
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论