helper_primitives.h 1.7 KB
Newer Older
1
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
F
Feng Xing 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
//
// 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

17
namespace phi {
18
namespace kps {
19

20
#ifdef PADDLE_WITH_XPU_KP
21 22 23 24
struct dim3 {
  int x;
  int y;
  int z;
25

26
  explicit inline dim3(int split_x = 1, int split_y = 1, int split_z = 1) {
27 28 29
    x = split_x;
    y = split_y;
    z = split_z;
30 31
  }
};
32
#endif
33

34 35 36 37 38 39 40 41 42 43
struct DimConfig {
  int split_num_x;
  int split_num_y;
  int split_num_z;
  int deal_size_x;
  int deal_size_y;
  int deal_size_z;
  int rem_x;
  int rem_y;
  int rem_z;
44

45 46 47 48 49 50
  HOSTDEVICE explicit inline DimConfig(int split_x,
                                       int split_y,
                                       int split_z,
                                       int size_x,
                                       int size_y,
                                       int size_z) {
51 52 53 54 55 56
    split_num_x = split_x;
    split_num_y = split_y;
    split_num_z = split_z;
    deal_size_x = size_x;
    deal_size_y = size_y;
    deal_size_z = size_z;
57 58
  }

59 60 61 62
  HOSTDEVICE void SetRem(int rem_nx, int rem_ny, int rem_nz) {
    rem_x = rem_nx;
    rem_y = rem_ny;
    rem_z = rem_nz;
63 64 65
  }
};

66
}  // namespace kps
67
}  // namespace phi