Snapdragon Neural Processing Engine SDK
Reference Guide
Java

Classes

class  FloatTensor
 
interface  NeuralNetwork
 
class  PlatformValidator
 
class  SNPE
 
class  SnpeError
 
class  Tensor
 
interface  TensorAttributes
 
class  TF8UserBufferTensor
 
class  UserBufferTensor
 

Functions

boolean isRuntimeAvailable (final Application application)
 
String coreVersion (final Application application)
 
String libVersion (final Application application)
 
boolean runtimeCheck (final Application application)
 

Detailed Description

This module defines the SNPE Java APIs


Class Documentation

◆ com::qualcomm::qti::snpe::FloatTensor

class com::qualcomm::qti::snpe::FloatTensor

Tensor class containing float elements.

Public Member Functions

abstract void write (float[] value, int offset, int length, int... position)
 
abstract void write (float value, int... position)
 
abstract int read (float[] value, int offset, int length, int... position)
 
abstract float read (int... position)
 
- Public Member Functions inherited from Tensor
int [] getShape ()
 
int getSize ()
 
abstract void release ()
 

Member Function Documentation

◆ read() [1/2]

abstract int read ( float []  value,
int  offset,
int  length,
int...  position 
)
abstract

Reads elements from the tensor into the specified array range starting at the specified tensor position.

Parameters
valuearray to read values into.
offsetstart offset to write into array.
lengthnumber of elements to write into array.
positionthe zero indexed position for each of the tensor dimensions to start reading from.
Returns
number of elements read.

◆ read() [2/2]

abstract float read ( int...  position)
abstract

Reads a single value from the tensor.

Parameters
positionthe zero indexed position for each of the tensor dimensions to start reading from.
Returns
the value at the specified position.

◆ write() [1/2]

abstract void write ( float []  value,
int  offset,
int  length,
int...  position 
)
abstract

Writes the range of the provided input array into the tensor at the specified position.

Parameters
valuefloat values to write.
offsetstart position to read from the input array.
lengthnumber of floats to read from the input array.
positionthe zero indexed position for each of the tensor dimensions to start writing to.

◆ write() [2/2]

abstract void write ( float  value,
int...  position 
)
abstract

Writes a single float value to the specified position.

Parameters
valuefloat value.
positionthe zero indexed position for each of the tensor dimensions to start writing to.

◆ com::qualcomm::qti::snpe::NeuralNetwork

interface com::qualcomm::qti::snpe::NeuralNetwork

NeuralNetwork helper functions and properties.

Public Member Functions

NeuralNetwork.Runtime getRuntime ()
 
Set< String > getOutputLayers ()
 
Map< String, FloatTensorexecute (Map< String, FloatTensor > inputs)
 
boolean execute (Map< String, ? extends UserBufferTensor > inputs, Map< String, ? extends UserBufferTensor > outputs)
 
Map< String, int[]> getInputTensorsShapes ()
 
Map< String, int[]> getOutputTensorsShapes ()
 
Set< String > getInputTensorsNames ()
 
Set< String > getOutputTensorsNames ()
 
TensorAttributes getTensorAttributes (String name)
 
String getModelVersion ()
 
void release ()
 
FloatTensor createFloatTensor (int... shape)
 
TF8UserBufferTensor createTF8UserBufferTensor (final int size, final int[] strides, int stepExactly0, float quantizedStepSize, ByteBuffer userBuffer)
 

Member Function Documentation

◆ createFloatTensor()

FloatTensor createFloatTensor ( int...  shape)

Creates a FloatTensor instance with the specified shape.

Parameters
shapetensor shape.
Returns
newly created instance.

◆ createTF8UserBufferTensor()

TF8UserBufferTensor createTF8UserBufferTensor ( final int  size,
final int []  strides,
int  stepExactly0,
float  quantizedStepSize,
ByteBuffer  userBuffer 
)

Creates a TF8UserBufferTensor instance to wrap a user buffer.

