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
88f80be7
Commit
88f80be7
authored
Aug 10, 2023
by
Paul
Browse files
Fix compile errors
parent
631c1b52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
35 deletions
+35
-35
src/msgpack.cpp
src/msgpack.cpp
+35
-35
No files found.
src/msgpack.cpp
View file @
88f80be7
...
...
@@ -23,44 +23,45 @@
*/
#include <migraphx/msgpack.hpp>
#include <migraphx/serialize.hpp>
#include <migraphx/functional.hpp>
#include <msgpack.hpp>
#include <variant>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
//
namespace migraphx {
//
inline namespace MIGRAPHX_INLINE_NS {
struct
msgpack_chunk
{
std
::
vector
<
value
>
chunks
;
//
struct msgpack_chunk
//
{
//
std::vector<value> chunks;
value
as_value
()
const
{
if
(
chunks
.
empty
())
return
{};
const
value
&
v
=
chunks
.
front
();
if
(
v
.
is_array
()
or
v
.
is_object
())
{
std
::
vector
<
value
>
values
=
v
.
is_array
()
?
v
.
get_array
()
:
v
.
get_object
();
std
::
for_each
(
chunks
.
begin
()
+
1
,
chunks
.
end
(),
[
&
](
const
auto
&
chunk
)
{
values
.
insert
(
values
.
end
(),
chunk
.
begin
(),
chunk
.
end
());
});
return
values
;
}
else
if
(
v
.
is_binary
())
{
value
::
binary
data
=
v
.
get_binary
();
std
::
for_each
(
chunks
.
begin
()
+
1
,
chunks
.
end
(),
[
&
](
const
auto
&
chunk
)
{
const
value
::
binary
&
b
=
chunk
.
get_binary
();
data
.
insert
(
data
.
end
(),
b
.
begin
(),
b
.
end
());
});
return
data
;
}
MIGRAPHX_THROW
(
"Incorrect chunking"
);
}
};
//
value as_value() const
//
{
//
if(chunks.empty())
//
return {};
//
const value& v = chunks.front();
//
if(v.is_array() or v.is_object())
//
{
//
std::vector<value> values = v.is_array() ? v.get_array() : v.get_object();
//
std::for_each(chunks.begin() + 1, chunks.end(), [&](const auto& chunk) {
//
values.insert(values.end(), chunk.begin(), chunk.end());
//
});
//
return values;
//
}
//
else if(v.is_binary())
//
{
//
value::binary data = v.get_binary();
//
std::for_each(chunks.begin() + 1, chunks.end(), [&](const auto& chunk) {
//
const value::binary& b = chunk.get_binary();
//
data.insert(data.end(), b.begin(), b.end());
//
});
//
return data;
//
}
//
MIGRAPHX_THROW("Incorrect chunking");
//
}
//
};
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
//
} // namespace MIGRAPHX_INLINE_NS
//
} // namespace migraphx
namespace
msgpack
{
MSGPACK_API_VERSION_NAMESPACE
(
MSGPACK_DEFAULT_API_NS
)
...
...
@@ -125,13 +126,12 @@ MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
}
default:
MIGRAPHX_THROW
(
"Incorrect chunking"
);
}
}
std
::
for_each
(
o
.
via
.
array
.
ptr
,
o
.
via
.
array
.
ptr
+
o
.
via
.
array
.
size
,
[
&
](
const
msgpack
::
object
&
sa
)
{
std
::
visit
(
overload
(
migraphx
::
overload
(
[
&
](
migraphx
::
value
::
binary
&
bin
)
{
bin
.
insert
(
bin
.
end
(),
o
.
via
.
bin
.
ptr
,
o
.
via
.
bin
.
ptr
+
o
.
via
.
bin
.
size
);
...
...
@@ -164,9 +164,9 @@ MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
case
msgpack
::
type
::
EXT
:
{
MIGRAPHX_THROW
(
"msgpack EXT type not supported."
);
}
}
return
o
;
}
}
};
template
<
>
...
...
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