target.cpp 4.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2015-2022 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
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
Shucai Xiao's avatar
Shucai Xiao committed
24

25
26
#include <migraphx/auto_contiguous.hpp>
#include <migraphx/check_context.hpp>
27
#include <migraphx/adjust_allocation.hpp>
28
29
30
31
32
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/eliminate_allocation.hpp>
#include <migraphx/eliminate_common_subexpression.hpp>
#include <migraphx/eliminate_concat.hpp>
#include <migraphx/eliminate_contiguous.hpp>
33
#include <migraphx/eliminate_data_type.hpp>
34
35
36
37
38
#include <migraphx/eliminate_identity.hpp>
#include <migraphx/eliminate_pad.hpp>
#include <migraphx/memory_coloring.hpp>
#include <migraphx/propagate_constant.hpp>
#include <migraphx/register_target.hpp>
39
#include <migraphx/replace_allocate.hpp>
40
#include <migraphx/rewrite_pooling.hpp>
turneram's avatar
turneram committed
41
#include <migraphx/rewrite_quantization.hpp>
42
43
#include <migraphx/rewrite_rnn.hpp>
#include <migraphx/schedule.hpp>
44
#include <migraphx/memory_coloring.hpp>
45
#include <migraphx/simplify_algebra.hpp>
turneram's avatar
turneram committed
46
#include <migraphx/simplify_qdq.hpp>
47
#include <migraphx/simplify_reshapes.hpp>
48
#include <migraphx/preallocate_param.hpp>
49
#include <migraphx/cpu/fuse_ops.hpp>
50
#include <migraphx/cpu/write_literals.hpp>
51
#include <migraphx/cpu/allocation_model.hpp>
Paul's avatar
Paul committed
52
#include <migraphx/cpu/target.hpp>
53
#include <migraphx/cpu/context.hpp>
Paul's avatar
Paul committed
54
#include <migraphx/cpu/lowering.hpp>
Paul's avatar
Paul committed
55
#include <migraphx/pass.hpp>
56
#include <migraphx/generate.hpp>
Shucai Xiao's avatar
Shucai Xiao committed
57
#include <migraphx/normalize_ops.hpp>
Shucai Xiao's avatar
Shucai Xiao committed
58

Paul's avatar
Paul committed
59
namespace migraphx {
Paul's avatar
Paul committed
60
inline namespace MIGRAPHX_INLINE_NS {
Shucai Xiao's avatar
Shucai Xiao committed
61
62
63
64
namespace cpu {

std::string target::name() const { return "cpu"; }

65
66
// cppcheck-suppress constParameter
std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_options&) const
Shucai Xiao's avatar
Shucai Xiao committed
67
{
68
    auto& ctx = any_cast<context>(gctx);
69
70
    std::set<shape::type_t> unsupported_types(shape::types().begin(), shape::types().end());
    unsupported_types.erase(shape::type_t::float_type);
Shucai Xiao's avatar
Shucai Xiao committed
71
    return {normalize_ops{},
turneram's avatar
turneram committed
72
73
            rewrite_quantization{},
            dead_code_elimination{},
74
75
            eliminate_data_type{unsupported_types, shape::type_t::float_type},
            dead_code_elimination{},
76
77
78
79
80
81
82
            simplify_reshapes{},
            eliminate_identity{},
            eliminate_pad{},
            dead_code_elimination{},
            rewrite_rnn{},
            dead_code_elimination{},
            eliminate_common_subexpression{},
Shucai Xiao's avatar
Shucai Xiao committed
83
            dead_code_elimination{},
84
85
86
            simplify_algebra{},
            simplify_reshapes{},
            simplify_algebra{},
Shucai Xiao's avatar
Shucai Xiao committed
87
            auto_contiguous{},
88
89
            simplify_reshapes{},
            propagate_constant{},
Shucai Xiao's avatar
Shucai Xiao committed
90
91
            dead_code_elimination{},
            lowering{},
92
            eliminate_contiguous{"dnnl::reorder"},
93
            dead_code_elimination{},
94
95
            replace_allocate{cpu_allocation_model{}},
            dead_code_elimination{},
96
97
            adjust_allocation{cpu_allocation_model{}},
            dead_code_elimination{},
98
99
            fuse_ops{&ctx},
            dead_code_elimination{},
100
101
            write_literals{},
            dead_code_elimination{},
102
            memory_coloring{"cpu::allocate"},
103
104
            dead_code_elimination{},
            preallocate_param{"scratch", cpu_allocation_model{}},
Shucai Xiao's avatar
Shucai Xiao committed
105
            dead_code_elimination{}};
Shucai Xiao's avatar
Shucai Xiao committed
106
107
}

Shucai Xiao's avatar
Shucai Xiao committed
108
argument target::allocate(const shape& s) const { return fill_argument(s, 0); }
109

110
111
MIGRAPHX_REGISTER_TARGET(target);

Shucai Xiao's avatar
Shucai Xiao committed
112
} // namespace cpu
Paul's avatar
Paul committed
113
} // namespace MIGRAPHX_INLINE_NS
Paul's avatar
Paul committed
114
} // namespace migraphx