xnn.common.benchmark.metrics.load_custom_metric#

xnn.common.benchmark.metrics.load_custom_metric(name, path)[source]#

Import a module:function callable and register it under name.

Lets a benchmark config pull in user-defined metrics without any code changes to xnn: give the dotted import path of a callable with the (pred, target) -> float signature (see Metric).

Parameters:
  • name (str) – Name to register the imported callable under.

  • path (str) – Import path of the form "package.module:function".

Returns:

The imported (and now registered) callable.

Return type:

Metric

Raises:

ValueError – If path does not contain the module:function separator.