Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
5ee6f0c6
Commit
5ee6f0c6
authored
Aug 10, 2023
by
Paul
Browse files
Format
parent
b33287f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
src/msgpack.cpp
src/msgpack.cpp
+10
-11
No files found.
src/msgpack.cpp
View file @
5ee6f0c6
...
...
@@ -33,13 +33,13 @@ inline namespace MIGRAPHX_INLINE_NS {
// Leave an extra byte for error checking
constexpr
std
::
size_t
msgpack_size_limit
=
std
::
numeric_limits
<
uint32_t
>::
max
()
-
1
;
template
<
class
Range
>
template
<
class
Range
>
std
::
size_t
msgpack_chunk_size
(
const
Range
&
r
)
{
return
r
.
size
()
/
msgpack_size_limit
;
}
template
<
class
Iterator
,
class
F
>
template
<
class
Iterator
,
class
F
>
void
msgpack_chunk_for_each
(
Iterator
start
,
Iterator
last
,
F
f
)
{
while
(
std
::
distance
(
start
,
last
)
>
msgpack_size_limit
)
...
...
@@ -165,9 +165,10 @@ MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
const
auto
*
data
=
reinterpret_cast
<
const
char
*>
(
x
.
data
());
auto
size
=
x
.
size
();
o
.
pack_array
(
migraphx
::
msgpack_chunk_size
(
x
));
migraphx
::
msgpack_chunk_for_each
(
data
,
data
+
size
,
[
&
](
const
char
*
start
,
const
char
*
last
)
{
o
.
pack_bin
(
last
-
start
);
o
.
pack_bin_body
(
data
,
last
-
start
);
migraphx
::
msgpack_chunk_for_each
(
data
,
data
+
size
,
[
&
](
const
char
*
start
,
const
char
*
last
)
{
o
.
pack_bin
(
last
-
start
);
o
.
pack_bin_body
(
data
,
last
-
start
);
});
return
o
;
}
...
...
@@ -199,7 +200,7 @@ MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
if
(
not
v
.
front
().
get_key
().
empty
())
{
migraphx
::
msgpack_chunk_for_each
(
v
.
begin
(),
v
.
end
(),
[
&
](
auto
start
,
auto
last
)
{
o
.
pack_map
(
last
-
start
);
o
.
pack_map
(
last
-
start
);
std
::
for_each
(
start
,
last
,
[
&
](
auto
&&
x
)
{
o
.
pack
(
x
.
get_key
());
o
.
pack
(
x
.
without_key
());
...
...
@@ -209,10 +210,8 @@ MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
else
{
migraphx
::
msgpack_chunk_for_each
(
v
.
begin
(),
v
.
end
(),
[
&
](
auto
start
,
auto
last
)
{
o
.
pack_array
(
last
-
start
);
std
::
for_each
(
start
,
last
,
[
&
](
auto
&&
x
)
{
o
.
pack
(
x
);
});
o
.
pack_array
(
last
-
start
);
std
::
for_each
(
start
,
last
,
[
&
](
auto
&&
x
)
{
o
.
pack
(
x
);
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment