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
bc7ac032
Commit
bc7ac032
authored
Oct 31, 2023
by
Artur Wojcik
Browse files
partially merge with uif2-rbuild
parent
c70d1179
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
142 additions
and
364 deletions
+142
-364
.gitignore
.gitignore
+1
-1
CMakeLists.txt
CMakeLists.txt
+7
-10
cmake/EnableCompilerWarnings.cmake
cmake/EnableCompilerWarnings.cmake
+89
-71
src/CMakeLists.txt
src/CMakeLists.txt
+3
-4
src/driver/CMakeLists.txt
src/driver/CMakeLists.txt
+0
-1
src/driver/argument_parser.hpp
src/driver/argument_parser.hpp
+2
-0
src/driver/main.cpp
src/driver/main.cpp
+2
-4
src/include/migraphx/op/add.hpp
src/include/migraphx/op/add.hpp
+2
-2
src/targets/cpu/CMakeLists.txt
src/targets/cpu/CMakeLists.txt
+1
-2
src/targets/cpu/lowering.cpp
src/targets/cpu/lowering.cpp
+7
-3
src/targets/gpu/CMakeLists.txt
src/targets/gpu/CMakeLists.txt
+1
-1
src/targets/gpu/compile_hip.cpp
src/targets/gpu/compile_hip.cpp
+1
-1
src/targets/gpu/driver/CMakeLists.txt
src/targets/gpu/driver/CMakeLists.txt
+7
-14
src/targets/gpu/hiprtc/CMakeLists.txt
src/targets/gpu/hiprtc/CMakeLists.txt
+8
-8
src/targets/gpu/kernels/migraphx_kernels.cpp
src/targets/gpu/kernels/migraphx_kernels.cpp
+0
-77
src/targets/gpu/kernels/migraphx_kernels.hpp
src/targets/gpu/kernels/migraphx_kernels.hpp
+0
-33
src/targets/gpu/kernels/resource.h
src/targets/gpu/kernels/resource.h
+0
-64
src/targets/gpu/kernels/resource.rc
src/targets/gpu/kernels/resource.rc
+0
-59
src/targets/ref/lowering.cpp
src/targets/ref/lowering.cpp
+10
-8
src/version.h.in
src/version.h.in
+1
-1
No files found.
.gitignore
View file @
bc7ac032
...
...
@@ -81,7 +81,7 @@ cmake-build*/
build*/
# Recommended location to install rbuild dependencies from README.md
depend/
depend
*
/
# Python virtual environment
.venv/
CMakeLists.txt
View file @
bc7ac032
...
...
@@ -41,9 +41,10 @@ if(NOT MIGRAPHX_GENERATOR_IS_MULTI_CONFIG)
set_property
(
CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
${
CMAKE_CONFIGURATION_TYPES
}
)
endif
()
set
(
CMAKE_INSTALL_PREFIX
"/opt/rocm"
CACHE PATH
""
)
set
(
CMAKE_BUILD_RPATH
"
${
CMAKE_BINARY_DIR
}
/lib"
)
if
(
NOT WIN32
)
set
(
CMAKE_INSTALL_PREFIX
"/opt/rocm"
CACHE PATH
""
)
set
(
CMAKE_BUILD_RPATH
"
${
CMAKE_BINARY_DIR
}
/lib"
)
endif
()
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/llvm $ENV{ROCM_PATH} $ENV{HIP_PATH}
)
...
...
@@ -59,15 +60,15 @@ else()
option
(
MIGRAPHX_ENABLE_PYTHON
"Enable python bindings"
ON
)
endif
()
# By default build shared libraries
option
(
BUILD_SHARED_LIBS
"Create shared libraries"
ON
)
if
(
WIN32
)
# CK is not yet ported to Windows
option
(
MIGRAPHX_USE_COMPOSABLEKERNEL
"Enable MIGraphX to use composable kernel JIT library"
OFF
)
else
()
option
(
MIGRAPHX_USE_COMPOSABLEKERNEL
"Enable MIGraphX to use composable kernel JIT library"
ON
)
endif
()
# By default build shared libraries
option
(
BUILD_SHARED_LIBS
"Create shared libraries"
ON
)
if
(
WIN32
)
add_compile_definitions
(
$<$<COMPILE_LANGUAGE:C,CXX>:_CRT_SECURE_NO_WARNINGS>
)
add_subdirectory
(
extern
)
...
...
@@ -285,10 +286,6 @@ rocm_enable_cppcheck(
include
(
ROCMCreatePackage
)
include
(
ROCMTest
)
if
(
BUILD_TESTING
)
add_compile_definitions
(
$<$<COMPILE_LANGUAGE:C,CXX>:MIGRAPHX_BUILD_TESTING>
)
endif
()
set
(
CMAKE_LIBRARY_OUTPUT_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/lib
)
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/lib
)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
/bin
)
...
...
cmake/EnableCompilerWarnings.cmake
View file @
bc7ac032
...
...
@@ -23,77 +23,95 @@
#####################################################################################
# - Enable warning all for gcc/clang or use /W4 for visual studio
## Strict compile options for Visual C++ compiler
set
(
__default_msvc_compile_options /w
)
## Strict warning level
if
(
MSVC
)
# Use the highest warning level for visual studio.
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/w"
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
/w"
)
# set(CMAKE_CXX_WARNING_LEVEL 4)
# if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
# string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# else ()
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
# endif ()
## Strict compile options for GNU/Clang compilers
set
(
__default_compile_options
-Wall -Wextra
-Wcomment
-Wendif-labels
-Wformat
-Winit-self
-Wreturn-type
-Wsequence-point
-Wswitch
-Wtrigraphs
-Wundef
-Wuninitialized
-Wunreachable-code
-Wunused
-Wno-sign-compare
-Wno-reserved-macro-identifier
)
# set(CMAKE_C_WARNING_LEVEL 4)
# if (CMAKE_C_FLAGS MATCHES "/W[0-4]")
# string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# else ()
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
# endif ()
## Strict compile options for Clang compilers
set
(
__default_clang_compile_options
-Weverything
-Wshadow
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-conversion
-Wno-double-promotion
-Wno-exit-time-destructors
-Wno-extra-semi
-Wno-extra-semi-stmt
-Wno-float-conversion
-Wno-gnu-anonymous-struct
-Wno-gnu-zero-variadic-macro-arguments
-Wno-missing-prototypes
-Wno-nested-anon-types
-Wno-option-ignored
-Wno-padded
-Wno-shorten-64-to-32
-Wno-sign-conversion
-Wno-unused-command-line-argument
-Wno-weak-vtables
-Wno-c99-extensions
-fno-sanitize=function,vptr
)
if
(
WIN32
)
list
(
APPEND __default_clang_compile_options
-fms-extensions
-fms-compatibility
-fdelayed-template-parsing
)
endif
()
set
(
__default_gnu_compile_options
-Wduplicated-branches
-Wduplicated-cond
-Wno-noexcept-type
-Wodr
-Wshift-negative-value
-Wshift-overflow=2
-Wno-missing-field-initializers
-Wno-maybe-uninitialized
)
add_compile_options
(
"$<$<OR:$<CXX_COMPILER_ID:MSVC>,$<C_COMPILER_ID:MSVC>>:
${
__default_msvc_compile_options
}
>"
"$<$<OR:$<CXX_COMPILER_ID:GNU,Clang>,$<C_COMPILER_ID:GNU,Clang>>:
${
__default_compile_options
}
>"
"$<$<OR:$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,7>>,$<AND:$<C_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,7>>>:
${
__default_gnu_compile_options
}
>"
"$<$<OR:$<CXX_COMPILER_ID:Clang>,$<C_COMPILER_ID:Clang>>:
${
__default_clang_compile_options
}
>"
)
unset
(
__default_msvc_compile_options
)
unset
(
__default_compile_options
)
unset
(
__default_gnu_compile_options
)
unset
(
__default_clang_compile_options
)
else
()
foreach
(
COMPILER C CXX
)
set
(
CMAKE_COMPILER_WARNINGS
)
# use -Wall for gcc and clang
list
(
APPEND CMAKE_COMPILER_WARNINGS
-Wall
-Wextra
-Wcomment
-Wendif-labels
-Wformat
-Winit-self
-Wreturn-type
-Wsequence-point
# Shadow is broken on gcc when using lambdas
# -Wshadow
-Wswitch
-Wtrigraphs
-Wundef
-Wuninitialized
-Wunreachable-code
-Wunused
-Wno-sign-compare
)
# Flags for gcc 7
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER
"7.0"
)
list
(
APPEND CMAKE_COMPILER_WARNINGS
-Wduplicated-branches
-Wduplicated-cond
-Wno-noexcept-type
-Wodr
-Wshift-negative-value
-Wshift-overflow=2
)
endif
()
endif
()
if
(
CMAKE_
${
COMPILER
}
_COMPILER_ID MATCHES
"Clang"
)
list
(
APPEND CMAKE_COMPILER_WARNINGS
-Weverything
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-conversion
-Wno-double-promotion
-Wno-exit-time-destructors
-Wno-extra-semi
-Wno-extra-semi-stmt
-Wno-float-conversion
-Wno-gnu-anonymous-struct
-Wno-gnu-zero-variadic-macro-arguments
-Wno-missing-prototypes
-Wno-nested-anon-types
-Wno-option-ignored
-Wno-padded
-Wno-shorten-64-to-32
-Wno-sign-conversion
-Wno-unused-command-line-argument
-Wno-weak-vtables
-Wno-c99-extensions
# -Wno-c++2a-designator
)
else
()
list
(
APPEND CMAKE_COMPILER_WARNINGS
-Wno-missing-field-initializers
-Wno-maybe-uninitialized
# -Wno-deprecated-declarations
)
endif
()
foreach
(
COMPILER_WARNING
${
CMAKE_COMPILER_WARNINGS
}
)
add_compile_options
(
$<$<COMPILE_LANGUAGE:
${
COMPILER
}
>:
${
COMPILER_WARNING
}
>
)
endforeach
()
endforeach
()
endif
()
src/CMakeLists.txt
View file @
bc7ac032
...
...
@@ -104,9 +104,6 @@ add_library(migraphx
value.cpp
verify_args.cpp
)
if
(
WIN32
)
target_compile_definitions
(
migraphx PUBLIC -D_USE_MATH_DEFINES
)
endif
()
configure_file
(
version.h.in include/migraphx/version.h
)
rocm_set_soversion
(
migraphx
${
MIGRAPHX_SO_VERSION
}
)
function
(
register_migraphx_ops
)
...
...
@@ -249,7 +246,9 @@ rocm_install_targets(
${
CMAKE_CURRENT_BINARY_DIR
}
/include
)
if
(
NOT WIN32
)
if
(
WIN32
)
target_compile_definitions
(
migraphx PUBLIC _CRT_SECURE_NO_WARNINGS _USE_MATH_DEFINES
)
else
()
check_cxx_linker_flag
(
-lstdc++fs HAS_LIB_STD_FILESYSTEM
)
if
(
HAS_LIB_STD_FILESYSTEM
)
target_link_libraries
(
migraphx PRIVATE -lstdc++fs
)
...
...
src/driver/CMakeLists.txt
View file @
bc7ac032
...
...
@@ -43,7 +43,6 @@ if(NOT WIN32)
)
set_directory_properties
(
PROPERTIES ADDITIONAL_CLEAN_FILES
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/driver
)
endif
()
target_compile_options
(
driver PRIVATE -Wno-ignored-attributes -Wno-unused-parameter
)
rocm_clang_tidy_check
(
driver
)
file
(
STRINGS
"
${
CMAKE_SOURCE_DIR
}
/test/onnx/.onnxrt-commit"
String_output
)
...
...
src/driver/argument_parser.hpp
View file @
bc7ac032
...
...
@@ -105,6 +105,8 @@ inline std::ostream& operator<<(std::ostream& os, const color& c)
static
const
bool
use_color
=
isatty
(
STDOUT_FILENO
)
!=
0
;
if
(
use_color
)
return
os
<<
"
\033
["
<<
static_cast
<
std
::
size_t
>
(
c
)
<<
"m"
;
#else
(
void
)
c
;
#endif
return
os
;
}
...
...
src/driver/main.cpp
View file @
bc7ac032
...
...
@@ -603,8 +603,7 @@ struct version : command<version>
void
run
()
const
{
std
::
cout
<<
"MIGraphX Version: "
<<
MIGRAPHX_VERSION_MAJOR
<<
"."
<<
MIGRAPHX_VERSION_MINOR
<<
"."
<<
MIGRAPHX_VERSION_PATCH
<<
"."
<<
MIGRAPHX_STRINGIZE
(
MIGRAPHX_VERSION_TWEAK
)
<<
std
::
endl
;
<<
"."
<<
MIGRAPHX_VERSION_PATCH
<<
"."
MIGRAPHX_VERSION_TWEAK
<<
std
::
endl
;
}
};
...
...
@@ -762,8 +761,7 @@ struct main_command
{
std
::
string
version_str
=
"MIGraphX Version: "
+
std
::
to_string
(
MIGRAPHX_VERSION_MAJOR
)
+
"."
+
std
::
to_string
(
MIGRAPHX_VERSION_MINOR
)
+
"."
+
std
::
to_string
(
MIGRAPHX_VERSION_PATCH
)
+
"."
+
MIGRAPHX_STRINGIZE
(
MIGRAPHX_VERSION_TWEAK
);
std
::
to_string
(
MIGRAPHX_VERSION_PATCH
)
+
"."
MIGRAPHX_VERSION_TWEAK
;
ap
(
wrong_commands
,
{},
ap
.
metavar
(
"<command>"
),
ap
.
append
());
ap
(
nullptr
,
{
"-h"
,
"--help"
},
ap
.
help
(
"Show help"
),
ap
.
show_help
(
get_command_help
()));
ap
(
nullptr
,
...
...
src/include/migraphx/op/add.hpp
View file @
bc7ac032
...
...
@@ -35,8 +35,8 @@ struct add : binary<add>
{
value
attributes
()
const
{
value
a
=
base_attributes
();
a
[
"commutative"
]
=
value
(
true
)
;
auto
a
=
base_attributes
();
a
[
"commutative"
]
=
true
;
return
a
;
}
std
::
string
point_function
()
const
{
return
"+"
;
}
...
...
src/targets/cpu/CMakeLists.txt
View file @
bc7ac032
...
...
@@ -56,7 +56,7 @@ 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
"MIGraphX enable ZenDNN"
Off
)
set
(
MIGRAPHX_ENABLE_ZENDNN
Off CACHE BOOL
""
)
if
(
MIGRAPHX_ENABLE_ZENDNN
)
find_path
(
ZENDNN_INC_PATH zendnn.hpp
)
...
...
@@ -67,7 +67,6 @@ elseif(NOT WIN32)
endif
()
rocm_clang_tidy_check
(
migraphx_cpu
)
if
(
MIGRAPHX_ENABLE_ZENDNN
)
target_compile_definitions
(
migraphx_cpu PRIVATE -DMIGRAPHX_ENABLE_ZENDNN
)
target_include_directories
(
migraphx_cpu PRIVATE
${
ZENDNN_INC_PATH
}
)
...
...
src/targets/cpu/lowering.cpp
View file @
bc7ac032
...
...
@@ -122,11 +122,11 @@ struct cpu_im2col
const
std
::
size_t
col_height
=
(
height
-
kernel_h
+
2
*
pad_h
)
/
stride_h
+
1
;
const
std
::
size_t
col_width
=
(
width
-
kernel_w
+
2
*
pad_w
)
/
stride_w
+
1
;
// account for padding for the starting position of the input pixels
std
::
size_t
iinput
=
kdiv2_h
-
long
(
pad_h
);
long
iinput
=
kdiv2_h
-
long
(
pad_h
);
// loop over output pixels (ioutput, joutput)
for
(
std
::
size_t
ioutput
=
0
;
ioutput
<
col_height
;
ioutput
++
,
iinput
+=
stride_h
)
{
std
::
size_t
jinput
=
kdiv2_w
-
long
(
pad_w
);
long
jinput
=
kdiv2_w
-
long
(
pad_w
);
for
(
std
::
size_t
joutput
=
0
;
joutput
<
col_width
;
joutput
++
,
jinput
+=
stride_w
)
{
// compute linear index for output
...
...
@@ -137,7 +137,9 @@ struct cpu_im2col
kernel_w
)([
&
](
std
::
size_t
c
,
std
::
size_t
koffset
,
std
::
size_t
loffset
)
{
auto
idx
=
iinput
+
long
(
koffset
)
-
kdiv2_h
;
auto
jdx
=
jinput
+
long
(
loffset
)
-
kdiv2_w
;
col
(
ldx
,
p
)
=
((
idx
<
height
)
&&
(
jdx
<
width
))
?
input
(
0
,
c
,
idx
,
jdx
)
:
0
;
col
(
ldx
,
p
)
=
((
idx
>=
0
)
&&
(
idx
<
height
)
&&
(
jdx
>=
0
)
&&
(
jdx
<
width
))
?
input
(
0
,
c
,
idx
,
jdx
)
:
0
;
p
++
;
});
}
...
...
@@ -454,6 +456,8 @@ void lowering::apply(module& m) const
{
#if !defined(_MSC_VER)
cpu_apply
{
&
m
}.
apply
();
#else
(
void
)
m
;
#endif
}
...
...
src/targets/gpu/CMakeLists.txt
View file @
bc7ac032
...
...
@@ -22,7 +22,7 @@
# THE SOFTWARE.
# ####################################################################################
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm $ENV{
HIP
_PATH}
)
list
(
APPEND CMAKE_PREFIX_PATH /opt/rocm $ENV{
ROCM
_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."
)
...
...
src/targets/gpu/compile_hip.cpp
View file @
bc7ac032
...
...
@@ -361,7 +361,7 @@ compile_hip_src(const std::vector<src_file>& srcs, std::string params, const std
bool
hip_has_flags
(
const
std
::
vector
<
std
::
string
>&
flags
)
{
src_compiler
compiler
;
compiler
.
compiler
=
MIGRAPHX_STRINGIZE
(
MIGRAPHX_HIP_COMPILER
)
;
compiler
.
compiler
=
MIGRAPHX_HIP_COMPILER
;
compiler
.
flags
=
join_strings
(
flags
,
" "
)
+
" -x hip -c --offload-arch=gfx900 --cuda-device-only"
;
...
...
src/targets/gpu/driver/CMakeLists.txt
View file @
bc7ac032
...
...
@@ -22,17 +22,10 @@
# THE SOFTWARE.
#####################################################################################
add_executable
(
migraphx_gpu_driver
action.cpp
compile_op.cpp
main.cpp
parser.cpp
run_op.cpp
)
set_target_properties
(
migraphx_gpu_driver PROPERTIES OUTPUT_NAME migraphx-gpu-driver
)
rocm_clang_tidy_check
(
migraphx_gpu_driver
)
target_include_directories
(
migraphx_gpu_driver PRIVATE include
)
target_link_libraries
(
migraphx_gpu_driver PRIVATE migraphx MIOpen migraphx_gpu hip::device
)
target_compile_options
(
migraphx_gpu_driver PRIVATE -Wno-ignored-attributes -Wno-option-ignored
)
file
(
GLOB GPU_DRIVER_SRCS CONFIGURE_DEPENDS
${
CMAKE_CURRENT_SOURCE_DIR
}
/*.cpp
)
add_executable
(
gpu-driver
${
GPU_DRIVER_SRCS
}
)
rocm_clang_tidy_check
(
gpu-driver
)
target_include_directories
(
gpu-driver PRIVATE include
)
target_link_libraries
(
gpu-driver PRIVATE migraphx_gpu
)
src/targets/gpu/hiprtc/CMakeLists.txt
View file @
bc7ac032
...
...
@@ -22,15 +22,15 @@
# THE SOFTWARE.
#####################################################################################
add_executable
(
migraphx
_
hiprtc
_
driver
add_executable
(
migraphx
-
hiprtc
-
driver
main.cpp
)
rocm_clang_tidy_check
(
migraphx_hiprtc_driver
)
target_link_libraries
(
migraphx_hiprtc_driver PRIVATE migraphx migraphx_gpu
)
add_dependencies
(
migraphx_all_targets migraphx_hiprtc_driver
)
set_target_properties
(
migraphx_hiprtc_driver PROPERTIES OUTPUT_NAME migraphx-hiprtc-driver
)
if
(
WIN32
)
target_compile_definitions
(
migraphx-hiprtc-driver PRIVATE _CRT_SECURE_NO_WARNINGS
)
endif
()
rocm_clang_tidy_check
(
migraphx-hiprtc-driver
)
target_link_libraries
(
migraphx-hiprtc-driver PRIVATE migraphx_gpu
)
add_dependencies
(
migraphx_all_targets migraphx-hiprtc-driver
)
rocm_install_targets
(
TARGETS migraphx
_
hiprtc
_
driver
TARGETS migraphx
-
hiprtc
-
driver
)
target_compile_options
(
migraphx_hiprtc_driver PRIVATE -Wno-ignored-attributes
)
src/targets/gpu/kernels/migraphx_kernels.cpp
deleted
100644 → 0
View file @
c70d1179
/*
* 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 <Windows.h>
#include "migraphx_kernels.hpp"
#include "resource.h"
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
)};
}
}
std
::
unordered_map
<
std
::
string_view
,
std
::
string_view
>
migraphx_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
;
}
src/targets/gpu/kernels/migraphx_kernels.hpp
deleted
100644 → 0
View file @
c70d1179
/*
* 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_MIGRAPHX_KERNELS_HPP
#define MIGRAPHX_GUARD_MIGRAPHX_KERNELS_HPP
#include <string_view>
#include <unordered_map>
std
::
unordered_map
<
std
::
string_view
,
std
::
string_view
>
migraphx_kernels
();
#endif // MIGRAPHX_GUARD_MIGRAPHX_KERNELS_HPP
src/targets/gpu/kernels/resource.h
deleted
100644 → 0
View file @
c70d1179
/*
* 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_MIGRAPHX_KERNELS_RESOURCE_H
#define MIGRAPHX_GUARD_MIGRAPHX_KERNELS_RESOURCE_H
#define MIGRAPHX_TEXTFILE 256
#define MIGRAPHX_IDR_ALGORITHM_HPP 101
#define MIGRAPHX_IDR_ARGS_HPP 102
#define MIGRAPHX_IDR_ARRAY_HPP 103
#define MIGRAPHX_IDR_CONCAT_HPP 104
#define MIGRAPHX_IDR_DEBUG_HPP 105
#define MIGRAPHX_IDR_DFOR_HPP 106
#define MIGRAPHX_IDR_DPP_HPP 107
#define MIGRAPHX_IDR_FUNCTIONAL_HPP 108
#define MIGRAPHX_IDR_GATHER_HPP 109
#define MIGRAPHX_IDR_GATHERND_HPP 110
#define MIGRAPHX_IDR_GENERIC_CONSTANT_HPP 111
#define MIGRAPHX_IDR_HIP_HPP 112
#define MIGRAPHX_IDR_INDEX_HPP 113
#define MIGRAPHX_IDR_INTEGRAL_CONSTANT_HPP 114
#define MIGRAPHX_IDR_IOTA_ITERATOR_HPP 115
#define MIGRAPHX_IDR_LAYERNORM_HPP 116
#define MIGRAPHX_IDR_MATH_HPP 117
#define MIGRAPHX_IDR_OPS_HPP 118
#define MIGRAPHX_IDR_PAD_HPP 119
#define MIGRAPHX_IDR_POINTWISE_HPP 120
#define MIGRAPHX_IDR_PRELOAD_HPP 121
#define MIGRAPHX_IDR_PRINT_HPP 122
#define MIGRAPHX_IDR_RANGES_HPP 123
#define MIGRAPHX_IDR_REDUCE_HPP 124
#define MIGRAPHX_IDR_ROIALIGN_HPP 125
#define MIGRAPHX_IDR_SCATTERND_HPP 126
#define MIGRAPHX_IDR_SHAPE_HPP 127
#define MIGRAPHX_IDR_SOFTMAX_HPP 128
#define MIGRAPHX_IDR_TENSOR_VIEW_HPP 129
#define MIGRAPHX_IDR_TYPE_TRAITS_HPP 130
#define MIGRAPHX_IDR_TYPES_HPP 131
#define MIGRAPHX_IDR_VEC_HPP 132
#define MIGRAPHX_IDR_VECTORIZE_HPP 134
#endif // MIGRAPHX_GUARD_MIGRAPHX_KERNELS_RESOURCE_H
src/targets/gpu/kernels/resource.rc
deleted
100644 → 0
View file @
c70d1179
//
// 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 "resource.h"
MIGRAPHX_IDR_ALGORITHM_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/algorithm.hpp"
MIGRAPHX_IDR_ARGS_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/args.hpp"
MIGRAPHX_IDR_ARRAY_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/array.hpp"
MIGRAPHX_IDR_CONCAT_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/concat.hpp"
MIGRAPHX_IDR_DEBUG_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/debug.hpp"
MIGRAPHX_IDR_DFOR_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/dfor.hpp"
MIGRAPHX_IDR_DPP_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/dpp.hpp"
MIGRAPHX_IDR_FUNCTIONAL_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/functional.hpp"
MIGRAPHX_IDR_GATHER_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/gather.hpp"
MIGRAPHX_IDR_GATHERND_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/gathernd.hpp"
MIGRAPHX_IDR_GENERIC_CONSTANT_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/generic_constant.hpp"
MIGRAPHX_IDR_HIP_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/hip.hpp"
MIGRAPHX_IDR_INDEX_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/index.hpp"
MIGRAPHX_IDR_INTEGRAL_CONSTANT_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/integral_constant.hpp"
MIGRAPHX_IDR_IOTA_ITERATOR_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/iota_iterator.hpp"
MIGRAPHX_IDR_LAYERNORM_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/layernorm.hpp"
MIGRAPHX_IDR_MATH_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/math.hpp"
MIGRAPHX_IDR_OPS_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/ops.hpp"
MIGRAPHX_IDR_PAD_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/pad.hpp"
MIGRAPHX_IDR_POINTWISE_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/pointwise.hpp"
MIGRAPHX_IDR_PRELOAD_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/preload.hpp"
MIGRAPHX_IDR_PRINT_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/print.hpp"
MIGRAPHX_IDR_RANGES_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/ranges.hpp"
MIGRAPHX_IDR_REDUCE_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/reduce.hpp"
MIGRAPHX_IDR_ROIALIGN_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/roialign.hpp"
MIGRAPHX_IDR_SCATTERND_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/scatternd.hpp"
MIGRAPHX_IDR_SHAPE_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/shape.hpp"
MIGRAPHX_IDR_SOFTMAX_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/softmax.hpp"
MIGRAPHX_IDR_TENSOR_VIEW_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/tensor_view.hpp"
MIGRAPHX_IDR_TYPE_TRAITS_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/type_traits.hpp"
MIGRAPHX_IDR_TYPES_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/types.hpp"
MIGRAPHX_IDR_VEC_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/vec.hpp"
MIGRAPHX_IDR_VECTORIZE_HPP MIGRAPHX_TEXTFILE "include/migraphx/kernels/vectorize.hpp"
src/targets/ref/lowering.cpp
View file @
bc7ac032
...
...
@@ -88,13 +88,13 @@ struct ref_lrn
{
argument
result
{
output_shape
};
visit_all
(
result
,
args
[
0
])([
&
](
auto
output
,
auto
input
)
{
auto
n_batch
=
output_shape
.
lens
()[
0
];
auto
channels
=
output_shape
.
lens
()[
1
];
auto
height
=
output_shape
.
lens
()[
2
];
auto
width
=
output_shape
.
lens
()[
3
];
auto
alphaoverarea
=
op
.
alpha
/
float
(
op
.
size
);
auto
radius_lower
=
(
op
.
size
-
1
)
/
2
;
auto
radius_upper
=
op
.
size
/
2
+
1
;
int
n_batch
=
output_shape
.
lens
()[
0
];
int
channels
=
output_shape
.
lens
()[
1
];
int
height
=
output_shape
.
lens
()[
2
];
int
width
=
output_shape
.
lens
()[
3
];
float
alphaoverarea
=
op
.
alpha
/
float
(
op
.
size
);
int
radius_lower
=
(
op
.
size
-
1
)
/
2
;
int
radius_upper
=
op
.
size
/
2
+
1
;
par_dfor
(
n_batch
,
height
,
width
)([
&
](
int
b
,
int
h
,
int
w
)
{
float
scale
=
0
;
...
...
@@ -185,7 +185,9 @@ struct ref_im2col
kernel_w
)([
&
](
std
::
size_t
c
,
std
::
size_t
koffset
,
std
::
size_t
loffset
)
{
auto
idx
=
iinput
+
long
(
koffset
)
-
kdiv2_h
;
auto
jdx
=
jinput
+
long
(
loffset
)
-
kdiv2_w
;
col
(
ldx
,
p
)
=
((
idx
<
height
)
&&
(
jdx
<
width
))
?
input
(
0
,
c
,
idx
,
jdx
)
:
0
;
col
(
ldx
,
p
)
=
((
idx
>=
0
)
&&
(
idx
<
height
)
&&
(
jdx
>=
0
)
&&
(
jdx
<
width
))
?
input
(
0
,
c
,
idx
,
jdx
)
:
0
;
p
++
;
});
}
...
...
src/version.h.in
View file @
bc7ac032
...
...
@@ -25,5 +25,5 @@
#define MIGRAPHX_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define MIGRAPHX_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define MIGRAPHX_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define MIGRAPHX_VERSION_TWEAK @PROJECT_VERSION_TWEAK@
#define MIGRAPHX_VERSION_TWEAK
"
@PROJECT_VERSION_TWEAK@
"
// clang-format on
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