Package ai.djl.engine
Class Engine
java.lang.Object
ai.djl.engine.Engine
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Prints debug information about the environment for debugging environment issues.Returns the engine's defaultDevice
.Returns a set of engine names that are loaded.abstract Engine
Returns the alternativeengine
if available.static String
Returns the default Engine name.Device[]
Returns an array of devices.Device[]
getDevices
(int maxGpus) Returns an array of devices given the maximum number of GPUs to use.static String
Returns the DJL API version.static Engine
Returns theEngine
with the given name.abstract String
Returns the name of the Engine.int
Returns the number of GPUs available in the system.static Engine
Returns the default Engine.abstract int
getRank()
Return the rank of theEngine
.getSeed()
Returns the random seed in DJL Engine.abstract String
Returns the version of the deep learning engine.abstract boolean
hasCapability
(String capability) Returns whether the engine has the specified capability.static boolean
Returns if the specified engine is available.abstract NDManager
Creates a new top-levelNDManager
.abstract NDManager
newBaseManager
(Device device) Returns a new instance ofGradientCollector
.abstract Model
Constructs a new model.newParameterServer
(Optimizer optimizer) Returns a new instance ofParameterServer
.newSymbolBlock
(NDManager manager) Construct an empty SymbolBlock for loading.static void
registerEngine
(EngineProvider provider) Registers aEngineProvider
if not registered.void
setRandomSeed
(int seed) Seeds the random number generator in DJL Engine.toString()
-
Constructor Details
-
Engine
public Engine()
-
-
Method Details
-
getAlternativeEngine
Returns the alternativeengine
if available.- Returns:
- the alternative
engine
-
getEngineName
Returns the name of the Engine.- Returns:
- the name of the engine
-
getRank
public abstract int getRank()Return the rank of theEngine
.- Returns:
- the rank of the engine
-
getDefaultEngineName
Returns the default Engine name.- Returns:
- the default Engine name
-
getInstance
Returns the default Engine.- Returns:
- the instance of
Engine
- See Also:
-
hasEngine
Returns if the specified engine is available.- Parameters:
engineName
- the name of Engine to check- Returns:
true
if the specified engine is available- See Also:
-
registerEngine
Registers aEngineProvider
if not registered.- Parameters:
provider
- theEngineProvider
to be registered
-
getAllEngines
Returns a set of engine names that are loaded.- Returns:
- a set of engine names that are loaded
-
getEngine
Returns theEngine
with the given name.- Parameters:
engineName
- the name of Engine to retrieve- Returns:
- the instance of
Engine
- See Also:
-
getVersion
Returns the version of the deep learning engine.- Returns:
- the version number of the deep learning engine
-
hasCapability
Returns whether the engine has the specified capability.- Parameters:
capability
- the capability to retrieve- Returns:
true
if the engine has the specified capability
-
defaultDevice
Returns the engine's defaultDevice
.- Returns:
- the engine's default
Device
-
getDevices
Returns an array of devices.If GPUs are available, it will return an array of
Device
of size \(min(numAvailable, maxGpus)\). Else, it will return an array with a single CPU device.- Returns:
- an array of devices
-
getDevices
Returns an array of devices given the maximum number of GPUs to use.If GPUs are available, it will return an array of
Device
of size \(min(numAvailable, maxGpus)\). Else, it will return an array with a single CPU device.- Parameters:
maxGpus
- the max number of GPUs to use. Use 0 for no GPUs.- Returns:
- an array of devices
-
getGpuCount
public int getGpuCount()Returns the number of GPUs available in the system.- Returns:
- the number of GPUs available in the system
-
newSymbolBlock
Construct an empty SymbolBlock for loading.- Parameters:
manager
- the manager to manage parameters- Returns:
- Empty
SymbolBlock
for static graph
-
newModel
Constructs a new model.- Parameters:
name
- the model namedevice
- the device that the model will be loaded onto- Returns:
- a new Model instance using the network defined in block
-
newBaseManager
- Returns:
- a new top-level
NDManager
-
newBaseManager
- Parameters:
device
- the defaultDevice
- Returns:
- a new top-level
NDManager
-
newGradientCollector
Returns a new instance ofGradientCollector
.- Returns:
- a new instance of
GradientCollector
-
newParameterServer
Returns a new instance ofParameterServer
.- Parameters:
optimizer
- the optimizer to update- Returns:
- a new instance of
ParameterServer
-
setRandomSeed
public void setRandomSeed(int seed) Seeds the random number generator in DJL Engine.This will affect all
Device
s and all operators using Engine's random number generator.- Parameters:
seed
- the seed to be fixed in Engine
-
getSeed
Returns the random seed in DJL Engine.- Returns:
- seed the seed to be fixed in Engine
-
getDjlVersion
Returns the DJL API version.- Returns:
- seed the seed to be fixed in Engine
-
toString
-
debugEnvironment
public static void debugEnvironment()Prints debug information about the environment for debugging environment issues.
-