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
34493a8d
Commit
34493a8d
authored
May 14, 2019
by
Shucai Xiao
Browse files
clang format
parent
3003b4e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
13 deletions
+14
-13
src/include/migraphx/quantization.hpp
src/include/migraphx/quantization.hpp
+6
-6
src/targets/gpu/device/convert.cpp
src/targets/gpu/device/convert.cpp
+4
-3
src/targets/gpu/include/migraphx/gpu/convert.hpp
src/targets/gpu/include/migraphx/gpu/convert.hpp
+2
-3
src/targets/gpu/include/migraphx/gpu/device/convert.hpp
src/targets/gpu/include/migraphx/gpu/device/convert.hpp
+2
-1
No files found.
src/include/migraphx/quantization.hpp
View file @
34493a8d
...
@@ -20,15 +20,14 @@ namespace op {
...
@@ -20,15 +20,14 @@ namespace op {
struct
convert
:
unary
<
convert
>
struct
convert
:
unary
<
convert
>
{
{
shape
::
type_t
target_type
=
shape
::
half_type
;
shape
::
type_t
target_type
=
shape
::
half_type
;
float
scale
=
1.0
f
;
float
scale
=
1.0
f
;
float
shift
=
0.0
f
;
float
shift
=
0.0
f
;
template
<
class
Self
,
class
F
>
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
static
auto
reflect
(
Self
&
self
,
F
f
)
{
{
return
pack
(
f
(
self
.
target_type
,
"target_type"
),
return
pack
(
f
(
self
.
scale
,
"scale"
),
f
(
self
.
target_type
,
"target_type"
),
f
(
self
.
scale
,
"scale"
),
f
(
self
.
shift
,
"shift"
));
f
(
self
.
shift
,
"shift"
));
}
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
...
@@ -39,7 +38,8 @@ struct convert : unary<convert>
...
@@ -39,7 +38,8 @@ struct convert : unary<convert>
auto
apply
()
const
auto
apply
()
const
{
{
// return [&](auto x) { return (target_type == shape::int8_type) ? static_cast<int8_t>(x * scale + shift) : x; };
// return [&](auto x) { return (target_type == shape::int8_type) ? static_cast<int8_t>(x *
// scale + shift) : x; };
return
[
&
](
auto
x
)
{
return
scale
*
x
+
shift
;
};
return
[
&
](
auto
x
)
{
return
scale
*
x
+
shift
;
};
}
}
...
...
src/targets/gpu/device/convert.cpp
View file @
34493a8d
...
@@ -6,14 +6,15 @@ inline namespace MIGRAPHX_INLINE_NS {
...
@@ -6,14 +6,15 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace
gpu
{
namespace
gpu
{
namespace
device
{
namespace
device
{
void
convert
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
,
float
scale
,
float
shift
)
void
convert
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
,
float
scale
,
float
shift
)
{
{
result
.
visit
([
&
](
auto
output
)
{
result
.
visit
([
&
](
auto
output
)
{
arg
.
visit
([
&
](
auto
input
)
{
arg
.
visit
([
&
](
auto
input
)
{
const
auto
*
input_ptr
=
device_cast
(
input
.
data
());
const
auto
*
input_ptr
=
device_cast
(
input
.
data
());
auto
*
output_ptr
=
device_cast
(
output
.
data
());
auto
*
output_ptr
=
device_cast
(
output
.
data
());
gs_launch
(
stream
,
gs_launch
(
stream
,
result
.
get_shape
().
elements
())(
result
.
get_shape
().
elements
())(
[
=
](
auto
i
)
{
output_ptr
[
i
]
=
input_ptr
[
i
]
*
scale
+
shift
;
});
[
=
](
auto
i
)
{
output_ptr
[
i
]
=
input_ptr
[
i
]
*
scale
+
shift
;
});
});
});
});
});
}
}
...
...
src/targets/gpu/include/migraphx/gpu/convert.hpp
View file @
34493a8d
...
@@ -21,11 +21,10 @@ struct hip_convert
...
@@ -21,11 +21,10 @@ struct hip_convert
}
}
std
::
string
name
()
const
{
return
"gpu::convert"
;
}
std
::
string
name
()
const
{
return
"gpu::convert"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
;
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
;
argument
argument
compute
(
context
&
ctx
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
;
compute
(
context
&
ctx
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
;
std
::
ptrdiff_t
output_alias
(
const
std
::
vector
<
shape
>&
shapes
)
const
std
::
ptrdiff_t
output_alias
(
const
std
::
vector
<
shape
>&
shapes
)
const
{
{
...
...
src/targets/gpu/include/migraphx/gpu/device/convert.hpp
View file @
34493a8d
...
@@ -11,7 +11,8 @@ inline namespace MIGRAPHX_INLINE_NS {
...
@@ -11,7 +11,8 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace
gpu
{
namespace
gpu
{
namespace
device
{
namespace
device
{
void
convert
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
,
float
scale
,
float
shift
);
void
convert
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
,
float
scale
,
float
shift
);
}
// namespace device
}
// namespace device
}
// namespace gpu
}
// namespace gpu
...
...
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