Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
210130133
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2021
210130133
Commits
1b4edcfc
Commit
1b4edcfc
authored
7 years ago
by
willzhang4a58
Browse files
Options
Downloads
Patches
Plain Diff
DataContentDesc
parent
60328eea
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
oneflow/core/kernel/boxing_kernel.cpp
+44
-0
44 additions, 0 deletions
oneflow/core/kernel/boxing_kernel.cpp
oneflow/core/kernel/kernel_util.h
+1
-0
1 addition, 0 deletions
oneflow/core/kernel/kernel_util.h
with
45 additions
and
0 deletions
oneflow/core/kernel/boxing_kernel.cpp
+
44
−
0
View file @
1b4edcfc
...
...
@@ -33,6 +33,50 @@ void CopyFromFirstToOtherBlobs(DeviceCtx* ctx, std::function<Blob*(const std::st
FOR_RANGE
(
size_t
,
i
,
1
,
bns
.
size
())
{
(
BnInOp2Blob
(
bns
.
Get
(
i
))
->*
Copy
)(
ctx
,
blob_0
);
}
}
class
DataContentDesc
final
{
public:
OF_DISALLOW_COPY_AND_MOVE
(
DataContentDesc
);
DataContentDesc
()
=
delete
;
~
DataContentDesc
()
=
default
;
DataContentDesc
(
std
::
function
<
Blob
*
(
const
std
::
string
&
)
>
BnInOp2Blob
,
const
PbRpf
<
std
::
string
>*
bns
,
int32_t
axis
)
{
BnInOp2Blob_
=
BnInOp2Blob
;
seg_num_
=
BnInOp2Blob
(
bns
->
Get
(
0
))
->
shape
().
Count
(
0
,
axis
);
elem_sum_
.
assign
(
bns
->
size
(),
0
);
FOR_RANGE
(
size_t
,
i
,
0
,
elem_sum_
.
size
())
{
elem_sum_
[
i
]
=
BnInOp2Blob
(
bns
->
Get
(
i
))
->
shape
().
Count
(
axis
);
if
(
i
>
0
)
{
elem_sum_
[
i
]
+=
elem_sum_
[
i
-
1
];
}
}
bns_
=
bns
;
axis_
=
axis
;
}
std
::
tuple
<
int64_t
,
char
*>
CalcContinuousElemNumStartFrom
(
int64_t
idx
)
{
std
::
tuple
<
int64_t
,
char
*>
ret
(
0
,
nullptr
);
int64_t
seg_idx
=
idx
/
elem_sum_
.
back
();
int64_t
idx_in_seg
=
idx
%
elem_sum_
.
back
();
auto
elem_sum_it
=
std
::
upper_bound
(
elem_sum_
.
begin
(),
elem_sum_
.
end
(),
idx_in_seg
);
CHECK
(
elem_sum_it
!=
elem_sum_
.
end
());
std
::
get
<
0
>
(
ret
)
=
*
elem_sum_it
-
idx_in_seg
;
int64_t
bn_idx
=
elem_sum_it
-
elem_sum_
.
begin
();
int64_t
idx_in_blob
=
idx_in_seg
;
if
(
bn_idx
>
0
)
{
idx_in_blob
-=
elem_sum_
[
bn_idx
-
1
];
}
Blob
*
blob
=
BnInOp2Blob_
(
bns_
->
Get
(
bn_idx
));
std
::
get
<
1
>
(
ret
)
=
blob
->
mut_dptr
<
char
>
()
+
(
seg_idx
*
blob
->
shape
().
Count
(
axis_
)
+
idx_in_blob
)
*
GetSizeOfDataType
(
blob
->
data_type
());
return
ret
;
}
private
:
std
::
function
<
Blob
*
(
const
std
::
string
&
)
>
BnInOp2Blob_
;
int64_t
seg_num_
;
std
::
vector
<
int64_t
>
elem_sum_
;
const
PbRpf
<
std
::
string
>*
bns_
;
int32_t
axis_
;
};
void
ConcatSplitDataContent
(
DeviceCtx
*
ctx
,
std
::
function
<
Blob
*
(
const
std
::
string
&
)
>
BnInOp2Blob
,
const
PbRpf
<
std
::
string
>&
concat_bns
,
int32_t
concat_axis
,
const
PbRpf
<
std
::
string
>&
split_bns
,
int32_t
split_axis
)
{
...
...
This diff is collapsed.
Click to expand it.
oneflow/core/kernel/kernel_util.h
+
1
−
0
View file @
1b4edcfc
...
...
@@ -377,6 +377,7 @@ class FieldIterator {
virtual
char
*
GetMutPtr
(
Blob
*
blob
)
=
0
;
virtual
size_t
GetSizeOfField
(
Blob
*
blob
)
const
=
0
;
private
:
std
::
function
<
Blob
*
(
const
std
::
string
&
)
>
BnInOp2Blob_
;
const
PbRpf
<
std
::
string
>*
bns_
;
int32_t
bn_idx_
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment