File size: 7,391 Bytes
c1384fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#blocked = #triton_gpu.blocked<{sizePerThread = [4], threadsPerWarp = [32], warpsPerCTA = [2], order = [0], CTAsPerCGA = [1], CTASplitNum = [1], CTAOrder = [0]}>
#blocked1 = #triton_gpu.blocked<{sizePerThread = [1], threadsPerWarp = [32], warpsPerCTA = [2], order = [0], CTAsPerCGA = [1], CTASplitNum = [1], CTAOrder = [0]}>
module attributes {"triton_gpu.compute-capability" = 89 : i32, "triton_gpu.num-ctas" = 1 : i32, "triton_gpu.num-warps" = 2 : i32, "triton_gpu.threads-per-warp" = 32 : i32} {
  tt.func public @triton__0d1d2d3d4d5d6d7d8de9de(%arg0: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg1: !tt.ptr<i64, 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<f32, 1> {tt.divisibility = 16 : i32}, %arg5: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg6: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg7: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg8: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}, %arg9: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}) attributes {noinline = false} {
    %cst = arith.constant dense<256> : tensor<256xi32, #blocked>
    %cst_0 = arith.constant dense<0> : tensor<1xi64, #blocked>
    %cst_1 = arith.constant dense<50257> : tensor<1xi64, #blocked>
    %cst_2 = arith.constant dense<256> : tensor<1xi64, #blocked>
    %cst_3 = arith.constant 9.99999974E-6 : f32
    %cst_4 = arith.constant 2.560000e+02 : f32
    %cst_5 = arith.constant 0.000000e+00 : f32
    %c256_i32 = arith.constant 256 : i32
    %c512_i32 = arith.constant 512 : i32
    %cst_6 = arith.constant dense<50257> : tensor<1xi64, #blocked1>
    %cst_7 = arith.constant dense<0> : tensor<1xi64, #blocked1>
    %cst_8 = arith.constant dense<0.000000e+00> : tensor<256xf32, #blocked>
    %0 = tt.get_program_id x : i32
    %1 = tt.make_range {end = 256 : i32, start = 0 : i32} : tensor<256xi32, #blocked>
    %2 = arith.cmpi slt, %1, %cst : tensor<256xi32, #blocked>
    %3 = arith.remsi %0, %c512_i32 : i32
    %4 = tt.addptr %arg1, %0 : !tt.ptr<i64, 1>, i32
    %5 = tt.splat %4 : (!tt.ptr<i64, 1>) -> tensor<1x!tt.ptr<i64, 1>, #blocked>
    %6 = tt.splat %4 : (!tt.ptr<i64, 1>) -> tensor<1x!tt.ptr<i64, 1>, #blocked1>
    %7 = tt.load %5 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<1xi64, #blocked>
    %8 = tt.load %6 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<1xi64, #blocked1>
    %9 = arith.muli %3, %c256_i32 : i32
    %10 = tt.splat %9 : (i32) -> tensor<256xi32, #blocked>
    %11 = arith.addi %1, %10 : tensor<256xi32, #blocked>
    %12 = tt.splat %arg3 : (!tt.ptr<f32, 1>) -> tensor<256x!tt.ptr<f32, 1>, #blocked>
    %13 = tt.addptr %12, %11 : tensor<256x!tt.ptr<f32, 1>, #blocked>, tensor<256xi32, #blocked>
    %14 = tt.load %13, %2, %cst_8 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<256xf32, #blocked>
    %15 = tt.splat %arg4 : (!tt.ptr<f32, 1>) -> tensor<256x!tt.ptr<f32, 1>, #blocked>
    %16 = tt.addptr %15, %1 : tensor<256x!tt.ptr<f32, 1>, #blocked>, tensor<256xi32, #blocked>
    %17 = tt.load %16, %2, %cst_8 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<256xf32, #blocked>
    %18 = arith.addi %7, %cst_1 : tensor<1xi64, #blocked>
    %19 = arith.addi %8, %cst_6 : tensor<1xi64, #blocked1>
    %20 = arith.cmpi slt, %7, %cst_0 : tensor<1xi64, #blocked>
    %21 = arith.cmpi slt, %8, %cst_7 : tensor<1xi64, #blocked1>
    %22 = arith.select %20, %18, %7 : tensor<1xi1, #blocked>, tensor<1xi64, #blocked>
    %23 = arith.select %21, %19, %8 : tensor<1xi1, #blocked1>, tensor<1xi64, #blocked1>
    %24 = arith.cmpi sge, %23, %cst_7 : tensor<1xi64, #blocked1>
    %25 = arith.cmpi slt, %23, %cst_6 : tensor<1xi64, #blocked1>
    %26 = arith.andi %24, %25 : tensor<1xi1, #blocked1>
    tt.assert %26, "index out of bounds: 0 <= tmp3 < 50257", "<frozen importlib._bootstrap_external>", "_call_with_frames_removed", 883 : tensor<1xi1, #blocked1>
    %27 = arith.muli %22, %cst_2 : tensor<1xi64, #blocked>
    %28 = tt.broadcast %27 : (tensor<1xi64, #blocked>) -> tensor<256xi64, #blocked>
    %29 = arith.extsi %1 : tensor<256xi32, #blocked> to tensor<256xi64, #blocked>
    %30 = arith.addi %29, %28 : tensor<256xi64, #blocked>
    %31 = tt.splat %arg2 : (!tt.ptr<f32, 1>) -> tensor<256x!tt.ptr<f32, 1>, #blocked>
    %32 = tt.addptr %31, %30 : tensor<256x!tt.ptr<f32, 1>, #blocked>, tensor<256xi64, #blocked>
    %33 = tt.load %32, %2, %cst_8 {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<256xf32, #blocked>
    %34 = arith.addf %33, %14 : tensor<256xf32, #blocked>
    %35 = arith.select %2, %34, %cst_8 : tensor<256xi1, #blocked>, tensor<256xf32, #blocked>
    %36 = "tt.reduce"(%35) <{axis = 0 : i32}> ({
    ^bb0(%arg10: f32, %arg11: f32):
      %65 = arith.addf %arg10, %arg11 : f32
      tt.reduce.return %65 : f32
    }) : (tensor<256xf32, #blocked>) -> f32
    %37 = arith.addf %36, %cst_5 : f32
    %38 = arith.divf %37, %cst_4 : f32
    %39 = tt.splat %38 : (f32) -> tensor<1xf32, #blocked1>
    %40 = tt.splat %38 : (f32) -> tensor<256xf32, #blocked>
    %41 = arith.subf %34, %40 : tensor<256xf32, #blocked>
    %42 = arith.mulf %41, %41 : tensor<256xf32, #blocked>
    %43 = arith.select %2, %42, %cst_8 : tensor<256xi1, #blocked>, tensor<256xf32, #blocked>
    %44 = "tt.reduce"(%43) <{axis = 0 : i32}> ({
    ^bb0(%arg10: f32, %arg11: f32):
      %65 = arith.addf %arg10, %arg11 : f32
      tt.reduce.return %65 : f32
    }) : (tensor<256xf32, #blocked>) -> f32
    %45 = arith.addf %44, %cst_5 : f32
    %46 = arith.divf %45, %cst_4 : f32
    %47 = arith.addf %46, %cst_3 : f32
    %48 = tt.extern_elementwise %47 {libname = "libdevice", libpath = "/usr/local/lib/python3.10/dist-packages/triton/language/../third_party/cuda/lib/libdevice.10.bc", pure = true, symbol = "__nv_rsqrtf"} : (f32) -> f32
    %49 = tt.splat %48 : (f32) -> tensor<1xf32, #blocked1>
    %50 = tt.splat %48 : (f32) -> tensor<256xf32, #blocked>
    %51 = arith.mulf %41, %50 : tensor<256xf32, #blocked>
    %52 = arith.mulf %51, %17 : tensor<256xf32, #blocked>
    %53 = arith.muli %0, %c256_i32 : i32
    %54 = tt.splat %53 : (i32) -> tensor<256xi32, #blocked>
    %55 = arith.addi %1, %54 : tensor<256xi32, #blocked>
    %56 = tt.splat %arg5 : (!tt.ptr<f32, 1>) -> tensor<256x!tt.ptr<f32, 1>, #blocked>
    %57 = tt.addptr %56, %55 : tensor<256x!tt.ptr<f32, 1>, #blocked>, tensor<256xi32, #blocked>
    tt.store %57, %34, %2 {cache = 1 : i32, evict = 1 : i32} : tensor<256xf32, #blocked>
    gpu.barrier
    %58 = tt.addptr %arg0, %0 : !tt.ptr<f32, 1>, i32
    %59 = tt.splat %58 : (!tt.ptr<f32, 1>) -> tensor<1x!tt.ptr<f32, 1>, #blocked1>
    tt.store %59, %49 {cache = 1 : i32, evict = 1 : i32} : tensor<1xf32, #blocked1>
    %60 = tt.splat %arg7 : (!tt.ptr<bf16, 1>) -> tensor<256x!tt.ptr<bf16, 1>, #blocked>
    %61 = tt.addptr %60, %55 : tensor<256x!tt.ptr<bf16, 1>, #blocked>, tensor<256xi32, #blocked>
    %62 = arith.truncf %52 : tensor<256xf32, #blocked> to tensor<256xbf16, #blocked>
    tt.store %61, %62, %2 {cache = 1 : i32, evict = 1 : i32} : tensor<256xbf16, #blocked>
    %63 = tt.addptr %arg6, %0 : !tt.ptr<f32, 1>, i32
    %64 = tt.splat %63 : (!tt.ptr<f32, 1>) -> tensor<1x!tt.ptr<f32, 1>, #blocked1>
    tt.store %64, %39 {cache = 1 : i32, evict = 1 : i32} : tensor<1xf32, #blocked1>
    tt.return
  }
}