Upload utils.py
Browse files
utils.py
CHANGED
|
@@ -210,7 +210,7 @@ def generate_memory_report(model, dataset, output_path: str = 'memory_report.jso
|
|
| 210 |
|
| 211 |
Args:
|
| 212 |
model: LMCODE model
|
| 213 |
-
dataset: Evaluation dataset
|
| 214 |
output_path: Path to save report
|
| 215 |
"""
|
| 216 |
report = {
|
|
@@ -220,8 +220,18 @@ def generate_memory_report(model, dataset, output_path: str = 'memory_report.jso
|
|
| 220 |
'efficiency_metrics': {}
|
| 221 |
}
|
| 222 |
|
| 223 |
-
# Analyze memory
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
memory_analysis = analyze_memory_capacity(model, test_sequences)
|
| 226 |
report['memory_analysis'] = memory_analysis
|
| 227 |
|
|
@@ -411,4 +421,4 @@ class MemoryMonitor:
|
|
| 411 |
if save_path:
|
| 412 |
plt.savefig(save_path, dpi=150, bbox_inches='tight')
|
| 413 |
|
| 414 |
-
return fig
|
|
|
|
| 210 |
|
| 211 |
Args:
|
| 212 |
model: LMCODE model
|
| 213 |
+
dataset: Evaluation dataset (list of dicts or list of tensors)
|
| 214 |
output_path: Path to save report
|
| 215 |
"""
|
| 216 |
report = {
|
|
|
|
| 220 |
'efficiency_metrics': {}
|
| 221 |
}
|
| 222 |
|
| 223 |
+
# Analyze memory - handle different dataset formats
|
| 224 |
+
if isinstance(dataset, list):
|
| 225 |
+
if len(dataset) > 0:
|
| 226 |
+
if isinstance(dataset[0], dict):
|
| 227 |
+
test_sequences = [d['input_ids'] for d in dataset[:10]]
|
| 228 |
+
else:
|
| 229 |
+
test_sequences = dataset[:10]
|
| 230 |
+
else:
|
| 231 |
+
test_sequences = []
|
| 232 |
+
else:
|
| 233 |
+
test_sequences = []
|
| 234 |
+
|
| 235 |
memory_analysis = analyze_memory_capacity(model, test_sequences)
|
| 236 |
report['memory_analysis'] = memory_analysis
|
| 237 |
|
|
|
|
| 421 |
if save_path:
|
| 422 |
plt.savefig(save_path, dpi=150, bbox_inches='tight')
|
| 423 |
|
| 424 |
+
return fig
|