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
00b03957
Commit
00b03957
authored
Apr 16, 2019
by
Shucai Xiao
Browse files
clean up the quantize_ins implementation
parent
d096e06a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
src/include/migraphx/op/fp_conversion.hpp
src/include/migraphx/op/fp_conversion.hpp
+1
-1
src/quantize_ins.cpp
src/quantize_ins.cpp
+15
-14
src/targets/gpu/fp_conversion.cpp
src/targets/gpu/fp_conversion.cpp
+1
-1
No files found.
src/include/migraphx/op/fp_conversion.hpp
View file @
00b03957
...
...
@@ -31,7 +31,7 @@ struct fp_conversion
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
return
{
targe_type
,
inputs
.
front
().
lens
()};
return
{
targe_type
,
inputs
.
front
().
lens
()
,
inputs
.
front
().
strides
()
};
}
argument
compute
(
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
...
...
src/quantize_ins.cpp
View file @
00b03957
...
...
@@ -90,22 +90,23 @@ void quantize_ins(program& prog, const std::vector<std::string>& ins_names)
if
(
inputs
!=
converted_inputs
)
{
auto
op
=
ins
->
get_operator
();
instruction
::
replace
(
ins
,
op
,
compute_shape
(
op
,
converted_inputs
),
converted_inputs
);
}
if
(
ins
->
get_shape
().
type
()
!=
orig_type
)
{
// insert another fp_conversion instruction to convert it back
if
(
ins
==
std
::
prev
(
prog
.
end
()))
{
prog
.
add_instruction
(
op
::
fp_conversion
{
orig_type
},
ins
);
}
else
auto
ins_shape
=
compute_shape
(
op
,
converted_inputs
);
if
(
ins_shape
.
type
()
!=
orig_type
)
{
auto
ins_orig_type
=
prog
.
insert_instruction
(
std
::
next
(
ins
),
op
::
fp_conversion
{
orig_type
},
ins
);
prog
.
replace_instruction
(
ins
,
ins_orig_type
);
// insert another fp_conversion instruction to convert it back
if
(
ins
==
std
::
prev
(
prog
.
end
()))
{
prog
.
add_instruction
(
op
::
fp_conversion
{
orig_type
},
ins
);
}
else
{
auto
ins_orig_type
=
prog
.
insert_instruction
(
std
::
next
(
ins
),
op
::
fp_conversion
{
orig_type
},
ins
);
prog
.
replace_instruction
(
ins
,
ins_orig_type
);
}
}
instruction
::
replace
(
ins
,
op
,
compute_shape
(
op
,
converted_inputs
),
converted_inputs
);
}
}
}
...
...
src/targets/gpu/fp_conversion.cpp
View file @
00b03957
...
...
@@ -9,7 +9,7 @@ namespace gpu {
shape
hip_fp_conversion
::
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
inputs
.
pop_back
();
check_shapes
{
inputs
}.
not_broadcasted
().
not_transpos
ed
();
check_shapes
{
inputs
}.
pack
ed
();
return
op
.
compute_shape
(
inputs
);
}
...
...
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