Snapdragon Neural Processing Engine SDK
Reference Guide
SNPE.NeuralNetworkBuilder Class Reference

Public Member Functions

NeuralNetworkBuilder setRuntimeOrder (final NeuralNetwork.Runtime... order)
 
NeuralNetworkBuilder setInputDimensions (final Map< String, int[]> inputDimensions)
 
NeuralNetworkBuilder setOutputLayers (final String... outputLayers)
 
NeuralNetworkBuilder setModel (final InputStream stream, final int size) throws IOException
 
NeuralNetworkBuilder setModel (final File file) throws IOException
 
NeuralNetworkBuilder setPerformanceProfile (final PerformanceProfile profile)
 
NeuralNetworkBuilder setExecutionPriorityHint (final ExecutionPriorityHint priority)
 
NeuralNetworkBuilder setCpuFallbackEnabled (boolean enabled)
 
NeuralNetworkBuilder setUnsignedPD (boolean enabled)
 
NeuralNetworkBuilder setRuntimeCheckOption (final NeuralNetwork.RuntimeCheckOption runtimeCheckOption)
 
NeuralNetworkBuilder setUseUserSuppliedBuffers (boolean enabled)
 
NeuralNetworkBuilder setInitCacheEnabled (boolean isInitCacheEnabled, String cacheTag, Context context) throws SnpeError.IllegalArgsOrStateException
 
NeuralNetworkBuilder setStorageDirectory (String storageDirectory) throws SnpeError.SnpeIOException
 
NeuralNetwork build ()
 

Detailed Description

Class exposes a way to configure and create NeuralNetwork instances.

Member Function Documentation

◆ build()

NeuralNetwork build ( )
inline

Builds a NeuralNetwork instance based on this builder's configuration.

Returns
New network instance.

◆ setCpuFallbackEnabled()

NeuralNetworkBuilder setCpuFallbackEnabled ( boolean  enabled)
inline

Enables/Disables falling back to CPU if a layer is not supported in the selected runtime.

Parameters
enabled

◆ setExecutionPriorityHint()

NeuralNetworkBuilder setExecutionPriorityHint ( final ExecutionPriorityHint  priority)
inline

Passes an execution priority hint to the runtime

Parameters
prioritytarget execution priority.
Returns
the builder itself.

◆ setInitCacheEnabled()

NeuralNetworkBuilder setInitCacheEnabled ( boolean  isInitCacheEnabled,
String  cacheTag,
Context  context 
) throws SnpeError.IllegalArgsOrStateException
inline

Enable/disable the functionality of init caching. Init caching creates a set of init caches during network building/initialization process and adds them to DLC container. If such DLC container is saved by the user, in subsequent network building/initialization processes these init caches will be loaded from the DLC so as to reduce initialization time.

Parameters
isInitCacheEnabledenables/disables the functionality of init caching.
cacheTagThe init caches are saved into a location under this tag name.
contextThe android context from which the network is created.
Returns
The current instance of NeuralNetworkBuilder.

◆ setInputDimensions()

NeuralNetworkBuilder setInputDimensions ( final Map< String, int[]>  inputDimensions)
inline

Sets network's input dimensions to enable resizing of dimensions of the network.

Parameters
inputDimensionsmap of input names and their new dimensions.
Returns
the builder itself

◆ setModel() [1/2]

NeuralNetworkBuilder setModel ( final InputStream  stream,
final int  size 
) throws IOException
inline

Reads the model from the provided InputStream. The caller is responsible to close the stream after calling this method. After build() has been called, it is required that this method be invoked to re-set the input stream before every successive call to build() on the same instance.

Parameters
streaminput stream from where to read the model from.
sizenumber of bytes to read from the stream.
Returns
the builder itself.
Exceptions
IOExceptionif not able to read from the stream.

◆ setModel() [2/2]

NeuralNetworkBuilder setModel ( final File  file) throws IOException
inline

Sets the file from where to read the DLC model from.

Parameters
fileDLC model file.
Returns
the builder itself.
Exceptions
IOExceptionif not able to read from the stream.

◆ setOutputLayers()

NeuralNetworkBuilder setOutputLayers ( final String...  outputLayers)
inline

Sets the output layers to return when NeuralNetwork#execute(Map) is called.

Parameters
outputLayersname of the output layers to retrieve.
Returns
the builder itself.

◆ setPerformanceProfile()

NeuralNetworkBuilder setPerformanceProfile ( final PerformanceProfile  profile)
inline

Selects a performance profile to use during the network execution.

Parameters
profiletarget performance profile.
Returns
the builder itself.

◆ setRuntimeCheckOption()

NeuralNetworkBuilder setRuntimeCheckOption ( final NeuralNetwork.RuntimeCheckOption  runtimeCheckOption)
inline

Sets Unsigned PD constraint while building network

Parameters
enabled

◆ setRuntimeOrder()

NeuralNetworkBuilder setRuntimeOrder ( final NeuralNetwork.Runtime...  order)
inline

Sets the runtime selection order for the neural network.

Parameters
orderarray with the priority order for selecting an available runtime.
Returns
the builder itself.

◆ setStorageDirectory()

NeuralNetworkBuilder setStorageDirectory ( String  storageDirectory) throws SnpeError.SnpeIOException
inline

Set the SNPE storage location for all SNPE instances in this process. This may only be called once, and if so must be called before creating any SNPE instances

Parameters
Absolutepath to a directory which SNPE may use for caching and other storage purposes.
Returns
The current instance of NeuralNetworkBuilder.

◆ setUnsignedPD()

NeuralNetworkBuilder setUnsignedPD ( boolean  enabled)
inline

Sets Unsigned PD constraint while building network

Parameters
enabled

◆ setUseUserSuppliedBuffers()

NeuralNetworkBuilder setUseUserSuppliedBuffers ( boolean  enabled)
inline

Sets whether this network will perform inference with input from user-supplied buffers.

Parameters
enabled

The documentation for this class was generated from the following file: