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

Move featurizer batch part to serving computation #243

Merged
merged 2 commits into from
Sep 13, 2023

Conversation

jonatanklosko
Copy link
Member

🐈

"""
@callback apply(t(), input :: any(), defn_options :: keyword()) :: any()
Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't deprecate, because it's very unlikely that someone implements a featurizer outside bumblebee.

Copy link
Contributor

Choose a reason for hiding this comment

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

Beautiful. If you want to keep backwards compatibility, you could keep it as a apply and introduce apply_batch.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would rather check for it as fallback, I just don't think it's worth in this case.

As for naming, I didn't go with apply_batch because then it seems as if apply_batch were batched version of apply. I'm not sure the current naming is perfect either, but the best I come up with :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Your call, just mentioning for completeness.

@callback apply(t(), input :: any(), defn_options :: keyword()) :: any()
@spec process_batch(t(), Nx.t() | Nx.Container.t()) :: Nx.t() | Nx.Container.t()
def process_batch(%module{} = featurizer, batch) do
if function_exported?(module, :process_batch, 2) do
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep in mind this will only work if module is already loaded (which will be the case if you have called a previous function in module).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right, will add ensure loaded!

Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW it should be loaded, because we would call configure/2 in the module when loading the featurizer. But I still like checking since it's one less thing to think about :)

Copy link
Contributor

@josevalim josevalim left a comment

Choose a reason for hiding this comment

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

Great!

@jonatanklosko jonatanklosko merged commit 2af8cf3 into main Sep 13, 2023
2 checks passed
@jonatanklosko jonatanklosko deleted the jk-split-featurizer branch September 13, 2023 12:30
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.

None yet

2 participants