Skip to content

Commit

Permalink
Merge branch 'develop' into common-dims
Browse files Browse the repository at this point in the history
  • Loading branch information
causten authored Sep 7, 2023
2 parents 8171c0b + a0894c2 commit 2d2ea3f
Show file tree
Hide file tree
Showing 244 changed files with 16,767 additions and 11,999 deletions.
69 changes: 67 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
-DMIGRAPHX_ENABLE_GPU=On \
-DMIGRAPHX_ENABLE_CPU=On \
-DMIGRAPHX_ENABLE_FPGA=On \
-DMIGRAPHX_ENABLE_MLIR=On \
-DBUILD_DEV=On \
-DROCM_ENABLE_GH_ANNOTATIONS=On \
-DCLANG_TIDY_DEPEND_ON_TARGET=Off \
Expand Down Expand Up @@ -169,6 +170,71 @@ jobs:
git config --global --add safe.directory /data
python3 tools/format.py origin/${{ github.event_name == 'pull_request' && github.base_ref || 'develop' }}
sles:
runs-on: ROCM-Ubuntu
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

# In this step, this action saves a list of existing images,
# the cache is created without them in the post run.
# It also restores the cache if it exists.
- name: Docker layer cache
uses: jpribyl/[email protected]
with:
key: docker-layer-caching-migraphx-sles-${{hashFiles('hip-clang.docker', '**/*requirements.txt', '**/install_prereqs.sh', 'rbuild.ini')}}
restore-keys:
docker-layer-caching-migraphx-sles-
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true

- name: Build the Docker image
run: docker build . --file tools/docker/sles.docker --tag migraphx-sles

- name: Restore cache files for ccache
uses: actions/cache/restore@v3
id: ccache_restore
with:
path: ${{ github.workspace }}/ccache
key: ccache-sles-${{ github.ref }}
restore-keys: ccache-sles-

- name: Build migraphx
shell: bash -c "docker run -i -v=$GITHUB_WORKSPACE:/data -w /data migraphx-sles bash < {0}"
run: |
set -e
export CCACHE_COMPRESSLEVEL=10
export CCACHE_DIR=/data/ccache
export CCACHE_NOHASHDIR=true
export CCACHE_BASEDIR=/data
export CCACHE_MAXSIZE=1
mkdir build
cd build
CXX=/opt/rocm/llvm/bin/clang++ CC=/opt/rocm/llvm/bin/clang cmake \
-DBUILD_DEV=On \
-DCMAKE_CXX_COMPILER_LAUNCHER=/usr/local/bin/ccache \
-DCMAKE_C_COMPILER_LAUNCHER=/usr/local/bin/ccache \
..
make -j$(nproc) tests driver
- name: Clear ccache cache before saving
if: ${{ steps.ccache_restore.outputs.cache-hit }}
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set +x
gh extension install actions/gh-actions-cache --pin v1.0.1
gh actions-cache delete ${{ steps.ccache_restore.outputs.cache-matched-key }} --confirm
- name: Save cache files for ccache
uses: actions/cache/save@v3
if: always()
with:
path: ${{ github.workspace }}/ccache
key: ccache-sles-${{ github.ref }}

pyflakes:
runs-on: ubuntu-20.04

Expand Down Expand Up @@ -274,11 +340,10 @@ jobs:
# This path is specific to Ubuntu
path: ${{ github.workspace }}/cget
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ matrix.os }}-cget-4-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}
key: ${{ matrix.os }}-cget-4-${{ hashFiles('requirements.txt', 'dev-requirements.txt', 'rbuild.ini') }}
restore-keys: ${{ matrix.os }}-cget-4-

- name: Install dependencies
if: steps.deps_cache.outputs.cache-hit != 'true'
run: rbuild prepare -d cget -s gh

- name: Restore cache files for ccache
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sync-onnxrt-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
onnxruntime
dependancies
automated
skip bot checks
assignees: TedThemistokleous
reviewers: TedThemistokleous causten
draft: false
Expand Down
48 changes: 42 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,49 @@

