Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
00ce3959
Commit
00ce3959
authored
Jun 21, 2022
by
Paul
Browse files
Improve error message
parent
3577a3bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
27 deletions
+28
-27
src/driver/argument_parser.hpp
src/driver/argument_parser.hpp
+28
-27
No files found.
src/driver/argument_parser.hpp
View file @
00ce3959
...
...
@@ -81,6 +81,32 @@ inline std::ostream& operator<<(std::ostream& os, const color& c)
return
os
;
}
template
<
class
T
>
struct
type_name
{
static
const
std
::
string
&
apply
()
{
return
migraphx
::
get_type_name
<
T
>
();
}
};
template
<
>
struct
type_name
<
std
::
string
>
{
static
const
std
::
string
&
apply
()
{
static
const
std
::
string
name
=
"std::string"
;
return
name
;
}
};
template
<
class
T
>
struct
type_name
<
std
::
vector
<
T
>>
{
static
const
std
::
string
&
apply
()
{
static
const
std
::
string
name
=
"std::vector<"
+
type_name
<
T
>::
apply
()
+
">"
;
return
name
;
}
};
template
<
class
T
>
struct
value_parser
{
...
...
@@ -92,7 +118,7 @@ struct value_parser
ss
.
str
(
x
);
ss
>>
result
;
if
(
ss
.
fail
())
throw
std
::
runtime_error
(
"Failed to parse
:
"
+
x
);
throw
std
::
runtime_error
(
"Failed to parse
'
"
+
x
+
"' as "
+
type_name
<
T
>::
apply
()
);
return
result
;
}
...
...
@@ -104,7 +130,7 @@ struct value_parser
ss
.
str
(
x
);
ss
>>
i
;
if
(
ss
.
fail
())
throw
std
::
runtime_error
(
"Failed to parse
:
"
+
x
);
throw
std
::
runtime_error
(
"Failed to parse
'
"
+
x
+
"' as "
+
type_name
<
T
>::
apply
()
);
return
static_cast
<
T
>
(
i
);
}
...
...
@@ -118,31 +144,6 @@ struct value_parser
}
};
template
<
class
T
>
struct
type_name
{
static
const
std
::
string
&
apply
()
{
return
migraphx
::
get_type_name
<
T
>
();
}
};
template
<
>
struct
type_name
<
std
::
string
>
{
static
const
std
::
string
&
apply
()
{
static
const
std
::
string
name
=
"std::string"
;
return
name
;
}
};
template
<
class
T
>
struct
type_name
<
std
::
vector
<
T
>>
{
static
const
std
::
string
&
apply
()
{
static
const
std
::
string
name
=
"std::vector<"
+
type_name
<
T
>::
apply
()
+
">"
;
return
name
;
}
};
struct
argument_parser
{
...
...
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