0-hero's picture
Add files using upload-large-folder tool
d742687 verified
raw
history blame
11.9 kB
#blocked = #triton_gpu.blocked<{sizePerThread = [1, 1], threadsPerWarp = [8, 4], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [1, 0]}>
#blocked1 = #triton_gpu.blocked<{sizePerThread = [1, 1], threadsPerWarp = [32, 1], warpsPerCTA = [8, 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" = 8 : 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<64x1xi32, #blocked>
%cst_0 = arith.constant dense<256> : tensor<64x1xi32, #blocked>
%cst_1 = arith.constant dense<256> : tensor<64x1xi64, #blocked>
%cst_2 = arith.constant dense<0> : tensor<64x1xi64, #blocked>
%cst_3 = arith.constant dense<50257> : tensor<64x1xi64, #blocked>
%cst_4 = arith.constant dense<50257> : tensor<64x1xi64, #blocked1>
%cst_5 = arith.constant dense<0> : tensor<64x1xi64, #blocked1>
%c0_i32 = arith.constant 0 : i32
%c4_i32 = arith.constant 4 : i32
%c256_i32 = arith.constant 256 : i32
%cst_6 = arith.constant dense<1.000000e+00> : tensor<64x4xf32, #blocked>
%cst_7 = arith.constant 0.000000e+00 : f32
%cst_8 = arith.constant dense<0.000000e+00> : tensor<1x4xf32, #blocked>
%cst_9 = arith.constant dense<0.000000e+00> : tensor<64x4xf32, #blocked>
%cst_10 = arith.constant dense<256> : tensor<1x4xi32, #blocked>
%cst_11 = arith.constant dense<9.99999974E-6> : tensor<64x1xf32, #blocked>
%cst_12 = arith.constant dense<2.560000e+02> : tensor<64x1xf32, #blocked>
%c64_i32 = arith.constant 64 : i32
%0 = tt.get_program_id x : i32
%1 = arith.muli %0, %c64_i32 : i32
%2 = tt.make_range {end = 64 : i32, start = 0 : i32} : tensor<64xi32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>
%3 = tt.make_range {end = 64 : i32, start = 0 : i32} : tensor<64xi32, #triton_gpu.slice<{dim = 1, parent = #blocked1}>>
%4 = tt.expand_dims %2 {axis = 1 : i32} : (tensor<64xi32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>) -> tensor<64x1xi32, #blocked>
%5 = tt.expand_dims %3 {axis = 1 : i32} : (tensor<64xi32, #triton_gpu.slice<{dim = 1, parent = #blocked1}>>) -> tensor<64x1xi32, #blocked1>
%6 = tt.splat %1 : (i32) -> tensor<64x1xi32, #blocked>
%7 = tt.splat %1 : (i32) -> tensor<64x1xi32, #blocked1>
%8 = arith.addi %6, %4 : tensor<64x1xi32, #blocked>
%9 = arith.addi %7, %5 : tensor<64x1xi32, #blocked1>
%10 = tt.make_range {end = 4 : i32, start = 0 : i32} : tensor<4xi32, #triton_gpu.slice<{dim = 0, parent = #blocked}>>
%11 = tt.expand_dims %10 {axis = 0 : i32} : (tensor<4xi32, #triton_gpu.slice<{dim = 0, parent = #blocked}>>) -> tensor<1x4xi32, #blocked>
%12 = tt.splat %arg0 : (!tt.ptr<i64, 1>) -> tensor<64x1x!tt.ptr<i64, 1>, #blocked>
%13 = tt.splat %arg0 : (!tt.ptr<i64, 1>) -> tensor<64x1x!tt.ptr<i64, 1>, #blocked1>
%14 = tt.addptr %12, %8 : tensor<64x1x!tt.ptr<i64, 1>, #blocked>, tensor<64x1xi32, #blocked>
%15 = tt.addptr %13, %9 : tensor<64x1x!tt.ptr<i64, 1>, #blocked1>, tensor<64x1xi32, #blocked1>
%16 = tt.load %14 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<64x1xi64, #blocked>
%17 = tt.load %15 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<64x1xi64, #blocked1>
%18 = arith.remsi %8, %cst : tensor<64x1xi32, #blocked>
%19 = arith.muli %18, %cst_0 : tensor<64x1xi32, #blocked>
%20 = tt.broadcast %19 : (tensor<64x1xi32, #blocked>) -> tensor<64x4xi32, #blocked>
%21 = tt.splat %arg2 : (!tt.ptr<f32, 1>) -> tensor<64x4x!tt.ptr<f32, 1>, #blocked>
%22 = arith.addi %16, %cst_3 : tensor<64x1xi64, #blocked>
%23 = arith.addi %17, %cst_4 : tensor<64x1xi64, #blocked1>
%24 = arith.cmpi slt, %16, %cst_2 : tensor<64x1xi64, #blocked>
%25 = arith.cmpi slt, %17, %cst_5 : tensor<64x1xi64, #blocked1>
%26 = arith.select %24, %22, %16 : tensor<64x1xi1, #blocked>, tensor<64x1xi64, #blocked>
%27 = arith.select %25, %23, %17 : tensor<64x1xi1, #blocked1>, tensor<64x1xi64, #blocked1>
%28 = arith.cmpi sge, %27, %cst_5 : tensor<64x1xi64, #blocked1>
%29 = arith.cmpi slt, %27, %cst_4 : tensor<64x1xi64, #blocked1>
%30 = arith.andi %28, %29 : tensor<64x1xi1, #blocked1>
%31 = arith.muli %26, %cst_1 : tensor<64x1xi64, #blocked>
%32 = tt.broadcast %31 : (tensor<64x1xi64, #blocked>) -> tensor<64x4xi64, #blocked>
%33 = tt.splat %arg1 : (!tt.ptr<f32, 1>) -> tensor<64x4x!tt.ptr<f32, 1>, #blocked>
%34:3 = scf.for %arg7 = %c0_i32 to %c256_i32 step %c4_i32 iter_args(%arg8 = %cst_9, %arg9 = %cst_9, %arg10 = %cst_9) -> (tensor<64x4xf32, #blocked>, tensor<64x4xf32, #blocked>, tensor<64x4xf32, #blocked>) : i32 {
%45 = tt.splat %arg7 : (i32) -> tensor<1x4xi32, #blocked>
%46 = arith.addi %45, %11 : tensor<1x4xi32, #blocked>
%47 = arith.cmpi slt, %46, %cst_10 : tensor<1x4xi32, #blocked>
%48 = tt.broadcast %46 : (tensor<1x4xi32, #blocked>) -> tensor<64x4xi32, #blocked>
%49 = arith.addi %48, %20 : tensor<64x4xi32, #blocked>
%50 = tt.addptr %21, %49 : tensor<64x4x!tt.ptr<f32, 1>, #blocked>, tensor<64x4xi32, #blocked>
%51 = tt.broadcast %47 : (tensor<1x4xi1, #blocked>) -> tensor<64x4xi1, #blocked>
%52 = tt.load %50, %51, %cst_9 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<64x4xf32, #blocked>
tt.assert %30, "index out of bounds: 0 <= tmp3 < 50257", "<frozen importlib._bootstrap_external>", "_call_with_frames_removed", 883 : tensor<64x1xi1, #blocked1>
%53 = arith.extsi %46 : tensor<1x4xi32, #blocked> to tensor<1x4xi64, #blocked>
%54 = tt.broadcast %53 : (tensor<1x4xi64, #blocked>) -> tensor<64x4xi64, #blocked>
%55 = arith.addi %54, %32 : tensor<64x4xi64, #blocked>
%56 = tt.addptr %33, %55 : tensor<64x4x!tt.ptr<f32, 1>, #blocked>, tensor<64x4xi64, #blocked>
%57 = tt.load %56, %51, %cst_9 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<64x4xf32, #blocked>
%58 = arith.addf %57, %52 : tensor<64x4xf32, #blocked>
%59 = arith.subf %58, %arg8 : tensor<64x4xf32, #blocked>
%60 = arith.addf %arg10, %cst_6 : tensor<64x4xf32, #blocked>
%61 = arith.divf %59, %60 : tensor<64x4xf32, #blocked>
%62 = arith.addf %arg8, %61 : tensor<64x4xf32, #blocked>
%63 = arith.subf %58, %62 : tensor<64x4xf32, #blocked>
%64 = arith.mulf %59, %63 : tensor<64x4xf32, #blocked>
%65 = arith.addf %arg9, %64 : tensor<64x4xf32, #blocked>
%66 = arith.select %51, %62, %arg8 : tensor<64x4xi1, #blocked>, tensor<64x4xf32, #blocked>
%67 = arith.select %51, %65, %arg9 : tensor<64x4xi1, #blocked>, tensor<64x4xf32, #blocked>
%68 = arith.select %51, %60, %arg10 : tensor<64x4xi1, #blocked>, tensor<64x4xf32, #blocked>
scf.yield %66, %67, %68 : tensor<64x4xf32, #blocked>, tensor<64x4xf32, #blocked>, tensor<64x4xf32, #blocked>
}
%35:3 = "tt.reduce"(%34#0, %34#1, %34#2) <{axis = 1 : i32}> ({
^bb0(%arg7: f32, %arg8: f32, %arg9: f32, %arg10: f32, %arg11: f32, %arg12: f32):
%45 = arith.subf %arg10, %arg7 : f32
%46 = arith.addf %arg9, %arg12 : f32
%47 = arith.cmpf oeq, %46, %cst_7 : f32
%48 = arith.divf %arg12, %46 : f32
%49 = arith.select %47, %cst_7, %48 : f32
%50 = arith.mulf %45, %49 : f32
%51 = arith.addf %arg7, %50 : f32
%52 = arith.addf %arg8, %arg11 : f32
%53 = arith.mulf %45, %45 : f32
%54 = arith.mulf %53, %arg9 : f32
%55 = arith.mulf %54, %49 : f32
%56 = arith.addf %52, %55 : f32
tt.reduce.return %51, %56, %46 : f32, f32, f32
}) : (tensor<64x4xf32, #blocked>, tensor<64x4xf32, #blocked>, tensor<64x4xf32, #blocked>) -> (tensor<64xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>, tensor<64xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>, tensor<64xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>)
%36 = tt.expand_dims %35#0 {axis = 1 : i32} : (tensor<64xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>) -> tensor<64x1xf32, #blocked>
%37 = tt.expand_dims %35#1 {axis = 1 : i32} : (tensor<64xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>) -> tensor<64x1xf32, #blocked>
%38 = tt.splat %arg3 : (!tt.ptr<f32, 1>) -> tensor<1x4x!tt.ptr<f32, 1>, #blocked>
%39 = tt.broadcast %36 : (tensor<64x1xf32, #blocked>) -> tensor<64x4xf32, #blocked>
%40 = arith.divf %37, %cst_12 : tensor<64x1xf32, #blocked>
%41 = arith.addf %40, %cst_11 : tensor<64x1xf32, #blocked>
%42 = arith.muli %8, %cst_0 : tensor<64x1xi32, #blocked>
%43 = tt.broadcast %42 : (tensor<64x1xi32, #blocked>) -> tensor<64x4xi32, #blocked>
%44 = tt.splat %arg4 : (!tt.ptr<bf16, 1>) -> tensor<64x4x!tt.ptr<bf16, 1>, #blocked>
scf.for %arg7 = %c0_i32 to %c256_i32 step %c4_i32 : i32 {
%45 = tt.splat %arg7 : (i32) -> tensor<1x4xi32, #blocked>
%46 = arith.addi %45, %11 : tensor<1x4xi32, #blocked>
%47 = arith.cmpi slt, %46, %cst_10 : tensor<1x4xi32, #blocked>
%48 = tt.broadcast %46 : (tensor<1x4xi32, #blocked>) -> tensor<64x4xi32, #blocked>
%49 = arith.addi %48, %20 : tensor<64x4xi32, #blocked>
%50 = tt.addptr %21, %49 : tensor<64x4x!tt.ptr<f32, 1>, #blocked>, tensor<64x4xi32, #blocked>
%51 = tt.broadcast %47 : (tensor<1x4xi1, #blocked>) -> tensor<64x4xi1, #blocked>
%52 = tt.load %50, %51, %cst_9 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<64x4xf32, #blocked>
%53 = tt.addptr %38, %46 : tensor<1x4x!tt.ptr<f32, 1>, #blocked>, tensor<1x4xi32, #blocked>
%54 = tt.load %53, %47, %cst_8 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<1x4xf32, #blocked>
tt.assert %30, "index out of bounds: 0 <= tmp13 < 50257", "<frozen importlib._bootstrap_external>", "_call_with_frames_removed", 883 : tensor<64x1xi1, #blocked1>
%55 = arith.extsi %46 : tensor<1x4xi32, #blocked> to tensor<1x4xi64, #blocked>
%56 = tt.broadcast %55 : (tensor<1x4xi64, #blocked>) -> tensor<64x4xi64, #blocked>
%57 = arith.addi %56, %32 : tensor<64x4xi64, #blocked>
%58 = tt.addptr %33, %57 : tensor<64x4x!tt.ptr<f32, 1>, #blocked>, tensor<64x4xi64, #blocked>
%59 = tt.load %58, %51, %cst_9 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<64x4xf32, #blocked>
%60 = arith.addf %59, %52 : tensor<64x4xf32, #blocked>
%61 = arith.subf %60, %39 : tensor<64x4xf32, #blocked>
%62 = tt.extern_elementwise %41 {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<64x1xf32, #blocked>) -> tensor<64x1xf32, #blocked>
%63 = tt.broadcast %62 : (tensor<64x1xf32, #blocked>) -> tensor<64x4xf32, #blocked>
%64 = arith.mulf %61, %63 : tensor<64x4xf32, #blocked>
%65 = tt.broadcast %54 : (tensor<1x4xf32, #blocked>) -> tensor<64x4xf32, #blocked>
%66 = arith.mulf %64, %65 : tensor<64x4xf32, #blocked>
%67 = arith.addi %48, %43 : tensor<64x4xi32, #blocked>
%68 = tt.addptr %44, %67 : tensor<64x4x!tt.ptr<bf16, 1>, #blocked>, tensor<64x4xi32, #blocked>
%69 = arith.truncf %66 : tensor<64x4xf32, #blocked> to tensor<64x4xbf16, #blocked>
tt.store %68, %69, %51 {cache = 1 : i32, evict = 1 : i32} : tensor<64x4xbf16, #blocked>
}
tt.return
}
}