module { tt.func public @triton__0d1d2d3d4d5d6e7de(%arg0: !tt.ptr {tt.divisibility = 16 : i32}, %arg1: !tt.ptr {tt.divisibility = 16 : i32}, %arg2: !tt.ptr {tt.divisibility = 16 : i32}, %arg3: !tt.ptr {tt.divisibility = 16 : i32}, %arg4: !tt.ptr {tt.divisibility = 16 : i32}, %arg5: !tt.ptr {tt.divisibility = 16 : i32}, %arg6: i64 {tt.max_divisibility = 8 : i32}, %arg7: i64 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}) attributes {noinline = false} { %c8_i64 = arith.constant 8 : i64 %c7680_i64 = arith.constant 7680 : i64 %c385973760_i64 = arith.constant 385973760 : i64 %cst = arith.constant dense<0.000000e+00> : tensor<1x2048xbf16> %cst_0 = arith.constant dense<50257> : tensor<1x2048xi64> %cst_1 = arith.constant dense<7680> : tensor<1x2048xi64> %c2048_i32 = arith.constant 2048 : i32 %c7680_i32 = arith.constant 7680 : i32 %c0_i32 = arith.constant 0 : i32 %cst_2 = arith.constant dense<-1> : tensor<1x2048xi64> %cst_3 = arith.constant dense<0.000000e+00> : tensor<1x2048xf32> %cst_4 = arith.constant dense<0> : tensor<1x2048xi64> %0 = tt.get_program_id x : i32 %1 = arith.extsi %0 : i32 to i64 %2 = arith.cmpi slt, %1, %c8_i64 : i64 %3 = tt.splat %2 : (i1) -> tensor<1x1xi1> %4 = tt.make_range {end = 2048 : i32, start = 0 : i32} : tensor<2048xi32> %5 = tt.expand_dims %4 {axis = 0 : i32} : (tensor<2048xi32>) -> tensor<1x2048xi32> %6 = arith.extsi %5 : tensor<1x2048xi32> to tensor<1x2048xi64> %7 = arith.muli %1, %c7680_i64 : i64 %8 = tt.splat %7 : (i64) -> tensor<1x2048xi64> %9 = tt.splat %arg0 : (!tt.ptr) -> tensor<1x2048x!tt.ptr> %10 = tt.splat %2 : (i1) -> tensor<1x2048xi1> %11 = tt.splat %arg2 : (!tt.ptr) -> tensor<1x2048x!tt.ptr> %12 = tt.splat %arg3 : (!tt.ptr) -> tensor<1x2048x!tt.ptr> %13 = arith.muli %1, %c385973760_i64 : i64 %14 = tt.splat %13 : (i64) -> tensor<1x2048xi64> %15 = tt.splat %arg1 : (!tt.ptr) -> tensor<1x2048x!tt.ptr> %16:2 = scf.for %arg8 = %c0_i32 to %c7680_i32 step %c2048_i32 iter_args(%arg9 = %cst_4, %arg10 = %cst_3) -> (tensor<1x2048xi64>, tensor<1x2048xf32>) : i32 { %25 = arith.extsi %arg8 : i32 to i64 %26 = tt.splat %25 : (i64) -> tensor<1x2048xi64> %27 = arith.addi %26, %6 : tensor<1x2048xi64> %28 = arith.cmpi slt, %27, %cst_1 : tensor<1x2048xi64> %29 = arith.addi %27, %8 : tensor<1x2048xi64> %30 = tt.addptr %9, %29 : tensor<1x2048x!tt.ptr>, tensor<1x2048xi64> %31 = arith.andi %28, %10 : tensor<1x2048xi1> %32 = tt.load %30, %31, %cst_4 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<1x2048xi64> %33 = tt.addptr %11, %29 : tensor<1x2048x!tt.ptr>, tensor<1x2048xi64> %34 = tt.load %33, %31, %cst_3 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<1x2048xf32> %35 = tt.addptr %12, %29 : tensor<1x2048x!tt.ptr>, tensor<1x2048xi64> %36 = tt.load %35, %31, %cst_3 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<1x2048xf32> %37 = arith.cmpi ne, %32, %cst_2 : tensor<1x2048xi64> %38 = arith.extui %37 : tensor<1x2048xi1> to tensor<1x2048xi64> %39 = arith.addi %arg9, %38 : tensor<1x2048xi64> %40 = arith.select %31, %39, %arg9 : tensor<1x2048xi1>, tensor<1x2048xi64> %41 = arith.select %37, %32, %cst_4 : tensor<1x2048xi1>, tensor<1x2048xi64> %42 = arith.addi %41, %cst_0 : tensor<1x2048xi64> %43 = arith.cmpi slt, %41, %cst_4 : tensor<1x2048xi64> %44 = arith.select %43, %42, %41 : tensor<1x2048xi1>, tensor<1x2048xi64> %45 = arith.cmpi sge, %44, %cst_4 : tensor<1x2048xi64> %46 = arith.cmpi slt, %44, %cst_0 : tensor<1x2048xi64> %47 = arith.andi %45, %46 : tensor<1x2048xi1> tt.assert %47, "index out of bounds: 0 <= tmp11 < 50257", "", "_call_with_frames_removed", 883 : tensor<1x2048xi1> %48 = arith.muli %27, %cst_0 : tensor<1x2048xi64> %49 = arith.addi %44, %48 : tensor<1x2048xi64> %50 = arith.addi %49, %14 : tensor<1x2048xi64> %51 = tt.addptr %15, %50 : tensor<1x2048x!tt.ptr>, tensor<1x2048xi64> %52 = tt.load %51, %31, %cst {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<1x2048xbf16> %53 = arith.extf %52 : tensor<1x2048xbf16> to tensor<1x2048xf32> %54 = arith.subf %53, %34 : tensor<1x2048xf32> %55 = math.log %36 : tensor<1x2048xf32> %56 = arith.subf %54, %55 : tensor<1x2048xf32> %57 = arith.subf %cst_3, %56 : tensor<1x2048xf32> %58 = arith.select %37, %57, %cst_3 : tensor<1x2048xi1>, tensor<1x2048xf32> %59 = arith.addf %arg10, %58 : tensor<1x2048xf32> %60 = arith.select %31, %59, %arg10 : tensor<1x2048xi1>, tensor<1x2048xf32> scf.yield %40, %60 : tensor<1x2048xi64>, tensor<1x2048xf32> } %17 = "tt.reduce"(%16#0) <{axis = 1 : i32}> ({ ^bb0(%arg8: i64, %arg9: i64): %25 = arith.addi %arg8, %arg9 : i64 tt.reduce.return %25 : i64 }) : (tensor<1x2048xi64>) -> tensor<1xi64> %18 = tt.expand_dims %17 {axis = 1 : i32} : (tensor<1xi64>) -> tensor<1x1xi64> %19 = tt.addptr %arg4, %1 : !tt.ptr, i64 %20 = tt.splat %19 : (!tt.ptr) -> tensor<1x1x!tt.ptr> tt.store %20, %18, %3 {cache = 1 : i32, evict = 1 : i32} : tensor<1x1xi64> %21 = "tt.reduce"(%16#1) <{axis = 1 : i32}> ({ ^bb0(%arg8: f32, %arg9: f32): %25 = arith.addf %arg8, %arg9 : f32 tt.reduce.return %25 : f32 }) : (tensor<1x2048xf32>) -> tensor<1xf32> %22 = tt.expand_dims %21 {axis = 1 : i32} : (tensor<1xf32>) -> tensor<1x1xf32> %23 = tt.addptr %arg5, %1 : !tt.ptr, i64 %24 = tt.splat %23 : (!tt.ptr) -> tensor<1x1x!tt.ptr> tt.store %24, %22, %3 {cache = 1 : i32, evict = 1 : i32} : tensor<1x1xf32> tt.return } }