Commit bc5d7f75 authored by Paul's avatar Paul
Browse files

Merge from develop

parents 47c0854d a5b0afa0
CheckOptions: CheckOptions:
- key: bugprone-unused-return-value.CheckedFunctions - 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' 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|_THROW|_REQUIRES|_DECLARE_|_VISIT_|_GENERATE_|_DETAIL_|_MANAGE_PTR|_MATCHER|DEVICE_SHARED'
- key: modernize-loop-convert.MinConfidence - key: modernize-loop-convert.MinConfidence
value: risky value: risky
- key: modernize-loop-convert.NamingStyle - key: modernize-loop-convert.NamingStyle
value: lower_case value: lower_case
- key: performance-unnecessary-copy-initialization.AllowedTypes
value: 'shape'
- key: performance-unnecessary-value-param.AllowedTypes
value: 'shape'
- key: readability-function-size.BranchThreshold - key: readability-function-size.BranchThreshold
value: '15' value: '15'
- key: readability-function-size.LineThreshold - key: readability-function-size.LineThreshold
...@@ -104,4 +110,4 @@ CheckOptions: ...@@ -104,4 +110,4 @@ CheckOptions:
# - key: readability-identifier-naming.MacroDefinitionCase # - key: readability-identifier-naming.MacroDefinitionCase
# value: UPPER_CASE # value: UPPER_CASE
# - key: readability-identifier-naming.MacroDefinitionPrefix # - key: readability-identifier-naming.MacroDefinitionPrefix
# value: MIGRAPH_ # value: MIGRAPHX_
...@@ -17,7 +17,7 @@ else() ...@@ -17,7 +17,7 @@ else()
set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "") set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "")
endif() endif()
project(migraph) project(migraphx)
find_package(ROCM REQUIRED) find_package(ROCM REQUIRED)
include(ROCMSetupVersion) include(ROCMSetupVersion)
...@@ -34,9 +34,9 @@ endif() ...@@ -34,9 +34,9 @@ endif()
if(CMAKE_CXX_COMPILER MATCHES ".*hcc") if(CMAKE_CXX_COMPILER MATCHES ".*hcc")
message(STATUS "Enable miopen backend") message(STATUS "Enable miopen backend")
set(MIGRAPH_ENABLE_GPU On CACHE BOOL "") set(MIGRAPHX_ENABLE_GPU On CACHE BOOL "")
else() else()
set(MIGRAPH_ENABLE_GPU Off CACHE BOOL "") set(MIGRAPHX_ENABLE_GPU Off CACHE BOOL "")
endif() endif()
add_compile_options(-std=c++14) add_compile_options(-std=c++14)
...@@ -52,6 +52,7 @@ rocm_enable_clang_tidy( ...@@ -52,6 +52,7 @@ rocm_enable_clang_tidy(
-clang-analyzer-optin.performance.Padding -clang-analyzer-optin.performance.Padding
-clang-diagnostic-deprecated-declarations -clang-diagnostic-deprecated-declarations
-clang-diagnostic-extern-c-compat -clang-diagnostic-extern-c-compat
-clang-diagnostic-disabled-macro-expansion
-clang-diagnostic-unused-command-line-argument -clang-diagnostic-unused-command-line-argument
-cppcoreguidelines-pro-bounds-array-to-pointer-decay -cppcoreguidelines-pro-bounds-array-to-pointer-decay
-cppcoreguidelines-pro-bounds-constant-array-index -cppcoreguidelines-pro-bounds-constant-array-index
...@@ -70,13 +71,12 @@ rocm_enable_clang_tidy( ...@@ -70,13 +71,12 @@ rocm_enable_clang_tidy(
-hicpp-explicit-conversions -hicpp-explicit-conversions
-hicpp-no-array-decay -hicpp-no-array-decay
-hicpp-special-member-functions -hicpp-special-member-functions
-hicpp-uppercase-literal-suffix
-hicpp-use-override -hicpp-use-override
# This check is broken # This check is broken
-hicpp-use-auto
-llvm-header-guard -llvm-header-guard
-llvm-include-order -llvm-include-order
-misc-macro-parentheses -misc-macro-parentheses
-modernize-use-auto
-modernize-use-override -modernize-use-override
-modernize-pass-by-value -modernize-pass-by-value
-modernize-use-default-member-init -modernize-use-default-member-init
...@@ -84,7 +84,12 @@ rocm_enable_clang_tidy( ...@@ -84,7 +84,12 @@ rocm_enable_clang_tidy(
-readability-braces-around-statements -readability-braces-around-statements
-readability-else-after-return -readability-else-after-return
-readability-named-parameter -readability-named-parameter
-readability-uppercase-literal-suffix,
-*-avoid-c-arrays
-*-explicit-constructor -*-explicit-constructor
-*-magic-numbers
-*-non-private-member-variables-in-classes
-*-use-auto
-*-use-emplace -*-use-emplace
-*-use-equals-default -*-use-equals-default
ERRORS ERRORS
...@@ -93,7 +98,8 @@ rocm_enable_clang_tidy( ...@@ -93,7 +98,8 @@ rocm_enable_clang_tidy(
HEADER_FILTER HEADER_FILTER
".*hpp" ".*hpp"
EXTRA_ARGS EXTRA_ARGS
-DMIGRAPH_USE_CLANG_TIDY -DMIGRAPHX_USE_CLANG_TIDY
"-Dmain\\\\(...\\\\)=main\\\\(__VA_ARGS__\\\\) // NOLINT"
) )
include(ROCMCppCheck) include(ROCMCppCheck)
...@@ -111,7 +117,9 @@ rocm_enable_cppcheck( ...@@ -111,7 +117,9 @@ rocm_enable_cppcheck(
passedByValue passedByValue
unusedStructMember unusedStructMember
functionStatic functionStatic
functionConst functionConst:*program.*
shadowFunction
shadowVar
definePrefix:*test/include/test.hpp definePrefix:*test/include/test.hpp
FORCE FORCE
INCONCLUSIVE INCONCLUSIVE
...@@ -124,6 +132,7 @@ rocm_enable_cppcheck( ...@@ -124,6 +132,7 @@ rocm_enable_cppcheck(
${CMAKE_CURRENT_SOURCE_DIR}/src/include ${CMAKE_CURRENT_SOURCE_DIR}/src/include
${CMAKE_CURRENT_SOURCE_DIR}/src/targets/cpu/include ${CMAKE_CURRENT_SOURCE_DIR}/src/targets/cpu/include
${CMAKE_CURRENT_SOURCE_DIR}/src/targets/miopen/include ${CMAKE_CURRENT_SOURCE_DIR}/src/targets/miopen/include
${CMAKE_CURRENT_SOURCE_DIR}/test/include
DEFINE DEFINE
CPPCHECK=1 CPPCHECK=1
) )
...@@ -132,11 +141,11 @@ enable_testing() ...@@ -132,11 +141,11 @@ enable_testing()
include(ROCMCreatePackage) include(ROCMCreatePackage)
rocm_create_package( rocm_create_package(
NAME MIGraph NAME MIGraphX
DESCRIPTION "AMD's graph optimizer" DESCRIPTION "AMD's graph optimizer"
MAINTAINER "Paul Fultz II <paul.fultz@amd.com>" MAINTAINER "Paul Fultz II <paul.fultz@amd.com>"
LDCONFIG LDCONFIG
DEPENDS miopen-hip rocblas hip_hcc DEPENDS miopen-hip rocblas hip_hcc half
) )
add_subdirectory(src) add_subdirectory(src)
......
...@@ -50,7 +50,7 @@ RUN pip install cget ...@@ -50,7 +50,7 @@ RUN pip install cget
RUN pip install https://github.com/pfultz2/rclone/archive/master.tar.gz RUN pip install https://github.com/pfultz2/rclone/archive/master.tar.gz
# Install hcc # Install hcc
RUN rclone -b sanitizer1 https://github.com/RadeonOpenCompute/hcc.git /hcc RUN rclone -b roc-2.0.x -c 757fb492517b80e7c86338af5fc1a43d63cb25a9 https://github.com/RadeonOpenCompute/hcc.git /hcc
RUN cget -p $PREFIX install hcc,/hcc RUN cget -p $PREFIX install hcc,/hcc
# Use hcc # Use hcc
......
def rocmtestnode(variant, name, body) { def rocmtestnode(variant, name, body) {
def image = 'migraphlib' def image = 'migraphxlib'
def cmake_build = { compiler, flags -> def cmake_build = { compiler, flags ->
def cmd = """ def cmd = """
ulimit -c unlimited ulimit -c unlimited
...@@ -8,10 +8,16 @@ def rocmtestnode(variant, name, body) { ...@@ -8,10 +8,16 @@ def rocmtestnode(variant, name, body) {
mkdir build mkdir build
cd build cd build
CXX=${compiler} CXXFLAGS='-Werror -Wno-fallback' cmake ${flags} .. CXX=${compiler} CXXFLAGS='-Werror -Wno-fallback' cmake ${flags} ..
CTEST_PARALLEL_LEVEL=32 make -j32 all doc check CTEST_PARALLEL_LEVEL=32 make -j32 generate all doc package check
""" """
echo cmd echo cmd
sh cmd sh cmd
if (compiler == "hcc") {
// Only archive from master or develop
if (env.BRANCH_NAME == "develop" || env.BRANCH_NAME == "master") {
archiveArtifacts artifacts: "build/*.deb", allowEmptyArchive: true, fingerprint: true
}
}
} }
node(name) { node(name) {
stage("checkout ${variant}") { stage("checkout ${variant}") {
...@@ -73,7 +79,7 @@ rocmtest tidy: rocmnode('rocmtest') { cmake_build -> ...@@ -73,7 +79,7 @@ rocmtest tidy: rocmnode('rocmtest') { cmake_build ->
rm -rf build rm -rf build
mkdir build mkdir build
cd build cd build
CXX='clang++-5.0' cmake .. CXX=hcc cmake ..
make -j8 -k analyze make -j8 -k analyze
''' '''
} }
...@@ -91,11 +97,12 @@ rocmtest tidy: rocmnode('rocmtest') { cmake_build -> ...@@ -91,11 +97,12 @@ rocmtest tidy: rocmnode('rocmtest') { cmake_build ->
| xargs -n 1 -P 1 -I{} -t sh -c \'clang-format-5.0 -style=file {} | diff - {}\' | xargs -n 1 -P 1 -I{} -t sh -c \'clang-format-5.0 -style=file {} | diff - {}\'
''' '''
} }
}, clang: rocmnode('rocmtest') { cmake_build -> }, clang: rocmnode('vega') { cmake_build ->
stage('Clang Debug') { stage('Clang Debug') {
// TODO: Enanle integer // TODO: Enanle integer
def sanitizers = "undefined" def sanitizers = "undefined"
cmake_build("hcc", "-DCMAKE_BUILD_TYPE=debug -DCMAKE_CXX_FLAGS_DEBUG='-g -fno-omit-frame-pointer -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}'") def debug_flags = "-g -fno-omit-frame-pointer -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build("hcc", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
} }
stage('Clang Release') { stage('Clang Release') {
cmake_build("hcc", "-DCMAKE_BUILD_TYPE=release") cmake_build("hcc", "-DCMAKE_BUILD_TYPE=release")
...@@ -113,6 +120,19 @@ rocmtest tidy: rocmnode('rocmtest') { cmake_build -> ...@@ -113,6 +120,19 @@ rocmtest tidy: rocmnode('rocmtest') { cmake_build ->
def cmake_linker_flags = "-DCMAKE_EXE_LINKER_FLAGS='${linker_flags}' -DCMAKE_SHARED_LINKER_FLAGS='${linker_flags}'" def cmake_linker_flags = "-DCMAKE_EXE_LINKER_FLAGS='${linker_flags}' -DCMAKE_SHARED_LINKER_FLAGS='${linker_flags}'"
// TODO: Add bounds-strict // TODO: Add bounds-strict
def sanitizers = "undefined,address" def sanitizers = "undefined,address"
cmake_build("g++-7", "-DCMAKE_BUILD_TYPE=debug ${cmake_linker_flags} -DCMAKE_CXX_FLAGS_DEBUG='-g -fno-omit-frame-pointer -fsanitize-address-use-after-scope -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}'") def debug_flags = "-g -fprofile-arcs -ftest-coverage -fno-omit-frame-pointer -fsanitize-address-use-after-scope -fsanitize=${sanitizers} -fno-sanitize-recover=${sanitizers}"
cmake_build("g++-7", "-DCMAKE_BUILD_TYPE=debug -DMIGRAPHX_ENABLE_PYTHON=Off ${cmake_linker_flags} -DCMAKE_CXX_FLAGS_DEBUG='${debug_flags}'")
}
stage('Codecov') {
env.CODECOV_TOKEN="8545af1c-f90b-4345-92a5-0d075503ca56"
sh '''
cd build
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
curl -s https://codecov.io/bash | bash
echo "Uploaded"
'''
} }
} }
# MIGraph # AMD MIGraphX
AMD's library for graph optimizations. AMD's graph optimization engine.
## Prerequisites ## Prerequisites
* [ROCm cmake modules](https://github.com/RadeonOpenCompute/rocm-cmake) **required** * [ROCm cmake modules](https://github.com/RadeonOpenCompute/rocm-cmake) **required**
...@@ -8,6 +8,7 @@ AMD's library for graph optimizations. ...@@ -8,6 +8,7 @@ AMD's library for graph optimizations.
* [HIP](https://github.com/ROCm-Developer-Tools/HIP) for running on the GPU * [HIP](https://github.com/ROCm-Developer-Tools/HIP) for running on the GPU
* [Protobuf](https://github.com/google/protobuf) for reading [onxx](https://github.com/onnx/onnx) files * [Protobuf](https://github.com/google/protobuf) for reading [onxx](https://github.com/onnx/onnx) files
* [Half](http://half.sourceforge.net/) - IEEE 754-based half-precision floating point library * [Half](http://half.sourceforge.net/) - IEEE 754-based half-precision floating point library
* [pybind11](https://pybind11.readthedocs.io/en/stable/) - for python bindings
## Installing the dependencies ## Installing the dependencies
...@@ -20,7 +21,7 @@ cmake -P install_deps.cmake --prefix /some/local/dir ...@@ -20,7 +21,7 @@ cmake -P install_deps.cmake --prefix /some/local/dir
``` ```
## Building MIGraph from source ## Building MIGraphX from source
## Configuring with cmake ## Configuring with cmake
...@@ -105,8 +106,8 @@ Also, githooks can be installed to format the code per-commit: ...@@ -105,8 +106,8 @@ Also, githooks can be installed to format the code per-commit:
The easiest way to setup the development environment is to use docker. You can build the top-level docker file: The easiest way to setup the development environment is to use docker. You can build the top-level docker file:
docker build -t migraph . docker build -t migraphx .
Then to enter the developement environment use `docker run`: Then to enter the developement environment use `docker run`:
docker run --device='/dev/kfd' --device='/dev/dri' -v=`pwd`:/data -w /data --group-add video -it migraph docker run --device='/dev/kfd' --device='/dev/dri' -v=`pwd`:/data -w /data --group-add video -it migraphx
ignore:
- "test/"
...@@ -34,11 +34,19 @@ ...@@ -34,11 +34,19 @@
</rule> </rule>
<rule> <rule>
<tokenlist>define</tokenlist> <tokenlist>define</tokenlist>
<pattern>define (MIGRAP|[^H]{6})[^H][^_]</pattern> <pattern>define (MIGRAPH|[^X]{7})[^X][^_]</pattern>
<message> <message>
<id>definePrefix</id> <id>definePrefix</id>
<severity>style</severity> <severity>style</severity>
<summary>Macros must be prefixed with MIGRAPH_</summary> <summary>Macros must be prefixed with MIGRAPHX_</summary>
</message>
</rule>
<rule>
<pattern>mutable \w+</pattern>
<message>
<id>MutableVariable</id>
<severity>style</severity>
<summary>Do not create mutable variables.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
...@@ -74,7 +82,7 @@ ...@@ -74,7 +82,7 @@
</message> </message>
</rule> </rule>
<rule> <rule>
<pattern>(fclose|free|hipFree) \(</pattern> <pattern>\\W(fclose|free|hipFree|hipHostFree|hipFreeArray|hipMemFree|hipStreamDestroy|hipEventDestroy|hipArrayDestroy|hipCtxDestroy|hipDestroyTextureObject|hipDestroySurfaceObject) \(</pattern>
<message> <message>
<id>useManagePointer</id> <id>useManagePointer</id>
<severity>style</severity> <severity>style</severity>
......
pfultz2/rocm-recipes pfultz2/rocm-recipes
pcre danmar/cppcheck@681cb7dd909d1bfe41796b7616e43265177b9464 -DHAVE_RULES=1
danmar/cppcheck@f965e5873 -DHAVE_RULES=1 ROCm-Developer-Tools/HIP@fc22ef991ce7cb15821c8ccb4f03cdfc3e7e43cf
ROCm-Developer-Tools/HIP@3a41f286203968421c557338d6fb39c36f3c717c python/cpython@v3.6.6 -X autotools -H sha256:92aa914572c695c0aeb01b0a214813f414da4b51a371234df514a74761f2bb36
# python/cpython@v3.6.6 -X autotools -H sha256:92aa914572c695c0aeb01b0a214813f414da4b51a371234df514a74761f2bb36
-f requirements.txt -f requirements.txt
...@@ -19,7 +19,7 @@ add_doxygen_doc( ...@@ -19,7 +19,7 @@ add_doxygen_doc(
CALL_GRAPH YES CALL_GRAPH YES
CALLER_GRAPH YES CALLER_GRAPH YES
BUILTIN_STL_SUPPORT YES BUILTIN_STL_SUPPORT YES
PROJECT_NAME MIGraph PROJECT_NAME MIGraphX
SORT_MEMBERS_CTORS_1ST YES SORT_MEMBERS_CTORS_1ST YES
SOURCE_BROWSER YES SOURCE_BROWSER YES
GENERATE_TREEVIEW YES GENERATE_TREEVIEW YES
...@@ -32,7 +32,7 @@ add_doxygen_doc( ...@@ -32,7 +32,7 @@ add_doxygen_doc(
PREDEFINED DOXYGEN PREDEFINED DOXYGEN
) )
add_custom_target(remove_inline_ns add_custom_target(remove_inline_ns
sed -i "s/MIGRAPH_INLINE_NS:://g" *.xml sed -i "s/MIGRAPHX_INLINE_NS:://g" *.xml
WORKING_DIRECTORY ${DOXYGEN_OUTPUT}/xml) WORKING_DIRECTORY ${DOXYGEN_OUTPUT}/xml)
add_dependencies(remove_inline_ns doxygen) add_dependencies(remove_inline_ns doxygen)
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# MIGraph documentation build configuration file, created by # MIGraphX documentation build configuration file, created by
# sphinx-quickstart on Thu Jul 19 11:38:13 2018. # sphinx-quickstart on Thu Jul 19 11:38:13 2018.
# #
# This file is execfile()d with the current directory set to its # This file is execfile()d with the current directory set to its
...@@ -45,7 +45,7 @@ source_suffix = '.rst' ...@@ -45,7 +45,7 @@ source_suffix = '.rst'
master_doc = 'index' master_doc = 'index'
# General information about the project. # General information about the project.
project = u'MIGraph' project = u'MIGraphX'
copyright = u'2018, AMD' copyright = u'2018, AMD'
author = u'AMD' author = u'AMD'
...@@ -101,7 +101,7 @@ html_static_path = ['_static'] ...@@ -101,7 +101,7 @@ html_static_path = ['_static']
# -- Options for HTMLHelp output ------------------------------------------ # -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'MIGraphdoc' htmlhelp_basename = 'MIGraphXdoc'
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
...@@ -128,7 +128,7 @@ latex_elements = { ...@@ -128,7 +128,7 @@ latex_elements = {
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
(master_doc, 'MIGraph.tex', u'MIGraph Documentation', (master_doc, 'MIGraphX.tex', u'MIGraphX Documentation',
u'AMD', 'manual'), u'AMD', 'manual'),
] ]
...@@ -138,7 +138,7 @@ latex_documents = [ ...@@ -138,7 +138,7 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
(master_doc, 'migraph', u'MIGraph Documentation', (master_doc, 'migraphx', u'MIGraphX Documentation',
[author], 1) [author], 1)
] ]
...@@ -149,13 +149,13 @@ man_pages = [ ...@@ -149,13 +149,13 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'MIGraph', u'MIGraph Documentation', (master_doc, 'MIGraphX', u'MIGraphX Documentation',
author, 'MIGraph', 'One line description of project.', author, 'MIGraphX', 'One line description of project.',
'Miscellaneous'), 'Miscellaneous'),
] ]
breathe_default_members = ('members', 'undoc-members') breathe_default_members = ('members', 'undoc-members')
cpp_index_common_prefix = ['migraph::'] cpp_index_common_prefix = ['migraphx::']
default_role = 'any' default_role = 'any'
primary_domain = 'cpp' primary_domain = 'cpp'
......
.. MIGraph documentation master file, created by .. MIGraphX documentation master file, created by
sphinx-quickstart on Thu Jul 19 11:38:13 2018. sphinx-quickstart on Thu Jul 19 11:38:13 2018.
You can adapt this file completely to your liking, but it should at least You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive. contain the root `toctree` directive.
Welcome to MIGraph's documentation! Welcome to AMD MIGraphX's documentation!
=================================== ========================================
.. toctree:: .. toctree::
:maxdepth: 3 :maxdepth: 3
......
Overview Overview
======== ========
MIGraph provides an optimized execution engine for deep learning neural networks. MIGraphX provides an optimized execution engine for deep learning neural networks.
Building a program Building a program
------------------ ------------------
A program consists of a set of instructions to be executed when calling `eval <migraph::program::eval>`. Each instruction has an associated `operation <migraph::operation>` which represents the computation to be performed by the instruction. A program consists of a set of instructions to be executed when calling `eval <migraphx::program::eval>`. Each instruction has an associated `operation <migraphx::operation>` which represents the computation to be performed by the instruction.
We can start by building a simple program to add two numbers together:: We can start by building a simple program to add two numbers together::
...@@ -15,11 +15,11 @@ We can start by building a simple program to add two numbers together:: ...@@ -15,11 +15,11 @@ We can start by building a simple program to add two numbers together::
instruction_ref two = p.add_literal(2); instruction_ref two = p.add_literal(2);
p.add_instruction(add{}, one, two); p.add_instruction(add{}, one, two);
The `add_literal <migraph::program::add_literal>` function will add an instruction to the program to store a literal number. The `instruction_ref <migraph::instruction_ref>` is a reference to the instruction in the program, which can be used to compose the output of the instruction with another instruction. The `add_literal <migraphx::program::add_literal>` function will add an instruction to the program to store a literal number. The `instruction_ref <migraphx::instruction_ref>` is a reference to the instruction in the program, which can be used to compose the output of the instruction with another instruction.
After creating the literals, we then create the instruction to add the numbers together. This is done by using the `add{} <migraph::add>` operation class along with the `instruction_ref <migraph::instruction_ref>` for the input arguments of the instruction. After creating the literals, we then create the instruction to add the numbers together. This is done by using the `add{} <migraphx::add>` operation class along with the `instruction_ref <migraphx::instruction_ref>` for the input arguments of the instruction.
Finally, we can run this `program <migraph::program>` by compiling it for the cpu and then running it with `eval <migraph::program::eval>`:: Finally, we can run this `program <migraphx::program>` by compiling it for the cpu and then running it with `eval <migraphx::program::eval>`::
p.compile(cpu::target{}); p.compile(cpu::target{});
argument result = p.eval({}); argument result = p.eval({});
...@@ -43,7 +43,7 @@ Of course, this program will always produce the same value which is quite uninte ...@@ -43,7 +43,7 @@ Of course, this program will always produce the same value which is quite uninte
p.add_instruction(add{}, x, two); p.add_instruction(add{}, x, two);
p.compile(cpu::target{}); p.compile(cpu::target{});
This adds a parameter of type ``int64``, and compiles it for the ``cpu``. To run the program, we need to pass the parameter to it when we call `eval <migraph::program::eval>`:: This adds a parameter of type ``int64``, and compiles it for the ``cpu``. To run the program, we need to pass the parameter to it when we call `eval <migraphx::program::eval>`::
argument result = p.eval({ argument result = p.eval({
{"x", literal{1}.get_argument()} {"x", literal{1}.get_argument()}
...@@ -52,12 +52,12 @@ This adds a parameter of type ``int64``, and compiles it for the ``cpu``. To run ...@@ -52,12 +52,12 @@ This adds a parameter of type ``int64``, and compiles it for the ``cpu``. To run
This will print ``3``. This will print ``3``.
A parameter is given as an `argument <migraph::argument>`. In this case, the simplest way of creating an `argument <migraph::argument>` is from a `literal <migraph::literal>`. A parameter is given as an `argument <migraphx::argument>`. In this case, the simplest way of creating an `argument <migraphx::argument>` is from a `literal <migraphx::literal>`.
Tensor data Tensor data
----------- -----------
In this example we are just creating numbers, but the `shape <migraph::shape>` class can describe multi-dimensional tensors. For example, we can build a simple network with convolution and relu:: In this example we are just creating numbers, but the `shape <migraphx::shape>` class can describe multi-dimensional tensors. For example, we can build a simple network with convolution and relu::
program p; program p;
instruction_ref input = p.add_parameter("x", shape{shape::float_type, {1, 3, 32, 32}}); instruction_ref input = p.add_parameter("x", shape{shape::float_type, {1, 3, 32, 32}});
...@@ -65,7 +65,7 @@ In this example we are just creating numbers, but the `shape <migraph::shape>` c ...@@ -65,7 +65,7 @@ In this example we are just creating numbers, but the `shape <migraph::shape>` c
instruction_ref conv = p.add_instruction(convolution{}, input, weights); instruction_ref conv = p.add_instruction(convolution{}, input, weights);
p.add_instruction(activation{"relu"}, conv); p.add_instruction(activation{"relu"}, conv);
Here we create two parameters for both the ``input`` and ``weights``. In the previous examples, we just created simple literals, however, most programs will take data from already allocated buffers(usually on the GPU). In this case, we can create `argument <migraph::argument>` objects directly from the pointers to the buffers:: Here we create two parameters for both the ``input`` and ``weights``. In the previous examples, we just created simple literals, however, most programs will take data from already allocated buffers(usually on the GPU). In this case, we can create `argument <migraphx::argument>` objects directly from the pointers to the buffers::
// Compile the program // Compile the program
p.compile(gpu::target{}); p.compile(gpu::target{});
...@@ -77,12 +77,12 @@ Here we create two parameters for both the ``input`` and ``weights``. In the pre ...@@ -77,12 +77,12 @@ Here we create two parameters for both the ``input`` and ``weights``. In the pre
argument weights_arg{shape{shape::float_type, {1, 3, 32, 32}}, weights}; argument weights_arg{shape{shape::float_type, {1, 3, 32, 32}}, weights};
p.eval({{"x", input_arg}, {"w", weights_arg}}) p.eval({{"x", input_arg}, {"w", weights_arg}})
An `argument <migraph::argument>` can handle memory buffers from either the GPU or the CPU, but when running the `program <migraph::program>`, buffers should be allocated for the corresponding target. That is, when compiling for the CPU, the buffers should be allocated on the CPU, and when compiling for the GPU the buffers should be allocated on the GPU. An `argument <migraphx::argument>` can handle memory buffers from either the GPU or the CPU, but when running the `program <migraphx::program>`, buffers should be allocated for the corresponding target. That is, when compiling for the CPU, the buffers should be allocated on the CPU, and when compiling for the GPU the buffers should be allocated on the GPU.
Importing from onnx Importing from onnx
------------------- -------------------
A `program <migraph::program>` can be built directly from an onnx file, which makes it easier to use neural networks directly from other frameworks. In this case, there is an ``parse_onnx`` function:: A `program <migraphx::program>` can be built directly from an onnx file, which makes it easier to use neural networks directly from other frameworks. In this case, there is an ``parse_onnx`` function::
program p = parse_onnx("model.onnx"); program p = parse_onnx("model.onnx");
p.compile(gpu::target{}); p.compile(gpu::target{});
......
...@@ -4,27 +4,27 @@ Data types ...@@ -4,27 +4,27 @@ Data types
shape shape
----- -----
.. doxygenstruct:: migraph::shape .. doxygenstruct:: migraphx::shape
literal literal
------- -------
.. doxygenstruct:: migraph::literal .. doxygenstruct:: migraphx::literal
argument argument
-------- --------
.. doxygenstruct:: migraph::argument .. doxygenstruct:: migraphx::argument
raw_data raw_data
-------- --------
.. doxygenstruct:: migraph::raw_data .. doxygenstruct:: migraphx::raw_data
.. doxygenfunction:: migraph::MIGRAPH_INLINE_NS::visit_all .. doxygenfunction:: migraphx::MIGRAPHX_INLINE_NS::visit_all
tensor_view tensor_view
----------- -----------
.. doxygenstruct:: migraph::tensor_view .. doxygenstruct:: migraphx::tensor_view
...@@ -4,7 +4,7 @@ Operators ...@@ -4,7 +4,7 @@ Operators
operation operation
--------- ---------
.. doxygenstruct:: migraph::operation .. doxygenstruct:: migraphx::operation
operators operators
--------- ---------
......
...@@ -4,44 +4,44 @@ Passes ...@@ -4,44 +4,44 @@ Passes
pass pass
---- ----
.. doxygenstruct:: migraph::pass .. doxygenstruct:: migraphx::pass
dead_code_elimination dead_code_elimination
--------------------- ---------------------
.. doxygenstruct:: migraph::dead_code_elimination .. doxygenstruct:: migraphx::dead_code_elimination
common_subexpression_elimination common_subexpression_elimination
-------------------------------- --------------------------------
.. doxygenstruct:: migraph::common_subexpression_elimination .. doxygenstruct:: migraphx::common_subexpression_elimination
constant_propagate constant_propagate
------------------ ------------------
.. doxygenstruct:: migraph::constant_propagate .. doxygenstruct:: migraphx::constant_propagate
eliminate_concat eliminate_concat
---------------- ----------------
.. doxygenstruct:: migraph::eliminate_concat .. doxygenstruct:: migraphx::eliminate_concat
eliminate_contiguous eliminate_contiguous
-------------------- --------------------
.. doxygenstruct:: migraph::eliminate_contiguous .. doxygenstruct:: migraphx::eliminate_contiguous
fwd_conv_batchnorm_rewrite fwd_conv_batchnorm_rewrite
-------------------------- --------------------------
.. doxygenstruct:: migraph::fwd_conv_batchnorm_rewrite .. doxygenstruct:: migraphx::fwd_conv_batchnorm_rewrite
simplify_algebra simplify_algebra
---------------- ----------------
.. doxygenstruct:: migraph::simplify_algebra .. doxygenstruct:: migraphx::simplify_algebra
simplify_reshapes simplify_reshapes
----------------- -----------------
.. doxygenstruct:: migraph::simplify_reshapes .. doxygenstruct:: migraphx::simplify_reshapes
...@@ -4,21 +4,21 @@ Program ...@@ -4,21 +4,21 @@ Program
instruction instruction
----------- -----------
.. doxygenstruct:: migraph::instruction .. doxygenstruct:: migraphx::instruction
instruction_ref instruction_ref
--------------- ---------------
.. cpp:type:: migraph::instruction_ref .. cpp:type:: migraphx::instruction_ref
References an instruction in the program. References an instruction in the program.
program program
------- -------
.. doxygenstruct:: migraph::program .. doxygenstruct:: migraphx::program
parse_onnx parse_onnx
---------- ----------
.. doxygenfunction:: migraph::MIGRAPH_INLINE_NS::parse_onnx .. doxygenfunction:: migraphx::MIGRAPHX_INLINE_NS::parse_onnx
...@@ -4,15 +4,15 @@ Targets ...@@ -4,15 +4,15 @@ Targets
target target
------ ------
.. doxygenstruct:: migraph::target .. doxygenstruct:: migraphx::target
gpu::target gpu::target
----------- -----------
.. doxygenstruct:: migraph::gpu::target .. doxygenstruct:: migraphx::gpu::target
cpu::target cpu::target
----------- -----------
.. doxygenstruct:: migraph::cpu::target .. doxygenstruct:: migraphx::cpu::target
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
include(ROCMInstallTargets) include(ROCMInstallTargets)
include(ROCMPackageConfigHelpers) include(ROCMPackageConfigHelpers)
add_library(migraph add_library(migraphx
auto_contiguous.cpp auto_contiguous.cpp
common_subexpression_elimination.cpp common_subexpression_elimination.cpp
constant_propagate.cpp constant_propagate.cpp
...@@ -11,6 +11,7 @@ add_library(migraph ...@@ -11,6 +11,7 @@ add_library(migraph
eliminate_contiguous.cpp eliminate_contiguous.cpp
eliminate_concat.cpp eliminate_concat.cpp
fwd_conv_batchnorm_rewrite.cpp fwd_conv_batchnorm_rewrite.cpp
rewrite_rnn.cpp
env.cpp env.cpp
generate.cpp generate.cpp
instruction.cpp instruction.cpp
...@@ -21,29 +22,30 @@ add_library(migraph ...@@ -21,29 +22,30 @@ add_library(migraph
opt/memory_coloring.cpp opt/memory_coloring.cpp
opt/memory_coloring_impl.cpp opt/memory_coloring_impl.cpp
) )
rocm_clang_tidy_check(migraph) rocm_clang_tidy_check(migraphx)
rocm_install_targets( rocm_install_targets(
TARGETS migraph TARGETS migraphx
INCLUDE INCLUDE
${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include
) )
find_path(HALF_INCLUDE_DIR half.hpp) find_path(HALF_INCLUDE_DIR half.hpp)
# TODO: Fix the incorrect path # TODO: Fix the incorrect path
target_include_directories(migraph SYSTEM PUBLIC $<BUILD_INTERFACE:${HALF_INCLUDE_DIR}>) target_include_directories(migraphx SYSTEM PUBLIC $<BUILD_INTERFACE:${HALF_INCLUDE_DIR}>)
set(PACKAGE_DEPENDS) set(PACKAGE_DEPENDS)
add_subdirectory(onnx) add_subdirectory(onnx)
add_subdirectory(py)
add_subdirectory(targets/cpu) add_subdirectory(targets/cpu)
if(MIGRAPH_ENABLE_GPU) if(MIGRAPHX_ENABLE_GPU)
list(APPEND PACKAGE_DEPENDS MIOpen rocblas) list(APPEND PACKAGE_DEPENDS MIOpen rocblas)
add_subdirectory(targets/gpu) add_subdirectory(targets/gpu)
endif() endif()
rocm_export_targets( rocm_export_targets(
TARGETS migraph::migraph TARGETS migraphx::migraphx
NAMESPACE migraph:: NAMESPACE migraphx::
DEPENDS DEPENDS
${PACKAGE_DEPENDS} ${PACKAGE_DEPENDS}
) )
......
#include <migraph/auto_contiguous.hpp> #include <migraphx/auto_contiguous.hpp>
#include <migraph/program.hpp> #include <migraphx/program.hpp>
#include <migraph/instruction.hpp> #include <migraphx/instruction.hpp>
#include <migraph/operators.hpp> #include <migraphx/operators.hpp>
#include <migraph/iterator_for.hpp> #include <migraphx/iterator_for.hpp>
namespace migraph { namespace migraphx {
inline namespace MIGRAPH_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
void auto_contiguous::apply(program& p) const void auto_contiguous::apply(program& p) const
{ {
for(auto ins : iterator_for(p)) for(auto ins : iterator_for(p))
{ {
shape s = ins->get_shape(); shape s = ins->get_shape();
if(not s.standard()) if(not s.standard() and s.elements() != 0)
{ {
auto c = p.insert_instruction(std::next(ins), op::contiguous{}, ins); auto c = p.insert_instruction(std::next(ins), op::contiguous{}, ins);
p.replace_instruction(ins, c); p.replace_instruction(ins, c);
...@@ -20,5 +20,5 @@ void auto_contiguous::apply(program& p) const ...@@ -20,5 +20,5 @@ void auto_contiguous::apply(program& p) const
} }
} }
} // namespace MIGRAPH_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
} // namespace migraph } // namespace migraphx
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