norm.h 4.41 KB
Newer Older
Xiaowei.zhang's avatar
Xiaowei.zhang committed
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
// SPDX-License-Identifier: MIT
 
#include <torch/extension.h>

// void layernorm2d(torch::Tensor &out, torch::Tensor &input, torch::Tensor &weight, torch::Tensor &bias, double epsilon);
torch::Tensor layernorm2d(torch::Tensor &input,
                          torch::Tensor &weight,
                          torch::Tensor &bias,
                          double epsilon,
                          std::optional<torch::Tensor> x_bias);

void layernorm2d_with_add(torch::Tensor &out,
                          torch::Tensor &input,
                          torch::Tensor &residual_in,
                          torch::Tensor &residual_out,
                          torch::Tensor &weight,
                          torch::Tensor &bias,
                          double epsilon,
                          std::optional<torch::Tensor> x_bias);

void layernorm2d_with_smoothquant(torch::Tensor &out,    // [m ,n]
                                  torch::Tensor &input,  // [m ,n]
                                  torch::Tensor &xscale, // [1 ,n]
                                  torch::Tensor &yscale, // [m ,1]
                                  torch::Tensor &weight, // [1 ,n]
                                  torch::Tensor &bias,   // [1 ,n]
                                  double epsilon,
                                  std::optional<torch::Tensor> x_bias);

void layernorm2d_with_add_smoothquant(torch::Tensor &out,          // [m ,n]
                                      torch::Tensor &input,        // [m ,n]
                                      torch::Tensor &residual_in,  // [m ,n]
                                      torch::Tensor &residual_out, // [m ,n]
                                      torch::Tensor &xscale,       // [1 ,n]
                                      torch::Tensor &yscale,       // [m ,1]
                                      torch::Tensor &weight,       // [1 ,n]
                                      torch::Tensor &bias,         // [1 ,n]
                                      double epsilon,
                                      std::optional<torch::Tensor> x_bias);
void layernorm2d_with_dynamicquant(torch::Tensor &out,    // [m ,n]
                                   torch::Tensor &input,  // [m ,n]
                                   torch::Tensor &yscale, // [m ,1]
                                   torch::Tensor &weight, // [1 ,n]
                                   torch::Tensor &bias,   // [1 ,n]
                                   double epsilon,
                                   std::optional<torch::Tensor> x_bias);
void layernorm2d_with_add_dynamicquant(torch::Tensor &out,          // [m ,n]
                                       torch::Tensor &input,        // [m ,n]
                                       torch::Tensor &residual_in,  // [m ,n]
                                       torch::Tensor &residual_out, // [m ,n]
                                       torch::Tensor &yscale,       // [m ,1]
                                       torch::Tensor &weight,       // [1 ,n]
                                       torch::Tensor &bias,         // [1 ,n]
                                       double epsilon,
                                       std::optional<torch::Tensor> x_bias);

// following are asm kernels
// void layernorm2d_with_add_asm(torch::Tensor &out,          // [m ,n]
//                               torch::Tensor &input,        // [m ,n]
//                               torch::Tensor &residual_in,  // [m ,n]
//                               torch::Tensor &residual_out, // [m ,n]
//                               torch::Tensor &weight,       // [1 ,n]
//                               torch::Tensor &bias,         // [1 ,n]
//                               float epsilon);
// void layernorm2d_with_add_smoothquant_asm(torch::Tensor &out,          // [m ,n]
//                                           torch::Tensor &input,        // [m ,n]
//                                           torch::Tensor &residual_in,  // [m ,n]
//                                           torch::Tensor &residual_out, // [m ,n]
//                                           torch::Tensor &xscale,       // [1 ,n]
//                                           torch::Tensor &yscale,       // [m ,1]
//                                           torch::Tensor &weight,       // [1 ,n]
//                                           torch::Tensor &bias,         // [1 ,n]
//                                           float epsilon);