- Create python directory with data/, model/ subdirectories - Implement LinearEval(61072->1) model - Add config, constants, feature_extractor - Add tests with 4 passing test cases
30 lines
610 B
Python
30 lines
610 B
Python
"""Evaluate model performance"""
|
|
|
|
import time
|
|
import torch
|
|
import numpy as np
|
|
from python.model.nnue_linear import LinearEval
|
|
|
|
|
|
def benchmark(model: LinearEval, samples: int = 1000) -> dict:
|
|
"""
|
|
Benchmark inference speed.
|
|
|
|
Returns:
|
|
dict with speed metrics
|
|
"""
|
|
model.eval()
|
|
x = torch.randn(samples, 61072)
|
|
|
|
start = time.time()
|
|
with torch.no_grad():
|
|
for _ in range(samples):
|
|
_ = model(x)
|
|
end = time.time()
|
|
|
|
return {
|
|
"samples": samples,
|
|
"time_seconds": end - start,
|
|
"ms_per_sample": (end - start) / samples * 1000,
|
|
}
|