0-hero's picture
Add files using upload-large-folder tool
4bf7f8a verified
raw
history blame
7.4 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]}>
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__0d1d2d3d4d5d6d7de8(%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<bf16, 1> {tt.divisibility = 16 : i32}, %arg5: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg6: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg7: i64 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}, %arg8: i64) attributes {noinline = false} {
%cst = arith.constant dense<0.000000e+00> : tensor<64x1xf32, #blocked>
%cst_0 = arith.constant dense<50257> : tensor<64x1xi64, #blocked>
%cst_1 = arith.constant dense<-1> : tensor<64x1xi64, #blocked>
%cst_2 = arith.constant dense<0.000000e+00> : tensor<64x4xf32, #blocked>
%c64_i64 = arith.constant 64 : i64
%cst_3 = arith.constant dense<50257> : tensor<1x4xi64, #blocked>
%c0_i32 = arith.constant 0 : i32
%c4_i32 = arith.constant 4 : i32
%c50257_i32 = arith.constant 50257 : i32
%cst_4 = arith.constant dense<0.000000e+00> : tensor<64x4xbf16, #blocked>
%0 = tt.get_program_id x : i32
%1 = arith.extsi %0 : i32 to i64
%2 = arith.muli %1, %c64_i64 : i64
%3 = tt.make_range {end = 64 : i32, start = 0 : i32} : tensor<64xi32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>
%4 = tt.expand_dims %3 {axis = 1 : i32} : (tensor<64xi32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>) -> tensor<64x1xi32, #blocked>
%5 = arith.extsi %4 : tensor<64x1xi32, #blocked> to tensor<64x1xi64, #blocked>
%6 = tt.splat %2 : (i64) -> tensor<64x1xi64, #blocked>
%7 = arith.addi %6, %5 : tensor<64x1xi64, #blocked>
%8 = tt.make_range {end = 4 : i32, start = 0 : i32} : tensor<4xi32, #triton_gpu.slice<{dim = 0, parent = #blocked}>>
%9 = tt.expand_dims %8 {axis = 0 : i32} : (tensor<4xi32, #triton_gpu.slice<{dim = 0, parent = #blocked}>>) -> tensor<1x4xi32, #blocked>
%10 = arith.extsi %9 : tensor<1x4xi32, #blocked> to tensor<1x4xi64, #blocked>
%11 = tt.splat %arg1 : (!tt.ptr<i64, 1>) -> tensor<64x1x!tt.ptr<i64, 1>, #blocked>
%12 = tt.addptr %11, %7 : tensor<64x1x!tt.ptr<i64, 1>, #blocked>, tensor<64x1xi64, #blocked>
%13 = tt.load %12 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<64x1xi64, #blocked>
%14 = tt.addptr %arg2, %c0_i32 : !tt.ptr<f32, 1>, i32
%15 = tt.load %14 {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : f32
%16 = tt.addptr %arg3, %c0_i32 : !tt.ptr<f32, 1>, i32
%17 = tt.load %16 {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : f32
%18 = arith.muli %7, %cst_0 : tensor<64x1xi64, #blocked>
%19 = tt.broadcast %18 : (tensor<64x1xi64, #blocked>) -> tensor<64x4xi64, #blocked>
%20 = tt.splat %arg0 : (!tt.ptr<f32, 1>) -> tensor<64x4x!tt.ptr<f32, 1>, #blocked>
%21 = arith.cmpi ne, %13, %cst_1 : tensor<64x1xi64, #blocked>
%22 = arith.divf %15, %17 : f32
%23 = tt.splat %22 : (f32) -> tensor<64x1xf32, #blocked>
%24 = arith.select %21, %23, %cst : tensor<64x1xi1, #blocked>, tensor<64x1xf32, #blocked>
%25 = tt.broadcast %24 : (tensor<64x1xf32, #blocked>) -> tensor<64x4xf32, #blocked>
%26 = scf.for %arg9 = %c0_i32 to %c50257_i32 step %c4_i32 iter_args(%arg10 = %cst_2) -> (tensor<64x4xf32, #blocked>) : i32 {
%33 = arith.extsi %arg9 : i32 to i64
%34 = tt.splat %33 : (i64) -> tensor<1x4xi64, #blocked>
%35 = arith.addi %34, %10 : tensor<1x4xi64, #blocked>
%36 = arith.cmpi slt, %35, %cst_3 : tensor<1x4xi64, #blocked>
%37 = tt.broadcast %35 : (tensor<1x4xi64, #blocked>) -> tensor<64x4xi64, #blocked>
%38 = arith.addi %37, %19 : tensor<64x4xi64, #blocked>
%39 = tt.addptr %20, %38 : tensor<64x4x!tt.ptr<f32, 1>, #blocked>, tensor<64x4xi64, #blocked>
%40 = tt.broadcast %36 : (tensor<1x4xi1, #blocked>) -> tensor<64x4xi1, #blocked>
%41 = tt.load %39, %40, %cst_2 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<64x4xf32, #blocked>
%42 = arith.mulf %41, %25 : tensor<64x4xf32, #blocked>
%43 = arith.addf %arg10, %42 : tensor<64x4xf32, #blocked>
%44 = arith.select %40, %43, %arg10 : tensor<64x4xi1, #blocked>, tensor<64x4xf32, #blocked>
scf.yield %44 : tensor<64x4xf32, #blocked>
}
%27 = "tt.reduce"(%26) <{axis = 1 : i32}> ({
^bb0(%arg9: f32, %arg10: f32):
%33 = arith.addf %arg9, %arg10 : f32
tt.reduce.return %33 : f32
}) : (tensor<64x4xf32, #blocked>) -> tensor<64xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>
%28 = tt.expand_dims %27 {axis = 1 : i32} : (tensor<64xf32, #triton_gpu.slice<{dim = 1, parent = #blocked}>>) -> tensor<64x1xf32, #blocked>
%29 = tt.splat %arg4 : (!tt.ptr<bf16, 1>) -> tensor<64x4x!tt.ptr<bf16, 1>, #blocked>
%30 = tt.splat %arg5 : (!tt.ptr<bf16, 1>) -> tensor<64x4x!tt.ptr<bf16, 1>, #blocked>
%31 = tt.broadcast %28 : (tensor<64x1xf32, #blocked>) -> tensor<64x4xf32, #blocked>
%32 = tt.splat %arg6 : (!tt.ptr<bf16, 1>) -> tensor<64x4x!tt.ptr<bf16, 1>, #blocked>
scf.for %arg9 = %c0_i32 to %c50257_i32 step %c4_i32 : i32 {
%33 = arith.extsi %arg9 : i32 to i64
%34 = tt.splat %33 : (i64) -> tensor<1x4xi64, #blocked>
%35 = arith.addi %34, %10 : tensor<1x4xi64, #blocked>
%36 = arith.cmpi slt, %35, %cst_3 : tensor<1x4xi64, #blocked>
%37 = tt.broadcast %35 : (tensor<1x4xi64, #blocked>) -> tensor<64x4xi64, #blocked>
%38 = arith.addi %37, %19 : tensor<64x4xi64, #blocked>
%39 = tt.addptr %29, %38 : tensor<64x4x!tt.ptr<bf16, 1>, #blocked>, tensor<64x4xi64, #blocked>
%40 = tt.broadcast %36 : (tensor<1x4xi1, #blocked>) -> tensor<64x4xi1, #blocked>
%41 = tt.load %39, %40, %cst_4 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<64x4xbf16, #blocked>
%42 = arith.extf %41 : tensor<64x4xbf16, #blocked> to tensor<64x4xf32, #blocked>
%43 = tt.addptr %20, %38 : tensor<64x4x!tt.ptr<f32, 1>, #blocked>, tensor<64x4xi64, #blocked>
%44 = tt.load %43, %40, %cst_2 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<64x4xf32, #blocked>
%45 = tt.addptr %30, %38 : tensor<64x4x!tt.ptr<bf16, 1>, #blocked>, tensor<64x4xi64, #blocked>
%46 = tt.load %45, %40, %cst_4 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<64x4xbf16, #blocked>
%47 = arith.extf %46 : tensor<64x4xbf16, #blocked> to tensor<64x4xf32, #blocked>
%48 = arith.mulf %44, %25 : tensor<64x4xf32, #blocked>
%49 = math.exp %47 : tensor<64x4xf32, #blocked>
%50 = arith.mulf %49, %31 : tensor<64x4xf32, #blocked>
%51 = arith.subf %48, %50 : tensor<64x4xf32, #blocked>
%52 = arith.addf %42, %51 : tensor<64x4xf32, #blocked>
%53 = tt.addptr %32, %38 : tensor<64x4x!tt.ptr<bf16, 1>, #blocked>, tensor<64x4xi64, #blocked>
%54 = arith.truncf %52 : tensor<64x4xf32, #blocked> to tensor<64x4xbf16, #blocked>
tt.store %53, %54, %40 {cache = 1 : i32, evict = 1 : i32} : tensor<64x4xbf16, #blocked>
}
tt.return
}
}