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
901a95ef
"build/cmake.sh" did not exist on "84b36bc18dd605d2e5f6393f6ede413eaa7214ed"
Commit
901a95ef
authored
Apr 08, 2019
by
Shucai Xiao
Browse files
minor change of the fp_conversion operator to support more scenarios.
parent
45dddfa7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
20 deletions
+10
-20
src/include/migraphx/op/fp_conversion.hpp
src/include/migraphx/op/fp_conversion.hpp
+9
-19
src/quantization.cpp
src/quantization.cpp
+1
-1
No files found.
src/include/migraphx/op/fp_conversion.hpp
View file @
901a95ef
...
@@ -19,29 +19,19 @@ namespace op {
...
@@ -19,29 +19,19 @@ namespace op {
struct
fp_conversion
struct
fp_conversion
{
{
bool
reduce_precision
=
true
;
shape
::
type_t
targe_type
=
shape
::
half_type
;
std
::
string
name
()
const
{
return
"fp_conversion"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
if
(
reduce_precision
)
{
if
(
inputs
.
front
().
type
()
!=
shape
::
float_type
)
{
MIGRAPHX_THROW
(
"FP_CONVERSION: input arguments must be type float"
);
}
return
{
shape
::
half_type
,
inputs
.
front
().
lens
()};
template
<
class
Self
,
class
F
>
}
static
auto
reflect
(
Self
&
self
,
F
f
)
else
{
if
(
inputs
.
front
().
type
()
!=
shape
::
half_type
)
{
{
MIGRAPHX_THROW
(
"FP_CONVERSION: input arguments must be type fp16"
);
return
pack
(
f
(
self
.
targe_type
,
"target_type"
)
);
}
}
return
{
shape
::
float_type
,
inputs
.
front
().
lens
()};
std
::
string
name
()
const
{
return
"fp_conversion"
;
}
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
return
{
targe_type
,
inputs
.
front
().
lens
()};
}
}
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
...
...
src/quantization.cpp
View file @
901a95ef
...
@@ -80,7 +80,7 @@ void quantize(program& prog)
...
@@ -80,7 +80,7 @@ void quantize(program& prog)
auto
ins
=
std
::
prev
(
prog
.
end
());
auto
ins
=
std
::
prev
(
prog
.
end
());
if
(
ins
->
get_shape
().
type
()
==
shape
::
half_type
)
if
(
ins
->
get_shape
().
type
()
==
shape
::
half_type
)
{
{
prog
.
add_instruction
(
op
::
fp_conversion
{
fals
e
},
ins
);
prog
.
add_instruction
(
op
::
fp_conversion
{
shape
::
float_typ
e
},
ins
);
}
}
}
}
}
}
...
...
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