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
c45ba3d3
"...composable_kernel_onnxruntime.git" did not exist on "9d3f634a3cc37599db9f3ebfeb1f9a3c45d9a673"
Unverified
Commit
c45ba3d3
authored
Jan 12, 2023
by
Charlie Lin
Committed by
GitHub
Jan 12, 2023
Browse files
Merge branch 'develop' into dyn_onnx_gemm
parents
5b399aef
3fb5c0ef
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
479 additions
and
31 deletions
+479
-31
.github/workflows/gh_project.yaml
.github/workflows/gh_project.yaml
+19
-0
Jenkinsfile
Jenkinsfile
+18
-8
src/onnx/onnx_parser.cpp
src/onnx/onnx_parser.cpp
+13
-3
src/targets/gpu/jit/gather.cpp
src/targets/gpu/jit/gather.cpp
+89
-0
src/targets/gpu/kernels/include/migraphx/kernels/gather.hpp
src/targets/gpu/kernels/include/migraphx/kernels/gather.hpp
+64
-0
src/targets/gpu/kernels/include/migraphx/kernels/math.hpp
src/targets/gpu/kernels/include/migraphx/kernels/math.hpp
+19
-11
src/targets/gpu/kernels/include/migraphx/kernels/shape.hpp
src/targets/gpu/kernels/include/migraphx/kernels/shape.hpp
+1
-0
src/targets/gpu/lowering.cpp
src/targets/gpu/lowering.cpp
+0
-1
test/onnx/conv_dynamic_bias_test.onnx
test/onnx/conv_dynamic_bias_test.onnx
+0
-0
test/onnx/gen_onnx.py
test/onnx/gen_onnx.py
+18
-0
test/onnx/onnx_test.cpp
test/onnx/onnx_test.cpp
+19
-0
test/py/onnx_backend_test.py
test/py/onnx_backend_test.py
+13
-0
test/verify/test_gather.cpp
test/verify/test_gather.cpp
+8
-2
test/verify/test_gather_1d_index.cpp
test/verify/test_gather_1d_index.cpp
+7
-2
test/verify/test_gather_asymmetric.cpp
test/verify/test_gather_asymmetric.cpp
+45
-0
test/verify/test_gather_neg_axis_even_dims.cpp
test/verify/test_gather_neg_axis_even_dims.cpp
+45
-0
test/verify/test_gather_onnx_axis_one_ex.cpp
test/verify/test_gather_onnx_axis_one_ex.cpp
+46
-0
test/verify/test_gather_onnx_axis_zero_ex.cpp
test/verify/test_gather_onnx_axis_zero_ex.cpp
+46
-0
test/verify/test_gather_pos_neg_indices.cpp
test/verify/test_gather_pos_neg_indices.cpp
+2
-2
test/verify/test_gather_scalar_index.cpp
test/verify/test_gather_scalar_index.cpp
+7
-2
No files found.
.github/workflows/gh_project.yaml
0 → 100644
View file @
c45ba3d3
name
:
Update Github Project
on
:
pull_request
:
types
:
-
opened
issues
:
types
:
-
opened
jobs
:
add-to-project
:
name
:
Add PRs and issues to MIGX project
runs-on
:
ubuntu-latest
steps
:
-
uses
:
actions/add-to-project@v0.4.0
with
:
project-url
:
https://github.com/orgs/ROCmSoftwarePlatform/projects/20
github-token
:
$${{ ${{ github.token }} }}
Jenkinsfile
View file @
c45ba3d3
...
@@ -11,16 +11,22 @@ def rocmtestnode(Map conf) {
...
@@ -11,16 +11,22 @@ def rocmtestnode(Map conf) {
def
image
=
'migraphxlib'
def
image
=
'migraphxlib'
env
.
CCACHE_COMPRESSLEVEL
=
7
env
.
CCACHE_COMPRESSLEVEL
=
7
env
.
CCACHE_DIR
=
ccache
env
.
CCACHE_DIR
=
ccache
def
cmake_build
=
{
compiler
,
flags
->
def
cmake_build
=
{
bconf
->
def
compiler
=
bconf
.
get
(
"compiler"
,
"/opt/rocm/llvm/bin/clang++"
)
def
flags
=
bconf
.
get
(
"flags"
,
""
)
def
gpu_debug
=
bconf
.
get
(
"gpu_debug"
,
"0"
)
def
cmd
=
"""
def
cmd
=
"""
env
ulimit -c unlimited
ulimit -c unlimited
echo "leak:dnnl::impl::malloc" > suppressions.txt
echo "leak:dnnl::impl::malloc" > suppressions.txt
export LSAN_OPTIONS="suppressions=\$(pwd)/suppressions.txt"
export LSAN_OPTIONS="suppressions=\$(pwd)/suppressions.txt"
export MIGRAPHX_GPU_DEBUG=${gpu_debug}
export CXX=${compiler}
export CXXFLAGS='-Werror'
env
rm -rf build
rm -rf build
mkdir build
mkdir build
cd build
cd build
CXX=${compiler} CXXFLAGS='-Werror'
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ${flags} ..
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ${flags} ..
make -j\$(nproc) generate all doc package check VERBOSE=1
make -j\$(nproc) generate all doc package check VERBOSE=1
"""
"""
echo
cmd
echo
cmd
...
@@ -93,28 +99,32 @@ rocmtest clang_debug: rocmnode('vega') { cmake_build ->
...
@@ -93,28 +99,32 @@ rocmtest clang_debug: rocmnode('vega') { cmake_build ->
stage
(
'Hip Clang Debug'
)
{
stage
(
'Hip Clang Debug'
)
{
def
sanitizers
=
"undefined"
def
sanitizers
=
"undefined"
def
debug_flags
=
"-g -O2 -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
def
debug_flags
=
"-g -O2 -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build
(
"/opt/rocm/llvm/bin/clang++"
,
"-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}'"
)
cmake_build
(
flags:
"-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}'"
)
}
},
clang_gpu_debug:
rocmnode
(
'vega'
)
{
cmake_build
->
stage
(
'Hip Clang GPU Debug'
)
{
cmake_build
(
flags:
"-DCMAKE_BUILD_TYPE=release"
,
gpu_debug:
true
)
}
}
},
clang_release:
rocmnode
(
'vega'
)
{
cmake_build
->
},
clang_release:
rocmnode
(
'vega'
)
{
cmake_build
->
stage
(
'Hip Clang Release'
)
{
stage
(
'Hip Clang Release'
)
{
cmake_build
(
"/opt/rocm/llvm/bin/clang++"
,
"-DCMAKE_BUILD_TYPE=release"
)
cmake_build
(
flags:
"-DCMAKE_BUILD_TYPE=release"
)
stash
includes:
'build/*.deb'
,
name:
'migraphx-package'
stash
includes:
'build/*.deb'
,
name:
'migraphx-package'
}
}
},
mlir_debug:
rocmnode
(
'vega'
)
{
cmake_build
->
},
mlir_debug:
rocmnode
(
'vega'
)
{
cmake_build
->
stage
(
'MLIR Debug'
)
{
stage
(
'MLIR Debug'
)
{
def
sanitizers
=
"undefined"
def
sanitizers
=
"undefined"
def
debug_flags
=
"-g -O2 -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
def
debug_flags
=
"-g -O2 -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build
(
"/opt/rocm/llvm/bin/clang++"
,
"-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_MLIR=On -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}'"
)
cmake_build
(
flags:
"-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_MLIR=On -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}'"
)
}
}
},
clang_asan:
rocmnode
(
'nogpu'
)
{
cmake_build
->
},
clang_asan:
rocmnode
(
'nogpu'
)
{
cmake_build
->
stage
(
'Clang ASAN'
)
{
stage
(
'Clang ASAN'
)
{
def
sanitizers
=
"undefined,address"
def
sanitizers
=
"undefined,address"
def
debug_flags
=
"-g -O2 -fno-omit-frame-pointer -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
def
debug_flags
=
"-g -O2 -fno-omit-frame-pointer -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build
(
"/opt/rocm/llvm/bin/clang++"
,
"-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_GPU=Off -DMIGRAPHX_ENABLE_CPU=On -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}'"
)
cmake_build
(
flags:
"-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_GPU=Off -DMIGRAPHX_ENABLE_CPU=On -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}' -DCMAKE_C_FLAGS_DEBUG='${debug_flags}'"
)
}
}
}
//, clang_release_navi: rocmnode('navi21') { cmake_build ->
}
//, clang_release_navi: rocmnode('navi21') { cmake_build ->
// stage('HIP Clang Release Navi') {
// stage('HIP Clang Release Navi') {
// cmake_build(
"/opt/rocm/llvm/bin/clang++",
"-DCMAKE_BUILD_TYPE=release")
// cmake_build(
flags:
"-DCMAKE_BUILD_TYPE=release")
// }
// }
//}
//}
...
...
src/onnx/onnx_parser.cpp
View file @
c45ba3d3
...
@@ -110,9 +110,19 @@ instruction_ref onnx_parser::node_info::add_bias(const std::vector<instruction_r
...
@@ -110,9 +110,19 @@ instruction_ref onnx_parser::node_info::add_bias(const std::vector<instruction_r
{
{
if
(
args
.
size
()
==
3
)
if
(
args
.
size
()
==
3
)
{
{
auto
bias_bcast
=
mod
->
add_instruction
(
instruction_ref
bias_bcast
;
make_op
(
"broadcast"
,
{{
"axis"
,
axis
},
{
"out_lens"
,
curr_ins
->
get_shape
().
lens
()}}),
// if curr_ins has a dynamic output shape use 2 input broadcast
args
[
2
]);
if
(
curr_ins
->
get_shape
().
dynamic
())
{
bias_bcast
=
mod
->
add_instruction
(
make_op
(
"broadcast"
,
{{
"axis"
,
axis
}}),
args
[
2
],
curr_ins
);
}
else
{
bias_bcast
=
mod
->
add_instruction
(
make_op
(
"broadcast"
,
{{
"axis"
,
axis
},
{
"out_lens"
,
curr_ins
->
get_shape
().
lens
()}}),
args
[
2
]);
}
return
mod
->
add_instruction
(
make_op
(
"add"
),
curr_ins
,
bias_bcast
);
return
mod
->
add_instruction
(
make_op
(
"add"
),
curr_ins
,
bias_bcast
);
}
}
return
curr_ins
;
return
curr_ins
;
...
...
src/targets/gpu/jit/gather.cpp
0 → 100644
View file @
c45ba3d3
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <migraphx/gpu/compiler.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/compile_hip_code_object.hpp>
#include <migraphx/gpu/compile_hip.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
// NOLINTNEXTLINE
static
const
char
*
const
gather_kernel
=
R"__migraphx__(
#include <migraphx/kernels/gather.hpp>
#include <migraphx/kernels/ops.hpp>
#include <migraphx/kernels/integral_constant.hpp>
#include <migraphx/kernels/generic_constant.hpp>
#include <args.hpp>
namespace migraphx {
extern "C" {
__global__ void gather_kernel(void* in_data, void* in_indices, void* output)
{
make_tensors()(in_data, in_indices, output)([](auto&&... xs) {
gather<${axis}>(xs...);
});
}
}
} // namespace migraphx
)__migraphx__"
;
struct
gather_compiler
:
compiler
<
gather_compiler
>
{
std
::
vector
<
std
::
string
>
names
()
const
{
return
{
"gather"
};
}
operation
compile_op
(
context
&
ctx
,
const
std
::
vector
<
shape
>&
inputs
,
const
value
&
v
)
const
{
hip_compile_options
options
;
const
auto
&
out_s
=
inputs
.
back
();
options
.
set_launch_params
(
v
,
compute_global_for
(
ctx
,
out_s
.
elements
()));
options
.
inputs
=
inputs
;
options
.
output
=
out_s
;
options
.
kernel_name
=
"gather_kernel"
;
options
.
virtual_inputs
=
inputs
;
auto
axis
=
v
.
at
(
"axis"
).
to
<
std
::
string
>
();
auto
src
=
interpolate_string
(
gather_kernel
,
{{
"axis"
,
axis
}});
return
compile_hip_code_object
(
src
,
options
);
}
compiler_replace
compile
(
context
&
ctx
,
instruction_ref
ins
,
const
operation
&
op
)
const
{
return
replace
(
compile_op
(
ctx
,
to_shapes
(
ins
->
inputs
()),
op
.
to_value
()));
}
};
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/kernels/include/migraphx/kernels/gather.hpp
0 → 100644
View file @
c45ba3d3
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MIGRAPHX_GUARD_KERNELS_GATHER_HPP
#define MIGRAPHX_GUARD_KERNELS_GATHER_HPP
#include <migraphx/kernels/index.hpp>
#include <migraphx/kernels/shape.hpp>
#include <migraphx/kernels/algorithm.hpp>
#include <migraphx/kernels/tensor_view.hpp>
namespace
migraphx
{
template
<
int
Axis
,
class
Input
,
class
Indices
>
constexpr
auto
gather_shape
(
Input
input
,
Indices
indices
)
{
auto
lengths
=
input
.
lens
;
lengths
[
Axis
]
=
indices
.
elements
();
return
make_shape
(
lengths
,
input
.
strides
);
}
template
<
int
Axis
,
class
Input
,
class
Indices
,
class
Output
>
__device__
void
gather
(
Input
input
,
Indices
indices
,
Output
output
)
{
auto
ind
=
make_index
();
auto
axis_dim_size
=
input
.
get_shape
().
lens
[
Axis
];
constexpr
auto
out_comp
=
gather_shape
<
Axis
>
(
get_shape_c
<
Input
>
{},
get_shape_c
<
Indices
>
{});
ind
.
global_stride
(
output
.
get_shape
().
elements
(),
[
&
](
auto
i
)
{
auto
idx
=
out_comp
.
multi
(
i
);
auto
in_index
=
indices
[
idx
[
Axis
]];
auto
new_in_index
=
(
in_index
<
0
)
?
in_index
+
axis_dim_size
:
in_index
;
idx
[
Axis
]
=
new_in_index
;
output
[
i
]
=
input
[
idx
];
});
}
}
// namespace migraphx
#endif
src/targets/gpu/kernels/include/migraphx/kernels/math.hpp
View file @
c45ba3d3
...
@@ -132,9 +132,14 @@ MIGRAPHX_DEVICE_MATH_FOR(float, fmod, ::fmodf)
...
@@ -132,9 +132,14 @@ MIGRAPHX_DEVICE_MATH_FOR(float, fmod, ::fmodf)
// Builtin half functions
// Builtin half functions
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
abs
,
::
__habs
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
abs
,
::
__habs
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
ceil
,
::
hceil
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
cos
,
::
hcos
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
exp
,
::
hexp
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
exp
,
::
hexp
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
floor
,
::
hfloor
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
isnan
,
::
__hisnan
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
log
,
::
hlog
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
log
,
::
hlog
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
rsqrt
,
::
hrsqrt
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
rsqrt
,
::
hrsqrt
)
// MIGRAPHX_DEVICE_MATH_FOR(migraphx::half, sin, ::hsin)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
sqrt
,
::
hsqrt
)
MIGRAPHX_DEVICE_MATH_FOR
(
migraphx
::
half
,
sqrt
,
::
hsqrt
)
// Use float to compute half overload
// Use float to compute half overload
...
@@ -144,16 +149,11 @@ MIGRAPHX_DEVICE_MATH_HALF(asin, ::asin)
...
@@ -144,16 +149,11 @@ MIGRAPHX_DEVICE_MATH_HALF(asin, ::asin)
MIGRAPHX_DEVICE_MATH_HALF
(
asinh
,
::
asinh
)
MIGRAPHX_DEVICE_MATH_HALF
(
asinh
,
::
asinh
)
MIGRAPHX_DEVICE_MATH_HALF
(
atan
,
::
atan
)
MIGRAPHX_DEVICE_MATH_HALF
(
atan
,
::
atan
)
MIGRAPHX_DEVICE_MATH_HALF
(
atanh
,
::
atanh
)
MIGRAPHX_DEVICE_MATH_HALF
(
atanh
,
::
atanh
)
MIGRAPHX_DEVICE_MATH_HALF
(
ceil
,
::
ceil
)
MIGRAPHX_DEVICE_MATH_HALF
(
cos
,
::
cos
)
MIGRAPHX_DEVICE_MATH_HALF
(
cosh
,
::
cosh
)
MIGRAPHX_DEVICE_MATH_HALF
(
cosh
,
::
cosh
)
MIGRAPHX_DEVICE_MATH_HALF
(
erf
,
::
erf
)
MIGRAPHX_DEVICE_MATH_HALF
(
erf
,
::
erf
)
MIGRAPHX_DEVICE_MATH_HALF
(
floor
,
::
floor
)
MIGRAPHX_DEVICE_MATH_HALF
(
isnan
,
::
isnan
)
MIGRAPHX_DEVICE_MATH_HALF
(
pow
,
::
pow
)
MIGRAPHX_DEVICE_MATH_HALF
(
pow
,
::
pow
)
MIGRAPHX_DEVICE_MATH_HALF
(
remainder
,
::
remainder
)
MIGRAPHX_DEVICE_MATH_HALF
(
remainder
,
::
remainder
)
MIGRAPHX_DEVICE_MATH_HALF
(
round
,
::
round
)
MIGRAPHX_DEVICE_MATH_HALF
(
round
,
::
round
)
MIGRAPHX_DEVICE_MATH_HALF
(
sin
,
::
sin
)
MIGRAPHX_DEVICE_MATH_HALF
(
sinh
,
::
sinh
)
MIGRAPHX_DEVICE_MATH_HALF
(
sinh
,
::
sinh
)
MIGRAPHX_DEVICE_MATH_HALF
(
tan
,
::
tan
)
MIGRAPHX_DEVICE_MATH_HALF
(
tan
,
::
tan
)
MIGRAPHX_DEVICE_MATH_HALF
(
tanh
,
::
tanh
)
MIGRAPHX_DEVICE_MATH_HALF
(
tanh
,
::
tanh
)
...
@@ -166,19 +166,19 @@ MIGRAPHX_DEVICE_MATH_HALF(fmod, ::fmod)
...
@@ -166,19 +166,19 @@ MIGRAPHX_DEVICE_MATH_HALF(fmod, ::fmod)
// at this time are: exp2, exp10, log2, log10, isinf
// at this time are: exp2, exp10, log2, log10, isinf
MIGRAPHX_DEVICE_MATH_HALF2
(
abs
,
::
__habs2
)
MIGRAPHX_DEVICE_MATH_HALF2
(
abs
,
::
__habs2
)
MIGRAPHX_DEVICE_MATH_HALF2
(
ceil
,
::
h2ceil
)
MIGRAPHX_DEVICE_MATH_HALF2
(
ceil
,
::
h2ceil
)
MIGRAPHX_DEVICE_MATH_HALF2
(
floor
,
::
h2floor
)
MIGRAPHX_DEVICE_MATH_HALF2
(
sin
,
::
h2sin
)
MIGRAPHX_DEVICE_MATH_HALF2
(
cos
,
::
h2cos
)
MIGRAPHX_DEVICE_MATH_HALF2
(
cos
,
::
h2cos
)
MIGRAPHX_DEVICE_MATH_HALF2
(
exp
,
::
h2exp
)
MIGRAPHX_DEVICE_MATH_HALF2
(
exp
,
::
h2exp
)
MIGRAPHX_DEVICE_MATH_HALF2
(
exp2
,
::
h2exp2
)
MIGRAPHX_DEVICE_MATH_HALF2
(
exp10
,
::
h2exp10
)
MIGRAPHX_DEVICE_MATH_HALF2
(
exp10
,
::
h2exp10
)
MIGRAPHX_DEVICE_MATH_HALF2
(
log2
,
::
h2log2
)
MIGRAPHX_DEVICE_MATH_HALF2
(
exp2
,
::
h2exp2
)
MIGRAPHX_DEVICE_MATH_HALF2
(
floor
,
::
h2floor
)
MIGRAPHX_DEVICE_MATH_HALF2
(
isinf
,
::
__hisinf2
)
MIGRAPHX_DEVICE_MATH_HALF2
(
isnan
,
::
__hisnan2
)
MIGRAPHX_DEVICE_MATH_HALF2
(
log
,
::
h2log
)
MIGRAPHX_DEVICE_MATH_HALF2
(
log
,
::
h2log
)
MIGRAPHX_DEVICE_MATH_HALF2
(
log10
,
::
h2log10
)
MIGRAPHX_DEVICE_MATH_HALF2
(
log10
,
::
h2log10
)
MIGRAPHX_DEVICE_MATH_HALF2
(
log2
,
::
h2log2
)
MIGRAPHX_DEVICE_MATH_HALF2
(
rsqrt
,
::
h2rsqrt
)
MIGRAPHX_DEVICE_MATH_HALF2
(
rsqrt
,
::
h2rsqrt
)
// MIGRAPHX_DEVICE_MATH_HALF2(sin, ::h2sin)
MIGRAPHX_DEVICE_MATH_HALF2
(
sqrt
,
::
h2sqrt
)
MIGRAPHX_DEVICE_MATH_HALF2
(
sqrt
,
::
h2sqrt
)
MIGRAPHX_DEVICE_MATH_HALF2
(
isinf
,
::
__hisinf2
)
MIGRAPHX_DEVICE_MATH_HALF2
(
isnan
,
::
__hisnan2
)
template
<
class
T
,
class
U
>
template
<
class
T
,
class
U
>
constexpr
auto
where
(
bool
cond
,
const
T
&
a
,
const
U
&
b
)
constexpr
auto
where
(
bool
cond
,
const
T
&
a
,
const
U
&
b
)
...
@@ -218,6 +218,14 @@ constexpr auto min(const T& a, const U& b)
...
@@ -218,6 +218,14 @@ constexpr auto min(const T& a, const U& b)
return
min
<
common_type_t
<
T
,
U
>>
(
a
,
b
);
return
min
<
common_type_t
<
T
,
U
>>
(
a
,
b
);
}
}
// Sin for half is broken on hip, so use cos instead
template
<
class
T
,
MIGRAPHX_REQUIRES
(
is_same
<
vec_type
<
T
>,
half
>
{})
>
constexpr
T
sin
(
T
x
)
{
constexpr
const
T
shift
=
M_PI_2
;
return
migraphx
::
cos
(
shift
-
x
);
}
MIGRAPHX_DEVICE_MATH_VEC
(
abs
)
MIGRAPHX_DEVICE_MATH_VEC
(
abs
)
MIGRAPHX_DEVICE_MATH_VEC
(
acos
)
MIGRAPHX_DEVICE_MATH_VEC
(
acos
)
MIGRAPHX_DEVICE_MATH_VEC
(
acosh
)
MIGRAPHX_DEVICE_MATH_VEC
(
acosh
)
...
...
src/targets/gpu/kernels/include/migraphx/kernels/shape.hpp
View file @
c45ba3d3
...
@@ -128,6 +128,7 @@ struct shape
...
@@ -128,6 +128,7 @@ struct shape
result
[
0
]
=
tidx
;
result
[
0
]
=
tidx
;
return
result
;
return
result
;
}
}
/// Convert multi-index into a single index
/// Convert multi-index into a single index
constexpr
index_int
single
(
index_array
idx
)
const
constexpr
index_int
single
(
index_array
idx
)
const
{
{
...
...
src/targets/gpu/lowering.cpp
View file @
c45ba3d3
...
@@ -90,7 +90,6 @@ struct miopen_apply
...
@@ -90,7 +90,6 @@ struct miopen_apply
add_extend_op
(
"argmax"
);
add_extend_op
(
"argmax"
);
add_extend_op
(
"argmin"
);
add_extend_op
(
"argmin"
);
add_extend_op
(
"gather"
);
add_extend_op
(
"logsoftmax"
);
add_extend_op
(
"logsoftmax"
);
add_extend_op
(
"lrn"
);
add_extend_op
(
"lrn"
);
add_extend_op
(
"multinomial"
);
add_extend_op
(
"multinomial"
);
...
...
test/onnx/conv_dynamic_bias_test.onnx
0 → 100644
View file @
c45ba3d3
File added
test/onnx/gen_onnx.py
View file @
c45ba3d3
...
@@ -1121,6 +1121,24 @@ def conv_dynamic_batch_test():
...
@@ -1121,6 +1121,24 @@ def conv_dynamic_batch_test():
return
([
node
],
[
x
,
y
],
[
out
])
return
([
node
],
[
x
,
y
],
[
out
])
@
onnx_test
()
def
conv_dynamic_bias_test
():
x
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
[
None
,
3
,
32
,
32
])
y
=
helper
.
make_tensor_value_info
(
'1'
,
TensorProto
.
FLOAT
,
[
1
,
3
,
5
,
5
])
z
=
helper
.
make_tensor_value_info
(
'2'
,
TensorProto
.
FLOAT
,
[
1
])
out
=
helper
.
make_tensor_value_info
(
'3'
,
TensorProto
.
FLOAT
,
[
None
,
2
,
28
,
28
])
node
=
onnx
.
helper
.
make_node
(
'Conv'
,
inputs
=
[
'0'
,
'1'
,
'2'
],
outputs
=
[
'3'
],
dilations
=
[
1
,
1
],
strides
=
[
1
,
1
])
return
([
node
],
[
x
,
y
,
z
],
[
out
])
@
onnx_test
()
@
onnx_test
()
def
conv_dynamic_img_test
():
def
conv_dynamic_img_test
():
x
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
x
=
helper
.
make_tensor_value_info
(
'0'
,
TensorProto
.
FLOAT
,
...
...
test/onnx/onnx_test.cpp
View file @
c45ba3d3
...
@@ -1118,6 +1118,25 @@ TEST_CASE(conv_dynamic_batch_test)
...
@@ -1118,6 +1118,25 @@ TEST_CASE(conv_dynamic_batch_test)
EXPECT
(
p
==
prog
);
EXPECT
(
p
==
prog
);
}
}
TEST_CASE
(
conv_dynamic_bias_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x0
=
mm
->
add_parameter
(
"0"
,
{
migraphx
::
shape
::
float_type
,
{{
1
,
6
,
0
},
{
3
,
3
,
0
},
{
32
,
32
,
0
},
{
32
,
32
,
0
}}});
auto
x1
=
mm
->
add_parameter
(
"1"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
5
,
5
}});
auto
x2
=
mm
->
add_parameter
(
"2"
,
{
migraphx
::
shape
::
float_type
,
{
1
}});
auto
x3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution"
),
x0
,
x1
);
auto
x4
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
}}),
x2
,
x3
);
auto
x5
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x3
,
x4
);
mm
->
add_return
({
x5
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
6
,
0
};
auto
prog
=
migraphx
::
parse_onnx
(
"conv_dynamic_bias_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
TEST_CASE
(
conv_dynamic_img_test
)
TEST_CASE
(
conv_dynamic_img_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
test/py/onnx_backend_test.py
View file @
c45ba3d3
...
@@ -94,6 +94,16 @@ def disabled_tests_onnx_1_8_1(backend_test):
...
@@ -94,6 +94,16 @@ def disabled_tests_onnx_1_8_1(backend_test):
backend_test
.
exclude
(
r
'test_unsqueeze_unsorted_axes_cpu'
)
backend_test
.
exclude
(
r
'test_unsqueeze_unsorted_axes_cpu'
)
def
disabled_tests_onnx_1_10_0
(
backend_test
):
# unsupported shape attributes
backend_test
.
exclude
(
r
'test_shape_end_1_cpu'
)
backend_test
.
exclude
(
r
'test_shape_end_negative_1_cpu'
)
backend_test
.
exclude
(
r
'test_shape_start_1_cpu'
)
backend_test
.
exclude
(
r
'test_shape_start_1_end_2_cpu'
)
backend_test
.
exclude
(
r
'test_shape_start_1_end_negative_1_cpu'
)
backend_test
.
exclude
(
r
'test_shape_start_negative_1_cpu'
)
def
create_backend_test
(
testname
=
None
,
target_device
=
None
):
def
create_backend_test
(
testname
=
None
,
target_device
=
None
):
if
target_device
is
not
None
:
if
target_device
is
not
None
:
c2
.
set_device
(
target_device
)
c2
.
set_device
(
target_device
)
...
@@ -314,6 +324,9 @@ def create_backend_test(testname=None, target_device=None):
...
@@ -314,6 +324,9 @@ def create_backend_test(testname=None, target_device=None):
if
version
.
parse
(
onnx
.
__version__
)
>=
version
.
parse
(
"1.8.0"
):
if
version
.
parse
(
onnx
.
__version__
)
>=
version
.
parse
(
"1.8.0"
):
disabled_tests_onnx_1_8_1
(
backend_test
)
disabled_tests_onnx_1_8_1
(
backend_test
)
if
version
.
parse
(
onnx
.
__version__
)
>=
version
.
parse
(
"1.10.0"
):
disabled_tests_onnx_1_10_0
(
backend_test
)
# import all test cases at global scope to make
# import all test cases at global scope to make
# them visible to python.unittest.
# them visible to python.unittest.
...
...
test/verify/test_gather.cpp
View file @
c45ba3d3
...
@@ -27,7 +27,8 @@
...
@@ -27,7 +27,8 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_gather
:
verify_program
<
test_gather
>
template
<
int
Axis
>
struct
test_gather
:
verify_program
<
test_gather
<
Axis
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
...
@@ -38,8 +39,13 @@ struct test_gather : verify_program<test_gather>
...
@@ -38,8 +39,13 @@ struct test_gather : verify_program<test_gather>
std
::
vector
<
int
>
indices
{
1
,
2
,
2
,
1
};
std
::
vector
<
int
>
indices
{
1
,
2
,
2
,
1
};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
int
axis
=
0
;
int
axis
=
Axis
;
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
a0
,
a1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
a0
,
a1
);
return
p
;
return
p
;
}
}
};
};
// Standard gather test
template
struct
test_gather
<
0
>;
// Test Negative axis
template
struct
test_gather
<-
2
>;
test/verify/test_gather_1d_index.cpp
View file @
c45ba3d3
...
@@ -27,7 +27,8 @@
...
@@ -27,7 +27,8 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_gather_1d_index
:
verify_program
<
test_gather_1d_index
>
template
<
int
Index
>
struct
test_gather_1d_index
:
verify_program
<
test_gather_1d_index
<
Index
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
...
@@ -35,7 +36,7 @@ struct test_gather_1d_index : verify_program<test_gather_1d_index>
...
@@ -35,7 +36,7 @@ struct test_gather_1d_index : verify_program<test_gather_1d_index>
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
,
{
1
}};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
,
{
1
}};
std
::
vector
<
int
>
indices
{
1
};
std
::
vector
<
int
>
indices
{
Index
};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
int
axis
=
-
1
;
int
axis
=
-
1
;
...
@@ -43,3 +44,7 @@ struct test_gather_1d_index : verify_program<test_gather_1d_index>
...
@@ -43,3 +44,7 @@ struct test_gather_1d_index : verify_program<test_gather_1d_index>
return
p
;
return
p
;
}
}
};
};
// Test for positive and negative single dim indices
template
struct
test_gather_1d_index
<
1
>;
template
struct
test_gather_1d_index
<-
1
>;
test/verify/test_gather_asymmetric.cpp
0 → 100644
View file @
c45ba3d3
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_gather_asymmetric
:
verify_program
<
test_gather_asymmetric
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
5
}};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
,
{
2
,
1
}};
std
::
vector
<
int
>
indices
{
1
,
2
};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
int
axis
=
0
;
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
a0
,
a1
);
return
p
;
}
};
test/verify/test_gather_neg_axis_even_dims.cpp
0 → 100644
View file @
c45ba3d3
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_gather_neg_axis_even_dims
:
verify_program
<
test_gather_neg_axis_even_dims
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
4
,
4
}};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}};
std
::
vector
<
int
>
indices
{
1
,
2
,
2
,
1
};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
int
axis
=
-
1
;
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
a0
,
a1
);
return
p
;
}
};
test/verify/test_gather_onnx_axis_one_ex.cpp
0 → 100644
View file @
c45ba3d3
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
/* Test case mirrors the example for for axis = 1 found on the onnx gather documentation */
struct
test_gather_onnx_axis_one_ex
:
verify_program
<
test_gather_onnx_axis_one_ex
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
,
{
2
,
1
}};
std
::
vector
<
int
>
indices
{
0
,
2
};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
int
axis
=
1
;
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
a0
,
a1
);
return
p
;
}
};
test/verify/test_gather_onnx_axis_zero_ex.cpp
0 → 100644
View file @
c45ba3d3
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
/* Test case mirrors the example for axis = 0 found on the onnx gather documentation */
struct
test_gather_onnx_axis_zero_ex
:
verify_program
<
test_gather_onnx_axis_zero_ex
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
2
}};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}};
std
::
vector
<
int
>
indices
{
0
,
1
,
1
,
2
};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
int
axis
=
0
;
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
a0
,
a1
);
return
p
;
}
};
test/verify/test_gather_
neg_axi
s.cpp
→
test/verify/test_gather_
pos_neg_indice
s.cpp
View file @
c45ba3d3
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_gather_
neg_axi
s
:
verify_program
<
test_gather_
neg_axi
s
>
struct
test_gather_
pos_neg_indice
s
:
verify_program
<
test_gather_
pos_neg_indice
s
>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
...
@@ -35,7 +35,7 @@ struct test_gather_neg_axis : verify_program<test_gather_neg_axis>
...
@@ -35,7 +35,7 @@ struct test_gather_neg_axis : verify_program<test_gather_neg_axis>
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
,
{
2
,
2
}};
std
::
vector
<
int
>
indices
{
1
,
2
,
2
,
1
};
std
::
vector
<
int
>
indices
{
-
2
,
2
,
2
,
-
2
};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
int
axis
=
-
1
;
int
axis
=
-
1
;
...
...
test/verify/test_gather_scalar_index.cpp
View file @
c45ba3d3
...
@@ -27,7 +27,8 @@
...
@@ -27,7 +27,8 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_gather_scalar_index
:
verify_program
<
test_gather_scalar_index
>
template
<
int
Index
>
struct
test_gather_scalar_index
:
verify_program
<
test_gather_scalar_index
<
Index
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
...
@@ -35,7 +36,7 @@ struct test_gather_scalar_index : verify_program<test_gather_scalar_index>
...
@@ -35,7 +36,7 @@ struct test_gather_scalar_index : verify_program<test_gather_scalar_index>
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
};
migraphx
::
shape
s_indices
{
migraphx
::
shape
::
int32_type
};
std
::
vector
<
int
>
indices
{
1
};
std
::
vector
<
int
>
indices
{
Index
};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
auto
a1
=
mm
->
add_literal
(
migraphx
::
literal
{
s_indices
,
indices
});
int
axis
=
-
1
;
int
axis
=
-
1
;
...
@@ -43,3 +44,7 @@ struct test_gather_scalar_index : verify_program<test_gather_scalar_index>
...
@@ -43,3 +44,7 @@ struct test_gather_scalar_index : verify_program<test_gather_scalar_index>
return
p
;
return
p
;
}
}
};
};
// Add positive and negative cases for tests
template
struct
test_gather_scalar_index
<
1
>;
template
struct
test_gather_scalar_index
<-
1
>;
Prev
1
2
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