Move featurizer batch part to serving computation - #243
Conversation
| If the featurizer does not define batch processing, the input is | ||
| returned as is. | ||
| """ | ||
| @callback apply(t(), input :: any(), defn_options :: keyword()) :: any() |
There was a problem hiding this comment.
I didn't deprecate, because it's very unlikely that someone implements a featurizer outside bumblebee.
There was a problem hiding this comment.
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.
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.
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 |
There was a problem hiding this comment.
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.
Ah right, will add ensure loaded!
There was a problem hiding this comment.
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 :)
馃悎