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
359bac6d
Commit
359bac6d
authored
Oct 13, 2023
by
Umang Yadav
Browse files
Merge branch 'develop' into resnet50_partition
parents
124f7d55
1a1c1b42
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
192 additions
and
22 deletions
+192
-22
Jenkinsfile
Jenkinsfile
+3
-3
src/driver/main.cpp
src/driver/main.cpp
+38
-4
src/targets/gpu/fuse_mlir.cpp
src/targets/gpu/fuse_mlir.cpp
+9
-2
test/py/test_gpu.py
test/py/test_gpu.py
+2
-6
test/py/test_numpy.py
test/py/test_numpy.py
+3
-6
test/verify/test_flatten_dot_relu.cpp
test/verify/test_flatten_dot_relu.cpp
+46
-0
test/verify/test_squeeze_conv_relu.cpp
test/verify/test_squeeze_conv_relu.cpp
+45
-0
test/verify/test_unsqueeze_conv_relu.cpp
test/verify/test_unsqueeze_conv_relu.cpp
+45
-0
tools/CMakeLists.txt
tools/CMakeLists.txt
+1
-1
No files found.
Jenkinsfile
View file @
359bac6d
...
@@ -107,7 +107,7 @@ def rocmnode(name, body) {
...
@@ -107,7 +107,7 @@ def rocmnode(name, body) {
}
}
}
}
rocmtest
clang_debug:
rocmnode
(
'
cdna
'
)
{
cmake_build
->
rocmtest
clang_debug:
rocmnode
(
'
mi100+
'
)
{
cmake_build
->
stage
(
'hipRTC Debug'
)
{
stage
(
'hipRTC 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}"
...
@@ -124,12 +124,12 @@ rocmtest clang_debug: rocmnode('cdna') { cmake_build ->
...
@@ -124,12 +124,12 @@ rocmtest clang_debug: rocmnode('cdna') { cmake_build ->
// stage('Hidden symbols') {
// stage('Hidden symbols') {
// cmake_build(flags: "-DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_GPU=On -DMIGRAPHX_ENABLE_CPU=On -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_C_VISIBILITY_PRESET=hidden")
// cmake_build(flags: "-DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_GPU=On -DMIGRAPHX_ENABLE_CPU=On -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_C_VISIBILITY_PRESET=hidden")
// }
// }
},
all_targets_debug
:
rocmnode
(
'
cdna
'
)
{
cmake_build
->
},
all_targets_debug
:
rocmnode
(
'
mi100+
'
)
{
cmake_build
->
stage
(
'All targets Release'
)
{
stage
(
'All targets Release'
)
{
def
gpu_targets
=
getgputargets
()
def
gpu_targets
=
getgputargets
()
cmake_build
(
flags:
"-DCMAKE_BUILD_TYPE=release -DMIGRAPHX_ENABLE_GPU=On -DMIGRAPHX_ENABLE_CPU=On -DMIGRAPHX_ENABLE_FPGA=On -DGPU_TARGETS='${gpu_targets}'"
)
cmake_build
(
flags:
"-DCMAKE_BUILD_TYPE=release -DMIGRAPHX_ENABLE_GPU=On -DMIGRAPHX_ENABLE_CPU=On -DMIGRAPHX_ENABLE_FPGA=On -DGPU_TARGETS='${gpu_targets}'"
)
}
}
},
mlir_debug:
rocmnode
(
'
cdna
'
)
{
cmake_build
->
},
mlir_debug:
rocmnode
(
'
mi100+
'
)
{
cmake_build
->
stage
(
'MLIR Debug'
)
{
stage
(
'MLIR Debug'
)
{
withEnv
([
'MIGRAPHX_ENABLE_MLIR=1'
])
{
withEnv
([
'MIGRAPHX_ENABLE_MLIR=1'
])
{
def
sanitizers
=
"undefined"
def
sanitizers
=
"undefined"
...
...
src/driver/main.cpp
View file @
359bac6d
...
@@ -540,17 +540,20 @@ struct params : command<params>
...
@@ -540,17 +540,20 @@ struct params : command<params>
struct
verify
:
command
<
verify
>
struct
verify
:
command
<
verify
>
{
{
compiler
c
;
compiler
c
;
migraphx
::
verify
::
tolerance
tols
;
// Set to -1. as nonsense initial value
double
rms_tol
=
-
1.0
;
double
atol
=
-
1.0
;
double
rtol
=
-
1.0
;
bool
per_instruction
=
false
;
bool
per_instruction
=
false
;
bool
reduce
=
false
;
bool
reduce
=
false
;
void
parse
(
argument_parser
&
ap
)
void
parse
(
argument_parser
&
ap
)
{
{
c
.
parse
(
ap
);
c
.
parse
(
ap
);
ap
(
tols
.
rms_tol
,
{
"--rms-tol"
},
ap
.
help
(
"Tolerance for the RMS error (Default: 0.001)"
));
ap
(
rms_tol
,
{
"--rms-tol"
},
ap
.
help
(
"Tolerance for the RMS error (Default: 0.001)"
));
ap
(
tols
.
atol
,
ap
(
atol
,
{
"--atol"
},
{
"--atol"
},
ap
.
help
(
"Tolerance for the elementwise absolute difference (Default: 0.001)"
));
ap
.
help
(
"Tolerance for the elementwise absolute difference (Default: 0.001)"
));
ap
(
tols
.
rtol
,
ap
(
rtol
,
{
"--rtol"
},
{
"--rtol"
},
ap
.
help
(
"Tolerance for the elementwise relative difference (Default: 0.001)"
));
ap
.
help
(
"Tolerance for the elementwise relative difference (Default: 0.001)"
));
ap
(
per_instruction
,
ap
(
per_instruction
,
...
@@ -569,11 +572,42 @@ struct verify : command<verify>
...
@@ -569,11 +572,42 @@ struct verify : command<verify>
auto
t
=
c
.
ct
.
get_target
();
auto
t
=
c
.
ct
.
get_target
();
auto
m
=
c
.
parameters
.
generate
(
p
,
t
,
true
,
c
.
l
.
batch
);
auto
m
=
c
.
parameters
.
generate
(
p
,
t
,
true
,
c
.
l
.
batch
);
// TODO remove this and make the driver able to figure out datatype most used in the model
// then set the tolerances appropriately. Need to check here because c.to_fp16 only set
// after argument_parser.parse() is run. This code is complicated because there's not a
// good way to change the default tolerances after reading `--fp16` but before reading
// `--rms-tol`, `--atol`, and `--rtol`.
migraphx
::
verify
::
tolerance
tols
{};
if
(
c
.
to_fp16
)
{
tols
=
migraphx
::
verify
::
tolerance
{
8e-2
,
4e-2
,
4e-2
};
}
if
(
not
float_equal
(
this
->
rms_tol
,
-
1.0
))
{
tols
.
rms_tol
=
this
->
rms_tol
;
}
if
(
not
float_equal
(
this
->
atol
,
-
1.0
))
{
tols
.
atol
=
this
->
atol
;
}
if
(
not
float_equal
(
this
->
rtol
,
-
1.0
))
{
tols
.
rtol
=
this
->
rtol
;
}
std
::
cout
<<
"rms_tol: "
<<
tols
.
rms_tol
<<
std
::
endl
;
std
::
cout
<<
"atol: "
<<
tols
.
atol
<<
std
::
endl
;
std
::
cout
<<
"rtol: "
<<
tols
.
rtol
<<
std
::
endl
;
auto
quantize
=
precision
::
fp32
;
auto
quantize
=
precision
::
fp32
;
if
(
c
.
to_fp16
)
if
(
c
.
to_fp16
)
{
quantize
=
precision
::
fp16
;
quantize
=
precision
::
fp16
;
}
if
(
c
.
to_int8
)
if
(
c
.
to_int8
)
{
quantize
=
precision
::
int8
;
quantize
=
precision
::
int8
;
}
if
(
per_instruction
)
if
(
per_instruction
)
{
{
...
...
src/targets/gpu/fuse_mlir.cpp
View file @
359bac6d
...
@@ -131,9 +131,16 @@ fuse_input_ops_and_gemm_based_op(module_ref mm, instruction_ref gemm_based_op)
...
@@ -131,9 +131,16 @@ fuse_input_ops_and_gemm_based_op(module_ref mm, instruction_ref gemm_based_op)
for
(
instruction_ref
input
:
gemm_based_op
->
inputs
())
for
(
instruction_ref
input
:
gemm_based_op
->
inputs
())
{
{
std
::
vector
<
operation
>
op_stream
;
std
::
vector
<
operation
>
op_stream
;
while
(
contains
({
"slice"
,
"transpose"
,
"contiguous"
,
"reshape"
},
input
->
name
()))
while
(
contains
(
{
"slice"
,
"transpose"
,
"contiguous"
,
"reshape"
,
"squeeze"
,
"flatten"
,
"unsqueeze"
},
input
->
name
()))
{
{
op_stream
.
push_back
(
input
->
get_operator
());
operation
op
=
input
->
get_operator
();
if
(
contains
({
"squeeze"
,
"flatten"
,
"unsqueeze"
},
input
->
name
()))
{
op
=
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
input
->
get_shape
().
lens
()}});
}
op_stream
.
push_back
(
op
);
input
=
input
->
inputs
().
at
(
0
);
input
=
input
->
inputs
().
at
(
0
);
}
}
top_inputs
.
push_back
(
input
);
top_inputs
.
push_back
(
input
);
...
...
test/py/test_gpu.py
View file @
359bac6d
#####################################################################################
#####################################################################################
# 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
...
@@ -21,12 +21,8 @@
...
@@ -21,12 +21,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# THE SOFTWARE.
#####################################################################################
#####################################################################################
import
sys
import
migraphx
import
migraphx
try
:
import
numpy
as
np
import
numpy
as
np
except
:
sys
.
exit
()
def
test_conv_relu
():
def
test_conv_relu
():
...
...
test/py/test_numpy.py
View file @
359bac6d
#####################################################################################
#####################################################################################
# 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
...
@@ -21,11 +21,8 @@
...
@@ -21,11 +21,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# THE SOFTWARE.
#####################################################################################
#####################################################################################
import
migraphx
,
sys
import
migraphx
try
:
import
numpy
as
np
import
numpy
as
np
except
:
sys
.
exit
()
def
test_add_op
():
def
test_add_op
():
...
...
test/verify/test_flatten_dot_relu.cpp
0 → 100644
View file @
359bac6d
/*
* 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_flatten_dot_relu
:
verify_program
<
test_flatten_dot_relu
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
a
=
mm
->
add_parameter
(
"a"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
2
,
3
,
3
,
5
}});
a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
3
}}),
a
);
auto
b
=
mm
->
add_parameter
(
"b"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
5
,
3
,
3
,
1
}});
b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
3
}}),
b
);
auto
dot
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
a
,
b
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
dot
);
return
p
;
}
};
test/verify/test_squeeze_conv_relu.cpp
0 → 100644
View file @
359bac6d
/*
* 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_squeeze_conv_relu
:
verify_program
<
test_squeeze_conv_relu
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
1
,
3
,
3
}});
input
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
2
}}}),
input
);
auto
weights
=
mm
->
add_parameter
(
"w"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}});
auto
conv
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution"
),
input
,
weights
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
conv
);
return
p
;
}
};
test/verify/test_unsqueeze_conv_relu.cpp
0 → 100644
View file @
359bac6d
/*
* 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_unsqueeze_conv_relu
:
verify_program
<
test_unsqueeze_conv_relu
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
3
,
3
}});
auto
weights
=
mm
->
add_parameter
(
"w"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
3
,
3
}});
weights
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
0
}}}),
weights
);
auto
conv
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution"
),
input
,
weights
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
conv
);
return
p
;
}
};
tools/CMakeLists.txt
View file @
359bac6d
...
@@ -28,7 +28,7 @@ if(NOT Python_EXECUTABLE)
...
@@ -28,7 +28,7 @@ if(NOT Python_EXECUTABLE)
return
()
return
()
endif
()
endif
()
find_program
(
CLANG_FORMAT clang-format PATHS /opt/rocm/llvm
$
ENV
{
HIP_PATH
}
)
find_program
(
CLANG_FORMAT clang-format PATHS /opt/rocm/llvm ENV
HIP_PATH
PATH_SUFFIXES bin
)
if
(
NOT CLANG_FORMAT
)
if
(
NOT CLANG_FORMAT
)
message
(
WARNING
"clang-format not found - skipping 'generate' target!"
)
message
(
WARNING
"clang-format not found - skipping 'generate' target!"
)
return
()
return
()
...
...
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