Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

Fix metal shader fmt (#496)

uuuvne8f6238d1b2f
diff --git a/crates/backend-uzu/src/backends/metal/kernel/audio/norm_ncs.metal b/crates/backend-uzu/src/backends/metal/kernel/audio/norm_ncs.metal
index 58f917262..7650656d7 100644
--- a/crates/backend-uzu/src/backends/metal/kernel/audio/norm_ncs.metal
+++ b/crates/backend-uzu/src/backends/metal/kernel/audio/norm_ncs.metal
@@ -10,11 +10,11 @@ using namespace metal;
template <typename T>
void norm_ncs(
- device const T* input, // [B, C, T]
+ device const T* input, // [B, C, T]
device const float* scales, // [C]
device const float* bias, // [C]
- device T* output, // [B, C, T]
- device const int* lengths, // [B]
+ device T* output, // [B, C, T]
+ device const int* lengths, // [B]
const constant int& channels,
const constant int& seq_len,
const constant float& epsilon,
diff --git a/crates/backend-uzu/src/backends/metal/kernel/matmul/gemm/common/mxu_mma_core.h b/crates/backend-uzu/src/backends/metal/kernel/matmul/gemm/common/mxu_mma_core.h
index 82202985f..3d31a15bd 100644
--- a/crates/backend-uzu/src/backends/metal/kernel/matmul/gemm/common/mxu_mma_core.h
+++ b/crates/backend-uzu/src/backends/metal/kernel/matmul/gemm/common/mxu_mma_core.h
@@ -282,9 +282,8 @@ struct MxuMmaCore {
(simdgroup_limit_n == SIMDGROUP_BLOCK_N),
[&](auto aligned_n) {
auto accumulator_tile = [&]() {
- if constexpr (
- B_PROLOGUE == GemmBPrologueKind::FullPrecision
- ) {
+ if constexpr (B_PROLOGUE ==
+ GemmBPrologueKind::FullPrecision) {
const int aligned_k_iterations_fp =
int(params->aligned_inner_iterations);
return uzu::matmul::gemm_loop<
@@ -329,9 +328,8 @@ struct MxuMmaCore {
scales + block_col * groups_per_row + k_offset_groups;
auto loader_b = [&]() {
- if constexpr (
- B_PROLOGUE == GemmBPrologueKind::ScaleBiasDequant
- ) {
+ if constexpr (B_PROLOGUE ==
+ GemmBPrologueKind::ScaleBiasDequant) {
const device BT* biases_offset =
biases + block_col * groups_per_row +
k_offset_groups;
@@ -344,10 +342,9 @@ struct MxuMmaCore {
thread_context.simdgroup_index,
thread_context.simd_lane_id
);
- } else if constexpr (
- B_PROLOGUE ==
- GemmBPrologueKind::ScaleZeroPointDequant
- ) {
+ } else if constexpr (B_PROLOGUE ==
+ GemmBPrologueKind::
+ ScaleZeroPointDequant) {
const int zero_point_stride_per_row =
(BITS == 4) ? ((groups_per_row + 1) / 2)
: groups_per_row;
diff --git a/crates/backend-uzu/src/backends/metal/kernel/matmul/gemm/common/simdgroup_mma_core.h b/crates/backend-uzu/src/backends/metal/kernel/matmul/gemm/common/simdgroup_mma_core.h
index 1ce69ed3b..ce4cd08b1 100644
--- a/crates/backend-uzu/src/backends/metal/kernel/matmul/gemm/common/simdgroup_mma_core.h
+++ b/crates/backend-uzu/src/backends/metal/kernel/matmul/gemm/common/simdgroup_mma_core.h
@@ -175,10 +175,8 @@ struct SimdgroupMmaCore {
const thread ThreadContext& thread_context
) {
constexpr GemmAlignment gemm_alignment{GEMM_ALIGNMENT_RAW};
- if constexpr (
- gemm_alignment.contains(GemmAlignment::M) &&
- gemm_alignment.contains(GemmAlignment::N)
- ) {
+ if constexpr (gemm_alignment.contains(GemmAlignment::M) &&
+ gemm_alignment.contains(GemmAlignment::N)) {
if (needs_epilogue) {
accumulator.apply_epilogue(d, params->leading_dimension_d, 1, epilogue);
}
@@ -329,9 +327,8 @@ struct SimdgroupMmaCore {
thread_context.simdgroup_index,
thread_context.simd_lane_id
);
- } else if constexpr (
- B_PROLOGUE == GemmBPrologueKind::ScaleZeroPointDequant
- ) {
+ } else if constexpr (B_PROLOGUE ==
+ GemmBPrologueKind::ScaleZeroPointDequant) {
const int zero_point_stride_per_row =
(BITS == 4) ? ((groups_per_row + 1) / 2) : groups_per_row;
const device uint8_t* zero_points_row_start =
diff --git a/crates/backend-uzu/src/backends/metal/kernel/matmul/gemv/common/b_source.h b/crates/backend-uzu/src/backends/metal/kernel/matmul/gemv/common/b_source.h
index a9fa82495..a60b59081 100644
--- a/crates/backend-uzu/src/backends/metal/kernel/matmul/gemv/common/b_source.h
+++ b/crates/backend-uzu/src/backends/metal/kernel/matmul/gemv/common/b_source.h
@@ -111,9 +111,8 @@ struct BSource {
prep.scales = scales + out_row * in_vec_size_g + g_offset;
if constexpr (B_PROLOGUE == GemmBPrologueKind::ScaleBiasDequant) {
prep.biases = biases + out_row * in_vec_size_g + g_offset;
- } else if constexpr (
- B_PROLOGUE == GemmBPrologueKind::ScaleZeroPointDequant
- ) {
+ } else if constexpr (B_PROLOGUE ==
+ GemmBPrologueKind::ScaleZeroPointDequant) {
if (BITS == 4) {
prep.zp_stride = (in_vec_size_g + 1) / 2;
prep.zps = zero_points + out_row * prep.zp_stride + g_offset / 2;
diff --git a/crates/backend-uzu/src/backends/metal/kernel/matmul/gemv/common/quant_row_offsets.h b/crates/backend-uzu/src/backends/metal/kernel/matmul/gemv/common/quant_row_offsets.h
index 0965132c0..d3cdbd85d 100644
--- a/crates/backend-uzu/src/backends/metal/kernel/matmul/gemv/common/quant_row_offsets.h
+++ b/crates/backend-uzu/src/backends/metal/kernel/matmul/gemv/common/quant_row_offsets.h
@@ -30,9 +30,8 @@ struct QuantRowOffsets {
offset[1] = static_cast<U>(biases[group_stride]);
offset[2] = static_cast<U>(biases[2 * group_stride]);
offset[3] = static_cast<U>(biases[3 * group_stride]);
- } else if constexpr (
- B_PROLOGUE == GemmBPrologueKind::ScaleZeroPointDequant
- ) {
+ } else if constexpr (B_PROLOGUE ==
+ GemmBPrologueKind::ScaleZeroPointDequant) {
uchar4 zp_bytes = uchar4(
zps[0],
zps[zp_stride],
@@ -63,9 +62,8 @@ struct QuantRowOffsets {
scales += groups;
if constexpr (B_PROLOGUE == GemmBPrologueKind::ScaleBiasDequant) {
biases += groups;
- } else if constexpr (
- B_PROLOGUE == GemmBPrologueKind::ScaleZeroPointDequant
- ) {
+ } else if constexpr (B_PROLOGUE ==
+ GemmBPrologueKind::ScaleZeroPointDequant) {
constexpr uint zps_per_byte = get_pack_factor<BITS, 8>();
zps += groups / zps_per_byte;
}