Skip to content

Commit

Permalink
Merge branch 'develop' into qdq_clip
Browse files Browse the repository at this point in the history
  • Loading branch information
causten authored May 8, 2024
2 parents 587a0b0 + c7d5f09 commit 22ffcec
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 23 deletions.
22 changes: 19 additions & 3 deletions src/api/include/migraphx/migraphx.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -67,8 +67,24 @@ std::string compute_type_name()
{
std::string name;
#if defined(_MSC_VER) && !defined(__clang__)
name = typeid(PrivateMigraphTypeNameProbe).name();
name = name.substr(7);
const char struct_name[] = "struct ";
const char class_name[] = "class ";
const char function_name[] = "compute_type_name<";
const char parameter_name[] = ">(void)";
const char cdecl_name[] = "__cdecl";

name = __FUNCSIG__;

auto begin = name.find(function_name) + sizeof(function_name) - 1;
auto length = name.find(parameter_name) - begin;
name = name.substr(begin, length);
if(name.find(class_name) == 0)
name = name.substr(sizeof(class_name) - 1);
else if(name.find(struct_name) == 0)
name = name.substr(sizeof(struct_name) - 1);
begin = name.find(cdecl_name);
if(begin != std::string::npos)
name.erase(begin, sizeof(cdecl_name) - 1);
#else
const char parameter_name[] = "PrivateMigraphTypeNameProbe ="; // NOLINT

Expand Down
13 changes: 3 additions & 10 deletions src/include/migraphx/type_name.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -33,24 +33,17 @@ inline namespace MIGRAPHX_INLINE_NS {
template <class PrivateMigraphTypeNameProbe>
std::string compute_type_name()
{
std::string name;
#if defined(_MSC_VER) && !defined(__clang__)
name = typeid(PrivateMigraphTypeNameProbe).name();
name = name.substr(7);
#else
const char parameter_name[] = "PrivateMigraphTypeNameProbe ="; // NOLINT

name = __PRETTY_FUNCTION__;
std::string name = __PRETTY_FUNCTION__;

auto begin = name.find(parameter_name) + sizeof(parameter_name);
#if(defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7)
auto length = name.find_last_of(",") - begin;
#else
auto length = name.find_first_of("];", begin) - begin;
#endif
name = name.substr(begin, length);
#endif
return name;
return name.substr(begin, length);
}

template <class T>
Expand Down
4 changes: 2 additions & 2 deletions src/targets/gpu/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti
simplify_qdq{},
enable_pass(not mlir_enabled(), rewrite_quantization{}),
dead_code_elimination{},
// workaround for rocBLAS unsupported error when using uint8 in quant_dot & quant_convolution
eliminate_data_type{{migraphx::shape::uint8_type}, shape::float_type, {"quant_convolution", "quant_dot"}},
// workaround for rocBLAS unsupported error when using uint8 in quant_dot, quant_convolution & pooling
eliminate_data_type{{migraphx::shape::uint8_type}, shape::float_type, {"quant_convolution", "quant_dot", "pooling"}},
eliminate_data_type{unsupported_types, shape::type_t::float_type},
simplify_reshapes{},
eliminate_identity{},
Expand Down
1 change: 0 additions & 1 deletion test/py/onnx_backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def disabled_tests_onnx_1_7_0(backend_test):
backend_test.exclude(r'test_einsum_inner_prod_cpu')
backend_test.exclude(r'test_einsum_sum_cpu')
backend_test.exclude(r'test_einsum_transpose_cpu')
backend_test.exclude(r'test_maxpool_2d_uint8_cpu')
backend_test.exclude(r'test_maxunpool_export_with_output_shape_cpu')
backend_test.exclude(r'test_maxunpool_export_without_output_shape_cpu')
backend_test.exclude(r'test_mod_mixed_sign_int32_cpu')
Expand Down
11 changes: 7 additions & 4 deletions test/verify/test_global_max_pooling.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,18 +28,21 @@
#include <migraphx/op/pooling.hpp>
#include <migraphx/instruction.hpp>

struct test_global_max_pooling : verify_program<test_global_max_pooling>
template <migraphx::shape::type_t T>
struct test_global_max_pooling : verify_program<test_global_max_pooling<T>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input =
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 3, 16, 16}});
auto input = mm->add_parameter("x", migraphx::shape{T, {1, 3, 16, 16}});
auto op = migraphx::op::pooling{migraphx::op::pooling_mode::max};
auto lens = input->get_shape().lens();
op.lengths = {lens[2], lens[3]};
mm->add_instruction(op, input);
return p;
}
};

template struct test_global_max_pooling<migraphx::shape::float_type>;
template struct test_global_max_pooling<migraphx::shape::uint8_type>;
9 changes: 6 additions & 3 deletions test/verify/test_max_pooling_ceil_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/op/pooling.hpp>

struct test_max_pooling_ceil_3d : verify_program<test_max_pooling_ceil_3d>
template <migraphx::shape::type_t T>
struct test_max_pooling_ceil_3d : verify_program<test_max_pooling_ceil_3d<T>>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
auto input =
mm->add_parameter("x", migraphx::shape{migraphx::shape::float_type, {1, 3, 5, 5, 5}});
auto input = mm->add_parameter("x", migraphx::shape{T, {1, 3, 5, 5, 5}});
auto op = migraphx::op::pooling{
migraphx::op::pooling_mode::max, {1, 1, 1}, {3, 3, 3}, {3, 3, 3}, {1, 1, 1}, true};
mm->add_instruction(op, input);
return p;
}
};

template struct test_max_pooling_ceil_3d<migraphx::shape::float_type>;
template struct test_max_pooling_ceil_3d<migraphx::shape::uint8_type>;

0 comments on commit 22ffcec

Please sign in to comment.