module { tt.func public @triton__0d1d2d3d4d5d6de7de(%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: 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<2x128xbf16> %cst_0 = arith.constant 0.000000e+00 : f32 %cst_1 = arith.constant dense<1.000000e+00> : tensor<2x128xf32> %c256_i32 = arith.constant 256 : i32 %c128_i32 = arith.constant 128 : i32 %c0_i32 = arith.constant 0 : i32 %cst_2 = arith.constant dense<256> : tensor<2x1xi64> %cst_3 = arith.constant dense<0> : tensor<2x1xi64> %cst_4 = arith.constant dense<50257> : tensor<2x1xi64> %cst_5 = arith.constant dense<9.99999974E-6> : tensor<2x1xf32> %cst_6 = arith.constant dense<2.560000e+02> : tensor<2x1xf32> %cst_7 = arith.constant dense<0.000000e+00> : tensor<1x128xf32> %cst_8 = arith.constant dense<0.000000e+00> : tensor<2x128xf32> %cst_9 = arith.constant dense<256> : tensor<2x1xi32> %cst_10 = arith.constant dense<256> : tensor<1x128xi32> %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 = 128 : i32, start = 0 : i32} : tensor<128xi32> %7 = tt.expand_dims %6 {axis = 0 : i32} : (tensor<128xi32>) -> tensor<1x128xi32> %8 = tt.splat %arg0 : (!tt.ptr) -> tensor<2x1x!tt.ptr> %9 = tt.addptr %8, %5 : tensor<2x1x!tt.ptr>, 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.muli %11, %cst_9 : tensor<2x1xi32> %13 = tt.broadcast %12 : (tensor<2x1xi32>) -> tensor<2x128xi32> %14 = tt.splat %arg2 : (!tt.ptr) -> tensor<2x128x!tt.ptr> %15 = arith.muli %5, %cst_9 : tensor<2x1xi32> %16 = tt.broadcast %15 : (tensor<2x1xi32>) -> tensor<2x128xi32> %17 = tt.splat %arg3 : (!tt.ptr) -> tensor<2x128x!tt.ptr> %18 = arith.addi %10, %cst_4 : tensor<2x1xi64> %19 = arith.cmpi slt, %10, %cst_3 : tensor<2x1xi64> %20 = arith.select %19, %18, %10 : tensor<2x1xi1>, tensor<2x1xi64> %21 = arith.cmpi sge, %20, %cst_3 : tensor<2x1xi64> %22 = arith.cmpi slt, %20, %cst_4 : tensor<2x1xi64> %23 = arith.andi %21, %22 : tensor<2x1xi1> %24 = arith.muli %20, %cst_2 : tensor<2x1xi64> %25 = tt.broadcast %24 : (tensor<2x1xi64>) -> tensor<2x128xi64> %26 = tt.splat %arg1 : (!tt.ptr) -> tensor<2x128x!tt.ptr> %27:3 = scf.for %arg8 = %c0_i32 to %c256_i32 step %c128_i32 iter_args(%arg9 = %cst_8, %arg10 = %cst_8, %arg11 = %cst_8) -> (tensor<2x128xf32>, tensor<2x128xf32>, tensor<2x128xf32>) : i32 { %51 = tt.splat %arg8 : (i32) -> tensor<1x128xi32> %52 = arith.addi %51, %7 : tensor<1x128xi32> %53 = arith.cmpi slt, %52, %cst_10 : tensor<1x128xi32> %54 = tt.broadcast %52 : (tensor<1x128xi32>) -> tensor<2x128xi32> %55 = arith.addi %54, %13 : tensor<2x128xi32> %56 = tt.addptr %14, %55 : tensor<2x128x!tt.ptr>, tensor<2x128xi32> %57 = tt.broadcast %53 : (tensor<1x128xi1>) -> tensor<2x128xi1> %58 = tt.load %56, %57, %cst_8 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x128xf32> %59 = arith.addi %54, %16 : tensor<2x128xi32> %60 = tt.addptr %17, %59 : tensor<2x128x!tt.ptr>, tensor<2x128xi32> %61 = tt.load %60, %57, %cst {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x128xbf16> %62 = arith.extf %61 : tensor<2x128xbf16> to tensor<2x128xf32> tt.assert %23, "index out of bounds: 0 <= tmp3 < 50257", "/usr/local/lib/python3.10/dist-packages/torch/_inductor/codecache.py", "", 1892 : tensor<2x1xi1> %63 = arith.extsi %52 : tensor<1x128xi32> to tensor<1x128xi64> %64 = tt.broadcast %63 : (tensor<1x128xi64>) -> tensor<2x128xi64> %65 = arith.addi %64, %25 : tensor<2x128xi64> %66 = tt.addptr %26, %65 : tensor<2x128x!tt.ptr>, tensor<2x128xi64> %67 = tt.load %66, %57, %cst_8 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x128xf32> %68 = arith.addf %67, %58 : tensor<2x128xf32> %69 = arith.addf %68, %62 : tensor<2x128xf32> %70 = arith.subf %69, %arg9 : tensor<2x128xf32> %71 = arith.addf %arg11, %cst_1 : tensor<2x128xf32> %72 = arith.divf %70, %71 : tensor<2x128xf32> %73 = arith.addf %arg9, %72 : tensor<2x128xf32> %74 = arith.subf %69, %73 : tensor<2x128xf32> %75 = arith.mulf %70, %74 : tensor<2x128xf32> %76 = arith.addf %arg10, %75 : tensor<2x128xf32> %77 = arith.select %57, %73, %arg9 : tensor<2x128xi1>, tensor<2x128xf32> %78 = arith.select %57, %76, %arg10 : tensor<2x128xi1>, tensor<2x128xf32> %79 = arith.select %57, %71, %arg11 : tensor<2x128xi1>, tensor<2x128xf32> scf.yield %77, %78, %79 : tensor<2x128xf32>, tensor<2x128xf32>, tensor<2x128xf32> } %28:3 = "tt.reduce"(%27#0, %27#1, %27#2) <{axis = 1 : i32}> ({ ^bb0(%arg8: f32, %arg9: f32, %arg10: f32, %arg11: f32, %arg12: f32, %arg13: f32): %51 = arith.subf %arg11, %arg8 : f32 %52 = arith.addf %arg10, %arg13 : f32 %53 = arith.cmpf oeq, %52, %cst_0 : f32 %54 = arith.divf %arg13, %52 : f32 %55 = arith.select %53, %cst_0, %54 : f32 %56 = arith.mulf %51, %55 : f32 %57 = arith.addf %arg8, %56 : f32 %58 = arith.addf %arg9, %arg12 : f32 %59 = arith.mulf %51, %51 : f32 %60 = arith.mulf %59, %arg10 : f32 %61 = arith.mulf %60, %55 : f32 %62 = arith.addf %58, %61 : f32 tt.reduce.return %57, %62, %52 : f32, f32, f32 }) : (tensor<2x128xf32>, tensor<2x128xf32>, tensor<2x128xf32>) -> (tensor<2xf32>, tensor<2xf32>, tensor<2xf32>) %29 = tt.expand_dims %28#0 {axis = 1 : i32} : (tensor<2xf32>) -> tensor<2x1xf32> %30 = tt.expand_dims %28#1 {axis = 1 : i32} : (tensor<2xf32>) -> tensor<2x1xf32> %31 = arith.muli %11, %cst_9 : tensor<2x1xi32> %32 = tt.broadcast %31 : (tensor<2x1xi32>) -> tensor<2x128xi32> %33 = tt.splat %arg2 : (!tt.ptr) -> tensor<2x128x!tt.ptr> %34 = arith.muli %5, %cst_9 : tensor<2x1xi32> %35 = tt.broadcast %34 : (tensor<2x1xi32>) -> tensor<2x128xi32> %36 = tt.splat %arg3 : (!tt.ptr) -> tensor<2x128x!tt.ptr> %37 = tt.splat %arg4 : (!tt.ptr) -> tensor<1x128x!tt.ptr> %38 = arith.addi %10, %cst_4 : tensor<2x1xi64> %39 = arith.cmpi slt, %10, %cst_3 : tensor<2x1xi64> %40 = arith.select %39, %38, %10 : tensor<2x1xi1>, tensor<2x1xi64> %41 = arith.cmpi sge, %40, %cst_3 : tensor<2x1xi64> %42 = arith.cmpi slt, %40, %cst_4 : tensor<2x1xi64> %43 = arith.andi %41, %42 : tensor<2x1xi1> %44 = arith.muli %40, %cst_2 : tensor<2x1xi64> %45 = tt.broadcast %44 : (tensor<2x1xi64>) -> tensor<2x128xi64> %46 = tt.splat %arg1 : (!tt.ptr) -> tensor<2x128x!tt.ptr> %47 = tt.broadcast %29 : (tensor<2x1xf32>) -> tensor<2x128xf32> %48 = arith.divf %30, %cst_6 : tensor<2x1xf32> %49 = arith.addf %48, %cst_5 : tensor<2x1xf32> %50 = tt.splat %arg5 : (!tt.ptr) -> tensor<2x128x!tt.ptr> scf.for %arg8 = %c0_i32 to %c256_i32 step %c128_i32 : i32 { %51 = tt.splat %arg8 : (i32) -> tensor<1x128xi32> %52 = arith.addi %51, %7 : tensor<1x128xi32> %53 = arith.cmpi slt, %52, %cst_10 : tensor<1x128xi32> %54 = tt.broadcast %52 : (tensor<1x128xi32>) -> tensor<2x128xi32> %55 = arith.addi %54, %32 : tensor<2x128xi32> %56 = tt.addptr %33, %55 : tensor<2x128x!tt.ptr>, tensor<2x128xi32> %57 = tt.broadcast %53 : (tensor<1x128xi1>) -> tensor<2x128xi1> %58 = tt.load %56, %57, %cst_8 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<2x128xf32> %59 = arith.addi %54, %35 : tensor<2x128xi32> %60 = tt.addptr %36, %59 : tensor<2x128x!tt.ptr>, tensor<2x128xi32> %61 = tt.load %60, %57, %cst {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<2x128xbf16> %62 = arith.extf %61 : tensor<2x128xbf16> to tensor<2x128xf32> %63 = tt.addptr %37, %52 : tensor<1x128x!tt.ptr>, tensor<1x128xi32> %64 = tt.load %63, %53, %cst_7 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<1x128xf32> tt.assert %43, "index out of bounds: 0 <= tmp16 < 50257", "/usr/local/lib/python3.10/dist-packages/torch/_inductor/codecache.py", "", 1892 : tensor<2x1xi1> %65 = arith.extsi %52 : tensor<1x128xi32> to tensor<1x128xi64> %66 = tt.broadcast %65 : (tensor<1x128xi64>) -> tensor<2x128xi64> %67 = arith.addi %66, %45 : tensor<2x128xi64> %68 = tt.addptr %46, %67 : tensor<2x128x!tt.ptr>, tensor<2x128xi64> %69 = tt.load %68, %57, %cst_8 {cache = 1 : i32, evict = 2 : i32, isVolatile = false} : tensor<2x128xf32> %70 = arith.addf %69, %58 : tensor<2x128xf32> %71 = arith.addf %70, %62 : tensor<2x128xf32> %72 = arith.subf %71, %47 : tensor<2x128xf32> %73 = tt.extern_elementwise %49 {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> %74 = tt.broadcast %73 : (tensor<2x1xf32>) -> tensor<2x128xf32> %75 = arith.mulf %72, %74 : tensor<2x128xf32> %76 = tt.broadcast %64 : (tensor<1x128xf32>) -> tensor<2x128xf32> %77 = arith.mulf %75, %76 : tensor<2x128xf32> %78 = tt.addptr %50, %59 : tensor<2x128x!tt.ptr>, tensor<2x128xi32> %79 = arith.truncf %77 : tensor<2x128xf32> to tensor<2x128xbf16> tt.store %78, %79, %57 {cache = 1 : i32, evict = 1 : i32} : tensor<2x128xbf16> } tt.return } }