Commit 4a39a0f7 authored by Shucai Xiao's avatar Shucai Xiao
Browse files

Merge branch 'develop' of github.com:ROCmSoftwarePlatform/AMDMIGraphX into add-conv_bn_add-test

parents 5564172e bb827865
......@@ -4,9 +4,7 @@ CheckOptions:
- key: bugprone-unused-return-value.CheckedFunctions
value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::find;::std::find_if;::std::find_if_not;::std::all_of;::std::any_of;::std::none_of;::std::count;::std::count_if;::std::mismatch;::std::find_end;::std::find_first_of;::std::adjacent_find;::std::search;::std::search_n;::std::nth_element;::std::lower_bound;::std::upper_bound;::std::binary_search;::std::equal_range;::std::max;::std::max_element;::std::min;::std::min_element;::std::minmax;::std::minmax_element;::std::equal;::std::lexicographical_compare;::std::accumulate;::std::inner_product'
- key: cppcoreguidelines-macro-usage.AllowedRegexp
value: 'DEBUG|FALLTHROUGH|STRINGIZE|_HAS_|_THROW|_REQUIRES|_DECLARE_|_VISIT_|_REGISTER_|_GENERATE_|_DETAIL_|_TIDY_|_MANAGE_PTR|_MATCHER|DEVICE_SHARED'
- key: cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion
value: 0
value: 'DEBUG|FALLTHROUGH|STRINGIZE|_HAS_|_THROW|_REQUIRES|_DECLARE_|_VISIT_|_REGISTER_|_GENERATE_|_DETAIL_|_TIDY_|_MANAGE_PTR|_MATCHER|DEVICE_SHARED|_WORKAROUND_'
- key: modernize-loop-convert.MinConfidence
value: risky
- key: modernize-loop-convert.NamingStyle
......@@ -111,7 +109,7 @@ CheckOptions:
value: CamelCase
- key: readability-identifier-naming.TypeAliasCase
value: lower_case
# - key: readability-identifier-naming.MacroDefinitionCase
# value: UPPER_CASE
# - key: readability-identifier-naming.MacroDefinitionPrefix
# value: MIGRAPHX_
- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
- key: readability-identifier-naming.MacroDefinitionPrefix
value: MIGRAPHX_
......@@ -131,6 +131,22 @@ jobs:
find . -iname '*.py' \
| grep -v 'build/' \
| xargs -n 1 -P 1 -I{} -t sh -c 'yapf {} | diff - {}'
pyflakes:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install pyflakes
run: pip install pyflakes==2.3.1
- name: Run pyflakes
run: pyflakes examples/ tools/ src/ test/ doc/
linux:
runs-on: ${{ matrix.os }}
......@@ -145,8 +161,8 @@ jobs:
strategy:
matrix:
os:
- ubuntu-16.04
- ubuntu-18.04
- ubuntu-20.04
configuration:
- debug
- release
......@@ -166,19 +182,16 @@ 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-2-${{ hashFiles('requirements.txt') }}
key:
${{ matrix.os }}-cget-4-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}
${{ matrix.os }}-cget-4-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install cget
cget install pfultz2/rocm-recipes
cget ignore ROCmSoftwarePlatform/rocBLAS ROCmSoftwarePlatform/MIOpen
cget install -f requirements.txt
cget install oneapi-src/oneDNN@v1.7
cget install facebook/zstd@v1.4.5 -X subdir -DCMAKE_DIR=build/cmake
cget install ccache@v4.1
pip install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
rbuild prepare -d cget -s gh
- name: Prepare timestamp
id: cache_timestamp
shell: cmake -P {0}
......@@ -205,19 +218,13 @@ jobs:
run: |
echo "leak:dnnl::impl::malloc" > suppressions.txt
export LSAN_OPTIONS="suppressions=$(pwd)/suppressions.txt"
mkdir build
cd build
cmake .. \
-DCMAKE_C_COMPILER_LAUNCHER=${{ github.workspace }}/cget/bin/ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ github.workspace }}/cget/bin/ccache \
rbuild build -d cget -s gh -t check \
-DCMAKE_BUILD_TYPE=${{matrix.configuration}} \
-DMIGRAPHX_ENABLE_CPU=On \
-DMIGRAPHX_ENABLE_PYTHON=${{matrix.configuration == 'release' && 'On' || 'Off'}} \
-DCMAKE_CXX_FLAGS_DEBUG="-g1 -Os -fdebug-prefix-map=$PWD=. -fdebug-types-section -fno-omit-frame-pointer ${{matrix.os != 'ubuntu-16.04' && '-fsanitize-address-use-after-scope' || ''}} -fsanitize=undefined,address -fno-sanitize-recover=undefined,address" \
-DCMAKE_CXX_FLAGS_DEBUG="-g1 -Os -fdebug-prefix-map=$PWD=. -fdebug-types-section -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=undefined" \
-DCMAKE_CXX_FLAGS_CODECOV="-g1 -Og -fdebug-prefix-map=$PWD=. -fdebug-types-section -fprofile-arcs -ftest-coverage -fno-omit-frame-pointer" \
-DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=gold' \
-DCMAKE_SHARED_LINKER_FLAGS='-fuse-ld=gold'
make -j2 check
${{ github.workspace }}/cget/bin/ccache -s
- name: Upload code coverage
......
......@@ -36,7 +36,7 @@ find_package(nlohmann_json 3.8.0 REQUIRED)
include(ROCMSetupVersion)
rocm_setup_version(VERSION 1.1)
rocm_setup_version(VERSION 1.3)
set(MIGRAPHX_SO_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
option( BUILD_SHARED_LIBS "Build as a shared library" ON )
......@@ -148,6 +148,7 @@ rocm_enable_clang_tidy(
-*-avoid-c-arrays
-*-explicit-constructor
-*-magic-numbers
-*-narrowing-conversions
-*-non-private-member-variables-in-classes
-*-use-auto
-*-use-emplace
......@@ -222,7 +223,7 @@ rocm_create_package(
MAINTAINER "Paul Fultz II <paul.fultz@amd.com>"
LDCONFIG
PTH
DEPENDS miopen-hip rocblas hip-hcc half
DEPENDS miopen-hip rocblas hip-rocclr hip-base half
)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
......
......@@ -6,7 +6,7 @@ ARG PREFIX=/usr/local
RUN dpkg --add-architecture i386
# Add rocm repository
RUN sh -c 'echo deb [arch=amd64 trusted=yes] http://repo.radeon.com/rocm/apt/4.1/ xenial main > /etc/apt/sources.list.d/rocm.list'
RUN sh -c 'echo deb [arch=amd64 trusted=yes] http://repo.radeon.com/rocm/apt/4.2/ xenial main > /etc/apt/sources.list.d/rocm.list'
# Install dependencies
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
......@@ -53,9 +53,11 @@ ENV LANG=C.UTF-8
# Install dependencies
ADD dev-requirements.txt /dev-requirements.txt
ADD requirements.txt /requirements.txt
ADD rbuild.ini /rbuild.ini
COPY ./tools/install_prereqs.sh /
RUN /install_prereqs.sh /usr/local / && rm /install_prereqs.sh
RUN test -f /usr/local/hash || exit 1
# Install yapf
RUN pip3 install yapf==0.28.0
......@@ -95,4 +97,5 @@ ENV LD_LIBRARY_PATH=$PREFIX/lib
# Setup ubsan environment to printstacktrace
ENV UBSAN_OPTIONS=print_stacktrace=1
ENV ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
RUN ln -s /opt/rocm/llvm/bin/llvm-symbolizer /usr/bin/llvm-symbolizer
......@@ -15,11 +15,13 @@ def rocmtestnode(Map conf) {
def cmd = """
env
ulimit -c unlimited
echo "leak:dnnl::impl::malloc" > suppressions.txt
export LSAN_OPTIONS="suppressions=\$(pwd)/suppressions.txt"
rm -rf build
mkdir build
cd build
CXX=${compiler} CXXFLAGS='-Werror -Wno-fallback' cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ${flags} ..
CTEST_PARALLEL_LEVEL=32 make -j\$(nproc) generate all doc package check VERBOSE=1
make -j\$(nproc) generate all doc package check VERBOSE=1
"""
echo cmd
sh cmd
......@@ -73,6 +75,8 @@ def rocmnodename(name) {
node_name = "${rocmtest_name} && fiji";
} else if(name == "vega") {
node_name = "${rocmtest_name} && vega";
} else if(name == "nogpu") {
return rocmtest_name;
}
return node_name
}
......@@ -100,6 +104,12 @@ rocmtest clang_debug: rocmnode('vega') { cmake_build ->
def debug_flags = "-g -O2 -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build("/opt/rocm/llvm/bin/clang++", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_MLIR=On -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
}
}, clang_asan: rocmnode('nogpu') { cmake_build ->
stage('Clang ASAN') {
def sanitizers = "undefined,address"
def debug_flags = "-g -O2 -fno-omit-frame-pointer -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build("/opt/rocm/llvm/bin/clang++", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DMIGRAPHX_ENABLE_GPU=Off -DMIGRAPHX_ENABLE_CPU=On -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
}
}
def onnxnode(name, body) {
......@@ -114,8 +124,9 @@ def onnxnode(name, body) {
rocmtest onnx: onnxnode('rocmtest') { cmake_build ->
stage("Onnx runtime") {
sh '''
apt install half
ls -lR
dpkg -i --force-depends ./build/*.deb
dpkg -i ./build/*.deb
cd /onnxruntime && ./build_and_test_onnxrt.sh
'''
}
......
......@@ -2,27 +2,36 @@ if(COMMAND find_python)
return()
endif()
macro(py_exec)
execute_process(${ARGN} RESULT_VARIABLE RESULT)
if(NOT RESULT EQUAL 0)
message(FATAL_ERROR "Process failed: ${ARGN}")
endif()
endmacro()
set(PYBIND11_NOPYTHON On)
find_package(pybind11 REQUIRED)
macro(find_python version)
find_program(PYTHON_CONFIG_${version} python${version}-config)
if(EXISTS ${PYTHON_CONFIG_${version}})
execute_process(COMMAND ${PYTHON_CONFIG_${version}} --includes OUTPUT_VARIABLE _python_include_args)
py_exec(COMMAND ${PYTHON_CONFIG_${version}} --includes OUTPUT_VARIABLE _python_include_args)
separate_arguments(_python_includes UNIX_COMMAND "${_python_include_args}")
string(REPLACE "-I" "" _python_includes "${_python_includes}")
add_library(python${version}::headers INTERFACE IMPORTED GLOBAL)
set_target_properties(python${version}::headers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_python_includes}"
)
execute_process(COMMAND ${PYTHON_CONFIG_${version}} --prefix OUTPUT_VARIABLE _python_prefix)
py_exec(COMMAND ${PYTHON_CONFIG_${version}} --prefix OUTPUT_VARIABLE _python_prefix)
string(STRIP "${_python_prefix}" _python_prefix)
set(PYTHON_${version}_EXECUTABLE "${_python_prefix}/bin/python${version}" CACHE PATH "")
endif()
endmacro()
function(py_extension name version)
set(_python_module_extension)
execute_process(COMMAND ${PYTHON_CONFIG_${version}} --extension-suffix OUTPUT_VARIABLE _python_module_extension)
string(STRIP "${_python_module_extension}" _python_module_extension)
set(_python_module_extension ".so")
if(version VERSION_GREATER_EQUAL 3.0)
py_exec(COMMAND ${PYTHON_CONFIG_${version}} --extension-suffix OUTPUT_VARIABLE _python_module_extension)
string(STRIP "${_python_module_extension}" _python_module_extension)
endif()
set_target_properties(${name} PROPERTIES PREFIX "" SUFFIX "${_python_module_extension}")
endfunction()
function(py_add_module NAME)
......
# AMD MIGraphX Examples
## Description
This directory contains examples of common use cases for MIGraphX.
This directory contains examples of common use cases for MIGraphX.
## Examples:
- [C++ Parse, Load, and Save Graph Programs](./cpp_parse_load_save)
- [C++ MNIST Inference](./cpp_api_inference)
- [Exporting Frozen Graphs in TF1](./export_frozen_graph_tf1)
- [Exporting Frozen Graphs in TF2](./export_frozen_graph_tf2)
- [MIGraphX Docker Container](./migraphx_docker)
- [MIGraphX Driver](./migraphx_driver)
- [Python Resnet50 Inference](./python_api_inference)
- [Python BERT SQuAD Inference](./python_bert_squad_example)
- [Python Super Resolution](./python_super_resolution)
\ No newline at end of file
- [MIGraphX usage and utilities](./migraphx)
- [Vision inference examples](./vision)
- [Natural language inference examples](./nlp)
\ No newline at end of file
# AMD MIGraphX usage and utilities
- [C++ Parse, Load, and Save Graph Programs](./cpp_parse_load_save)
- [Exporting Frozen Graphs in TF1](./export_frozen_graph_tf1)
- [Exporting Frozen Graphs in TF2](./export_frozen_graph_tf2)
- [MIGraphX Docker Container](./migraphx_docker)
- [MIGraphX Driver](./migraphx_driver)
\ No newline at end of file
......@@ -25,8 +25,8 @@ migraphx::save(p, output_file);
```
migraphx::program p = ... <migraphx::program>;
migraphx_file_options options;
options.format = "msgpack";
migraphx::file_options options;
options.set_file_format("msgpack");
migraphx::save(p, output_file, options);
```
......@@ -41,15 +41,15 @@ p = migraphx::load(input_file);
```
migraphx::program p;
migraphx_file_options options;
options.format = "msgpack";
migraphx::file_options options;
options.set_file_format("msgpack");
p = migraphx::load(input_file, options);
```
To load a program that has been saved in JSON format:
```
migraphx::program p;
migraphx_file_options options;
options.format = "json";
migraphx::file_options options;
options.set_file_format("json");
p = migraphx::load(input_file, options);
```
......
......@@ -44,15 +44,15 @@ int main(int argc, char** argv)
std::string format = load_arg;
if(format == "json")
{
migraphx_file_options options;
options.format = "json";
p = migraphx::load(input_file, options);
migraphx::file_options options;
options.set_file_format("json");
p = migraphx::load(input_file, options);
}
else if(format == "msgpack")
{
migraphx_file_options options;
options.format = "msgpack";
p = migraphx::load(input_file, options);
migraphx::file_options options;
options.set_file_format("msgpack");
p = migraphx::load(input_file, options);
}
else
p = migraphx::load(input_file);
......@@ -80,8 +80,8 @@ int main(int argc, char** argv)
output_file = save_arg == nullptr ? "out" : save_arg;
output_file.append(".msgpack");
migraphx_file_options options;
options.format = "msgpack";
migraphx::file_options options;
options.set_file_format("msgpack");
migraphx::save(p, output_file.c_str(), options);
std::cout << "Program has been saved as ./" << output_file << std::endl;
}
......
......@@ -148,13 +148,6 @@
"\n",
"print(process.stdout)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......@@ -172,8 +165,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
......
# Natural Language Processing Inference Examples
- [Python BERT-SQuAD](./python_bert_squad)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment