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
d2f9399a
Commit
d2f9399a
authored
Apr 18, 2019
by
Shucai Xiao
Browse files
rename the operator fp_conversion to convert
parent
0faaf780
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
42 additions
and
42 deletions
+42
-42
src/include/migraphx/op/convert.hpp
src/include/migraphx/op/convert.hpp
+4
-4
src/include/migraphx/operators.hpp
src/include/migraphx/operators.hpp
+1
-1
src/quantization.cpp
src/quantization.cpp
+9
-9
src/targets/cpu/lowering.cpp
src/targets/cpu/lowering.cpp
+4
-4
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+2
-2
src/targets/gpu/convert.cpp
src/targets/gpu/convert.cpp
+5
-5
src/targets/gpu/device/convert.cpp
src/targets/gpu/device/convert.cpp
+6
-6
src/targets/gpu/include/migraphx/gpu/convert.hpp
src/targets/gpu/include/migraphx/gpu/convert.hpp
+6
-6
src/targets/gpu/include/migraphx/gpu/device/convert.hpp
src/targets/gpu/include/migraphx/gpu/device/convert.hpp
+3
-3
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+2
-2
No files found.
src/include/migraphx/op/
fp_
conver
sion
.hpp
→
src/include/migraphx/op/conver
t
.hpp
View file @
d2f9399a
#ifndef MIGRAPHX_GUARD_OPERATORS_
FP_
CONVER
SION
_HPP
#ifndef MIGRAPHX_GUARD_OPERATORS_CONVER
T
_HPP
#define MIGRAPHX_GUARD_OPERATORS_
FP_
CONVER
SION
_HPP
#define MIGRAPHX_GUARD_OPERATORS_CONVER
T
_HPP
#include <array>
#include <array>
#include <migraphx/op/binary.hpp>
#include <migraphx/op/binary.hpp>
...
@@ -17,7 +17,7 @@ namespace migraphx {
...
@@ -17,7 +17,7 @@ namespace migraphx {
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
namespace
op
{
struct
fp_
conver
sion
struct
conver
t
{
{
shape
::
type_t
targe_type
=
shape
::
half_type
;
shape
::
type_t
targe_type
=
shape
::
half_type
;
...
@@ -27,7 +27,7 @@ struct fp_conversion
...
@@ -27,7 +27,7 @@ struct fp_conversion
return
pack
(
f
(
self
.
targe_type
,
"target_type"
));
return
pack
(
f
(
self
.
targe_type
,
"target_type"
));
}
}
std
::
string
name
()
const
{
return
"
fp_
conver
sion
"
;
}
std
::
string
name
()
const
{
return
"conver
t
"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
...
...
src/include/migraphx/operators.hpp
View file @
d2f9399a
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include <migraphx/op/common.hpp>
#include <migraphx/op/common.hpp>
#include <migraphx/op/concat.hpp>
#include <migraphx/op/concat.hpp>
#include <migraphx/op/contiguous.hpp>
#include <migraphx/op/contiguous.hpp>
#include <migraphx/op/convert.hpp>
#include <migraphx/op/convolution.hpp>
#include <migraphx/op/convolution.hpp>
#include <migraphx/op/cosh.hpp>
#include <migraphx/op/cosh.hpp>
#include <migraphx/op/cos.hpp>
#include <migraphx/op/cos.hpp>
...
@@ -22,7 +23,6 @@
...
@@ -22,7 +23,6 @@
#include <migraphx/op/elu.hpp>
#include <migraphx/op/elu.hpp>
#include <migraphx/op/exp.hpp>
#include <migraphx/op/exp.hpp>
#include <migraphx/op/flatten.hpp>
#include <migraphx/op/flatten.hpp>
#include <migraphx/op/fp_conversion.hpp>
#include <migraphx/op/gather.hpp>
#include <migraphx/op/gather.hpp>
#include <migraphx/op/gru.hpp>
#include <migraphx/op/gru.hpp>
#include <migraphx/op/identity.hpp>
#include <migraphx/op/identity.hpp>
...
...
src/quantization.cpp
View file @
d2f9399a
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include <migraphx/program.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/op/
fp_
conver
sion
.hpp>
#include <migraphx/op/conver
t
.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/ranges.hpp>
#include <migraphx/ranges.hpp>
#include <utility>
#include <utility>
...
@@ -35,11 +35,11 @@ instruction_ref insert_fp16(program& prog,
...
@@ -35,11 +35,11 @@ instruction_ref insert_fp16(program& prog,
{
{
if
(
ins
==
std
::
prev
(
prog
.
end
()))
if
(
ins
==
std
::
prev
(
prog
.
end
()))
{
{
ins_fp16
=
prog
.
add_instruction
(
op
::
fp_
conver
sion
{
type
},
ins
);
ins_fp16
=
prog
.
add_instruction
(
op
::
conver
t
{
type
},
ins
);
}
}
else
else
{
{
ins_fp16
=
prog
.
insert_instruction
(
std
::
next
(
ins
),
op
::
fp_
conver
sion
{},
ins
);
ins_fp16
=
prog
.
insert_instruction
(
std
::
next
(
ins
),
op
::
conver
t
{},
ins
);
}
}
}
}
map_fp16
[
ins
]
=
ins_fp16
;
map_fp16
[
ins
]
=
ins_fp16
;
...
@@ -60,7 +60,7 @@ void quantize(program& prog, const std::vector<std::string>& ins_names)
...
@@ -60,7 +60,7 @@ void quantize(program& prog, const std::vector<std::string>& ins_names)
shape
::
type_t
orig_type
=
ins
->
get_shape
().
type
();
shape
::
type_t
orig_type
=
ins
->
get_shape
().
type
();
// process all inputs, if input is a fp32 or fp64, convert it
// process all inputs, if input is a fp32 or fp64, convert it
// to a fp16 by adding a
fp_
conver
sion
operator.
// to a fp16 by adding a conver
t
operator.
auto
inputs
=
ins
->
inputs
();
auto
inputs
=
ins
->
inputs
();
std
::
vector
<
instruction_ref
>
converted_inputs
;
std
::
vector
<
instruction_ref
>
converted_inputs
;
for
(
auto
input
:
inputs
)
for
(
auto
input
:
inputs
)
...
@@ -68,10 +68,10 @@ void quantize(program& prog, const std::vector<std::string>& ins_names)
...
@@ -68,10 +68,10 @@ void quantize(program& prog, const std::vector<std::string>& ins_names)
auto
s
=
input
->
get_shape
();
auto
s
=
input
->
get_shape
();
if
(
s
.
type
()
==
shape
::
float_type
||
s
.
type
()
==
shape
::
double_type
)
if
(
s
.
type
()
==
shape
::
float_type
||
s
.
type
()
==
shape
::
double_type
)
{
{
// if the input is a
fp_
conver
sion
operator, uses its input
// if the input is a conver
t
operator, uses its input
// as its current input
// as its current input
instruction_ref
input_fp16
{};
instruction_ref
input_fp16
{};
if
(
input
->
name
()
==
"
fp_
conver
sion
"
)
if
(
input
->
name
()
==
"conver
t
"
)
{
{
input_fp16
=
input
->
inputs
().
front
();
input_fp16
=
input
->
inputs
().
front
();
}
}
...
@@ -94,15 +94,15 @@ void quantize(program& prog, const std::vector<std::string>& ins_names)
...
@@ -94,15 +94,15 @@ void quantize(program& prog, const std::vector<std::string>& ins_names)
auto
ins_shape
=
compute_shape
(
op
,
converted_inputs
);
auto
ins_shape
=
compute_shape
(
op
,
converted_inputs
);
if
(
ins_shape
.
type
()
!=
orig_type
)
if
(
ins_shape
.
type
()
!=
orig_type
)
{
{
// insert another
fp_
conver
sion
instruction to convert it back
// insert another conver
t
instruction to convert it back
if
(
ins
==
std
::
prev
(
prog
.
end
()))
if
(
ins
==
std
::
prev
(
prog
.
end
()))
{
{
prog
.
add_instruction
(
op
::
fp_
conver
sion
{
orig_type
},
ins
);
prog
.
add_instruction
(
op
::
conver
t
{
orig_type
},
ins
);
}
}
else
else
{
{
auto
ins_orig_type
=
auto
ins_orig_type
=
prog
.
insert_instruction
(
std
::
next
(
ins
),
op
::
fp_
conver
sion
{
orig_type
},
ins
);
prog
.
insert_instruction
(
std
::
next
(
ins
),
op
::
conver
t
{
orig_type
},
ins
);
prog
.
replace_instruction
(
ins
,
ins_orig_type
);
prog
.
replace_instruction
(
ins
,
ins_orig_type
);
}
}
}
}
...
...
src/targets/cpu/lowering.cpp
View file @
d2f9399a
...
@@ -727,10 +727,10 @@ struct cpu_logsoftmax
...
@@ -727,10 +727,10 @@ struct cpu_logsoftmax
}
}
};
};
struct
cpu_
fp_
conver
sion
struct
cpu_conver
t
{
{
op
::
fp_
conver
sion
op
;
op
::
conver
t
op
;
std
::
string
name
()
const
{
return
"cpu_
fp_
conver
sion
"
;
}
std
::
string
name
()
const
{
return
"cpu_conver
t
"
;
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
return
op
.
compute_shape
(
inputs
);
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
return
op
.
compute_shape
(
inputs
);
}
argument
compute
(
context
&
,
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
context
&
,
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
...
@@ -853,7 +853,7 @@ struct cpu_apply
...
@@ -853,7 +853,7 @@ struct cpu_apply
apply_map
[
"pad"
]
=
extend_op
<
cpu_pad
,
op
::
pad
>
();
apply_map
[
"pad"
]
=
extend_op
<
cpu_pad
,
op
::
pad
>
();
apply_map
[
"concat"
]
=
extend_op
<
cpu_concat
,
op
::
concat
>
();
apply_map
[
"concat"
]
=
extend_op
<
cpu_concat
,
op
::
concat
>
();
apply_map
[
"gather"
]
=
extend_op
<
cpu_gather
,
op
::
gather
>
();
apply_map
[
"gather"
]
=
extend_op
<
cpu_gather
,
op
::
gather
>
();
apply_map
[
"
fp_
conver
sion
"
]
=
extend_op
<
cpu_
fp_
conver
sion
,
op
::
fp_
conver
sion
>
();
apply_map
[
"conver
t
"
]
=
extend_op
<
cpu_conver
t
,
op
::
conver
t
>
();
apply_map
[
"logsoftmax"
]
=
extend_op
<
cpu_logsoftmax
,
op
::
logsoftmax
>
();
apply_map
[
"logsoftmax"
]
=
extend_op
<
cpu_logsoftmax
,
op
::
logsoftmax
>
();
apply_map
[
"leaky_relu"
]
=
extend_op
<
cpu_unary
<
leaky_relu_op
>
,
op
::
leaky_relu
>
();
apply_map
[
"leaky_relu"
]
=
extend_op
<
cpu_unary
<
leaky_relu_op
>
,
op
::
leaky_relu
>
();
apply_map
[
"elu"
]
=
extend_op
<
cpu_unary
<
elu_op
>
,
op
::
elu
>
();
apply_map
[
"elu"
]
=
extend_op
<
cpu_unary
<
elu_op
>
,
op
::
elu
>
();
...
...
src/targets/gpu/CMakeLists.txt
View file @
d2f9399a
...
@@ -27,7 +27,7 @@ add_library(migraphx_device
...
@@ -27,7 +27,7 @@ add_library(migraphx_device
device/add_relu.cpp
device/add_relu.cpp
device/contiguous.cpp
device/contiguous.cpp
device/logsoftmax.cpp
device/logsoftmax.cpp
device/
fp_
conver
sion
.cpp
device/conver
t
.cpp
device/mul.cpp
device/mul.cpp
device/concat.cpp
device/concat.cpp
device/pad.cpp
device/pad.cpp
...
@@ -51,7 +51,7 @@ add_library(migraphx_gpu
...
@@ -51,7 +51,7 @@ add_library(migraphx_gpu
convolution.cpp
convolution.cpp
softmax.cpp
softmax.cpp
logsoftmax.cpp
logsoftmax.cpp
fp_
conver
sion
.cpp
conver
t
.cpp
contiguous.cpp
contiguous.cpp
concat.cpp
concat.cpp
relu.cpp
relu.cpp
...
...
src/targets/gpu/
fp_
conver
sion
.cpp
→
src/targets/gpu/conver
t
.cpp
View file @
d2f9399a
#include <migraphx/gpu/
fp_
conver
sion
.hpp>
#include <migraphx/gpu/conver
t
.hpp>
#include <migraphx/gpu/device/
fp_
conver
sion
.hpp>
#include <migraphx/gpu/device/conver
t
.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/context.hpp>
namespace
migraphx
{
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
gpu
{
shape
hip_
fp_
conver
sion
::
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
shape
hip_conver
t
::
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
{
inputs
.
pop_back
();
inputs
.
pop_back
();
check_shapes
{
inputs
}.
packed
();
check_shapes
{
inputs
}.
packed
();
return
op
.
compute_shape
(
inputs
);
return
op
.
compute_shape
(
inputs
);
}
}
argument
hip_
fp_
conver
sion
::
compute
(
context
&
ctx
,
argument
hip_conver
t
::
compute
(
context
&
ctx
,
const
shape
&
output_shape
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
const
const
std
::
vector
<
argument
>&
args
)
const
{
{
return
device
::
fp_
conver
sion
(
ctx
.
get_stream
().
get
(),
output_shape
,
args
);
return
device
::
conver
t
(
ctx
.
get_stream
().
get
(),
args
[
1
]
,
args
[
0
]
);
}
}
}
// namespace gpu
}
// namespace gpu
...
...
src/targets/gpu/device/
fp_
conver
sion
.cpp
→
src/targets/gpu/device/conver
t
.cpp
View file @
d2f9399a
#include <migraphx/gpu/device/
fp_
conver
sion
.hpp>
#include <migraphx/gpu/device/conver
t
.hpp>
#include <migraphx/gpu/device/nary.hpp>
#include <migraphx/gpu/device/nary.hpp>
namespace
migraphx
{
namespace
migraphx
{
...
@@ -7,18 +7,18 @@ namespace gpu {
...
@@ -7,18 +7,18 @@ namespace gpu {
namespace
device
{
namespace
device
{
argument
argument
fp_
conver
sion
(
hipStream_t
stream
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>
&
arg
s
)
conver
t
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
)
{
{
args
.
back
()
.
visit
([
&
](
auto
output
)
{
result
.
visit
([
&
](
auto
output
)
{
arg
s
.
front
()
.
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
,
outpu
t_shape
.
elements
())([
=
](
auto
i
)
{
output_ptr
[
i
]
=
input_ptr
[
i
];
});
result
.
ge
t_shape
()
.
elements
())([
=
](
auto
i
)
{
output_ptr
[
i
]
=
input_ptr
[
i
];
});
});
});
});
});
return
args
.
back
()
;
return
result
;
}
}
}
// namespace device
}
// namespace device
...
...
src/targets/gpu/include/migraphx/gpu/
fp_
conver
sion
.hpp
→
src/targets/gpu/include/migraphx/gpu/conver
t
.hpp
View file @
d2f9399a
#ifndef MIGRAPHX_GUARD_RTGLIB_
FP_
CONVER
SION
_HPP
#ifndef MIGRAPHX_GUARD_RTGLIB_CONVER
T
_HPP
#define MIGRAPHX_GUARD_RTGLIB_
FP_
CONVER
SION
_HPP
#define MIGRAPHX_GUARD_RTGLIB_CONVER
T
_HPP
#include <migraphx/shape.hpp>
#include <migraphx/shape.hpp>
#include <migraphx/op/
fp_
conver
sion
.hpp>
#include <migraphx/op/conver
t
.hpp>
namespace
migraphx
{
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
inline
namespace
MIGRAPHX_INLINE_NS
{
...
@@ -10,10 +10,10 @@ namespace gpu {
...
@@ -10,10 +10,10 @@ namespace gpu {
struct
context
;
struct
context
;
struct
hip_
fp_
conver
sion
struct
hip_conver
t
{
{
op
::
fp_
conver
sion
op
;
op
::
conver
t
op
;
std
::
string
name
()
const
{
return
"gpu::
fp_
conver
sion
"
;
}
std
::
string
name
()
const
{
return
"gpu::conver
t
"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
;
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
;
argument
argument
compute
(
context
&
ctx
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
const
;
compute
(
context
&
ctx
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
const
;
...
...
src/targets/gpu/include/migraphx/gpu/device/
fp_
conver
sion
.hpp
→
src/targets/gpu/include/migraphx/gpu/device/conver
t
.hpp
View file @
d2f9399a
#ifndef MIGRAPHX_GUARD_RTGLIB_DEVICE_
FP_
CONVER
SION
_HPP
#ifndef MIGRAPHX_GUARD_RTGLIB_DEVICE_CONVER
T
_HPP
#define MIGRAPHX_GUARD_RTGLIB_DEVICE_
FP_
CONVER
SION
_HPP
#define MIGRAPHX_GUARD_RTGLIB_DEVICE_CONVER
T
_HPP
#include <migraphx/argument.hpp>
#include <migraphx/argument.hpp>
#include <migraphx/config.hpp>
#include <migraphx/config.hpp>
...
@@ -12,7 +12,7 @@ namespace gpu {
...
@@ -12,7 +12,7 @@ namespace gpu {
namespace
device
{
namespace
device
{
argument
argument
fp_
conver
sion
(
hipStream_t
stream
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>
&
arg
s
);
conver
t
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg
);
}
// namespace device
}
// namespace device
}
// namespace gpu
}
// namespace gpu
...
...
src/targets/gpu/lowering.cpp
View file @
d2f9399a
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
#include <migraphx/gpu/pad.hpp>
#include <migraphx/gpu/pad.hpp>
#include <migraphx/gpu/gather.hpp>
#include <migraphx/gpu/gather.hpp>
#include <migraphx/gpu/lrn.hpp>
#include <migraphx/gpu/lrn.hpp>
#include <migraphx/gpu/
fp_
conver
sion
.hpp>
#include <migraphx/gpu/conver
t
.hpp>
#include <utility>
#include <utility>
#include <functional>
#include <functional>
#include <algorithm>
#include <algorithm>
...
@@ -102,7 +102,7 @@ struct miopen_apply
...
@@ -102,7 +102,7 @@ struct miopen_apply
add_extend_op
<
hip_logsoftmax
,
op
::
logsoftmax
>
(
"logsoftmax"
);
add_extend_op
<
hip_logsoftmax
,
op
::
logsoftmax
>
(
"logsoftmax"
);
add_extend_op
<
hip_gather
,
op
::
gather
>
(
"gather"
);
add_extend_op
<
hip_gather
,
op
::
gather
>
(
"gather"
);
add_extend_op
<
hip_pad
,
op
::
pad
>
(
"pad"
);
add_extend_op
<
hip_pad
,
op
::
pad
>
(
"pad"
);
add_extend_op
<
hip_
fp_
conver
sion
,
op
::
fp_
conver
sion
>
(
"fp_
conver
sion
"
);
add_extend_op
<
hip_conver
t
,
op
::
conver
t
>
(
"
conver
t
"
);
add_lrn_op
();
add_lrn_op
();
add_convolution_op
();
add_convolution_op
();
...
...
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