layout_compute.cc 3.6 KB
Newer Older
J
jackzhang235 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.ddNod
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "lite/kernels/mlu/layout_compute.h"

namespace paddle {
namespace lite {
namespace kernels {
namespace mlu {}  // namespace mlu
}  // namespace kernels
}  // namespace lite
}  // namespace paddle

REGISTER_LITE_KERNEL(
    layout,
    kMLU,
    kFloat,
    kNHWC,
    paddle::lite::kernels::mlu::LayoutNhwcToNchwCompute<PRECISION(kFloat)>,
    def_layout_nhwc2nchw_fp32)
J
jackzhang235 已提交
32 33
    .BindInput("Input",
               {LiteType::GetTensorTy(TARGET(kHost),
J
jackzhang235 已提交
34 35
                                      PRECISION(kFloat),
                                      DATALAYOUT(kNHWC))})
J
jackzhang235 已提交
36 37
    .BindOutput("Out",
                {LiteType::GetTensorTy(TARGET(kHost),
J
jackzhang235 已提交
38 39 40 41 42 43 44 45 46 47 48
                                       PRECISION(kFloat),
                                       DATALAYOUT(kNCHW))})
    .Finalize();

REGISTER_LITE_KERNEL(
    layout,
    kMLU,
    kFP16,
    kNHWC,
    paddle::lite::kernels::mlu::LayoutNhwcToNchwCompute<PRECISION(kFP16)>,
    def_layout_nhwc2nchw_fp16)
J
jackzhang235 已提交
49 50
    .BindInput("Input",
               {LiteType::GetTensorTy(TARGET(kHost),
51
                                      PRECISION(kFP16),
J
jackzhang235 已提交
52
                                      DATALAYOUT(kNHWC))})
J
jackzhang235 已提交
53 54
    .BindOutput("Out",
                {LiteType::GetTensorTy(TARGET(kHost),
55
                                       PRECISION(kFP16),
J
jackzhang235 已提交
56 57 58 59 60 61 62 63 64 65
                                       DATALAYOUT(kNCHW))})
    .Finalize();

REGISTER_LITE_KERNEL(
    layout,
    kMLU,
    kFloat,
    kNHWC,
    paddle::lite::kernels::mlu::LayoutNchwToNhwcCompute<PRECISION(kFloat)>,
    def_layout_nchw2nhwc_fp32)
J
jackzhang235 已提交
66 67
    .BindInput("Input",
               {LiteType::GetTensorTy(TARGET(kHost),
J
jackzhang235 已提交
68 69
                                      PRECISION(kFloat),
                                      DATALAYOUT(kNCHW))})
J
jackzhang235 已提交
70 71
    .BindOutput("Out",
                {LiteType::GetTensorTy(TARGET(kHost),
J
jackzhang235 已提交
72 73 74 75 76 77 78 79 80 81 82
                                       PRECISION(kFloat),
                                       DATALAYOUT(kNHWC))})
    .Finalize();

REGISTER_LITE_KERNEL(
    layout,
    kMLU,
    kFP16,
    kNHWC,
    paddle::lite::kernels::mlu::LayoutNchwToNhwcCompute<PRECISION(kFP16)>,
    def_layout_nchw2nhwc_fp16)
J
jackzhang235 已提交
83 84
    .BindInput("Input",
               {LiteType::GetTensorTy(TARGET(kHost),
85
                                      PRECISION(kFP16),
J
jackzhang235 已提交
86
                                      DATALAYOUT(kNCHW))})
J
jackzhang235 已提交
87 88
    .BindOutput("Out",
                {LiteType::GetTensorTy(TARGET(kHost),
89
                                       PRECISION(kFP16),
J
jackzhang235 已提交
90 91
                                       DATALAYOUT(kNHWC))})
    .Finalize();
J
jackzhang235 已提交
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108

REGISTER_LITE_KERNEL(
    layout,
    kMLU,
    kInt8,
    kNHWC,
    paddle::lite::kernels::mlu::LayoutNchwToNhwcCompute<PRECISION(kInt8)>,
    def_layout_nchw2nhwc_fp32_int8)
    .BindInput("Input",
               {LiteType::GetTensorTy(TARGET(kHost),
                                      PRECISION(kInt8),
                                      DATALAYOUT(kNCHW))})
    .BindOutput("Out",
                {LiteType::GetTensorTy(TARGET(kHost),
                                       PRECISION(kInt8),
                                       DATALAYOUT(kNHWC))})
    .Finalize();