layout_compute.h 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// 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.

#pragma once
W
Wilber 已提交
16
#include "lite/backends/cuda/math/transpose.h"
17 18 19 20 21 22 23
#include "lite/core/kernel.h"

namespace paddle {
namespace lite {
namespace kernels {
namespace cuda {

Z
Zhaolong Xing 已提交
24
class NCHWToNHWCCompute : public KernelLite<TARGET(kCUDA), PRECISION(kFloat)> {
25 26 27
 public:
  using param_t = operators::LayoutParam;
  void Run() override;
Z
Zhaolong Xing 已提交
28
  virtual ~NCHWToNHWCCompute() = default;
W
Wilber 已提交
29 30 31

 private:
  lite::cuda::math::Transpose<float> trans;
32 33
};

Z
Zhaolong Xing 已提交
34 35
class NCHWToNHWCComputeInt8
    : public KernelLite<TARGET(kCUDA), PRECISION(kInt8)> {
36 37 38
 public:
  using param_t = operators::LayoutParam;
  void Run() override;
Z
Zhaolong Xing 已提交
39
  virtual ~NCHWToNHWCComputeInt8() = default;
W
Wilber 已提交
40 41 42

 private:
  lite::cuda::math::Transpose<int8_t> trans;
43 44
};

Z
Zhaolong Xing 已提交
45
class NHWCToNCHWCompute : public KernelLite<TARGET(kCUDA), PRECISION(kFloat)> {
46 47 48 49
 public:
  using param_t = operators::LayoutParam;
  void Run() override;
  virtual ~NHWCToNCHWCompute() = default;
W
Wilber 已提交
50 51 52

 private:
  lite::cuda::math::Transpose<float> trans;
53 54
};

Z
Zhaolong Xing 已提交
55 56 57 58 59 60
class NHWCToNCHWComputeInt8
    : public KernelLite<TARGET(kCUDA), PRECISION(kInt8)> {
 public:
  using param_t = operators::LayoutParam;
  void Run() override;
  virtual ~NHWCToNCHWComputeInt8() = default;
W
Wilber 已提交
61 62 63

 private:
  lite::cuda::math::Transpose<int8_t> trans;
Z
Zhaolong Xing 已提交
64 65
};

66 67 68 69
}  // namespace cuda
}  // namespace kernels
}  // namespace lite
}  // namespace paddle