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
00d5d880
Commit
00d5d880
authored
Jul 06, 2021
by
Khalique Ahmed
Browse files
Merge branch 'develop' of
https://github.com/ROCmSoftwarePlatform/AMDMIGraphX
into mi100_opts
parents
00d90ca8
f60c3815
Changes
128
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
212 additions
and
26 deletions
+212
-26
test/verify/test_reverse.cpp
test/verify/test_reverse.cpp
+18
-0
test/verify/test_reverse_multiaxis.cpp
test/verify/test_reverse_multiaxis.cpp
+18
-0
test/verify/test_reverse_negaxis.cpp
test/verify/test_reverse_negaxis.cpp
+18
-0
test/verify/test_slice_reverse.cpp
test/verify/test_slice_reverse.cpp
+22
-0
test/verify/test_slice_reverse_step.cpp
test/verify/test_slice_reverse_step.cpp
+24
-0
test/verify/test_slice_step_reverse.cpp
test/verify/test_slice_step_reverse.cpp
+24
-0
tools/build_and_test_onnxrt.sh
tools/build_and_test_onnxrt.sh
+1
-1
tools/include/operation.hpp
tools/include/operation.hpp
+87
-25
No files found.
test/verify/test_reverse.cpp
0 → 100644
View file @
00d5d880
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_reverse
:
verify_program
<
test_reverse
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
4
,
16
}};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
std
::
vector
<
int64_t
>
axis
=
{
0
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"reverse"
,
{{
"axes"
,
axis
}}),
a0
);
return
p
;
}
};
test/verify/test_reverse_multiaxis.cpp
0 → 100644
View file @
00d5d880
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_reverse_multiaxis
:
verify_program
<
test_reverse_multiaxis
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
4
,
16
}};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
std
::
vector
<
int64_t
>
axes
=
{
0
,
1
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"reverse"
,
{{
"axes"
,
axes
}}),
a0
);
return
p
;
}
};
test/verify/test_reverse_negaxis.cpp
0 → 100644
View file @
00d5d880
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_reverse_negaxis
:
verify_program
<
test_reverse_negaxis
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
4
,
16
}};
auto
a0
=
mm
->
add_parameter
(
"data"
,
s
);
std
::
vector
<
int64_t
>
axis
=
{
-
1
};
mm
->
add_instruction
(
migraphx
::
make_op
(
"reverse"
,
{{
"axes"
,
axis
}}),
a0
);
return
p
;
}
};
test/verify/test_slice_reverse.cpp
0 → 100644
View file @
00d5d880
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_slice_reverse
:
verify_program
<
test_slice_reverse
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
int32_type
,
{
3
,
5
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
slice_out
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}},
{
"starts"
,
{
0
,
2
}},
{
"ends"
,
{
2
,
-
1
}}}),
x
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"reverse"
,
{{
"axes"
,
{
0
}}}),
slice_out
);
return
p
;
}
};
test/verify/test_slice_reverse_step.cpp
0 → 100644
View file @
00d5d880
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_slice_reverse_step
:
verify_program
<
test_slice_reverse_step
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
int32_type
,
{
7
,
5
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
slice_out
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}},
{
"starts"
,
{
0
,
2
}},
{
"ends"
,
{
2
,
-
1
}}}),
x
);
auto
step_out
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reverse"
,
{{
"axes"
,
{
0
,
1
}}}),
slice_out
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"step"
,
{{
"axes"
,
{
0
,
1
}},
{
"steps"
,
{
2
,
2
}}}),
step_out
);
return
p
;
}
};
test/verify/test_slice_step_reverse.cpp
0 → 100644
View file @
00d5d880
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_slice_step_reverse
:
verify_program
<
test_slice_step_reverse
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
int32_type
,
{
7
,
5
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
slice_out
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"slice"
,
{{
"axes"
,
{
0
,
1
}},
{
"starts"
,
{
0
,
2
}},
{
"ends"
,
{
2
,
-
1
}}}),
x
);
auto
step_out
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"step"
,
{{
"axes"
,
{
0
,
1
}},
{
"steps"
,
{
2
,
2
}}}),
slice_out
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"reverse"
,
{{
"axes"
,
{
0
}}}),
step_out
);
return
p
;
}
};
tools/build_and_test_onnxrt.sh
View file @
00d5d880
...
@@ -3,5 +3,5 @@ pip3 install -r requirements.txt
...
@@ -3,5 +3,5 @@ pip3 install -r requirements.txt
# Add newer cmake to the path
# Add newer cmake to the path
export
PATH
=
"/opt/cmake/bin:
$PATH
"
export
PATH
=
"/opt/cmake/bin:
$PATH
"
export
CXXFLAGS
=
"-D__HIP_PLATFORM_HCC__=1 -w"
export
CXXFLAGS
=
"-D__HIP_PLATFORM_HCC__=1 -w"
./build.sh
--config
Release
--update
--build
--parallel
--cmake_extra_defines
ONNXRUNTIME_VERSION
=
$(
cat
./VERSION_NUMBER
)
--use_migraphx
./build.sh
--config
Release
--update
--build
--parallel
--cmake_extra_defines
ONNXRUNTIME_VERSION
=
$(
cat
./VERSION_NUMBER
)
--test
--use_migraphx
# pip3 install /code/onnxruntime/build/Linux/Release/dist/*.whl
# pip3 install /code/onnxruntime/build/Linux/Release/dist/*.whl
tools/include/operation.hpp
View file @
00d5d880
...
@@ -178,7 +178,7 @@ shape normalize_compute_shape_op(const T& x,
...
@@ -178,7 +178,7 @@ shape normalize_compute_shape_op(const T& x,
}
}
template
<
class
T
>
template
<
class
T
>
auto
compute_op
(
rank
<
2
>
,
auto
compute_op
(
rank
<
1
>
,
const
T
&
x
,
const
T
&
x
,
context
&
ctx
,
context
&
ctx
,
const
shape
&
output_shape
,
const
shape
&
output_shape
,
...
@@ -188,14 +188,6 @@ auto compute_op(rank<2>,
...
@@ -188,14 +188,6 @@ auto compute_op(rank<2>,
return
x
.
compute
(
auto_any_cast
(
ctx
),
output_shape
,
input
);
return
x
.
compute
(
auto_any_cast
(
ctx
),
output_shape
,
input
);
}
}
template
<
class
T
>
auto
compute_op
(
rank
<
1
>
,
const
T
&
x
,
context
&
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
->
decltype
(
x
.
compute
(
output_shape
,
input
))
{
return
x
.
compute
(
output_shape
,
input
);
}
template
<
class
T
>
template
<
class
T
>
argument
compute_op
(
rank
<
0
>
,
const
T
&
x
,
context
&
,
const
shape
&
,
const
std
::
vector
<
argument
>&
)
argument
compute_op
(
rank
<
0
>
,
const
T
&
x
,
context
&
,
const
shape
&
,
const
std
::
vector
<
argument
>&
)
{
{
...
@@ -207,50 +199,106 @@ template <class T>
...
@@ -207,50 +199,106 @@ template <class T>
argument
argument
compute_op
(
const
T
&
x
,
context
&
ctx
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
compute_op
(
const
T
&
x
,
context
&
ctx
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
{
{
return
compute_op
(
rank
<
2
>
{},
x
,
ctx
,
output_shape
,
input
);
return
compute_op
(
rank
<
1
>
{},
x
,
ctx
,
output_shape
,
input
);
}
}
template
<
class
T
>
template
<
class
T
>
auto
compute_op
(
rank
<
2
>
,
const
T
&
x
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
auto
compute_op
(
rank
<
1
>
,
const
T
&
x
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
->
decltype
(
x
.
compute
(
output_shape
,
input
))
->
decltype
(
x
.
compute
(
output_shape
,
input
))
{
{
return
x
.
compute
(
output_shape
,
input
);
return
x
.
compute
(
output_shape
,
input
);
}
}
template
<
class
T
>
template
<
class
T
>
auto
compute_op
(
rank
<
1
>
,
const
T
&
x
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
argument
compute_op
(
rank
<
0
>
,
const
T
&
x
,
const
shape
&
,
const
std
::
vector
<
argument
>&
)
->
decltype
(
x
.
compute
(
auto_any_cast
(
std
::
declval
<
context
&>
()),
output_shape
,
input
))
{
{
std
::
string
name
=
x
.
name
();
std
::
string
name
=
x
.
name
();
MIGRAPHX_THROW
(
"Not computable
without a context
: "
+
name
);
MIGRAPHX_THROW
(
"Not computable: "
+
name
);
}
}
template
<
class
T
>
template
<
class
T
>
argument
compute_op
(
rank
<
0
>
,
const
T
&
x
,
const
shape
&
,
const
std
::
vector
<
argument
>&
)
argument
compute_op
(
const
T
&
x
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
{
return
compute_op
(
rank
<
1
>
{},
x
,
output_shape
,
input
);
}
template
<
class
T
,
class
F
>
auto
compute_op
(
rank
<
1
>
,
const
T
&
x
,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
module_args
,
F
f
)
->
decltype
(
x
.
compute
(
output
,
inputs
,
module_args
,
f
))
{
return
x
.
compute
(
output
,
inputs
,
module_args
,
f
);
}
template
<
class
T
,
class
F
>
argument
compute_op
(
rank
<
0
>
,
const
T
&
x
,
const
shape
&
,
const
std
::
vector
<
argument
>&
,
const
std
::
vector
<
module_ref
>&
,
F
)
{
{
std
::
string
name
=
x
.
name
();
std
::
string
name
=
x
.
name
();
MIGRAPHX_THROW
(
"Not computable: "
+
name
);
MIGRAPHX_THROW
(
"Not computable: "
+
name
);
}
}
template
<
class
T
>
template
<
class
T
,
class
F
>
argument
compute_op
(
const
T
&
x
,
const
shape
&
output_shape
,
const
std
::
vector
<
argument
>&
input
)
argument
compute_op
(
const
T
&
x
,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
module_args
,
F
f
)
{
{
return
compute_op
(
rank
<
2
>
{},
x
,
output
_shape
,
input
);
return
compute_op
(
rank
<
1
>
{},
x
,
output
,
input
s
,
module_args
,
f
);
}
}
template
<
class
T
,
class
F
>
template
<
class
T
,
class
F
>
auto
compute_op
(
rank
<
1
>
,
auto
compute_op
(
rank
<
3
>
,
const
T
&
x
,
const
T
&
x
,
context
&
,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
module_args
,
const
std
::
vector
<
module_ref
>&
module_args
,
F
f
)
->
decltype
(
x
.
compute
(
inputs
,
module_args
,
f
))
F
f
)
->
decltype
(
x
.
compute
(
output
,
inputs
,
module_args
,
f
))
{
{
return
x
.
compute
(
inputs
,
module_args
,
f
);
return
x
.
compute
(
output
,
inputs
,
module_args
,
f
);
}
}
template
<
class
T
,
class
F
>
template
<
class
T
,
class
F
>
argument
auto
compute_op
(
rank
<
2
>
,
compute_op
(
rank
<
0
>
,
const
T
&
x
,
const
std
::
vector
<
argument
>&
,
const
std
::
vector
<
module_ref
>&
,
F
)
const
T
&
x
,
context
&
,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
,
F
)
->
decltype
(
x
.
compute
(
output
,
inputs
))
{
return
x
.
compute
(
output
,
inputs
);
}
template
<
class
T
,
class
F
>
auto
compute_op
(
rank
<
1
>
,
const
T
&
x
,
context
&
ctx
,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
,
F
)
->
decltype
(
x
.
compute
(
auto_any_cast
(
ctx
),
output
,
inputs
))
{
return
x
.
compute
(
auto_any_cast
(
ctx
),
output
,
inputs
);
}
template
<
class
T
,
class
F
>
argument
compute_op
(
rank
<
0
>
,
const
T
&
x
,
context
&
,
const
shape
&
,
const
std
::
vector
<
argument
>&
,
const
std
::
vector
<
module_ref
>&
,
F
)
{
{
std
::
string
name
=
x
.
name
();
std
::
string
name
=
x
.
name
();
MIGRAPHX_THROW
(
"Not computable: "
+
name
);
MIGRAPHX_THROW
(
"Not computable: "
+
name
);
...
@@ -258,11 +306,13 @@ argument
...
@@ -258,11 +306,13 @@ argument
template
<
class
T
,
class
F
>
template
<
class
T
,
class
F
>
argument
compute_op
(
const
T
&
x
,
argument
compute_op
(
const
T
&
x
,
context
&
ctx
,
const
shape
&
output
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
argument
>&
inputs
,
const
std
::
vector
<
module_ref
>&
module_args
,
const
std
::
vector
<
module_ref
>&
module_args
,
F
f
)
F
f
)
{
{
return
compute_op
(
rank
<
1
>
{},
x
,
inputs
,
module_args
,
f
);
return
compute_op
(
rank
<
3
>
{},
x
,
ctx
,
output
,
inputs
,
module_args
,
f
);
}
}
template
<
class
T
>
template
<
class
T
>
...
@@ -447,10 +497,22 @@ bool is_borrowed_op(const T&)
...
@@ -447,10 +497,22 @@ bool is_borrowed_op(const T&)
virtual
(
virtual
(
'
compute
'
,
'
compute
'
,
returns
=
'
argument
'
,
returns
=
'
argument
'
,
output
=
'
const
shape
&
'
,
input
=
'
const
std
::
vector
<
argument
>&
'
,
module_args
=
'
const
std
::
vector
<
module_ref
>&
'
,
run
=
'
std
::
function
<
std
::
vector
<
argument
>
(
module_ref
&
,
const
std
::
unordered_map
<
std
::
string
,
argument
>&
)
>
'
,
const
=
True
,
default
=
'
detail
::
compute_op
'
),
virtual
(
'
compute
'
,
returns
=
'
argument
'
,
ctx
=
'
context
&
'
,
output
=
'
const
shape
&
'
,
input
=
'
const
std
::
vector
<
argument
>&
'
,
input
=
'
const
std
::
vector
<
argument
>&
'
,
module_args
=
'
const
std
::
vector
<
module_ref
>&
'
,
module_args
=
'
const
std
::
vector
<
module_ref
>&
'
,
run
=
run
=
'
std
::
function
<
std
::
vector
<
argument
>
(
module_ref
&
mdl
,
const
std
::
unordered_map
<
std
::
string
,
argument
>&
inputs
)
>
'
,
'
std
::
function
<
std
::
vector
<
argument
>
(
module_ref
&
,
const
std
::
unordered_map
<
std
::
string
,
argument
>&
)
>
'
,
const
=
True
,
const
=
True
,
default
=
'
detail
::
compute_op
'
),
default
=
'
detail
::
compute_op
'
),
virtual
(
'
to_value
'
,
returns
=
'
value
'
,
const
=
True
,
default
=
'
detail
::
to_value_op
'
),
virtual
(
'
to_value
'
,
returns
=
'
value
'
,
const
=
True
,
default
=
'
detail
::
to_value_op
'
),
...
...
Prev
1
…
3
4
5
6
7
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