-
Notifications
You must be signed in to change notification settings - Fork 93
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
Conversation
""" | ||
@callback apply(t(), input :: any(), defn_options :: keyword()) :: any() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
lib/bumblebee/featurizer.ex
Outdated
@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 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
🐈