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
01557ea0
Commit
01557ea0
authored
May 07, 2019
by
Shucai Xiao
Browse files
merge changes from the develop branches.
parents
ec1ab58b
767ca0cc
Changes
49
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
363 additions
and
336 deletions
+363
-336
Dockerfile
Dockerfile
+5
-0
src/include/migraphx/instruction.hpp
src/include/migraphx/instruction.hpp
+3
-2
src/include/migraphx/op/abnormal_ops.hpp
src/include/migraphx/op/abnormal_ops.hpp
+5
-0
src/include/migraphx/op/clip.hpp
src/include/migraphx/op/clip.hpp
+51
-0
src/include/migraphx/op/concat.hpp
src/include/migraphx/op/concat.hpp
+7
-0
src/include/migraphx/op/leaky_relu.hpp
src/include/migraphx/op/leaky_relu.hpp
+7
-6
src/include/migraphx/operation.hpp
src/include/migraphx/operation.hpp
+3
-1
src/include/migraphx/operators.hpp
src/include/migraphx/operators.hpp
+1
-0
src/include/migraphx/reflect.hpp
src/include/migraphx/reflect.hpp
+61
-6
src/instruction.cpp
src/instruction.cpp
+6
-0
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+17
-0
src/program.cpp
src/program.cpp
+6
-3
src/targets/cpu/lowering.cpp
src/targets/cpu/lowering.cpp
+87
-318
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+2
-0
src/targets/gpu/clip.cpp
src/targets/gpu/clip.cpp
+23
-0
src/targets/gpu/device/clip.cpp
src/targets/gpu/device/clip.cpp
+22
-0
src/targets/gpu/include/migraphx/gpu/abs.hpp
src/targets/gpu/include/migraphx/gpu/abs.hpp
+7
-0
src/targets/gpu/include/migraphx/gpu/batchnorm.hpp
src/targets/gpu/include/migraphx/gpu/batchnorm.hpp
+7
-0
src/targets/gpu/include/migraphx/gpu/clip.hpp
src/targets/gpu/include/migraphx/gpu/clip.hpp
+37
-0
src/targets/gpu/include/migraphx/gpu/concat.hpp
src/targets/gpu/include/migraphx/gpu/concat.hpp
+6
-0
No files found.
Dockerfile
View file @
01557ea0
...
@@ -74,3 +74,8 @@ ENV LD_LIBRARY_PATH=$PREFIX/lib
...
@@ -74,3 +74,8 @@ ENV LD_LIBRARY_PATH=$PREFIX/lib
# Install doc requirements
# Install doc requirements
ADD
doc/requirements.txt /doc-requirements.txt
ADD
doc/requirements.txt /doc-requirements.txt
RUN
pip
install
-r
/doc-requirements.txt
RUN
pip
install
-r
/doc-requirements.txt
# Setup ubsan environment to printstacktrace
RUN
ln
-s
/usr/bin/llvm-symbolizer-5.0 /usr/local/bin/llvm-symbolizer
ENV
UBSAN_OPTIONS=print_stacktrace=1
ENV
ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
src/include/migraphx/instruction.hpp
View file @
01557ea0
...
@@ -24,7 +24,7 @@ struct instruction
...
@@ -24,7 +24,7 @@ struct instruction
instruction
(
literal
l
);
instruction
(
literal
l
);
void
replace
(
const
shape
&
r
);
void
replace
(
operation
o
);
void
recompute_shape
();
void
recompute_shape
();
...
@@ -90,7 +90,8 @@ struct instruction
...
@@ -90,7 +90,8 @@ struct instruction
// internal
// internal
void
replace_argument
(
instruction_ref
old
,
instruction_ref
new_ins
);
void
replace_argument
(
instruction_ref
old
,
instruction_ref
new_ins
);
private:
void
replace
(
const
shape
&
r
);
operation
op
;
operation
op
;
shape
result
;
shape
result
;
std
::
vector
<
instruction_ref
>
output
;
std
::
vector
<
instruction_ref
>
output
;
...
...
src/include/migraphx/op/abnormal_ops.hpp
View file @
01557ea0
...
@@ -39,6 +39,11 @@ struct undefined
...
@@ -39,6 +39,11 @@ struct undefined
struct
unknown
struct
unknown
{
{
std
::
string
op
;
std
::
string
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
pack
(
f
(
self
.
op
,
"op"
));
}
std
::
string
name
()
const
{
return
"unknown:"
+
op
;
}
std
::
string
name
()
const
{
return
"unknown:"
+
op
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
input
)
const
shape
compute_shape
(
std
::
vector
<
shape
>
input
)
const
{
{
...
...
src/include/migraphx/op/clip.hpp
0 → 100644
View file @
01557ea0
#ifndef MIGRAPHX_GUARD_OPERATORS_CLIP_HPP
#define MIGRAPHX_GUARD_OPERATORS_CLIP_HPP
#include <array>
#include <migraphx/op/unary.hpp>
#include <migraphx/operation.hpp>
#include <migraphx/check_shapes.hpp>
#include <migraphx/stringutils.hpp>
#include <migraphx/streamutils.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/shape_for_each.hpp>
#include <migraphx/config.hpp>
#include <cmath>
#include <utility>
#include <limits>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
op
{
struct
clip
:
unary
<
clip
>
{
float
max_val
=
std
::
numeric_limits
<
float
>::
max
();
float
min_val
=
std
::
numeric_limits
<
float
>::
min
();
clip
()
{}
clip
(
float
max
,
float
min
)
:
max_val
(
max
),
min_val
(
min
)
{}
auto
apply
()
const
{
auto
max
=
max_val
;
auto
min
=
min_val
;
return
[
max
,
min
](
auto
x
)
{
using
type
=
decltype
(
x
);
return
std
::
min
(
std
::
max
(
type
(
min
),
x
),
type
(
max
));
};
}
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
pack
(
f
(
self
.
max_val
,
"max"
),
f
(
self
.
min_val
,
"min"
));
}
};
}
// namespace op
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/include/migraphx/op/concat.hpp
View file @
01557ea0
...
@@ -19,6 +19,13 @@ namespace op {
...
@@ -19,6 +19,13 @@ namespace op {
struct
concat
struct
concat
{
{
std
::
size_t
axis
=
0
;
std
::
size_t
axis
=
0
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
pack
(
f
(
self
.
axis
,
"axis"
));
}
std
::
string
name
()
const
{
return
"concat"
;
}
std
::
string
name
()
const
{
return
"concat"
;
}
std
::
vector
<
std
::
size_t
>
compute_offsets
(
const
shape
&
output_shape
,
std
::
vector
<
std
::
size_t
>
compute_offsets
(
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
const
const
std
::
vector
<
argument
>&
args
)
const
...
...
src/include/migraphx/op/leaky_relu.hpp
View file @
01557ea0
...
@@ -18,19 +18,20 @@ namespace op {
...
@@ -18,19 +18,20 @@ namespace op {
struct
leaky_relu
struct
leaky_relu
{
{
std
::
string
name
()
const
{
return
"leaky_relu"
;
}
float
alpha
;
float
alpha
;
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
return
inputs
.
front
();
}
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
.
alpha
,
"alpha"
));
return
pack
(
f
(
self
.
alpha
,
"alpha"
));
}
}
std
::
string
name
()
const
{
return
"leaky_relu"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
check_shapes
{
inputs
,
*
this
}.
has
(
1
);
return
inputs
.
front
();
}
};
};
}
// namespace op
}
// namespace op
...
...
src/include/migraphx/operation.hpp
View file @
01557ea0
...
@@ -69,7 +69,7 @@ auto operator<<(std::ostream& os, const T& x) -> decltype(os << x.name())
...
@@ -69,7 +69,7 @@ auto operator<<(std::ostream& os, const T& x) -> decltype(os << x.name())
{
{
os
<<
x
.
name
();
os
<<
x
.
name
();
char
delim
=
'['
;
char
delim
=
'['
;
reflect_each
(
x
,
[
&
](
auto
&
y
,
auto
name
)
{
reflect_each
(
x
,
[
&
](
auto
&
&
y
,
auto
name
)
{
os
<<
delim
;
os
<<
delim
;
os
<<
name
<<
"="
;
os
<<
name
<<
"="
;
stream_write_value
(
os
,
y
);
stream_write_value
(
os
,
y
);
...
@@ -87,6 +87,8 @@ namespace operation_equal {
...
@@ -87,6 +87,8 @@ namespace operation_equal {
template
<
class
T
,
class
U
>
template
<
class
T
,
class
U
>
auto
operator
==
(
const
T
&
x
,
const
U
&
y
)
->
decltype
(
x
.
name
()
==
y
.
name
())
auto
operator
==
(
const
T
&
x
,
const
U
&
y
)
->
decltype
(
x
.
name
()
==
y
.
name
())
{
{
static_assert
(
is_reflectable
<
T
>
{}
or
sizeof
(
T
)
<=
1
,
"Missing equality operator or reflect method."
);
if
(
x
.
name
()
!=
y
.
name
())
if
(
x
.
name
()
!=
y
.
name
())
return
false
;
return
false
;
const
auto
&
yy
=
any_cast
<
T
>
(
y
);
const
auto
&
yy
=
any_cast
<
T
>
(
y
);
...
...
src/include/migraphx/operators.hpp
View file @
01557ea0
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <migraphx/op/batch_norm.hpp>
#include <migraphx/op/batch_norm.hpp>
#include <migraphx/op/binary.hpp>
#include <migraphx/op/binary.hpp>
#include <migraphx/op/broadcast.hpp>
#include <migraphx/op/broadcast.hpp>
#include <migraphx/op/clip.hpp>
#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>
...
...
src/include/migraphx/reflect.hpp
View file @
01557ea0
...
@@ -11,6 +11,15 @@ inline namespace MIGRAPHX_INLINE_NS {
...
@@ -11,6 +11,15 @@ inline namespace MIGRAPHX_INLINE_NS {
namespace
detail
{
namespace
detail
{
struct
reflect_placeholder
{
template
<
class
...
Ts
>
int
operator
()(
Ts
&&
...)
const
{
return
0
;
}
};
template
<
class
T
,
class
Selector
>
template
<
class
T
,
class
Selector
>
auto
reflect_impl
(
rank
<
1
>
,
T
&
x
,
Selector
f
)
->
decltype
(
T
::
reflect
(
x
,
f
))
auto
reflect_impl
(
rank
<
1
>
,
T
&
x
,
Selector
f
)
->
decltype
(
T
::
reflect
(
x
,
f
))
{
{
...
@@ -23,8 +32,53 @@ auto reflect_impl(rank<0>, T&, Selector)
...
@@ -23,8 +32,53 @@ auto reflect_impl(rank<0>, T&, Selector)
return
pack
();
return
pack
();
}
}
template
<
class
T
>
auto
reflectable_impl
(
rank
<
1
>
,
T
&&
x
)
->
decltype
(
T
::
reflect
(
x
,
reflect_placeholder
{}),
std
::
true_type
{});
template
<
class
T
>
auto
reflectable_impl
(
rank
<
0
>
,
T
&&
)
->
decltype
(
std
::
false_type
{});
template
<
class
T
>
struct
remove_rvalue_reference
{
using
type
=
T
;
};
template
<
class
T
>
struct
remove_rvalue_reference
<
T
&&>
{
using
type
=
T
;
};
template
<
class
T
>
struct
wrapper
{
using
type
=
typename
remove_rvalue_reference
<
T
>::
type
;
type
data
;
type
get
()
const
{
return
data
;
}
};
template
<
class
T
>
wrapper
<
T
>
wrap
(
std
::
remove_reference_t
<
T
>&
x
)
{
return
wrapper
<
T
>
{
std
::
forward
<
T
>
(
x
)};
}
template
<
class
...
Ts
>
using
auto_tuple_t
=
std
::
tuple
<
typename
remove_rvalue_reference
<
Ts
>::
type
...
>
;
template
<
class
...
Ts
>
auto_tuple_t
<
Ts
...
>
auto_tuple
(
Ts
&&
...
xs
)
{
return
auto_tuple_t
<
Ts
...
>
{
std
::
forward
<
Ts
>
(
xs
)...};
}
}
// namespace detail
}
// namespace detail
template
<
class
T
>
using
is_reflectable
=
decltype
(
detail
::
reflectable_impl
(
rank
<
1
>
{},
std
::
declval
<
T
>
()));
template
<
class
T
,
class
Selector
>
template
<
class
T
,
class
Selector
>
auto
reflect
(
T
&
x
,
Selector
f
)
auto
reflect
(
T
&
x
,
Selector
f
)
{
{
...
@@ -34,17 +88,18 @@ auto reflect(T& x, Selector f)
...
@@ -34,17 +88,18 @@ auto reflect(T& x, Selector f)
template
<
class
T
>
template
<
class
T
>
auto
reflect_tie
(
T
&
x
)
auto
reflect_tie
(
T
&
x
)
{
{
return
reflect
(
x
,
[](
auto
&&
y
,
auto
&&
...)
{
return
std
::
ref
(
y
);
})(
return
reflect
(
x
,
[](
auto
&&
y
,
auto
&&
...)
{
return
detail
::
wrap
<
decltype
(
y
)
>
(
y
);
})(
[](
auto
&&
...
xs
)
{
return
std
::
ti
e
(
xs
.
get
()...);
});
[](
auto
&&
...
xs
)
{
return
detail
::
auto_tupl
e
(
xs
.
get
()...);
});
}
}
template
<
class
T
,
class
F
>
template
<
class
T
,
class
F
>
void
reflect_each
(
T
&
x
,
F
f
)
void
reflect_each
(
T
&
x
,
F
f
)
{
{
return
reflect
(
x
,
[](
auto
&&
y
,
auto
...
ys
)
{
return
pack
(
std
::
ref
(
y
),
ys
...);
})(
return
reflect
(
x
,
[](
auto
&&
y
,
auto
...
ys
)
{
[
&
](
auto
&&
...
xs
)
{
return
pack
(
detail
::
wrap
<
decltype
(
y
)
>
(
y
),
ys
...);
each_args
([
&
](
auto
p
)
{
p
([
&
](
auto
&&
y
,
auto
...
ys
)
{
f
(
y
.
get
(),
ys
...);
});
},
xs
...);
})([
&
](
auto
&&
...
xs
)
{
});
each_args
([
&
](
auto
p
)
{
p
([
&
](
auto
&&
y
,
auto
...
ys
)
{
f
(
y
.
get
(),
ys
...);
});
},
xs
...);
});
}
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
...
...
src/instruction.cpp
View file @
01557ea0
...
@@ -28,6 +28,12 @@ void instruction::replace(const shape& r)
...
@@ -28,6 +28,12 @@ void instruction::replace(const shape& r)
}
}
}
}
void
instruction
::
replace
(
operation
o
)
{
op
=
std
::
move
(
o
);
recompute_shape
();
}
void
instruction
::
recompute_shape
()
{
replace
(
compute_shape
(
op
,
arguments
));
}
void
instruction
::
recompute_shape
()
{
replace
(
compute_shape
(
op
,
arguments
));
}
void
instruction
::
clear_arguments
()
void
instruction
::
clear_arguments
()
...
...
src/onnx/onnx.cpp
View file @
01557ea0
...
@@ -63,6 +63,7 @@ struct onnx_parser
...
@@ -63,6 +63,7 @@ struct onnx_parser
add_variadic_op
(
"Max"
,
op
::
max
{});
add_variadic_op
(
"Max"
,
op
::
max
{});
add_variadic_op
(
"Min"
,
op
::
min
{});
add_variadic_op
(
"Min"
,
op
::
min
{});
add_mem_op
(
"Clip"
,
&
onnx_parser
::
parse_clip
);
add_mem_op
(
"LRN"
,
&
onnx_parser
::
parse_lrn
);
add_mem_op
(
"LRN"
,
&
onnx_parser
::
parse_lrn
);
add_mem_op
(
"ImageScaler"
,
&
onnx_parser
::
parse_imagescaler
);
add_mem_op
(
"ImageScaler"
,
&
onnx_parser
::
parse_imagescaler
);
add_mem_op
(
"LeakyRelu"
,
&
onnx_parser
::
parse_leaky_relu
);
add_mem_op
(
"LeakyRelu"
,
&
onnx_parser
::
parse_leaky_relu
);
...
@@ -225,6 +226,22 @@ struct onnx_parser
...
@@ -225,6 +226,22 @@ struct onnx_parser
});
});
}
}
instruction_ref
parse_clip
(
const
std
::
string
&
,
const
attribute_map
&
attributes
,
std
::
vector
<
instruction_ref
>
args
)
{
op
::
clip
op
;
if
(
contains
(
attributes
,
"max"
))
{
op
.
max_val
=
parse_value
(
attributes
.
at
(
"max"
)).
at
<
float
>
();
}
if
(
contains
(
attributes
,
"min"
))
{
op
.
min_val
=
parse_value
(
attributes
.
at
(
"min"
)).
at
<
float
>
();
}
return
prog
.
add_instruction
(
op
,
std
::
move
(
args
));
}
instruction_ref
instruction_ref
parse_softmax
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
parse_softmax
(
const
std
::
string
&
,
const
attribute_map
&
,
std
::
vector
<
instruction_ref
>
args
)
{
{
...
...
src/program.cpp
View file @
01557ea0
...
@@ -63,11 +63,16 @@ static void print_program(const program& p, F print_func)
...
@@ -63,11 +63,16 @@ static void print_program(const program& p, F print_func)
for
(
auto
ins
:
iterator_for
(
p
))
for
(
auto
ins
:
iterator_for
(
p
))
{
{
std
::
string
var_name
=
"@"
+
std
::
to_string
(
count
)
;
std
::
string
var_name
;
if
(
ins
->
name
()
==
"@param"
)
if
(
ins
->
name
()
==
"@param"
)
{
{
var_name
=
any_cast
<
builtin
::
param
>
(
ins
->
get_operator
()).
parameter
;
var_name
=
any_cast
<
builtin
::
param
>
(
ins
->
get_operator
()).
parameter
;
}
}
else
{
var_name
=
"@"
+
std
::
to_string
(
count
);
count
++
;
}
names
.
emplace
(
ins
,
var_name
);
names
.
emplace
(
ins
,
var_name
);
// TODO: Use all_of
// TODO: Use all_of
...
@@ -78,8 +83,6 @@ static void print_program(const program& p, F print_func)
...
@@ -78,8 +83,6 @@ static void print_program(const program& p, F print_func)
}
}
print_func
(
ins
,
names
);
print_func
(
ins
,
names
);
count
++
;
}
}
}
}
...
...
src/targets/cpu/lowering.cpp
View file @
01557ea0
...
@@ -48,6 +48,12 @@ struct cpu_batch_norm_inference
...
@@ -48,6 +48,12 @@ struct cpu_batch_norm_inference
{
{
op
::
batch_norm_inference
op
;
op
::
batch_norm_inference
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"cpu::batch_norm_inference"
;
}
std
::
string
name
()
const
{
return
"cpu::batch_norm_inference"
;
}
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
);
}
...
@@ -107,6 +113,12 @@ struct cpu_lrn
...
@@ -107,6 +113,12 @@ struct cpu_lrn
{
{
op
::
lrn
op
;
op
::
lrn
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"cpu::lrn"
;
}
std
::
string
name
()
const
{
return
"cpu::lrn"
;
}
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
&
,
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
context
&
,
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
...
@@ -144,6 +156,12 @@ struct cpu_convolution
...
@@ -144,6 +156,12 @@ struct cpu_convolution
{
{
op
::
convolution
op
;
op
::
convolution
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"cpu::convolution"
;
}
std
::
string
name
()
const
{
return
"cpu::convolution"
;
}
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
&
,
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
argument
compute
(
context
&
,
shape
output_shape
,
std
::
vector
<
argument
>
args
)
const
...
@@ -190,6 +208,12 @@ struct cpu_im2col
...
@@ -190,6 +208,12 @@ struct cpu_im2col
{
{
op
::
im2col
op
;
op
::
im2col
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
static
std
::
string
name
()
{
return
"cpu::im2col"
;
}
static
std
::
string
name
()
{
return
"cpu::im2col"
;
}
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
);
}
...
@@ -271,6 +295,12 @@ struct cpu_pooling
...
@@ -271,6 +295,12 @@ struct cpu_pooling
{
{
op
::
pooling
op
;
op
::
pooling
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"cpu::pooling_"
+
Op
::
name
();
}
std
::
string
name
()
const
{
return
"cpu::pooling_"
+
Op
::
name
();
}
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
...
@@ -315,20 +345,35 @@ struct cpu_pooling
...
@@ -315,20 +345,35 @@ struct cpu_pooling
}
}
};
};
struct
cpu_
contiguous
struct
cpu_
op
{
{
op
::
contiguous
op
;
op
eration
op
;
std
::
string
name
()
const
{
return
"cpu::
contiguous"
;
}
std
::
string
name
()
const
{
return
"cpu::
"
+
op
.
name
()
;
}
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
,
const
std
::
vector
<
argument
>
&
args
)
const
{
{
return
op
.
compute
(
output_shape
,
std
::
move
(
args
)
)
;
return
op
.
compute
(
output_shape
,
args
);
}
}
friend
bool
operator
==
(
const
cpu_op
&
x
,
const
cpu_op
&
y
)
{
return
x
.
op
==
y
.
op
;
}
friend
bool
operator
==
(
const
cpu_op
&
x
,
const
operation
&
y
)
{
if
(
x
.
name
()
!=
y
.
name
())
return
false
;
return
x
==
any_cast
<
cpu_op
>
(
y
);
}
friend
bool
operator
==
(
const
operation
&
x
,
const
cpu_op
&
y
)
{
return
y
==
x
;
}
};
};
struct
cpu_pad
struct
cpu_pad
{
{
op
::
pad
op
;
op
::
pad
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"cpu::contiguous"
;
}
std
::
string
name
()
const
{
return
"cpu::contiguous"
;
}
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
...
@@ -352,20 +397,15 @@ struct cpu_pad
...
@@ -352,20 +397,15 @@ struct cpu_pad
}
}
};
};
struct
cpu_concat
{
op
::
concat
op
;
std
::
string
name
()
const
{
return
"cpu::concat"
;
}
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
{
return
op
.
compute
(
output_shape
,
std
::
move
(
args
));
}
};
struct
cpu_gemm
struct
cpu_gemm
{
{
op
::
dot
op
;
op
::
dot
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"cpu::dot"
;
}
std
::
string
name
()
const
{
return
"cpu::dot"
;
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
{
...
@@ -408,162 +448,6 @@ struct cpu_gemm
...
@@ -408,162 +448,6 @@ struct cpu_gemm
}
}
};
};
struct
cpu_gather
{
op
::
gather
op
;
std
::
string
name
()
const
{
return
"cpu::gather"
;
}
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
{
return
op
.
compute
(
output_shape
,
std
::
move
(
args
));
}
};
struct
identity_op
{
std
::
string
name
()
const
{
return
"cpu::identity"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
x
;
};
}
};
struct
abs_op
{
std
::
string
name
()
const
{
return
"cpu::abs"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
abs
(
make_signed
(
x
));
};
}
};
struct
exp_op
{
std
::
string
name
()
const
{
return
"cpu::exp"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
exp
(
x
);
};
}
};
struct
log_op
{
std
::
string
name
()
const
{
return
"cpu::log"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
log
(
x
);
};
}
};
struct
sin_op
{
std
::
string
name
()
const
{
return
"cpu::sin"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
sin
(
x
);
};
}
};
struct
cos_op
{
std
::
string
name
()
const
{
return
"cpu::cos"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
cos
(
x
);
};
}
};
struct
tan_op
{
std
::
string
name
()
const
{
return
"cpu::tan"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
tan
(
x
);
};
}
};
struct
asin_op
{
std
::
string
name
()
const
{
return
"cpu::asin"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
asin
(
x
);
};
}
};
struct
acos_op
{
std
::
string
name
()
const
{
return
"cpu::acos"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
acos
(
x
);
};
}
};
struct
atan_op
{
std
::
string
name
()
const
{
return
"cpu::atan"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
atan
(
x
);
};
}
};
struct
sinh_op
{
std
::
string
name
()
const
{
return
"cpu::sinh"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
sinh
(
x
);
};
}
};
struct
cosh_op
{
std
::
string
name
()
const
{
return
"cpu::cosh"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
cosh
(
x
);
};
}
};
struct
tanh_op
{
std
::
string
name
()
const
{
return
"cpu::tanh"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
tanh
(
x
);
};
}
};
struct
sigmoid_op
{
std
::
string
name
()
const
{
return
"cpu::sigmoid"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
1.
f
/
(
1.
f
+
std
::
exp
(
-
x
));
};
}
};
struct
neg_op
{
std
::
string
name
()
const
{
return
"cpu::neg"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
-
x
;
};
}
};
struct
relu_op
{
std
::
string
name
()
const
{
return
"cpu::relu"
;
}
auto
fcn
()
const
{
return
[](
auto
x
)
{
return
std
::
max
(
decltype
(
x
){
0
},
x
);
};
}
};
struct
leaky_relu_op
struct
leaky_relu_op
{
{
op
::
leaky_relu
op
;
op
::
leaky_relu
op
;
...
@@ -590,6 +474,12 @@ template <typename Op>
...
@@ -590,6 +474,12 @@ template <typename Op>
struct
cpu_unary
struct
cpu_unary
{
{
Op
op
;
Op
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
.
op
,
f
);
}
std
::
string
name
()
const
{
return
op
.
name
();
}
std
::
string
name
()
const
{
return
op
.
name
();
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
{
...
@@ -668,6 +558,13 @@ struct softmax2d
...
@@ -668,6 +558,13 @@ struct softmax2d
struct
cpu_logsoftmax
struct
cpu_logsoftmax
{
{
op
::
logsoftmax
op
;
op
::
logsoftmax
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"cpu::logsoftmax"
;
}
std
::
string
name
()
const
{
return
"cpu::logsoftmax"
;
}
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
);
}
...
@@ -734,116 +631,6 @@ struct cpu_logsoftmax
...
@@ -734,116 +631,6 @@ struct cpu_logsoftmax
}
}
};
};
struct
cpu_convert
{
op
::
convert
op
;
std
::
string
name
()
const
{
return
"cpu_convert"
;
}
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
{
return
op
.
compute
(
output_shape
,
std
::
move
(
args
));
}
};
struct
add_op
{
std
::
string
name
()
const
{
return
"add"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
+
y
;
};
}
};
struct
sub_op
{
std
::
string
name
()
const
{
return
"sub"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
-
y
;
};
}
};
struct
mul_op
{
std
::
string
name
()
const
{
return
"mul"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
*
y
;
};
}
};
struct
div_op
{
std
::
string
name
()
const
{
return
"div"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
x
/
y
;
};
}
};
struct
max_op
{
std
::
string
name
()
const
{
return
"max"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
std
::
max
(
x
,
y
);
};
}
};
struct
min_op
{
std
::
string
name
()
const
{
return
"min"
;
}
auto
fcn
()
const
{
return
[](
auto
x
,
auto
y
)
{
return
std
::
min
(
x
,
y
);
};
}
};
template
<
typename
Op
>
struct
cpu_binary
{
Op
op
;
std
::
string
name
()
const
{
return
"cpu::"
+
op
.
name
();
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
{
check_shapes
{
inputs
}.
has
(
2
).
same_type
().
same_dims
();
auto
s0
=
inputs
.
at
(
0
);
auto
s1
=
inputs
.
at
(
1
);
if
(
s0
==
s1
and
s0
.
packed
())
{
return
s0
;
}
else
{
return
{
s0
.
type
(),
s0
.
lens
()};
}
}
argument
compute
(
context
&
,
const
shape
&
output_shape
,
std
::
vector
<
argument
>
args
)
const
{
argument
result
{
output_shape
};
visit_all
(
result
,
args
[
0
],
args
[
1
])([
&
](
auto
output
,
auto
input1
,
auto
input2
)
{
auto
s1
=
input1
.
get_shape
();
auto
s2
=
input2
.
get_shape
();
if
(
s1
==
s2
and
s1
.
standard
())
{
std
::
transform
(
input1
.
begin
(),
input1
.
end
(),
input2
.
begin
(),
output
.
begin
(),
op
.
fcn
());
}
else
{
shape_for_each
(
output
.
get_shape
(),
[
&
](
const
auto
&
idx
)
{
output
(
idx
.
begin
(),
idx
.
end
())
=
op
.
fcn
()(
input1
(
idx
.
begin
(),
idx
.
end
()),
input2
(
idx
.
begin
(),
idx
.
end
()));
});
}
});
return
result
;
}
};
struct
cpu_apply
struct
cpu_apply
{
{
program
*
prog
;
program
*
prog
;
...
@@ -863,44 +650,17 @@ struct cpu_apply
...
@@ -863,44 +650,17 @@ struct cpu_apply
void
init
()
void
init
()
{
{
apply_map
[
"im2col"
]
=
extend_op
<
cpu_im2col
,
op
::
im2col
>
();
apply_map
[
"convolution"
]
=
extend_op
<
cpu_convolution
,
op
::
convolution
>
();
apply_map
[
"dot"
]
=
extend_op
<
cpu_gemm
,
op
::
dot
>
();
apply_map
[
"batch_norm_inference"
]
=
apply_map
[
"batch_norm_inference"
]
=
extend_op
<
cpu_batch_norm_inference
,
op
::
batch_norm_inference
>
();
extend_op
<
cpu_batch_norm_inference
,
op
::
batch_norm_inference
>
();
apply_map
[
"lrn"
]
=
extend_op
<
cpu_lrn
,
op
::
lrn
>
();
apply_map
[
"convolution"
]
=
extend_op
<
cpu_convolution
,
op
::
convolution
>
();
apply_map
[
"contiguous"
]
=
extend_op
<
cpu_contiguous
,
op
::
contiguous
>
();
apply_map
[
"dot"
]
=
extend_op
<
cpu_gemm
,
op
::
dot
>
();
apply_map
[
"pad"
]
=
extend_op
<
cpu_pad
,
op
::
pad
>
();
apply_map
[
"elu"
]
=
extend_op
<
cpu_unary
<
elu_op
>
,
op
::
elu
>
();
apply_map
[
"concat"
]
=
extend_op
<
cpu_concat
,
op
::
concat
>
();
apply_map
[
"im2col"
]
=
extend_op
<
cpu_im2col
,
op
::
im2col
>
();
apply_map
[
"gather"
]
=
extend_op
<
cpu_gather
,
op
::
gather
>
();
apply_map
[
"leaky_relu"
]
=
extend_op
<
cpu_unary
<
leaky_relu_op
>
,
op
::
leaky_relu
>
();
apply_map
[
"convert"
]
=
extend_op
<
cpu_convert
,
op
::
convert
>
();
apply_map
[
"logsoftmax"
]
=
extend_op
<
cpu_logsoftmax
,
op
::
logsoftmax
>
();
apply_map
[
"logsoftmax"
]
=
extend_op
<
cpu_logsoftmax
,
op
::
logsoftmax
>
();
apply_map
[
"lrn"
]
=
extend_op
<
cpu_lrn
,
op
::
lrn
>
();
apply_map
[
"leaky_relu"
]
=
extend_op
<
cpu_unary
<
leaky_relu_op
>
,
op
::
leaky_relu
>
();
apply_map
[
"pad"
]
=
extend_op
<
cpu_pad
,
op
::
pad
>
();
apply_map
[
"elu"
]
=
extend_op
<
cpu_unary
<
elu_op
>
,
op
::
elu
>
();
apply_map
[
"softmax"
]
=
simple_op
<
softmax2d
>
();
apply_map
[
"identity"
]
=
simple_op
<
cpu_unary
<
identity_op
>>
();
apply_map
[
"abs"
]
=
simple_op
<
cpu_unary
<
abs_op
>>
();
apply_map
[
"sinh"
]
=
simple_op
<
cpu_unary
<
sinh_op
>>
();
apply_map
[
"cosh"
]
=
simple_op
<
cpu_unary
<
cosh_op
>>
();
apply_map
[
"tanh"
]
=
simple_op
<
cpu_unary
<
tanh_op
>>
();
apply_map
[
"sigmoid"
]
=
simple_op
<
cpu_unary
<
sigmoid_op
>>
();
apply_map
[
"exp"
]
=
simple_op
<
cpu_unary
<
exp_op
>>
();
apply_map
[
"log"
]
=
simple_op
<
cpu_unary
<
log_op
>>
();
apply_map
[
"neg"
]
=
simple_op
<
cpu_unary
<
neg_op
>>
();
apply_map
[
"sin"
]
=
simple_op
<
cpu_unary
<
sin_op
>>
();
apply_map
[
"cos"
]
=
simple_op
<
cpu_unary
<
cos_op
>>
();
apply_map
[
"tan"
]
=
simple_op
<
cpu_unary
<
tan_op
>>
();
apply_map
[
"asin"
]
=
simple_op
<
cpu_unary
<
asin_op
>>
();
apply_map
[
"acos"
]
=
simple_op
<
cpu_unary
<
acos_op
>>
();
apply_map
[
"atan"
]
=
simple_op
<
cpu_unary
<
atan_op
>>
();
apply_map
[
"relu"
]
=
simple_op
<
cpu_unary
<
relu_op
>>
();
apply_map
[
"add"
]
=
simple_op
<
cpu_binary
<
add_op
>>
();
apply_map
[
"sub"
]
=
simple_op
<
cpu_binary
<
sub_op
>>
();
apply_map
[
"mul"
]
=
simple_op
<
cpu_binary
<
mul_op
>>
();
apply_map
[
"div"
]
=
simple_op
<
cpu_binary
<
div_op
>>
();
apply_map
[
"max"
]
=
simple_op
<
cpu_binary
<
max_op
>>
();
apply_map
[
"min"
]
=
simple_op
<
cpu_binary
<
min_op
>>
();
apply_map
[
"softmax"
]
=
simple_op
<
softmax2d
>
();
}
}
void
apply
()
void
apply
()
...
@@ -916,9 +676,18 @@ struct cpu_apply
...
@@ -916,9 +676,18 @@ struct cpu_apply
{
{
apply_map
.
at
(
it
->
name
())(
it
);
apply_map
.
at
(
it
->
name
())(
it
);
}
}
else
if
(
is_context_free
(
it
->
get_operator
()))
{
apply_cpu_op
(
it
);
}
}
}
}
}
void
apply_cpu_op
(
instruction_ref
ins
)
{
prog
->
replace_instruction
(
ins
,
cpu_op
{
ins
->
get_operator
()},
ins
->
inputs
());
}
template
<
class
T
>
template
<
class
T
>
void
apply_simple_op
(
instruction_ref
ins
)
void
apply_simple_op
(
instruction_ref
ins
)
{
{
...
...
src/targets/gpu/CMakeLists.txt
View file @
01557ea0
...
@@ -33,6 +33,7 @@ add_library(migraphx_device
...
@@ -33,6 +33,7 @@ add_library(migraphx_device
device/pad.cpp
device/pad.cpp
device/gather.cpp
device/gather.cpp
device/sub.cpp
device/sub.cpp
device/clip.cpp
)
)
set_target_properties
(
migraphx_device PROPERTIES EXPORT_NAME device
)
set_target_properties
(
migraphx_device PROPERTIES EXPORT_NAME device
)
rocm_clang_tidy_check
(
migraphx_device
)
rocm_clang_tidy_check
(
migraphx_device
)
...
@@ -67,6 +68,7 @@ add_library(migraphx_gpu
...
@@ -67,6 +68,7 @@ add_library(migraphx_gpu
lrn.cpp
lrn.cpp
schedule_model.cpp
schedule_model.cpp
adjust_allocation.cpp
adjust_allocation.cpp
clip.cpp
)
)
set_target_properties
(
migraphx_gpu PROPERTIES EXPORT_NAME gpu
)
set_target_properties
(
migraphx_gpu PROPERTIES EXPORT_NAME gpu
)
rocm_clang_tidy_check
(
migraphx_gpu
)
rocm_clang_tidy_check
(
migraphx_gpu
)
...
...
src/targets/gpu/clip.cpp
0 → 100644
View file @
01557ea0
#include <migraphx/gpu/clip.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/device/clip.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
shape
hip_clip
::
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
{
inputs
.
pop_back
();
return
op
.
compute_shape
(
inputs
);
}
argument
hip_clip
::
compute
(
context
&
ctx
,
const
shape
&
,
const
std
::
vector
<
argument
>&
args
)
const
{
device
::
clip
(
ctx
.
get_stream
().
get
(),
args
.
back
(),
args
.
front
(),
op
.
max_val
,
op
.
min_val
);
return
args
.
back
();
}
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/device/clip.cpp
0 → 100644
View file @
01557ea0
#include <migraphx/gpu/device/clip.hpp>
#include <migraphx/gpu/device/nary.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
device
{
void
clip
(
hipStream_t
stream
,
const
argument
&
result
,
const
argument
&
arg1
,
const
float
max
,
const
float
min
)
{
nary
(
stream
,
result
,
arg1
)(
[
max
,
min
](
auto
x
)
{
return
std
::
min
<
decltype
(
x
)
>
(
std
::
max
<
decltype
(
x
)
>
(
min
,
x
),
max
);
});
}
}
// namespace device
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/include/migraphx/gpu/abs.hpp
View file @
01557ea0
...
@@ -13,6 +13,13 @@ struct context;
...
@@ -13,6 +13,13 @@ struct context;
struct
miopen_abs
struct
miopen_abs
{
{
shared
<
activation_descriptor
>
ad
;
shared
<
activation_descriptor
>
ad
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
gpu
::
reflect
(
self
.
ad
.
get
(),
f
);
}
std
::
string
name
()
const
{
return
"gpu::abs"
;
}
std
::
string
name
()
const
{
return
"gpu::abs"
;
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
;
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
;
argument
argument
...
...
src/targets/gpu/include/migraphx/gpu/batchnorm.hpp
View file @
01557ea0
...
@@ -13,6 +13,13 @@ struct context;
...
@@ -13,6 +13,13 @@ struct context;
struct
miopen_batch_norm_inference
struct
miopen_batch_norm_inference
{
{
op
::
batch_norm_inference
op
;
op
::
batch_norm_inference
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"gpu::batch_norm_inference"
;
}
std
::
string
name
()
const
{
return
"gpu::batch_norm_inference"
;
}
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
;
shape
compute_shape
(
const
std
::
vector
<
shape
>&
inputs
)
const
;
argument
argument
...
...
src/targets/gpu/include/migraphx/gpu/clip.hpp
0 → 100644
View file @
01557ea0
#ifndef MIGRAPHX_GUARD_RTGLIB_CLIP_HPP
#define MIGRAPHX_GUARD_RTGLIB_CLIP_HPP
#include <migraphx/shape.hpp>
#include <migraphx/op/clip.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
struct
context
;
struct
hip_clip
{
op
::
clip
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"gpu::clip"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
;
argument
compute
(
context
&
ctx
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
args
)
const
;
std
::
ptrdiff_t
output_alias
(
const
std
::
vector
<
shape
>&
shapes
)
const
{
return
shapes
.
size
()
-
1
;
}
};
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
#endif
src/targets/gpu/include/migraphx/gpu/concat.hpp
View file @
01557ea0
...
@@ -14,6 +14,12 @@ struct hip_concat
...
@@ -14,6 +14,12 @@ struct hip_concat
{
{
op
::
concat
op
;
op
::
concat
op
;
template
<
class
Self
,
class
F
>
static
auto
reflect
(
Self
&
self
,
F
f
)
{
return
migraphx
::
reflect
(
self
.
op
,
f
);
}
std
::
string
name
()
const
{
return
"gpu::concat"
;
}
std
::
string
name
()
const
{
return
"gpu::concat"
;
}
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
;
shape
compute_shape
(
std
::
vector
<
shape
>
inputs
)
const
;
argument
argument
...
...
Prev
1
2
3
Next
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