| 1 | // Tencent is pleased to support the open source community by making ncnn available. |
| 2 | // |
| 3 | // Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. |
| 4 | // |
| 5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except |
| 6 | // in compliance with the License. You may obtain a copy of the License at |
| 7 | // |
| 8 | // https://opensource.org/licenses/BSD-3-Clause |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software distributed |
| 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 13 | // specific language governing permissions and limitations under the License. |
| 14 | |
| 15 | #include "pass_level2.h" |
| 16 | |
| 17 | namespace pnnx { |
| 18 | |
| 19 | class F_upsample_nearest : public GraphRewriterPass |
| 20 | { |
| 21 | public: |
| 22 | const char* match_pattern_graph() const |
| 23 | { |
| 24 | return R"PNNXIR(7767517 |
| 25 | 6 5 |
| 26 | pnnx.Input input_0 0 1 input |
| 27 | pnnx.Input input_1 0 1 size |
| 28 | prim::Constant op_0 0 1 scale_h value=None |
| 29 | prim::Constant op_1 0 1 scale_w value=None |
| 30 | aten::upsample_nearest2d op_2 4 1 input size scale_h scale_w out |
| 31 | pnnx.Output output 1 0 out |
| 32 | )PNNXIR"; |
| 33 | } |
| 34 | |
| 35 | const char* type_str() const |
| 36 | { |
| 37 | return "F.upsample_nearest"; |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(F_upsample_nearest, 10) |
| 42 | |
| 43 | class F_upsample_nearest_1 : public GraphRewriterPass |
| 44 | { |
| 45 | public: |
| 46 | const char* match_pattern_graph() const |
| 47 | { |
| 48 | return R"PNNXIR(7767517 |
| 49 | 5 4 |
| 50 | pnnx.Input input_0 0 1 input |
| 51 | pnnx.Input input_1 0 1 scale_factor |
| 52 | prim::Constant op_0 0 1 size value=None |
| 53 | aten::upsample_nearest2d op_1 3 1 input size scale_factor out |
| 54 | pnnx.Output output 1 0 out |
| 55 | )PNNXIR"; |
| 56 | } |
| 57 | |
| 58 | const char* type_str() const |
| 59 | { |
| 60 | return "F.upsample_nearest"; |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(F_upsample_nearest_1, 10) |
| 65 | |
| 66 | class F_upsample_nearest_1_1 : public GraphRewriterPass |
| 67 | { |
| 68 | public: |
| 69 | const char* match_pattern_graph() const |
| 70 | { |
| 71 | return R"PNNXIR(7767517 |
| 72 | 5 4 |
| 73 | pnnx.Input input_0 0 1 input |
| 74 | pnnx.Input input_1 0 1 size |
| 75 | prim::Constant op_0 0 1 scale_factor value=None |
| 76 | aten::upsample_nearest2d op_1 3 1 input size scale_factor out |
| 77 | pnnx.Output output 1 0 out |
| 78 | )PNNXIR"; |
| 79 | } |
| 80 | |
| 81 | const char* type_str() const |
| 82 | { |
| 83 | return "F.upsample_nearest"; |
| 84 | } |
| 85 | }; |
| 86 | |
| 87 | REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(F_upsample_nearest_1_1, 10) |
| 88 | |
| 89 | class F_upsample_nearest_2 : public GraphRewriterPass |
| 90 | { |
| 91 | public: |
| 92 | const char* match_pattern_graph() const |
| 93 | { |
| 94 | return R"PNNXIR(7767517 |
| 95 | 7 6 |
| 96 | pnnx.Input input_0 0 1 input |
| 97 | pnnx.Input input_1 0 1 size |
| 98 | prim::Constant op_0 0 1 scale_d value=None |
| 99 | prim::Constant op_1 0 1 scale_h value=None |
| 100 | prim::Constant op_2 0 1 scale_w value=None |
| 101 | aten::upsample_nearest3d op_3 5 1 input size scale_d scale_h scale_w out |
| 102 | pnnx.Output output 1 0 out |
| 103 | )PNNXIR"; |
| 104 | } |
| 105 | |
| 106 | const char* type_str() const |
| 107 | { |
| 108 | return "F.upsample_nearest"; |
| 109 | } |
| 110 | }; |
| 111 | |
| 112 | REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(F_upsample_nearest_2, 10) |
| 113 | |
| 114 | class F_upsample_nearest_2_1 : public GraphRewriterPass |
| 115 | { |
| 116 | public: |
| 117 | const char* match_pattern_graph() const |
| 118 | { |
| 119 | return R"PNNXIR(7767517 |
| 120 | 5 4 |
| 121 | pnnx.Input input_0 0 1 input |
| 122 | pnnx.Input input_1 0 1 size |
| 123 | prim::Constant op_0 0 1 scale_factor value=None |
| 124 | aten::upsample_nearest3d op_1 3 1 input size scale_factor out |
| 125 | pnnx.Output output 1 0 out |
| 126 | )PNNXIR"; |
| 127 | } |
| 128 | |
| 129 | const char* type_str() const |
| 130 | { |
| 131 | return "F.upsample_nearest"; |
| 132 | } |
| 133 | }; |
| 134 | |
| 135 | REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(F_upsample_nearest_2_1, 10) |
| 136 | |
| 137 | class F_upsample_nearest_3 : public GraphRewriterPass |
| 138 | { |
| 139 | public: |
| 140 | const char* match_pattern_graph() const |
| 141 | { |
| 142 | return R"PNNXIR(7767517 |
| 143 | 5 4 |
| 144 | pnnx.Input input_0 0 1 input |
| 145 | pnnx.Input input_1 0 1 scale_factor |
| 146 | prim::Constant op_0 0 1 size value=None |
| 147 | aten::upsample_nearest3d op_1 3 1 input size scale_factor out |
| 148 | pnnx.Output output 1 0 out |
| 149 | )PNNXIR"; |
| 150 | } |
| 151 | |
| 152 | const char* type_str() const |
| 153 | { |
| 154 | return "F.upsample_nearest"; |
| 155 | } |
| 156 | }; |
| 157 | |
| 158 | REGISTER_GLOBAL_PNNX_GRAPH_REWRITER_PASS(F_upsample_nearest_3, 10) |
| 159 | |
| 160 | } // namespace pnnx |