File size: 11,002 Bytes
d742687
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#blocked = #triton_gpu.blocked<{sizePerThread = [1, 4], threadsPerWarp = [1, 32], warpsPerCTA = [2, 2], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [1, 0]}>
#blocked1 = #triton_gpu.blocked<{sizePerThread = [1, 2], threadsPerWarp = [1, 32], warpsPerCTA = [1, 4], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [1, 0]}>
#blocked2 = #triton_gpu.blocked<{sizePerThread = [1, 1], threadsPerWarp = [32, 1], warpsPerCTA = [4, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [1, 0]}>
module attributes {"triton_gpu.compute-capability" = 89 : i32, "triton_gpu.num-ctas" = 1 : i32, "triton_gpu.num-warps" = 4 : i32, "triton_gpu.threads-per-warp" = 32 : i32} {
  tt.func public @triton__0d1d2d3d4d5de6de(%arg0: !tt.ptr<i64, 1> {tt.divisibility = 16 : i32}, %arg1: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg2: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg3: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg4: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg5: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}, %arg6: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}) attributes {noinline = false} {
    %cst = arith.constant dense<512> : tensor<2x1xi32, #blocked>
    %cst_0 = arith.constant dense<256> : tensor<1x256xi32, #blocked>
    %cst_1 = arith.constant dense<256> : tensor<1x256xi32, #blocked1>
    %cst_2 = arith.constant dense<256> : tensor<2x1xi32, #blocked>
    %cst_3 = arith.constant dense<1.000000e+00> : tensor<1x256xf32, #blocked>
    %cst_4 = arith.constant dense<0.000000e+00> : tensor<1x256xf32, #blocked>
    %cst_5 = arith.constant dense<256> : tensor<2x1xi64, #blocked>
    %cst_6 = arith.constant dense<50257> : tensor<2x1xi64, #blocked>
    %cst_7 = arith.constant dense<0> : tensor<2x1xi64, #blocked>
    %cst_8 = arith.constant dense<0> : tensor<2x1xi64, #blocked2>
    %cst_9 = arith.constant dense<50257> : tensor<2x1xi64, #blocked2>
    %cst_10 = arith.constant 0.000000e+00 : f32
    %cst_11 = arith.constant dense<9.99999974E-6> : tensor<2x1xf32, #blocked>
    %cst_12 = arith.constant dense<2.560000e+02> : tensor<2x1xf32, #blocked>
    %cst_13 = arith.constant dense<0.000000e+00> : tensor<2x256xf32, #blocked>
    %cst_14 = arith.constant dense<0.000000e+00> : tensor<1x256xf32, #blocked1>
    %c2_i32 = arith.constant 2 : i32
    %0 = tt.get_program_id x : i32
    %1 = arith.muli %0, %c2_i32 : i32
    %2 = tt.make_range {end = 2 : i32, start = 0 : i32} : tensor<2xi32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>
    %3 = tt.make_range {end = 2 : i32, start = 0 : i32} : tensor<2xi32, #triton_gpu.slice<{dim = 1, parent = #blocked2}>>
    %4 = tt.expand_dims %2 {axis = 1 : i32} : (tensor<2xi32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>) -> tensor<2x1xi32, #blocked>
    %5 = tt.expand_dims %3 {axis = 1 : i32} : (tensor<2xi32, #triton_gpu.slice<{dim = 1, parent = #blocked2}>>) -> tensor<2x1xi32, #blocked2>
    %6 = tt.splat %1 : (i32) -> tensor<2x1xi32, #blocked>
    %7 = tt.splat %1 : (i32) -> tensor<2x1xi32, #blocked2>
    %8 = arith.addi %6, %4 : tensor<2x1xi32, #blocked>
    %9 = arith.addi %7, %5 : tensor<2x1xi32, #blocked2>
    %10 = tt.make_range {end = 256 : i32, start = 0 : i32} : tensor<256xi32, #triton_gpu.slice<{dim = 0, parent = #blocked}>>
    %11 = tt.make_range {end = 256 : i32, start = 0 : i32} : tensor<256xi32, #triton_gpu.slice<{dim = 0, parent = #blocked1}>>
    %12 = tt.expand_dims %10 {axis = 0 : i32} : (tensor<256xi32, #triton_gpu.slice<{dim = 0, parent = #blocked}>>) -> tensor<1x256xi32, #blocked>
    %13 = tt.expand_dims %11 {axis = 0 : i32} : (tensor<256xi32, #triton_gpu.slice<{dim = 0, parent = #blocked1}>>) -> tensor<1x256xi32, #blocked1>
    %14 = tt.splat %arg0 : (!tt.ptr<i64, 1>) -> tensor<2x1x!tt.ptr<i64, 1>, #blocked>
    %15 = tt.splat %arg0 : (!tt.ptr<i64, 1>) -> tensor<2x1x!tt.ptr<i64, 1>, #blocked2>
    %16 = tt.addptr %14, %8 : tensor<2x1x!tt.ptr<i64, 1>, #blocked>, tensor<2x1xi32, #blocked>
    %17 = tt.addptr %15, %9 : tensor<2x1x!tt.ptr<i64, 1>, #blocked2>, tensor<2x1xi32, #blocked2>
    %18 = tt.load %16 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x1xi64, #blocked>
    %19 = tt.load %17 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x1xi64, #blocked2>
    %20 = arith.remsi %8, %cst : tensor<2x1xi32, #blocked>
    %21 = arith.cmpi slt, %12, %cst_0 : tensor<1x256xi32, #blocked>
    %22 = arith.cmpi slt, %13, %cst_1 : tensor<1x256xi32, #blocked1>
    %23 = arith.muli %20, %cst_2 : tensor<2x1xi32, #blocked>
    %24 = tt.broadcast %12 : (tensor<1x256xi32, #blocked>) -> tensor<2x256xi32, #blocked>
    %25 = tt.broadcast %23 : (tensor<2x1xi32, #blocked>) -> tensor<2x256xi32, #blocked>
    %26 = arith.addi %24, %25 : tensor<2x256xi32, #blocked>
    %27 = tt.splat %arg2 : (!tt.ptr<f32, 1>) -> tensor<2x256x!tt.ptr<f32, 1>, #blocked>
    %28 = tt.addptr %27, %26 : tensor<2x256x!tt.ptr<f32, 1>, #blocked>, tensor<2x256xi32, #blocked>
    %29 = tt.broadcast %21 : (tensor<1x256xi1, #blocked>) -> tensor<2x256xi1, #blocked>
    %30 = tt.load %28, %29, %cst_13 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x256xf32, #blocked>
    %31 = arith.addi %18, %cst_6 : tensor<2x1xi64, #blocked>
    %32 = arith.addi %19, %cst_9 : tensor<2x1xi64, #blocked2>
    %33 = arith.cmpi slt, %18, %cst_7 : tensor<2x1xi64, #blocked>
    %34 = arith.cmpi slt, %19, %cst_8 : tensor<2x1xi64, #blocked2>
    %35 = arith.select %33, %31, %18 : tensor<2x1xi1, #blocked>, tensor<2x1xi64, #blocked>
    %36 = arith.select %34, %32, %19 : tensor<2x1xi1, #blocked2>, tensor<2x1xi64, #blocked2>
    %37 = arith.cmpi sge, %36, %cst_8 : tensor<2x1xi64, #blocked2>
    %38 = arith.cmpi slt, %36, %cst_9 : tensor<2x1xi64, #blocked2>
    %39 = arith.andi %37, %38 : tensor<2x1xi1, #blocked2>
    tt.assert %39, "index out of bounds: 0 <= tmp3 < 50257", "<frozen importlib._bootstrap_external>", "_call_with_frames_removed", 883 : tensor<2x1xi1, #blocked2>
    %40 = arith.muli %35, %cst_5 : tensor<2x1xi64, #blocked>
    %41 = tt.broadcast %40 : (tensor<2x1xi64, #blocked>) -> tensor<2x256xi64, #blocked>
    %42 = arith.extsi %12 : tensor<1x256xi32, #blocked> to tensor<1x256xi64, #blocked>
    %43 = tt.broadcast %42 : (tensor<1x256xi64, #blocked>) -> tensor<2x256xi64, #blocked>
    %44 = arith.addi %43, %41 : tensor<2x256xi64, #blocked>
    %45 = tt.splat %arg1 : (!tt.ptr<f32, 1>) -> tensor<2x256x!tt.ptr<f32, 1>, #blocked>
    %46 = tt.addptr %45, %44 : tensor<2x256x!tt.ptr<f32, 1>, #blocked>, tensor<2x256xi64, #blocked>
    %47 = tt.load %46, %29, %cst_13 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x256xf32, #blocked>
    %48 = arith.addf %47, %30 : tensor<2x256xf32, #blocked>
    %49 = arith.addf %48, %cst_13 : tensor<2x256xf32, #blocked>
    %50 = arith.subf %48, %49 : tensor<2x256xf32, #blocked>
    %51 = arith.mulf %48, %50 : tensor<2x256xf32, #blocked>
    %52 = arith.addf %51, %cst_13 : tensor<2x256xf32, #blocked>
    %53 = arith.select %29, %49, %cst_13 : tensor<2x256xi1, #blocked>, tensor<2x256xf32, #blocked>
    %54 = arith.select %29, %52, %cst_13 : tensor<2x256xi1, #blocked>, tensor<2x256xf32, #blocked>
    %55 = arith.select %21, %cst_3, %cst_4 : tensor<1x256xi1, #blocked>, tensor<1x256xf32, #blocked>
    %56 = tt.broadcast %55 : (tensor<1x256xf32, #blocked>) -> tensor<2x256xf32, #blocked>
    %57:3 = "tt.reduce"(%53, %54, %56) <{axis = 1 : i32}> ({
    ^bb0(%arg7: f32, %arg8: f32, %arg9: f32, %arg10: f32, %arg11: f32, %arg12: f32):
      %82 = arith.subf %arg10, %arg7 : f32
      %83 = arith.addf %arg9, %arg12 : f32
      %84 = arith.cmpf oeq, %83, %cst_10 : f32
      %85 = arith.divf %arg12, %83 : f32
      %86 = arith.select %84, %cst_10, %85 : f32
      %87 = arith.mulf %82, %86 : f32
      %88 = arith.addf %arg7, %87 : f32
      %89 = arith.addf %arg8, %arg11 : f32
      %90 = arith.mulf %82, %82 : f32
      %91 = arith.mulf %90, %arg9 : f32
      %92 = arith.mulf %91, %86 : f32
      %93 = arith.addf %89, %92 : f32
      tt.reduce.return %88, %93, %83 : f32, f32, f32
    }) : (tensor<2x256xf32, #blocked>, tensor<2x256xf32, #blocked>, tensor<2x256xf32, #blocked>) -> (tensor<2xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>, tensor<2xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>, tensor<2xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>)
    %58 = tt.expand_dims %57#0 {axis = 1 : i32} : (tensor<2xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>) -> tensor<2x1xf32, #blocked>
    %59 = tt.expand_dims %57#1 {axis = 1 : i32} : (tensor<2xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>) -> tensor<2x1xf32, #blocked>
    %60 = tt.load %28, %29, %cst_13 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x256xf32, #blocked>
    %61 = tt.splat %arg3 : (!tt.ptr<f32, 1>) -> tensor<1x256x!tt.ptr<f32, 1>, #blocked1>
    %62 = tt.addptr %61, %13 : tensor<1x256x!tt.ptr<f32, 1>, #blocked1>, tensor<1x256xi32, #blocked1>
    %63 = tt.load %62, %22, %cst_14 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<1x256xf32, #blocked1>
    tt.assert %39, "index out of bounds: 0 <= tmp13 < 50257", "<frozen importlib._bootstrap_external>", "_call_with_frames_removed", 883 : tensor<2x1xi1, #blocked2>
    %64 = tt.load %46, %29, %cst_13 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<2x256xf32, #blocked>
    %65 = arith.addf %64, %60 : tensor<2x256xf32, #blocked>
    %66 = tt.broadcast %58 : (tensor<2x1xf32, #blocked>) -> tensor<2x256xf32, #blocked>
    %67 = arith.subf %65, %66 : tensor<2x256xf32, #blocked>
    %68 = arith.divf %59, %cst_12 : tensor<2x1xf32, #blocked>
    %69 = arith.addf %68, %cst_11 : tensor<2x1xf32, #blocked>
    %70 = tt.extern_elementwise %69 {libname = "libdevice", libpath = "/usr/local/lib/python3.10/dist-packages/triton/language/../third_party/cuda/lib/libdevice.10.bc", pure = true, symbol = "__nv_rsqrtf"} : (tensor<2x1xf32, #blocked>) -> tensor<2x1xf32, #blocked>
    %71 = tt.broadcast %70 : (tensor<2x1xf32, #blocked>) -> tensor<2x256xf32, #blocked>
    %72 = arith.mulf %67, %71 : tensor<2x256xf32, #blocked>
    %73 = triton_gpu.convert_layout %63 : (tensor<1x256xf32, #blocked1>) -> tensor<1x256xf32, #blocked>
    %74 = tt.broadcast %73 : (tensor<1x256xf32, #blocked>) -> tensor<2x256xf32, #blocked>
    %75 = arith.mulf %72, %74 : tensor<2x256xf32, #blocked>
    %76 = arith.muli %8, %cst_2 : tensor<2x1xi32, #blocked>
    %77 = tt.broadcast %76 : (tensor<2x1xi32, #blocked>) -> tensor<2x256xi32, #blocked>
    %78 = arith.addi %24, %77 : tensor<2x256xi32, #blocked>
    %79 = tt.splat %arg4 : (!tt.ptr<bf16, 1>) -> tensor<2x256x!tt.ptr<bf16, 1>, #blocked>
    %80 = tt.addptr %79, %78 : tensor<2x256x!tt.ptr<bf16, 1>, #blocked>, tensor<2x256xi32, #blocked>
    %81 = arith.truncf %75 : tensor<2x256xf32, #blocked> to tensor<2x256xbf16, #blocked>
    tt.store %80, %81, %29 {cache = 1 : i32, evict = 1 : i32} : tensor<2x256xbf16, #blocked>
    tt.return
  }
}