Package ai.djl.engine
Class Engine
java.lang.Object
ai.djl.engine.Engine
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidPrints debug information about the environment for debugging environment issues.Returns the engine's defaultDevice.Returns a set of engine names that are loaded.abstract EngineReturns the alternativeengineif available.static StringReturns 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 StringReturns the DJL API version.static EngineReturns theEnginewith the given name.abstract StringReturns the name of the Engine.intReturns the number of GPUs available in the system.static EngineReturns the default Engine.abstract intgetRank()Return the rank of theEngine.getSeed()Returns the random seed in DJL Engine.abstract StringReturns the version of the deep learning engine.abstract booleanhasCapability(String capability) Returns whether the engine has the specified capability.static booleanReturns if the specified engine is available.abstract NDManagerCreates a new top-levelNDManager.abstract NDManagernewBaseManager(Device device) Returns a new instance ofGradientCollector.abstract ModelConstructs a new model.newParameterServer(Optimizer optimizer) Returns a new instance ofParameterServer.newSymbolBlock(NDManager manager) Construct an empty SymbolBlock for loading.static voidregisterEngine(EngineProvider provider) Registers aEngineProviderif not registered.voidsetRandomSeed(int seed) Seeds the random number generator in DJL Engine.toString()
-
Constructor Details
-
Engine
public Engine()
-
-
Method Details
-
getAlternativeEngine
Returns the alternativeengineif 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:
trueif the specified engine is available- See Also:
-
registerEngine
Registers aEngineProviderif not registered.- Parameters:
provider- theEngineProviderto be registered
-
getAllEngines
Returns a set of engine names that are loaded.- Returns:
- a set of engine names that are loaded
-
getEngine
Returns theEnginewith 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:
trueif 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
Deviceof 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
Deviceof 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
SymbolBlockfor 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
Devices 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.
-