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
0662a9a3
Unverified
Commit
0662a9a3
authored
Nov 09, 2023
by
Brian Pickrell
Committed by
GitHub
Nov 09, 2023
Browse files
Merge branch 'develop' into dyn_resize_gather
parents
b74d3a8f
35e5298e
Changes
130
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
191 additions
and
77 deletions
+191
-77
test/verify/quant_conv_1.cpp
test/verify/quant_conv_1.cpp
+1
-1
test/verify/quant_conv_2.cpp
test/verify/quant_conv_2.cpp
+1
-1
test/verify/test_isinf.cpp
test/verify/test_isinf.cpp
+52
-0
test/verify/test_isinf_broadcast.cpp
test/verify/test_isinf_broadcast.cpp
+48
-0
test/verify/test_nearbyint.cpp
test/verify/test_nearbyint.cpp
+47
-0
tools/accuracy/accuracy_checker.py
tools/accuracy/accuracy_checker.py
+36
-13
tools/accuracy/requirements.txt
tools/accuracy/requirements.txt
+1
-1
tools/api/api.cpp
tools/api/api.cpp
+5
-0
tools/docker/ubuntu_2204.dockerfile
tools/docker/ubuntu_2204.dockerfile
+0
-5
tools/download_models.sh
tools/download_models.sh
+0
-56
No files found.
test/verify/quant_conv_
default_mode
.cpp
→
test/verify/quant_conv_
1
.cpp
View file @
0662a9a3
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/op/quant_convolution.hpp>
#include <migraphx/op/quant_convolution.hpp>
struct
quant_conv_
default_mode
:
verify_program
<
quant_conv_
default_mode
>
struct
quant_conv_
1
:
verify_program
<
quant_conv_
1
>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
...
...
test/verify/quant_conv_
int8x4_default
.cpp
→
test/verify/quant_conv_
2
.cpp
View file @
0662a9a3
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/op/quant_convolution.hpp>
#include <migraphx/op/quant_convolution.hpp>
struct
quant_conv_
int8x4_default
:
verify_program
<
quant_conv_
int8x4_default
>
struct
quant_conv_
2
:
verify_program
<
quant_conv_
2
>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
...
...
test/verify/test_isinf.cpp
0 → 100644
View file @
0662a9a3
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 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 <limits>
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
template
<
class
T
>
struct
test_isinf
:
verify_program
<
test_isinf
<
T
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
max
=
std
::
numeric_limits
<
T
>::
max
();
auto
min
=
std
::
numeric_limits
<
T
>::
min
();
auto
inf
=
std
::
numeric_limits
<
T
>::
infinity
();
auto
nan
=
std
::
numeric_limits
<
T
>::
quiet_NaN
();
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
get_type
<
T
>
(),
{
5
}});
std
::
vector
<
T
>
data0
{
inf
,
-
inf
,
max
,
min
,
nan
};
migraphx
::
shape
s1
{
migraphx
::
shape
::
get_type
<
T
>
(),
{
5
}};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s1
,
data0
});
x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
0
}}),
x
,
l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"isinf"
),
x
);
return
p
;
}
};
template
struct
test_isinf
<
migraphx
::
half
>;
template
struct
test_isinf
<
float
>;
test/verify/test_isinf_broadcast.cpp
0 → 100644
View file @
0662a9a3
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 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 <limits>
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_isinf_broadcast
:
verify_program
<
test_isinf_broadcast
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
}});
auto
s0
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}};
x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
0
},
{
"out_lens"
,
s0
.
lens
()}}),
x
);
auto
inf
=
std
::
numeric_limits
<
float
>::
infinity
();
std
::
vector
<
float
>
data0
{
-
inf
,
inf
};
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
1
,
2
}};
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s1
,
data0
});
x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
0
}}),
x
,
l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"isinf"
),
x
);
return
p
;
}
};
test/verify/test_nearbyint.cpp
0 → 100644
View file @
0662a9a3
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 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>
template
<
class
T
>
struct
test_nearbyint
:
verify_program
<
test_nearbyint
<
T
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
std
::
vector
<
float
>
tmp
{
-
4.5
,
-
3.5
,
0.5
,
2.5
,
3.5
};
std
::
vector
<
T
>
data
{
tmp
.
cbegin
(),
tmp
.
cend
()};
migraphx
::
shape
s1
{
migraphx
::
shape
::
get_type
<
T
>
(),
{
5
}};
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_literal
(
migraphx
::
literal
{
s1
,
data
});
mm
->
add_instruction
(
migraphx
::
make_op
(
"isinf"
),
l0
);
return
p
;
};
};
template
struct
test_nearbyint
<
migraphx
::
half
>;
template
struct
test_nearbyint
<
float
>;
tools/accuracy/accuracy_checker.py
View file @
0662a9a3
#####################################################################################
#####################################################################################
# The MIT License (MIT)
# The MIT License (MIT)
#
#
# Copyright (c) 2015-202
2
Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2015-202
3
Advanced Micro Devices, Inc. All rights reserved.
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# of this software and associated documentation files (the "Software"), to deal
...
@@ -52,6 +52,12 @@ def parse_args():
...
@@ -52,6 +52,12 @@ def parse_args():
parser
.
add_argument
(
'--fill0'
,
parser
.
add_argument
(
'--fill0'
,
action
=
'store_true'
,
action
=
'store_true'
,
help
=
'fill all arguments with a value of 0'
)
help
=
'fill all arguments with a value of 0'
)
parser
.
add_argument
(
'--fp16'
,
action
=
'store_true'
,
help
=
'quantize MIGraphX model to fp16'
)
parser
.
add_argument
(
'--argmax'
,
action
=
'store_true'
,
help
=
'use argmax for accuracy'
)
parser
.
add_argument
(
'--verbose'
,
parser
.
add_argument
(
'--verbose'
,
action
=
'store_true'
,
action
=
'store_true'
,
help
=
'show verbose information (for debugging)'
)
help
=
'show verbose information (for debugging)'
)
...
@@ -105,7 +111,7 @@ def parse_args():
...
@@ -105,7 +111,7 @@ def parse_args():
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
return
args
return
args
,
parser
# taken from ../test_runner.py
# taken from ../test_runner.py
...
@@ -113,6 +119,7 @@ def check_correctness(gold_outputs,
...
@@ -113,6 +119,7 @@ def check_correctness(gold_outputs,
outputs
,
outputs
,
rtol
=
1e-3
,
rtol
=
1e-3
,
atol
=
1e-3
,
atol
=
1e-3
,
use_argmax
=
False
,
verbose
=
False
):
verbose
=
False
):
if
len
(
gold_outputs
)
!=
len
(
outputs
):
if
len
(
gold_outputs
)
!=
len
(
outputs
):
print
(
'Number of outputs {} is not equal to expected number {}'
.
format
(
print
(
'Number of outputs {} is not equal to expected number {}'
.
format
(
...
@@ -121,18 +128,29 @@ def check_correctness(gold_outputs,
...
@@ -121,18 +128,29 @@ def check_correctness(gold_outputs,
out_num
=
len
(
gold_outputs
)
out_num
=
len
(
gold_outputs
)
ret
=
True
ret
=
True
for
i
in
range
(
out_num
):
if
not
np
.
allclose
(
gold_outputs
[
i
],
outputs
[
i
],
rtol
,
atol
):
if
not
use_argmax
:
for
i
in
range
(
out_num
):
if
not
np
.
allclose
(
gold_outputs
[
i
],
outputs
[
i
],
rtol
,
atol
):
ret
=
False
if
verbose
:
print
(
'
\n
Output {} is incorrect ...'
.
format
(
i
))
print
(
'Expected value:
\n
{}'
.
format
(
gold_outputs
[
i
]))
print
(
'......'
)
print
(
'Actual value:
\n
{}
\n
'
.
format
(
outputs
[
i
]))
else
:
print
(
'Outputs do not match'
)
break
else
:
golden_argmax
=
np
.
argmax
(
gold_outputs
)
actual_argmax
=
np
.
argmax
(
outputs
)
if
actual_argmax
!=
golden_argmax
:
ret
=
False
ret
=
False
print
(
'
\n
Output argmax is incorrect ...'
)
if
verbose
:
if
verbose
:
print
(
'
\n
Output {} is incorrect ...'
.
format
(
i
))
print
(
'Expected argmax value:
\n
{}'
.
format
(
golden_argmax
))
print
(
'Expected value:
\n
{}'
.
format
(
gold_outputs
[
i
]))
print
(
'......'
)
print
(
'......'
)
print
(
'Actual value:
\n
{}
\n
'
.
format
(
outputs
[
i
]))
print
(
'Actual argmax value:
\n
{}
\n
'
.
format
(
actual_argmax
))
else
:
print
(
'Outputs do not match'
)
break
return
ret
return
ret
...
@@ -155,13 +173,14 @@ def get_np_datatype(in_type):
...
@@ -155,13 +173,14 @@ def get_np_datatype(in_type):
def
main
():
def
main
():
args
=
parse_args
()
args
,
parser
=
parse_args
()
use_onnx
=
True
use_onnx
=
True
if
args
.
onnx
==
None
:
if
args
.
onnx
==
None
:
use_onnx
=
False
use_onnx
=
False
if
not
use_onnx
and
args
.
tf
==
None
:
if
not
use_onnx
and
args
.
tf
==
None
:
print
(
'Error: please specify either an onnx or tf pb file'
)
print
(
'Error: please specify either an onnx or tf pb file'
)
parser
.
print_help
()
sys
.
exit
(
-
1
)
sys
.
exit
(
-
1
)
model_name
=
args
.
onnx
model_name
=
args
.
onnx
...
@@ -194,6 +213,9 @@ def main():
...
@@ -194,6 +213,9 @@ def main():
batch_size
=
batch
,
batch_size
=
batch
,
map_input_dims
=
input_dims
)
map_input_dims
=
input_dims
)
if
(
args
.
fp16
):
migraphx
.
quantize_fp16
(
model
)
if
args
.
verbose
:
if
args
.
verbose
:
print
(
model
)
print
(
model
)
...
@@ -300,7 +322,8 @@ def main():
...
@@ -300,7 +322,8 @@ def main():
if
not
args
.
ort_run
:
if
not
args
.
ort_run
:
is_correct
=
check_correctness
(
pred_fw
,
pred_migx
,
args
.
tolerance
,
is_correct
=
check_correctness
(
pred_fw
,
pred_migx
,
args
.
tolerance
,
args
.
tolerance
,
args
.
verbose
)
args
.
tolerance
,
args
.
argmax
,
args
.
verbose
)
verbose_string
=
' Rerun with --verbose for detailed information.'
\
verbose_string
=
' Rerun with --verbose for detailed information.'
\
if
not
args
.
verbose
else
''
if
not
args
.
verbose
else
''
if
is_correct
:
if
is_correct
:
...
...
tools/accuracy/requirements.txt
View file @
0662a9a3
...
@@ -22,4 +22,4 @@
...
@@ -22,4 +22,4 @@
# THE SOFTWARE.
# THE SOFTWARE.
#####################################################################################
#####################################################################################
numpy==1.21.6
numpy==1.21.6
onnxruntime==1.16.
1
onnxruntime==1.16.
2
tools/api/api.cpp
View file @
0662a9a3
...
@@ -164,6 +164,11 @@ void set_default_loop_iterations(onnx_options& options, int64_t value)
...
@@ -164,6 +164,11 @@ void set_default_loop_iterations(onnx_options& options, int64_t value)
options
.
max_loop_iterations
=
value
;
options
.
max_loop_iterations
=
value
;
}
}
void
set_limit_loop_iterations
(
onnx_options
&
options
,
int64_t
value
)
{
options
.
limit_max_iterations
=
value
;
}
void
set_nhwc
(
tf_options
&
options
,
bool
is_nhwc
)
{
options
.
is_nhwc
=
is_nhwc
;
}
void
set_nhwc
(
tf_options
&
options
,
bool
is_nhwc
)
{
options
.
is_nhwc
=
is_nhwc
;
}
void
set_default_dim_value
(
tf_options
&
options
,
size_t
value
)
{
options
.
batch_size
=
value
;
}
void
set_default_dim_value
(
tf_options
&
options
,
size_t
value
)
{
options
.
batch_size
=
value
;
}
...
...
tools/docker/ubuntu_2204.dockerfile
View file @
0662a9a3
...
@@ -90,11 +90,6 @@ RUN pip3 install yapf==0.28.0
...
@@ -90,11 +90,6 @@ RUN pip3 install yapf==0.28.0
ADD
docs/.sphinx/requirements.txt /doc-requirements.txt
ADD
docs/.sphinx/requirements.txt /doc-requirements.txt
RUN
pip3
install
-r
/doc-requirements.txt
RUN
pip3
install
-r
/doc-requirements.txt
# Download real models to run onnx unit tests
ENV
ONNX_HOME=/.onnx
COPY
./tools/download_models.sh /
RUN
/download_models.sh
&&
rm
/download_models.sh
# Install latest ccache version
# Install latest ccache version
RUN
cget
-p
$PREFIX
install
facebook/zstd@v1.4.5
-X
subdir
-DCMAKE_DIR
=
build/cmake
RUN
cget
-p
$PREFIX
install
facebook/zstd@v1.4.5
-X
subdir
-DCMAKE_DIR
=
build/cmake
RUN
cget
-p
$PREFIX
install
ccache@v4.1
-DENABLE_TESTING
=
OFF
RUN
cget
-p
$PREFIX
install
ccache@v4.1
-DENABLE_TESTING
=
OFF
...
...
tools/download_models.sh
deleted
100755 → 0
View file @
b74d3a8f
#!/bin/bash
#####################################################################################
# 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.
#####################################################################################
set
-e
if
[
-z
"
$ONNX_HOME
"
]
then
# The onnx library uses ONNX_HOME, by default if it doesn't exist
# the path of " ~/.onnx " is used
ONNX_HOME
=
$HOME
/.onnx
fi
model_dir
=
$ONNX_HOME
/models
tmp_dir
=
$ONNX_HOME
/tmp/
mkdir
-p
$model_dir
mkdir
-p
$tmp_dir
models
=
"bvlc_alexnet
\
densenet121
\
inception_v2
\
shufflenet
\
vgg19
\
zfnet512"
for
name
in
$models
do
curl https://download.onnxruntime.ai/onnx/models/
$name
.tar.gz
--output
$tmp_dir
/
$name
.tar.gz
tar
-xzvf
$tmp_dir
/
$name
.tar.gz
--directory
$model_dir
&&
rm
$tmp_dir
/
$name
.tar.gz
done
# CI jobs can run as a different user then the docker image builder.
# Allow read/write access to the models
chmod
777
$model_dir
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