Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface class member to Benchmark class #20

Merged
merged 10 commits into from
Jan 24, 2024
Merged

Conversation

maxmynter
Copy link
Collaborator

@maxmynter maxmynter commented Jan 24, 2024

Add an Interface immutable dataclass to the Benchmark class that contains the signature information of a function. I.e.:

  • Keys
  • Values
  • Key - Value Pairs
  • Defaults

@maxmynter maxmynter marked this pull request as ready for review January 24, 2024 14:26
Copy link
Collaborator

@nicholasjng nicholasjng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great test case!

Let's move Interface to the nnbench.types top-level though - we don't (presumably) need to use it anywhere except the Benchmark dataclass for now.

src/nnbench/types.py Outdated Show resolved Hide resolved
src/nnbench/types.py Outdated Show resolved Hide resolved
src/nnbench/types.py Outdated Show resolved Hide resolved
tests/test_benchmark_cls.py Outdated Show resolved Hide resolved
src/nnbench/types.py Outdated Show resolved Hide resolved
@nicholasjng
Copy link
Collaborator

Sorry I forgot, you also need to add interface to the Benchmark class as a field like so (otherwise it will not show up in the typing):

class Benchmark:
    """
    ...
    interface: Interface
        The benchmark function's interface, set in the post-init hook.
    """
    ...
    interface: Interface = field(init=False, repr=False)

Copy link
Collaborator

@nicholasjng nicholasjng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! You can merge directly after attaching the interface to the Benchmark.

@maxmynter maxmynter merged commit caf9719 into main Jan 24, 2024
5 checks passed
@nicholasjng nicholasjng deleted the benchmark-cls branch January 24, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants