Skip to content

Commit

Permalink
Move OutputObserver from accuracy to observers
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnh committed Oct 2, 2023
1 parent 3f9ac4f commit 1aa79ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
13 changes: 1 addition & 12 deletions kernel_tuner/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import re

from kernel_tuner.observers import AccuracyObserver
from .observers import OutputObserver


class Tunable(UserDict):
Expand Down Expand Up @@ -141,17 +141,6 @@ def __init__(
super().__init__(param_key, arrays)


class OutputObserver(BenchmarkObserver):
"""Observer that can verify or measure something about the output produced by a kernel."""

@abstractmethod
def process_kernel_output(self, answer, output):
"""method will be called once before benchmarking of a single kernel configuration. The arguments
provided are the `answer` as passed `tune_kernel` and the `output` produced by the kernel
"""
pass


def error_metric_from_name(user_key, EPS=1e-8):
"""Find the error metric function for the given name.
Expand Down
2 changes: 1 addition & 1 deletion kernel_tuner/observers/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .observer import BenchmarkObserver, IterationObserver, ContinuousObserver
from .observer import BenchmarkObserver, IterationObserver, ContinuousObserver, OutputObserver
15 changes: 14 additions & 1 deletion kernel_tuner/observers/observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def register_configuration(self, params):
"""Called once before benchmarking of a single kernel configuration. The `params` argument is a `dict`
that stores the configuration parameters."""
pass

def before_start(self):
"""before start is called every iteration before the kernel starts"""
pass
Expand Down Expand Up @@ -45,3 +45,16 @@ class IterationObserver(BenchmarkObserver):

class ContinuousObserver(BenchmarkObserver):
pass


class OutputObserver(BenchmarkObserver):
"""Observer that can verify or measure something about the output produced by a kernel."""

@abstractmethod
def process_kernel_output(self, answer, output):
"""method will be called once before benchmarking of a single kernel configuration. The arguments
provided are the `answer` as passed `tune_kernel` and the `output` produced by the kernel
"""
pass


0 comments on commit 1aa79ae

Please sign in to comment.