Parameters
sizetotal size of the buffer, in bytes
stridestotal number of bytes between elements in each dimension
stepExactly0step value that represents exactly 0.0
quantizedStepSizestep size
userBufferbyte buffer that contains user data. This buffer must have been allocated using direct allocation and possess native byte ordering.
Returns
newly created instance

◆ execute() [1/2]

Map<String, FloatTensor> execute ( Map< String, FloatTensor inputs)

Forward propagates the inputs through the neural network.

Parameters
inputsmap of input name and tensor.
Returns
a map of output name and tensor.

◆ execute() [2/2]

boolean execute ( Map< String, ? extends UserBufferTensor inputs,
Map< String, ? extends UserBufferTensor outputs 
)

Forward propagates the inputs through the neural network.

Parameters
inputsmap of input name and user buffer tensor.
Returns
a map of output name and user buffer tensor.

◆ getInputTensorsNames()

Set<String> getInputTensorsNames ( )
Returns
a set with the input tensor(s) name(s).

◆ getInputTensorsShapes()

Map<String, int[]> getInputTensorsShapes ( )
Returns
a map of the input tensors(s) shape(s).

◆ getModelVersion()

String getModelVersion ( )
Returns
the user defined model version.

◆ getOutputLayers()

Set<String> getOutputLayers ( )
Returns
The selected output layer(s) name(s).
See also
com.qualcomm.qti.snpe.SNPE.NeuralNetworkBuilder::setOutputLayers(String...)

◆ getOutputTensorsNames()

Set<String> getOutputTensorsNames ( )
Returns
a set with the output tensor(s) name(s).

◆ getOutputTensorsShapes()

Map<String, int[]> getOutputTensorsShapes ( )
Returns
a map of the input tensors(s) shape(s).

◆ getRuntime()

NeuralNetwork.Runtime getRuntime ( )
Returns
The neural network's selected runtime.
See also
com.qualcomm.qti.snpe.SNPE.NeuralNetworkBuilder::setRuntimeOrder(Runtime...)

◆ getTensorAttributes()

TensorAttributes getTensorAttributes ( String  name)
Parameters
namename of the network tensor.
Returns
object representing the attributes of the tensor.

◆ release()

void release ( )

Releases the neural network's resources. After this call you can no longer invoke any methods on this class instance.

◆ com::qualcomm::qti::platformvalidator::PlatformValidator

class com::qualcomm::qti::platformvalidator::PlatformValidator

PlatformValidator class - top level APIs of the SNPE Platform Validator.

Public Member Functions

boolean isRuntimeAvailable (final Application application)
 
String coreVersion (final Application application)
 
String libVersion (final Application application)
 
boolean runtimeCheck (final Application application)
 

◆ com::qualcomm::qti::snpe::SNPE

class com::qualcomm::qti::snpe::SNPE

SNPE class - top level APIs of the Snapdragon Neural Network Engine.

Static Public Member Functions

static String getRuntimeVersion (final Application application)
 
static boolean addOpPackage (final Application application, String regLibraryPath)
 

Static Public Attributes

static final String LOG_TAG = "snpe-android"
 

Member Function Documentation

◆ addOpPackage()

static boolean addOpPackage ( final Application  application,
String  regLibraryPath 
)
inlinestatic

Registers a UDO Package Registration Library

Parameters
applicationthe application registering the package
regLibraryPathPath to registration library
Returns
true for successful registration, false for unsuccessful registration

◆ getRuntimeVersion()

static String getRuntimeVersion ( final Application  application)
inlinestatic

Returns the version of the Snapdragon Neural Network Engine.

Member Data Documentation

◆ LOG_TAG

final String LOG_TAG = "snpe-android"
static

Log tag used internally by the SDK.

See also
android.util.Log

◆ com::qualcomm::qti::snpe::SnpeError

class com::qualcomm::qti::snpe::SnpeError

SnpeError throws exceptions with code and message

◆ com::qualcomm::qti::snpe::Tensor

class com::qualcomm::qti::snpe::Tensor

Tensor class.

Public Member Functions

int [] getShape ()
 
int getSize ()
 
abstract void release ()
 

Member Function Documentation

◆ getShape()

int [] getShape ( )
inline

Returns the shape of the tensor.

Returns
shape array.

◆ getSize()

int getSize ( )
inline

Returns the number of elements in the tensor.

Returns
the size of the tensor.

◆ release()

abstract void release ( )
abstract

Releases the resources used by this tensor. After this call no other methods can be called on this instance!

◆ com::qualcomm::qti::snpe::TensorAttributes

interface com::qualcomm::qti::snpe::TensorAttributes

class representing attributes of a tensor

Public Member Functions

int [] getDims ()
 
int [] getAlignments ()
 
int getElementSize ()
 
Encoding getEncoding ()
 

Member Function Documentation

◆ getAlignments()

int [] getAlignments ( )

Returns the alignment requirements of the tensor

Alignment per each dimension is expressed as an multiple, for example, if one particular dimension can accept multiples of 8, the alignment will be 8.

Returns
alignment in each dimension, in terms of multiple of number of elements

◆ getDims()

int [] getDims ( )

Returns the dimensions attribute

Returns
the dimensions attribute

◆ getElementSize()

int getElementSize ( )

Returns the tensor's element size, in bytes

Returns
element size, in bytes

◆ getEncoding()

Encoding getEncoding ( )

Returns the tensor's encoding type

Returns
the encoding type

◆ com::qualcomm::qti::snpe::TF8UserBufferTensor

class com::qualcomm::qti::snpe::TF8UserBufferTensor

UserBufferTensor class representing TF8 user buffer elements.

Public Member Functions

Encoding getEncoding ()
 
abstract int getStepExactly0 ()
 
abstract float getQuantizedStepSize ()
 
- Public Member Functions inherited from UserBufferTensor
int [] getStrides ()
 
int getSize ()
 
abstract Encoding getEncoding ()
 
abstract void release ()
 

Member Function Documentation

◆ getEncoding()

Encoding getEncoding ( )
inline

Returns the encoding type of the tensor.

Returns
the encoding type of the tensor

◆ getQuantizedStepSize()

abstract float getQuantizedStepSize ( )
abstract

Returns the step size.

Returns
the step size

◆ getStepExactly0()

abstract int getStepExactly0 ( )
abstract

Returns the step that represents exactly 0.0.

Returns
the step value

◆ com::qualcomm::qti::snpe::UserBufferTensor

class com::qualcomm::qti::snpe::UserBufferTensor

UserBufferTensor class representing user buffer tensors.

Public Member Functions

int [] getStrides ()
 
int getSize ()
 
abstract Encoding getEncoding ()
 
abstract void release ()
 

Member Function Documentation

◆ getEncoding()

abstract Encoding getEncoding ( )
abstract

Returns the encoding type of the tensor.

Returns
the encoding type of the tensor

◆ getSize()

int getSize ( )
inline

Returns the total size of the tensor.

Returns
the size of the tensor, in bytes.

◆ getStrides()

int [] getStrides ( )
inline

Returns the strides of the tensor.

Returns
shape array.

◆ release()

abstract void release ( )
abstract

Releases the resources used by this tensor. After this call no other methods can be called on this instance!

Function Documentation

◆ coreVersion()

String coreVersion ( final Application  application)
inline

Checks core version of the runtime

Parameters
Applicationcontext of the caller
Returns
Coreversion string of the runtime

◆ isRuntimeAvailable()

boolean isRuntimeAvailable ( final Application  application)
inline

Checks if the runtime associated with the object is available or not

Parameters
Applicationcontext of the caller
Returns
True if runtime is available otherwise false

◆ libVersion()

String libVersion ( final Application  application)
inline

Checks library version of the runtime

Parameters
Applicationcontext of the caller
Returns
library version string of the runtime

◆ runtimeCheck()

boolean runtimeCheck ( final Application  application)
inline

Checks SNPE runtime availability

Parameters
Applicationcontext of the caller
Returns
True if runtime is available otherwise false