0-hero's picture
Add files using upload-large-folder tool
d742687 verified
raw
history blame
7.91 kB
module {
tt.func public @triton__0d1d2d3d4d5d6de7de(%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<bf16, 1> {tt.divisibility = 16 : i32}, %arg4: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg5: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg6: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}, %arg7: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}) attributes {noinline = false} {
%cst = arith.constant dense<0.000000e+00> : tensor<2x256xbf16>
%cst_0 = arith.constant dense<1.000000e+00> : tensor<1x256xf32>
%cst_1 = arith.constant dense<0.000000e+00> : tensor<1x256xf32>
%cst_2 = arith.constant 0.000000e+00 : f32
%cst_3 = arith.constant dense<256> : tensor<2x1xi64>
%cst_4 = arith.constant dense<50257> : tensor<2x1xi64>
%cst_5 = arith.constant dense<0> : tensor<2x1xi64>
%cst_6 = arith.constant dense<9.99999974E-6> : tensor<2x1xf32>
%cst_7 = arith.constant dense<2.560000e+02> : tensor<2x1xf32>
%cst_8 = arith.constant dense<0.000000e+00> : tensor<2x256xf32>
%cst_9 = arith.constant dense<256> : tensor<2x1xi32>
%cst_10 = arith.constant dense<256> : tensor<1x256xi32>
%cst_11 = arith.constant dense<512> : tensor<2x1xi32>
%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>
%3 = tt.expand_dims %2 {axis = 1 : i32} : (tensor<2xi32>) -> tensor<2x1xi32>
%4 = tt.splat %1 : (i32) -> tensor<2x1xi32>
%5 = arith.addi %4, %3 : tensor<2x1xi32>
%6 = tt.make_range {end = 256 : i32, start = 0 : i32} : tensor<256xi32>
%7 = tt.expand_dims %6 {axis = 0 : i32} : (tensor<256xi32>) -> tensor<1x256xi32>
%8 = tt.splat %arg0 : (!tt.ptr<i64, 1>) -> tensor<2x1x!tt.ptr<i64, 1>>
%9 = tt.addptr %8, %5 : tensor<2x1x!tt.ptr<i64, 1>>, tensor<2x1xi32>
%10 = tt.load %9 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x1xi64>
%11 = arith.remsi %5, %cst_11 : tensor<2x1xi32>
%12 = arith.cmpi slt, %7, %cst_10 : tensor<1x256xi32>
%13 = arith.muli %11, %cst_9 : tensor<2x1xi32>
%14 = tt.broadcast %7 : (tensor<1x256xi32>) -> tensor<2x256xi32>
%15 = tt.broadcast %13 : (tensor<2x1xi32>) -> tensor<2x256xi32>
%16 = arith.addi %14, %15 : tensor<2x256xi32>
%17 = tt.splat %arg2 : (!tt.ptr<f32, 1>) -> tensor<2x256x!tt.ptr<f32, 1>>
%18 = tt.addptr %17, %16 : tensor<2x256x!tt.ptr<f32, 1>>, tensor<2x256xi32>
%19 = tt.broadcast %12 : (tensor<1x256xi1>) -> tensor<2x256xi1>
%20 = tt.load %18, %19, %cst_8 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x256xf32>
%21 = arith.muli %5, %cst_9 : tensor<2x1xi32>
%22 = tt.broadcast %21 : (tensor<2x1xi32>) -> tensor<2x256xi32>
%23 = arith.addi %14, %22 : tensor<2x256xi32>
%24 = tt.splat %arg3 : (!tt.ptr<bf16, 1>) -> tensor<2x256x!tt.ptr<bf16, 1>>
%25 = tt.addptr %24, %23 : tensor<2x256x!tt.ptr<bf16, 1>>, tensor<2x256xi32>
%26 = tt.load %25, %19, %cst {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x256xbf16>
%27 = arith.extf %26 : tensor<2x256xbf16> to tensor<2x256xf32>
%28 = arith.addi %10, %cst_4 : tensor<2x1xi64>
%29 = arith.cmpi slt, %10, %cst_5 : tensor<2x1xi64>
%30 = arith.select %29, %28, %10 : tensor<2x1xi1>, tensor<2x1xi64>
%31 = arith.cmpi sge, %30, %cst_5 : tensor<2x1xi64>
%32 = arith.cmpi slt, %30, %cst_4 : tensor<2x1xi64>
%33 = arith.andi %31, %32 : tensor<2x1xi1>
tt.assert %33, "index out of bounds: 0 <= tmp3 < 50257", "<frozen importlib._bootstrap_external>", "_call_with_frames_removed", 883 : tensor<2x1xi1>
%34 = arith.muli %30, %cst_3 : tensor<2x1xi64>
%35 = tt.broadcast %34 : (tensor<2x1xi64>) -> tensor<2x256xi64>
%36 = arith.extsi %7 : tensor<1x256xi32> to tensor<1x256xi64>
%37 = tt.broadcast %36 : (tensor<1x256xi64>) -> tensor<2x256xi64>
%38 = arith.addi %37, %35 : tensor<2x256xi64>
%39 = tt.splat %arg1 : (!tt.ptr<f32, 1>) -> tensor<2x256x!tt.ptr<f32, 1>>
%40 = tt.addptr %39, %38 : tensor<2x256x!tt.ptr<f32, 1>>, tensor<2x256xi64>
%41 = tt.load %40, %19, %cst_8 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x256xf32>
%42 = arith.addf %41, %20 : tensor<2x256xf32>
%43 = arith.addf %42, %27 : tensor<2x256xf32>
%44 = arith.addf %43, %cst_8 : tensor<2x256xf32>
%45 = arith.subf %43, %44 : tensor<2x256xf32>
%46 = arith.mulf %43, %45 : tensor<2x256xf32>
%47 = arith.addf %46, %cst_8 : tensor<2x256xf32>
%48 = arith.select %19, %44, %cst_8 : tensor<2x256xi1>, tensor<2x256xf32>
%49 = arith.select %19, %47, %cst_8 : tensor<2x256xi1>, tensor<2x256xf32>
%50 = arith.select %12, %cst_0, %cst_1 : tensor<1x256xi1>, tensor<1x256xf32>
%51 = tt.broadcast %50 : (tensor<1x256xf32>) -> tensor<2x256xf32>
%52:3 = "tt.reduce"(%48, %49, %51) <{axis = 1 : i32}> ({
^bb0(%arg8: f32, %arg9: f32, %arg10: f32, %arg11: f32, %arg12: f32, %arg13: f32):
%76 = arith.subf %arg11, %arg8 : f32
%77 = arith.addf %arg10, %arg13 : f32
%78 = arith.cmpf oeq, %77, %cst_2 : f32
%79 = arith.divf %arg13, %77 : f32
%80 = arith.select %78, %cst_2, %79 : f32
%81 = arith.mulf %76, %80 : f32
%82 = arith.addf %arg8, %81 : f32
%83 = arith.addf %arg9, %arg12 : f32
%84 = arith.mulf %76, %76 : f32
%85 = arith.mulf %84, %arg10 : f32
%86 = arith.mulf %85, %80 : f32
%87 = arith.addf %83, %86 : f32
tt.reduce.return %82, %87, %77 : f32, f32, f32
}) : (tensor<2x256xf32>, tensor<2x256xf32>, tensor<2x256xf32>) -> (tensor<2xf32>, tensor<2xf32>, tensor<2xf32>)
%53 = tt.expand_dims %52#0 {axis = 1 : i32} : (tensor<2xf32>) -> tensor<2x1xf32>
%54 = tt.expand_dims %52#1 {axis = 1 : i32} : (tensor<2xf32>) -> tensor<2x1xf32>
%55 = tt.load %18, %19, %cst_8 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x256xf32>
%56 = tt.load %25, %19, %cst {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<2x256xbf16>
%57 = arith.extf %56 : tensor<2x256xbf16> to tensor<2x256xf32>
%58 = tt.splat %arg4 : (!tt.ptr<f32, 1>) -> tensor<1x256x!tt.ptr<f32, 1>>
%59 = tt.addptr %58, %7 : tensor<1x256x!tt.ptr<f32, 1>>, tensor<1x256xi32>
%60 = tt.load %59, %12, %cst_1 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<1x256xf32>
tt.assert %33, "index out of bounds: 0 <= tmp16 < 50257", "<frozen importlib._bootstrap_external>", "_call_with_frames_removed", 883 : tensor<2x1xi1>
%61 = tt.load %40, %19, %cst_8 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<2x256xf32>
%62 = arith.addf %61, %55 : tensor<2x256xf32>
%63 = arith.addf %62, %57 : tensor<2x256xf32>
%64 = tt.broadcast %53 : (tensor<2x1xf32>) -> tensor<2x256xf32>
%65 = arith.subf %63, %64 : tensor<2x256xf32>
%66 = arith.divf %54, %cst_7 : tensor<2x1xf32>
%67 = arith.addf %66, %cst_6 : tensor<2x1xf32>
%68 = tt.extern_elementwise %67 {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>) -> tensor<2x1xf32>
%69 = tt.broadcast %68 : (tensor<2x1xf32>) -> tensor<2x256xf32>
%70 = arith.mulf %65, %69 : tensor<2x256xf32>
%71 = tt.broadcast %60 : (tensor<1x256xf32>) -> tensor<2x256xf32>
%72 = arith.mulf %70, %71 : tensor<2x256xf32>
%73 = tt.splat %arg5 : (!tt.ptr<bf16, 1>) -> tensor<2x256x!tt.ptr<bf16, 1>>
%74 = tt.addptr %73, %23 : tensor<2x256x!tt.ptr<bf16, 1>>, tensor<2x256xi32>
%75 = arith.truncf %72 : tensor<2x256xf32> to tensor<2x256xbf16>
tt.store %74, %75, %19 {cache = 1 : i32, evict = 1 : i32} : tensor<2x256xbf16>
tt.return
}
}