Unverified Commit 628724c7 authored by Paul Fultz II's avatar Paul Fultz II Committed by GitHub
Browse files

Merge branch 'master' into multi_broadcast

parents eab6e97b d9b08400
...@@ -10,9 +10,20 @@ if( NOT MSVC_IDE AND NOT CMAKE_BUILD_TYPE ) ...@@ -10,9 +10,20 @@ if( NOT MSVC_IDE AND NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." ) set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." )
endif() endif()
project(migraphlib) # Default installation path
if(WIN32)
set(CMAKE_INSTALL_PREFIX "/opt/rocm/x86_64-w64-mingw32" CACHE PATH "")
else()
set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "")
endif()
project(migraph)
find_package(ROCM REQUIRED) find_package(ROCM REQUIRED)
include(ROCMSetupVersion)
rocm_setup_version(VERSION 0.1)
option( BUILD_SHARED_LIBS "Build as a shared library" ON ) option( BUILD_SHARED_LIBS "Build as a shared library" ON )
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
...@@ -119,6 +130,15 @@ rocm_enable_cppcheck( ...@@ -119,6 +130,15 @@ rocm_enable_cppcheck(
enable_testing() enable_testing()
include(ROCMCreatePackage)
rocm_create_package(
NAME MIGraph
DESCRIPTION "AMD's graph optimizer"
MAINTAINER "Paul Fultz II <paul.fultz@amd.com>"
LDCONFIG
DEPENDS miopen-hip rocblas hip_hcc
)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(doc) add_subdirectory(doc)
add_subdirectory(test) add_subdirectory(test)
......
...@@ -7,6 +7,7 @@ AMD's library for graph optimizations. ...@@ -7,6 +7,7 @@ AMD's library for graph optimizations.
* [MIOpen](https://github.com/ROCmSoftwarePlatform/MIOpen) for running on the GPU * [MIOpen](https://github.com/ROCmSoftwarePlatform/MIOpen) for running on the GPU
* [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
## Installing the dependencies ## Installing the dependencies
...@@ -70,6 +71,16 @@ The tests can be run by using the 'check' target: ...@@ -70,6 +71,16 @@ The tests can be run by using the 'check' target:
` cmake --build . --config Release --target check ` **OR** ` make check ` ` cmake --build . --config Release --target check ` **OR** ` make check `
This will build a local searchable web site inside the doc/html folder.
Documentation is built using [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html), [Sphinx](http://www.sphinx-doc.org/en/stable/index.html), and [Breathe](https://breathe.readthedocs.io/en/latest/)
Requirements for both Sphinx and Breathe can be installed with:
`pip install -r doc/requirements.txt`
Depending on your setup `sudo` may be required for the pip install.
## Building the documentation ## Building the documentation
HTML and PDF documentation can be built using: HTML and PDF documentation can be built using:
......
...@@ -5,9 +5,12 @@ set(DOXYGEN_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doxygen/) ...@@ -5,9 +5,12 @@ set(DOXYGEN_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doxygen/)
add_doxygen_doc( add_doxygen_doc(
OUTPUT_DIRECTORY ${DOXYGEN_OUTPUT} OUTPUT_DIRECTORY ${DOXYGEN_OUTPUT}
INPUT INPUT
${CMAKE_CURRENT_SOURCE_DIR}/../include
${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_CURRENT_SOURCE_DIR}/../src
${CMAKE_CURRENT_SOURCE_DIR}/../onnx INCLUDE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/../src/include
${CMAKE_CURRENT_SOURCE_DIR}/../src/targets/cpu/include
${CMAKE_CURRENT_SOURCE_DIR}/../src/targets/gpu/include
SEARCH_INCLUDES YES
MACRO_EXPANSION YES MACRO_EXPANSION YES
RECURSIVE YES RECURSIVE YES
GENERATE_XML YES GENERATE_XML YES
...@@ -28,6 +31,10 @@ add_doxygen_doc( ...@@ -28,6 +31,10 @@ add_doxygen_doc(
FULL_PATH_NAMES YES FULL_PATH_NAMES YES
PREDEFINED DOXYGEN PREDEFINED DOXYGEN
) )
add_custom_target(remove_inline_ns
sed -i "s/MIGRAPH_INLINE_NS:://g" *.xml
WORKING_DIRECTORY ${DOXYGEN_OUTPUT}/xml)
add_dependencies(remove_inline_ns doxygen)
include(SphinxDoc) include(SphinxDoc)
add_sphinx_doc(src add_sphinx_doc(src
...@@ -36,7 +43,7 @@ add_sphinx_doc(src ...@@ -36,7 +43,7 @@ add_sphinx_doc(src
VARS VARS
breathe_projects.proj=${DOXYGEN_OUTPUT}/xml breathe_projects.proj=${DOXYGEN_OUTPUT}/xml
breathe_default_project=proj breathe_default_project=proj
DEPENDS doxygen DEPENDS doxygen remove_inline_ns
) )
find_package(LATEX) find_package(LATEX)
......
...@@ -21,7 +21,7 @@ raw_data ...@@ -21,7 +21,7 @@ raw_data
.. doxygenstruct:: migraph::raw_data .. doxygenstruct:: migraph::raw_data
.. doxygenfunction:: migraph::visit_all .. doxygenfunction:: migraph::MIGRAPH_INLINE_NS::visit_all
tensor_view tensor_view
......
...@@ -11,12 +11,37 @@ dead_code_elimination ...@@ -11,12 +11,37 @@ dead_code_elimination
.. doxygenstruct:: migraph::dead_code_elimination .. doxygenstruct:: migraph::dead_code_elimination
auto_contiguous common_subexpression_elimination
--------------- --------------------------------
.. doxygenstruct:: migraph::gpu::auto_contiguous .. doxygenstruct:: migraph::common_subexpression_elimination
write_literals constant_propagate
-------------- ------------------
.. doxygenstruct:: migraph::gpu::write_literals .. doxygenstruct:: migraph::constant_propagate
eliminate_concat
----------------
.. doxygenstruct:: migraph::eliminate_concat
eliminate_contiguous
--------------------
.. doxygenstruct:: migraph::eliminate_contiguous
fwd_conv_batchnorm_rewrite
--------------------------
.. doxygenstruct:: migraph::fwd_conv_batchnorm_rewrite
simplify_algebra
----------------
.. doxygenstruct:: migraph::simplify_algebra
simplify_reshapes
-----------------
.. doxygenstruct:: migraph::simplify_reshapes
...@@ -21,4 +21,4 @@ program ...@@ -21,4 +21,4 @@ program
parse_onnx parse_onnx
---------- ----------
.. doxygenfunction:: migraph::parse_onnx .. doxygenfunction:: migraph::MIGRAPH_INLINE_NS::parse_onnx
include(ROCMInstallTargets)
include(ROCMPackageConfigHelpers)
add_library(migraph add_library(migraph
auto_contiguous.cpp auto_contiguous.cpp
common_subexpression_elimination.cpp common_subexpression_elimination.cpp
...@@ -19,20 +22,30 @@ add_library(migraph ...@@ -19,20 +22,30 @@ add_library(migraph
opt/memory_coloring_impl.cpp opt/memory_coloring_impl.cpp
) )
rocm_clang_tidy_check(migraph) rocm_clang_tidy_check(migraph)
target_include_directories(migraph PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>) rocm_install_targets(
TARGETS migraph
INCLUDE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
find_path(HALF_INCLUDE_DIR half.hpp) find_path(HALF_INCLUDE_DIR half.hpp)
target_include_directories(migraph SYSTEM PUBLIC ${HALF_INCLUDE_DIR}) # TODO: Fix the incorrect path
target_include_directories(migraph SYSTEM PUBLIC $<BUILD_INTERFACE:${HALF_INCLUDE_DIR}>)
set(PACKAGE_DEPENDS)
add_subdirectory(onnx) add_subdirectory(onnx)
add_subdirectory(targets/cpu) add_subdirectory(targets/cpu)
if(MIGRAPH_ENABLE_GPU) if(MIGRAPH_ENABLE_GPU)
list(APPEND PACKAGE_DEPENDS MIOpen rocblas)
add_subdirectory(targets/gpu) add_subdirectory(targets/gpu)
endif() endif()
#install (TARGETS migraph rocm_export_targets(
# LIBRARY DESTINATION /opt/rocm/lib) TARGETS migraph::migraph
NAMESPACE migraph::
#install (DIRECTORY include/migraph DESTINATION /opt/rocm/include) DEPENDS
${PACKAGE_DEPENDS}
)
...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS { ...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Remove identical instructions.
*/
struct common_subexpression_elimination struct common_subexpression_elimination
{ {
std::string name() const { return "common_subexpression_elimination"; } std::string name() const { return "common_subexpression_elimination"; }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace migraph { namespace migraph {
#ifndef MIGRAPH_USE_CLANG_TIDY #if !defined(MIGRAPH_USE_CLANG_TIDY) && !defined(DOXYGEN)
#define MIGRAPH_INLINE_NS version_1 #define MIGRAPH_INLINE_NS version_1
#endif #endif
......
...@@ -9,6 +9,9 @@ inline namespace MIGRAPH_INLINE_NS { ...@@ -9,6 +9,9 @@ inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Replace instructions which take all literals with a literal of the computation.
*/
struct constant_propagate struct constant_propagate
{ {
std::string name() const { return "constant_propagate"; } std::string name() const { return "constant_propagate"; }
......
...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS { ...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Remove instructions where the output is not used.
*/
struct dead_code_elimination struct dead_code_elimination
{ {
std::string name() const { return "dead_code_elimination"; } std::string name() const { return "dead_code_elimination"; }
......
...@@ -10,6 +10,10 @@ inline namespace MIGRAPH_INLINE_NS { ...@@ -10,6 +10,10 @@ inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Remove memory allocations. This will create a parameter which is the max of all memory used in
* the program.
*/
struct eliminate_allocation struct eliminate_allocation
{ {
std::string allocation_op{}; std::string allocation_op{};
......
...@@ -11,6 +11,9 @@ inline namespace MIGRAPH_INLINE_NS { ...@@ -11,6 +11,9 @@ inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Remove concat operators by having each operator can write to different chunk of memory.
*/
struct eliminate_concat struct eliminate_concat
{ {
concat_optimization concat_opt; concat_optimization concat_opt;
......
...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS { ...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Remove contiguous instructions by checking if the operator can use non-standard shapes.
*/
struct eliminate_contiguous struct eliminate_contiguous
{ {
std::string name() const { return "eliminate_contiguous"; } std::string name() const { return "eliminate_contiguous"; }
......
...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS { ...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Rewrite batchnorm to a multiply and add.
*/
struct fwd_conv_batchnorm_rewrite struct fwd_conv_batchnorm_rewrite
{ {
std::string name() const { return "fwd_conv_batchnorm_rewrite"; } std::string name() const { return "fwd_conv_batchnorm_rewrite"; }
......
...@@ -9,6 +9,9 @@ namespace migraph { ...@@ -9,6 +9,9 @@ namespace migraph {
inline namespace MIGRAPH_INLINE_NS { inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Remove memory allocations. It uses graph coloring to find memory allocations that can be reused.
*/
struct memory_coloring struct memory_coloring
{ {
std::string allocation_op{}; std::string allocation_op{};
......
...@@ -97,9 +97,9 @@ struct program ...@@ -97,9 +97,9 @@ struct program
void perf_report(std::ostream& os, std::size_t n, parameter_map params) const; void perf_report(std::ostream& os, std::size_t n, parameter_map params) const;
void debug_print(); void debug_print() const;
void debug_print(instruction_ref ins); void debug_print(instruction_ref ins) const;
void debug_print(const std::vector<instruction_ref>& inss); void debug_print(const std::vector<instruction_ref>& inss) const;
friend std::ostream& operator<<(std::ostream& os, const program& p); friend std::ostream& operator<<(std::ostream& os, const program& p);
friend bool operator==(const program& x, const program& y); friend bool operator==(const program& x, const program& y);
......
...@@ -9,6 +9,9 @@ inline namespace MIGRAPH_INLINE_NS { ...@@ -9,6 +9,9 @@ inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Simplify many algebraic instructions to more efficient versions.
*/
struct simplify_algebra struct simplify_algebra
{ {
std::string name() const { return "simplify_algebra"; } std::string name() const { return "simplify_algebra"; }
......
...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS { ...@@ -10,6 +10,9 @@ inline namespace MIGRAPH_INLINE_NS {
struct program; struct program;
/**
* Eliminate redundant reshapes.
*/
struct simplify_reshapes struct simplify_reshapes
{ {
std::string name() const { return "simplify_reshapes"; } std::string name() const { return "simplify_reshapes"; }
......
...@@ -8,10 +8,15 @@ target_link_libraries(onnx-proto PRIVATE ${PROTOBUF_LIBRARY}) ...@@ -8,10 +8,15 @@ target_link_libraries(onnx-proto PRIVATE ${PROTOBUF_LIBRARY})
set_target_properties(onnx-proto PROPERTIES POSITION_INDEPENDENT_CODE On) set_target_properties(onnx-proto PROPERTIES POSITION_INDEPENDENT_CODE On)
add_library(migraph_onnx onnx.cpp) add_library(migraph_onnx onnx.cpp)
set_target_properties(migraph_onnx PROPERTIES EXPORT_NAME onnx)
rocm_clang_tidy_check(migraph_onnx) rocm_clang_tidy_check(migraph_onnx)
target_link_libraries(migraph_onnx PRIVATE onnx-proto) target_link_libraries(migraph_onnx PRIVATE onnx-proto)
target_link_libraries(migraph_onnx PUBLIC migraph) target_link_libraries(migraph_onnx PUBLIC migraph)
rocm_install_targets(
TARGETS migraph_onnx
)
add_executable(read_onnx read_onnx.cpp) add_executable(read_onnx read_onnx.cpp)
rocm_clang_tidy_check(read_onnx) rocm_clang_tidy_check(read_onnx)
target_link_libraries(read_onnx migraph_onnx) target_link_libraries(read_onnx migraph_onnx)
......
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