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
ecc1a605
Commit
ecc1a605
authored
Jul 02, 2018
by
Paul
Browse files
Add assert for cast
parent
17f5d17e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
src/include/migraph/argument.hpp
src/include/migraph/argument.hpp
+0
-6
src/include/migraph/raw_data.hpp
src/include/migraph/raw_data.hpp
+11
-0
No files found.
src/include/migraph/argument.hpp
View file @
ecc1a605
...
...
@@ -39,12 +39,6 @@ struct argument : raw_data<argument>
const
shape
&
get_shape
()
const
{
return
this
->
m_shape
;
}
template
<
class
T
>
T
*
cast
()
const
{
return
reinterpret_cast
<
T
*>
(
this
->
data
());
}
private:
shape
m_shape
;
};
...
...
src/include/migraph/raw_data.hpp
View file @
ecc1a605
...
...
@@ -127,6 +127,17 @@ struct raw_data : raw_data_base
MIGRAPH_THROW
(
"Incorrect data type for raw data"
);
return
make_view
(
s
,
reinterpret_cast
<
T
*>
(
buffer
));
}
/// Cast the data pointer
template
<
class
T
>
T
*
cast
()
const
{
auto
&&
s
=
static_cast
<
const
Derived
&>
(
*
this
).
get_shape
();
auto
&&
buffer
=
static_cast
<
const
Derived
&>
(
*
this
).
data
();
assert
(
s
.
type
()
==
migraph
::
shape
::
get_type
<
T
>
{});
return
reinterpret_cast
<
T
*>
(
buffer
);
}
};
template
<
class
T
,
...
...
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