DSL for deploying AI models on edge devices.
EdgeFlow is a domain-specific language (DSL) and compiler for optimizing AI models for edge deployment. Users write simple .ef configuration files that describe optimization strategies (e.g., INT8 quantization), target devices, and goals like latency or size. The CLI parses these configs and runs the optimization pipeline.
NEW: Comprehensive Semantic Analysis System - The compiler now includes a sophisticated semantic analyzer that validates DSL models for shape compatibility, parameter ranges, resource constraints, and device compatibility before code generation.
Project Status: CLI with semantic analysis, tests, and CI. Parser and optimizer integration points ready.
- Language: EdgeFlow
.efconfiguration files - Targets: TFLite models on edge devices (e.g., Raspberry Pi)
- Pipeline: parse config → optimize model → (future) benchmark → report
model_path = "path/to/model.tflite"
output_path = "path/to/optimized_model.tflite"
quantize = int8
target_device = "raspberry_pi"
optimize_for = latency- Python 3.11 (CI target)
- Install runtime dependencies:
pip install -r requirements.txtFor development (linting, tests, coverage, hooks):
pip install -r requirements-dev.txtRecommended: Install as editable package
pip install -e .This allows you to use edgeflow command directly instead of python -m edgeflow.compiler.edgeflowc.
# Clone repository
git clone https://github.com/pointblank-club/edgeFlow.git
cd edgeFlow
# Create and activate virtual environment (recommended)
python3 -m venv .venv
source .venv/bin/activate # Linux/Mac
# On Windows: .venv\Scripts\activate
# Install package
pip install -e .edgeflow --version
edgeflow --helpNote: You may see a warning about missing 'dynamic_device_profiles'. This is expected and doesn't affect functionality.
# View the example configuration
cat examples/quick_start.ef
# Run the compiler (note: requires a .tflite model file)
edgeflow examples/quick_start.efCreate a file my_config.ef:
model = "path/to/your/model.tflite"
output = "optimized_model.tflite"
quantize = int8
target_device = "raspberry_pi"
optimize_for = latency
Then run:
edgeflow my_config.efIf you prefer not to install, set PYTHONPATH:
export PYTHONPATH=$(pwd)/src
python -m edgeflow.compiler.edgeflowc examples/quick_start.efBasic:
python -m edgeflow.compiler.edgeflowc path/to/config.efVerbose:
python -m edgeflow.compiler.edgeflowc path/to/config.ef --verboseHelp and Version:
python -m edgeflow.compiler.edgeflowc --help
python -m edgeflow.compiler.edgeflowc --version- Missing file:
python -m edgeflow.compiler.edgeflowc non_existent.ef
# Error: File 'non_existent.ef' not found- Wrong extension:
python -m edgeflow.compiler.edgeflowc invalid.txt
# Error: Invalid file extension. Expected '.ef' fileThe EdgeFlow compiler now includes a comprehensive semantic analysis system that validates DSL models before code generation. This ensures that generated models are correct, efficient, and compatible with target devices.
- Shape Compatibility Validation: Ensures tensor shapes match between connected layers
- Parameter Range Checking: Validates that all layer parameters are within acceptable ranges
- Device Compatibility: Checks if the model is compatible with target device constraints
- Resource Analysis: Validates memory usage and computational requirements
- Forbidden Configuration Detection: Identifies problematic layer sequences and configurations
- Graph Structure Validation: Detects cycles, connectivity issues, and missing components
from semantic_analyzer import SemanticAnalyzer, IRGraph, semantic_check
from semantic_analyzer import get_edge_device_config
# Create or load your IR graph
graph = create_your_model_graph()
# Run semantic analysis
config = get_edge_device_config() # For edge devices
errors = semantic_check(graph, config)
# Check results
if errors.has_errors():
errors.print_summary()
else:
print("✅ Model validation passed!")📊 Semantic Analysis Summary:
Errors: 2
Warnings: 1
Info: 0
Fatal: 0
📝 Detailed Report:
[ERROR] at model.dsl:line 7: Expected input shape (1, 256), got (1, 28, 28, 3).
Suggestion: Ensure the previous layer outputs shape (1, 256)
[ERROR] at model.dsl:line 10: Dense layer requires Flatten layer after Conv2D
Suggestion: Add a Flatten layer between the convolutional and dense layers
[WARNING] at model.dsl:line 5: Kernel size 13 exceeds recommended maximum (11) for target device
edgeFlow/
├── .github/workflows/ # CI/CD GitHub Actions
├── scripts/ # Build and verification scripts
├── src/edgeflow/ # Core source code
│ ├── analysis/ # Static and semantic analysis
│ ├── backend/ # Backend API
│ ├── benchmarking/ # Performance benchmarking
│ ├── compiler/ # Core compiler logic
│ ├── config/ # Configuration handling
│ ├── deployment/ # Deployment orchestration
│ ├── frontend/ # Frontend application
│ ├── ir/ # Intermediate Representation
│ ├── optimization/ # Optimization strategies
│ ├── parser/ # Parser logic
│ ├── pipeline/ # Pipeline orchestration
│ ├── reporting/ # Error reporting
│ ├── semantic_analyzer/ # Semantic analysis system
│ └── utils/ # Utility functions
├── tests/ # Unit and integration tests
├── Dockerfile # Docker container build
├── docker-compose.yml # Docker Compose configuration
├── requirements.txt # Runtime dependencies
├── requirements-dev.txt # Dev/test dependencies
└── README.md # This file- Parser (
parser.parse_ef(path)):edgeflowc.load_configtries to import and call this. If not found yet, it falls back to returning a minimal config with raw text. - Optimizer (
optimizer.optimize(config)):edgeflowc.optimize_modeltries to import and call this. If not found yet, it logs a message and continues.
Set up pre-commit hooks:
pre-commit installRun linters and type checks:
black .
isort --profile black .
flake8 .
mypy --ignore-missing-imports .Run tests with coverage:
pytest -q --cov=edgeflowc --cov-report=term-missingSee CONTRIBUTING.md for detailed guidelines on how to contribute to EdgeFlow.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.