Skip to content

Optional get_example_inputs method of model#38

Merged
danielfleischer merged 4 commits into
IntelLabs:mainfrom
Xia-Weiwen:get_example_inputs
Jun 8, 2026
Merged

Optional get_example_inputs method of model#38
danielfleischer merged 4 commits into
IntelLabs:mainfrom
Xia-Weiwen:get_example_inputs

Conversation

@Xia-Weiwen

Copy link
Copy Markdown
Contributor

This PR allows users to write an optional get_example_inputs method of the wrapper model so that it generates desired input tensors. It is useful when the inputs are complex and cannot be simply generated by random numbers and a common dtype.
If this method is not provided, Xe-Forge still generates random inputs as before.
Users should remove this method if it is not needed.

@danielfleischer danielfleischer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the PR! It is a good idea to add. Two things we'd like to see:

  • Make sure it's callable
method = getattr(obj, "greet", None)
if callable(method):
      result = method()
  • Please add a sentence in the writing-the-model-class section in the README about custom initialization and mention this method.

@Xia-Weiwen

Copy link
Copy Markdown
Contributor Author

Thank you for the PR! It is a good idea to add. Two things we'd like to see:

  • Make sure it's callable
method = getattr(obj, "greet", None)
if callable(method):
      result = method()
  • Please add a sentence in the writing-the-model-class section in the README about custom initialization and mention this method.

Thanks. I have updated per your comments. Please review again.

@Xia-Weiwen

Copy link
Copy Markdown
Contributor Author

I also fixed an issue in spec_loader.get_flop. It substitutes dimension values into formula without checking if the name of one variable is the prefix of another, like B (batch) and BK (block K). Now it traverse the dict from the longest key string to shortest.

@danielfleischer danielfleischer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

@danielfleischer danielfleischer merged commit 7118236 into IntelLabs:main Jun 8, 2026
2 checks passed
@mzweilin

mzweilin commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

@danielfleischer

Copy link
Copy Markdown
Member

Shall we adopt the same formatting style used in the KernelBench dataset?

Are you saying this PR functionality is the same as what get_inputs does or you're talking about some other formatting issue?

@mzweilin

mzweilin commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Shall we adopt the same formatting style used in the KernelBench dataset?

Are you saying this PR functionality is the same as what get_inputs does or you're talking about some other formatting issue?

It looks like get_example_inputs() serves the same purpose as get_inputs() does in the KernelBench.

BTW, can we make the spec file optional when the KernelBench problem format is given? I think every spec we need is already in the .py file.

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.

3 participants