| Line |
Branch |
Exec |
Source |
| 1 |
|
|
#include "mir_conv_cm.h" |
| 2 |
|
|
|
| 3 |
|
|
#include "mir_common.h" |
| 4 |
|
|
#include "mir_coop_common.h" |
| 5 |
|
|
#include "mir_math.h" |
| 6 |
|
|
#include "../vulkan/shaders/op_codes.h" |
| 7 |
|
|
|
| 8 |
|
|
#include <array> |
| 9 |
|
|
#include <stdexcept> |
| 10 |
|
|
#include <string> |
| 11 |
|
|
#include <vector> |
| 12 |
|
|
|
| 13 |
|
|
namespace brotensor::kernels { |
| 14 |
|
|
|
| 15 |
|
|
namespace { |
| 16 |
|
|
|
| 17 |
|
|
using jit::gpu_mir::bits_to_f32; |
| 18 |
|
|
|
| 19 |
|
128 |
Value* conv_act(Ctx& c, std::uint32_t act, Value* v) { |
| 20 |
|
128 |
return emit_gemm_act(c, act, v); |
| 21 |
|
|
} |
| 22 |
|
|
|
| 23 |
|
64 |
Value* bf16_bits_to_f16_bits(Ctx& c, Value* b16) { |
| 24 |
|
64 |
return c.kb.f32_to_f16(bits_to_f32(c, c.b.build_shl(b16, c.i32(16)))); |
| 25 |
|
|
} |
| 26 |
|
|
|
| 27 |
|
✗ |
Value* load8_a_scalar(Ctx& c, Dtype dt, Value* base, Value* k_tot, Value* row, Value* row_ok, Value* col) { |
| 28 |
|
✗ |
Value* any_ok = c.b.build_and(row_ok, c.b.build_ult(col, k_tot)); |
| 29 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
return emit_if_else_values( |
| 30 |
|
✗ |
c, any_ok, {Type::i32x4()}, |
| 31 |
|
✗ |
[&]() -> std::vector<Value*> { |
| 32 |
|
✗ |
Value* idx = c.b.build_add(c.b.build_mul(row, k_tot), col); |
| 33 |
|
✗ |
std::array<Value*, 8> v{}; |
| 34 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
for (int e = 0; e < 8; ++e) { |
| 35 |
|
✗ |
Value* ok = c.b.build_ult(c.b.build_add(col, c.i32(e)), k_tot); |
| 36 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
v[static_cast<std::size_t>(e)] = emit_if_else_values( |
| 37 |
|
✗ |
c, ok, {Type::f32()}, |
| 38 |
|
✗ |
[&]() -> std::vector<Value*> { |
| 39 |
|
✗ |
return {load_elem_dt(c, dt, base, c.b.build_add(idx, c.i32(e)))}; |
| 40 |
|
|
}, |
| 41 |
|
✗ |
[&]() -> std::vector<Value*> { return {c.f32(0.0f)}; })[0]; |
| 42 |
|
✗ |
} |
| 43 |
|
✗ |
return {emit_pack_f32x8_to_f16_v4(c, v)}; |
| 44 |
|
✗ |
}, |
| 45 |
|
✗ |
[&]() -> std::vector<Value*> { return {emit_v4_zero(c)}; })[0]; |
| 46 |
|
✗ |
} |
| 47 |
|
|
|
| 48 |
|
|
} // namespace |
| 49 |
|
|
|
| 50 |
|
21 |
brass::Function* build_conv_cm_mir(brass::Module& mod, const ConvCmSpec& s) { |
| 51 |
1/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
21 |
if (s.cfg_idx >= 4u) throw std::runtime_error("brotensor: mir_conv_cm: invalid cfg_idx"); |
| 52 |
|
21 |
const GemmCmTile& cfg = kGemmCmTiles[s.cfg_idx]; |
| 53 |
|
21 |
const std::uint32_t BM = cfg.bm, BN = cfg.bn, BK = cfg.bk, WM = cfg.wm, WN = cfg.wn, WG = cfg.wg; |
| 54 |
|
21 |
const std::uint32_t TM = WM / 16u, TN = WN / 16u; |
| 55 |
|
21 |
const std::uint32_t NSG = (BM / WM) * (BN / WN); |
| 56 |
|
21 |
const std::uint32_t LA = (BM * BK / 8u) / WG; |
| 57 |
|
21 |
const std::uint32_t LB = (BN * BK / 8u) / WG; |
| 58 |
|
21 |
const std::uint32_t CA = BK / 8u; |
| 59 |
|
21 |
const std::uint32_t CB = BN / 8u; |
| 60 |
|
21 |
const std::uint32_t SKA = CA + 1u; |
| 61 |
|
21 |
const std::uint32_t SKB = CB + 1u; |
| 62 |
|
21 |
const std::uint32_t ASZ = BM * SKA; |
| 63 |
|
21 |
const std::uint32_t BSZ = BK * SKB; |
| 64 |
|
21 |
const int KHW = s.kh * s.kw; |
| 65 |
|
|
|
| 66 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
42 |
const std::string name = std::string("mir_conv_cm_c") + std::to_string(s.cfg_idx) + |
| 67 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
(s.dt == Dtype::FP16 ? "_f16" : "_bf16") + |
| 68 |
6/12
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
|
21 |
"_bv" + std::to_string(s.bvec) + "_qa" + std::to_string(s.qa) + |
| 69 |
4/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
|
21 |
"_a" + std::to_string(s.act) + (s.avec ? "_av" : "") + |
| 70 |
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 |
(s.direct ? "_d" : "") + (s.has_bias ? "_bi" : "") + |
| 71 |
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 |
(s.rowch ? "_rc" : "") + (s.accum ? "_ac" : "") + |
| 72 |
6/12
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
|
21 |
"_k" + std::to_string(s.kh) + "x" + std::to_string(s.kw) + |
| 73 |
6/12
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
|
21 |
"_s" + std::to_string(s.sh) + "x" + std::to_string(s.sw) + |
| 74 |
6/12
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
|
21 |
"_p" + std::to_string(s.ph) + "x" + std::to_string(s.pw) + |
| 75 |
5/10
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
|
21 |
"_d" + std::to_string(s.dh) + "x" + std::to_string(s.dw); |
| 76 |
|
|
|
| 77 |
16/32
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 21 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 21 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 21 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 21 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 21 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 21 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 21 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 21 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 21 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 21 times.
✗ Branch 31 not taken.
|
336 |
std::vector<Type> params = { |
| 78 |
|
105 |
Type::ptr(), Type::ptr(), Type::ptr(), Type::ptr(), Type::ptr(), |
| 79 |
|
105 |
Type::i32(), Type::i32(), Type::i32(), Type::i32(), Type::i32(), |
| 80 |
|
126 |
Type::i32(), Type::i32(), Type::i32(), Type::i32(), Type::i32(), Type::i32(), |
| 81 |
|
|
}; |
| 82 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Function* fn = mod.create_function(name, Type::void_type(), brass::Span<const Type>(params)); |
| 83 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
brass::codegen::KernelBuilder kb(mod, fn); |
| 84 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Ctx c(kb); |
| 85 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
auto p = entry_params(c, fn); |
| 86 |
|
|
// ptrs: 0:x 1:w 2:y 3:bias 4:scale |
| 87 |
|
|
// ints: 5:m 6:n 7:k 8:h 9:wd 10:wo 11:cin 12:cout 13:groups 14:tm0 15:tn0 |
| 88 |
|
|
|
| 89 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Value* As = kb.shared_alloc_i32x4(2u * ASZ); |
| 90 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Value* Bs = kb.shared_alloc_i32x4(2u * BSZ); |
| 91 |
|
|
|
| 92 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 |
Value* tid = c.b.build_and(kb.tid_x(), c.i32(static_cast<int>(WG - 1u))); |
| 93 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 |
Value* sg = c.b.build_and(kb.subgroup_id(), c.i32(static_cast<int>(NSG - 1u))); |
| 94 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 |
Value* lane = c.b.build_and(kb.lane_id(), c.i32(31)); |
| 95 |
|
|
|
| 96 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Value* z = kb.ctaid_z(); |
| 97 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Value* img = c.b.build_udiv(z, p[13]); |
| 98 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Value* grp = c.b.build_umod(z, p[13]); |
| 99 |
|
21 |
Value* P = p[6]; |
| 100 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Value* cgi = c.b.build_udiv(p[11], p[13]); |
| 101 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 |
Value* x_ch_off = c.b.build_add(c.b.build_mul(img, p[11]), c.b.build_mul(grp, cgi)); |
| 102 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 |
Value* hw_in = c.b.build_mul(c.b.build_zext_i64(p[8]), c.b.build_zext_i64(p[9])); |
| 103 |
5/10
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
|
21 |
Value* X = c.b.build_add(p[0], c.b.build_shl(c.b.build_mul(c.b.build_zext_i64(x_ch_off), hw_in), kb.const_i64(1))); |
| 104 |
4/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
|
42 |
Value* w_off_elems = c.b.build_mul(c.b.build_mul(c.b.build_zext_i64(grp), c.b.build_zext_i64(p[5])), |
| 105 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
c.b.build_zext_i64(p[7])); |
| 106 |
5/8
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
|
21 |
Value* A = c.b.build_add(p[1], (s.qa != 0u) ? w_off_elems : c.b.build_shl(w_off_elems, kb.const_i64(1))); |
| 107 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 |
Value* y_ch_off = c.b.build_add(c.b.build_mul(img, p[12]), c.b.build_mul(grp, p[5])); |
| 108 |
5/10
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
|
42 |
Value* C = c.b.build_add(p[2], c.b.build_shl(c.b.build_mul(c.b.build_zext_i64(y_ch_off), c.b.build_zext_i64(P)), |
| 109 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
kb.const_i64(1))); |
| 110 |
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 |
Value* BIASP = ptr_at(c, p[3], c.b.build_mul(grp, p[5]), 2); |
| 111 |
|
|
|
| 112 |
4/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
|
21 |
Value* m0 = c.b.build_mul(c.b.build_add(kb.ctaid_y(), p[14]), c.i32(static_cast<int>(BM))); |
| 113 |
4/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
|
21 |
Value* n0 = c.b.build_mul(c.b.build_add(kb.ctaid_x(), p[15]), c.i32(static_cast<int>(BN))); |
| 114 |
4/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
|
21 |
Value* wm0 = c.b.build_mul(c.b.build_umod(sg, c.i32(static_cast<int>(BM / WM))), c.i32(static_cast<int>(WM))); |
| 115 |
4/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
|
21 |
Value* wn0 = c.b.build_mul(c.b.build_udiv(sg, c.i32(static_cast<int>(BM / WM))), c.i32(static_cast<int>(WN))); |
| 116 |
|
|
|
| 117 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 |
std::vector<Value*> fa(TM), fb(TN), acc(TM * TN); |
| 118 |
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
|
79 |
for (std::uint32_t i = 0; i < TM; ++i) fa[i] = kb.coop_alloc_a(); |
| 119 |
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
|
63 |
for (std::uint32_t j = 0; j < TN; ++j) fb[j] = kb.coop_alloc_b(); |
| 120 |
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 116 times.
|
137 |
for (std::uint32_t i = 0; i < TM * TN; ++i) { |
| 121 |
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
|
116 |
acc[i] = kb.coop_alloc_acc(); |
| 122 |
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
|
116 |
kb.coop_fill_acc(acc[i], c.f32(0.0f)); |
| 123 |
|
116 |
} |
| 124 |
|
|
|
| 125 |
|
|
// Precompute A and B shared offsets + fixed output pixel geometry per B chunk. |
| 126 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 |
std::vector<Value*> a_r(LA), a_q(LA), a_smem(LA); |
| 127 |
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 58 times.
|
79 |
for (std::uint32_t j = 0; j < LA; ++j) { |
| 128 |
4/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
|
58 |
Value* i = (j == 0) ? tid : c.b.build_add(tid, c.i32(static_cast<int>(j * WG))); |
| 129 |
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
|
58 |
a_r[j] = c.b.build_udiv(i, c.i32(static_cast<int>(CA))); |
| 130 |
2/4
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
|
58 |
a_q[j] = c.b.build_umod(i, c.i32(static_cast<int>(CA))); |
| 131 |
3/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58 times.
✗ Branch 5 not taken.
|
58 |
a_smem[j] = c.b.build_add(c.b.build_mul(a_r[j], c.i32(static_cast<int>(SKA))), a_q[j]); |
| 132 |
|
58 |
} |
| 133 |
6/12
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
|
21 |
std::vector<Value*> b_r(LB), b_smem(LB), cb_p0(LB), cb_ih(LB), cb_iw(LB), cb_any_ok(LB); |
| 134 |
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 |
std::vector<std::array<Value*, 8>> cb_ih_e(LB), cb_iw_e(LB), cb_ok_e(LB); |
| 135 |
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 42 times.
|
63 |
for (std::uint32_t j = 0; j < LB; ++j) { |
| 136 |
4/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
42 |
Value* i = (j == 0) ? tid : c.b.build_add(tid, c.i32(static_cast<int>(j * WG))); |
| 137 |
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
|
42 |
b_r[j] = c.b.build_udiv(i, c.i32(static_cast<int>(CB))); |
| 138 |
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
|
42 |
Value* q = c.b.build_umod(i, c.i32(static_cast<int>(CB))); |
| 139 |
3/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
|
42 |
b_smem[j] = c.b.build_add(c.b.build_mul(b_r[j], c.i32(static_cast<int>(SKB))), q); |
| 140 |
3/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
|
42 |
cb_p0[j] = c.b.build_add(n0, c.b.build_shl(q, c.i32(3))); |
| 141 |
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
|
42 |
cb_any_ok[j] = c.b.build_ult(cb_p0[j], P); |
| 142 |
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
|
42 |
Value* oh = c.b.build_udiv(cb_p0[j], p[10]); |
| 143 |
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
|
42 |
Value* ow = c.b.build_umod(cb_p0[j], p[10]); |
| 144 |
4/8
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42 times.
✗ Branch 7 not taken.
|
42 |
cb_ih[j] = c.b.build_sub(c.b.build_mul(oh, c.i32(s.sh)), c.i32(s.ph)); |
| 145 |
4/8
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42 times.
✗ Branch 7 not taken.
|
42 |
cb_iw[j] = c.b.build_sub(c.b.build_mul(ow, c.i32(s.sw)), c.i32(s.pw)); |
| 146 |
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 14 times.
|
42 |
if (s.bvec == 0u && !s.rowch) { |
| 147 |
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14 times.
|
126 |
for (int e = 0; e < 8; ++e) { |
| 148 |
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
|
112 |
Value* pe = c.b.build_add(cb_p0[j], c.i32(e)); |
| 149 |
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
|
112 |
cb_ok_e[j][static_cast<std::size_t>(e)] = c.b.build_ult(pe, P); |
| 150 |
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
|
112 |
Value* ohe = c.b.build_udiv(pe, p[10]); |
| 151 |
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
|
112 |
Value* owe = c.b.build_umod(pe, p[10]); |
| 152 |
4/8
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 112 times.
✗ Branch 7 not taken.
|
112 |
cb_ih_e[j][static_cast<std::size_t>(e)] = c.b.build_sub(c.b.build_mul(ohe, c.i32(s.sh)), c.i32(s.ph)); |
| 153 |
4/8
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 112 times.
✗ Branch 7 not taken.
|
112 |
cb_iw_e[j][static_cast<std::size_t>(e)] = c.b.build_sub(c.b.build_mul(owe, c.i32(s.sw)), c.i32(s.pw)); |
| 154 |
|
112 |
} |
| 155 |
|
14 |
} |
| 156 |
|
42 |
} |
| 157 |
|
|
|
| 158 |
|
21 |
Value* H = p[8]; |
| 159 |
|
21 |
Value* W = p[9]; |
| 160 |
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 |
Value* W8 = c.b.build_lshr(W, c.i32(3)); |
| 161 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Value* scale_grp = c.b.build_mul(grp, p[5]); |
| 162 |
|
|
|
| 163 |
|
|
struct Loaded { |
| 164 |
|
|
std::vector<Value*> ra, va, qka; |
| 165 |
|
|
std::vector<QRawMir> rqa; |
| 166 |
|
|
std::vector<Value*> rbv, rbv2, vb_mask, vb_sft; |
| 167 |
|
|
std::vector<std::array<Value*, 8>> rb_u16, rb_ok; |
| 168 |
|
|
}; |
| 169 |
|
|
|
| 170 |
|
63 |
auto load_tiles = [&](Value* k0) -> Loaded { |
| 171 |
|
42 |
Loaded t; |
| 172 |
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
|
42 |
t.ra.resize(LA); |
| 173 |
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
|
42 |
t.va.resize(LA); |
| 174 |
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 28 times.
|
42 |
if (s.qa != 0u) { |
| 175 |
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 |
t.rqa.resize(LA); |
| 176 |
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 |
t.qka.resize(LA); |
| 177 |
|
14 |
} |
| 178 |
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 42 times.
|
158 |
for (std::uint32_t j = 0; j < LA; ++j) { |
| 179 |
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
|
116 |
Value* row = c.b.build_add(m0, a_r[j]); |
| 180 |
3/6
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
|
116 |
Value* col = c.b.build_add(k0, c.b.build_shl(a_q[j], c.i32(3))); |
| 181 |
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
|
116 |
Value* row_ok = c.b.build_ult(row, p[5]); |
| 182 |
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 84 times.
|
116 |
if (s.qa != 0u) { |
| 183 |
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
32 |
Value* ok = c.b.build_and(row_ok, c.b.build_ult(col, p[7])); |
| 184 |
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
32 |
Value* srow = c.b.build_select(ok, row, c.i32(0)); |
| 185 |
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
32 |
Value* scol = c.b.build_select(ok, col, c.i32(0)); |
| 186 |
4/8
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 32 times.
✗ Branch 7 not taken.
|
32 |
Value* rptr = c.b.build_add(A, c.b.build_mul(c.b.build_zext_i64(srow), c.b.build_zext_i64(p[7]))); |
| 187 |
|
32 |
t.qka[j] = scol; |
| 188 |
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
32 |
t.rqa[j] = emit_qload8_mir(c, QF_INT8, s.avec, rptr, p[4], c.b.build_add(scale_grp, srow), scol, p[7]); |
| 189 |
|
32 |
t.va[j] = ok; |
| 190 |
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
|
116 |
} else if (s.avec) { |
| 191 |
2/4
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
|
84 |
Value* ok = c.b.build_and(row_ok, c.b.build_ult(col, p[7])); |
| 192 |
4/8
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 84 times.
✗ Branch 7 not taken.
|
84 |
Value* idx = c.b.build_select(ok, c.b.build_add(c.b.build_mul(row, p[7]), col), c.i32(0)); |
| 193 |
2/4
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
|
84 |
t.ra[j] = kb.vload(Type::i32x4(), ptr_at(c, A, idx, 2)); |
| 194 |
|
84 |
t.va[j] = ok; |
| 195 |
|
84 |
} else { |
| 196 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
t.ra[j] = load8_a_scalar(c, s.dt, A, p[7], row, row_ok, col); |
| 197 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
t.va[j] = c.i32(1); |
| 198 |
|
|
} |
| 199 |
|
116 |
} |
| 200 |
|
|
|
| 201 |
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 36 times.
|
42 |
if (s.bvec == 1u) { |
| 202 |
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 |
t.rbv.resize(LB); |
| 203 |
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 |
t.vb_mask.resize(LB); |
| 204 |
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
|
18 |
for (std::uint32_t j = 0; j < LB; ++j) { |
| 205 |
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 |
Value* kk = c.b.build_add(k0, b_r[j]); |
| 206 |
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 |
Value* v = c.b.build_and(c.b.build_ult(kk, p[7]), cb_any_ok[j]); |
| 207 |
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
|
12 |
Value* idx = c.b.build_select(v, c.b.build_add(c.b.build_mul(kk, P), cb_p0[j]), c.i32(0)); |
| 208 |
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
12 |
t.rbv[j] = kb.vload(Type::i32x4(), ptr_at(c, X, idx, 2)); |
| 209 |
|
12 |
t.vb_mask[j] = v; |
| 210 |
|
12 |
} |
| 211 |
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 18 times.
|
42 |
} else if (s.bvec == 2u) { |
| 212 |
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 |
t.rbv.resize(LB); |
| 213 |
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 |
t.rbv2.resize(LB); |
| 214 |
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 |
t.vb_mask.resize(LB); |
| 215 |
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 |
t.vb_sft.resize(LB); |
| 216 |
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
|
54 |
for (std::uint32_t j = 0; j < LB; ++j) { |
| 217 |
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
|
36 |
Value* kk = c.b.build_add(k0, b_r[j]); |
| 218 |
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 |
Value* ic = c.b.build_udiv(kk, c.i32(KHW)); |
| 219 |
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 |
Value* rem = c.b.build_umod(kk, c.i32(KHW)); |
| 220 |
5/10
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
|
36 |
Value* ih = c.b.build_add(cb_ih[j], c.b.build_mul(c.b.build_udiv(rem, c.i32(s.kw)), c.i32(s.dh))); |
| 221 |
5/10
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
|
36 |
Value* iw0 = c.b.build_add(cb_iw[j], c.b.build_mul(c.b.build_umod(rem, c.i32(s.kw)), c.i32(s.dw))); |
| 222 |
4/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
|
36 |
Value* ih_ok = c.b.build_and(c.b.build_sge(ih, c.i32(0)), c.b.build_slt(ih, H)); |
| 223 |
3/6
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
|
36 |
Value* rok = c.b.build_and(c.b.build_ult(kk, p[7]), c.b.build_and(ih_ok, cb_any_ok[j])); |
| 224 |
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 |
Value* sft = c.b.build_and(iw0, c.i32(7)); |
| 225 |
3/6
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
|
36 |
Value* q0 = c.b.build_ashr(c.b.build_sub(iw0, sft), c.i32(3)); |
| 226 |
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 |
Value* ih_cl = smax_i32(c, ih, c.i32(0)); |
| 227 |
3/6
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
|
36 |
Value* rowq = c.b.build_mul(c.b.build_add(c.b.build_mul(ic, H), ih_cl), W8); |
| 228 |
5/10
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
|
36 |
Value* v0 = c.b.build_and(rok, c.b.build_and(c.b.build_sge(q0, c.i32(0)), c.b.build_slt(q0, W8))); |
| 229 |
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 |
Value* q1 = c.b.build_add(q0, c.i32(1)); |
| 230 |
5/10
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
|
36 |
Value* v1 = c.b.build_and(rok, c.b.build_and(c.b.build_sge(q1, c.i32(0)), c.b.build_slt(q1, W8))); |
| 231 |
5/10
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
|
36 |
t.rbv[j] = kb.vload(Type::i32x4(), ptr_at(c, X, c.b.build_select(v0, c.b.build_add(rowq, q0), c.i32(0)), 16)); |
| 232 |
5/10
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
|
36 |
t.rbv2[j] = kb.vload(Type::i32x4(), ptr_at(c, X, c.b.build_select(v1, c.b.build_add(rowq, q1), c.i32(0)), 16)); |
| 233 |
4/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
|
36 |
Value* lo = clamp_i32(c, c.b.build_neg(iw0), c.i32(0), c.i32(8)); |
| 234 |
4/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
|
36 |
Value* hi = clamp_i32(c, c.b.build_sub(W, iw0), c.i32(0), c.i32(8)); |
| 235 |
4/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
|
36 |
Value* m_hi = c.b.build_sub(c.b.build_shl(c.i32(1), hi), c.i32(1)); |
| 236 |
4/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
|
36 |
Value* m_lo = c.b.build_sub(c.b.build_shl(c.i32(1), lo), c.i32(1)); |
| 237 |
3/6
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
|
36 |
Value* m_bits = c.b.build_and(m_hi, c.b.build_xor(m_lo, c.i32(-1))); |
| 238 |
4/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
|
36 |
t.vb_mask[j] = c.b.build_select(c.b.build_and(rok, c.b.build_sgt(hi, lo)), m_bits, c.i32(0)); |
| 239 |
|
36 |
t.vb_sft[j] = sft; |
| 240 |
|
36 |
} |
| 241 |
|
18 |
} else { |
| 242 |
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 |
t.rb_u16.resize(LB); |
| 243 |
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 |
t.rb_ok.resize(LB); |
| 244 |
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
|
54 |
for (std::uint32_t j = 0; j < LB; ++j) { |
| 245 |
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
|
36 |
Value* kk = c.b.build_add(k0, b_r[j]); |
| 246 |
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
|
36 |
Value* kok = c.b.build_ult(kk, p[7]); |
| 247 |
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 |
Value* ic = c.b.build_udiv(kk, c.i32(KHW)); |
| 248 |
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 |
Value* rem = c.b.build_umod(kk, c.i32(KHW)); |
| 249 |
4/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
|
36 |
Value* kh_off = c.b.build_mul(c.b.build_udiv(rem, c.i32(s.kw)), c.i32(s.dh)); |
| 250 |
4/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
|
36 |
Value* kw_off = c.b.build_mul(c.b.build_umod(rem, c.i32(s.kw)), c.i32(s.dw)); |
| 251 |
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
|
36 |
Value* cbase = c.b.build_mul(ic, H); |
| 252 |
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 28 times.
|
36 |
if (s.rowch) { |
| 253 |
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 |
Value* ihb = c.b.build_add(cb_ih[j], kh_off); |
| 254 |
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 |
Value* iwb = c.b.build_add(cb_iw[j], kw_off); |
| 255 |
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
16 |
Value* rok = c.b.build_and( |
| 256 |
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
16 |
kok, c.b.build_and(cb_any_ok[j], |
| 257 |
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
|
8 |
c.b.build_and(c.b.build_sge(ihb, c.i32(0)), c.b.build_slt(ihb, H)))); |
| 258 |
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
|
8 |
Value* rowbase = c.b.build_mul(c.b.build_add(cbase, smax_i32(c, ihb, c.i32(0))), W); |
| 259 |
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8 times.
|
72 |
for (int e = 0; e < 8; ++e) { |
| 260 |
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
|
64 |
Value* iw = c.b.build_add(iwb, c.i32(e * s.sw)); |
| 261 |
5/10
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
|
64 |
Value* v = c.b.build_and(rok, c.b.build_and(c.b.build_sge(iw, c.i32(0)), c.b.build_slt(iw, W))); |
| 262 |
3/6
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
|
64 |
Value* idx = c.b.build_select(v, c.b.build_add(rowbase, iw), c.i32(0)); |
| 263 |
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
|
64 |
t.rb_u16[j][static_cast<std::size_t>(e)] = kb.load_u16(ptr_at(c, X, idx, 2)); |
| 264 |
|
64 |
t.rb_ok[j][static_cast<std::size_t>(e)] = v; |
| 265 |
|
64 |
} |
| 266 |
|
8 |
} else { |
| 267 |
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 224 times.
|
252 |
for (int e = 0; e < 8; ++e) { |
| 268 |
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
|
224 |
Value* ih = c.b.build_add(cb_ih_e[j][static_cast<std::size_t>(e)], kh_off); |
| 269 |
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
|
224 |
Value* iw = c.b.build_add(cb_iw_e[j][static_cast<std::size_t>(e)], kw_off); |
| 270 |
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
|
448 |
Value* v = c.b.build_and( |
| 271 |
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
|
448 |
kok, c.b.build_and( |
| 272 |
|
224 |
cb_ok_e[j][static_cast<std::size_t>(e)], |
| 273 |
5/10
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 224 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 224 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 224 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 224 times.
✗ Branch 9 not taken.
|
448 |
c.b.build_and(c.b.build_and(c.b.build_sge(ih, c.i32(0)), c.b.build_slt(ih, H)), |
| 274 |
4/8
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 224 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 224 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 224 times.
✗ Branch 7 not taken.
|
224 |
c.b.build_and(c.b.build_sge(iw, c.i32(0)), c.b.build_slt(iw, W))))); |
| 275 |
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
|
448 |
Value* idx = c.b.build_select( |
| 276 |
4/8
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 224 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 224 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 224 times.
✗ Branch 7 not taken.
|
224 |
v, c.b.build_add(c.b.build_mul(c.b.build_add(cbase, ih), W), iw), c.i32(0)); |
| 277 |
2/4
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 224 times.
✗ Branch 3 not taken.
|
224 |
t.rb_u16[j][static_cast<std::size_t>(e)] = kb.load_u16(ptr_at(c, X, idx, 2)); |
| 278 |
|
224 |
t.rb_ok[j][static_cast<std::size_t>(e)] = v; |
| 279 |
|
224 |
} |
| 280 |
|
|
} |
| 281 |
|
36 |
} |
| 282 |
|
|
} |
| 283 |
|
42 |
return t; |
| 284 |
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
|
42 |
}; |
| 285 |
|
|
|
| 286 |
|
63 |
auto store_tiles = [&](Value* buf, const Loaded& t) { |
| 287 |
|
42 |
Value* b01 = c.b.build_and(buf, c.i32(1)); |
| 288 |
|
42 |
Value* abase = c.b.build_mul(b01, c.i32(static_cast<int>(ASZ))); |
| 289 |
|
42 |
Value* bbase = c.b.build_mul(b01, c.i32(static_cast<int>(BSZ))); |
| 290 |
|
42 |
Value* z4 = emit_v4_zero(c); |
| 291 |
|
|
|
| 292 |
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 42 times.
|
158 |
for (std::uint32_t j = 0; j < LA; ++j) { |
| 293 |
|
116 |
Value* h = nullptr; |
| 294 |
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 84 times.
|
116 |
if (s.qa != 0u) { |
| 295 |
|
32 |
h = emit_v4_select(c, t.va[j], emit_qdecode8_f16_mir(c, QF_INT8, t.rqa[j], t.qka[j]), z4); |
| 296 |
|
32 |
} else { |
| 297 |
|
84 |
h = t.ra[j]; |
| 298 |
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
|
84 |
if (s.avec) { |
| 299 |
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 16 times.
|
84 |
if (s.dt == Dtype::BF16) h = emit_bf16x8_to_f16x8(c, h); |
| 300 |
|
84 |
h = emit_v4_select(c, t.va[j], h, z4); |
| 301 |
|
84 |
} |
| 302 |
|
|
} |
| 303 |
|
116 |
kb.shared_store_i32x4_indexed(As, c.b.build_add(abase, a_smem[j]), h); |
| 304 |
|
116 |
} |
| 305 |
|
|
|
| 306 |
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 36 times.
|
42 |
if (s.bvec == 1u) { |
| 307 |
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
|
18 |
for (std::uint32_t j = 0; j < LB; ++j) { |
| 308 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 |
Value* h = (s.dt == Dtype::BF16) ? emit_bf16x8_to_f16x8(c, t.rbv[j]) : t.rbv[j]; |
| 309 |
|
12 |
h = emit_v4_select(c, t.vb_mask[j], h, z4); |
| 310 |
|
12 |
kb.shared_store_i32x4_indexed(Bs, c.b.build_add(bbase, b_smem[j]), h); |
| 311 |
|
12 |
} |
| 312 |
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 18 times.
|
42 |
} else if (s.bvec == 2u) { |
| 313 |
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 18 times.
|
54 |
for (std::uint32_t j = 0; j < LB; ++j) { |
| 314 |
|
|
Value* u[8]; |
| 315 |
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
|
180 |
for (std::uint32_t q = 0; q < 4; ++q) { |
| 316 |
|
144 |
u[q] = c.b.build_vextract_lane(t.rbv[j], q); |
| 317 |
|
144 |
u[4u + q] = c.b.build_vextract_lane(t.rbv2[j], q); |
| 318 |
|
144 |
} |
| 319 |
|
36 |
Value* sft = t.vb_sft[j]; |
| 320 |
|
36 |
Value* a = c.b.build_lshr(sft, c.i32(1)); |
| 321 |
|
36 |
Value* odd = c.b.build_ne(c.b.build_and(sft, c.i32(1)), c.i32(0)); |
| 322 |
|
36 |
Value* eq0 = c.b.build_eq(a, c.i32(0)); |
| 323 |
|
36 |
Value* eq1 = c.b.build_eq(a, c.i32(1)); |
| 324 |
|
36 |
Value* eq2 = c.b.build_eq(a, c.i32(2)); |
| 325 |
|
|
Value* w[4]; |
| 326 |
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
|
180 |
for (std::uint32_t q = 0; q < 4; ++q) { |
| 327 |
|
288 |
Value* w0 = c.b.build_select(eq0, u[q], c.b.build_select(eq1, u[q + 1], |
| 328 |
|
144 |
c.b.build_select(eq2, u[q + 2], u[q + 3]))); |
| 329 |
|
288 |
Value* w1 = c.b.build_select(eq0, u[q + 1], c.b.build_select(eq1, u[q + 2], |
| 330 |
|
144 |
c.b.build_select(eq2, u[q + 3], u[q + 4]))); |
| 331 |
|
144 |
w[q] = c.b.build_select(odd, c.b.build_or(c.b.build_lshr(w0, c.i32(16)), c.b.build_shl(w1, c.i32(16))), w0); |
| 332 |
|
144 |
} |
| 333 |
|
36 |
Value* h = emit_v4_pack(c, w[0], w[1], w[2], w[3]); |
| 334 |
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
|
36 |
if (s.dt == Dtype::BF16) h = emit_bf16x8_to_f16x8(c, h); |
| 335 |
|
36 |
Value* m = t.vb_mask[j]; |
| 336 |
|
|
Value* mw[4]; |
| 337 |
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
|
180 |
for (std::uint32_t q = 0; q < 4; ++q) { |
| 338 |
|
144 |
Value* lo_ok = c.b.build_ne(c.b.build_and(c.b.build_lshr(m, c.i32(static_cast<int>(2u * q))), c.i32(1)), c.i32(0)); |
| 339 |
|
144 |
Value* hi_ok = c.b.build_ne(c.b.build_and(c.b.build_lshr(m, c.i32(static_cast<int>(2u * q + 1u))), c.i32(1)), c.i32(0)); |
| 340 |
|
288 |
Value* mm = c.b.build_or(c.b.build_select(lo_ok, c.i32(0xffff), c.i32(0)), |
| 341 |
|
144 |
c.b.build_select(hi_ok, c.i32(static_cast<int>(0xffff0000u)), c.i32(0))); |
| 342 |
|
144 |
mw[q] = c.b.build_and(c.b.build_vextract_lane(h, q), mm); |
| 343 |
|
144 |
} |
| 344 |
|
36 |
kb.shared_store_i32x4_indexed(Bs, c.b.build_add(bbase, b_smem[j]), emit_v4_pack(c, mw[0], mw[1], mw[2], mw[3])); |
| 345 |
|
36 |
} |
| 346 |
|
18 |
} else { |
| 347 |
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 18 times.
|
54 |
for (std::uint32_t j = 0; j < LB; ++j) { |
| 348 |
|
|
Value* w[4]; |
| 349 |
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
|
180 |
for (int q = 0; q < 4; ++q) { |
| 350 |
|
144 |
Value* lo = t.rb_u16[j][static_cast<std::size_t>(2 * q)]; |
| 351 |
|
144 |
Value* hi = t.rb_u16[j][static_cast<std::size_t>(2 * q + 1)]; |
| 352 |
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 32 times.
|
144 |
if (s.dt == Dtype::BF16) { |
| 353 |
|
32 |
lo = bf16_bits_to_f16_bits(c, lo); |
| 354 |
|
32 |
hi = bf16_bits_to_f16_bits(c, hi); |
| 355 |
|
32 |
} |
| 356 |
|
144 |
lo = c.b.build_select(t.rb_ok[j][static_cast<std::size_t>(2 * q)], lo, c.i32(0)); |
| 357 |
|
144 |
hi = c.b.build_select(t.rb_ok[j][static_cast<std::size_t>(2 * q + 1)], hi, c.i32(0)); |
| 358 |
|
144 |
w[q] = c.b.build_or(lo, c.b.build_shl(hi, c.i32(16))); |
| 359 |
|
144 |
} |
| 360 |
|
36 |
kb.shared_store_i32x4_indexed(Bs, c.b.build_add(bbase, b_smem[j]), emit_v4_pack(c, w[0], w[1], w[2], w[3])); |
| 361 |
|
36 |
} |
| 362 |
|
|
} |
| 363 |
|
42 |
}; |
| 364 |
|
|
|
| 365 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Value* stride_a = c.i32(static_cast<int>(SKA * 8u)); |
| 366 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
Value* stride_b = c.i32(static_cast<int>(SKB * 8u)); |
| 367 |
|
63 |
auto mma_tile = [&](Value* buf) { |
| 368 |
|
42 |
Value* b01 = c.b.build_and(buf, c.i32(1)); |
| 369 |
|
42 |
Value* abase = c.b.build_mul(b01, c.i32(static_cast<int>(ASZ))); |
| 370 |
|
42 |
Value* bbase = c.b.build_mul(b01, c.i32(static_cast<int>(BSZ))); |
| 371 |
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 42 times.
|
126 |
for (std::uint32_t kk = 0; kk < BK / 16u; ++kk) { |
| 372 |
2/2
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 84 times.
|
316 |
for (std::uint32_t i = 0; i < TM; ++i) { |
| 373 |
|
232 |
Value* row_m = c.b.build_add(wm0, c.i32(static_cast<int>(i * 16u))); |
| 374 |
|
232 |
Value* off = c.b.build_add(c.b.build_mul(row_m, c.i32(static_cast<int>(SKA))), c.i32(static_cast<int>(kk * 2u))); |
| 375 |
|
232 |
kb.coop_load_a(fa[i], c.b.build_add(As, c.b.build_shl(c.b.build_add(abase, off), c.i32(4))), stride_a, false); |
| 376 |
|
232 |
} |
| 377 |
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 84 times.
|
252 |
for (std::uint32_t j = 0; j < TN; ++j) { |
| 378 |
|
168 |
Value* col_n = c.b.build_add(wn0, c.i32(static_cast<int>(j * 16u))); |
| 379 |
|
168 |
Value* off = c.b.build_add(c.i32(static_cast<int>(kk * 16u * SKB)), c.b.build_lshr(col_n, c.i32(3))); |
| 380 |
|
168 |
kb.coop_load_b(fb[j], c.b.build_add(Bs, c.b.build_shl(c.b.build_add(bbase, off), c.i32(4))), stride_b, false); |
| 381 |
|
168 |
} |
| 382 |
2/2
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 84 times.
|
316 |
for (std::uint32_t i = 0; i < TM; ++i) { |
| 383 |
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 232 times.
|
696 |
for (std::uint32_t j = 0; j < TN; ++j) kb.coop_mma(acc[i * TN + j], fa[i], fb[j]); |
| 384 |
|
232 |
} |
| 385 |
|
84 |
} |
| 386 |
|
42 |
}; |
| 387 |
|
|
|
| 388 |
4/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
|
21 |
Value* nk = c.b.build_lshr(c.b.build_add(p[7], c.i32(static_cast<int>(BK - 1u))), c.i32(5)); |
| 389 |
4/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
|
42 |
kb.if_then(c.b.build_ugt(nk, c.i32(0)), [&] { |
| 390 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
store_tiles(c.i32(0), load_tiles(c.i32(0))); |
| 391 |
|
21 |
kb.sync(); |
| 392 |
|
21 |
Value* nk_m1 = c.b.build_sub(nk, c.i32(1)); |
| 393 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
42 |
kb.for_range(c.i32(0), nk_m1, c.i32(1), [&](Value* kt) { |
| 394 |
|
21 |
Value* cur = c.b.build_and(kt, c.i32(1)); |
| 395 |
|
21 |
Value* nxt = c.b.build_xor(cur, c.i32(1)); |
| 396 |
|
21 |
Loaded next_t = load_tiles(c.b.build_shl(c.b.build_add(kt, c.i32(1)), c.i32(5))); |
| 397 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
mma_tile(cur); |
| 398 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
store_tiles(nxt, next_t); |
| 399 |
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 |
kb.sync(); |
| 400 |
|
21 |
}); |
| 401 |
|
21 |
mma_tile(c.b.build_and(nk_m1, c.i32(1))); |
| 402 |
|
21 |
}); |
| 403 |
|
|
|
| 404 |
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 11 times.
|
21 |
if (s.direct) { |
| 405 |
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
10 |
Value* tmp_acc = (s.has_bias || s.accum) ? kb.coop_alloc_acc() : nullptr; |
| 406 |
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 22 times.
|
32 |
for (std::uint32_t i = 0; i < TM; ++i) { |
| 407 |
3/6
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
|
22 |
Value* row = c.b.build_add(c.b.build_add(m0, wm0), c.i32(static_cast<int>(i * 16u))); |
| 408 |
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 |
Value* row_off = c.b.build_mul(row, P); |
| 409 |
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 22 times.
|
66 |
for (std::uint32_t j = 0; j < TN; ++j) { |
| 410 |
|
44 |
Value* r = acc[i * TN + j]; |
| 411 |
3/6
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
|
44 |
Value* col = c.b.build_add(c.b.build_add(n0, wn0), c.i32(static_cast<int>(j * 16u))); |
| 412 |
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
|
44 |
Value* c_ptr = ptr_at(c, C, c.b.build_add(row_off, col), 2); |
| 413 |
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 20 times.
|
44 |
if (s.has_bias) { |
| 414 |
3/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
|
24 |
kb.coop_load_acc(tmp_acc, ptr_at(c, BIASP, row, 2), c.i32(0), true, true); |
| 415 |
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 |
kb.coop_add_acc(r, tmp_acc); |
| 416 |
|
24 |
} |
| 417 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
|
44 |
if (s.act != LACT_NONE) { |
| 418 |
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
✗ |
emit_coop_acc_map(c, r, [&](Value*, Value* rv) { return conv_act(c, s.act, rv); }); |
| 419 |
|
✗ |
} |
| 420 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
|
44 |
if (s.accum) { |
| 421 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
kb.coop_load_acc(tmp_acc, c_ptr, P, false, true); |
| 422 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
kb.coop_add_acc(r, tmp_acc); |
| 423 |
|
✗ |
} |
| 424 |
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
|
44 |
kb.coop_store_acc(r, c_ptr, P, false, true); |
| 425 |
|
44 |
} |
| 426 |
|
22 |
} |
| 427 |
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 |
c.b.build_ret_void(); |
| 428 |
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 |
return finalize_fn(fn); |
| 429 |
|
|
} |
| 430 |
|
|
|
| 431 |
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 |
kb.sync(); |
| 432 |
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 |
Value* sbase_v4 = c.b.build_shl(sg, c.i32(7)); |
| 433 |
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 |
Value* sbase_f = c.b.build_shl(sbase_v4, c.i32(2)); |
| 434 |
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 |
Value* sbase_bytes = c.b.build_shl(sbase_v4, c.i32(4)); |
| 435 |
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 36 times.
|
47 |
for (std::uint32_t i = 0; i < TM; ++i) { |
| 436 |
3/6
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
|
36 |
Value* gm0 = c.b.build_add(c.b.build_add(m0, wm0), c.i32(static_cast<int>(i * 16u))); |
| 437 |
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 36 times.
|
108 |
for (std::uint32_t j = 0; j < TN; ++j) { |
| 438 |
3/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 |
kb.coop_store_acc(acc[i * TN + j], c.b.build_add(As, sbase_bytes), c.i32(16), false, false); |
| 439 |
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 |
kb.subgroup_barrier(); |
| 440 |
3/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 |
Value* gn0 = c.b.build_add(c.b.build_add(n0, wn0), c.i32(static_cast<int>(j * 16u))); |
| 441 |
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 576 times.
|
648 |
for (int e0 = 0; e0 < 256; e0 += 32) { |
| 442 |
4/6
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 504 times.
✗ Branch 5 not taken.
|
576 |
Value* e = (e0 == 0) ? lane : c.b.build_add(lane, c.i32(e0)); |
| 443 |
3/6
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 576 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
|
576 |
Value* gm = c.b.build_add(gm0, c.b.build_lshr(e, c.i32(4))); |
| 444 |
3/6
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 576 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
|
576 |
Value* gn = c.b.build_add(gn0, c.b.build_and(e, c.i32(15))); |
| 445 |
5/10
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 576 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 576 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 576 times.
|
1152 |
kb.if_then(c.b.build_and(c.b.build_ult(gm, p[5]), c.b.build_ult(gn, P)), [&] { |
| 446 |
|
576 |
Value* v = kb.shared_load_f32_from_v4(As, c.b.build_add(sbase_f, e)); |
| 447 |
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 512 times.
|
576 |
if (s.has_bias) v = c.b.build_add(v, load_elem_dt(c, s.dt, BIASP, gm)); |
| 448 |
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 128 times.
|
576 |
if (s.act != LACT_NONE) v = conv_act(c, s.act, v); |
| 449 |
|
576 |
Value* o = c.b.build_add(c.b.build_mul(gm, P), gn); |
| 450 |
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
|
576 |
if (s.accum) v = c.b.build_add(v, load_elem_dt(c, s.dt, C, o)); |
| 451 |
|
576 |
store_elem_dt(c, s.dt, C, o, v); |
| 452 |
|
576 |
}); |
| 453 |
|
576 |
} |
| 454 |
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
|
72 |
kb.subgroup_barrier(); |
| 455 |
|
72 |
} |
| 456 |
|
36 |
} |
| 457 |
|
|
|
| 458 |
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 |
c.b.build_ret_void(); |
| 459 |
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 |
return finalize_fn(fn); |
| 460 |
|
21 |
} |
| 461 |
|
|
|
| 462 |
|
|
} // namespace brotensor::kernels |
| 463 |
|
|
|