Package ai.djl.serving.wlm
Class Adapter
- java.lang.Object
-
- ai.djl.serving.wlm.Adapter
-
- Direct Known Subclasses:
PyAdapter
public abstract class Adapter extends java.lang.Object
An adapter is a modification producing a variation of a model that can be used during prediction.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
getName()
Returns the adapter name.java.lang.String
getSrc()
Returns the adapter src.static Adapter
newInstance(WorkerPoolConfig<?,?> wpc, java.lang.String name, java.lang.String src)
Constructs a newAdapter
.<I,O>
voidregister(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 aWorkerJob
to register this adapter in aWorkerThread
.protected abstract void
registerPredictor(ai.djl.inference.Predictor<?,?> predictor)
static <I,O>
voidunregister(WorkerPool<I,O> wp, java.lang.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 aWorkerJob
to unregister this adapter from aWorkerThread
.protected abstract void
unregisterPredictor(ai.djl.inference.Predictor<?,?> predictor)
-
-
-
Constructor Detail
-
Adapter
protected Adapter(java.lang.String name, java.lang.String src)
Constructs anAdapter
.- Parameters:
name
- the adapter namesrc
- the adapter source
-
-
Method Detail
-
newInstance
public static Adapter newInstance(WorkerPoolConfig<?,?> wpc, java.lang.String name, java.lang.String src)
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 source- Returns:
- the new adapter
-
unregister
public static <I,O> void unregister(WorkerPool<I,O> wp, java.lang.String adapterName)
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
public java.lang.String getName()
Returns the adapter name.- Returns:
- the adapter name
-
getSrc
public java.lang.String getSrc()
Returns the adapter src.- Returns:
- the adapter src
-
register
public <I,O> void register(WorkerPool<I,O> wp)
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 aWorkerJob
to 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 aWorkerJob
to 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)
-
-