Motivation
Nott's public API promise is a clean, safe surface. Right now core.hpp exposes three structurally identical evaluate() overloads that differ only in descriptor type. Adding a fourth evaluation mode (e.g., regression, ranking) requires copy-pasting the same boilerplate again. The /// TODO: do it cleaner comment at line 2398 acknowledges this debt.
Current State
src/core.hpp:2385–2423 has three overloads:
auto evaluate(..., Evaluation::ClassificationDescriptor, ...) -> ClassificationReport;
auto evaluate(..., Evaluation::MultiClassificationDescriptor, ...) -> ClassificationReport; // TODO: do it cleaner
auto evaluate(..., Evaluation::SegmentationDescriptor, ...) -> ClassificationReport;
All three bodies are identical:
return Evaluation::Evaluate(*this, inputs, targets, descriptor, metrics, options);
~30 lines of pure duplication with no behavioural difference at this layer.
Proposed Change
Collapse to a single constrained template:
template<Evaluation::EvaluationDescriptor DescriptorT>
auto evaluate(torch::Tensor inputs,
torch::Tensor targets,
DescriptorT descriptor,
std::vector<Metric::Classification::Descriptor> metrics,
Evaluation::Options options = {}) -> Evaluation::ClassificationReport
{
return Evaluation::Evaluate(*this,
std::move(inputs), std::move(targets),
descriptor, std::move(metrics), options);
}
Where Evaluation::EvaluationDescriptor is a concept:
template<typename T>
concept EvaluationDescriptor =
std::same_as<T, Evaluation::ClassificationDescriptor> ||
std::same_as<T, Evaluation::MultiClassificationDescriptor> ||
std::same_as<T, Evaluation::SegmentationDescriptor>;
Acceptance Criteria
Motivation
Nott's public API promise is a clean, safe surface. Right now
core.hppexposes three structurally identicalevaluate()overloads that differ only in descriptor type. Adding a fourth evaluation mode (e.g., regression, ranking) requires copy-pasting the same boilerplate again. The/// TODO: do it cleanercomment at line 2398 acknowledges this debt.Current State
src/core.hpp:2385–2423has three overloads:All three bodies are identical:
~30 lines of pure duplication with no behavioural difference at this layer.
Proposed Change
Collapse to a single constrained template:
Where
Evaluation::EvaluationDescriptoris a concept:Acceptance Criteria
evaluate()template replaces the three overloadsEvaluationDescriptorconcept defined and constrains the template/// TODO: do it cleanercomment removed