tinyblocks-ai: redes neurais em blocos sobre a tinyblocks-tensor
Camadas com os parametros na instancia do bloco (nascem na primeira avaliacao, no grupo ativo): linear, convolucao e convolucao transposta (im2col + GEMM, lote dividido entre threads), max pool, batch norm, layer norm, RMSNorm, embedding, dropout, LSTM, atencao multi-cabeca (causal ou nao) e SwiGLU. Ativacoes relu, leaky relu, tanh, sigmoide, GELU, SiLU, softmax; perdas entropia cruzada, BCE com logits e erro quadratico; Adam e SGD por grupo; algoritmo genetico; tokenizador BPE por bytes; amostragem com temperatura e top-k. Usa so a tabela TbTensorApi (sem linkar com a tensor). test-ai confere o gradiente de cada operacao e camada (pesos inclusive) por diferenca finita, um treino com Adam, o BPE ida e volta e o algoritmo genetico. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
520cb10f08
commit
05fdb094ed
11 files changed
+1947
-2
No files matched your search
@@ -86,7 +86,7 @@ CAT_LDFLAGS := $(foreach l,$(CAT_LIBS),-ltinyblocks-$(l))
|
||||
CAT_INCS := $(foreach l,$(CAT_LIBS),-I$(LIBDIR)/tinyblocks-$(l)/include)
|
||||
# Libraries que o editor registra como as de categoria, mas com varios
|
||||
# fontes e o Makefile proprio (o harness nao as compila junto)
|
||||
APP_LIBS := tensor
|
||||
APP_LIBS := tensor ai
|
||||
APP_A := $(foreach l,$(APP_LIBS),$(LIBDIR)/tinyblocks-$(l)/build/libtinyblocks-$(l).a)
|
||||
APP_INCS := $(foreach l,$(APP_LIBS),-I$(LIBDIR)/tinyblocks-$(l)/include)
|
||||
APP_LDLIBS := -lpthread
|
||||
@@ -111,7 +111,7 @@ LIB_LDFLAGS := -L$(ED_DIR)/build -L$(GX_DIR)/build -L$(SD_DIR)/build \
|
||||
editor run-editor run-sdl2 mylib vector customappearance graphics sdl2-backend test-editor \
|
||||
appdir appimage run-appimage icon \
|
||||
test-toml test-plugin test-blueprint test-a11y test-mcp test-mcp-server test-base64 test-curves test-meta test-ppm test-bmp test-png test-image test-vg test-svg test-jpg \
|
||||
test-tensor test-syntax test-os test-value test-vars test-scratchblocks test-input test-stdlib test-regex test-markdown test-opentype \
|
||||
test-tensor test-ai test-syntax test-os test-value test-vars test-scratchblocks test-input test-stdlib test-regex test-markdown test-opentype \
|
||||
category-libs category-sos libs app-libs \
|
||||
lib-events lib-control lib-errors lib-input lib-operators lib-number lib-string lib-variables lib-vector lib-appearance lib-pen lib-fs lib-os \
|
||||
lib-environ \
|
||||
@@ -616,6 +616,18 @@ $(BUILD)/tensor_test: tests/tensor_test.c $(TENSOR_SRCS) $(TENSOR_DIR)/include/t
|
||||
test-tensor: $(BUILD)/tensor_test ## Roda o teste da tensor (ASan/UBSan)
|
||||
./$(BUILD)/tensor_test
|
||||
|
||||
# -- Teste da library ai (gradiente de cada camada, Adam, BPE, genetico) ---
|
||||
AI_DIR := $(LIBDIR)/tinyblocks-ai
|
||||
AI_SRCS := $(AI_DIR)/src/ai_ops.c $(AI_DIR)/src/ai_conv.c $(AI_DIR)/src/ai_bpe.c
|
||||
$(BUILD)/ai_test: tests/ai_test.c $(AI_SRCS) $(AI_DIR)/src/ai_blocks.c $(AI_DIR)/src/ai_internal.h $(TENSOR_SRCS) static
|
||||
@mkdir -p $(BUILD)
|
||||
$(CC) $(CFLAGS_DBG) -I$(TENSOR_DIR)/include -I$(AI_DIR)/include -I$(AI_DIR)/src \
|
||||
$(TENSOR_SRCS) $(AI_SRCS) tests/ai_test.c -o $@ \
|
||||
-Wl,--start-group $(LIB_A) -Wl,--end-group -lm -lpthread
|
||||
|
||||
test-ai: $(BUILD)/ai_test ## Roda o teste da ai (ASan/UBSan)
|
||||
./$(BUILD)/ai_test
|
||||
|
||||
# -- Teste da library curves ---
|
||||
$(BUILD)/curves_test: tests/curves_test.c $(CV_DIR)/src/tb_curves.c static
|
||||
@mkdir -p $(BUILD)
|
||||
|
||||
Reference in new issue
Block a user