forked from antirez/qwen-asr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (89 loc) · 3.75 KB
/
Makefile
File metadata and controls
104 lines (89 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# qwen_asr — Qwen3-ASR Pure C Inference Engine
# Makefile
CC = gcc
CFLAGS_BASE = -Wall -Wextra -O3 -march=native -ffast-math
LDFLAGS = -lm -lpthread
# Platform detection
UNAME_S := $(shell uname -s)
# Source files
SRCS = qwen_asr.c qwen_asr_kernels.c qwen_asr_kernels_generic.c qwen_asr_kernels_neon.c qwen_asr_kernels_avx.c qwen_asr_audio.c qwen_asr_encoder.c qwen_asr_decoder.c qwen_asr_tokenizer.c qwen_asr_safetensors.c
OBJS = $(SRCS:.c=.o)
MAIN = main.c
TARGET = qwen_asr
# Debug build flags
DEBUG_CFLAGS = -Wall -Wextra -g -O0 -DDEBUG -fsanitize=address
.PHONY: all clean debug info help blas test test-stream-cache
# Default: show available targets
all: help
help:
@echo "qwen_asr — Qwen3-ASR Pure C Inference - Build Targets"
@echo ""
@echo "Choose a backend:"
@echo " make blas - With BLAS acceleration (Accelerate/OpenBLAS)"
@echo ""
@echo "Other targets:"
@echo " make debug - Debug build with AddressSanitizer"
@echo " make test - Run regression suite (requires ./qwen_asr and model files)"
@echo " make test-stream-cache - Run stream cache on/off equivalence check"
@echo " make clean - Remove build artifacts"
@echo " make info - Show build configuration"
@echo ""
@echo "Example: make blas && ./qwen_asr -d model_dir -i audio.wav"
# =============================================================================
# Backend: blas (Accelerate on macOS, OpenBLAS on Linux)
# =============================================================================
ifeq ($(UNAME_S),Darwin)
blas: CFLAGS = $(CFLAGS_BASE) -DUSE_BLAS -DACCELERATE_NEW_LAPACK
blas: LDFLAGS += -framework Accelerate
else
blas: CFLAGS = $(CFLAGS_BASE) -DUSE_BLAS -DUSE_OPENBLAS -I/usr/include/openblas
blas: LDFLAGS += -lopenblas
endif
blas:
@$(MAKE) clean
@$(MAKE) $(TARGET) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
@echo ""
@echo "Built with BLAS backend"
# =============================================================================
# Build rules
# =============================================================================
$(TARGET): $(OBJS) main.o
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c qwen_asr.h qwen_asr_kernels.h
$(CC) $(CFLAGS) -c -o $@ $<
# Debug build
debug: CFLAGS = $(DEBUG_CFLAGS)
debug: LDFLAGS += -fsanitize=address
debug:
@$(MAKE) clean
@$(MAKE) $(TARGET) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
# =============================================================================
# Utilities
# =============================================================================
clean:
rm -f $(OBJS) main.o $(TARGET)
info:
@echo "Platform: $(UNAME_S)"
@echo "Compiler: $(CC)"
@echo ""
ifeq ($(UNAME_S),Darwin)
@echo "Backend: blas (Apple Accelerate)"
else
@echo "Backend: blas (OpenBLAS)"
endif
test:
./asr_regression.py --binary ./qwen_asr --model-dir qwen3-asr-1.7b
# =============================================================================
# Dependencies
# =============================================================================
qwen_asr.o: qwen_asr.c qwen_asr.h qwen_asr_kernels.h qwen_asr_safetensors.h qwen_asr_audio.h qwen_asr_tokenizer.h
qwen_asr_kernels.o: qwen_asr_kernels.c qwen_asr_kernels.h qwen_asr_kernels_impl.h
qwen_asr_kernels_generic.o: qwen_asr_kernels_generic.c qwen_asr_kernels_impl.h
qwen_asr_kernels_neon.o: qwen_asr_kernels_neon.c qwen_asr_kernels_impl.h
qwen_asr_kernels_avx.o: qwen_asr_kernels_avx.c qwen_asr_kernels_impl.h
qwen_asr_audio.o: qwen_asr_audio.c qwen_asr_audio.h
qwen_asr_encoder.o: qwen_asr_encoder.c qwen_asr.h qwen_asr_kernels.h qwen_asr_safetensors.h
qwen_asr_decoder.o: qwen_asr_decoder.c qwen_asr.h qwen_asr_kernels.h qwen_asr_safetensors.h
qwen_asr_tokenizer.o: qwen_asr_tokenizer.c qwen_asr_tokenizer.h
qwen_asr_safetensors.o: qwen_asr_safetensors.c qwen_asr_safetensors.h
main.o: main.c qwen_asr.h qwen_asr_kernels.h