From 893074990367e9b438fb612e035b4e1c9fb0e9ad Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Sat, 20 Apr 2024 05:50:01 +0800 Subject: [PATCH] Fully functional inference command via UART. --- main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.go b/main.go index 71892f2..6755f61 100644 --- a/main.go +++ b/main.go @@ -88,6 +88,20 @@ func main() { uart.WriteOk() break + case N2CMU_NET_INFER: + input := make([]float32, network.InputCount) + for j := 0; j < int(network.InputCount); j++ { + input[j] = uart.ReadFloat32() + } + + output := network.Infer(input) + for i := 0; i < int(network.OutputCount); i++ { + uart.WriteFloat32(output[i]) + } + + uart.WriteOk() + break + case N2CMU_SET_INPUT_COUNT: network.InputCount = uart.ReadUint8() network.InitMatrix()