TinyML은 마이크로컨트롤러(MCU) 수준의 초소형·저전력 디바이스에서 머신러닝 추론을 실행하는 기술이다. 수 킬로바이트 RAM과 수 밀리와트 전력에서 AI를 구현한다.
TinyML vs 엣지 AI vs 클라우드 AI
| 구분 | TinyML | 엣지 AI | 클라우드 AI |
|---|
| 플랫폼 | MCU (ARM Cortex-M) | GPU/NPU 보드 | 서버 클러스터 |
| RAM | KB 단위 | GB 단위 | TB 단위 |
| 전력 | μW ~ mW | W 단위 | kW 단위 |
| 모델 크기 | < 1MB | MB ~ GB | GB 이상 |
| 연결성 | 불필요 | 옵션 | 필수 |
TensorFlow Lite Micro
cpp
// Arduino/STM32에서 TFLite Micro
# include "tensorflow/lite/micro/all_ops_resolver.h"
# include "tensorflow/lite/micro/micro_interpreter.h"
# include "model_data.h" // 모델 배열 (hex)
// 텐서 아레나 (SRAM에서 할당)
constexpr int kTensorArenaSize = 10 * 1024; // 10KB
uint8_t tensor_arena[kTensorArenaSize];
// 인터프리터 설정
tflite::AllOpsResolver resolver;
tflite::MicroInterpreter interpreter(
tflite::GetModel(model_data), resolver,
tensor_arena, kTensorArenaSize);
interpreter.AllocateTensors();
// 추론 실행
TfLiteTensor* input = interpreter.input(0);
input->data.f[0] = sensor_reading;
interpreter.Invoke();
TfLiteTensor* output = interpreter.output(0);
float prediction = output->data.f[0];
모델 최적화 파이프라인
일반 모델 (수 MB)
↓ 지식 증류 (Knowledge Distillation)
경량 모델 (수백 KB)
↓ 가지치기 (Pruning, 80% sparsity)
희소 모델 (수십 KB)
↓ 양자화 (INT8 또는 INT4)
양자화 모델 (< 10KB)
↓ TFLite Micro 변환
MCU 배포 가능
주요 활용 사례
- •웨이크워드 감지: "Hey Siri", "OK Google" (수십 KB)
- •이상 감지: 산업 기계 진동 패턴 분석
- •제스처 인식: 스마트워치 동작 인식
- •예측적 유지보수: 센서 데이터 분류
관련 문서
- •[edge-ai|[엣지 AI]]
- •[[mqtt-advanced|MQTT 심화]]
- •[[lorawan|LoRaWAN]]
- •[[coap|CoAP]]