@@ -134,9 +134,7 @@ def generate_recommendations(improvements: Dict[str, float]) -> str:
134134 speedup = improvements .get ("speedup" , 0.0 )
135135
136136 if size_red >= 70 :
137- recs .append (
138- "- Excellent size reduction achieved! Model is now highly suitable for edge deployment"
139- )
137+ recs .append ("- Excellent size reduction! Model highly suitable for edge" )
140138 elif size_red >= 50 :
141139 recs .append (
142140 "- Good size reduction achieved; consider further quantization or pruning"
@@ -209,7 +207,7 @@ def generate_report(
209207
210208✨ **Model successfully optimized using EdgeFlow DSL** ✨
211209
212- The EdgeFlow compiler has successfully optimized your model with the following impressive results:
210+ EdgeFlow successfully optimized your model with these results:
213211
214212- **Size Reduction**: { improvements ['size_reduction' ]:.1f} %
215213- **Speed Improvement**: { improvements ['speedup' ]:.1f} x faster
@@ -228,7 +226,7 @@ def generate_report(
228226| **Model Size** | { unoptimized_stats ['size_mb' ]:.2f} MB | \
229227 { optimized_stats ['size_mb' ]:.2f} MB | ↓ { improvements ['size_reduction' ]:.1f} % |
230228| **Inference Latency** | { unoptimized_stats ['latency_ms' ]:.2f} ms | \
231- { optimized_stats ['latency_ms' ]:.2f} ms | ↓ { improvements ['latency_reduction' ]:.1f} % |
229+ { optimized_stats ['latency_ms' ]:.2f} ms | ↓ { improvements ['latency_reduction' ]:.1f} % |
232230| **Throughput** | { 1000 / float (unoptimized_stats ['latency_ms' ]):.1f} fps | \
233231 { 1000 / float (optimized_stats ['latency_ms' ]):.1f} fps | \
234232 ↑ { improvements ['throughput_increase' ]:.1f} % |
@@ -244,7 +242,8 @@ def generate_report(
244242### Technique Applied
245243- **Quantization**: INT8 quantization applied
246244- **Target Device**: { config .get ('target_device' , 'Generic' ) if config else 'Generic' }
247- - **Optimization Goal**: { config .get ('optimize_for' , 'Balanced' ) if config else 'Balanced' }
245+ - **Optimization Goal**: \
246+ { config .get ('optimize_for' , 'Balanced' ) if config else 'Balanced' }
248247
249248### Benefits Achieved
2502491. **Reduced Storage Requirements**: Your model now requires \
@@ -283,7 +282,11 @@ def generate_json_report(
283282 config : Optional [Dict [str , Any ]] = None ,
284283 output_path : str = "report.json" ,
285284) -> str :
286- """Generate machine-readable JSON report for API consumption."""
285+ """Generate machine-readable JSON report for API consumption.
286+
287+ Returns:
288+ JSON string containing the report data
289+ """
287290 # Validate minimal fields
288291 required_fields = ["size_mb" , "latency_ms" ]
289292 for field in required_fields :
@@ -299,7 +302,12 @@ def generate_json_report(
299302 "timestamp" : datetime .now ().isoformat (),
300303 }
301304
302- output = Path (output_path )
303- output .write_text (json .dumps (payload , indent = 2 ))
304- logger .info ("JSON report successfully generated: %s" , output )
305- return str (output )
305+ json_content = json .dumps (payload , indent = 2 )
306+
307+ # Optionally write to file if output_path is provided
308+ if output_path :
309+ output = Path (output_path )
310+ output .write_text (json_content )
311+ logger .info ("JSON report successfully generated: %s" , output )
312+
313+ return json_content
0 commit comments