Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
e39370c5
M
models
项目概览
PaddlePaddle
/
models
大约 2 年 前同步成功
通知
232
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e39370c5
编写于
3月 13, 2018
作者:
X
Xinghai Sun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine the comments.
上级
3adaf7f5
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
8 addition
and
8 deletion
+8
-8
fluid/DeepASR/data_utils/util.py
fluid/DeepASR/data_utils/util.py
+8
-8
未找到文件。
fluid/DeepASR/data_utils/util.py
浏览文件 @
e39370c5
...
...
@@ -78,21 +78,21 @@ class CriticalException(Exception):
class
SharedNDArray
(
object
):
"""SharedNDArray utilizes shared memory to avoid data serialization when
object of which shared between
different processes. We can reconstruct the
ndarray when memory address
provided.
data object shared among
different processes. We can reconstruct the
`ndarray` when memory address, shape and dtype
provided.
Args:
name (str): Address name of shared memory.
is_verify (bool): Whether to do validation for
writing operation.
whether_verify (bool): Whether to validate the
writing operation.
"""
def
__init__
(
self
,
name
,
is
_verify
=
False
):
def
__init__
(
self
,
name
,
whether
_verify
=
False
):
self
.
_name
=
name
self
.
_shm
=
None
self
.
_buf
=
None
self
.
_array
=
np
.
zeros
(
1
,
dtype
=
np
.
float32
)
self
.
_inited
=
False
self
.
_
is_verify
=
is
_verify
self
.
_
whether_verify
=
whether
_verify
def
zeros_like
(
self
,
shape
,
dtype
):
size
=
int
(
np
.
prod
(
shape
))
*
np
.
dtype
(
dtype
).
itemsize
...
...
@@ -111,7 +111,7 @@ class SharedNDArray(object):
self
.
_buf
.
flush
()
self
.
_inited
=
True
if
self
.
_
is
_verify
:
if
self
.
_
whether
_verify
:
shm
=
posix_ipc
.
SharedMemory
(
self
.
_name
)
buf
=
mmap
.
mmap
(
shm
.
fd
,
size
)
array
=
np
.
ndarray
(
ndarray
.
shape
,
ndarray
.
dtype
,
buf
,
order
=
'C'
)
...
...
@@ -129,13 +129,13 @@ class SharedNDArray(object):
def
__getstate__
(
self
):
return
(
self
.
_name
,
self
.
_array
.
shape
,
self
.
_array
.
dtype
,
self
.
_inited
,
self
.
_
is
_verify
)
self
.
_
whether
_verify
)
def
__setstate__
(
self
,
state
):
self
.
_name
=
state
[
0
]
self
.
_inited
=
state
[
3
]
self
.
zeros_like
(
state
[
1
],
state
[
2
])
self
.
_
is
_verify
=
state
[
4
]
self
.
_
whether
_verify
=
state
[
4
]
class
SharedMemoryPoolManager
(
object
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录