Commit ca052a91 authored by Artur Wojcik's avatar Artur Wojcik
Browse files

Merge branch 'develop' into uif2-initial

parents bc7ac032 254c2a78
...@@ -112,9 +112,17 @@ set(MIGRAPHX_ENABLE_CPU Off CACHE BOOL "") ...@@ -112,9 +112,17 @@ set(MIGRAPHX_ENABLE_CPU Off CACHE BOOL "")
# Disable fpga backend by default # Disable fpga backend by default
set(MIGRAPHX_ENABLE_FPGA Off CACHE BOOL "") set(MIGRAPHX_ENABLE_FPGA Off CACHE BOOL "")
set(CMAKE_CXX_STANDARD 17) if(WIN32)
set(CMAKE_CXX_STANDARD_REQUIRED ON) add_compile_definitions(
set(CMAKE_CXX_EXTENSIONS OFF) $<$<COMPILE_LANGUAGE:C,CXX>:_CRT_SECURE_NO_WARNINGS>
$<$<COMPILE_LANGUAGE:C,CXX>:_USE_MATH_DEFINES>)
endif()
if(MSVC)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/std:c++17>)
else()
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=c++17>)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(EnableCompilerWarnings) include(EnableCompilerWarnings)
......
...@@ -28,7 +28,11 @@ include(ROCMInstallTargets) ...@@ -28,7 +28,11 @@ include(ROCMInstallTargets)
include(ROCMPackageConfigHelpers) include(ROCMPackageConfigHelpers)
include(RegisterOp) include(RegisterOp)
include(CheckCXXLinkerFlag) include(CheckCXXLinkerFlag)
if(WIN32)
# Due to compilation crashing, we need to use type-erased matchers on Windows.
add_compile_definitions($<$<COMPILE_LANGUAGE:C,CXX>:MIGRAPHX_USE_TYPE_ERASED_MATCHERS=1>)
endif()
add_library(migraphx add_library(migraphx
adjust_allocation.cpp adjust_allocation.cpp
...@@ -246,9 +250,7 @@ rocm_install_targets( ...@@ -246,9 +250,7 @@ rocm_install_targets(
${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include
) )
if(WIN32) if(NOT WIN32)
target_compile_definitions(migraphx PUBLIC _CRT_SECURE_NO_WARNINGS _USE_MATH_DEFINES)
else()
check_cxx_linker_flag(-lstdc++fs HAS_LIB_STD_FILESYSTEM) check_cxx_linker_flag(-lstdc++fs HAS_LIB_STD_FILESYSTEM)
if(HAS_LIB_STD_FILESYSTEM) if(HAS_LIB_STD_FILESYSTEM)
target_link_libraries(migraphx PRIVATE -lstdc++fs) target_link_libraries(migraphx PRIVATE -lstdc++fs)
......
...@@ -37,6 +37,8 @@ namespace op { ...@@ -37,6 +37,8 @@ namespace op {
* Static allocate: * Static allocate:
* No inputs: `allocate()` * No inputs: `allocate()`
* `this.s` attribute set to the static output shape of the buffer. * `this.s` attribute set to the static output shape of the buffer.
* `this.s` attribute can be set to a dynamic output shape; however this will allocate the maximum
* buffer size for that case
* *
* Dynamic allocate: * Dynamic allocate:
* One input: `allocate(output_dims)` * One input: `allocate(output_dims)`
...@@ -74,10 +76,6 @@ struct allocate ...@@ -74,10 +76,6 @@ struct allocate
} }
else else
{ {
if(s->dynamic())
{
MIGRAPHX_THROW("ALLOCATE: dynamic shape attribute and no input");
}
migraphx::check_shapes{inputs, *this, false}.has(0); migraphx::check_shapes{inputs, *this, false}.has(0);
} }
return s.value(); return s.value();
......
...@@ -147,8 +147,8 @@ void quantize_int8(program& prog, ...@@ -147,8 +147,8 @@ void quantize_int8(program& prog,
run_passes(prog, run_passes(prog,
{quantize_int8_pass{ins_names, *int8_quant_params}, {quantize_int8_pass{ins_names, *int8_quant_params},
optimize_module{},
simplify_qdq{}, simplify_qdq{},
optimize_module{},
dead_code_elimination{}}); dead_code_elimination{}});
} }
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
*/ */
#include <migraphx/cpu/lowering.hpp> #include <migraphx/cpu/lowering.hpp>
#if !defined(_MSC_VER)
#include <migraphx/instruction.hpp> #include <migraphx/instruction.hpp>
#include <migraphx/dfor.hpp> #include <migraphx/dfor.hpp>
#include <migraphx/op/identity.hpp> #include <migraphx/op/identity.hpp>
...@@ -52,15 +51,12 @@ ...@@ -52,15 +51,12 @@
#include <migraphx/cpu/context.hpp> #include <migraphx/cpu/context.hpp>
#include <migraphx/register_op.hpp> #include <migraphx/register_op.hpp>
#include <migraphx/make_op.hpp> #include <migraphx/make_op.hpp>
#endif
#include <migraphx/program.hpp> #include <migraphx/program.hpp>
#if !defined(_MSC_VER)
#include <migraphx/tune_axis.hpp> #include <migraphx/tune_axis.hpp>
#include <migraphx/match/layernorm.hpp> #include <migraphx/match/layernorm.hpp>
#include <migraphx/match/gelu_erf.hpp> #include <migraphx/match/gelu_erf.hpp>
#include <migraphx/match/gelu_tanh.hpp> #include <migraphx/match/gelu_tanh.hpp>
#include <migraphx/matcher.hpp> #include <migraphx/matcher.hpp>
#endif
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
#include <iostream> #include <iostream>
...@@ -69,7 +65,6 @@ namespace migraphx { ...@@ -69,7 +65,6 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
namespace cpu { namespace cpu {
#if !defined(_MSC_VER)
template <typename T> template <typename T>
T zero(const T&) T zero(const T&)
{ {
...@@ -450,16 +445,8 @@ struct cpu_apply ...@@ -450,16 +445,8 @@ struct cpu_apply
return modl->insert_instruction(ins, make_op("allocate", {{"shape", to_value(s)}})); return modl->insert_instruction(ins, make_op("allocate", {{"shape", to_value(s)}}));
} }
}; };
#endif
void lowering::apply(module& m) const void lowering::apply(module& m) const { cpu_apply{&m}.apply(); }
{
#if !defined(_MSC_VER)
cpu_apply{&m}.apply();
#else
(void)m;
#endif
}
} // namespace cpu } // namespace cpu
} // namespace MIGRAPHX_INLINE_NS } // namespace MIGRAPHX_INLINE_NS
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
# THE SOFTWARE. # THE SOFTWARE.
# #################################################################################### # ####################################################################################
list(APPEND CMAKE_PREFIX_PATH /opt/rocm $ENV{ROCM_PATH}) find_package(hip REQUIRED)
find_package(hip)
if(NOT GPU_TARGETS) 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.") 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.")
endif() endif()
......
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
add_executable(migraphx-hiprtc-driver add_executable(migraphx-hiprtc-driver
main.cpp main.cpp
) )
if(WIN32)
target_compile_definitions(migraphx-hiprtc-driver PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
rocm_clang_tidy_check(migraphx-hiprtc-driver) rocm_clang_tidy_check(migraphx-hiprtc-driver)
target_link_libraries(migraphx-hiprtc-driver PRIVATE migraphx_gpu) target_link_libraries(migraphx-hiprtc-driver PRIVATE migraphx_gpu)
add_dependencies(migraphx_all_targets migraphx-hiprtc-driver) add_dependencies(migraphx_all_targets migraphx-hiprtc-driver)
......
...@@ -23,24 +23,19 @@ ...@@ -23,24 +23,19 @@
*/ */
#include <migraphx/permutation.hpp> #include <migraphx/permutation.hpp>
#include <migraphx/gpu/prefuse_ops.hpp> #include <migraphx/gpu/prefuse_ops.hpp>
#if !defined(_MSC_VER)
#include <migraphx/gpu/gemm_softmax_gemm.hpp> #include <migraphx/gpu/gemm_softmax_gemm.hpp>
#include <migraphx/match/layernorm.hpp> #include <migraphx/match/layernorm.hpp>
#include <migraphx/register_op.hpp> #include <migraphx/register_op.hpp>
#endif
#include <migraphx/pass_manager.hpp> #include <migraphx/pass_manager.hpp>
#if !defined(_MSC_VER)
#include <migraphx/dead_code_elimination.hpp> #include <migraphx/dead_code_elimination.hpp>
#if MIGRAPHX_USE_COMPOSABLEKERNEL #ifdef MIGRAPHX_USE_COMPOSABLEKERNEL
#include <migraphx/gpu/ck.hpp> #include <migraphx/gpu/ck.hpp>
#endif #endif
#endif
namespace migraphx { namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS { inline namespace MIGRAPHX_INLINE_NS {
namespace gpu { namespace gpu {
#if !defined(_MSC_VER)
namespace { namespace {
template <class Derived, std::size_t N> template <class Derived, std::size_t N>
...@@ -129,6 +124,8 @@ struct find_add_layernorm ...@@ -129,6 +124,8 @@ struct find_add_layernorm
} }
}; };
#ifdef MIGRAPHX_USE_COMPOSABLEKERNEL
struct pre_gemm_softmax_gemm : gemm_softmax_gemm struct pre_gemm_softmax_gemm : gemm_softmax_gemm
{ {
std::string name() const { return "gpu::pre_gemm_softmax_gemm"; } std::string name() const { return "gpu::pre_gemm_softmax_gemm"; }
...@@ -182,19 +179,18 @@ struct find_gemm_softmax_gemm ...@@ -182,19 +179,18 @@ struct find_gemm_softmax_gemm
} }
}; };
} // namespace
#endif #endif
} // namespace
void prefuse_ops::apply(module_pass_manager& mpm) const void prefuse_ops::apply(module_pass_manager& mpm) const
{ {
#if !defined(_MSC_VER)
match::find_matches(mpm.get_module(), find_layernorm{}); match::find_matches(mpm.get_module(), find_layernorm{});
mpm.run_pass(dead_code_elimination{}); mpm.run_pass(dead_code_elimination{});
match::find_matches(mpm.get_module(), find_add_layernorm{}); match::find_matches(mpm.get_module(), find_add_layernorm{});
#ifdef MIHRAPHX_USE_COMPOSABLEKERNEL
if(enabled(MIGRAPHX_ENABLE_CK{})) if(enabled(MIGRAPHX_ENABLE_CK{}))
match::find_matches(mpm, find_gemm_softmax_gemm{}); match::find_matches(mpm, find_gemm_softmax_gemm{});
#else
(void)mpm;
#endif #endif
} }
......
...@@ -30,9 +30,6 @@ function(add_api_test TEST_NAME TEST_SRC TEST_DIR) ...@@ -30,9 +30,6 @@ function(add_api_test TEST_NAME TEST_SRC TEST_DIR)
add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}> WORKING_DIRECTORY ${TEST_DIR}) add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}> WORKING_DIRECTORY ${TEST_DIR})
add_dependencies(tests ${NAME}) add_dependencies(tests ${NAME})
add_dependencies(check ${NAME}) add_dependencies(check ${NAME})
if(WIN32)
target_compile_definitions(${NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
endfunction() endfunction()
# Workaround: C file dont work with clang-tidy right now, need a fix in rocm-cmake # Workaround: C file dont work with clang-tidy right now, need a fix in rocm-cmake
...@@ -44,9 +41,6 @@ function(add_c_api_test TEST_NAME TEST_SRC TEST_DIR) ...@@ -44,9 +41,6 @@ function(add_c_api_test TEST_NAME TEST_SRC TEST_DIR)
add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}> WORKING_DIRECTORY ${TEST_DIR}) add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}> WORKING_DIRECTORY ${TEST_DIR})
add_dependencies(tests ${NAME}) add_dependencies(tests ${NAME})
add_dependencies(check ${NAME}) add_dependencies(check ${NAME})
if(WIN32)
target_compile_definitions(${NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
endfunction() endfunction()
add_api_test(array_base test_array_base.cpp ${TEST_ONNX_DIR}) add_api_test(array_base test_array_base.cpp ${TEST_ONNX_DIR})
......
...@@ -116,11 +116,12 @@ TEST_CASE(allocate_dyn_with_shape_attr) ...@@ -116,11 +116,12 @@ TEST_CASE(allocate_dyn_with_shape_attr)
input); input);
} }
TEST_CASE(allocate_dyn_no_input_error) TEST_CASE(allocate_dyn_no_input)
{ {
migraphx::shape shape_attr{migraphx::shape::float_type, migraphx::shape shape_attr{migraphx::shape::float_type,
{{1, 4}, {3, 3}, {4, 8, {4, 6}}, {4, 8}, {4, 6}}}; {{1, 4}, {3, 3}, {4, 8, {4, 6}}, {4, 8}, {4, 6}}};
throws_shape(migraphx::make_op("allocate", {{"shape", migraphx::to_value(shape_attr)}})); expect_shape(shape_attr,
migraphx::make_op("allocate", {{"shape", migraphx::to_value(shape_attr)}}));
} }
TEST_CASE(allocate_shape_and_buf_type_error) TEST_CASE(allocate_shape_and_buf_type_error)
......
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