Full documentation for MIGraphX is available at [MIGraphX Documentation](https://rocmdocs.amd.com/projects/AMDMIGraphX/en/latest/).

## MIGraphX 2.5 for ROCm 5.5.0
## MIGraphX 2.7 for ROCm 5.7.0
### Added
- Enabled hipRTC to not require dev packages for migraphx runtime and allow the ROCm install to be in a different directory than it was during build time
- Add support for multi-target execution
- Added Dynamic Batch support with C++/Python APIs
- Add migraphx.create_argument to python API
- Added dockerfile example for Ubuntu 22.04
- Add TensorFlow supported ops in driver similar to exist onnx operator list
- Add a MIGRAPHX_TRACE_MATCHES_FOR env variable to filter the matcher trace
- Improved debugging by printing max,min,mean and stddev values for TRACE_EVAL = 2
- use fast_math flag instead of ENV flag for GELU
- Print message from driver if offload copy is set for compiled program
### Optimizations
- Optimized for ONNX Runtime 1.14.0
- Improved compile times by only building for the GPU on the system
- Improve performance of pointwise/reduction kernels when using NHWC layouts
- Load specific version of the migraphx_py library
- Annotate functions with the block size so the compiler can do a better job of optimizing
- Enable reshape on nonstandard shapes
- Use half HIP APIs to compute max and min
- Added support for broadcasted scalars to unsqueeze operator
- Improved multiplies with dot operator
- Handle broadcasts across dot and concat
- Add verify namespace for better symbol resolution
### Fixed
- Resolved accuracy issues with FP16 resnet50
- Update cpp generator to handle inf from float
- Fix assertion error during verify and make DCE work with tuples
- Fix convert operation for NaNs
- Fix shape typo in API test
- Fix compile warnings for shadowing variable names
- Add missing specialization for the `nullptr` for the hash function
### Changed
- Bumped version of half library to 5.6.0
- Bumped CI to support rocm 5.6
- Make building tests optional
- replace np.bool with bool as per numpy request
### Removed
- Removed int8x4 rocBlas calls due to deprecation
- removed std::reduce usage since not all OS' support it


## MIGraphX 2.5 for ROCm 5.5.0
### Added
- Y-Model feature to store tuning information with the optimized model
- Added Python 3.10 bindings
Expand All @@ -12,15 +53,11 @@ Full documentation for MIGraphX is available at [MIGraphX Documentation](https:/
- Build support for ROCm MLIR
- Added migraphx-driver flag to print optimizations in python (--python)
- Added JIT implementation of the Gather and Pad operator which results in better handling of larger tensor sizes.


### Optimizations
- Improved performance of Transformer based models
- Improved performance of the Pad, Concat, Gather, and Pointwise operators
- Improved onnx/pb file loading speed
- Added general optimize pass which runs several passes such as simplify_reshapes/algebra and DCE in loop.


### Fixed
- Improved parsing Tensorflow Protobuf files
- Resolved various accuracy issues with some onnx models
Expand All @@ -29,6 +66,5 @@ Full documentation for MIGraphX is available at [MIGraphX Documentation](https:/
- Use --offload-arch instead of --cuda-gpu-arch for the HIP compiler
- Changes inside JIT to use float accumulator for large reduce ops of half type to avoid overflow.
- Changes inside JIT to temporarily use cosine to compute sine function.

### Changed
- Changed version/location of 3rd party build dependencies to pick up fixes
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ project(migraphx LANGUAGES C CXX)
include(CTest)

find_package(ROCM REQUIRED)
find_package(Threads REQUIRED)

find_path(HALF_INCLUDE_DIR half.hpp PATH_SUFFIXES half)
if (NOT HALF_INCLUDE_DIR)
Expand Down Expand Up @@ -227,14 +228,12 @@ rocm_enable_cppcheck(
shadowVar
shadowVariable
unsafeClassDivZero
# Disable because of too many FPs
arithOperationsOnVoidPointer
definePrefix:*test/include/test.hpp
ctuOneDefinitionRuleViolation:*test/*
useSmartPointer:*src/api/api.cpp
useSmartPointer:*make_shared_array.hpp
constParameter:*src/targets/gpu/*.cpp
constParameter:*src/targets/gpu/*.hpp
# Suppress mlir_conv.cpp since this file will be deleted
*:*src/targets/gpu/mlir_conv.cpp
FORCE
INCONCLUSIVE
RULE_FILE
Expand All @@ -251,10 +250,13 @@ rocm_enable_cppcheck(
${CMAKE_CURRENT_SOURCE_DIR}/src/targets/gpu/kernels/include
${CMAKE_CURRENT_SOURCE_DIR}/test/include
DEFINE
MIGRAPHX_MLIR=1
CPPCHECK=1
__device__=
__host__=
__global__=
UNDEFINE
MIGRAPHX_USE_CLANG_TIDY
)

enable_testing()
Expand Down
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ ADD dev-requirements.txt /dev-requirements.txt
ADD requirements.txt /requirements.txt
ADD rbuild.ini /rbuild.ini

# Temporarily install a new cmake until switching to ubuntu 22.04
RUN pip3 install cmake==3.22.1

COPY ./tools/install_prereqs.sh /
RUN /install_prereqs.sh /usr/local / && rm /install_prereqs.sh
RUN test -f /usr/local/hash || exit 1
Expand All @@ -98,6 +101,9 @@ RUN cget -p $PREFIX install facebook/[email protected] -X subdir -DCMAKE_DIR=build/cma
RUN cget -p $PREFIX install [email protected] -DENABLE_TESTING=OFF
RUN cget -p /opt/cmake install kitware/[email protected]

# Install MLIR
ADD mlir-requirements.txt /mlir-requirements.txt
RUN cget -p /usr/local install -f /mlir-requirements.txt

COPY ./test/onnx/.onnxrt-commit /

Expand All @@ -113,9 +119,6 @@ RUN git clone --single-branch --branch ${ONNXRUNTIME_BRANCH} --recursive ${ONNXR

ADD tools/build_and_test_onnxrt.sh /onnxruntime/build_and_test_onnxrt.sh

# Use the /opt/cmake install because LLVM/MLIR need cmake >= 3.20
RUN env PATH=/opt/cmake/bin:$PATH cget -p /usr/local install ROCmSoftwarePlatform/rocMLIR@1ad9d6df32acc6d29d58e8ed6710e36746d0a4d6 -DBUILD_FAT_LIBROCKCOMPILER=On

ENV MIOPEN_FIND_DB_PATH=/tmp/miopen/find-db
ENV MIOPEN_USER_DB_PATH=/tmp/miopen/user-db
ENV LD_LIBRARY_PATH=$PREFIX/lib
Expand Down
8 changes: 6 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def rocmtestnode(Map conf) {
rm -rf build
mkdir build
cd build
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_DEV=On ${flags} ..
cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_DEV=On -DCMAKE_EXECUTE_PROCESS_COMMAND_ECHO=STDOUT ${flags} ..
git diff
git diff-index --quiet HEAD || (echo "Git repo is not clean after running cmake." && exit 1)
make -j\$(nproc) generate VERBOSE=1
Expand Down Expand Up @@ -90,7 +90,7 @@ def rocmnodename(name) {
} else if(name == "mi100+") {
node_name = "${rocmtest_name} && (gfx908 || gfx90a) && !vm";
} else if(name == "cdna") {
node_name = "${rocmtest_name} && (gfx908 || gfx90a || vega) && !vm";
node_name = "${rocmtest_name} && (gfx908 || gfx90a || vega20) && !vm";
} else if(name == "nogpu") {
node_name = "${rocmtest_name} && nogpu";
}
Expand All @@ -114,6 +114,10 @@ rocmtest clang_debug: rocmnode('cdna') { cmake_build ->
cmake_build(flags: "-DCMAKE_BUILD_TYPE=release")
stash includes: 'build/*.deb', name: 'migraphx-package'
}
// }, hidden_symbols: rocmnode('cdna') { cmake_build ->
// 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")
// }
}, all_targets_debug : rocmnode('cdna') { cmake_build ->
stage('All targets Release') {
cmake_build(flags: "-DCMAKE_BUILD_TYPE=release -DMIGRAPHX_ENABLE_GPU=On -DMIGRAPHX_ENABLE_CPU=On -DMIGRAPHX_ENABLE_FPGA=On")
Expand Down
48 changes: 32 additions & 16 deletions cmake/Embed.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
find_program(EMBED_LD ld)
find_program(EMBED_OBJCOPY objcopy)

if(LINUX)
option(EMBED_USE_LD "Use ld to embed data files" ON)
else()
option(EMBED_USE_LD "Use ld to embed data files" OFF)
endif()
option(EMBED_USE_LD "Use ld to embed data files" OFF)

function(wrap_string)
set(options)
Expand Down Expand Up @@ -60,8 +56,8 @@ endfunction()

function(generate_embed_source EMBED_NAME)
set(options)
set(oneValueArgs SRC HEADER)
set(multiValueArgs OBJECTS SYMBOLS)
set(oneValueArgs SRC HEADER RELATIVE)
set(multiValueArgs OBJECTS SYMBOLS FILES)

cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

Expand All @@ -78,6 +74,8 @@ function(generate_embed_source EMBED_NAME)
foreach(idx RANGE ${LEN})
list(GET PARSE_SYMBOLS ${idx} SYMBOL)
list(GET PARSE_OBJECTS ${idx} OBJECT)
list(GET PARSE_FILES ${idx} FILE)

set(START_SYMBOL "_binary_${SYMBOL}_start")
set(END_SYMBOL "_binary_${SYMBOL}_end")
if(EMBED_USE_LD)
Expand All @@ -92,9 +90,11 @@ function(generate_embed_source EMBED_NAME)
")
endif()

# TODO: Should use NAME_WLE
get_filename_component(BASE_NAME "${OBJECT}" NAME)
string(REGEX REPLACE ".[A-Za-z0-9_]+$" "" BASE_NAME ${BASE_NAME})
if(PARSE_RELATIVE)
file(RELATIVE_PATH BASE_NAME ${PARSE_RELATIVE} "${FILE}")
else()
get_filename_component(BASE_NAME "${FILE}" NAME)
endif()

string(APPEND INIT_KERNELS "
{ \"${BASE_NAME}\", { ${START_SYMBOL}, ${END_SYMBOL}} },
Expand Down Expand Up @@ -162,6 +162,11 @@ function(embed_file OUTPUT_FILE OUTPUT_SYMBOL FILE)
endfunction()

function(add_embed_library EMBED_NAME)
set(options)
set(oneValueArgs RELATIVE)
set(multiValueArgs)
cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/embed)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/embed/${EMBED_NAME})
set(EMBED_DIR ${CMAKE_CURRENT_BINARY_DIR}/embed/${EMBED_NAME})
Expand All @@ -171,15 +176,26 @@ function(add_embed_library EMBED_NAME)
set(OUTPUT_FILES)
set(SYMBOLS)
message(STATUS "Embedding files")
foreach(FILE ${ARGN})
foreach(FILE ${PARSE_UNPARSED_ARGUMENTS})
embed_file(OUTPUT_FILE OUTPUT_SYMBOL ${FILE})
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})
add_library(${EMBED_NAME} STATIC ${OUTPUT_FILES} "${SRC_FILE}")
target_include_directories(${EMBED_NAME} PUBLIC "${EMBED_DIR}/include")
target_compile_options(${EMBED_NAME} PRIVATE -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 ${SRC_FILE} HEADER ${HEADER_FILE} OBJECTS ${OUTPUT_FILES} SYMBOLS ${SYMBOLS} RELATIVE ${PARSE_RELATIVE} FILES ${PARSE_UNPARSED_ARGUMENTS})

set(INTERNAL_EMBED_LIB embed_lib_${EMBED_NAME})
add_library(${INTERNAL_EMBED_LIB} OBJECT "${SRC_FILE}")
target_include_directories(${INTERNAL_EMBED_LIB} PRIVATE "${EMBED_DIR}/include")
target_compile_options(${INTERNAL_EMBED_LIB} PRIVATE -Wno-reserved-identifier -Wno-extern-initializer -Wno-missing-variable-declarations)
set_target_properties(${INTERNAL_EMBED_LIB} PROPERTIES POSITION_INDEPENDENT_CODE On)

add_library(${EMBED_NAME} INTERFACE)
if(EMBED_USE_LD)
target_sources(${EMBED_NAME} INTERFACE ${OUTPUT_FILES})
else()
target_sources(${INTERNAL_EMBED_LIB} PRIVATE ${OUTPUT_FILES})
endif()
target_sources(${EMBED_NAME} INTERFACE $<TARGET_OBJECTS:${INTERNAL_EMBED_LIB}>)
target_include_directories(${EMBED_NAME} INTERFACE "${EMBED_DIR}/include")
endfunction()
5 changes: 4 additions & 1 deletion cmake/ExportHeader.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ endif()
include(GenerateExportHeader)

function(migraphx_generate_export_header TARGET)
cmake_parse_arguments(PARSE "" "DIRECTORY" "" ${ARGN})
set(options)
set(oneValueArgs DIRECTORY)
set(multiValueArgs)
cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(PARSE_DIRECTORY)
set(__directory ${PARSE_DIRECTORY})
else()
Expand Down
Loading

0 comments on commit 2d2ea3f

Please sign in to comment.