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
80eb522f
Commit
80eb522f
authored
Oct 05, 2023
by
Artur Wojcik
Browse files
update uif2-initial with the recent changes
parent
bba8276d
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
396 additions
and
383 deletions
+396
-383
.gitignore
.gitignore
+3
-1
CMakeLists.txt
CMakeLists.txt
+3
-2
cmake/Embed.cmake
cmake/Embed.cmake
+68
-95
src/CMakeLists.txt
src/CMakeLists.txt
+4
-6
src/dynamic_loader_win32.cpp
src/dynamic_loader_win32.cpp
+12
-0
src/include/migraphx/compile_src.hpp
src/include/migraphx/compile_src.hpp
+1
-1
src/include/migraphx/dynamic_loader.hpp
src/include/migraphx/dynamic_loader.hpp
+0
-2
src/include/migraphx/matcher.hpp
src/include/migraphx/matcher.hpp
+0
-6
src/include/migraphx/op/random_uniform.hpp
src/include/migraphx/op/random_uniform.hpp
+6
-8
src/process.cpp
src/process.cpp
+7
-141
src/process_win32.cpp
src/process_win32.cpp
+213
-0
src/py/CMakeLists.txt
src/py/CMakeLists.txt
+19
-21
src/targets/cpu/CMakeLists.txt
src/targets/cpu/CMakeLists.txt
+2
-2
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+5
-20
src/targets/gpu/compile_hip.cpp
src/targets/gpu/compile_hip.cpp
+2
-1
src/targets/gpu/compile_hip_code_object.cpp
src/targets/gpu/compile_hip_code_object.cpp
+7
-17
src/targets/gpu/kernels/migraphx_kernels.cpp
src/targets/gpu/kernels/migraphx_kernels.cpp
+39
-49
src/targets/gpu/kernels/migraphx_kernels.hpp
src/targets/gpu/kernels/migraphx_kernels.hpp
+3
-8
test/multi_target/multitarget_test.cpp
test/multi_target/multitarget_test.cpp
+0
-1
test/verify/run_verify.cpp
test/verify/run_verify.cpp
+2
-2
No files found.
.gitignore
View file @
80eb522f
...
...
@@ -81,5 +81,7 @@ cmake-build*/
build*/
# Recommended location to install rbuild dependencies from README.md
depend
depend
/
# Python virtual environment
.venv/
CMakeLists.txt
View file @
80eb522f
...
...
@@ -55,6 +55,9 @@ include(CTest)
find_package
(
ROCM REQUIRED
)
find_package
(
Threads REQUIRED
)
include
(
CMakeDependentOption
)
cmake_dependent_option
(
MIGRAPHX_ENABLE_PYTHON
"Enable python bindings"
ON
"WIN32"
OFF
)
# By default build shared libraries
option
(
BUILD_SHARED_LIBS
"Create shared libraries"
ON
)
...
...
@@ -271,8 +274,6 @@ rocm_enable_cppcheck(
MIGRAPHX_USE_CLANG_TIDY
)
enable_testing
()
include
(
ROCMCreatePackage
)
include
(
ROCMTest
)
...
...
cmake/Embed.cmake
View file @
80eb522f
...
...
@@ -31,7 +31,6 @@ function(wrap_string)
set
(
oneValueArgs VARIABLE AT_COLUMN
)
set
(
multiValueArgs
)
cmake_parse_arguments
(
PARSE
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
cmake_parse_arguments
(
WRAP_STRING
"
${
options
}
"
"
${
oneValueArgs
}
"
""
${
ARGN
}
)
string
(
LENGTH
${${
PARSE_VARIABLE
}}
string_length
)
math
(
EXPR offset
"0"
)
...
...
@@ -54,140 +53,114 @@ function(wrap_string)
set
(
${
PARSE_VARIABLE
}
"
${
lines
}
"
PARENT_SCOPE
)
endfunction
()
function
(
generate_embed_source EMBED_NAME
)
function
(
generate_embed_source EMBED_NAME
SRC_FILE HEADER_FILE BASE_DIRECTORY
)
set
(
options
)
set
(
oneValueArgs SRC HEADER RELATIVE
)
set
(
multiValueArgs OBJECTS SYMBOLS FILES
)
set
(
oneValueArgs
""
)
set
(
multiValueArgs SYMBOLS FILES
)
cmake_parse_arguments
(
PARSE
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
set
(
EXTERNS
)
set
(
INIT_KERNELS
)
list
(
LENGTH PARSE_SYMBOLS SYMBOLS_LEN
)
list
(
LENGTH PARSE_OBJECTS OBJECTS_LEN
)
if
(
NOT
${
SYMBOLS_LEN
}
EQUAL
${
OBJECTS_LEN
}
)
message
(
FATAL_ERROR
"Symbols and objects dont match:
${
SYMBOLS_LEN
}
!=
${
OBJECTS_LEN
}
"
)
endif
()
math
(
EXPR LEN
"
${
SYMBOLS_LEN
}
- 1"
)
foreach
(
idx RANGE
${
LEN
}
)
list
(
GET PARSE_SYMBOLS
${
idx
}
SYMBOL
)
list
(
GET PARSE_OBJECTS
${
idx
}
OBJECT
)
list
(
GET PARSE_FILES
${
idx
}
FILE
)
foreach
(
SYMBOL FILE IN ZIP_LISTS PARSE_SYMBOLS PARSE_FILES
)
set
(
START_SYMBOL
"_binary_
${
SYMBOL
}
_start"
)
set
(
LENGTH_SYMBOL
"_binary_
${
SYMBOL
}
_length"
)
if
(
EMBED_USE_LD
)
string
(
APPEND EXTERNS
"
extern const char
${
START_SYMBOL
}
[];
extern const size_t _binary_
${
SYMBOL
}
_size;
const auto
${
LENGTH_SYMBOL
}
= reinterpret_cast<size_t>(&_binary_
${
SYMBOL
}
_size);
extern const char
${
START_SYMBOL
}
[];
extern const size_t _binary_
${
SYMBOL
}
_size;
const auto
${
LENGTH_SYMBOL
}
= reinterpret_cast<size_t>(&_binary_
${
SYMBOL
}
_size);
"
)
else
()
string
(
APPEND EXTERNS
"
extern const char
${
START_SYMBOL
}
[];
extern const size_t
${
LENGTH_SYMBOL
}
;
extern const char
${
START_SYMBOL
}
[];
extern const size_t
${
LENGTH_SYMBOL
}
;
"
)
endif
()
if
(
PARSE_RELATIVE
)
file
(
RELATIVE_PATH BASE_NAME
${
PARSE_RELATIVE
}
"
${
FILE
}
"
)
else
()
get_filename_component
(
BASE_NAME
"
${
FILE
}
"
NAME
)
endif
()
cmake_path
(
RELATIVE_PATH FILE BASE_DIRECTORY
${
BASE_DIRECTORY
}
OUTPUT_VARIABLE BASE_NAME
)
string
(
APPEND INIT_KERNELS
"
{
\"
${
BASE_NAME
}
\"
, {
${
START_SYMBOL
}
,
${
LENGTH_SYMBOL
}
} },
"
)
{
\"
${
BASE_NAME
}
\"
, {
${
START_SYMBOL
}
,
${
LENGTH_SYMBOL
}
} },"
)
endforeach
()
file
(
WRITE
"
${
PARSE_HEADER
}
"
"
#include <utility>
file
(
WRITE
"
${
HEADER_FILE
}
"
"
#include <string_view>
#include <vector>
std::vector<std::pair<std::string_view, std::string_view>>
${
EMBED_NAME
}
();
#include <unordered_map>
#include <utility>
std::unordered_map<std::string_view, std::string_view>
${
EMBED_NAME
}
();
"
)
file
(
WRITE
"
${
PARSE_SRC
}
"
"
file
(
WRITE
"
${
SRC_FILE
}
"
"
#include <
${
EMBED_NAME
}
.hpp>
${
EXTERNS
}
std::
vector<std::pair
<std::string_view, std::string_view>
>
${
EMBED_NAME
}
()
std::
unordered_map
<std::string_view, std::string_view>
${
EMBED_NAME
}
()
{
static std::
vector<std::pair
<std::string_view, std::string_view>
>
result = {
${
INIT_KERNELS
}
};
static std::
unordered_map
<std::string_view, std::string_view> result = {
${
INIT_KERNELS
}
};
return result;
}
"
)
endfunction
()
macro
(
embed_file FILE
)
function
(
embed_file FILE
BASE_DIRECTORY
)
message
(
STATUS
"
${
FILE
}
"
)
# Glob is used to compute the relative path
file
(
GLOB FILES RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
${
FILE
}
)
foreach
(
REL_FILE
${
FILES
}
)
string
(
MAKE_C_IDENTIFIER
"
${
REL_FILE
}
"
OUTPUT_SYMBOL
)
get_filename_component
(
OUTPUT_FILE_DIR
"
${
REL_FILE
}
"
DIRECTORY
)
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
OUTPUT_FILE_DIR
}
"
)
if
(
EMBED_USE_LD
)
set
(
OUTPUT_FILE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
REL_FILE
}
.o"
)
else
()
set
(
OUTPUT_FILE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
REL_FILE
}
.cpp"
)
endif
()
if
(
EMBED_USE_LD
)
add_custom_command
(
OUTPUT
"
${
OUTPUT_FILE
}
"
COMMAND
${
EMBED_LD
}
-r -o
"
${
OUTPUT_FILE
}
"
-z noexecstack --format=binary
"
${
REL_FILE
}
"
COMMAND
${
EMBED_OBJCOPY
}
--rename-section .data=.rodata,alloc,load,readonly,data,contents
"
${
OUTPUT_FILE
}
"
WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
DEPENDS
${
FILE
}
VERBATIM
)
else
()
set_property
(
DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
${
FILE
}
)
# reads source file contents as hex string
file
(
READ
${
FILE
}
HEX_STRING HEX
)
# wraps the hex string into multiple lines
wrap_string
(
VARIABLE HEX_STRING AT_COLUMN 80
)
# adds '0x' prefix and comma suffix before and after every byte respectively
string
(
REGEX REPLACE
"([0-9a-f][0-9a-f])"
"0x
\\
1, "
ARRAY_VALUES
${
HEX_STRING
}
)
# removes trailing comma
string
(
REGEX REPLACE
", $"
""
ARRAY_VALUES
${
ARRAY_VALUES
}
)
file
(
WRITE
"
${
OUTPUT_FILE
}
"
"
extern const char _binary_
${
SYMBOL
}
_start[] = {
${
ARRAY_VALUES
}
};
extern const size_t _binary_
${
SYMBOL
}
_length = sizeof(_binary_
${
SYMBOL
}
_start);
\n
"
)
endif
()
endforeach
()
endmacro
()
cmake_path
(
RELATIVE_PATH FILE BASE_DIRECTORY
${
BASE_DIRECTORY
}
OUTPUT_VARIABLE REL_FILE
)
string
(
MAKE_C_IDENTIFIER
"
${
REL_FILE
}
"
OUTPUT_SYMBOL
)
get_filename_component
(
OUTPUT_FILE_DIR
"
${
REL_FILE
}
"
DIRECTORY
)
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
OUTPUT_FILE_DIR
}
"
)
if
(
EMBED_USE_LD
)
set
(
OUTPUT_FILE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
REL_FILE
}
.o"
)
add_custom_command
(
OUTPUT
${
OUTPUT_FILE
}
COMMAND
${
EMBED_LD
}
-r -o
"
${
OUTPUT_FILE
}
"
-z noexecstack --format=binary
"
${
REL_FILE
}
"
COMMAND
${
EMBED_OBJCOPY
}
--rename-section .data=.rodata,alloc,load,readonly,data,contents
"
${
OUTPUT_FILE
}
"
WORKING_DIRECTORY
${
BASE_DIRECTORY
}
DEPENDS
${
FILE
}
VERBATIM
)
else
()
set
(
OUTPUT_FILE
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
REL_FILE
}
.cpp"
)
# reads source file contents as hex string
file
(
READ
${
FILE
}
HEX_STRING HEX
)
# wraps the hex string into multiple lines
wrap_string
(
VARIABLE HEX_STRING AT_COLUMN 80
)
# adds '0x' prefix and comma suffix before and after every byte respectively
string
(
REGEX REPLACE
"([0-9a-f][0-9a-f])"
"0x
\\
1, "
ARRAY_VALUES
${
HEX_STRING
}
)
# removes trailing comma
string
(
REGEX REPLACE
", $"
""
ARRAY_VALUES
${
ARRAY_VALUES
}
)
file
(
WRITE
"
${
OUTPUT_FILE
}
"
"
#include <cstddef>
extern const char _binary_
${
OUTPUT_SYMBOL
}
_start[] = {
${
ARRAY_VALUES
}
};
extern const size_t _binary_
${
OUTPUT_SYMBOL
}
_length = sizeof(_binary_
${
OUTPUT_SYMBOL
}
_start);
"
)
endif
()
set
(
OUTPUT_FILE
${
OUTPUT_FILE
}
PARENT_SCOPE
)
set
(
OUTPUT_SYMBOL
${
OUTPUT_SYMBOL
}
PARENT_SCOPE
)
endfunction
()
function
(
add_embed_library EMBED_NAME
)
set
(
options
)
set
(
oneValueArgs
RELATIVE
)
set
(
oneValueArgs
BASE_DIRECTORY
)
set
(
multiValueArgs
)
cmake_parse_arguments
(
PARSE
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
set
(
EMBED_DIR
${
CMAKE_CURRENT_BINARY_DIR
}
/embed/
${
EMBED_NAME
}
)
file
(
MAKE_DIRECTORY
${
EMBED_DIR
}
)
set
(
SRC_FILE
"
${
EMBED_DIR
}
/
${
EMBED_NAME
}
.cpp"
)
set
(
HEADER_FILE
"
${
EMBED_DIR
}
/include/
${
EMBED_NAME
}
.hpp"
)
message
(
STATUS
"Embedding kernel files:"
)
foreach
(
FILE
${
PARSE_UNPARSED_ARGUMENTS
}
)
embed_file
(
${
FILE
}
)
embed_file
(
${
FILE
}
${
PARSE_BASE_DIRECTORY
}
)
list
(
APPEND OUTPUT_FILES
${
OUTPUT_FILE
}
)
list
(
APPEND SYMBOLS
${
OUTPUT_SYMBOL
}
)
endforeach
()
message
(
STATUS
"Generating embedding library '
${
EMBED_NAME
}
'"
)
generate_embed_source
(
${
EMBED_NAME
}
SRC
${
SRC_FILE
}
HEADER
${
HEADER_FILE
}
OBJECTS
${
OUTPUT_FILES
}
SYMBOLS
${
SYMBOLS
}
RELATIVE
${
PARSE_RELATIVE
}
FILES
${
PARSE_UNPARSED_ARGUMENTS
}
)
add_library
(
${
EMBED_NAME
}
OBJECT
${
SRC_FILE
}
${
OUTPUT_FILES
}
)
target_include_directories
(
${
EMBED_NAME
}
PUBLIC
${
EMBED_DIR
}
/include
)
target_compile_options
(
${
EMBED_NAME
}
PUBLIC -Wno-reserved-identifier -Wno-extern-initializer -Wno-missing-variable-declarations
)
set_target_properties
(
${
EMBED_NAME
}
PROPERTIES POSITION_INDEPENDENT_CODE On
)
generate_embed_source
(
${
EMBED_NAME
}
${
SRC_FILE
}
${
HEADER_FILE
}
"
${
PARSE_BASE_DIRECTORY
}
"
SYMBOLS
${
SYMBOLS
}
FILES
${
PARSE_UNPARSED_ARGUMENTS
}
)
add_library
(
embed_lib_
${
EMBED_NAME
}
OBJECT
${
SRC_FILE
}
${
HEADER_FILE
}
)
if
(
NOT EMBED_USE_LD
)
target_sources
(
embed_lib_
${
EMBED_NAME
}
PRIVATE
${
OUTPUT_FILES
}
)
endif
()
target_include_directories
(
embed_lib_
${
EMBED_NAME
}
PUBLIC
${
EMBED_DIR
}
/include
)
target_compile_options
(
embed_lib_
${
EMBED_NAME
}
PRIVATE
-Wno-reserved-identifier -Wno-extern-initializer -Wno-missing-variable-declarations
)
set_target_properties
(
embed_lib_
${
EMBED_NAME
}
PROPERTIES POSITION_INDEPENDENT_CODE ON
)
add_library
(
${
EMBED_NAME
}
INTERFACE $<TARGET_OBJECTS:embed_lib_
${
EMBED_NAME
}
>
${
OUTPUT_FILES
}
)
target_link_libraries
(
${
EMBED_NAME
}
INTERFACE $<TARGET_OBJECTS:embed_lib_
${
EMBED_NAME
}
>
)
if
(
EMBED_USE_LD
)
target_link_libraries
(
${
EMBED_NAME
}
INTERFACE
${
OUTPUT_FILES
}
)
endif
()
target_include_directories
(
${
EMBED_NAME
}
INTERFACE
${
EMBED_DIR
}
/include
)
endfunction
()
src/CMakeLists.txt
View file @
80eb522f
...
...
@@ -74,7 +74,6 @@ add_library(migraphx
pass_manager.cpp
permutation.cpp
preallocate_param.cpp
process.cpp
program.cpp
propagate_constant.cpp
promote_literals.cpp
...
...
@@ -104,10 +103,10 @@ add_library(migraphx
verify_args.cpp
)
if
(
WIN32
)
target_sources
(
migraphx PRIVATE dynamic_loader_win32.cpp
)
target_sources
(
migraphx PRIVATE dynamic_loader_win32.cpp
process_win32.cpp
)
target_compile_definitions
(
migraphx PUBLIC -D_USE_MATH_DEFINES
)
else
()
target_sources
(
migraphx PRIVATE dynamic_loader.cpp
)
target_sources
(
migraphx PRIVATE dynamic_loader.cpp
process.cpp
)
endif
()
configure_file
(
version.h.in include/migraphx/version.h
)
rocm_set_soversion
(
migraphx
${
MIGRAPHX_SO_VERSION
}
)
...
...
@@ -286,15 +285,14 @@ target_link_libraries(migraphx INTERFACE $<BUILD_INTERFACE:msgpackc-cxx>)
add_library
(
migraphx_all_targets INTERFACE
)
include
(
CMakeDependentOption
)
cmake_dependent_option
(
MIGRAPHX_ENABLE_PYTHON
"Enable python bindings"
ON
"WIN32"
OFF
)
add_subdirectory
(
api
)
add_subdirectory
(
driver
)
add_subdirectory
(
onnx
)
add_subdirectory
(
tf
)
if
(
MIGRAPHX_ENABLE_PYTHON
)
add_subdirectory
(
py
)
endif
()
add_subdirectory
(
targets/ref
)
target_link_libraries
(
migraphx_all_targets INTERFACE migraphx_ref
)
if
(
MIGRAPHX_ENABLE_CPU
)
...
...
src/dynamic_loader_win32.cpp
View file @
80eb522f
...
...
@@ -66,6 +66,18 @@ struct dynamic_loader_impl
std
::
shared_ptr
<
tmp_dir
>
temp
=
nullptr
;
};
optional
<
dynamic_loader
>
dynamic_loader
::
try_load
(
const
fs
::
path
&
p
)
{
try
{
return
dynamic_loader
{
p
};
}
catch
(
const
std
::
exception
&
)
{
return
nullopt
;
}
}
dynamic_loader
::
dynamic_loader
(
const
fs
::
path
&
p
)
:
impl
(
std
::
make_shared
<
dynamic_loader_impl
>
(
p
))
{
}
...
...
src/include/migraphx/compile_src.hpp
View file @
80eb522f
...
...
@@ -39,7 +39,7 @@ struct src_file
fs
::
path
path
;
std
::
string_view
content
;
src_file
()
=
de
lete
;
src_file
()
=
de
fault
;
src_file
(
fs
::
path
file_path
,
std
::
string_view
file_content
)
:
path
{
std
::
move
(
file_path
)},
content
{
file_content
}
{
...
...
src/include/migraphx/dynamic_loader.hpp
View file @
80eb522f
...
...
@@ -47,9 +47,7 @@ struct MIGRAPHX_EXPORT dynamic_loader
static
fs
::
path
path
(
void
*
address
);
#endif
#ifdef MIGRAPHX_ENABLE_PYTHON
static
optional
<
dynamic_loader
>
try_load
(
const
fs
::
path
&
p
);
#endif
dynamic_loader
()
=
default
;
...
...
src/include/migraphx/matcher.hpp
View file @
80eb522f
...
...
@@ -308,12 +308,6 @@ struct matcher_result
{
}
instruction_container
&
operator
=
(
const
std
::
unordered_map
<
std
::
string
,
instruction_ref
>&
x
)
{
ins_map
=
x
;
return
*
this
;
}
instruction_ref
operator
[](
const
std
::
string
&
name
)
const
{
auto
it
=
ins_map
.
find
(
name
);
...
...
src/include/migraphx/op/random_uniform.hpp
View file @
80eb522f
...
...
@@ -75,15 +75,13 @@ struct random_uniform
result
.
visit
([
&
](
auto
output
)
{
using
type
=
typename
decltype
(
output
)
::
value_type
;
if
constexpr
(
std
::
is_integral_v
<
type
>
if
constexpr
(
std
::
is_integral_v
<
type
>
#ifdef _MSC_VER
// According to the C++ specification, the effect is undefined if the result type for
// the generator is not one of short, int, long, long long, unsigned short, unsigned int,
// unsigned long, or unsigned long long.
// See https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution.
//
// The standard library of Microsoft Visual C++ compiler is strict about that.
// The Clang C++ compiler uses the standard library from Microsoft Visual C++ compiler.
// According to the C++ specification, the effect is undefined if the result type
// for the generator is not one of short, int, long, long long, unsigned short,
// unsigned int, unsigned long, or unsigned long long. See
// https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution.
&&
!
(
std
::
is_same_v
<
type
,
unsigned
char
>
||
std
::
is_same_v
<
type
,
signed
char
>
)
#endif
)
...
...
src/process.cpp
View file @
80eb522f
...
...
@@ -26,21 +26,17 @@
#include <migraphx/env.hpp>
#include <functional>
#include <iostream>
#ifdef _WIN32
// cppcheck-suppress definePrefix
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#else
#include <unistd.h>
#endif
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
MIGRAPHX_DECLARE_ENV_VAR
(
MIGRAPHX_TRACE_CMD_EXECUTE
)
#ifndef _WIN32
std
::
function
<
void
(
const
char
*
)
>
redirect_to
(
std
::
ostream
&
os
)
{
return
[
&
](
const
char
*
x
)
{
os
<<
x
;
};
}
template
<
class
F
>
int
exec
(
const
std
::
string
&
cmd
,
const
char
*
type
,
F
f
)
...
...
@@ -62,11 +58,10 @@ int exec(const std::string& cmd, const char* type, F f)
return
ec
;
}
int
exec
(
const
std
::
string
&
cmd
)
int
exec
(
const
std
::
string
&
cmd
,
const
std
::
function
<
void
(
const
char
*
)
>&
std_out
)
{
auto
std_out
{[](
const
char
*
x
)
{
std
::
cout
<<
x
;
}};
return
exec
(
cmd
,
"r"
,
[
&
](
FILE
*
f
)
{
std
::
array
<
char
,
128
>
buffer
{}
;
std
::
array
<
char
,
128
>
buffer
;
while
(
fgets
(
buffer
.
data
(),
buffer
.
size
(),
f
)
!=
nullptr
)
std_out
(
buffer
.
data
());
});
...
...
@@ -79,131 +74,6 @@ int exec(const std::string& cmd, std::function<void(process::writer)> std_in)
});
}
#else
#define MIGRAPHX_PROCESS_BUFSIZE 4096
class
pipe
{
public:
explicit
pipe
(
bool
inherit_handle
=
true
)
{
SECURITY_ATTRIBUTES
attrs
;
attrs
.
nLength
=
sizeof
(
SECURITY_ATTRIBUTES
);
attrs
.
bInheritHandle
=
inherit_handle
?
TRUE
:
FALSE
;
attrs
.
lpSecurityDescriptor
=
nullptr
;
if
(
CreatePipe
(
&
hRead_
,
&
hWrite_
,
&
attrs
,
0
)
==
FALSE
)
throw
GetLastError
();
if
(
SetHandleInformation
(
&
hRead_
,
HANDLE_FLAG_INHERIT
,
0
)
==
FALSE
)
throw
GetLastError
();
}
~
pipe
()
{
close_write_handle
();
close_read_handle
();
}
HANDLE
get_read_handle
()
const
{
return
hRead_
;
}
void
close_read_handle
()
{
if
(
hRead_
!=
nullptr
)
{
CloseHandle
(
hRead_
);
hRead_
=
nullptr
;
}
}
HANDLE
get_write_handle
()
const
{
return
hWrite_
;
}
void
close_write_handle
()
{
if
(
hWrite_
!=
nullptr
)
{
CloseHandle
(
hWrite_
);
hWrite_
=
nullptr
;
}
}
private:
HANDLE
hWrite_
{
nullptr
},
hRead_
{
nullptr
};
};
int
exec
(
const
std
::
string
&
cmd
)
{
try
{
if
(
enabled
(
MIGRAPHX_TRACE_CMD_EXECUTE
{}))
std
::
cout
<<
cmd
<<
std
::
endl
;
pipe
stdin_
{},
stdout_
{};
STARTUPINFO
info
;
PROCESS_INFORMATION
processInfo
;
ZeroMemory
(
&
info
,
sizeof
(
STARTUPINFO
));
info
.
cb
=
sizeof
(
STARTUPINFO
);
info
.
hStdError
=
stdout_
.
get_write_handle
();
info
.
hStdOutput
=
stdout_
.
get_write_handle
();
info
.
hStdInput
=
stdin_
.
get_read_handle
();
info
.
dwFlags
|=
STARTF_USESTDHANDLES
;
ZeroMemory
(
&
processInfo
,
sizeof
(
processInfo
));
LPSTR
lpCmdLn
{
const_cast
<
LPSTR
>
(
cmd
.
c_str
())};
BOOL
bSuccess
=
CreateProcess
(
nullptr
,
lpCmdLn
,
nullptr
,
nullptr
,
TRUE
,
0
,
nullptr
,
nullptr
,
&
info
,
&
processInfo
);
if
(
bSuccess
==
FALSE
)
return
GetLastError
();
DWORD
dwRead
,
dwWritten
;
TCHAR
chBuf
[
MIGRAPHX_PROCESS_BUFSIZE
];
HANDLE
hStdOut
{
GetStdHandle
(
STD_OUTPUT_HANDLE
)};
for
(;;)
{
BOOL
bRead
=
ReadFile
(
stdout_
.
get_read_handle
(),
chBuf
,
MIGRAPHX_PROCESS_BUFSIZE
,
&
dwRead
,
nullptr
);
if
(
bRead
==
FALSE
)
{
if
(
GetLastError
()
!=
ERROR_MORE_DATA
)
break
;
}
if
(
dwRead
==
0
)
break
;
BOOL
bWrite
=
WriteFile
(
hStdOut
,
chBuf
,
dwRead
,
&
dwWritten
,
nullptr
);
if
(
bWrite
==
FALSE
)
break
;
}
WaitForSingleObject
(
processInfo
.
hProcess
,
INFINITE
);
DWORD
status
{};
GetExitCodeProcess
(
processInfo
.
hProcess
,
&
status
);
CloseHandle
(
processInfo
.
hProcess
);
CloseHandle
(
processInfo
.
hThread
);
return
static_cast
<
int
>
(
status
);
}
// cppcheck-suppress catchExceptionByValue
catch
(
DWORD
lastError
)
{
return
lastError
;
}
}
#endif
struct
process_impl
{
std
::
string
command
{};
...
...
@@ -249,15 +119,11 @@ process& process::cwd(const fs::path& p)
return
*
this
;
}
void
process
::
exec
()
{
impl
->
check_exec
(
impl
->
get_command
());
}
void
process
::
exec
()
{
impl
->
check_exec
(
impl
->
get_command
()
,
redirect_to
(
std
::
cout
)
);
}
void
process
::
write
(
std
::
function
<
void
(
process
::
writer
)
>
pipe_in
)
{
#ifdef _WIN32
impl
->
check_exec
(
impl
->
get_command
());
#else
impl
->
check_exec
(
impl
->
get_command
(),
std
::
move
(
pipe_in
));
#endif
}
}
// namespace MIGRAPHX_INLINE_NS
...
...
src/process_win32.cpp
0 → 100644
View file @
80eb522f
/*
* 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/process.hpp>
#include <migraphx/errors.hpp>
#include <migraphx/env.hpp>
#include <functional>
#include <iostream>
// cppcheck-suppress definePrefix
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
MIGRAPHX_DECLARE_ENV_VAR
(
MIGRAPHX_TRACE_CMD_EXECUTE
)
#define MIGRAPHX_PROCESS_BUFSIZE 4096
class
pipe
{
public:
explicit
pipe
(
bool
inherit_handle
=
true
)
{
SECURITY_ATTRIBUTES
attrs
;
attrs
.
nLength
=
sizeof
(
SECURITY_ATTRIBUTES
);
attrs
.
bInheritHandle
=
inherit_handle
?
TRUE
:
FALSE
;
attrs
.
lpSecurityDescriptor
=
nullptr
;
if
(
CreatePipe
(
&
hRead_
,
&
hWrite_
,
&
attrs
,
0
)
==
FALSE
)
throw
GetLastError
();
if
(
SetHandleInformation
(
&
hRead_
,
HANDLE_FLAG_INHERIT
,
0
)
==
FALSE
)
throw
GetLastError
();
}
~
pipe
()
{
close_write_handle
();
close_read_handle
();
}
HANDLE
get_read_handle
()
const
{
return
hRead_
;
}
void
close_read_handle
()
{
if
(
hRead_
!=
nullptr
)
{
CloseHandle
(
hRead_
);
hRead_
=
nullptr
;
}
}
HANDLE
get_write_handle
()
const
{
return
hWrite_
;
}
void
close_write_handle
()
{
if
(
hWrite_
!=
nullptr
)
{
CloseHandle
(
hWrite_
);
hWrite_
=
nullptr
;
}
}
private:
HANDLE
hWrite_
{
nullptr
},
hRead_
{
nullptr
};
};
int
exec
(
const
std
::
string
&
cmd
)
{
try
{
if
(
enabled
(
MIGRAPHX_TRACE_CMD_EXECUTE
{}))
std
::
cout
<<
cmd
<<
std
::
endl
;
pipe
stdin_
{},
stdout_
{};
STARTUPINFO
info
;
PROCESS_INFORMATION
processInfo
;
ZeroMemory
(
&
info
,
sizeof
(
STARTUPINFO
));
info
.
cb
=
sizeof
(
STARTUPINFO
);
info
.
hStdError
=
stdout_
.
get_write_handle
();
info
.
hStdOutput
=
stdout_
.
get_write_handle
();
info
.
hStdInput
=
stdin_
.
get_read_handle
();
info
.
dwFlags
|=
STARTF_USESTDHANDLES
;
ZeroMemory
(
&
processInfo
,
sizeof
(
processInfo
));
LPSTR
lpCmdLn
{
const_cast
<
LPSTR
>
(
cmd
.
c_str
())};
BOOL
bSuccess
=
CreateProcess
(
nullptr
,
lpCmdLn
,
nullptr
,
nullptr
,
TRUE
,
0
,
nullptr
,
nullptr
,
&
info
,
&
processInfo
);
if
(
bSuccess
==
FALSE
)
return
GetLastError
();
DWORD
dwRead
,
dwWritten
;
TCHAR
chBuf
[
MIGRAPHX_PROCESS_BUFSIZE
];
HANDLE
hStdOut
{
GetStdHandle
(
STD_OUTPUT_HANDLE
)};
for
(;;)
{
BOOL
bRead
=
ReadFile
(
stdout_
.
get_read_handle
(),
chBuf
,
MIGRAPHX_PROCESS_BUFSIZE
,
&
dwRead
,
nullptr
);
if
(
bRead
==
FALSE
)
{
if
(
GetLastError
()
!=
ERROR_MORE_DATA
)
break
;
}
if
(
dwRead
==
0
)
break
;
BOOL
bWrite
=
WriteFile
(
hStdOut
,
chBuf
,
dwRead
,
&
dwWritten
,
nullptr
);
if
(
bWrite
==
FALSE
)
break
;
}
WaitForSingleObject
(
processInfo
.
hProcess
,
INFINITE
);
DWORD
status
{};
GetExitCodeProcess
(
processInfo
.
hProcess
,
&
status
);
CloseHandle
(
processInfo
.
hProcess
);
CloseHandle
(
processInfo
.
hThread
);
return
static_cast
<
int
>
(
status
);
}
// cppcheck-suppress catchExceptionByValue
catch
(
DWORD
lastError
)
{
return
lastError
;
}
}
struct
process_impl
{
std
::
string
command
{};
fs
::
path
cwd
{};
std
::
string
get_command
()
const
{
std
::
string
result
;
if
(
not
cwd
.
empty
())
result
+=
"cd "
+
cwd
.
string
()
+
"; "
;
result
+=
command
;
return
result
;
}
template
<
class
...
Ts
>
void
check_exec
(
Ts
&&
...
xs
)
const
{
int
ec
=
migraphx
::
exec
(
std
::
forward
<
Ts
>
(
xs
)...);
if
(
ec
!=
0
)
MIGRAPHX_THROW
(
"Command "
+
get_command
()
+
" exited with status "
+
std
::
to_string
(
ec
));
}
};
process
::
process
(
const
std
::
string
&
cmd
)
:
impl
(
std
::
make_unique
<
process_impl
>
())
{
impl
->
command
=
cmd
;
}
process
::
process
(
process
&&
)
noexcept
=
default
;
process
&
process
::
operator
=
(
process
rhs
)
{
std
::
swap
(
impl
,
rhs
.
impl
);
return
*
this
;
}
process
::~
process
()
noexcept
=
default
;
process
&
process
::
cwd
(
const
fs
::
path
&
p
)
{
impl
->
cwd
=
p
;
return
*
this
;
}
void
process
::
exec
()
{
impl
->
check_exec
(
impl
->
get_command
());
}
void
process
::
write
(
std
::
function
<
void
(
process
::
writer
)
>
pipe_in
)
{
impl
->
check_exec
(
impl
->
get_command
());
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/py/CMakeLists.txt
View file @
80eb522f
...
...
@@ -22,27 +22,25 @@
# THE SOFTWARE.
#####################################################################################
if
(
MIGRAPHX_ENABLE_PYTHON
)
add_compile_definitions
(
$<$<COMPILE_LANGUAGE:CXX,C>:MIGRAPHX_ENABLE_PYTHON>
)
add_library
(
migraphx_py py_loader.cpp
)
migraphx_generate_export_header
(
migraphx_py
)
target_include_directories
(
migraphx_py PRIVATE include
)
target_link_libraries
(
migraphx_py PUBLIC migraphx
)
rocm_install_targets
(
TARGETS migraphx_py INCLUDE include
)
add_compile_definitions
(
$<$<COMPILE_LANGUAGE:CXX,C>:MIGRAPHX_ENABLE_PYTHON>
)
add_library
(
migraphx_py py_loader.cpp
)
migraphx_generate_export_header
(
migraphx_py
)
target_include_directories
(
migraphx_py PRIVATE include
)
target_link_libraries
(
migraphx_py PUBLIC migraphx
)
rocm_install_targets
(
TARGETS migraphx_py INCLUDE include
)
include
(
PythonModules
)
include
(
PythonModules
)
foreach
(
PYTHON_VERSION
${
PYTHON_VERSIONS
}
)
py_add_module
(
migraphx_pybind_
${
PYTHON_VERSION
}
migraphx_py.cpp PYTHON_VERSION
${
PYTHON_VERSION
}
PYTHON_MODULE migraphx
)
target_link_libraries
(
migraphx_pybind_
${
PYTHON_VERSION
}
PRIVATE migraphx migraphx_tf migraphx_onnx migraphx_all_targets
)
rocm_install_targets
(
TARGETS migraphx_pybind_
${
PYTHON_VERSION
}
)
add_dependencies
(
migraphx_py migraphx_pybind_
${
PYTHON_VERSION
}
)
foreach
(
PYTHON_VERSION
${
PYTHON_VERSIONS
}
)
py_add_module
(
migraphx_pybind_
${
PYTHON_VERSION
}
migraphx_py.cpp PYTHON_VERSION
${
PYTHON_VERSION
}
PYTHON_MODULE migraphx
)
target_link_libraries
(
migraphx_pybind_
${
PYTHON_VERSION
}
PRIVATE migraphx migraphx_tf migraphx_onnx migraphx_all_targets
)
rocm_install_targets
(
TARGETS migraphx_pybind_
${
PYTHON_VERSION
}
)
add_dependencies
(
migraphx_py migraphx_pybind_
${
PYTHON_VERSION
}
)
add_library
(
migraphx_py_
${
PYTHON_VERSION
}
py.cpp
)
target_include_directories
(
migraphx_py_
${
PYTHON_VERSION
}
PRIVATE include
)
target_link_libraries
(
migraphx_py_
${
PYTHON_VERSION
}
PUBLIC migraphx
)
target_link_libraries
(
migraphx_py_
${
PYTHON_VERSION
}
PRIVATE pybind11::pybind11 python
${
PYTHON_VERSION
}
::runtime
)
rocm_install_targets
(
TARGETS migraphx_py_
${
PYTHON_VERSION
}
)
add_dependencies
(
migraphx_py migraphx_py_
${
PYTHON_VERSION
}
)
endforeach
()
endif
()
add_library
(
migraphx_py_
${
PYTHON_VERSION
}
py.cpp
)
target_include_directories
(
migraphx_py_
${
PYTHON_VERSION
}
PRIVATE include
)
target_link_libraries
(
migraphx_py_
${
PYTHON_VERSION
}
PUBLIC migraphx
)
target_link_libraries
(
migraphx_py_
${
PYTHON_VERSION
}
PRIVATE pybind11::pybind11 python
${
PYTHON_VERSION
}
::runtime
)
rocm_install_targets
(
TARGETS migraphx_py_
${
PYTHON_VERSION
}
)
add_dependencies
(
migraphx_py migraphx_py_
${
PYTHON_VERSION
}
)
endforeach
()
src/targets/cpu/CMakeLists.txt
View file @
80eb522f
...
...
@@ -56,13 +56,13 @@ add_library(migraphx_cpu
set_target_properties
(
migraphx_cpu PROPERTIES EXPORT_NAME cpu
)
rocm_set_soversion
(
migraphx_cpu
${
MIGRAPHX_SO_VERSION
}
)
option
(
MIGRAPHX_ENABLE_ZENDNN
""
O
FF
)
option
(
MIGRAPHX_ENABLE_ZENDNN
"
MIGraphX enable ZenDNN
"
O
ff
)
if
(
MIGRAPHX_ENABLE_ZENDNN
)
find_path
(
ZENDNN_INC_PATH zendnn.hpp
)
find_library
(
ZENDNN_LIB amdZenDNN
)
find_library
(
BLIS_LIB blis
)
elif
(
NOT WIN32
)
el
se
if
(
NOT WIN32
)
find_package
(
dnnl REQUIRED
)
endif
()
...
...
src/targets/gpu/CMakeLists.txt
View file @
80eb522f
...
...
@@ -22,7 +22,7 @@
# THE SOFTWARE.
# ####################################################################################
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm $ENV{
ROCM
_PATH}
)
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm $ENV{
HIP
_PATH}
)
find_package
(
hip
)
if
(
NOT GPU_TARGETS
)
message
(
FATAL_ERROR
"HIP package is broken and has no GPU_TARGETS, please pass -DGPU_TARGETS=$(/opt/rocm/bin/rocminfo | grep -o -m1 'gfx.*') to cmake to build for your gpu."
)
...
...
@@ -57,10 +57,13 @@ endif()
if
(
NOT WIN32
)
include
(
Embed
)
add_embed_library
(
migraphx_kernels
${
KERNEL_FILES
}
RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/
)
add_embed_library
(
migraphx_kernels
${
KERNEL_FILES
}
BASE_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
/kernels/include/
)
endif
()
configure_file
(
device/targets.hpp.in include/migraphx/gpu/device/targets.hpp
)
file
(
GLOB DEVICE_GPU_SRCS CONFIGURE_DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/device/*.cpp
)
add_library
(
migraphx_device
${
DEVICE_GPU_SRCS
}
)
add_library
(
compile_for_gpu INTERFACE
)
target_compile_features
(
compile_for_gpu INTERFACE cxx_std_17
)
target_compile_options
(
compile_for_gpu INTERFACE -fno-gpu-rdc -Wno-cuda-compat -Wno-unused-command-line-argument -Xclang -fallow-half-arguments-and-returns
)
...
...
@@ -73,24 +76,6 @@ if(HAS_HIP_LAMBDA_HOST_DEVICE)
target_compile_options
(
compile_for_gpu INTERFACE -fhip-lambda-host-device
)
endif
()
add_library
(
migraphx_device
device/argmax.cpp
device/argmin.cpp
device/contiguous.cpp
device/fill.cpp
device/gather.cpp
device/int8_gemm_pack.cpp
device/logsoftmax.cpp
device/multinomial.cpp
device/nonzero.cpp
device/pad.cpp
device/prefix_scan_sum.cpp
device/reverse.cpp
device/rnn_variable_seq_lens.cpp
device/scatter.cpp
device/targets.cpp
device/topk.cpp
)
set_target_properties
(
migraphx_device PROPERTIES EXPORT_NAME device
)
rocm_set_soversion
(
migraphx_device
${
MIGRAPHX_SO_VERSION
}
)
rocm_clang_tidy_check
(
migraphx_device
)
...
...
src/targets/gpu/compile_hip.cpp
View file @
80eb522f
...
...
@@ -366,7 +366,8 @@ bool hip_has_flags(const std::vector<std::string>& flags)
join_strings
(
flags
,
" "
)
+
" -x hip -c --offload-arch=gfx900 --cuda-device-only"
;
std
::
string
src
;
src_file
input
{
"main.cpp"
,
src
};
src_file
input
{
"main.cpp"
,
src
};
try
{
compiler
.
compile
({
input
});
...
...
src/targets/gpu/compile_hip_code_object.cpp
View file @
80eb522f
...
...
@@ -164,20 +164,6 @@ std::size_t compute_block_size(std::size_t n, std::size_t max_block_size)
return
std
::
min
(
std
::
max
(
min_block_size
,
block_size
),
max_block_size
);
}
#ifndef _WIN32
std
::
vector
<
src_file
>
migraphx_kernels
()
{
auto
kernels
{
::
migraphx_kernels
()};
std
::
vector
<
src_file
>
result
;
std
::
transform
(
kernels
.
begin
(),
kernels
.
end
(),
std
::
back_inserter
(
result
),
[](
std
::
pair
<
std
::
string_view
,
std
::
string_view
>
const
&
elem
)
{
return
src_file
{
elem
};
});
return
result
;
}
#endif
operation
compile_hip_code_object
(
const
std
::
string
&
content
,
hip_compile_options
options
)
{
assert
(
options
.
global
>
0
);
...
...
@@ -185,9 +171,13 @@ operation compile_hip_code_object(const std::string& content, hip_compile_option
assert
(
not
options
.
inputs
.
empty
());
assert
(
options
.
inputs
.
size
()
==
options
.
virtual_inputs
.
size
()
or
options
.
virtual_inputs
.
empty
());
std
::
vector
<
src_file
>
srcs
{
migraphx_kernels
()};
srcs
.
insert
(
srcs
.
end
(),
options
.
additional_src_files
.
begin
(),
options
.
additional_src_files
.
end
());
std
::
vector
<
src_file
>
srcs
=
options
.
additional_src_files
;
static
auto
kernels
{
::
migraphx_kernels
()};
std
::
transform
(
kernels
.
begin
(),
kernels
.
end
(),
std
::
back_inserter
(
srcs
),
[](
const
std
::
pair
<
std
::
string_view
,
std
::
string_view
>&
elem
)
{
return
src_file
{
elem
};
});
srcs
.
emplace_back
(
"main.cpp"
,
content
);
auto
args_hpp
=
generate_args_hpp
(
options
.
virtual_inputs
.
empty
()
?
options
.
inputs
:
options
.
virtual_inputs
);
...
...
src/targets/gpu/kernels/migraphx_kernels.cpp
View file @
80eb522f
...
...
@@ -27,61 +27,51 @@
#include "migraphx_kernels.hpp"
#include "resource.h"
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
namespace
resource
{
std
::
string_view
read
(
int
id
)
namespace
{
std
::
string_view
__read
(
int
id
)
{
HMODULE
handle
{
::
GetModuleHandle
(
nullptr
)};
HRSRC
rc
{
::
FindResource
(
handle
,
MAKEINTRESOURCE
(
id
),
MAKEINTRESOURCE
(
MIGRAPHX_TEXTFILE
))};
HGLOBAL
data
{
::
LoadResource
(
handle
,
rc
)};
return
{
static_cast
<
char
const
*>
(
::
LockResource
(
data
)),
::
SizeofResource
(
handle
,
rc
)};
}
}
// namespace resource
}
std
::
vector
<
src_file
>
migraphx_kernels
()
std
::
unordered_map
<
std
::
string_view
,
std
::
string_view
>
migraphx_kernels
()
{
static
src_file
_kernels_
[]
=
{
{
"migraphx/kernels/algorithm.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_ALGORITHM_HPP
)},
{
"migraphx/kernels/args.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_ARGS_HPP
)},
{
"migraphx/kernels/array.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_ARRAY_HPP
)},
{
"migraphx/kernels/concat.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_CONCAT_HPP
)},
{
"migraphx/kernels/debug.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_DEBUG_HPP
)},
{
"migraphx/kernels/dfor.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_DFOR_HPP
)},
{
"migraphx/kernels/dpp.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_DPP_HPP
)},
{
"migraphx/kernels/functional.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_FUNCTIONAL_HPP
)},
{
"migraphx/kernels/gather.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_GATHER_HPP
)},
{
"migraphx/kernels/gathernd.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_GATHERND_HPP
)},
{
"migraphx/kernels/generic_constant.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_GENERIC_CONSTANT_HPP
)},
{
"migraphx/kernels/hip.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_HIP_HPP
)},
{
"migraphx/kernels/index.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_INDEX_HPP
)},
{
"migraphx/kernels/integral_constant.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_INTEGRAL_CONSTANT_HPP
)},
{
"migraphx/kernels/iota_iterator.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_IOTA_ITERATOR_HPP
)},
{
"migraphx/kernels/layernorm.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_LAYERNORM_HPP
)},
{
"migraphx/kernels/math.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_MATH_HPP
)},
{
"migraphx/kernels/ops.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_OPS_HPP
)},
{
"migraphx/kernels/pad.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_PAD_HPP
)},
{
"migraphx/kernels/pointwise.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_POINTWISE_HPP
)},
{
"migraphx/kernels/preload.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_PRELOAD_HPP
)},
{
"migraphx/kernels/print.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_PRINT_HPP
)},
{
"migraphx/kernels/ranges.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_RANGES_HPP
)},
{
"migraphx/kernels/reduce.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_REDUCE_HPP
)},
{
"migraphx/kernels/roialign.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_ROIALIGN_HPP
)},
{
"migraphx/kernels/scatternd.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_SCATTERND_HPP
)},
{
"migraphx/kernels/shape.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_SHAPE_HPP
)},
{
"migraphx/kernels/softmax.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_SOFTMAX_HPP
)},
{
"migraphx/kernels/tensor_view.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_TENSOR_VIEW_HPP
)},
{
"migraphx/kernels/type_traits.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_TYPE_TRAITS_HPP
)},
{
"migraphx/kernels/types.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_TYPES_HPP
)},
{
"migraphx/kernels/vec.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_VEC_HPP
)},
{
"migraphx/kernels/vectorize.hpp"
,
resource
::
read
(
MIGRAPHX_IDR_VECTORIZE_HPP
)}};
return
{
std
::
begin
(
_kernels_
),
std
::
end
(
_kernels_
)};
static
std
::
unordered_map
<
std
::
string_view
,
std
::
string_view
>
kernels
=
{
{
"migraphx/kernels/algorithm.hpp"
,
__read
(
MIGRAPHX_IDR_ALGORITHM_HPP
)},
{
"migraphx/kernels/args.hpp"
,
__read
(
MIGRAPHX_IDR_ARGS_HPP
)},
{
"migraphx/kernels/array.hpp"
,
__read
(
MIGRAPHX_IDR_ARRAY_HPP
)},
{
"migraphx/kernels/concat.hpp"
,
__read
(
MIGRAPHX_IDR_CONCAT_HPP
)},
{
"migraphx/kernels/debug.hpp"
,
__read
(
MIGRAPHX_IDR_DEBUG_HPP
)},
{
"migraphx/kernels/dfor.hpp"
,
__read
(
MIGRAPHX_IDR_DFOR_HPP
)},
{
"migraphx/kernels/dpp.hpp"
,
__read
(
MIGRAPHX_IDR_DPP_HPP
)},
{
"migraphx/kernels/functional.hpp"
,
__read
(
MIGRAPHX_IDR_FUNCTIONAL_HPP
)},
{
"migraphx/kernels/gather.hpp"
,
__read
(
MIGRAPHX_IDR_GATHER_HPP
)},
{
"migraphx/kernels/gathernd.hpp"
,
__read
(
MIGRAPHX_IDR_GATHERND_HPP
)},
{
"migraphx/kernels/generic_constant.hpp"
,
__read
(
MIGRAPHX_IDR_GENERIC_CONSTANT_HPP
)},
{
"migraphx/kernels/hip.hpp"
,
__read
(
MIGRAPHX_IDR_HIP_HPP
)},
{
"migraphx/kernels/index.hpp"
,
__read
(
MIGRAPHX_IDR_INDEX_HPP
)},
{
"migraphx/kernels/integral_constant.hpp"
,
__read
(
MIGRAPHX_IDR_INTEGRAL_CONSTANT_HPP
)},
{
"migraphx/kernels/iota_iterator.hpp"
,
__read
(
MIGRAPHX_IDR_IOTA_ITERATOR_HPP
)},
{
"migraphx/kernels/layernorm.hpp"
,
__read
(
MIGRAPHX_IDR_LAYERNORM_HPP
)},
{
"migraphx/kernels/math.hpp"
,
__read
(
MIGRAPHX_IDR_MATH_HPP
)},
{
"migraphx/kernels/ops.hpp"
,
__read
(
MIGRAPHX_IDR_OPS_HPP
)},
{
"migraphx/kernels/pad.hpp"
,
__read
(
MIGRAPHX_IDR_PAD_HPP
)},
{
"migraphx/kernels/pointwise.hpp"
,
__read
(
MIGRAPHX_IDR_POINTWISE_HPP
)},
{
"migraphx/kernels/preload.hpp"
,
__read
(
MIGRAPHX_IDR_PRELOAD_HPP
)},
{
"migraphx/kernels/print.hpp"
,
__read
(
MIGRAPHX_IDR_PRINT_HPP
)},
{
"migraphx/kernels/ranges.hpp"
,
__read
(
MIGRAPHX_IDR_RANGES_HPP
)},
{
"migraphx/kernels/reduce.hpp"
,
__read
(
MIGRAPHX_IDR_REDUCE_HPP
)},
{
"migraphx/kernels/roialign.hpp"
,
__read
(
MIGRAPHX_IDR_ROIALIGN_HPP
)},
{
"migraphx/kernels/scatternd.hpp"
,
__read
(
MIGRAPHX_IDR_SCATTERND_HPP
)},
{
"migraphx/kernels/shape.hpp"
,
__read
(
MIGRAPHX_IDR_SHAPE_HPP
)},
{
"migraphx/kernels/softmax.hpp"
,
__read
(
MIGRAPHX_IDR_SOFTMAX_HPP
)},
{
"migraphx/kernels/tensor_view.hpp"
,
__read
(
MIGRAPHX_IDR_TENSOR_VIEW_HPP
)},
{
"migraphx/kernels/type_traits.hpp"
,
__read
(
MIGRAPHX_IDR_TYPE_TRAITS_HPP
)},
{
"migraphx/kernels/types.hpp"
,
__read
(
MIGRAPHX_IDR_TYPES_HPP
)},
{
"migraphx/kernels/vec.hpp"
,
__read
(
MIGRAPHX_IDR_VEC_HPP
)},
{
"migraphx/kernels/vectorize.hpp"
,
__read
(
MIGRAPHX_IDR_VECTORIZE_HPP
)}};
return
kernels
;
}
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
src/targets/gpu/kernels/migraphx_kernels.hpp
View file @
80eb522f
...
...
@@ -25,14 +25,9 @@
#ifndef MIGRAPHX_GUARD_MIGRAPHX_KERNELS_HPP
#define MIGRAPHX_GUARD_MIGRAPHX_KERNELS_HPP
#include "migraphx/compile_src.hpp"
#include <string_view>
#include <unordered_map>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
namespace
gpu
{
std
::
vector
<
src_file
>
migraphx_kernels
();
}
// namespace gpu
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
std
::
unordered_map
<
std
::
string_view
,
std
::
string_view
>
migraphx_kernels
();
#endif // MIGRAPHX_GUARD_MIGRAPHX_KERNELS_HPP
test/multi_target/multitarget_test.cpp
View file @
80eb522f
...
...
@@ -37,7 +37,6 @@
#include <migraphx/make_op.hpp>
#include <migraphx/check_shapes.hpp>
#include <migraphx/functional.hpp>
#include <basic_ops.hpp>
#include <migraphx/compile_options.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/generate.hpp>
...
...
test/verify/run_verify.cpp
View file @
80eb522f
...
...
@@ -44,8 +44,8 @@ MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_DUMP_TEST)
// An improved async, that doesn't block
template
<
class
Function
>
std
::
future
<
typename
std
::
result_
of
<
Function
()
>::
type
>
detach_async
(
Function
&&
f
,
bool
parallel
=
true
)
std
::
future
<
typename
std
::
invoke_
result_
t
<
Function
>
>
detach_async
(
Function
&&
f
,
bool
parallel
=
true
)
{
if
(
parallel
)
{
...
...
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