Package ai.djl.serving.wlm
Class Adapter
java.lang.Object
ai.djl.serving.wlm.Adapter
- Direct Known Subclasses:
PyAdapter
An adapter is a modification producing a variation of a model that can be used during prediction.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName()Returns the adapter name.getSrc()Returns the adapter src.static AdapternewInstance(WorkerPoolConfig<?, ?> wpc, String name, String src, Map<String, String> options) Constructs a newAdapter.<I,O> void register(WorkerPool<I, O> wp) Registers this adapter in a worker pool.<I,O> WorkerJob<I, O> registerJob(WorkerPoolConfig<I, O> wpc, WorkerPoolConfig.ThreadConfig<I, O> threadConfig) Creates aWorkerJobto register this adapter in aWorkerThread.protected abstract voidregisterPredictor(ai.djl.inference.Predictor<?, ?> predictor) static <I,O> void unregister(WorkerPool<I, O> wp, String adapterName) Unregisters an adapter in a worker pool.<I,O> WorkerJob<I, O> unregisterJob(WorkerPoolConfig<I, O> wpc, WorkerPoolConfig.ThreadConfig<I, O> threadConfig) Creates aWorkerJobto unregister this adapter from aWorkerThread.protected abstract voidunregisterPredictor(ai.djl.inference.Predictor<?, ?> predictor)
-
Field Details
-
name
-
src
-
options
-
-
Constructor Details
-
Adapter
Constructs anAdapter.- Parameters:
name- the adapter namesrc- the adapter sourceoptions- additional adapter options
-
-
Method Details
-
newInstance
public static Adapter newInstance(WorkerPoolConfig<?, ?> wpc, String name, String src, Map<String, String> options) Constructs a newAdapter.After registration, you should call
register(WorkerPool). This doesn't affect the worker pool itself.- Parameters:
wpc- the worker pool config for the new adaptername- the adapter namesrc- the adapter sourceoptions- additional adapter options- Returns:
- the new adapter
-
unregister
Unregisters an adapter in a worker pool.This unregisters it in the wpc for new threads and all existing threads.
- Type Parameters:
I- the input typeO- the output type- Parameters:
wp- the worker pool to remove the adapter fromadapterName- the adapter name
-
getName
Returns the adapter name.- Returns:
- the adapter name
-
getSrc
Returns the adapter src.- Returns:
- the adapter src
-
register
Registers this adapter in a worker pool.This registers it in the wpc for new threads and all existing threads.
- Type Parameters:
I- the input typeO- the output type- Parameters:
wp- the worker pool to register this adapter in
-
registerJob
public <I,O> WorkerJob<I,O> registerJob(WorkerPoolConfig<I, O> wpc, WorkerPoolConfig.ThreadConfig<I, O> threadConfig) Creates aWorkerJobto register this adapter in aWorkerThread.- Type Parameters:
I- the input typeO- the output type- Parameters:
wpc- the worker pool of the threadthreadConfig- the thread config to register- Returns:
- the registration job
-
unregisterJob
public <I,O> WorkerJob<I,O> unregisterJob(WorkerPoolConfig<I, O> wpc, WorkerPoolConfig.ThreadConfig<I, O> threadConfig) Creates aWorkerJobto unregister this adapter from aWorkerThread.- Type Parameters:
I- the input typeO- the output type- Parameters:
wpc- the worker pool of the threadthreadConfig- the thread config to unregister- Returns:
- the unregistration job
-
registerPredictor
protected abstract void registerPredictor(ai.djl.inference.Predictor<?, ?> predictor) -
unregisterPredictor
protected abstract void unregisterPredictor(ai.djl.inference.Predictor<?, ?> predictor)
-