Pads a variable. Args: x: A variable. paddings: A variable of type Halide_Type_Int. The shape is [n, 2] where n is the rank of variable. mode: A enum, One of PadValueMode_CONSTANT, PadValueMode_SYMMETRIC, or PadValueMode_REFLECT. Returns: A variable. Has the same type as x. */
| 737 | A variable. Has the same type as x. |
| 738 | */ |
| 739 | VARP _Pad(VARP x, VARP paddings, PadValueMode mode) { |
| 740 | std::unique_ptr<OpT> pad(new OpT); |
| 741 | pad->type = OpType_Padding; |
| 742 | pad->main.type = OpParameter_PadParam; |
| 743 | pad->main.value = new PadParamT; |
| 744 | switch (mode) { |
| 745 | case CONSTANT: |
| 746 | pad->main.AsPadParam()->mode = MNN::PadValueMode_CONSTANT; |
| 747 | break; |
| 748 | case SYMMETRIC: |
| 749 | pad->main.AsPadParam()->mode = MNN::PadValueMode_SYMMETRIC; |
| 750 | break; |
| 751 | case REFLECT: |
| 752 | pad->main.AsPadParam()->mode = MNN::PadValueMode_REFLECT; |
| 753 | break; |
| 754 | default: |
| 755 | pad->main.AsPadParam()->mode = MNN::PadValueMode_CONSTANT; |
| 756 | break; |
| 757 | } |
| 758 | return (Variable::create(Expr::create(std::move(pad), {x, paddings}))); |
| 759 | } |
| 760 | /*Returns a variable with an additional dimension inserted at index axis. |
| 761 | Args: |
| 762 | input: A variable. |