Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow
提交
10929941
O
oneflow
项目概览
Oneflow-Inc
/
oneflow
上一次同步 2 年多
通知
13
Star
2733
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oneflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
10929941
编写于
1月 17, 2018
作者:
W
willzhang4a58
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add set_col_id for blob
Former-commit-id:
271de42e
上级
b6ffa37f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
24 addition
and
12 deletion
+24
-12
oneflow/core/kernel/kernel_util.cu
oneflow/core/kernel/kernel_util.cu
+2
-2
oneflow/core/kernel/opkernel_test_common.cpp
oneflow/core/kernel/opkernel_test_common.cpp
+1
-1
oneflow/core/kernel/opkernel_test_common.cu
oneflow/core/kernel/opkernel_test_common.cu
+1
-1
oneflow/core/register/blob.cpp
oneflow/core/register/blob.cpp
+6
-1
oneflow/core/register/blob.h
oneflow/core/register/blob.h
+10
-3
oneflow/core/register/register_manager.cpp
oneflow/core/register/register_manager.cpp
+4
-4
未找到文件。
oneflow/core/kernel/kernel_util.cu
浏览文件 @
10929941
...
...
@@ -117,7 +117,7 @@ struct KernelUtil<DeviceType::kGPU, T> final {
BlobDesc
blob_desc
=
BlobDesc
(
blob
->
blob_desc
());
char
*
host_raw_dptr
=
nullptr
;
CudaCheck
(
cudaMallocHost
(
&
host_raw_dptr
,
blob
->
TotalByteSize
()));
Blob
host_blob
(
&
blob_desc
,
host_raw_dptr
);
Blob
host_blob
(
nullptr
,
&
blob_desc
,
host_raw_dptr
);
// synchronous initialize the host blob
KernelUtil
<
DeviceType
::
kCPU
,
T
>::
Initialize
(
nullptr
,
initializer_conf
,
random_seed
,
&
host_blob
);
...
...
@@ -137,7 +137,7 @@ struct KernelUtil<DeviceType::kGPU, T> final {
BlobDesc
blob_desc
=
BlobDesc
(
blob
->
blob_desc
());
char
*
host_raw_dptr
=
nullptr
;
CudaCheck
(
cudaMallocHost
(
&
host_raw_dptr
,
blob
->
TotalByteSize
()));
Blob
host_blob
(
&
blob_desc
,
host_raw_dptr
);
Blob
host_blob
(
nullptr
,
&
blob_desc
,
host_raw_dptr
);
KernelUtil
<
DeviceType
::
kCPU
,
T
>::
InitializeWithModelDir
(
ctx
,
part_id
,
part_num
,
model_dir
,
&
host_blob
,
bn_in_op
,
dim_num
,
num_in_each_dim
);
...
...
oneflow/core/kernel/opkernel_test_common.cpp
浏览文件 @
10929941
...
...
@@ -34,7 +34,7 @@ template<>
Blob
*
CreateBlob
<
DeviceType
::
kCPU
>
(
const
BlobDesc
*
blob_desc
)
{
void
*
mem_ptr
=
nullptr
;
CudaCheck
(
cudaMallocHost
(
&
mem_ptr
,
blob_desc
->
TotalByteSize
()));
return
new
Blob
(
blob_desc
,
static_cast
<
char
*>
(
mem_ptr
));
return
new
Blob
(
nullptr
,
blob_desc
,
static_cast
<
char
*>
(
mem_ptr
));
}
template
<
>
...
...
oneflow/core/kernel/opkernel_test_common.cu
浏览文件 @
10929941
...
...
@@ -10,7 +10,7 @@ template<>
Blob
*
CreateBlob
<
DeviceType
::
kGPU
>
(
const
BlobDesc
*
blob_desc
)
{
void
*
mem_ptr
=
nullptr
;
CudaCheck
(
cudaMalloc
(
&
mem_ptr
,
blob_desc
->
TotalByteSize
()));
return
new
Blob
(
blob_desc
,
static_cast
<
char
*>
(
mem_ptr
));
return
new
Blob
(
nullptr
,
blob_desc
,
static_cast
<
char
*>
(
mem_ptr
));
}
template
<
>
...
...
oneflow/core/register/blob.cpp
浏览文件 @
10929941
...
...
@@ -5,7 +5,7 @@
namespace
oneflow
{
Blob
::
Blob
(
const
BlobDesc
*
blob_desc
,
char
*
mem_ptr
,
Blob
::
Blob
(
Regst
*
regst
,
const
BlobDesc
*
blob_desc
,
char
*
mem_ptr
,
const
void
*
comm_net_token
)
{
mem_ptr_
=
mem_ptr
;
if
(
blob_desc
->
has_data_id_field
())
{
...
...
@@ -23,6 +23,7 @@ Blob::Blob(const BlobDesc* blob_desc, char* mem_ptr,
+
blob_desc
->
ByteSizeOfColNumField
();
blob_desc_
=
blob_desc
;
comm_net_token_
=
comm_net_token
;
regst_
=
regst
;
}
const
char
*
Blob
::
data_id
(
int32_t
no
)
const
{
...
...
@@ -80,6 +81,10 @@ void Blob::CopyFrom(DeviceCtx* device_ctx, const Blob* rhs) {
TotalByteSize
());
}
void
Blob
::
set_col_id
(
int32_t
val
)
{
regst_
->
set_col_id
(
val
);
}
void
Blob
::
set_max_col_id
(
int32_t
val
)
{
regst_
->
set_max_col_id
(
val
);
}
#define INSTANTIATE_BLOB_FUNC(dev_t) \
template void Blob::CopyDataContentFrom<dev_t>(DeviceCtx*, const Blob*); \
template void Blob::CopyDataIdFrom<dev_t>(DeviceCtx*, const Blob*); \
...
...
oneflow/core/register/blob.h
浏览文件 @
10929941
...
...
@@ -7,12 +7,15 @@
namespace
oneflow
{
class
Regst
;
class
Blob
final
{
public:
OF_DISALLOW_COPY_AND_MOVE
(
Blob
);
Blob
(
const
BlobDesc
*
blob_desc
,
char
*
mem_ptr
)
:
Blob
(
blob_desc
,
mem_ptr
,
nullptr
)
{}
Blob
(
const
BlobDesc
*
blob_desc
,
char
*
mem_ptr
,
const
void
*
comm_net_token
);
Blob
(
Regst
*
regst
,
const
BlobDesc
*
blob_desc
,
char
*
mem_ptr
)
:
Blob
(
regst
,
blob_desc
,
mem_ptr
,
nullptr
)
{}
Blob
(
Regst
*
regst
,
const
BlobDesc
*
blob_desc
,
char
*
mem_ptr
,
const
void
*
comm_net_token
);
~
Blob
()
=
default
;
const
char
*
data_id
(
int32_t
no
)
const
;
...
...
@@ -62,6 +65,9 @@ class Blob final {
template
<
DeviceType
device_type
>
void
CopyFrom
(
DeviceCtx
*
device_ctx
,
const
Blob
*
rhs
);
void
set_col_id
(
int32_t
val
);
void
set_max_col_id
(
int32_t
val
);
private:
template
<
typename
T
>
void
CheckDataType
()
const
{
...
...
@@ -78,6 +84,7 @@ class Blob final {
void
*
dptr_
;
const
void
*
comm_net_token_
;
const
BlobDesc
*
blob_desc_
;
Regst
*
regst_
;
};
}
// namespace oneflow
...
...
oneflow/core/register/register_manager.cpp
浏览文件 @
10929941
...
...
@@ -24,13 +24,13 @@ void RegstMgr::NewRegsts(const RegstDescProto& regst_desc_proto,
char
*
cur_pointer
=
std
::
get
<
0
>
(
allocation_result
);
for
(
const
std
::
string
&
lbn
:
lbns
)
{
const
BlobDesc
*
blob_desc
=
runtime_regst_desc
->
GetBlobDescFromLbn
(
lbn
);
auto
blob_ptr
=
of_make_unique
<
Blob
>
(
blob_desc
,
cur_pointer
);
auto
blob_ptr
=
of_make_unique
<
Blob
>
(
regst
,
blob_desc
,
cur_pointer
);
CHECK
(
regst
->
lbn2blob_
.
emplace
(
lbn
,
std
::
move
(
blob_ptr
)).
second
);
cur_pointer
+=
blob_desc
->
TotalByteSize
();
}
regst
->
packed_blob_
.
reset
(
new
Blob
(
runtime_regst_desc
->
packed_blob_desc
(),
std
::
get
<
0
>
(
allocation_result
),
std
::
get
<
1
>
(
allocation_result
)));
regst
->
packed_blob_
.
reset
(
new
Blob
(
regst
,
runtime_regst_desc
->
packed_blob_desc
(
),
std
::
get
<
0
>
(
allocation_result
),
std
::
get
<
1
>
(
allocation_result
)));
regst
->
deleter_
=
std
::
get
<
2
>
(
allocation_result
);
OneRegstDone
(
regst
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录