Skip to content

Commit 615b121

Browse files
committed
feat: Add grammar validation, dynamic fast compiler, and backend codegen
1 parent 2952d7c commit 615b121

23 files changed

Lines changed: 6128 additions & 418 deletions

.gitignore

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ frontend/.venv2/
3434
*.ef
3535
test_*.ef
3636
sample.ef
37+
tests/
3738

3839
# Generated files and artifacts
3940
generated/
@@ -72,3 +73,83 @@ simple_model*
7273
frontend/.next/
7374
frontend/out/
7475
frontend/build/
76+
77+
# Documentation and summary files (auto-generated)
78+
*_SUMMARY.md
79+
GRAMMAR_VALIDATION_SUMMARY.md
80+
FAST_COMPILER_SUMMARY.md
81+
INTEGRATION_GUIDE.md
82+
83+
# Generated code and artifacts
84+
backend_*/
85+
generated_code/
86+
*.c
87+
*.h
88+
*.cpp
89+
*.hpp
90+
main.c
91+
edge_model.*
92+
Makefile
93+
94+
# Performance and profiling
95+
*.prof
96+
*.perf
97+
performance_*.json
98+
benchmark_*.json
99+
100+
# Device profiles and configurations
101+
device_profiles.json
102+
custom_devices.json
103+
104+
# Test artifacts and temporary files
105+
test_output/
106+
*.test
107+
test_*.py.bak
108+
examples/output/
109+
110+
# Jupyter notebook checkpoints
111+
.ipynb_checkpoints/
112+
113+
# OS and system files
114+
.DS_Store
115+
Thumbs.db
116+
*.pid
117+
*.lock
118+
119+
# Backup and temporary files
120+
*.bak
121+
*.backup
122+
*.orig
123+
*~
124+
.#*
125+
#*#
126+
127+
# Compiled Python extensions
128+
*.so
129+
*.pyd
130+
*.dll
131+
132+
# Distribution / packaging
133+
.Python
134+
build/
135+
develop-eggs/
136+
dist/
137+
downloads/
138+
eggs/
139+
.eggs/
140+
lib/
141+
lib64/
142+
parts/
143+
sdist/
144+
var/
145+
wheels/
146+
*.egg-info/
147+
.installed.cfg
148+
*.egg
149+
150+
# Environment variables
151+
.env
152+
.env.local
153+
.env.development.local
154+
.env.test.local
155+
.env.production.local

README.md

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
EdgeFlow Compiler (CLI)
2-
=======================
1+
EdgeFlow Compiler with Semantic Analysis
2+
==========================================
33

44
EdgeFlow is a domain-specific language (DSL) and compiler for optimizing TensorFlow Lite 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.
55

6-
Project Status: Day 1 CLI skeleton with tests and CI. Parser and optimizer are stubbed for integration by other teams.
6+
**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.
7+
8+
Project Status: CLI with semantic analysis, tests, and CI. Parser and optimizer integration points ready.
79

810
Overview
911
--------
@@ -112,20 +114,80 @@ Parse a `.ef` config and run the (placeholder) optimization pipeline:
112114
python edgeflowc.py path/to/config.ef
113115
```
114116

117+
## Semantic Analysis System
118+
119+
The 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.
120+
121+
### Key Features
122+
123+
- **Shape Compatibility Validation**: Ensures tensor shapes match between connected layers
124+
- **Parameter Range Checking**: Validates that all layer parameters are within acceptable ranges
125+
- **Device Compatibility**: Checks if the model is compatible with target device constraints
126+
- **Resource Analysis**: Validates memory usage and computational requirements
127+
- **Forbidden Configuration Detection**: Identifies problematic layer sequences and configurations
128+
- **Graph Structure Validation**: Detects cycles, connectivity issues, and missing components
129+
130+
### Quick Start with Semantic Analysis
131+
132+
```python
133+
from semantic_analyzer import SemanticAnalyzer, IRGraph, semantic_check
134+
from semantic_analyzer import get_edge_device_config
135+
136+
# Create or load your IR graph
137+
graph = create_your_model_graph()
138+
139+
# Run semantic analysis
140+
config = get_edge_device_config() # For edge devices
141+
errors = semantic_check(graph, config)
142+
143+
# Check results
144+
if errors.has_errors():
145+
errors.print_summary()
146+
else:
147+
print("✅ Model validation passed!")
148+
```
149+
150+
### Example Error Output
151+
152+
```
153+
📊 Semantic Analysis Summary:
154+
Errors: 2
155+
Warnings: 1
156+
Info: 0
157+
Fatal: 0
158+
159+
📝 Detailed Report:
160+
[ERROR] at model.dsl:line 7: Expected input shape (1, 256), got (1, 28, 28, 3).
161+
Suggestion: Ensure the previous layer outputs shape (1, 256)
162+
[ERROR] at model.dsl:line 10: Dense layer requires Flatten layer after Conv2D
163+
Suggestion: Add a Flatten layer between the convolutional and dense layers
164+
[WARNING] at model.dsl:line 5: Kernel size 13 exceeds recommended maximum (11) for target device
165+
```
166+
115167
## Project Structure
116168

117169
Architecture
118170
------------
119171

120172
```bash
121173
edgeFlow/
122-
├── edgeflowc.py # CLI entry point (this repo)
123-
├── parser/ # ANTLR-generated modules + wrapper (__init__.py)
124-
├── optimizer.py # Model optimization logic (Team B)
174+
├── edgeflowc.py # CLI entry point
175+
├── semantic_analyzer/ # 🆕 Semantic analysis system
176+
│ ├── __init__.py # Main exports
177+
│ ├── analyzer.py # Core semantic analyzer
178+
│ ├── error_types.py # Error definitions and collection
179+
│ ├── ir_nodes.py # IR graph and node structures
180+
│ ├── constraints.py # Parameter ranges and device constraints
181+
│ └── compiler_integration.py # Integration with compiler pipeline
182+
├── parser/ # ANTLR-generated modules + wrapper
183+
├── optimizer.py # Model optimization logic
125184
├── benchmarker.py # Performance measurement tools
126185
├── reporter.py # Report generation
186+
├── examples/ # 🆕 Semantic analysis examples
187+
│ └── semantic_analysis_examples.py
127188
├── tests/ # Unit tests
128-
│ └── test_cli.py
189+
│ ├── test_cli.py
190+
│ └── test_semantic_analyzer.py # 🆕 Semantic analyzer tests
129191
├── .github/workflows/ci.yml # CI: lint, type, test, coverage badge
130192
├── requirements.txt # Runtime dependencies
131193
├── requirements-dev.txt # Dev/test dependencies

0 commit comments

Comments
 (0)