diff --git "a/program/vision_encoder.loom" "b/program/vision_encoder.loom" new file mode 100644--- /dev/null +++ "b/program/vision_encoder.loom" @@ -0,0 +1,4045 @@ +target.decl @device +amdgpu.target @rdna3 +amdgpu.target @rdna4 + +kernel.def export("v_row_scale_f16") @v_row_scale_f16(%rows: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + kernel.launch.config workgroups(%rows, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %x: buffer, %scales: buffer, %x16: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 1, 2097152)] : index + %k = index.assume %k_arg [range(%k_arg, 8, 65536), multiple_of(%k_arg, 8)] : index + %row_id = kernel.workgroup.id : index + %row = index.assume %row_id [lt(%row_id, %rows)] : index + %lane = kernel.workitem.id : index + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %zero_f = scalar.constant 0.0 : f32 + %x_view = buffer.view %x[%zero] : buffer -> view<[%rows]x[%k]xf32> + %h_view = buffer.view %x16[%zero] : buffer -> view<[%rows]x[%k]xf16> + %local = scf.for %c = [%lane to %k step %c256](%m = %zero_f : f32) -> (f32) { + %bc = index.assume %c [lt(%c, %k)] : index + %v = view.load %x_view[%row, %bc] : view<[%rows]x[%k]xf32> -> f32 + %a = scalar.absf %v : f32 + %n = scalar.maxnumf %m, %a : f32 + scf.yield %n : f32 + } + %maximum = kernel.workgroup.reduce %local : f32 + %bits = scalar.bitcast %maximum : f32 to i32 + %c23 = scalar.constant 23 : i32 + %c255 = scalar.constant 255 : i32 + %shifted = scalar.shrui %bits, %c23 : i32 + %biased = scalar.andi %shifted, %c255 : i32 + %c127 = scalar.constant 127 : i32 + %c13 = scalar.constant 13 : i32 + %c0_i32 = scalar.constant 0 : i32 + %c100 = scalar.constant 100 : i32 + %unbiased = scalar.subi %biased, %c127 : i32 + %raw_e = scalar.subi %unbiased, %c13 : i32 + %positive = scalar.maxsi %raw_e, %c0_i32 : i32 + %e = scalar.minsi %positive, %c100 : i32 + %scale_exp = scalar.subi %c127, %e : i32 + %inverse_exp = scalar.addi %c127, %e : i32 + %scale_bits = scalar.shli %scale_exp, %c23 : i32 + %inverse_bits = scalar.shli %inverse_exp, %c23 : i32 + %scale = scalar.bitcast %scale_bits : i32 to f32 + %inverse = scalar.bitcast %inverse_bits : i32 to f32 + scf.for %c = [%lane to %k step %c256] { + %bc = index.assume %c [lt(%c, %k)] : index + %v = view.load %x_view[%row, %bc] : view<[%rows]x[%k]xf32> -> f32 + %sv = scalar.mulf %v, %scale : f32 + %hv = scalar.fptrunc %sv : f32 to f16 + view.store %hv, %h_view[%row, %bc] : f16, view<[%rows]x[%k]xf16> + } + %first = index.cmp eq, %lane, %c0 : index + scf.if %first { + %s_view = buffer.view %scales[%zero] : buffer -> view<[%rows]x2xf32> + view.store %scale, %s_view[%row, %c0] : f32, view<[%rows]x2xf32> + view.store %inverse, %s_view[%row, %c1] : f32, view<[%rows]x2xf32> + } + kernel.return +} + +kernel.def export("v_pixels_0p5_0p5_0p5") @v_pixels_0p5_0p5_0p5(%n: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %c255 = index.constant 255 : index + %n_up = index.add %n, %c255 : index + %groups = index.div %n_up, %c256 : index + kernel.launch.config workgroups(%groups, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%n_arg: index, %src: buffer, %y: buffer) { + %n = index.assume %n_arg [range(%n_arg, 1, 268435456)] : index + %c256 = index.constant 256 : index + %c3 = index.constant 3 : index + %gid = kernel.workgroup.id : index + %lid = kernel.workitem.id : index + %i = index.madd %gid, %c256, %lid : index + %live = index.cmp ult, %i, %n : index + scf.if %live { + %bi = index.assume %i [lt(%i, %n)] : index + %zero = index.constant 0 : offset + %sv = buffer.view %src[%zero] : buffer -> view<[%n]xi8> + %raw = view.load %sv[%bi] : view<[%n]xi8> -> i8 + %u = scalar.extui %raw : i8 to i32 + %f = scalar.uitofp %u : i32 to f32 + %ch = index.rem %bi, %c3 : index + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %is0 = index.cmp eq, %ch, %c0 : index + %is1 = index.cmp eq, %ch, %c1 : index + %a0 = scalar.constant 0.00784313725490196 : f32 + %a1 = scalar.constant 0.00784313725490196 : f32 + %a2 = scalar.constant 0.00784313725490196 : f32 + %b0 = scalar.constant -1.0 : f32 + %b1 = scalar.constant -1.0 : f32 + %b2 = scalar.constant -1.0 : f32 + %a12 = scf.select %is1, %a1, %a2 : f32 + %a = scf.select %is0, %a0, %a12 : f32 + %b12 = scf.select %is1, %b1, %b2 : f32 + %b = scf.select %is0, %b0, %b12 : f32 + %r = scalar.fmaf %f, %a, %b : f32 + %yv = buffer.view %y[%zero] : buffer -> view<[%n]xf32> + view.store %r, %yv[%bi] : f32, view<[%n]xf32> + } + kernel.return +} + +kernel.def export("v_patch_20_1024_f16_raster") @v_patch_20_1024_f16_raster(%tokens: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + kernel.launch.config workgroups(%tokens, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%tokens_arg: index, %gw_arg: index, %img_w_arg: index, %pix: buffer, %w: buffer, %y: buffer) { + %tokens = index.assume %tokens_arg [range(%tokens_arg, 1, 65536)] : index + %gw = index.assume %gw_arg [range(%gw_arg, 1, 1024)] : index + %img_w = index.assume %img_w_arg [range(%img_w_arg, 1, 16384)] : index + %t_id = kernel.workgroup.id : index + %t = index.assume %t_id [lt(%t_id, %tokens)] : index + %lid = kernel.workitem.id : index + %lane = index.assume %lid [range(%lid, 0, 255)] : index + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c3 = index.constant 3 : index + %c256 = index.constant 256 : index + %cP = index.constant 20 : index + %cPP = index.constant 400 : index + %cK = index.constant 1200 : index + %cKP = index.constant 1280 : index + %cE = index.constant 1024 : index + %zf = scalar.constant 0.0 : f32 + %py = index.div %t, %gw : index + %px = index.rem %t, %gw : index + %stage_bytes = index.constant 5120 : offset + %stage = buffer.alloca align(16) %stage_bytes : buffer + %sv = buffer.view %stage[%zero] : buffer -> view<1280xf32> + %rows_px = index.mul %tokens, %c1 : index + %pix_n = index.constant 268435456 : index + %pv = buffer.view %pix[%zero] : buffer -> view<[%pix_n]xf32> + %y0 = index.mul %py, %cP : index + %x0 = index.mul %px, %cP : index + scf.for %i = [%lane to %cKP step %c256] { + %bi = index.assume %i [lt(%i, %cKP)] : index + %inside = index.cmp ult, %i, %cK : index + %v = scf.if %inside -> (f32) { + %ch = index.div %i, %cPP : index + %r = index.rem %i, %cPP : index + %ky = index.div %r, %cP : index + %kx = index.rem %r, %cP : index + %yy = index.add %y0, %ky : index + %xx = index.add %x0, %kx : index + %rowpix = index.mul %yy, %img_w : index + %pixel = index.add %rowpix, %xx : index + %el = index.madd %pixel, %c3, %ch : index + %bel = index.assume %el [lt(%el, %pix_n)] : index + %pval = view.load %pv[%bel] : view<[%pix_n]xf32> -> f32 + scf.yield %pval : f32 + } else { + scf.yield %zf : f32 + } + view.store %v, %sv[%bi] : f32, view<1280xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %wn = index.constant 1228800 : index + %wv = buffer.view %w[%zero] : buffer -> view<[%wn]xf16> + %yv = buffer.view %y[%zero] : buffer -> view<[%tokens]x1024xf32> + scf.for %e = [%lane to %cE step %c256] { + %be = index.assume %e [lt(%e, %cE)] : index + %wrow = index.mul %be, %cK : index + %acc = scf.for %k = [%c0 to %cK step %c1](%a = %zf : f32) -> (f32) { + %bk = index.assume %k [lt(%k, %cKP)] : index + %xk = view.load %sv[%bk] : view<1280xf32> -> f32 + %wi = index.add %wrow, %k : index + %bwi = index.assume %wi [lt(%wi, %wn)] : index + %wk_h = view.load %wv[%bwi] : view<[%wn]xf16> -> f16 + %wk = scalar.extf %wk_h : f16 to f32 + %wks = scalar.addf %wk, %zf : f32 + %na = scalar.fmaf %wks, %xk, %a : f32 + scf.yield %na : f32 + } + %out = scalar.addf %acc, %zf : f32 + view.store %out, %yv[%t, %be] : f32, view<[%tokens]x1024xf32> + } + kernel.return +} + +kernel.def export("v_pos_interp_1024_32_raster_hp") @v_pos_interp_1024_32_raster_hp(%tokens: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + kernel.launch.config workgroups(%tokens, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%tokens_arg: index, %gw_arg: index, %gh_arg: index, %tab: buffer, %y: buffer) { + %tokens = index.assume %tokens_arg [range(%tokens_arg, 1, 65536)] : index + %gw = index.assume %gw_arg [range(%gw_arg, 1, 1024)] : index + %gh = index.assume %gh_arg [range(%gh_arg, 1, 1024)] : index + %t_id = kernel.workgroup.id : index + %t = index.assume %t_id [lt(%t_id, %tokens)] : index + %lid = kernel.workitem.id : index + %lane = index.assume %lid [range(%lid, 0, 255)] : index + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %cE = index.constant 1024 : index + %nm1 = index.constant 31 : index + %c0i = scalar.constant 0 : i32 + %nm1i = scalar.constant 31 : i32 + %zf = scalar.constant 0.0 : f32 + %onef = scalar.constant 1.0 : f32 + %halff = scalar.constant 0.5 : f32 + %nf = scalar.constant 32.0 : f32 + %nm1f = scalar.constant 31.0 : f32 + %py = index.div %t, %gw : index + %px = index.rem %t, %gw : index + %py_of_i = index.cast %py : index to i32 + %py_of = scalar.sitofp %py_of_i : i32 to f32 + %gh_f_i = index.cast %gh : index to i32 + %gh_f = scalar.sitofp %gh_f_i : i32 to f32 + %py_h = scalar.addf %py_of, %halff : f32 + %py_r = scalar.mulf %py_h, %nf : f32 + %py_q = scalar.divf %py_r, %gh_f : f32 + %py_m = scalar.subf %py_q, %halff : f32 + %py_c = scalar.maxnumf %py_m, %zf : f32 + %py_s = scalar.minnumf %py_c, %nm1f : f32 + %px_of_i = index.cast %px : index to i32 + %px_of = scalar.sitofp %px_of_i : i32 to f32 + %gw_f_i = index.cast %gw : index to i32 + %gw_f = scalar.sitofp %gw_f_i : i32 to f32 + %px_h = scalar.addf %px_of, %halff : f32 + %px_r = scalar.mulf %px_h, %nf : f32 + %px_q = scalar.divf %px_r, %gw_f : f32 + %px_m = scalar.subf %px_q, %halff : f32 + %px_c = scalar.maxnumf %px_m, %zf : f32 + %px_s = scalar.minnumf %px_c, %nm1f : f32 + %py_fl = scalar.floorf %py_s : f32 + %py_fr = scalar.subf %py_s, %py_fl : f32 + %py_i0r = scalar.fptosi %py_fl : f32 to i32 + %py_i0c = scalar.maxsi %py_i0r, %c0i : i32 + %py_i0d = scalar.minsi %py_i0c, %nm1i : i32 + %py_i0a = scalar.assume %py_i0d [range(%py_i0d, 0, 31)] : i32 + %py_i0 = index.cast %py_i0a : i32 to index + %py_i1r = index.add %py_i0, %c1 : index + %py_i1m = index.min %py_i1r, %nm1 : index + %py_i1 = index.assume %py_i1m [range(%py_i1m, 0, 31)] : index + %px_fl = scalar.floorf %px_s : f32 + %px_fr = scalar.subf %px_s, %px_fl : f32 + %px_i0r = scalar.fptosi %px_fl : f32 to i32 + %px_i0c = scalar.maxsi %px_i0r, %c0i : i32 + %px_i0d = scalar.minsi %px_i0c, %nm1i : i32 + %px_i0a = scalar.assume %px_i0d [range(%px_i0d, 0, 31)] : i32 + %px_i0 = index.cast %px_i0a : i32 to index + %px_i1r = index.add %px_i0, %c1 : index + %px_i1m = index.min %px_i1r, %nm1 : index + %px_i1 = index.assume %px_i1m [range(%px_i1m, 0, 31)] : index + %fy1 = scalar.addf %py_fr, %zf : f32 + %fy0 = scalar.subf %onef, %py_fr : f32 + %fx1 = scalar.addf %px_fr, %zf : f32 + %fx0 = scalar.subf %onef, %px_fr : f32 + %tv = buffer.view %tab[%zero] : buffer -> view<32x32x1024xf32> + %yv = buffer.view %y[%zero] : buffer -> view<[%tokens]x1024xf32> + scf.for %e = [%lane to %cE step %c256] { + %be = index.assume %e [lt(%e, %cE)] : index + %v00 = view.load %tv[%py_i0, %px_i0, %be] : view<32x32x1024xf32> -> f32 + %v01 = view.load %tv[%py_i0, %px_i1, %be] : view<32x32x1024xf32> -> f32 + %v10 = view.load %tv[%py_i1, %px_i0, %be] : view<32x32x1024xf32> -> f32 + %v11 = view.load %tv[%py_i1, %px_i1, %be] : view<32x32x1024xf32> -> f32 + %r0a = scalar.mulf %v00, %fx0 : f32 + %r0 = scalar.fmaf %v01, %fx1, %r0a : f32 + %r1a = scalar.mulf %v10, %fx0 : f32 + %r1 = scalar.fmaf %v11, %fx1, %r1a : f32 + %ra = scalar.mulf %r0, %fy0 : f32 + %r = scalar.fmaf %r1, %fy1, %ra : f32 + %a = view.load %yv[%t, %be] : view<[%tokens]x1024xf32> -> f32 + %s = scalar.addf %a, %r : f32 + view.store %s, %yv[%t, %be] : f32, view<[%tokens]x1024xf32> + } + kernel.return +} + +kernel.def export("v_prepend_cls_1024") @v_prepend_cls_1024(%tokens: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + kernel.launch.config workgroups(%tokens, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%tokens_arg: index, %x: buffer, %cls_e: buffer, %cls_p: buffer, %y: buffer) { + %tokens = index.assume %tokens_arg [range(%tokens_arg, 2, 65536)] : index + %t_id = kernel.workgroup.id : index + %t = index.assume %t_id [lt(%t_id, %tokens)] : index + %lid = kernel.workitem.id : index + %lane = index.assume %lid [range(%lid, 0, 255)] : index + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %cE = index.constant 1024 : index + %patches = index.sub %tokens, %c1 : index + %is0 = index.cmp eq, %t, %c0 : index + %cev = buffer.view %cls_e[%zero] : buffer -> view<1024xf32> + %cpv = buffer.view %cls_p[%zero] : buffer -> view<1024xf32> + %xv = buffer.view %x[%zero] : buffer -> view<[%patches]x1024xf32> + %yv = buffer.view %y[%zero] : buffer -> view<[%tokens]x1024xf32> + scf.if %is0 { + scf.for %c = [%lane to %cE step %c256] { + %bc = index.assume %c [lt(%c, 1024)] : index + %ce = view.load %cev[%bc] : view<1024xf32> -> f32 + %cp = view.load %cpv[%bc] : view<1024xf32> -> f32 + %s = scalar.addf %ce, %cp : f32 + view.store %s, %yv[%c0, %bc] : f32, view<[%tokens]x1024xf32> + } + } else { + %src0 = index.sub %t, %c1 : index + %src = index.assume %src0 [lt(%src0, %patches)] : index + scf.for %c = [%lane to %cE step %c256] { + %bc = index.assume %c [lt(%c, 1024)] : index + %v = view.load %xv[%src, %bc] : view<[%patches]x1024xf32> -> f32 + view.store %v, %yv[%t, %bc] : f32, view<[%tokens]x1024xf32> + } + } + kernel.return +} + +kernel.def export("v_norm_ln_1024") @v_norm_ln_1024(%rows: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + kernel.launch.config workgroups(%rows, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %x: buffer, %w: buffer, %b: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 1, 65536)] : index + %row_id = kernel.workgroup.id : index + %row = index.assume %row_id [lt(%row_id, %rows)] : index + %lane_id = kernel.workitem.id : index + %lane = index.assume %lane_id [range(%lane_id, 0, 255)] : index + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %groups = index.constant 32 : index + %zero_f = scalar.constant 0.0 : f32 + %zero32 = vector.splatf 0.0 : vector<32xf32> + %count = scalar.constant 1024.0 : f32 + %active = index.cmp ult, %lane, %groups : index + %x_view = buffer.view %x[%zero] : buffer -> view<[%rows]x32x32xf32> + %xv = scf.if %active -> (vector<32xf32>) { + %bl = index.assume %lane [range(%lane, 0, 31)] : index + %a = vector.load %x_view[%row, %bl, %c0] : view<[%rows]x32x32xf32> -> vector<32xf32> + scf.yield %a : vector<32xf32> + } else { + scf.yield %zero32 : vector<32xf32> + } + %xlocal = vector.reduce %xv, %zero_f : vector<32xf32>, f32 + %xsum = kernel.workgroup.reduce %xlocal : f32 + %xmean = scalar.divf %xsum, %count : f32 + %xmeans = vector.splat %xmean : vector<32xf32> + %xd = vector.subf %xv, %xmeans : vector<32xf32> + %xc = scf.select %active, %xd, %zero32 : vector<32xf32> + %sq = vector.mulf %xc, %xc : vector<32xf32> + %local = vector.reduce %sq, %zero_f : vector<32xf32>, f32 + %sum = kernel.workgroup.reduce %local : f32 + %mean = scalar.divf %sum, %count : f32 + %eps = scalar.constant 9.999999747378752e-06 : f32 + %stable = scalar.addf %mean, %eps : f32 + %inv = scalar.rsqrtf %stable : f32 + %invs = vector.splat %inv : vector<32xf32> + scf.if %active { + %bl = index.assume %lane [range(%lane, 0, 31)] : index + %xn = vector.mulf %xc, %invs : vector<32xf32> + %w_view = buffer.view %w[%zero] : buffer -> view<32x32xf32> + %b_view = buffer.view %b[%zero] : buffer -> view<32x32xf32> + %wv = vector.load %w_view[%bl, %c0] : view<32x32xf32> -> vector<32xf32> + %bv = vector.load %b_view[%bl, %c0] : view<32x32xf32> -> vector<32xf32> + %xw = vector.mulf %xn, %wv : vector<32xf32> + %r = vector.addf %xw, %bv : vector<32xf32> + %y_view = buffer.view %y[%zero] : buffer -> view<[%rows]x32x32xf32> + vector.store %r, %y_view[%row, %bl, %c0] : vector<32xf32>, view<[%rows]x32x32xf32> + } + kernel.return +} + +kernel.def target(@rdna3) export("v_gemm_f16_store_1024x1024") @v_gemm_f16_store_1024x1024(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 1024 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 1024 : index + %n = index.constant 1024 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv000 = vector.load %w_stage_view[%w_row0, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs000 = vector.fragment %rv000 shape [%c16, %c16] : vector<16xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv010 = vector.load %w_stage_view[%w_row1, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs010 = vector.fragment %rv010 shape [%c16, %c16] : vector<16xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv001 = vector.load %w_stage_view[%w_row0, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs001 = vector.fragment %rv001 shape [%c16, %c16] : vector<16xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv011 = vector.load %w_stage_view[%w_row1, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs011 = vector.fragment %rv011 shape [%c16, %c16] : vector<16xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv002 = vector.load %w_stage_view[%w_row0, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs002 = vector.fragment %rv002 shape [%c16, %c16] : vector<16xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv012 = vector.load %w_stage_view[%w_row1, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs012 = vector.fragment %rv012 shape [%c16, %c16] : vector<16xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv003 = vector.load %w_stage_view[%w_row0, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs003 = vector.fragment %rv003 shape [%c16, %c16] : vector<16xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv013 = vector.load %w_stage_view[%w_row1, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs013 = vector.fragment %rv013 shape [%c16, %c16] : vector<16xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} +kernel.def target(@rdna4) export("v_gemm_f16_store_1024x1024_rdna4") @v_gemm_f16_store_1024x1024_rdna4(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 1024 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 1024 : index + %n = index.constant 1024 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + %w_stage_view_tl = encoding.layout.strided [1, 72] : encoding + %w_stage_view_t = buffer.view %w_stage[%origin] : buffer -> view<72x64xf16, %w_stage_view_tl> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv000_b = index.sub %w_row0, %lane_row : index + %rhs000 = vector.fragment.load %w_stage_view_t[%fc0, %rv000_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv010_b = index.sub %w_row1, %lane_row : index + %rhs010 = vector.fragment.load %w_stage_view_t[%fc0, %rv010_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv001_b = index.sub %w_row0, %lane_row : index + %rhs001 = vector.fragment.load %w_stage_view_t[%fc1, %rv001_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv011_b = index.sub %w_row1, %lane_row : index + %rhs011 = vector.fragment.load %w_stage_view_t[%fc1, %rv011_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv002_b = index.sub %w_row0, %lane_row : index + %rhs002 = vector.fragment.load %w_stage_view_t[%fc2, %rv002_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv012_b = index.sub %w_row1, %lane_row : index + %rhs012 = vector.fragment.load %w_stage_view_t[%fc2, %rv012_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv003_b = index.sub %w_row0, %lane_row : index + %rhs003 = vector.fragment.load %w_stage_view_t[%fc3, %rv003_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv013_b = index.sub %w_row1, %lane_row : index + %rhs013 = vector.fragment.load %w_stage_view_t[%fc3, %rv013_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} + + +kernel.def export("v_bias_none_1024") @v_bias_none_1024(%rows: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %cols = index.constant 1024 : index + %cg = index.constant 4 : index + kernel.launch.config workgroups(%rows, %cg, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %x: buffer, %bias: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 1, 65536)] : index + %c256 = index.constant 256 : index + %cols = index.constant 1024 : index + %row_id = kernel.workgroup.id : index + %row = index.assume %row_id [lt(%row_id, %rows)] : index + %cg = kernel.workgroup.id : index + %lid = kernel.workitem.id : index + %c = index.madd %cg, %c256, %lid : index + %live = index.cmp ult, %c, %cols : index + scf.if %live { + %bc = index.assume %c [lt(%c, %cols)] : index + %zero = index.constant 0 : offset + %zf = scalar.constant 0.0 : f32 + %xv = buffer.view %x[%zero] : buffer -> view<[%rows]x1024xf32> + %bv = buffer.view %bias[%zero] : buffer -> view<1024xf32> + %x0 = view.load %xv[%row, %bc] : view<[%rows]x1024xf32> -> f32 + %b0 = view.load %bv[%bc] : view<1024xf32> -> f32 + %a = scalar.addf %x0, %b0 : f32 + %r = scalar.addf %a, %zf : f32 + %yv = buffer.view %y[%zero] : buffer -> view<[%rows]x1024xf32> + view.store %r, %yv[%row, %bc] : f32, view<[%rows]x1024xf32> + } + kernel.return +} + +kernel.def export("v_rope_inkling2v_64x16_s1024_o0_raster_cls") @v_rope_inkling2v_64x16_s1024_o0_raster_cls(%tokens: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + kernel.launch.config workgroups(%tokens, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%tokens_arg: index, %gw_arg: index, %x: buffer) { + %tokens = index.assume %tokens_arg [range(%tokens_arg, 1, 65536)] : index + %gw = index.assume %gw_arg [range(%gw_arg, 1, 4096)] : index + %t_id = kernel.workgroup.id : index + %t = index.assume %t_id [lt(%t_id, %tokens)] : index + %lid = kernel.workitem.id : index + %lane = index.assume %lid [range(%lid, 0, 255)] : index + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %cNP = index.constant 32 : index + %cWORK = index.constant 512 : index + %cD = index.constant 64 : index + %cO = index.constant 0 : index + %is_cls_o = index.cmp eq, %t, %c0 : index + %t_nz_o = index.max %t, %c1 : index + %tp_o = index.sub %t_nz_o, %c1 : index + %py0_o = index.div %tp_o, %gw : index + %px0_o = index.rem %tp_o, %gw : index + %py1_o = index.add %py0_o, %c1 : index + %px1_o = index.add %px0_o, %c1 : index + %py = scf.select %is_cls_o, %c0, %py1_o : index + %px = scf.select %is_cls_o, %c0, %px1_o : index + %pxi = index.cast %px : index to i32 + %pyi = index.cast %py : index to i32 + %offi = scalar.constant 0 : i32 + %pxo = scalar.addi %pxi, %offi : i32 + %pyo = scalar.addi %pyi, %offi : i32 + %pxf = scalar.sitofp %pxo : i32 to f32 + %pyf = scalar.sitofp %pyo : i32 to f32 + %two_pi = scalar.constant 6.283185307179586 : f32 + %inv_two_pi = scalar.constant 0.15915494309189535 : f32 + %xv = buffer.view %x[%zero] : buffer -> view<[%tokens]x1024xf32> + %cq = index.constant 16 : index + %chalf = index.constant 32 : index + %lnth = scalar.constant 18.420680743952367 : f32 + %halff = scalar.constant 32.0 : f32 + scf.for %w = [%lane to %cWORK step %c256] { + %h = index.div %w, %cNP : index + %j0 = index.rem %w, %cNP : index + %j = index.assume %j0 [range(%j0, 0, 31)] : index + %isy = index.cmp uge, %j, %cq : index + %jj = index.rem %j, %cq : index + %c0p = index.constant 0 : index + %c2p = index.constant 2 : index + %base = scf.select %isy, %chalf, %c0p : index + %lo_i = index.madd %jj, %c2p, %base : index + %hi_i = index.add %lo_i, %c1 : index + %ii = index.cast %jj : index to i32 + %if0 = scalar.sitofp %ii : i32 to f32 + %if1 = scalar.mulf %if0, %lnth : f32 + %if2 = scalar.divf %if1, %halff : f32 + %if3 = scalar.negf %if2 : f32 + %invf = scalar.expf %if3 : f32 + %pos = scf.select %isy, %pyf, %pxf : f32 + %ang0 = scalar.mulf %pos, %invf : f32 + %tr = scalar.mulf %ang0, %inv_two_pi : f32 + %trf = scalar.floorf %tr : f32 + %wrap = scalar.mulf %trf, %two_pi : f32 + %ang = scalar.subf %ang0, %wrap : f32 + %cs = scalar.cosf %ang : f32 + %sn = scalar.sinf %ang : f32 + %hcol = index.madd %h, %cD, %cO : index + %clo0 = index.add %hcol, %lo_i : index + %chi0 = index.add %hcol, %hi_i : index + %clo = index.assume %clo0 [lt(%clo0, 1024)] : index + %chi = index.assume %chi0 [lt(%chi0, 1024)] : index + %a = view.load %xv[%t, %clo] : view<[%tokens]x1024xf32> -> f32 + %b = view.load %xv[%t, %chi] : view<[%tokens]x1024xf32> -> f32 + %acs = scalar.mulf %a, %cs : f32 + %bsn = scalar.mulf %b, %sn : f32 + %ra = scalar.subf %acs, %bsn : f32 + %asn = scalar.mulf %a, %sn : f32 + %rb = scalar.fmaf %b, %cs, %asn : f32 + view.store %ra, %xv[%t, %clo] : f32, view<[%tokens]x1024xf32> + view.store %rb, %xv[%t, %chi] : f32, view<[%tokens]x1024xf32> + } + kernel.return +} + +kernel.def export("v_attn_64x16_s1024_0_0_0") @v_attn_64x16_s1024_0_0_0(%tokens: index) { + %c1 = index.constant 1 : index + %c32 = index.constant 32 : index + %heads = index.constant 16 : index + kernel.launch.config workgroups(%tokens, %heads, %c1) workgroup_size(%c32, %c1, %c1) : index +} launch(%tokens_arg: index, %gw_arg: index, %q: buffer, %k: buffer, %v: buffer, %o: buffer) { + %tokens = index.assume %tokens_arg [range(%tokens_arg, 1, 65536)] : index + %gw = index.assume %gw_arg [range(%gw_arg, 1, 4096)] : index + %t_id = kernel.workgroup.id : index + %t = index.assume %t_id [lt(%t_id, %tokens)] : index + %h_id = kernel.workgroup.id : index + %h = index.assume %h_id [range(%h_id, 0, 15)] : index + %lid = kernel.workitem.id : index + %lane = index.assume %lid [range(%lid, 0, 31)] : index + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c32 = index.constant 32 : index + %cD = index.constant 64 : index + %zf = scalar.constant 0.0 : f32 + %neg_big = scalar.constant -3.0e38 : f32 + %scale = scalar.constant 0.125 : f32 + %zero32 = vector.splatf 0.0 : vector<32xf32> + %qv = buffer.view %q[%zero] : buffer -> view<[%tokens]x1024xf32> + %kv = buffer.view %k[%zero] : buffer -> view<[%tokens]x1024xf32> + %vv = buffer.view %v[%zero] : buffer -> view<[%tokens]x1024xf32> + %cOQ = index.constant 0 : index + %cOK = index.constant 0 : index + %cOV = index.constant 0 : index + %qcol = index.madd %h, %cD, %cOQ : index + %kcol = index.madd %h, %cD, %cOK : index + %vcol = index.madd %h, %cD, %cOV : index + + %qc00 = index.constant 0 : index + %qc01 = index.add %qcol, %qc00 : index + %qc0 = index.assume %qc01 [range(%qc01, 0, 992)] : index + %qr0 = vector.load %qv[%t, %qc0] : view<[%tokens]x1024xf32> -> vector<32xf32> + %scv0 = vector.splat %scale : vector<32xf32> + %q0 = vector.mulf %qr0, %scv0 : vector<32xf32> + %qc10 = index.constant 32 : index + %qc11 = index.add %qcol, %qc10 : index + %qc1 = index.assume %qc11 [range(%qc11, 0, 992)] : index + %qr1 = vector.load %qv[%t, %qc1] : view<[%tokens]x1024xf32> -> vector<32xf32> + %scv1 = vector.splat %scale : vector<32xf32> + %q1 = vector.mulf %qr1, %scv1 : vector<32xf32> + %m_l, %l_l, %acc0_l, %acc1_l = scf.for %j = [%lane to %tokens step %c32](%m_c = %neg_big : f32, %l_c = %zf : f32, %acc0_c = %zero32 : vector<32xf32>, %acc1_c = %zero32 : vector<32xf32>) -> (f32, f32, vector<32xf32>, vector<32xf32>) { + %bj = index.assume %j [lt(%j, %tokens)] : index + %allowed = index.cmp ult, %bj, %tokens : index + %m_n, %l_n, %acc0_n, %acc1_n = scf.if %allowed -> (f32, f32, vector<32xf32>, vector<32xf32>) { + %kc00 = index.constant 0 : index + %kc01 = index.add %kcol, %kc00 : index + %kc0 = index.assume %kc01 [range(%kc01, 0, 992)] : index + %kr0 = vector.load %kv[%bj, %kc0] : view<[%tokens]x1024xf32> -> vector<32xf32> + %vc01 = index.add %vcol, %kc00 : index + %vc0 = index.assume %vc01 [range(%vc01, 0, 992)] : index + %vr0 = vector.load %vv[%bj, %vc0] : view<[%tokens]x1024xf32> -> vector<32xf32> + %pd0 = vector.mulf %q0, %kr0 : vector<32xf32> + %ps0 = vector.reduce %pd0, %zf : vector<32xf32>, f32 + %kc10 = index.constant 32 : index + %kc11 = index.add %kcol, %kc10 : index + %kc1 = index.assume %kc11 [range(%kc11, 0, 992)] : index + %kr1 = vector.load %kv[%bj, %kc1] : view<[%tokens]x1024xf32> -> vector<32xf32> + %vc11 = index.add %vcol, %kc10 : index + %vc1 = index.assume %vc11 [range(%vc11, 0, 992)] : index + %vr1 = vector.load %vv[%bj, %vc1] : view<[%tokens]x1024xf32> -> vector<32xf32> + %pd1 = vector.mulf %q1, %kr1 : vector<32xf32> + %ps1 = vector.reduce %pd1, %zf : vector<32xf32>, f32 + %ss1 = scalar.addf %ps0, %ps1 : f32 + %s = scalar.addf %ss1, %zf : f32 + %mx = scalar.maxnumf %m_c, %s : f32 + %dm = scalar.subf %m_c, %mx : f32 + %corr = scalar.expf %dm : f32 + %ds = scalar.subf %s, %mx : f32 + %p = scalar.expf %ds : f32 + %lc = scalar.mulf %l_c, %corr : f32 + %ln = scalar.addf %lc, %p : f32 + %corrv = vector.splat %corr : vector<32xf32> + %pv = vector.splat %p : vector<32xf32> + %ac0 = vector.mulf %acc0_c, %corrv : vector<32xf32> + %an0 = vector.fmaf %vr0, %pv, %ac0 : vector<32xf32> + %ac1 = vector.mulf %acc1_c, %corrv : vector<32xf32> + %an1 = vector.fmaf %vr1, %pv, %ac1 : vector<32xf32> + scf.yield %mx, %ln, %an0, %an1 : f32, f32, vector<32xf32>, vector<32xf32> + } else { + scf.yield %m_c, %l_c, %acc0_c, %acc1_c : f32, f32, vector<32xf32>, vector<32xf32> + } + scf.yield %m_n, %l_n, %acc0_n, %acc1_n : f32, f32, vector<32xf32>, vector<32xf32> + } + %mg = kernel.subgroup.reduce %m_l : f32 + %dml = scalar.subf %m_l, %mg : f32 + %cl = scalar.expf %dml : f32 + %lw = scalar.mulf %l_l, %cl : f32 + %lg = kernel.subgroup.reduce %lw : f32 + %one = scalar.constant 1.0 : f32 + %invl = scalar.divf %one, %lg : f32 + %clv = vector.splat %cl : vector<32xf32> + %stage_bytes = index.constant 8192 : offset + %stage = buffer.alloca align(16) %stage_bytes : buffer + %st = buffer.view %stage[%zero] : buffer -> view<32x64xf32> + %aw0 = vector.mulf %acc0_l, %clv : vector<32xf32> + %sc0 = index.constant 0 : index + vector.store %aw0, %st[%lane, %sc0] : vector<32xf32>, view<32x64xf32> + %aw1 = vector.mulf %acc1_l, %clv : vector<32xf32> + %sc1 = index.constant 32 : index + vector.store %aw1, %st[%lane, %sc1] : vector<32xf32>, view<32x64xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + %ov = buffer.view %o[%zero] : buffer -> view<[%tokens]x1024xf32> + %ocol0 = index.mul %h, %cD : index + scf.for %col = [%lane to %cD step %c32] { + %bcol = index.assume %col [lt(%col, %cD)] : index + %tot = scf.for %r = [%c0 to %c32 step %c1](%a = %zf : f32) -> (f32) { + %br = index.assume %r [range(%r, 0, 31)] : index + %x = view.load %st[%br, %bcol] : view<32x64xf32> -> f32 + %na = scalar.addf %a, %x : f32 + scf.yield %na : f32 + } + %res = scalar.mulf %tot, %invl : f32 + %oc0 = index.add %ocol0, %bcol : index + %oc = index.assume %oc0 [lt(%oc0, 1024)] : index + view.store %res, %ov[%t, %oc] : f32, view<[%tokens]x1024xf32> + } + kernel.return +} + +kernel.def export("v_scale_add_1024") @v_scale_add_1024(%rows: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + kernel.launch.config workgroups(%rows, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %h: buffer, %a: buffer, %ls: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 1, 65536)] : index + %r_id = kernel.workgroup.id : index + %r = index.assume %r_id [lt(%r_id, %rows)] : index + %lid = kernel.workitem.id : index + %lane = index.assume %lid [range(%lid, 0, 255)] : index + %zero = index.constant 0 : offset + %c256 = index.constant 256 : index + %cE = index.constant 1024 : index + %hv = buffer.view %h[%zero] : buffer -> view<[%rows]x1024xf32> + %av = buffer.view %a[%zero] : buffer -> view<[%rows]x1024xf32> + %lv = buffer.view %ls[%zero] : buffer -> view<1024xf32> + scf.for %c = [%lane to %cE step %c256] { + %bc = index.assume %c [lt(%c, 1024)] : index + %h0 = view.load %hv[%r, %bc] : view<[%rows]x1024xf32> -> f32 + %a0 = view.load %av[%r, %bc] : view<[%rows]x1024xf32> -> f32 + %l0 = view.load %lv[%bc] : view<1024xf32> -> f32 + %out = scalar.fmaf %a0, %l0, %h0 : f32 + view.store %out, %hv[%r, %bc] : f32, view<[%rows]x1024xf32> + } + kernel.return +} + +kernel.def target(@rdna3) export("v_gemm_f16_store_1024x4096") @v_gemm_f16_store_1024x4096(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 4096 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 1024 : index + %n = index.constant 4096 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv000 = vector.load %w_stage_view[%w_row0, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs000 = vector.fragment %rv000 shape [%c16, %c16] : vector<16xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv010 = vector.load %w_stage_view[%w_row1, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs010 = vector.fragment %rv010 shape [%c16, %c16] : vector<16xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv001 = vector.load %w_stage_view[%w_row0, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs001 = vector.fragment %rv001 shape [%c16, %c16] : vector<16xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv011 = vector.load %w_stage_view[%w_row1, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs011 = vector.fragment %rv011 shape [%c16, %c16] : vector<16xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv002 = vector.load %w_stage_view[%w_row0, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs002 = vector.fragment %rv002 shape [%c16, %c16] : vector<16xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv012 = vector.load %w_stage_view[%w_row1, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs012 = vector.fragment %rv012 shape [%c16, %c16] : vector<16xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv003 = vector.load %w_stage_view[%w_row0, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs003 = vector.fragment %rv003 shape [%c16, %c16] : vector<16xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv013 = vector.load %w_stage_view[%w_row1, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs013 = vector.fragment %rv013 shape [%c16, %c16] : vector<16xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} +kernel.def target(@rdna4) export("v_gemm_f16_store_1024x4096_rdna4") @v_gemm_f16_store_1024x4096_rdna4(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 4096 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 1024 : index + %n = index.constant 4096 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + %w_stage_view_tl = encoding.layout.strided [1, 72] : encoding + %w_stage_view_t = buffer.view %w_stage[%origin] : buffer -> view<72x64xf16, %w_stage_view_tl> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv000_b = index.sub %w_row0, %lane_row : index + %rhs000 = vector.fragment.load %w_stage_view_t[%fc0, %rv000_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv010_b = index.sub %w_row1, %lane_row : index + %rhs010 = vector.fragment.load %w_stage_view_t[%fc0, %rv010_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv001_b = index.sub %w_row0, %lane_row : index + %rhs001 = vector.fragment.load %w_stage_view_t[%fc1, %rv001_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv011_b = index.sub %w_row1, %lane_row : index + %rhs011 = vector.fragment.load %w_stage_view_t[%fc1, %rv011_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv002_b = index.sub %w_row0, %lane_row : index + %rhs002 = vector.fragment.load %w_stage_view_t[%fc2, %rv002_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv012_b = index.sub %w_row1, %lane_row : index + %rhs012 = vector.fragment.load %w_stage_view_t[%fc2, %rv012_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv003_b = index.sub %w_row0, %lane_row : index + %rhs003 = vector.fragment.load %w_stage_view_t[%fc3, %rv003_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv013_b = index.sub %w_row1, %lane_row : index + %rhs013 = vector.fragment.load %w_stage_view_t[%fc3, %rv013_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} + + +kernel.def export("v_bias_gelu_erf_4096") @v_bias_gelu_erf_4096(%rows: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %cols = index.constant 4096 : index + %cg = index.constant 16 : index + kernel.launch.config workgroups(%rows, %cg, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %x: buffer, %bias: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 1, 65536)] : index + %c256 = index.constant 256 : index + %cols = index.constant 4096 : index + %row_id = kernel.workgroup.id : index + %row = index.assume %row_id [lt(%row_id, %rows)] : index + %cg = kernel.workgroup.id : index + %lid = kernel.workitem.id : index + %c = index.madd %cg, %c256, %lid : index + %live = index.cmp ult, %c, %cols : index + scf.if %live { + %bc = index.assume %c [lt(%c, %cols)] : index + %zero = index.constant 0 : offset + %zf = scalar.constant 0.0 : f32 + %xv = buffer.view %x[%zero] : buffer -> view<[%rows]x4096xf32> + %bv = buffer.view %bias[%zero] : buffer -> view<4096xf32> + %x0 = view.load %xv[%row, %bc] : view<[%rows]x4096xf32> -> f32 + %b0 = view.load %bv[%bc] : view<4096xf32> -> f32 + %a = scalar.addf %x0, %b0 : f32 + %one = scalar.constant 1.0 : f32 + %half = scalar.constant 0.5 : f32 + %rs2 = scalar.constant 0.7071067811865476 : f32 + %u = scalar.mulf %a, %rs2 : f32 + %au = scalar.absf %u : f32 + %hz = scalar.mulf %au, %half : f32 + %tden = scalar.addf %hz, %one : f32 + %t = scalar.divf %one, %tden : f32 + %p9 = scalar.constant 0.17087277 : f32 + %p8 = scalar.constant -0.82215223 : f32 + %p7 = scalar.constant 1.48851587 : f32 + %p6 = scalar.constant -1.13520398 : f32 + %p5 = scalar.constant 0.27886807 : f32 + %p4 = scalar.constant -0.18628806 : f32 + %p3 = scalar.constant 0.09678418 : f32 + %p2 = scalar.constant 0.37409196 : f32 + %p1 = scalar.constant 1.00002368 : f32 + %p0 = scalar.constant -1.26551223 : f32 + %q8 = scalar.fmaf %t, %p9, %p8 : f32 + %q7 = scalar.fmaf %t, %q8, %p7 : f32 + %q6 = scalar.fmaf %t, %q7, %p6 : f32 + %q5 = scalar.fmaf %t, %q6, %p5 : f32 + %q4 = scalar.fmaf %t, %q5, %p4 : f32 + %q3 = scalar.fmaf %t, %q4, %p3 : f32 + %q2 = scalar.fmaf %t, %q3, %p2 : f32 + %q1 = scalar.fmaf %t, %q2, %p1 : f32 + %q0 = scalar.fmaf %t, %q1, %p0 : f32 + %u2 = scalar.mulf %au, %au : f32 + %e0 = scalar.subf %q0, %u2 : f32 + %e1 = scalar.expf %e0 : f32 + %erfc = scalar.mulf %t, %e1 : f32 + %erfa = scalar.subf %one, %erfc : f32 + %zf_e = scalar.constant 0.0 : f32 + %neg = scalar.cmpf olt, %u, %zf_e : f32 + %erfn = scalar.negf %erfa : f32 + %erf = scf.select %neg, %erfn, %erfa : f32 + %onep = scalar.addf %erf, %one : f32 + %hx = scalar.mulf %a, %half : f32 + %r = scalar.mulf %hx, %onep : f32 + %yv = buffer.view %y[%zero] : buffer -> view<[%rows]x4096xf32> + view.store %r, %yv[%row, %bc] : f32, view<[%rows]x4096xf32> + } + kernel.return +} + +kernel.def target(@rdna3) export("v_gemm_f16_store_4096x1024") @v_gemm_f16_store_4096x1024(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 1024 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 4096 : index + %n = index.constant 1024 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv000 = vector.load %w_stage_view[%w_row0, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs000 = vector.fragment %rv000 shape [%c16, %c16] : vector<16xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv010 = vector.load %w_stage_view[%w_row1, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs010 = vector.fragment %rv010 shape [%c16, %c16] : vector<16xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv001 = vector.load %w_stage_view[%w_row0, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs001 = vector.fragment %rv001 shape [%c16, %c16] : vector<16xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv011 = vector.load %w_stage_view[%w_row1, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs011 = vector.fragment %rv011 shape [%c16, %c16] : vector<16xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv002 = vector.load %w_stage_view[%w_row0, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs002 = vector.fragment %rv002 shape [%c16, %c16] : vector<16xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv012 = vector.load %w_stage_view[%w_row1, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs012 = vector.fragment %rv012 shape [%c16, %c16] : vector<16xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv003 = vector.load %w_stage_view[%w_row0, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs003 = vector.fragment %rv003 shape [%c16, %c16] : vector<16xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv013 = vector.load %w_stage_view[%w_row1, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs013 = vector.fragment %rv013 shape [%c16, %c16] : vector<16xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} +kernel.def target(@rdna4) export("v_gemm_f16_store_4096x1024_rdna4") @v_gemm_f16_store_4096x1024_rdna4(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 1024 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 4096 : index + %n = index.constant 1024 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + %w_stage_view_tl = encoding.layout.strided [1, 72] : encoding + %w_stage_view_t = buffer.view %w_stage[%origin] : buffer -> view<72x64xf16, %w_stage_view_tl> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv000_b = index.sub %w_row0, %lane_row : index + %rhs000 = vector.fragment.load %w_stage_view_t[%fc0, %rv000_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv010_b = index.sub %w_row1, %lane_row : index + %rhs010 = vector.fragment.load %w_stage_view_t[%fc0, %rv010_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv001_b = index.sub %w_row0, %lane_row : index + %rhs001 = vector.fragment.load %w_stage_view_t[%fc1, %rv001_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv011_b = index.sub %w_row1, %lane_row : index + %rhs011 = vector.fragment.load %w_stage_view_t[%fc1, %rv011_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv002_b = index.sub %w_row0, %lane_row : index + %rhs002 = vector.fragment.load %w_stage_view_t[%fc2, %rv002_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv012_b = index.sub %w_row1, %lane_row : index + %rhs012 = vector.fragment.load %w_stage_view_t[%fc2, %rv012_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv003_b = index.sub %w_row0, %lane_row : index + %rhs003 = vector.fragment.load %w_stage_view_t[%fc3, %rv003_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv013_b = index.sub %w_row1, %lane_row : index + %rhs013 = vector.fragment.load %w_stage_view_t[%fc3, %rv013_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} + + +kernel.def export("v_merge2_skip1_1024") @v_merge2_skip1_1024(%out_tokens: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + kernel.launch.config workgroups(%out_tokens, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%out_tokens_arg: index, %gw_arg: index, %tokens_arg: index, %x: buffer, %y: buffer) { + %out_tokens = index.assume %out_tokens_arg [range(%out_tokens_arg, 1, 65536)] : index + %gw = index.assume %gw_arg [range(%gw_arg, 2, 4096)] : index + %tokens = index.assume %tokens_arg [range(%tokens_arg, 1, 65536)] : index + %o_id = kernel.workgroup.id : index + %o = index.assume %o_id [lt(%o_id, %out_tokens)] : index + %lid = kernel.workitem.id : index + %lane = index.assume %lid [range(%lid, 0, 255)] : index + %zero = index.constant 0 : offset + %c256 = index.constant 256 : index + %cm = index.constant 2 : index + %cE = index.constant 1024 : index + %cSKIP = index.constant 1 : index + %cEO = index.constant 4096 : index + %ow0 = index.div %gw, %cm : index + %ow = index.assume %ow0 [range(%ow0, 1, 4096)] : index + %oy = index.div %o, %ow : index + %ox = index.rem %o, %ow : index + %xv = buffer.view %x[%zero] : buffer -> view<[%tokens]x1024xf32> + %yv = buffer.view %y[%zero] : buffer -> view<[%out_tokens]x4096xf32> + scf.for %f = [%lane to %cEO step %c256] { + %bf = index.assume %f [lt(%f, %cEO)] : index + %s = index.div %bf, %cE : index + %bc0 = index.rem %bf, %cE : index + %bc = index.assume %bc0 [lt(%bc0, 1024)] : index + %ry = index.div %s, %cm : index + %rx = index.rem %s, %cm : index + %yy = index.madd %oy, %cm, %ry : index + %xx = index.madd %ox, %cm, %rx : index + %src0 = index.madd %yy, %gw, %xx : index + %src = index.add %src0, %cSKIP : index + %bs = index.assume %src [lt(%src, %tokens)] : index + %val = view.load %xv[%bs, %bc] : view<[%tokens]x1024xf32> -> f32 + view.store %val, %yv[%o, %bf] : f32, view<[%out_tokens]x4096xf32> + } + kernel.return +} + +kernel.def target(@rdna3) export("v_gemm_f16_store_4096x4096") @v_gemm_f16_store_4096x4096(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 4096 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 4096 : index + %n = index.constant 4096 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv000 = vector.load %w_stage_view[%w_row0, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs000 = vector.fragment %rv000 shape [%c16, %c16] : vector<16xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv010 = vector.load %w_stage_view[%w_row1, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs010 = vector.fragment %rv010 shape [%c16, %c16] : vector<16xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv001 = vector.load %w_stage_view[%w_row0, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs001 = vector.fragment %rv001 shape [%c16, %c16] : vector<16xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv011 = vector.load %w_stage_view[%w_row1, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs011 = vector.fragment %rv011 shape [%c16, %c16] : vector<16xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv002 = vector.load %w_stage_view[%w_row0, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs002 = vector.fragment %rv002 shape [%c16, %c16] : vector<16xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv012 = vector.load %w_stage_view[%w_row1, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs012 = vector.fragment %rv012 shape [%c16, %c16] : vector<16xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv003 = vector.load %w_stage_view[%w_row0, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs003 = vector.fragment %rv003 shape [%c16, %c16] : vector<16xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv013 = vector.load %w_stage_view[%w_row1, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs013 = vector.fragment %rv013 shape [%c16, %c16] : vector<16xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} +kernel.def target(@rdna4) export("v_gemm_f16_store_4096x4096_rdna4") @v_gemm_f16_store_4096x4096_rdna4(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 4096 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 4096 : index + %n = index.constant 4096 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + %w_stage_view_tl = encoding.layout.strided [1, 72] : encoding + %w_stage_view_t = buffer.view %w_stage[%origin] : buffer -> view<72x64xf16, %w_stage_view_tl> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv000_b = index.sub %w_row0, %lane_row : index + %rhs000 = vector.fragment.load %w_stage_view_t[%fc0, %rv000_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv010_b = index.sub %w_row1, %lane_row : index + %rhs010 = vector.fragment.load %w_stage_view_t[%fc0, %rv010_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv001_b = index.sub %w_row0, %lane_row : index + %rhs001 = vector.fragment.load %w_stage_view_t[%fc1, %rv001_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv011_b = index.sub %w_row1, %lane_row : index + %rhs011 = vector.fragment.load %w_stage_view_t[%fc1, %rv011_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv002_b = index.sub %w_row0, %lane_row : index + %rhs002 = vector.fragment.load %w_stage_view_t[%fc2, %rv002_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv012_b = index.sub %w_row1, %lane_row : index + %rhs012 = vector.fragment.load %w_stage_view_t[%fc2, %rv012_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv003_b = index.sub %w_row0, %lane_row : index + %rhs003 = vector.fragment.load %w_stage_view_t[%fc3, %rv003_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv013_b = index.sub %w_row1, %lane_row : index + %rhs013 = vector.fragment.load %w_stage_view_t[%fc3, %rv013_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} + + +kernel.def export("v_ew_gelu_erf") @v_ew_gelu_erf(%n: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %c255 = index.constant 255 : index + %n_up = index.add %n, %c255 : index + %groups = index.div %n_up, %c256 : index + kernel.launch.config workgroups(%groups, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%n_arg: index, %x: buffer, %y: buffer) { + %n = index.assume %n_arg [range(%n_arg, 1, 268435456)] : index + %c256 = index.constant 256 : index + %gid = kernel.workgroup.id : index + %lid = kernel.workitem.id : index + %i = index.madd %gid, %c256, %lid : index + %live = index.cmp ult, %i, %n : index + scf.if %live { + %bi = index.assume %i [lt(%i, %n)] : index + %zero = index.constant 0 : offset + %xv = buffer.view %x[%zero] : buffer -> view<[%n]xf32> + %a = view.load %xv[%bi] : view<[%n]xf32> -> f32 + + %one = scalar.constant 1.0 : f32 + %half = scalar.constant 0.5 : f32 + %rs2 = scalar.constant 0.7071067811865476 : f32 + %u = scalar.mulf %a, %rs2 : f32 + %au = scalar.absf %u : f32 + %hz = scalar.mulf %au, %half : f32 + %tden = scalar.addf %hz, %one : f32 + %t = scalar.divf %one, %tden : f32 + %p9 = scalar.constant 0.17087277 : f32 + %p8 = scalar.constant -0.82215223 : f32 + %p7 = scalar.constant 1.48851587 : f32 + %p6 = scalar.constant -1.13520398 : f32 + %p5 = scalar.constant 0.27886807 : f32 + %p4 = scalar.constant -0.18628806 : f32 + %p3 = scalar.constant 0.09678418 : f32 + %p2 = scalar.constant 0.37409196 : f32 + %p1 = scalar.constant 1.00002368 : f32 + %p0 = scalar.constant -1.26551223 : f32 + %q8 = scalar.fmaf %t, %p9, %p8 : f32 + %q7 = scalar.fmaf %t, %q8, %p7 : f32 + %q6 = scalar.fmaf %t, %q7, %p6 : f32 + %q5 = scalar.fmaf %t, %q6, %p5 : f32 + %q4 = scalar.fmaf %t, %q5, %p4 : f32 + %q3 = scalar.fmaf %t, %q4, %p3 : f32 + %q2 = scalar.fmaf %t, %q3, %p2 : f32 + %q1 = scalar.fmaf %t, %q2, %p1 : f32 + %q0 = scalar.fmaf %t, %q1, %p0 : f32 + %u2 = scalar.mulf %au, %au : f32 + %e0 = scalar.subf %q0, %u2 : f32 + %e1 = scalar.expf %e0 : f32 + %erfc = scalar.mulf %t, %e1 : f32 + %erfa = scalar.subf %one, %erfc : f32 + %zf_e = scalar.constant 0.0 : f32 + %neg = scalar.cmpf olt, %u, %zf_e : f32 + %erfn = scalar.negf %erfa : f32 + %erf = scf.select %neg, %erfn, %erfa : f32 + %onep = scalar.addf %erf, %one : f32 + %hx = scalar.mulf %a, %half : f32 + %r = scalar.mulf %hx, %onep : f32 + %yv = buffer.view %y[%zero] : buffer -> view<[%n]xf32> + view.store %r, %yv[%bi] : f32, view<[%n]xf32> + } + kernel.return +} + +kernel.def target(@rdna3) export("v_gemm_f16_store_4096x2304") @v_gemm_f16_store_4096x2304(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 2304 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 4096 : index + %n = index.constant 2304 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv000 = vector.load %w_stage_view[%w_row0, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs000 = vector.fragment %rv000 shape [%c16, %c16] : vector<16xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv010 = vector.load %w_stage_view[%w_row1, %fc0] : view<64x72xf16> -> vector<16xf16> + %rhs010 = vector.fragment %rv010 shape [%c16, %c16] : vector<16xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv001 = vector.load %w_stage_view[%w_row0, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs001 = vector.fragment %rv001 shape [%c16, %c16] : vector<16xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv011 = vector.load %w_stage_view[%w_row1, %fc1] : view<64x72xf16> -> vector<16xf16> + %rhs011 = vector.fragment %rv011 shape [%c16, %c16] : vector<16xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv002 = vector.load %w_stage_view[%w_row0, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs002 = vector.fragment %rv002 shape [%c16, %c16] : vector<16xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv012 = vector.load %w_stage_view[%w_row1, %fc2] : view<64x72xf16> -> vector<16xf16> + %rhs012 = vector.fragment %rv012 shape [%c16, %c16] : vector<16xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<16xf16> + %rv003 = vector.load %w_stage_view[%w_row0, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs003 = vector.fragment %rv003 shape [%c16, %c16] : vector<16xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + %rv013 = vector.load %w_stage_view[%w_row1, %fc3] : view<64x72xf16> -> vector<16xf16> + %rhs013 = vector.fragment %rv013 shape [%c16, %c16] : vector<16xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<16xf16>, vector<16xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} +kernel.def target(@rdna4) export("v_gemm_f16_store_4096x2304_rdna4") @v_gemm_f16_store_4096x2304_rdna4(%rows: index, %n: index) { + %c1 = index.constant 1 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %row_tiles = index.div %rows, %c64 : index + %n_const = index.constant 2304 : index + %out_tiles = index.div %n_const, %c64 : index + kernel.launch.config workgroups(%row_tiles, %out_tiles, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%rows_arg: index, %k_arg: index, %n_arg: index, %x: buffer, %scales: buffer, %w: buffer, %y: buffer) { + %rows = index.assume %rows_arg [range(%rows_arg, 64, 65536), multiple_of(%rows_arg, 64)] : index + %k = index.constant 4096 : index + %n = index.constant 2304 : index + %origin = index.constant 0 : offset + %two = index.constant 2 : offset + %sixteen = index.constant 16 : offset + %block_bytes = index.constant 64 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c4 = index.constant 4 : index + %c8 = index.constant 8 : index + %c16 = index.constant 16 : index + %c32 = index.constant 32 : index + %c64 = index.constant 64 : index + %c256 = index.constant 256 : index + %nibble_mask = vector.splati 252645135 : vector<4xi32> + %stage_bytes = index.constant 9216 : offset + %row_tile_count = index.div %rows, %c64 : index + %out_tile_count = index.div %n, %c64 : index + %row_group_id = kernel.workgroup.id : index + %out_group_id = kernel.workgroup.id : index + %row_group = index.assume %row_group_id [lt(%row_group_id, %row_tile_count)] : index + %out_group = index.assume %out_group_id [lt(%out_group_id, %out_tile_count)] : index + %workitem_id = kernel.workitem.id : index + %workitem = index.assume %workitem_id [range(%workitem_id, 0, 255)] : index + %subgroup = kernel.subgroup.id : index + %lane = kernel.subgroup.lane.id : index + %lane_row = index.rem %lane, %c16 : index + %bounded_subgroup = index.assume %subgroup [range(%subgroup, 0, 7)] : index + %wave_row_group = index.div %bounded_subgroup, %c2 : index + %wave_out_group = index.rem %bounded_subgroup, %c2 : index + %wave_row = index.mul %wave_row_group, %c16 : index + %wave_out = index.mul %wave_out_group, %c32 : index + %w_row0 = index.add %wave_out, %lane_row : index + %w_row1 = index.add %w_row0, %c16 : index + %row_origin = index.mul %row_group, %c64 : index + %out_origin = index.mul %out_group, %c64 : index + %result_row = index.add %row_origin, %wave_row : index + %result_col0 = index.add %out_origin, %wave_out : index + %result_col1 = index.add %result_col0, %c16 : index + %blocks = index.div %k, %c32 : index + %row_bytes = index.scale %blocks, %block_bytes : index, offset -> offset + %x_view = buffer.view %x[%origin] : buffer -> view<[%rows]x[%k]xf16> + // 64x64 output tile with the full row stride n. + %y_layout = encoding.layout.strided [%n, %c1] : encoding + %tile_first = index.madd %row_origin, %n, %out_origin : index + %four = index.constant 4 : offset + %tile_offset = index.scale %tile_first, %four : index, offset -> offset + %y_view = buffer.view %y[%tile_offset] : buffer -> view<64x64xf32, %y_layout> + %bounded_wave_row = index.assume %wave_row [range(%wave_row, 0, 48)] : index + %bounded_wave_out = index.assume %wave_out [range(%wave_out, 0, 32)] : index + %wave_out1 = index.add %bounded_wave_out, %c16 : index + %x_stage = buffer.alloca align(16) %stage_bytes : buffer + %x_stage_view = buffer.view %x_stage[%origin] : buffer -> view<64x72xf16> + %w_stage = buffer.alloca align(16) %stage_bytes : buffer + %w_stage_view = buffer.view %w_stage[%origin] : buffer -> view<64x72xf16> + %w_stage_view_tl = encoding.layout.strided [1, 72] : encoding + %w_stage_view_t = buffer.view %w_stage[%origin] : buffer -> view<72x64xf16, %w_stage_view_tl> + // Thread t stages 16 values: row t/4, columns (t%4)*16. + %stage_row = index.div %workitem, %c4 : index + %stage_quarter = index.rem %workitem, %c4 : index + %stage_col = index.mul %stage_quarter, %c16 : index + %x_row = index.add %row_origin, %stage_row : index + %bounded_x_row = index.assume %x_row [lt(%x_row, %rows)] : index + %w_out_row = index.add %out_origin, %stage_row : index + %bounded_w_out_row = index.assume %w_out_row [lt(%w_out_row, %n)] : index + %w_row_origin = index.scale %bounded_w_out_row, %row_bytes : index, offset -> offset + %zero8 = vector.splatf 0.0 : vector<8xf32> + %init = vector.fragment %zero8 shape [%c16, %c16] : vector<8xf32> + %k_steps = index.div %k, %c64 : index + %s_view = buffer.view %scales[%origin] : buffer -> view<[%rows]x2xf32> + %x_scale = view.load %s_view[%bounded_x_row, %c0] : view<[%rows]x2xf32> -> f32 + %x_scales = vector.splat %x_scale : vector<16xf32> + %a0_raw, %a1_raw = scf.for %step = [%c0 to %k_steps step %c1](%a0_acc = %init : vector<8xf32>, %a1_acc = %init : vector<8xf32>) -> (vector<8xf32>, vector<8xf32>) { + %k_origin = index.mul %step, %c64 : index + %x_col = index.add %k_origin, %stage_col : index + %x_half = vector.load %x_view[%bounded_x_row, %x_col] : view<[%rows]x[%k]xf16> -> vector<16xf16> + vector.store %x_half, %x_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + %w_col = index.add %k_origin, %stage_col : index + + %deq0_two_b = index.constant 2 : offset + %deq0_col_bytes = index.scale %w_col, %deq0_two_b : index, offset -> offset + %deq0_origin = index.add %w_row_origin, %deq0_col_bytes : offset + %deq0_view = buffer.view %w[%deq0_origin] : buffer -> view<16xf16> + %deq0 = vector.load %deq0_view[0] : view<16xf16> -> vector<16xf16> + vector.store %deq0, %w_stage_view[%stage_row, %stage_col] : vector<16xf16>, view<64x72xf16> + kernel.barrier scope(workgroup) ordering(acq_rel) + %fc0 = index.constant 0 : index + %lhs0 = vector.fragment.load %x_stage_view[%wave_row, %fc0] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv000_b = index.sub %w_row0, %lane_row : index + %rhs000 = vector.fragment.load %w_stage_view_t[%fc0, %rv000_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_0 = vector.mma %lhs0, %rhs000, %a0_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv010_b = index.sub %w_row1, %lane_row : index + %rhs010 = vector.fragment.load %w_stage_view_t[%fc0, %rv010_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_0 = vector.mma %lhs0, %rhs010, %a1_acc : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc1 = index.constant 16 : index + %lhs1 = vector.fragment.load %x_stage_view[%wave_row, %fc1] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv001_b = index.sub %w_row0, %lane_row : index + %rhs001 = vector.fragment.load %w_stage_view_t[%fc1, %rv001_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_1 = vector.mma %lhs1, %rhs001, %na0_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv011_b = index.sub %w_row1, %lane_row : index + %rhs011 = vector.fragment.load %w_stage_view_t[%fc1, %rv011_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_1 = vector.mma %lhs1, %rhs011, %na1_0 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc2 = index.constant 32 : index + %lhs2 = vector.fragment.load %x_stage_view[%wave_row, %fc2] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv002_b = index.sub %w_row0, %lane_row : index + %rhs002 = vector.fragment.load %w_stage_view_t[%fc2, %rv002_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_2 = vector.mma %lhs2, %rhs002, %na0_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv012_b = index.sub %w_row1, %lane_row : index + %rhs012 = vector.fragment.load %w_stage_view_t[%fc2, %rv012_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_2 = vector.mma %lhs2, %rhs012, %na1_1 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %fc3 = index.constant 48 : index + %lhs3 = vector.fragment.load %x_stage_view[%wave_row, %fc3] shape [%c16, %c16] : view<64x72xf16> -> vector<8xf16> + %rv003_b = index.sub %w_row0, %lane_row : index + %rhs003 = vector.fragment.load %w_stage_view_t[%fc3, %rv003_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na0_3 = vector.mma %lhs3, %rhs003, %na0_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + %rv013_b = index.sub %w_row1, %lane_row : index + %rhs013 = vector.fragment.load %w_stage_view_t[%fc3, %rv013_b] shape [%c16, %c16] : view<72x64xf16, %w_stage_view_tl> -> vector<8xf16> + %na1_3 = vector.mma %lhs3, %rhs013, %na1_2 : vector<8xf16>, vector<8xf16>, vector<8xf32> + kernel.barrier scope(workgroup) ordering(acq_rel) + scf.yield %na0_3, %na1_3 : vector<8xf32>, vector<8xf32> + } + %inv_bytes = index.constant 4096 : offset + %inv_view = buffer.view %x_stage[%origin] : buffer -> view<64x16xf32> + %writer = index.cmp ult, %workitem, %c64 : index + scf.if %writer { + %inv_row_value = index.add %row_origin, %workitem : index + %inv_row = index.assume %inv_row_value [lt(%inv_row_value, %rows)] : index + %inverse = view.load %s_view[%inv_row, %c1] : view<[%rows]x2xf32> -> f32 + %inverse16 = vector.splat %inverse : vector<16xf32> + %bw = index.assume %workitem [range(%workitem, 0, 63)] : index + vector.store %inverse16, %inv_view[%bw, %c0] : vector<16xf32>, view<64x16xf32> + } + kernel.barrier scope(workgroup) ordering(acq_rel) + %inv_frag = vector.fragment.load %inv_view[%wave_row, %c0] shape [%c16, %c16] : view<64x16xf32> -> vector<8xf32> + %a0 = vector.mulf %a0_raw, %inv_frag : vector<8xf32> + %a1 = vector.mulf %a1_raw, %inv_frag : vector<8xf32> + vector.fragment.store %a0, %y_view[%bounded_wave_row, %bounded_wave_out] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + vector.fragment.store %a1, %y_view[%bounded_wave_row, %wave_out1] shape [%c16, %c16] : vector<8xf32>, view<64x64xf32, %y_layout> + kernel.return +} + +template.decl @sel1_v_gemm_f16_store_1024x1024(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<2097152xi8>, %a6: buffer) +template.def<@sel1_v_gemm_f16_store_1024x1024> target(@rdna3) @sel1_v_gemm_f16_store_1024x1024_rdna3(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<2097152xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_1024x1024[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<2097152xi8>, buffer) + template.return +} +template.def<@sel1_v_gemm_f16_store_1024x1024> target(@rdna4) @sel1_v_gemm_f16_store_1024x1024_rdna4(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<2097152xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_1024x1024_rdna4[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<2097152xi8>, buffer) + template.return +} +template.decl @sel2_v_gemm_f16_store_1024x4096(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<8388608xi8>, %a6: buffer) +template.def<@sel2_v_gemm_f16_store_1024x4096> target(@rdna3) @sel2_v_gemm_f16_store_1024x4096_rdna3(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<8388608xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_1024x4096[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<8388608xi8>, buffer) + template.return +} +template.def<@sel2_v_gemm_f16_store_1024x4096> target(@rdna4) @sel2_v_gemm_f16_store_1024x4096_rdna4(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<8388608xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_1024x4096_rdna4[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<8388608xi8>, buffer) + template.return +} +template.decl @sel3_v_gemm_f16_store_4096x1024(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<8388608xi8>, %a6: buffer) +template.def<@sel3_v_gemm_f16_store_4096x1024> target(@rdna3) @sel3_v_gemm_f16_store_4096x1024_rdna3(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<8388608xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_4096x1024[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<8388608xi8>, buffer) + template.return +} +template.def<@sel3_v_gemm_f16_store_4096x1024> target(@rdna4) @sel3_v_gemm_f16_store_4096x1024_rdna4(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<8388608xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_4096x1024_rdna4[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<8388608xi8>, buffer) + template.return +} +template.decl @sel4_v_gemm_f16_store_4096x4096(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<33554432xi8>, %a6: buffer) +template.def<@sel4_v_gemm_f16_store_4096x4096> target(@rdna3) @sel4_v_gemm_f16_store_4096x4096_rdna3(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<33554432xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_4096x4096[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<33554432xi8>, buffer) + template.return +} +template.def<@sel4_v_gemm_f16_store_4096x4096> target(@rdna4) @sel4_v_gemm_f16_store_4096x4096_rdna4(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<33554432xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_4096x4096_rdna4[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<33554432xi8>, buffer) + template.return +} +template.decl @sel5_v_gemm_f16_store_4096x2304(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<18874368xi8>, %a6: buffer) +template.def<@sel5_v_gemm_f16_store_4096x2304> target(@rdna3) @sel5_v_gemm_f16_store_4096x2304_rdna3(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<18874368xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_4096x2304[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<18874368xi8>, buffer) + template.return +} +template.def<@sel5_v_gemm_f16_store_4096x2304> target(@rdna4) @sel5_v_gemm_f16_store_4096x2304_rdna4(%g0: index, %g1: index, %a0: index, %a1: index, %a2: index, %a3: buffer, %a4: buffer, %a5: view<18874368xi8>, %a6: buffer) { + kernel.launch @v_gemm_f16_store_4096x2304_rdna4[%g0, %g1](%a0, %a1, %a2, %a3, %a4, %a5, %a6) : [index, index](index, index, index, buffer, buffer, view<18874368xi8>, buffer) + template.return +} + + +kernel.def export("v_resize_bicubic_h_hdr") @v_resize_bicubic_h_hdr(%out_w: index, %max_rows: index) { + %count = index.mul %out_w, %max_rows : index + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %c255 = index.constant 255 : index + %n_up = index.add %count, %c255 : index + %groups = index.div %n_up, %c256 : index + kernel.launch.config workgroups(%groups, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%out_n_arg: index, %other_arg: index, %src: buffer, %dst: buffer) { + %zero_h = index.constant 0 : offset + %hv = buffer.view %src[%zero_h] : buffer -> view<16xi32> + %in_w32 = view.load %hv[0] : view<16xi32> -> i32 + %rows32 = view.load %hv[1] : view<16xi32> -> i32 + %cin32 = view.load %hv[2] : view<16xi32> -> i32 + %pix32 = view.load %hv[3] : view<16xi32> -> i32 + %in_b = scalar.assume %in_w32 [range(%in_w32, 1, 16384)] : i32 + %in_n = index.cast %in_b : i32 to index + %rows_b = scalar.assume %rows32 [range(%rows32, 1, 16384)] : i32 + %rows_i = index.cast %rows_b : i32 to index + %cin_b = scalar.assume %cin32 [range(%cin32, 3, 4)] : i32 + %cin_i = index.cast %cin_b : i32 to index + %pix_b = scalar.assume %pix32 [range(%pix32, 0, 2147483647)] : i32 + %pix_i = index.cast %pix_b : i32 to index + %out_n = index.assume %out_n_arg [range(%out_n_arg, 1, 65536)] : index + %other = index.assume %other_arg [range(%other_arg, 1, 65536)] : index + %count = index.mul %rows_i, %out_n : index + %c256 = index.constant 256 : index + %gid = kernel.workgroup.id : index + %lid = kernel.workitem.id : index + %i = index.madd %gid, %c256, %lid : index + %live = index.cmp ult, %i, %count : index + scf.if %live { + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c3 = index.constant 3 : index + %ccin = index.add %cin_i, %c0 : index + %zf = scalar.constant 0.0 : f32 + %onef = scalar.constant 1.0 : f32 + %halff = scalar.constant 0.5 : f32 + %twof = scalar.constant 2.0 : f32 + %threef = scalar.constant 3.0 : f32 + %m3f = scalar.constant -3.0 : f32 + %fourf = scalar.constant 4.0 : f32 + %fivef = scalar.constant 5.0 : f32 + %eightf = scalar.constant 8.0 : f32 + %c1p5 = scalar.constant 1.5 : f32 + %c2p5 = scalar.constant 2.5 : f32 + %mhalf = scalar.constant -0.5 : f32 + %pif = scalar.constant 3.141592653589793 : f32 + %tinyf = scalar.constant 1.0e-12 : f32 + %fxp = scalar.constant 4194304.0 : f32 + %o = index.rem %i, %out_n : index + %row = index.div %i, %out_n : index + %in_i = index.cast %in_n : index to i32 + %out_i = index.cast %out_n : index to i32 + %in_f = scalar.sitofp %in_i : i32 to f32 + %out_f = scalar.sitofp %out_i : i32 to f32 + %scale = scalar.divf %in_f, %out_f : f32 + %fs = scalar.maxnumf %scale, %onef : f32 + %supc = scalar.constant 2.0 : f32 + %support = scalar.mulf %supc, %fs : f32 + %ss = scalar.divf %onef, %fs : f32 + %oi = index.cast %o : index to i32 + %of = scalar.sitofp %oi : i32 to f32 + %oh = scalar.addf %of, %halff : f32 + %center = scalar.mulf %oh, %scale : f32 + %lo0 = scalar.subf %center, %support : f32 + %lo1 = scalar.addf %lo0, %halff : f32 + %lo2 = scalar.fptosi %lo1 : f32 to i32 + %zi = scalar.constant 0 : i32 + %lo3 = scalar.maxsi %lo2, %zi : i32 + %hi0 = scalar.addf %center, %support : f32 + %hi1 = scalar.addf %hi0, %halff : f32 + %hi2 = scalar.fptosi %hi1 : f32 to i32 + %hi3 = scalar.minsi %hi2, %in_i : i32 + %lo4 = scalar.assume %lo3 [range(%lo3, 0, 65536)] : i32 + %hi4 = scalar.assume %hi3 [range(%hi3, 0, 65536)] : i32 + %xlo = index.cast %lo4 : i32 to index + %xhi = index.cast %hi4 : i32 to index + %ww = scf.for %xi = [%xlo to %xhi step %c1](%acc = %zf : f32) -> (f32) { + %xii = index.cast %xi : index to i32 + %xf = scalar.sitofp %xii : i32 to f32 + %d0 = scalar.subf %xf, %center : f32 + %d1 = scalar.addf %d0, %halff : f32 + %d = scalar.mulf %d1, %ss : f32 + %wv_x = scalar.absf %d : f32 + %wv_lt1 = scalar.cmpf olt, %wv_x, %onef : f32 + %wv_lt2 = scalar.cmpf olt, %wv_x, %twof : f32 + %wv_p1a = scalar.mulf %wv_x, %c1p5 : f32 + %wv_p1b = scalar.subf %wv_p1a, %c2p5 : f32 + %wv_p1c = scalar.mulf %wv_p1b, %wv_x : f32 + %wv_p1d = scalar.mulf %wv_p1c, %wv_x : f32 + %wv_p1 = scalar.addf %wv_p1d, %onef : f32 + %wv_p2a = scalar.subf %wv_x, %fivef : f32 + %wv_p2b = scalar.mulf %wv_p2a, %wv_x : f32 + %wv_p2c = scalar.addf %wv_p2b, %eightf : f32 + %wv_p2d = scalar.mulf %wv_p2c, %wv_x : f32 + %wv_p2e = scalar.subf %wv_p2d, %fourf : f32 + %wv_p2 = scalar.mulf %wv_p2e, %mhalf : f32 + %wv_q = scf.select %wv_lt2, %wv_p2, %zf : f32 + %wv = scf.select %wv_lt1, %wv_p1, %wv_q : f32 + %na = scalar.addf %acc, %wv : f32 + scf.yield %na : f32 + } + %wnz = scalar.cmpf one, %ww, %zf : f32 + %wdiv = scf.select %wnz, %ww, %onef : f32 + %srcn = index.constant 268435456 : index + %sv = buffer.view %src[%zero] : buffer -> view<[%srcn]xi8> + %bias = scalar.constant 2097152 : i32 + %s0, %s1, %s2 = scf.for %xi = [%xlo to %xhi step %c1](%a0 = %bias : i32, %a1 = %bias : i32, %a2 = %bias : i32) -> (i32, i32, i32) { + %xii = index.cast %xi : index to i32 + %xf = scalar.sitofp %xii : i32 to f32 + %d0 = scalar.subf %xf, %center : f32 + %d1 = scalar.addf %d0, %halff : f32 + %d = scalar.mulf %d1, %ss : f32 + %wv_x = scalar.absf %d : f32 + %wv_lt1 = scalar.cmpf olt, %wv_x, %onef : f32 + %wv_lt2 = scalar.cmpf olt, %wv_x, %twof : f32 + %wv_p1a = scalar.mulf %wv_x, %c1p5 : f32 + %wv_p1b = scalar.subf %wv_p1a, %c2p5 : f32 + %wv_p1c = scalar.mulf %wv_p1b, %wv_x : f32 + %wv_p1d = scalar.mulf %wv_p1c, %wv_x : f32 + %wv_p1 = scalar.addf %wv_p1d, %onef : f32 + %wv_p2a = scalar.subf %wv_x, %fivef : f32 + %wv_p2b = scalar.mulf %wv_p2a, %wv_x : f32 + %wv_p2c = scalar.addf %wv_p2b, %eightf : f32 + %wv_p2d = scalar.mulf %wv_p2c, %wv_x : f32 + %wv_p2e = scalar.subf %wv_p2d, %fourf : f32 + %wv_p2 = scalar.mulf %wv_p2e, %mhalf : f32 + %wv_q = scf.select %wv_lt2, %wv_p2, %zf : f32 + %wv = scf.select %wv_lt1, %wv_p1, %wv_q : f32 + %wn = scalar.divf %wv, %wdiv : f32 + %wfx = scalar.mulf %wn, %fxp : f32 + %neg = scalar.cmpf olt, %wn, %zf : f32 + %rnd = scf.select %neg, %mhalf, %halff : f32 + %wr = scalar.addf %wfx, %rnd : f32 + %wi = scalar.fptosi %wr : f32 to i32 + %src_idx = index.madd %row, %in_n, %xi : index + %el_rel = index.mul %src_idx, %ccin : index + %el0 = index.add %el_rel, %pix_i : index + %el = index.assume %el0 [lt(%el0, %srcn)] : index + %el1r = index.add %el0, %c1 : index + %el1 = index.assume %el1r [lt(%el1r, %srcn)] : index + %el2r = index.add %el1r, %c1 : index + %el2 = index.assume %el2r [lt(%el2r, %srcn)] : index + %p0r = view.load %sv[%el] : view<[%srcn]xi8> -> i8 + %p1r = view.load %sv[%el1] : view<[%srcn]xi8> -> i8 + %p2r = view.load %sv[%el2] : view<[%srcn]xi8> -> i8 + %p0 = scalar.extui %p0r : i8 to i32 + %p1 = scalar.extui %p1r : i8 to i32 + %p2 = scalar.extui %p2r : i8 to i32 + %m0 = scalar.muli %p0, %wi : i32 + %m1 = scalar.muli %p1, %wi : i32 + %m2 = scalar.muli %p2, %wi : i32 + %n0 = scalar.addi %a0, %m0 : i32 + %n1 = scalar.addi %a1, %m1 : i32 + %n2 = scalar.addi %a2, %m2 : i32 + scf.yield %n0, %n1, %n2 : i32, i32, i32 + } + %sh = scalar.constant 22 : i32 + %c255i = scalar.constant 255 : i32 + %dst_idx = index.madd %row, %out_n, %o : index + %dstn = index.constant 268435456 : index + %dv = buffer.view %dst[%zero] : buffer -> view<[%dstn]xi8> + %de0 = index.mul %dst_idx, %c3 : index + %c2x = index.constant 2 : index + %q0a = scalar.shrsi %s0, %sh : i32 + %q0b = scalar.maxsi %q0a, %zi : i32 + %q0c = scalar.minsi %q0b, %c255i : i32 + %q0 = scalar.trunci %q0c : i32 to i8 + %dc0r = index.add %de0, %c0 : index + %dc0 = index.assume %dc0r [lt(%dc0r, %dstn)] : index + view.store %q0, %dv[%dc0] : i8, view<[%dstn]xi8> + %q1a = scalar.shrsi %s1, %sh : i32 + %q1b = scalar.maxsi %q1a, %zi : i32 + %q1c = scalar.minsi %q1b, %c255i : i32 + %q1 = scalar.trunci %q1c : i32 to i8 + %dc1r = index.add %de0, %c1 : index + %dc1 = index.assume %dc1r [lt(%dc1r, %dstn)] : index + view.store %q1, %dv[%dc1] : i8, view<[%dstn]xi8> + %q2a = scalar.shrsi %s2, %sh : i32 + %q2b = scalar.maxsi %q2a, %zi : i32 + %q2c = scalar.minsi %q2b, %c255i : i32 + %q2 = scalar.trunci %q2c : i32 to i8 + %dc2r = index.add %de0, %c2x : index + %dc2 = index.assume %dc2r [lt(%dc2r, %dstn)] : index + view.store %q2, %dv[%dc2] : i8, view<[%dstn]xi8> + } + kernel.return +} + +kernel.def export("v_resize_bicubic_v_hdr") @v_resize_bicubic_v_hdr(%out_h: index, %cols: index) { + %count = index.mul %out_h, %cols : index + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %c255 = index.constant 255 : index + %n_up = index.add %count, %c255 : index + %groups = index.div %n_up, %c256 : index + kernel.launch.config workgroups(%groups, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%out_n_arg: index, %other_arg: index, %hdr: buffer, %src: buffer, %dst: buffer) { + %zero_h = index.constant 0 : offset + %hv = buffer.view %hdr[%zero_h] : buffer -> view<16xi32> + %in_w32 = view.load %hv[1] : view<16xi32> -> i32 + %rows32 = scalar.constant 1 : i32 + %cin32 = scalar.constant 3 : i32 + %pix32 = scalar.constant 0 : i32 + %in_b = scalar.assume %in_w32 [range(%in_w32, 1, 16384)] : i32 + %in_n = index.cast %in_b : i32 to index + %rows_b = scalar.assume %rows32 [range(%rows32, 1, 16384)] : i32 + %rows_i = index.cast %rows_b : i32 to index + %cin_b = scalar.assume %cin32 [range(%cin32, 3, 4)] : i32 + %cin_i = index.cast %cin_b : i32 to index + %pix_b = scalar.assume %pix32 [range(%pix32, 0, 2147483647)] : i32 + %pix_i = index.cast %pix_b : i32 to index + %out_n = index.assume %out_n_arg [range(%out_n_arg, 1, 65536)] : index + %other = index.assume %other_arg [range(%other_arg, 1, 65536)] : index + %count = index.mul %other, %out_n : index + %c256 = index.constant 256 : index + %gid = kernel.workgroup.id : index + %lid = kernel.workitem.id : index + %i = index.madd %gid, %c256, %lid : index + %live = index.cmp ult, %i, %count : index + scf.if %live { + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c3 = index.constant 3 : index + %ccin = index.constant 3 : index + %zf = scalar.constant 0.0 : f32 + %onef = scalar.constant 1.0 : f32 + %halff = scalar.constant 0.5 : f32 + %twof = scalar.constant 2.0 : f32 + %threef = scalar.constant 3.0 : f32 + %m3f = scalar.constant -3.0 : f32 + %fourf = scalar.constant 4.0 : f32 + %fivef = scalar.constant 5.0 : f32 + %eightf = scalar.constant 8.0 : f32 + %c1p5 = scalar.constant 1.5 : f32 + %c2p5 = scalar.constant 2.5 : f32 + %mhalf = scalar.constant -0.5 : f32 + %pif = scalar.constant 3.141592653589793 : f32 + %tinyf = scalar.constant 1.0e-12 : f32 + %fxp = scalar.constant 4194304.0 : f32 + %o_v = index.div %i, %other : index + %col = index.rem %i, %other : index + %in_i = index.cast %in_n : index to i32 + %out_i = index.cast %out_n : index to i32 + %in_f = scalar.sitofp %in_i : i32 to f32 + %out_f = scalar.sitofp %out_i : i32 to f32 + %scale = scalar.divf %in_f, %out_f : f32 + %fs = scalar.maxnumf %scale, %onef : f32 + %supc = scalar.constant 2.0 : f32 + %support = scalar.mulf %supc, %fs : f32 + %ss = scalar.divf %onef, %fs : f32 + %oi = index.cast %o_v : index to i32 + %of = scalar.sitofp %oi : i32 to f32 + %oh = scalar.addf %of, %halff : f32 + %center = scalar.mulf %oh, %scale : f32 + %lo0 = scalar.subf %center, %support : f32 + %lo1 = scalar.addf %lo0, %halff : f32 + %lo2 = scalar.fptosi %lo1 : f32 to i32 + %zi = scalar.constant 0 : i32 + %lo3 = scalar.maxsi %lo2, %zi : i32 + %hi0 = scalar.addf %center, %support : f32 + %hi1 = scalar.addf %hi0, %halff : f32 + %hi2 = scalar.fptosi %hi1 : f32 to i32 + %hi3 = scalar.minsi %hi2, %in_i : i32 + %lo4 = scalar.assume %lo3 [range(%lo3, 0, 65536)] : i32 + %hi4 = scalar.assume %hi3 [range(%hi3, 0, 65536)] : i32 + %xlo = index.cast %lo4 : i32 to index + %xhi = index.cast %hi4 : i32 to index + %ww = scf.for %xi = [%xlo to %xhi step %c1](%acc = %zf : f32) -> (f32) { + %xii = index.cast %xi : index to i32 + %xf = scalar.sitofp %xii : i32 to f32 + %d0 = scalar.subf %xf, %center : f32 + %d1 = scalar.addf %d0, %halff : f32 + %d = scalar.mulf %d1, %ss : f32 + %wv_x = scalar.absf %d : f32 + %wv_lt1 = scalar.cmpf olt, %wv_x, %onef : f32 + %wv_lt2 = scalar.cmpf olt, %wv_x, %twof : f32 + %wv_p1a = scalar.mulf %wv_x, %c1p5 : f32 + %wv_p1b = scalar.subf %wv_p1a, %c2p5 : f32 + %wv_p1c = scalar.mulf %wv_p1b, %wv_x : f32 + %wv_p1d = scalar.mulf %wv_p1c, %wv_x : f32 + %wv_p1 = scalar.addf %wv_p1d, %onef : f32 + %wv_p2a = scalar.subf %wv_x, %fivef : f32 + %wv_p2b = scalar.mulf %wv_p2a, %wv_x : f32 + %wv_p2c = scalar.addf %wv_p2b, %eightf : f32 + %wv_p2d = scalar.mulf %wv_p2c, %wv_x : f32 + %wv_p2e = scalar.subf %wv_p2d, %fourf : f32 + %wv_p2 = scalar.mulf %wv_p2e, %mhalf : f32 + %wv_q = scf.select %wv_lt2, %wv_p2, %zf : f32 + %wv = scf.select %wv_lt1, %wv_p1, %wv_q : f32 + %na = scalar.addf %acc, %wv : f32 + scf.yield %na : f32 + } + %wnz = scalar.cmpf one, %ww, %zf : f32 + %wdiv = scf.select %wnz, %ww, %onef : f32 + %srcn = index.constant 268435456 : index + %sv = buffer.view %src[%zero] : buffer -> view<[%srcn]xi8> + %bias = scalar.constant 2097152 : i32 + %s0, %s1, %s2 = scf.for %xi = [%xlo to %xhi step %c1](%a0 = %bias : i32, %a1 = %bias : i32, %a2 = %bias : i32) -> (i32, i32, i32) { + %xii = index.cast %xi : index to i32 + %xf = scalar.sitofp %xii : i32 to f32 + %d0 = scalar.subf %xf, %center : f32 + %d1 = scalar.addf %d0, %halff : f32 + %d = scalar.mulf %d1, %ss : f32 + %wv_x = scalar.absf %d : f32 + %wv_lt1 = scalar.cmpf olt, %wv_x, %onef : f32 + %wv_lt2 = scalar.cmpf olt, %wv_x, %twof : f32 + %wv_p1a = scalar.mulf %wv_x, %c1p5 : f32 + %wv_p1b = scalar.subf %wv_p1a, %c2p5 : f32 + %wv_p1c = scalar.mulf %wv_p1b, %wv_x : f32 + %wv_p1d = scalar.mulf %wv_p1c, %wv_x : f32 + %wv_p1 = scalar.addf %wv_p1d, %onef : f32 + %wv_p2a = scalar.subf %wv_x, %fivef : f32 + %wv_p2b = scalar.mulf %wv_p2a, %wv_x : f32 + %wv_p2c = scalar.addf %wv_p2b, %eightf : f32 + %wv_p2d = scalar.mulf %wv_p2c, %wv_x : f32 + %wv_p2e = scalar.subf %wv_p2d, %fourf : f32 + %wv_p2 = scalar.mulf %wv_p2e, %mhalf : f32 + %wv_q = scf.select %wv_lt2, %wv_p2, %zf : f32 + %wv = scf.select %wv_lt1, %wv_p1, %wv_q : f32 + %wn = scalar.divf %wv, %wdiv : f32 + %wfx = scalar.mulf %wn, %fxp : f32 + %neg = scalar.cmpf olt, %wn, %zf : f32 + %rnd = scf.select %neg, %mhalf, %halff : f32 + %wr = scalar.addf %wfx, %rnd : f32 + %wi = scalar.fptosi %wr : f32 to i32 + %src_idx = index.madd %xi, %other, %col : index + %el0 = index.mul %src_idx, %ccin : index + %el = index.assume %el0 [lt(%el0, %srcn)] : index + %el1r = index.add %el0, %c1 : index + %el1 = index.assume %el1r [lt(%el1r, %srcn)] : index + %el2r = index.add %el1r, %c1 : index + %el2 = index.assume %el2r [lt(%el2r, %srcn)] : index + %p0r = view.load %sv[%el] : view<[%srcn]xi8> -> i8 + %p1r = view.load %sv[%el1] : view<[%srcn]xi8> -> i8 + %p2r = view.load %sv[%el2] : view<[%srcn]xi8> -> i8 + %p0 = scalar.extui %p0r : i8 to i32 + %p1 = scalar.extui %p1r : i8 to i32 + %p2 = scalar.extui %p2r : i8 to i32 + %m0 = scalar.muli %p0, %wi : i32 + %m1 = scalar.muli %p1, %wi : i32 + %m2 = scalar.muli %p2, %wi : i32 + %n0 = scalar.addi %a0, %m0 : i32 + %n1 = scalar.addi %a1, %m1 : i32 + %n2 = scalar.addi %a2, %m2 : i32 + scf.yield %n0, %n1, %n2 : i32, i32, i32 + } + %sh = scalar.constant 22 : i32 + %c255i = scalar.constant 255 : i32 + %dst_idx = index.madd %o_v, %other, %col : index + %dstn = index.constant 268435456 : index + %dv = buffer.view %dst[%zero] : buffer -> view<[%dstn]xi8> + %de0 = index.mul %dst_idx, %c3 : index + %c2x = index.constant 2 : index + %q0a = scalar.shrsi %s0, %sh : i32 + %q0b = scalar.maxsi %q0a, %zi : i32 + %q0c = scalar.minsi %q0b, %c255i : i32 + %q0 = scalar.trunci %q0c : i32 to i8 + %dc0r = index.add %de0, %c0 : index + %dc0 = index.assume %dc0r [lt(%dc0r, %dstn)] : index + view.store %q0, %dv[%dc0] : i8, view<[%dstn]xi8> + %q1a = scalar.shrsi %s1, %sh : i32 + %q1b = scalar.maxsi %q1a, %zi : i32 + %q1c = scalar.minsi %q1b, %c255i : i32 + %q1 = scalar.trunci %q1c : i32 to i8 + %dc1r = index.add %de0, %c1 : index + %dc1 = index.assume %dc1r [lt(%dc1r, %dstn)] : index + view.store %q1, %dv[%dc1] : i8, view<[%dstn]xi8> + %q2a = scalar.shrsi %s2, %sh : i32 + %q2b = scalar.maxsi %q2a, %zi : i32 + %q2c = scalar.minsi %q2b, %c255i : i32 + %q2 = scalar.trunci %q2c : i32 to i8 + %dc2r = index.add %de0, %c2x : index + %dc2 = index.assume %dc2r [lt(%dc2r, %dstn)] : index + view.store %q2, %dv[%dc2] : i8, view<[%dstn]xi8> + } + kernel.return +} + +kernel.def export("v_inkling2v_pad_norm") @v_inkling2v_pad_norm(%dst_h: index, %dst_w: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %c255 = index.constant 255 : index + %np = index.mul %dst_h, %dst_w : index + %np_up = index.add %np, %c255 : index + %groups = index.div %np_up, %c256 : index + kernel.launch.config workgroups(%groups, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%dst_h_arg: index, %dst_w_arg: index, %hdr_in: buffer, %pix_resized: buffer, %pixf: buffer) { + %dst_h = index.assume %dst_h_arg [range(%dst_h_arg, 1, 16384)] : index + %dst_w = index.assume %dst_w_arg [range(%dst_w_arg, 1, 16384)] : index + %zero = index.constant 0 : offset + %c0 = index.constant 0 : index + %c1 = index.constant 1 : index + %c2 = index.constant 2 : index + %c3 = index.constant 3 : index + %c256 = index.constant 256 : index + %hv = buffer.view %hdr_in[%zero] : buffer -> view<16xi32> + %sw32 = view.load %hv[0] : view<16xi32> -> i32 + %sh32 = view.load %hv[1] : view<16xi32> -> i32 + %cin32 = view.load %hv[2] : view<16xi32> -> i32 + %poff32 = view.load %hv[3] : view<16xi32> -> i32 + %sw_b = scalar.assume %sw32 [range(%sw32, 1, 16384)] : i32 + %sh_b = scalar.assume %sh32 [range(%sh32, 1, 16384)] : i32 + %cin_b = scalar.assume %cin32 [range(%cin32, 3, 4)] : i32 + %poff_b = scalar.assume %poff32 [range(%poff32, 0, 2147483647)] : i32 + %sw = index.cast %sw_b : i32 to index + %sh = index.cast %sh_b : i32 to index + %cin = index.cast %cin_b : i32 to index + %poff = index.cast %poff_b : i32 to index + %gt_w = index.cmp ugt, %sw, %dst_w : index + %gt_h = index.cmp ugt, %sh, %dst_h : index + %use_rs = scalar.ori %gt_w, %gt_h : i1 + %np = index.mul %dst_h, %dst_w : index + %gid = kernel.workgroup.id : index + %lid = kernel.workitem.id : index + %p = index.madd %gid, %c256, %lid : index + %live = index.cmp ult, %p, %np : index + scf.if %live { + %bp = index.assume %p [lt(%p, %np)] : index + %y = index.div %bp, %dst_w : index + %x = index.rem %bp, %dst_w : index + %out_n = index.mul %np, %c3 : index + %outv = buffer.view %pixf[%zero] : buffer -> view<[%out_n]xf32> + %o0_v = index.mul %bp, %c3 : index + %o0 = index.assume %o0_v [lt(%o0_v, %out_n)] : index + %o1_v = index.add %o0, %c1 : index + %o1 = index.assume %o1_v [lt(%o1_v, %out_n)] : index + %o2_v = index.add %o0, %c2 : index + %o2 = index.assume %o2_v [lt(%o2_v, %out_n)] : index + %m0 = scalar.constant 127.5 : f32 + %m1 = scalar.constant 127.5 : f32 + %m2 = scalar.constant 127.5 : f32 + %is0 = scalar.constant 0.00784313725490196 : f32 + %is1 = scalar.constant 0.00784313725490196 : f32 + %is2 = scalar.constant 0.00784313725490196 : f32 + %v0, %v1, %v2 = scf.if %use_rs -> (f32, f32, f32) { + %rsv = buffer.view %pix_resized[%zero] : buffer -> view<[%out_n]xi8> + %b0 = view.load %rsv[%o0] : view<[%out_n]xi8> -> i8 + %b1 = view.load %rsv[%o1] : view<[%out_n]xi8> -> i8 + %b2 = view.load %rsv[%o2] : view<[%out_n]xi8> -> i8 + %u0 = scalar.extui %b0 : i8 to i32 + %u1 = scalar.extui %b1 : i8 to i32 + %u2 = scalar.extui %b2 : i8 to i32 + %f0 = scalar.uitofp %u0 : i32 to f32 + %f1 = scalar.uitofp %u1 : i32 to f32 + %f2 = scalar.uitofp %u2 : i32 to f32 + %d0 = scalar.subf %f0, %m0 : f32 + %d1 = scalar.subf %f1, %m1 : f32 + %d2 = scalar.subf %f2, %m2 : f32 + %q0 = scalar.mulf %d0, %is0 : f32 + %q1 = scalar.mulf %d1, %is1 : f32 + %q2 = scalar.mulf %d2, %is2 : f32 + scf.yield %q0, %q1, %q2 : f32, f32, f32 + } else { + %in_x = index.cmp ult, %x, %sw : index + %in_y = index.cmp ult, %y, %sh : index + %in_b = scalar.andi %in_x, %in_y : i1 + %r0, %r1, %r2 = scf.if %in_b -> (f32, f32, f32) { + %in_len_o = buffer.length %hdr_in + %in_len = index.cast %in_len_o : offset to index + %inv = buffer.view %hdr_in[%zero] : buffer -> view<[%in_len]xi8> + %sp = index.madd %y, %sw, %x : index + %sb = index.mul %sp, %cin : index + %i0_v = index.add %poff, %sb : index + %i0 = index.assume %i0_v [lt(%i0_v, %in_len)] : index + %i1_v = index.add %i0, %c1 : index + %i1 = index.assume %i1_v [lt(%i1_v, %in_len)] : index + %i2_v = index.add %i0, %c2 : index + %i2 = index.assume %i2_v [lt(%i2_v, %in_len)] : index + %b0 = view.load %inv[%i0] : view<[%in_len]xi8> -> i8 + %b1 = view.load %inv[%i1] : view<[%in_len]xi8> -> i8 + %b2 = view.load %inv[%i2] : view<[%in_len]xi8> -> i8 + %u0 = scalar.extui %b0 : i8 to i32 + %u1 = scalar.extui %b1 : i8 to i32 + %u2 = scalar.extui %b2 : i8 to i32 + %f0 = scalar.uitofp %u0 : i32 to f32 + %f1 = scalar.uitofp %u1 : i32 to f32 + %f2 = scalar.uitofp %u2 : i32 to f32 + %d0 = scalar.subf %f0, %m0 : f32 + %d1 = scalar.subf %f1, %m1 : f32 + %d2 = scalar.subf %f2, %m2 : f32 + %q0 = scalar.mulf %d0, %is0 : f32 + %q1 = scalar.mulf %d1, %is1 : f32 + %q2 = scalar.mulf %d2, %is2 : f32 + scf.yield %q0, %q1, %q2 : f32, f32, f32 + } else { + %p0 = scalar.constant -1.007843137254902 : f32 + %p1 = scalar.constant -1.007843137254902 : f32 + %p2 = scalar.constant -1.007843137254902 : f32 + scf.yield %p0, %p1, %p2 : f32, f32, f32 + } + scf.yield %r0, %r1, %r2 : f32, f32, f32 + } + view.store %v0, %outv[%o0] : f32, view<[%out_n]xf32> + view.store %v1, %outv[%o1] : f32, view<[%out_n]xf32> + view.store %v2, %outv[%o2] : f32, view<[%out_n]xf32> + } + kernel.return +} + +kernel.def export("v_copy") @v_copy(%n: index) { + %c1 = index.constant 1 : index + %c256 = index.constant 256 : index + %c255 = index.constant 255 : index + %n_up = index.add %n, %c255 : index + %groups = index.div %n_up, %c256 : index + kernel.launch.config workgroups(%groups, %c1, %c1) workgroup_size(%c256, %c1, %c1) : index +} launch(%n_arg: index, %x: buffer, %y: buffer) { + %n = index.assume %n_arg [range(%n_arg, 1, 268435456)] : index + %c256 = index.constant 256 : index + %gid = kernel.workgroup.id : index + %lid = kernel.workitem.id : index + %i = index.madd %gid, %c256, %lid : index + %live = index.cmp ult, %i, %n : index + scf.if %live { + %bi = index.assume %i [lt(%i, %n)] : index + %zero = index.constant 0 : offset + %xv = buffer.view %x[%zero] : buffer -> view<[%n]xf32> + %a = view.load %xv[%bi] : view<[%n]xf32> -> f32 + %yv = buffer.view %y[%zero] : buffer -> view<[%n]xf32> + view.store %a, %yv[%bi] : f32, view<[%n]xf32> + } + kernel.return +} + +config.decl @vision.height : %value: index where [range(%value, 1, 16384)] +config.decl @vision.width : %value: index where [range(%value, 1, 16384)] + +command.def public target(@device) @vision_encode() launch(%weights: buffer, %input: buffer, %output: buffer) { + %img_h = config.get @vision.height : index + %img_w = config.get @vision.width : index + %cP = index.constant 20 : index + %cm = index.constant 2 : index + %c1 = index.constant 1 : index + %c3 = index.constant 3 : index + %c63 = index.constant 63 : index + %c64 = index.constant 64 : index + %c255 = index.constant 255 : index + %c256 = index.constant 256 : index + %gh = index.div %img_h, %cP : index + %gw = index.div %img_w, %cP : index + %T = index.mul %gh, %gw : index + %Tv = index.add %T, %c1 : index + %mh = index.div %gh, %cm : index + %mw = index.div %gw, %cm : index + %M = index.mul %mh, %mw : index + %T_up = index.add %Tv, %c255 : index + %T_t = index.div %T_up, %c256 : index + %Tp = index.mul %T_t, %c256 : index + %M_up = index.add %M, %c63 : index + %M_t = index.div %M_up, %c64 : index + %Mp = index.mul %M_t, %c64 : index + %NH = index.constant 16 : index + %img_px = index.mul %img_h, %img_w : index + %n_pix = index.mul %img_px, %c3 : index + %max_rows = index.constant 4096 : index + %hdr_bytes = index.constant 64 : offset + %zero_o = index.constant 0 : offset + %h_w = index.constant 1024 : index + %h_n = index.mul %Tp, %h_w : index + %h_bpe = index.constant 4 : offset + %h_size = index.scale %h_n, %h_bpe : index, offset -> offset + %h = buffer.alloca align(256) %h_size : buffer + %x_w = index.constant 1024 : index + %x_n = index.mul %Tp, %x_w : index + %x_bpe = index.constant 4 : offset + %x_size = index.scale %x_n, %x_bpe : index, offset -> offset + %x = buffer.alloca align(256) %x_size : buffer + %q_w = index.constant 3072 : index + %q_n = index.mul %Tp, %q_w : index + %q_bpe = index.constant 4 : offset + %q_size = index.scale %q_n, %q_bpe : index, offset -> offset + %q = buffer.alloca align(256) %q_size : buffer + %k_w = index.constant 1024 : index + %k_n = index.mul %Tp, %k_w : index + %k_bpe = index.constant 4 : offset + %k_size = index.scale %k_n, %k_bpe : index, offset -> offset + %k = buffer.alloca align(256) %k_size : buffer + %v_w = index.constant 1024 : index + %v_n = index.mul %Tp, %v_w : index + %v_bpe = index.constant 4 : offset + %v_size = index.scale %v_n, %v_bpe : index, offset -> offset + %v = buffer.alloca align(256) %v_size : buffer + %o_w = index.constant 1024 : index + %o_n = index.mul %Tp, %o_w : index + %o_bpe = index.constant 4 : offset + %o_size = index.scale %o_n, %o_bpe : index, offset -> offset + %o = buffer.alloca align(256) %o_size : buffer + %a_w = index.constant 1024 : index + %a_n = index.mul %Tp, %a_w : index + %a_bpe = index.constant 4 : offset + %a_size = index.scale %a_n, %a_bpe : index, offset -> offset + %a = buffer.alloca align(256) %a_size : buffer + %f_w = index.constant 4096 : index + %f_n = index.mul %Tp, %f_w : index + %f_bpe = index.constant 4 : offset + %f_size = index.scale %f_n, %f_bpe : index, offset -> offset + %f = buffer.alloca align(256) %f_size : buffer + %g_w = index.constant 4096 : index + %g_n = index.mul %Tp, %g_w : index + %g_bpe = index.constant 4 : offset + %g_size = index.scale %g_n, %g_bpe : index, offset -> offset + %g = buffer.alloca align(256) %g_size : buffer + %xs_w = index.constant 4096 : index + %xs_n = index.mul %Tp, %xs_w : index + %xs_bpe = index.constant 4 : offset + %xs_size = index.scale %xs_n, %xs_bpe : index, offset -> offset + %xs = buffer.alloca align(256) %xs_size : buffer + %x16_w = index.constant 4096 : index + %x16_n = index.mul %Tp, %x16_w : index + %x16_bpe = index.constant 2 : offset + %x16_size = index.scale %x16_n, %x16_bpe : index, offset -> offset + %x16 = buffer.alloca align(256) %x16_size : buffer + %sc_w = index.constant 2 : index + %sc_n = index.mul %Tp, %sc_w : index + %sc_bpe = index.constant 4 : offset + %sc_size = index.scale %sc_n, %sc_bpe : index, offset -> offset + %sc = buffer.alloca align(256) %sc_size : buffer + %m_in_w = index.constant 4096 : index + %m_in_n = index.mul %Mp, %m_in_w : index + %m_in_bpe = index.constant 4 : offset + %m_in_size = index.scale %m_in_n, %m_in_bpe : index, offset -> offset + %m_in = buffer.alloca align(256) %m_in_size : buffer + %m1_w = index.constant 4096 : index + %m1_n = index.mul %Mp, %m1_w : index + %m1_bpe = index.constant 4 : offset + %m1_size = index.scale %m1_n, %m1_bpe : index, offset -> offset + %m1 = buffer.alloca align(256) %m1_size : buffer + %m2_w = index.constant 4096 : index + %m2_n = index.mul %Mp, %m2_w : index + %m2_bpe = index.constant 4 : offset + %m2_size = index.scale %m2_n, %m2_bpe : index, offset -> offset + %m2 = buffer.alloca align(256) %m2_size : buffer + %out_w = index.constant 2304 : index + %out_n = index.mul %Mp, %out_w : index + %out_bpe = index.constant 4 : offset + %out_size = index.scale %out_n, %out_bpe : index, offset -> offset + %out = buffer.alloca align(256) %out_size : buffer + %wide_n = index.mul %max_rows, %img_w : index + %wide_n3 = index.mul %wide_n, %c3 : index + %wide_bpe = index.constant 1 : offset + %wide_size = index.scale %wide_n3, %wide_bpe : index, offset -> offset + %wide = buffer.alloca align(256) %wide_size : buffer + %pix_size = index.scale %n_pix, %wide_bpe : index, offset -> offset + %pix = buffer.alloca align(256) %pix_size : buffer + %pixf_bpe = index.constant 4 : offset + %pixf_size = index.scale %n_pix, %pixf_bpe : index, offset -> offset + %pixf = buffer.alloca align(256) %pixf_size : buffer + kernel.launch @v_resize_bicubic_h_hdr[%img_w, %max_rows](%img_w, %max_rows, %input, %wide) : [index, index](index, index, buffer, buffer) + kernel.launch @v_resize_bicubic_v_hdr[%img_h, %img_w](%img_h, %img_w, %input, %wide, %pix) : [index, index](index, index, buffer, buffer, buffer) + %w_v_patch_embd_weight = command.parameter %weights, "v.patch_embd.weight" : view<2457600xi8> + %w_v_position_embd_weight = command.parameter %weights, "v.position_embd.weight" : view<4194304xi8> + %w_v_class_embd = command.parameter %weights, "v.class_embd" : view<4096xi8> + %w_v_class_position_embd_weight = command.parameter %weights, "v.class_position_embd.weight" : view<4096xi8> + %w_v_pre_ln_weight = command.parameter %weights, "v.pre_ln.weight" : view<4096xi8> + %w_v_pre_ln_bias = command.parameter %weights, "v.pre_ln.bias" : view<4096xi8> + %w_v_blk_0_ln1_weight = command.parameter %weights, "v.blk.0.ln1.weight" : view<4096xi8> + %w_v_blk_0_ln1_bias = command.parameter %weights, "v.blk.0.ln1.bias" : view<4096xi8> + %w_v_blk_0_attn_q_weight = command.parameter %weights, "v.blk.0.attn_q.weight" : view<2097152xi8> + %w_v_blk_0_attn_q_bias = command.parameter %weights, "v.blk.0.attn_q.bias" : view<4096xi8> + %w_v_blk_0_attn_k_weight = command.parameter %weights, "v.blk.0.attn_k.weight" : view<2097152xi8> + %w_v_blk_0_attn_k_bias = command.parameter %weights, "v.blk.0.attn_k.bias" : view<4096xi8> + %w_v_blk_0_attn_v_weight = command.parameter %weights, "v.blk.0.attn_v.weight" : view<2097152xi8> + %w_v_blk_0_attn_v_bias = command.parameter %weights, "v.blk.0.attn_v.bias" : view<4096xi8> + %w_v_blk_0_attn_out_weight = command.parameter %weights, "v.blk.0.attn_out.weight" : view<2097152xi8> + %w_v_blk_0_attn_out_bias = command.parameter %weights, "v.blk.0.attn_out.bias" : view<4096xi8> + %w_v_blk_0_ls1_weight = command.parameter %weights, "v.blk.0.ls1.weight" : view<4096xi8> + %w_v_blk_0_ln2_weight = command.parameter %weights, "v.blk.0.ln2.weight" : view<4096xi8> + %w_v_blk_0_ln2_bias = command.parameter %weights, "v.blk.0.ln2.bias" : view<4096xi8> + %w_v_blk_0_ffn_up_weight = command.parameter %weights, "v.blk.0.ffn_up.weight" : view<8388608xi8> + %w_v_blk_0_ffn_up_bias = command.parameter %weights, "v.blk.0.ffn_up.bias" : view<16384xi8> + %w_v_blk_0_ffn_down_weight = command.parameter %weights, "v.blk.0.ffn_down.weight" : view<8388608xi8> + %w_v_blk_0_ffn_down_bias = command.parameter %weights, "v.blk.0.ffn_down.bias" : view<4096xi8> + %w_v_blk_0_ls2_weight = command.parameter %weights, "v.blk.0.ls2.weight" : view<4096xi8> + %w_v_blk_1_ln1_weight = command.parameter %weights, "v.blk.1.ln1.weight" : view<4096xi8> + %w_v_blk_1_ln1_bias = command.parameter %weights, "v.blk.1.ln1.bias" : view<4096xi8> + %w_v_blk_1_attn_q_weight = command.parameter %weights, "v.blk.1.attn_q.weight" : view<2097152xi8> + %w_v_blk_1_attn_q_bias = command.parameter %weights, "v.blk.1.attn_q.bias" : view<4096xi8> + %w_v_blk_1_attn_k_weight = command.parameter %weights, "v.blk.1.attn_k.weight" : view<2097152xi8> + %w_v_blk_1_attn_k_bias = command.parameter %weights, "v.blk.1.attn_k.bias" : view<4096xi8> + %w_v_blk_1_attn_v_weight = command.parameter %weights, "v.blk.1.attn_v.weight" : view<2097152xi8> + %w_v_blk_1_attn_v_bias = command.parameter %weights, "v.blk.1.attn_v.bias" : view<4096xi8> + %w_v_blk_1_attn_out_weight = command.parameter %weights, "v.blk.1.attn_out.weight" : view<2097152xi8> + %w_v_blk_1_attn_out_bias = command.parameter %weights, "v.blk.1.attn_out.bias" : view<4096xi8> + %w_v_blk_1_ls1_weight = command.parameter %weights, "v.blk.1.ls1.weight" : view<4096xi8> + %w_v_blk_1_ln2_weight = command.parameter %weights, "v.blk.1.ln2.weight" : view<4096xi8> + %w_v_blk_1_ln2_bias = command.parameter %weights, "v.blk.1.ln2.bias" : view<4096xi8> + %w_v_blk_1_ffn_up_weight = command.parameter %weights, "v.blk.1.ffn_up.weight" : view<8388608xi8> + %w_v_blk_1_ffn_up_bias = command.parameter %weights, "v.blk.1.ffn_up.bias" : view<16384xi8> + %w_v_blk_1_ffn_down_weight = command.parameter %weights, "v.blk.1.ffn_down.weight" : view<8388608xi8> + %w_v_blk_1_ffn_down_bias = command.parameter %weights, "v.blk.1.ffn_down.bias" : view<4096xi8> + %w_v_blk_1_ls2_weight = command.parameter %weights, "v.blk.1.ls2.weight" : view<4096xi8> + %w_v_blk_2_ln1_weight = command.parameter %weights, "v.blk.2.ln1.weight" : view<4096xi8> + %w_v_blk_2_ln1_bias = command.parameter %weights, "v.blk.2.ln1.bias" : view<4096xi8> + %w_v_blk_2_attn_q_weight = command.parameter %weights, "v.blk.2.attn_q.weight" : view<2097152xi8> + %w_v_blk_2_attn_q_bias = command.parameter %weights, "v.blk.2.attn_q.bias" : view<4096xi8> + %w_v_blk_2_attn_k_weight = command.parameter %weights, "v.blk.2.attn_k.weight" : view<2097152xi8> + %w_v_blk_2_attn_k_bias = command.parameter %weights, "v.blk.2.attn_k.bias" : view<4096xi8> + %w_v_blk_2_attn_v_weight = command.parameter %weights, "v.blk.2.attn_v.weight" : view<2097152xi8> + %w_v_blk_2_attn_v_bias = command.parameter %weights, "v.blk.2.attn_v.bias" : view<4096xi8> + %w_v_blk_2_attn_out_weight = command.parameter %weights, "v.blk.2.attn_out.weight" : view<2097152xi8> + %w_v_blk_2_attn_out_bias = command.parameter %weights, "v.blk.2.attn_out.bias" : view<4096xi8> + %w_v_blk_2_ls1_weight = command.parameter %weights, "v.blk.2.ls1.weight" : view<4096xi8> + %w_v_blk_2_ln2_weight = command.parameter %weights, "v.blk.2.ln2.weight" : view<4096xi8> + %w_v_blk_2_ln2_bias = command.parameter %weights, "v.blk.2.ln2.bias" : view<4096xi8> + %w_v_blk_2_ffn_up_weight = command.parameter %weights, "v.blk.2.ffn_up.weight" : view<8388608xi8> + %w_v_blk_2_ffn_up_bias = command.parameter %weights, "v.blk.2.ffn_up.bias" : view<16384xi8> + %w_v_blk_2_ffn_down_weight = command.parameter %weights, "v.blk.2.ffn_down.weight" : view<8388608xi8> + %w_v_blk_2_ffn_down_bias = command.parameter %weights, "v.blk.2.ffn_down.bias" : view<4096xi8> + %w_v_blk_2_ls2_weight = command.parameter %weights, "v.blk.2.ls2.weight" : view<4096xi8> + %w_v_blk_3_ln1_weight = command.parameter %weights, "v.blk.3.ln1.weight" : view<4096xi8> + %w_v_blk_3_ln1_bias = command.parameter %weights, "v.blk.3.ln1.bias" : view<4096xi8> + %w_v_blk_3_attn_q_weight = command.parameter %weights, "v.blk.3.attn_q.weight" : view<2097152xi8> + %w_v_blk_3_attn_q_bias = command.parameter %weights, "v.blk.3.attn_q.bias" : view<4096xi8> + %w_v_blk_3_attn_k_weight = command.parameter %weights, "v.blk.3.attn_k.weight" : view<2097152xi8> + %w_v_blk_3_attn_k_bias = command.parameter %weights, "v.blk.3.attn_k.bias" : view<4096xi8> + %w_v_blk_3_attn_v_weight = command.parameter %weights, "v.blk.3.attn_v.weight" : view<2097152xi8> + %w_v_blk_3_attn_v_bias = command.parameter %weights, "v.blk.3.attn_v.bias" : view<4096xi8> + %w_v_blk_3_attn_out_weight = command.parameter %weights, "v.blk.3.attn_out.weight" : view<2097152xi8> + %w_v_blk_3_attn_out_bias = command.parameter %weights, "v.blk.3.attn_out.bias" : view<4096xi8> + %w_v_blk_3_ls1_weight = command.parameter %weights, "v.blk.3.ls1.weight" : view<4096xi8> + %w_v_blk_3_ln2_weight = command.parameter %weights, "v.blk.3.ln2.weight" : view<4096xi8> + %w_v_blk_3_ln2_bias = command.parameter %weights, "v.blk.3.ln2.bias" : view<4096xi8> + %w_v_blk_3_ffn_up_weight = command.parameter %weights, "v.blk.3.ffn_up.weight" : view<8388608xi8> + %w_v_blk_3_ffn_up_bias = command.parameter %weights, "v.blk.3.ffn_up.bias" : view<16384xi8> + %w_v_blk_3_ffn_down_weight = command.parameter %weights, "v.blk.3.ffn_down.weight" : view<8388608xi8> + %w_v_blk_3_ffn_down_bias = command.parameter %weights, "v.blk.3.ffn_down.bias" : view<4096xi8> + %w_v_blk_3_ls2_weight = command.parameter %weights, "v.blk.3.ls2.weight" : view<4096xi8> + %w_v_blk_4_ln1_weight = command.parameter %weights, "v.blk.4.ln1.weight" : view<4096xi8> + %w_v_blk_4_ln1_bias = command.parameter %weights, "v.blk.4.ln1.bias" : view<4096xi8> + %w_v_blk_4_attn_q_weight = command.parameter %weights, "v.blk.4.attn_q.weight" : view<2097152xi8> + %w_v_blk_4_attn_q_bias = command.parameter %weights, "v.blk.4.attn_q.bias" : view<4096xi8> + %w_v_blk_4_attn_k_weight = command.parameter %weights, "v.blk.4.attn_k.weight" : view<2097152xi8> + %w_v_blk_4_attn_k_bias = command.parameter %weights, "v.blk.4.attn_k.bias" : view<4096xi8> + %w_v_blk_4_attn_v_weight = command.parameter %weights, "v.blk.4.attn_v.weight" : view<2097152xi8> + %w_v_blk_4_attn_v_bias = command.parameter %weights, "v.blk.4.attn_v.bias" : view<4096xi8> + %w_v_blk_4_attn_out_weight = command.parameter %weights, "v.blk.4.attn_out.weight" : view<2097152xi8> + %w_v_blk_4_attn_out_bias = command.parameter %weights, "v.blk.4.attn_out.bias" : view<4096xi8> + %w_v_blk_4_ls1_weight = command.parameter %weights, "v.blk.4.ls1.weight" : view<4096xi8> + %w_v_blk_4_ln2_weight = command.parameter %weights, "v.blk.4.ln2.weight" : view<4096xi8> + %w_v_blk_4_ln2_bias = command.parameter %weights, "v.blk.4.ln2.bias" : view<4096xi8> + %w_v_blk_4_ffn_up_weight = command.parameter %weights, "v.blk.4.ffn_up.weight" : view<8388608xi8> + %w_v_blk_4_ffn_up_bias = command.parameter %weights, "v.blk.4.ffn_up.bias" : view<16384xi8> + %w_v_blk_4_ffn_down_weight = command.parameter %weights, "v.blk.4.ffn_down.weight" : view<8388608xi8> + %w_v_blk_4_ffn_down_bias = command.parameter %weights, "v.blk.4.ffn_down.bias" : view<4096xi8> + %w_v_blk_4_ls2_weight = command.parameter %weights, "v.blk.4.ls2.weight" : view<4096xi8> + %w_v_blk_5_ln1_weight = command.parameter %weights, "v.blk.5.ln1.weight" : view<4096xi8> + %w_v_blk_5_ln1_bias = command.parameter %weights, "v.blk.5.ln1.bias" : view<4096xi8> + %w_v_blk_5_attn_q_weight = command.parameter %weights, "v.blk.5.attn_q.weight" : view<2097152xi8> + %w_v_blk_5_attn_q_bias = command.parameter %weights, "v.blk.5.attn_q.bias" : view<4096xi8> + %w_v_blk_5_attn_k_weight = command.parameter %weights, "v.blk.5.attn_k.weight" : view<2097152xi8> + %w_v_blk_5_attn_k_bias = command.parameter %weights, "v.blk.5.attn_k.bias" : view<4096xi8> + %w_v_blk_5_attn_v_weight = command.parameter %weights, "v.blk.5.attn_v.weight" : view<2097152xi8> + %w_v_blk_5_attn_v_bias = command.parameter %weights, "v.blk.5.attn_v.bias" : view<4096xi8> + %w_v_blk_5_attn_out_weight = command.parameter %weights, "v.blk.5.attn_out.weight" : view<2097152xi8> + %w_v_blk_5_attn_out_bias = command.parameter %weights, "v.blk.5.attn_out.bias" : view<4096xi8> + %w_v_blk_5_ls1_weight = command.parameter %weights, "v.blk.5.ls1.weight" : view<4096xi8> + %w_v_blk_5_ln2_weight = command.parameter %weights, "v.blk.5.ln2.weight" : view<4096xi8> + %w_v_blk_5_ln2_bias = command.parameter %weights, "v.blk.5.ln2.bias" : view<4096xi8> + %w_v_blk_5_ffn_up_weight = command.parameter %weights, "v.blk.5.ffn_up.weight" : view<8388608xi8> + %w_v_blk_5_ffn_up_bias = command.parameter %weights, "v.blk.5.ffn_up.bias" : view<16384xi8> + %w_v_blk_5_ffn_down_weight = command.parameter %weights, "v.blk.5.ffn_down.weight" : view<8388608xi8> + %w_v_blk_5_ffn_down_bias = command.parameter %weights, "v.blk.5.ffn_down.bias" : view<4096xi8> + %w_v_blk_5_ls2_weight = command.parameter %weights, "v.blk.5.ls2.weight" : view<4096xi8> + %w_v_blk_6_ln1_weight = command.parameter %weights, "v.blk.6.ln1.weight" : view<4096xi8> + %w_v_blk_6_ln1_bias = command.parameter %weights, "v.blk.6.ln1.bias" : view<4096xi8> + %w_v_blk_6_attn_q_weight = command.parameter %weights, "v.blk.6.attn_q.weight" : view<2097152xi8> + %w_v_blk_6_attn_q_bias = command.parameter %weights, "v.blk.6.attn_q.bias" : view<4096xi8> + %w_v_blk_6_attn_k_weight = command.parameter %weights, "v.blk.6.attn_k.weight" : view<2097152xi8> + %w_v_blk_6_attn_k_bias = command.parameter %weights, "v.blk.6.attn_k.bias" : view<4096xi8> + %w_v_blk_6_attn_v_weight = command.parameter %weights, "v.blk.6.attn_v.weight" : view<2097152xi8> + %w_v_blk_6_attn_v_bias = command.parameter %weights, "v.blk.6.attn_v.bias" : view<4096xi8> + %w_v_blk_6_attn_out_weight = command.parameter %weights, "v.blk.6.attn_out.weight" : view<2097152xi8> + %w_v_blk_6_attn_out_bias = command.parameter %weights, "v.blk.6.attn_out.bias" : view<4096xi8> + %w_v_blk_6_ls1_weight = command.parameter %weights, "v.blk.6.ls1.weight" : view<4096xi8> + %w_v_blk_6_ln2_weight = command.parameter %weights, "v.blk.6.ln2.weight" : view<4096xi8> + %w_v_blk_6_ln2_bias = command.parameter %weights, "v.blk.6.ln2.bias" : view<4096xi8> + %w_v_blk_6_ffn_up_weight = command.parameter %weights, "v.blk.6.ffn_up.weight" : view<8388608xi8> + %w_v_blk_6_ffn_up_bias = command.parameter %weights, "v.blk.6.ffn_up.bias" : view<16384xi8> + %w_v_blk_6_ffn_down_weight = command.parameter %weights, "v.blk.6.ffn_down.weight" : view<8388608xi8> + %w_v_blk_6_ffn_down_bias = command.parameter %weights, "v.blk.6.ffn_down.bias" : view<4096xi8> + %w_v_blk_6_ls2_weight = command.parameter %weights, "v.blk.6.ls2.weight" : view<4096xi8> + %w_v_blk_7_ln1_weight = command.parameter %weights, "v.blk.7.ln1.weight" : view<4096xi8> + %w_v_blk_7_ln1_bias = command.parameter %weights, "v.blk.7.ln1.bias" : view<4096xi8> + %w_v_blk_7_attn_q_weight = command.parameter %weights, "v.blk.7.attn_q.weight" : view<2097152xi8> + %w_v_blk_7_attn_q_bias = command.parameter %weights, "v.blk.7.attn_q.bias" : view<4096xi8> + %w_v_blk_7_attn_k_weight = command.parameter %weights, "v.blk.7.attn_k.weight" : view<2097152xi8> + %w_v_blk_7_attn_k_bias = command.parameter %weights, "v.blk.7.attn_k.bias" : view<4096xi8> + %w_v_blk_7_attn_v_weight = command.parameter %weights, "v.blk.7.attn_v.weight" : view<2097152xi8> + %w_v_blk_7_attn_v_bias = command.parameter %weights, "v.blk.7.attn_v.bias" : view<4096xi8> + %w_v_blk_7_attn_out_weight = command.parameter %weights, "v.blk.7.attn_out.weight" : view<2097152xi8> + %w_v_blk_7_attn_out_bias = command.parameter %weights, "v.blk.7.attn_out.bias" : view<4096xi8> + %w_v_blk_7_ls1_weight = command.parameter %weights, "v.blk.7.ls1.weight" : view<4096xi8> + %w_v_blk_7_ln2_weight = command.parameter %weights, "v.blk.7.ln2.weight" : view<4096xi8> + %w_v_blk_7_ln2_bias = command.parameter %weights, "v.blk.7.ln2.bias" : view<4096xi8> + %w_v_blk_7_ffn_up_weight = command.parameter %weights, "v.blk.7.ffn_up.weight" : view<8388608xi8> + %w_v_blk_7_ffn_up_bias = command.parameter %weights, "v.blk.7.ffn_up.bias" : view<16384xi8> + %w_v_blk_7_ffn_down_weight = command.parameter %weights, "v.blk.7.ffn_down.weight" : view<8388608xi8> + %w_v_blk_7_ffn_down_bias = command.parameter %weights, "v.blk.7.ffn_down.bias" : view<4096xi8> + %w_v_blk_7_ls2_weight = command.parameter %weights, "v.blk.7.ls2.weight" : view<4096xi8> + %w_v_blk_8_ln1_weight = command.parameter %weights, "v.blk.8.ln1.weight" : view<4096xi8> + %w_v_blk_8_ln1_bias = command.parameter %weights, "v.blk.8.ln1.bias" : view<4096xi8> + %w_v_blk_8_attn_q_weight = command.parameter %weights, "v.blk.8.attn_q.weight" : view<2097152xi8> + %w_v_blk_8_attn_q_bias = command.parameter %weights, "v.blk.8.attn_q.bias" : view<4096xi8> + %w_v_blk_8_attn_k_weight = command.parameter %weights, "v.blk.8.attn_k.weight" : view<2097152xi8> + %w_v_blk_8_attn_k_bias = command.parameter %weights, "v.blk.8.attn_k.bias" : view<4096xi8> + %w_v_blk_8_attn_v_weight = command.parameter %weights, "v.blk.8.attn_v.weight" : view<2097152xi8> + %w_v_blk_8_attn_v_bias = command.parameter %weights, "v.blk.8.attn_v.bias" : view<4096xi8> + %w_v_blk_8_attn_out_weight = command.parameter %weights, "v.blk.8.attn_out.weight" : view<2097152xi8> + %w_v_blk_8_attn_out_bias = command.parameter %weights, "v.blk.8.attn_out.bias" : view<4096xi8> + %w_v_blk_8_ls1_weight = command.parameter %weights, "v.blk.8.ls1.weight" : view<4096xi8> + %w_v_blk_8_ln2_weight = command.parameter %weights, "v.blk.8.ln2.weight" : view<4096xi8> + %w_v_blk_8_ln2_bias = command.parameter %weights, "v.blk.8.ln2.bias" : view<4096xi8> + %w_v_blk_8_ffn_up_weight = command.parameter %weights, "v.blk.8.ffn_up.weight" : view<8388608xi8> + %w_v_blk_8_ffn_up_bias = command.parameter %weights, "v.blk.8.ffn_up.bias" : view<16384xi8> + %w_v_blk_8_ffn_down_weight = command.parameter %weights, "v.blk.8.ffn_down.weight" : view<8388608xi8> + %w_v_blk_8_ffn_down_bias = command.parameter %weights, "v.blk.8.ffn_down.bias" : view<4096xi8> + %w_v_blk_8_ls2_weight = command.parameter %weights, "v.blk.8.ls2.weight" : view<4096xi8> + %w_v_blk_9_ln1_weight = command.parameter %weights, "v.blk.9.ln1.weight" : view<4096xi8> + %w_v_blk_9_ln1_bias = command.parameter %weights, "v.blk.9.ln1.bias" : view<4096xi8> + %w_v_blk_9_attn_q_weight = command.parameter %weights, "v.blk.9.attn_q.weight" : view<2097152xi8> + %w_v_blk_9_attn_q_bias = command.parameter %weights, "v.blk.9.attn_q.bias" : view<4096xi8> + %w_v_blk_9_attn_k_weight = command.parameter %weights, "v.blk.9.attn_k.weight" : view<2097152xi8> + %w_v_blk_9_attn_k_bias = command.parameter %weights, "v.blk.9.attn_k.bias" : view<4096xi8> + %w_v_blk_9_attn_v_weight = command.parameter %weights, "v.blk.9.attn_v.weight" : view<2097152xi8> + %w_v_blk_9_attn_v_bias = command.parameter %weights, "v.blk.9.attn_v.bias" : view<4096xi8> + %w_v_blk_9_attn_out_weight = command.parameter %weights, "v.blk.9.attn_out.weight" : view<2097152xi8> + %w_v_blk_9_attn_out_bias = command.parameter %weights, "v.blk.9.attn_out.bias" : view<4096xi8> + %w_v_blk_9_ls1_weight = command.parameter %weights, "v.blk.9.ls1.weight" : view<4096xi8> + %w_v_blk_9_ln2_weight = command.parameter %weights, "v.blk.9.ln2.weight" : view<4096xi8> + %w_v_blk_9_ln2_bias = command.parameter %weights, "v.blk.9.ln2.bias" : view<4096xi8> + %w_v_blk_9_ffn_up_weight = command.parameter %weights, "v.blk.9.ffn_up.weight" : view<8388608xi8> + %w_v_blk_9_ffn_up_bias = command.parameter %weights, "v.blk.9.ffn_up.bias" : view<16384xi8> + %w_v_blk_9_ffn_down_weight = command.parameter %weights, "v.blk.9.ffn_down.weight" : view<8388608xi8> + %w_v_blk_9_ffn_down_bias = command.parameter %weights, "v.blk.9.ffn_down.bias" : view<4096xi8> + %w_v_blk_9_ls2_weight = command.parameter %weights, "v.blk.9.ls2.weight" : view<4096xi8> + %w_v_blk_10_ln1_weight = command.parameter %weights, "v.blk.10.ln1.weight" : view<4096xi8> + %w_v_blk_10_ln1_bias = command.parameter %weights, "v.blk.10.ln1.bias" : view<4096xi8> + %w_v_blk_10_attn_q_weight = command.parameter %weights, "v.blk.10.attn_q.weight" : view<2097152xi8> + %w_v_blk_10_attn_q_bias = command.parameter %weights, "v.blk.10.attn_q.bias" : view<4096xi8> + %w_v_blk_10_attn_k_weight = command.parameter %weights, "v.blk.10.attn_k.weight" : view<2097152xi8> + %w_v_blk_10_attn_k_bias = command.parameter %weights, "v.blk.10.attn_k.bias" : view<4096xi8> + %w_v_blk_10_attn_v_weight = command.parameter %weights, "v.blk.10.attn_v.weight" : view<2097152xi8> + %w_v_blk_10_attn_v_bias = command.parameter %weights, "v.blk.10.attn_v.bias" : view<4096xi8> + %w_v_blk_10_attn_out_weight = command.parameter %weights, "v.blk.10.attn_out.weight" : view<2097152xi8> + %w_v_blk_10_attn_out_bias = command.parameter %weights, "v.blk.10.attn_out.bias" : view<4096xi8> + %w_v_blk_10_ls1_weight = command.parameter %weights, "v.blk.10.ls1.weight" : view<4096xi8> + %w_v_blk_10_ln2_weight = command.parameter %weights, "v.blk.10.ln2.weight" : view<4096xi8> + %w_v_blk_10_ln2_bias = command.parameter %weights, "v.blk.10.ln2.bias" : view<4096xi8> + %w_v_blk_10_ffn_up_weight = command.parameter %weights, "v.blk.10.ffn_up.weight" : view<8388608xi8> + %w_v_blk_10_ffn_up_bias = command.parameter %weights, "v.blk.10.ffn_up.bias" : view<16384xi8> + %w_v_blk_10_ffn_down_weight = command.parameter %weights, "v.blk.10.ffn_down.weight" : view<8388608xi8> + %w_v_blk_10_ffn_down_bias = command.parameter %weights, "v.blk.10.ffn_down.bias" : view<4096xi8> + %w_v_blk_10_ls2_weight = command.parameter %weights, "v.blk.10.ls2.weight" : view<4096xi8> + %w_v_blk_11_ln1_weight = command.parameter %weights, "v.blk.11.ln1.weight" : view<4096xi8> + %w_v_blk_11_ln1_bias = command.parameter %weights, "v.blk.11.ln1.bias" : view<4096xi8> + %w_v_blk_11_attn_q_weight = command.parameter %weights, "v.blk.11.attn_q.weight" : view<2097152xi8> + %w_v_blk_11_attn_q_bias = command.parameter %weights, "v.blk.11.attn_q.bias" : view<4096xi8> + %w_v_blk_11_attn_k_weight = command.parameter %weights, "v.blk.11.attn_k.weight" : view<2097152xi8> + %w_v_blk_11_attn_k_bias = command.parameter %weights, "v.blk.11.attn_k.bias" : view<4096xi8> + %w_v_blk_11_attn_v_weight = command.parameter %weights, "v.blk.11.attn_v.weight" : view<2097152xi8> + %w_v_blk_11_attn_v_bias = command.parameter %weights, "v.blk.11.attn_v.bias" : view<4096xi8> + %w_v_blk_11_attn_out_weight = command.parameter %weights, "v.blk.11.attn_out.weight" : view<2097152xi8> + %w_v_blk_11_attn_out_bias = command.parameter %weights, "v.blk.11.attn_out.bias" : view<4096xi8> + %w_v_blk_11_ls1_weight = command.parameter %weights, "v.blk.11.ls1.weight" : view<4096xi8> + %w_v_blk_11_ln2_weight = command.parameter %weights, "v.blk.11.ln2.weight" : view<4096xi8> + %w_v_blk_11_ln2_bias = command.parameter %weights, "v.blk.11.ln2.bias" : view<4096xi8> + %w_v_blk_11_ffn_up_weight = command.parameter %weights, "v.blk.11.ffn_up.weight" : view<8388608xi8> + %w_v_blk_11_ffn_up_bias = command.parameter %weights, "v.blk.11.ffn_up.bias" : view<16384xi8> + %w_v_blk_11_ffn_down_weight = command.parameter %weights, "v.blk.11.ffn_down.weight" : view<8388608xi8> + %w_v_blk_11_ffn_down_bias = command.parameter %weights, "v.blk.11.ffn_down.bias" : view<4096xi8> + %w_v_blk_11_ls2_weight = command.parameter %weights, "v.blk.11.ls2.weight" : view<4096xi8> + %w_v_blk_12_ln1_weight = command.parameter %weights, "v.blk.12.ln1.weight" : view<4096xi8> + %w_v_blk_12_ln1_bias = command.parameter %weights, "v.blk.12.ln1.bias" : view<4096xi8> + %w_v_blk_12_attn_q_weight = command.parameter %weights, "v.blk.12.attn_q.weight" : view<2097152xi8> + %w_v_blk_12_attn_q_bias = command.parameter %weights, "v.blk.12.attn_q.bias" : view<4096xi8> + %w_v_blk_12_attn_k_weight = command.parameter %weights, "v.blk.12.attn_k.weight" : view<2097152xi8> + %w_v_blk_12_attn_k_bias = command.parameter %weights, "v.blk.12.attn_k.bias" : view<4096xi8> + %w_v_blk_12_attn_v_weight = command.parameter %weights, "v.blk.12.attn_v.weight" : view<2097152xi8> + %w_v_blk_12_attn_v_bias = command.parameter %weights, "v.blk.12.attn_v.bias" : view<4096xi8> + %w_v_blk_12_attn_out_weight = command.parameter %weights, "v.blk.12.attn_out.weight" : view<2097152xi8> + %w_v_blk_12_attn_out_bias = command.parameter %weights, "v.blk.12.attn_out.bias" : view<4096xi8> + %w_v_blk_12_ls1_weight = command.parameter %weights, "v.blk.12.ls1.weight" : view<4096xi8> + %w_v_blk_12_ln2_weight = command.parameter %weights, "v.blk.12.ln2.weight" : view<4096xi8> + %w_v_blk_12_ln2_bias = command.parameter %weights, "v.blk.12.ln2.bias" : view<4096xi8> + %w_v_blk_12_ffn_up_weight = command.parameter %weights, "v.blk.12.ffn_up.weight" : view<8388608xi8> + %w_v_blk_12_ffn_up_bias = command.parameter %weights, "v.blk.12.ffn_up.bias" : view<16384xi8> + %w_v_blk_12_ffn_down_weight = command.parameter %weights, "v.blk.12.ffn_down.weight" : view<8388608xi8> + %w_v_blk_12_ffn_down_bias = command.parameter %weights, "v.blk.12.ffn_down.bias" : view<4096xi8> + %w_v_blk_12_ls2_weight = command.parameter %weights, "v.blk.12.ls2.weight" : view<4096xi8> + %w_v_blk_13_ln1_weight = command.parameter %weights, "v.blk.13.ln1.weight" : view<4096xi8> + %w_v_blk_13_ln1_bias = command.parameter %weights, "v.blk.13.ln1.bias" : view<4096xi8> + %w_v_blk_13_attn_q_weight = command.parameter %weights, "v.blk.13.attn_q.weight" : view<2097152xi8> + %w_v_blk_13_attn_q_bias = command.parameter %weights, "v.blk.13.attn_q.bias" : view<4096xi8> + %w_v_blk_13_attn_k_weight = command.parameter %weights, "v.blk.13.attn_k.weight" : view<2097152xi8> + %w_v_blk_13_attn_k_bias = command.parameter %weights, "v.blk.13.attn_k.bias" : view<4096xi8> + %w_v_blk_13_attn_v_weight = command.parameter %weights, "v.blk.13.attn_v.weight" : view<2097152xi8> + %w_v_blk_13_attn_v_bias = command.parameter %weights, "v.blk.13.attn_v.bias" : view<4096xi8> + %w_v_blk_13_attn_out_weight = command.parameter %weights, "v.blk.13.attn_out.weight" : view<2097152xi8> + %w_v_blk_13_attn_out_bias = command.parameter %weights, "v.blk.13.attn_out.bias" : view<4096xi8> + %w_v_blk_13_ls1_weight = command.parameter %weights, "v.blk.13.ls1.weight" : view<4096xi8> + %w_v_blk_13_ln2_weight = command.parameter %weights, "v.blk.13.ln2.weight" : view<4096xi8> + %w_v_blk_13_ln2_bias = command.parameter %weights, "v.blk.13.ln2.bias" : view<4096xi8> + %w_v_blk_13_ffn_up_weight = command.parameter %weights, "v.blk.13.ffn_up.weight" : view<8388608xi8> + %w_v_blk_13_ffn_up_bias = command.parameter %weights, "v.blk.13.ffn_up.bias" : view<16384xi8> + %w_v_blk_13_ffn_down_weight = command.parameter %weights, "v.blk.13.ffn_down.weight" : view<8388608xi8> + %w_v_blk_13_ffn_down_bias = command.parameter %weights, "v.blk.13.ffn_down.bias" : view<4096xi8> + %w_v_blk_13_ls2_weight = command.parameter %weights, "v.blk.13.ls2.weight" : view<4096xi8> + %w_v_blk_14_ln1_weight = command.parameter %weights, "v.blk.14.ln1.weight" : view<4096xi8> + %w_v_blk_14_ln1_bias = command.parameter %weights, "v.blk.14.ln1.bias" : view<4096xi8> + %w_v_blk_14_attn_q_weight = command.parameter %weights, "v.blk.14.attn_q.weight" : view<2097152xi8> + %w_v_blk_14_attn_q_bias = command.parameter %weights, "v.blk.14.attn_q.bias" : view<4096xi8> + %w_v_blk_14_attn_k_weight = command.parameter %weights, "v.blk.14.attn_k.weight" : view<2097152xi8> + %w_v_blk_14_attn_k_bias = command.parameter %weights, "v.blk.14.attn_k.bias" : view<4096xi8> + %w_v_blk_14_attn_v_weight = command.parameter %weights, "v.blk.14.attn_v.weight" : view<2097152xi8> + %w_v_blk_14_attn_v_bias = command.parameter %weights, "v.blk.14.attn_v.bias" : view<4096xi8> + %w_v_blk_14_attn_out_weight = command.parameter %weights, "v.blk.14.attn_out.weight" : view<2097152xi8> + %w_v_blk_14_attn_out_bias = command.parameter %weights, "v.blk.14.attn_out.bias" : view<4096xi8> + %w_v_blk_14_ls1_weight = command.parameter %weights, "v.blk.14.ls1.weight" : view<4096xi8> + %w_v_blk_14_ln2_weight = command.parameter %weights, "v.blk.14.ln2.weight" : view<4096xi8> + %w_v_blk_14_ln2_bias = command.parameter %weights, "v.blk.14.ln2.bias" : view<4096xi8> + %w_v_blk_14_ffn_up_weight = command.parameter %weights, "v.blk.14.ffn_up.weight" : view<8388608xi8> + %w_v_blk_14_ffn_up_bias = command.parameter %weights, "v.blk.14.ffn_up.bias" : view<16384xi8> + %w_v_blk_14_ffn_down_weight = command.parameter %weights, "v.blk.14.ffn_down.weight" : view<8388608xi8> + %w_v_blk_14_ffn_down_bias = command.parameter %weights, "v.blk.14.ffn_down.bias" : view<4096xi8> + %w_v_blk_14_ls2_weight = command.parameter %weights, "v.blk.14.ls2.weight" : view<4096xi8> + %w_v_blk_15_ln1_weight = command.parameter %weights, "v.blk.15.ln1.weight" : view<4096xi8> + %w_v_blk_15_ln1_bias = command.parameter %weights, "v.blk.15.ln1.bias" : view<4096xi8> + %w_v_blk_15_attn_q_weight = command.parameter %weights, "v.blk.15.attn_q.weight" : view<2097152xi8> + %w_v_blk_15_attn_q_bias = command.parameter %weights, "v.blk.15.attn_q.bias" : view<4096xi8> + %w_v_blk_15_attn_k_weight = command.parameter %weights, "v.blk.15.attn_k.weight" : view<2097152xi8> + %w_v_blk_15_attn_k_bias = command.parameter %weights, "v.blk.15.attn_k.bias" : view<4096xi8> + %w_v_blk_15_attn_v_weight = command.parameter %weights, "v.blk.15.attn_v.weight" : view<2097152xi8> + %w_v_blk_15_attn_v_bias = command.parameter %weights, "v.blk.15.attn_v.bias" : view<4096xi8> + %w_v_blk_15_attn_out_weight = command.parameter %weights, "v.blk.15.attn_out.weight" : view<2097152xi8> + %w_v_blk_15_attn_out_bias = command.parameter %weights, "v.blk.15.attn_out.bias" : view<4096xi8> + %w_v_blk_15_ls1_weight = command.parameter %weights, "v.blk.15.ls1.weight" : view<4096xi8> + %w_v_blk_15_ln2_weight = command.parameter %weights, "v.blk.15.ln2.weight" : view<4096xi8> + %w_v_blk_15_ln2_bias = command.parameter %weights, "v.blk.15.ln2.bias" : view<4096xi8> + %w_v_blk_15_ffn_up_weight = command.parameter %weights, "v.blk.15.ffn_up.weight" : view<8388608xi8> + %w_v_blk_15_ffn_up_bias = command.parameter %weights, "v.blk.15.ffn_up.bias" : view<16384xi8> + %w_v_blk_15_ffn_down_weight = command.parameter %weights, "v.blk.15.ffn_down.weight" : view<8388608xi8> + %w_v_blk_15_ffn_down_bias = command.parameter %weights, "v.blk.15.ffn_down.bias" : view<4096xi8> + %w_v_blk_15_ls2_weight = command.parameter %weights, "v.blk.15.ls2.weight" : view<4096xi8> + %w_v_blk_16_ln1_weight = command.parameter %weights, "v.blk.16.ln1.weight" : view<4096xi8> + %w_v_blk_16_ln1_bias = command.parameter %weights, "v.blk.16.ln1.bias" : view<4096xi8> + %w_v_blk_16_attn_q_weight = command.parameter %weights, "v.blk.16.attn_q.weight" : view<2097152xi8> + %w_v_blk_16_attn_q_bias = command.parameter %weights, "v.blk.16.attn_q.bias" : view<4096xi8> + %w_v_blk_16_attn_k_weight = command.parameter %weights, "v.blk.16.attn_k.weight" : view<2097152xi8> + %w_v_blk_16_attn_k_bias = command.parameter %weights, "v.blk.16.attn_k.bias" : view<4096xi8> + %w_v_blk_16_attn_v_weight = command.parameter %weights, "v.blk.16.attn_v.weight" : view<2097152xi8> + %w_v_blk_16_attn_v_bias = command.parameter %weights, "v.blk.16.attn_v.bias" : view<4096xi8> + %w_v_blk_16_attn_out_weight = command.parameter %weights, "v.blk.16.attn_out.weight" : view<2097152xi8> + %w_v_blk_16_attn_out_bias = command.parameter %weights, "v.blk.16.attn_out.bias" : view<4096xi8> + %w_v_blk_16_ls1_weight = command.parameter %weights, "v.blk.16.ls1.weight" : view<4096xi8> + %w_v_blk_16_ln2_weight = command.parameter %weights, "v.blk.16.ln2.weight" : view<4096xi8> + %w_v_blk_16_ln2_bias = command.parameter %weights, "v.blk.16.ln2.bias" : view<4096xi8> + %w_v_blk_16_ffn_up_weight = command.parameter %weights, "v.blk.16.ffn_up.weight" : view<8388608xi8> + %w_v_blk_16_ffn_up_bias = command.parameter %weights, "v.blk.16.ffn_up.bias" : view<16384xi8> + %w_v_blk_16_ffn_down_weight = command.parameter %weights, "v.blk.16.ffn_down.weight" : view<8388608xi8> + %w_v_blk_16_ffn_down_bias = command.parameter %weights, "v.blk.16.ffn_down.bias" : view<4096xi8> + %w_v_blk_16_ls2_weight = command.parameter %weights, "v.blk.16.ls2.weight" : view<4096xi8> + %w_v_blk_17_ln1_weight = command.parameter %weights, "v.blk.17.ln1.weight" : view<4096xi8> + %w_v_blk_17_ln1_bias = command.parameter %weights, "v.blk.17.ln1.bias" : view<4096xi8> + %w_v_blk_17_attn_q_weight = command.parameter %weights, "v.blk.17.attn_q.weight" : view<2097152xi8> + %w_v_blk_17_attn_q_bias = command.parameter %weights, "v.blk.17.attn_q.bias" : view<4096xi8> + %w_v_blk_17_attn_k_weight = command.parameter %weights, "v.blk.17.attn_k.weight" : view<2097152xi8> + %w_v_blk_17_attn_k_bias = command.parameter %weights, "v.blk.17.attn_k.bias" : view<4096xi8> + %w_v_blk_17_attn_v_weight = command.parameter %weights, "v.blk.17.attn_v.weight" : view<2097152xi8> + %w_v_blk_17_attn_v_bias = command.parameter %weights, "v.blk.17.attn_v.bias" : view<4096xi8> + %w_v_blk_17_attn_out_weight = command.parameter %weights, "v.blk.17.attn_out.weight" : view<2097152xi8> + %w_v_blk_17_attn_out_bias = command.parameter %weights, "v.blk.17.attn_out.bias" : view<4096xi8> + %w_v_blk_17_ls1_weight = command.parameter %weights, "v.blk.17.ls1.weight" : view<4096xi8> + %w_v_blk_17_ln2_weight = command.parameter %weights, "v.blk.17.ln2.weight" : view<4096xi8> + %w_v_blk_17_ln2_bias = command.parameter %weights, "v.blk.17.ln2.bias" : view<4096xi8> + %w_v_blk_17_ffn_up_weight = command.parameter %weights, "v.blk.17.ffn_up.weight" : view<8388608xi8> + %w_v_blk_17_ffn_up_bias = command.parameter %weights, "v.blk.17.ffn_up.bias" : view<16384xi8> + %w_v_blk_17_ffn_down_weight = command.parameter %weights, "v.blk.17.ffn_down.weight" : view<8388608xi8> + %w_v_blk_17_ffn_down_bias = command.parameter %weights, "v.blk.17.ffn_down.bias" : view<4096xi8> + %w_v_blk_17_ls2_weight = command.parameter %weights, "v.blk.17.ls2.weight" : view<4096xi8> + %w_v_blk_18_ln1_weight = command.parameter %weights, "v.blk.18.ln1.weight" : view<4096xi8> + %w_v_blk_18_ln1_bias = command.parameter %weights, "v.blk.18.ln1.bias" : view<4096xi8> + %w_v_blk_18_attn_q_weight = command.parameter %weights, "v.blk.18.attn_q.weight" : view<2097152xi8> + %w_v_blk_18_attn_q_bias = command.parameter %weights, "v.blk.18.attn_q.bias" : view<4096xi8> + %w_v_blk_18_attn_k_weight = command.parameter %weights, "v.blk.18.attn_k.weight" : view<2097152xi8> + %w_v_blk_18_attn_k_bias = command.parameter %weights, "v.blk.18.attn_k.bias" : view<4096xi8> + %w_v_blk_18_attn_v_weight = command.parameter %weights, "v.blk.18.attn_v.weight" : view<2097152xi8> + %w_v_blk_18_attn_v_bias = command.parameter %weights, "v.blk.18.attn_v.bias" : view<4096xi8> + %w_v_blk_18_attn_out_weight = command.parameter %weights, "v.blk.18.attn_out.weight" : view<2097152xi8> + %w_v_blk_18_attn_out_bias = command.parameter %weights, "v.blk.18.attn_out.bias" : view<4096xi8> + %w_v_blk_18_ls1_weight = command.parameter %weights, "v.blk.18.ls1.weight" : view<4096xi8> + %w_v_blk_18_ln2_weight = command.parameter %weights, "v.blk.18.ln2.weight" : view<4096xi8> + %w_v_blk_18_ln2_bias = command.parameter %weights, "v.blk.18.ln2.bias" : view<4096xi8> + %w_v_blk_18_ffn_up_weight = command.parameter %weights, "v.blk.18.ffn_up.weight" : view<8388608xi8> + %w_v_blk_18_ffn_up_bias = command.parameter %weights, "v.blk.18.ffn_up.bias" : view<16384xi8> + %w_v_blk_18_ffn_down_weight = command.parameter %weights, "v.blk.18.ffn_down.weight" : view<8388608xi8> + %w_v_blk_18_ffn_down_bias = command.parameter %weights, "v.blk.18.ffn_down.bias" : view<4096xi8> + %w_v_blk_18_ls2_weight = command.parameter %weights, "v.blk.18.ls2.weight" : view<4096xi8> + %w_v_blk_19_ln1_weight = command.parameter %weights, "v.blk.19.ln1.weight" : view<4096xi8> + %w_v_blk_19_ln1_bias = command.parameter %weights, "v.blk.19.ln1.bias" : view<4096xi8> + %w_v_blk_19_attn_q_weight = command.parameter %weights, "v.blk.19.attn_q.weight" : view<2097152xi8> + %w_v_blk_19_attn_q_bias = command.parameter %weights, "v.blk.19.attn_q.bias" : view<4096xi8> + %w_v_blk_19_attn_k_weight = command.parameter %weights, "v.blk.19.attn_k.weight" : view<2097152xi8> + %w_v_blk_19_attn_k_bias = command.parameter %weights, "v.blk.19.attn_k.bias" : view<4096xi8> + %w_v_blk_19_attn_v_weight = command.parameter %weights, "v.blk.19.attn_v.weight" : view<2097152xi8> + %w_v_blk_19_attn_v_bias = command.parameter %weights, "v.blk.19.attn_v.bias" : view<4096xi8> + %w_v_blk_19_attn_out_weight = command.parameter %weights, "v.blk.19.attn_out.weight" : view<2097152xi8> + %w_v_blk_19_attn_out_bias = command.parameter %weights, "v.blk.19.attn_out.bias" : view<4096xi8> + %w_v_blk_19_ls1_weight = command.parameter %weights, "v.blk.19.ls1.weight" : view<4096xi8> + %w_v_blk_19_ln2_weight = command.parameter %weights, "v.blk.19.ln2.weight" : view<4096xi8> + %w_v_blk_19_ln2_bias = command.parameter %weights, "v.blk.19.ln2.bias" : view<4096xi8> + %w_v_blk_19_ffn_up_weight = command.parameter %weights, "v.blk.19.ffn_up.weight" : view<8388608xi8> + %w_v_blk_19_ffn_up_bias = command.parameter %weights, "v.blk.19.ffn_up.bias" : view<16384xi8> + %w_v_blk_19_ffn_down_weight = command.parameter %weights, "v.blk.19.ffn_down.weight" : view<8388608xi8> + %w_v_blk_19_ffn_down_bias = command.parameter %weights, "v.blk.19.ffn_down.bias" : view<4096xi8> + %w_v_blk_19_ls2_weight = command.parameter %weights, "v.blk.19.ls2.weight" : view<4096xi8> + %w_v_blk_20_ln1_weight = command.parameter %weights, "v.blk.20.ln1.weight" : view<4096xi8> + %w_v_blk_20_ln1_bias = command.parameter %weights, "v.blk.20.ln1.bias" : view<4096xi8> + %w_v_blk_20_attn_q_weight = command.parameter %weights, "v.blk.20.attn_q.weight" : view<2097152xi8> + %w_v_blk_20_attn_q_bias = command.parameter %weights, "v.blk.20.attn_q.bias" : view<4096xi8> + %w_v_blk_20_attn_k_weight = command.parameter %weights, "v.blk.20.attn_k.weight" : view<2097152xi8> + %w_v_blk_20_attn_k_bias = command.parameter %weights, "v.blk.20.attn_k.bias" : view<4096xi8> + %w_v_blk_20_attn_v_weight = command.parameter %weights, "v.blk.20.attn_v.weight" : view<2097152xi8> + %w_v_blk_20_attn_v_bias = command.parameter %weights, "v.blk.20.attn_v.bias" : view<4096xi8> + %w_v_blk_20_attn_out_weight = command.parameter %weights, "v.blk.20.attn_out.weight" : view<2097152xi8> + %w_v_blk_20_attn_out_bias = command.parameter %weights, "v.blk.20.attn_out.bias" : view<4096xi8> + %w_v_blk_20_ls1_weight = command.parameter %weights, "v.blk.20.ls1.weight" : view<4096xi8> + %w_v_blk_20_ln2_weight = command.parameter %weights, "v.blk.20.ln2.weight" : view<4096xi8> + %w_v_blk_20_ln2_bias = command.parameter %weights, "v.blk.20.ln2.bias" : view<4096xi8> + %w_v_blk_20_ffn_up_weight = command.parameter %weights, "v.blk.20.ffn_up.weight" : view<8388608xi8> + %w_v_blk_20_ffn_up_bias = command.parameter %weights, "v.blk.20.ffn_up.bias" : view<16384xi8> + %w_v_blk_20_ffn_down_weight = command.parameter %weights, "v.blk.20.ffn_down.weight" : view<8388608xi8> + %w_v_blk_20_ffn_down_bias = command.parameter %weights, "v.blk.20.ffn_down.bias" : view<4096xi8> + %w_v_blk_20_ls2_weight = command.parameter %weights, "v.blk.20.ls2.weight" : view<4096xi8> + %w_v_blk_21_ln1_weight = command.parameter %weights, "v.blk.21.ln1.weight" : view<4096xi8> + %w_v_blk_21_ln1_bias = command.parameter %weights, "v.blk.21.ln1.bias" : view<4096xi8> + %w_v_blk_21_attn_q_weight = command.parameter %weights, "v.blk.21.attn_q.weight" : view<2097152xi8> + %w_v_blk_21_attn_q_bias = command.parameter %weights, "v.blk.21.attn_q.bias" : view<4096xi8> + %w_v_blk_21_attn_k_weight = command.parameter %weights, "v.blk.21.attn_k.weight" : view<2097152xi8> + %w_v_blk_21_attn_k_bias = command.parameter %weights, "v.blk.21.attn_k.bias" : view<4096xi8> + %w_v_blk_21_attn_v_weight = command.parameter %weights, "v.blk.21.attn_v.weight" : view<2097152xi8> + %w_v_blk_21_attn_v_bias = command.parameter %weights, "v.blk.21.attn_v.bias" : view<4096xi8> + %w_v_blk_21_attn_out_weight = command.parameter %weights, "v.blk.21.attn_out.weight" : view<2097152xi8> + %w_v_blk_21_attn_out_bias = command.parameter %weights, "v.blk.21.attn_out.bias" : view<4096xi8> + %w_v_blk_21_ls1_weight = command.parameter %weights, "v.blk.21.ls1.weight" : view<4096xi8> + %w_v_blk_21_ln2_weight = command.parameter %weights, "v.blk.21.ln2.weight" : view<4096xi8> + %w_v_blk_21_ln2_bias = command.parameter %weights, "v.blk.21.ln2.bias" : view<4096xi8> + %w_v_blk_21_ffn_up_weight = command.parameter %weights, "v.blk.21.ffn_up.weight" : view<8388608xi8> + %w_v_blk_21_ffn_up_bias = command.parameter %weights, "v.blk.21.ffn_up.bias" : view<16384xi8> + %w_v_blk_21_ffn_down_weight = command.parameter %weights, "v.blk.21.ffn_down.weight" : view<8388608xi8> + %w_v_blk_21_ffn_down_bias = command.parameter %weights, "v.blk.21.ffn_down.bias" : view<4096xi8> + %w_v_blk_21_ls2_weight = command.parameter %weights, "v.blk.21.ls2.weight" : view<4096xi8> + %w_v_blk_22_ln1_weight = command.parameter %weights, "v.blk.22.ln1.weight" : view<4096xi8> + %w_v_blk_22_ln1_bias = command.parameter %weights, "v.blk.22.ln1.bias" : view<4096xi8> + %w_v_blk_22_attn_q_weight = command.parameter %weights, "v.blk.22.attn_q.weight" : view<2097152xi8> + %w_v_blk_22_attn_q_bias = command.parameter %weights, "v.blk.22.attn_q.bias" : view<4096xi8> + %w_v_blk_22_attn_k_weight = command.parameter %weights, "v.blk.22.attn_k.weight" : view<2097152xi8> + %w_v_blk_22_attn_k_bias = command.parameter %weights, "v.blk.22.attn_k.bias" : view<4096xi8> + %w_v_blk_22_attn_v_weight = command.parameter %weights, "v.blk.22.attn_v.weight" : view<2097152xi8> + %w_v_blk_22_attn_v_bias = command.parameter %weights, "v.blk.22.attn_v.bias" : view<4096xi8> + %w_v_blk_22_attn_out_weight = command.parameter %weights, "v.blk.22.attn_out.weight" : view<2097152xi8> + %w_v_blk_22_attn_out_bias = command.parameter %weights, "v.blk.22.attn_out.bias" : view<4096xi8> + %w_v_blk_22_ls1_weight = command.parameter %weights, "v.blk.22.ls1.weight" : view<4096xi8> + %w_v_blk_22_ln2_weight = command.parameter %weights, "v.blk.22.ln2.weight" : view<4096xi8> + %w_v_blk_22_ln2_bias = command.parameter %weights, "v.blk.22.ln2.bias" : view<4096xi8> + %w_v_blk_22_ffn_up_weight = command.parameter %weights, "v.blk.22.ffn_up.weight" : view<8388608xi8> + %w_v_blk_22_ffn_up_bias = command.parameter %weights, "v.blk.22.ffn_up.bias" : view<16384xi8> + %w_v_blk_22_ffn_down_weight = command.parameter %weights, "v.blk.22.ffn_down.weight" : view<8388608xi8> + %w_v_blk_22_ffn_down_bias = command.parameter %weights, "v.blk.22.ffn_down.bias" : view<4096xi8> + %w_v_blk_22_ls2_weight = command.parameter %weights, "v.blk.22.ls2.weight" : view<4096xi8> + %w_mm_1_weight = command.parameter %weights, "mm.1.weight" : view<33554432xi8> + %w_mm_2_weight = command.parameter %weights, "mm.2.weight" : view<18874368xi8> + kernel.launch @v_inkling2v_pad_norm[%img_h, %img_w](%img_h, %img_w, %input, %pix, %pixf) : [index, index](index, index, buffer, buffer, buffer) + kernel.launch @v_patch_20_1024_f16_raster[%T](%T, %gw, %img_w, %pixf, %w_v_patch_embd_weight, %x) : [index](index, index, index, buffer, view<2457600xi8>, buffer) + kernel.launch @v_pos_interp_1024_32_raster_hp[%T](%T, %gw, %gh, %w_v_position_embd_weight, %x) : [index](index, index, index, view<4194304xi8>, buffer) + kernel.launch @v_prepend_cls_1024[%Tv](%Tv, %x, %w_v_class_embd, %w_v_class_position_embd_weight, %h) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_pre_ln_weight, %w_v_pre_ln_bias, %h) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_0_ln1_weight, %w_v_blk_0_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + %k1024 = index.constant 1024 : index + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_0_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_0_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_0_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_0_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_0_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_0_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_0_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_0_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_0_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_0_ln2_weight, %w_v_blk_0_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + %k4096 = index.constant 4096 : index + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_0_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_0_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_0_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_0_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_0_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_1_ln1_weight, %w_v_blk_1_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_1_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_1_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_1_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_1_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_1_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_1_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_1_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_1_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_1_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_1_ln2_weight, %w_v_blk_1_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_1_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_1_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_1_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_1_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_1_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_2_ln1_weight, %w_v_blk_2_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_2_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_2_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_2_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_2_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_2_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_2_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_2_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_2_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_2_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_2_ln2_weight, %w_v_blk_2_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_2_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_2_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_2_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_2_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_2_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_3_ln1_weight, %w_v_blk_3_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_3_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_3_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_3_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_3_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_3_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_3_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_3_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_3_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_3_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_3_ln2_weight, %w_v_blk_3_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_3_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_3_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_3_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_3_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_3_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_4_ln1_weight, %w_v_blk_4_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_4_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_4_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_4_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_4_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_4_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_4_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_4_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_4_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_4_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_4_ln2_weight, %w_v_blk_4_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_4_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_4_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_4_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_4_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_4_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_5_ln1_weight, %w_v_blk_5_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_5_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_5_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_5_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_5_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_5_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_5_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_5_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_5_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_5_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_5_ln2_weight, %w_v_blk_5_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_5_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_5_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_5_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_5_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_5_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_6_ln1_weight, %w_v_blk_6_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_6_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_6_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_6_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_6_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_6_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_6_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_6_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_6_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_6_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_6_ln2_weight, %w_v_blk_6_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_6_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_6_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_6_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_6_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_6_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_7_ln1_weight, %w_v_blk_7_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_7_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_7_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_7_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_7_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_7_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_7_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_7_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_7_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_7_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_7_ln2_weight, %w_v_blk_7_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_7_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_7_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_7_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_7_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_7_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_8_ln1_weight, %w_v_blk_8_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_8_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_8_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_8_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_8_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_8_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_8_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_8_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_8_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_8_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_8_ln2_weight, %w_v_blk_8_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_8_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_8_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_8_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_8_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_8_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_9_ln1_weight, %w_v_blk_9_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_9_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_9_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_9_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_9_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_9_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_9_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_9_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_9_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_9_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_9_ln2_weight, %w_v_blk_9_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_9_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_9_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_9_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_9_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_9_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_10_ln1_weight, %w_v_blk_10_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_10_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_10_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_10_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_10_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_10_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_10_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_10_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_10_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_10_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_10_ln2_weight, %w_v_blk_10_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_10_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_10_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_10_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_10_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_10_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_11_ln1_weight, %w_v_blk_11_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_11_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_11_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_11_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_11_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_11_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_11_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_11_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_11_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_11_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_11_ln2_weight, %w_v_blk_11_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_11_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_11_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_11_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_11_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_11_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_12_ln1_weight, %w_v_blk_12_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_12_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_12_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_12_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_12_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_12_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_12_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_12_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_12_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_12_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_12_ln2_weight, %w_v_blk_12_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_12_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_12_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_12_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_12_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_12_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_13_ln1_weight, %w_v_blk_13_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_13_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_13_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_13_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_13_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_13_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_13_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_13_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_13_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_13_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_13_ln2_weight, %w_v_blk_13_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_13_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_13_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_13_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_13_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_13_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_14_ln1_weight, %w_v_blk_14_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_14_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_14_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_14_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_14_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_14_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_14_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_14_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_14_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_14_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_14_ln2_weight, %w_v_blk_14_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_14_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_14_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_14_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_14_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_14_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_15_ln1_weight, %w_v_blk_15_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_15_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_15_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_15_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_15_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_15_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_15_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_15_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_15_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_15_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_15_ln2_weight, %w_v_blk_15_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_15_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_15_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_15_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_15_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_15_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_16_ln1_weight, %w_v_blk_16_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_16_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_16_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_16_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_16_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_16_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_16_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_16_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_16_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_16_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_16_ln2_weight, %w_v_blk_16_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_16_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_16_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_16_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_16_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_16_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_17_ln1_weight, %w_v_blk_17_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_17_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_17_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_17_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_17_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_17_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_17_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_17_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_17_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_17_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_17_ln2_weight, %w_v_blk_17_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_17_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_17_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_17_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_17_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_17_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_18_ln1_weight, %w_v_blk_18_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_18_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_18_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_18_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_18_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_18_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_18_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_18_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_18_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_18_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_18_ln2_weight, %w_v_blk_18_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_18_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_18_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_18_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_18_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_18_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_19_ln1_weight, %w_v_blk_19_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_19_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_19_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_19_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_19_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_19_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_19_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_19_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_19_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_19_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_19_ln2_weight, %w_v_blk_19_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_19_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_19_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_19_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_19_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_19_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_20_ln1_weight, %w_v_blk_20_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_20_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_20_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_20_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_20_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_20_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_20_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_20_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_20_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_20_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_20_ln2_weight, %w_v_blk_20_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_20_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_20_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_20_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_20_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_20_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_21_ln1_weight, %w_v_blk_21_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_21_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_21_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_21_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_21_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_21_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_21_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_21_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_21_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_21_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_21_ln2_weight, %w_v_blk_21_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_21_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_21_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_21_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_21_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_21_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_22_ln1_weight, %w_v_blk_22_ln1_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_22_attn_q_weight, %q) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %q, %w_v_blk_22_attn_q_bias, %q) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_22_attn_k_weight, %k) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %k, %w_v_blk_22_attn_k_bias, %k) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_22_attn_v_weight, %v) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %v, %w_v_blk_22_attn_v_bias, %v) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %q) : [index](index, index, buffer) + kernel.launch @v_rope_inkling2v_64x16_s1024_o0_raster_cls[%Tv](%Tv, %gw, %k) : [index](index, index, buffer) + kernel.launch @v_attn_64x16_s1024_0_0_0[%Tv](%Tv, %gw, %q, %k, %v, %o) : [index](index, index, buffer, buffer, buffer, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %o, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel1_v_gemm_f16_store_1024x1024>(%Tp, %k1024, %Tp, %k1024, %k1024, %x16, %sc, %w_v_blk_22_attn_out_weight, %a) : (index, index, index, index, index, buffer, buffer, view<2097152xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_22_attn_out_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_22_ls1_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_norm_ln_1024[%Tv](%Tv, %h, %w_v_blk_22_ln2_weight, %w_v_blk_22_ln2_bias, %x) : [index](index, buffer, view<4096xi8>, view<4096xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k1024, %x, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel2_v_gemm_f16_store_1024x4096>(%Tp, %k4096, %Tp, %k1024, %k4096, %x16, %sc, %w_v_blk_22_ffn_up_weight, %f) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_gelu_erf_4096[%Tv](%Tv, %f, %w_v_blk_22_ffn_up_bias, %f) : [index](index, buffer, view<16384xi8>, buffer) + kernel.launch @v_row_scale_f16[%Tp](%Tp, %k4096, %f, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel3_v_gemm_f16_store_4096x1024>(%Tp, %k1024, %Tp, %k4096, %k1024, %x16, %sc, %w_v_blk_22_ffn_down_weight, %a) : (index, index, index, index, index, buffer, buffer, view<8388608xi8>, buffer) + kernel.launch @v_bias_none_1024[%Tv](%Tv, %a, %w_v_blk_22_ffn_down_bias, %a) : [index](index, buffer, view<4096xi8>, buffer) + kernel.launch @v_scale_add_1024[%Tv](%Tv, %h, %a, %w_v_blk_22_ls2_weight) : [index](index, buffer, buffer, view<4096xi8>) + kernel.launch @v_merge2_skip1_1024[%M](%M, %gw, %Tv, %h, %m_in) : [index](index, index, index, buffer, buffer) + kernel.launch @v_row_scale_f16[%Mp](%Mp, %k4096, %m_in, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + template.apply<@sel4_v_gemm_f16_store_4096x4096>(%Mp, %k4096, %Mp, %k4096, %k4096, %x16, %sc, %w_mm_1_weight, %m1) : (index, index, index, index, index, buffer, buffer, view<33554432xi8>, buffer) + %p_M_4096 = index.mul %M, %k4096 : index + kernel.launch @v_ew_gelu_erf[%p_M_4096](%p_M_4096, %m1, %m1) : [index](index, buffer, buffer) + kernel.launch @v_row_scale_f16[%Mp](%Mp, %k4096, %m1, %sc, %x16) : [index](index, index, buffer, buffer, buffer) + %k2304 = index.constant 2304 : index + template.apply<@sel5_v_gemm_f16_store_4096x2304>(%Mp, %k2304, %Mp, %k4096, %k2304, %x16, %sc, %w_mm_2_weight, %out) : (index, index, index, index, index, buffer, buffer, view<18874368xi8>, buffer) + %out_rows = index.constant 2304 : index + %final_n = index.mul %M, %out_rows : index + kernel.launch @v_copy[%final_n](%final_n, %out, %output) : [index](index, buffer, buffer) + command.return +}