File NativeNetwork.java¶
↰ Parent directory (internal)
Definition (internal/NativeNetwork.java)¶
Classes¶
Full File Listing¶
-
namespace internal
- NativeNetwork : public com.qualcomm.qti.snpe.NeuralNetwork
Public Functions
- inline NativeNetwork (final Runtime runtime, final NativeBufferOutputStream modelBuffer, final Set< String > outputLayerNames, final boolean isDebugEnabled, final PerformanceProfile performanceProfile, final ProfilingLevel profileLevel, final ExecutionPriorityHint executionPriorityHint, boolean isCpuFallbackEnabled, boolean unsignedPD, boolean useUserSuppliedBuffers, boolean isInitCacheEnabled, boolean isDlCacheAvailable, boolean cpuFxpMode, final String storageDirectory, final String dspCachePath, final Map< String, int[]> inputDimensions, boolean unconsumedTensorsOutput)
- inline NativeNetwork (final Runtime runtime, final File modelFile, final Set< String > outputLayerNames, final boolean isDebugEnabled, final PerformanceProfile performanceProfile, final ProfilingLevel profileLevel, final ExecutionPriorityHint executionPriorityHint, boolean isCpuFallbackEnabled, boolean unsignedPD, boolean useUserSuppliedBuffers, boolean isInitCacheEnabled, boolean isDlCacheAvailable, boolean cpuFxpMode, final String storageDirectory, final String dspCachePath, final Map< String, int[]> inputDimensions, boolean unconsumedTensorsOutput)
- inline Map< String, FloatTensor > execute (final Map< String, FloatTensor > inputs)
Forward propagates the inputs through the neural network.
- Parameters
inputs – map of input name and tensor.
- Returns
a map of output name and tensor.
- inline boolean execute (Map< String, ? extends UserBufferTensor > inputs, Map< String, ? extends UserBufferTensor > outputs)
Forward propagates the inputs through the neural network.
- Parameters
inputs – map of input name and user buffer tensor.
- Returns
a map of output name and user buffer tensor.
- inline FloatTensor createFloatTensor (final int... shape)
Creates a FloatTensor instance with the specified shape.
- Parameters
shape – tensor shape.
- Returns
newly created instance.
- inline TF8UserBufferTensor createTF8UserBufferTensor (final int size, final int[] strides, int stepExactly0, float quantizedStepSize, ByteBuffer userBuffer)
Creates a TF8UserBufferTensor instance to wrap a user buffer.
- Parameters
size – total size of the buffer, in bytes
strides – total number of bytes between elements in each dimension
stepExactly0 – step value that represents exactly 0.0
quantizedStepSize – step size
userBuffer – byte buffer that contains user data. This buffer must have been allocated using direct allocation and possess native byte ordering.
- Returns
newly created instance
- inline TF16UserBufferTensor createTF16UserBufferTensor (final int size, final int[] strides, int stepExactly0, float quantizedStepSize, ByteBuffer userBuffer)
Creates a TF16UserBufferTensor instance to wrap a user buffer.
- Parameters
size – total size of the buffer, in bytes
strides – total number of bytes between elements in each dimension
stepExactly0 – step value that represents exactly 0.0
quantizedStepSize – step size
userBuffer – byte buffer that contains user data. This buffer must have been allocated using direct allocation and possess native byte ordering.
- Returns
newly created instance
-
inline Map<String, int[]> getInputTensorsShapes()¶
- Returns
a map of the input tensors(s) shape(s).
-
inline Map<String, int[]> getOutputTensorsShapes()¶
- Returns
a map of the input tensors(s) shape(s).
-
inline Set<String> getInputTensorsNames()¶
- Returns
a set with the input tensor(s) name(s).
-
inline Set<String> getOutputTensorsNames()¶
- Returns
a set with the output tensor(s) name(s).
-
inline TensorAttributes getTensorAttributes(String name)¶
- Parameters
name – name of the network tensor.
- Returns
object representing the attributes of the tensor.
-
inline String getModelVersion()¶
- Returns
the user defined model version.
-
inline Runtime getRuntime()¶
See also
com.qualcomm.qti.snpe.SNPE.NeuralNetworkBuilder::setRuntimeOrder(Runtime…)
- Returns
The neural network’s selected runtime.
-
inline Set<String> getOutputLayers()¶
-
- Returns
The selected output layer(s) name(s).
- inline synchronized void release ()
Releases the neural network’s resources. After this call you can no longer invoke any methods on this class instance.
Public Static Functions
- static inline synchronized boolean isRuntimeAvailable (final Runtime runtime, final RuntimeCheckOption runtimeCheckOption)
Protected Functions
-
inline void finalize()
Private Functions
-
inline void init(Runtime runtime, Set<String> outputLayerNames, boolean isDebugEnabled)¶
-
inline void doRelease()
- inline Map< String, FloatTensor > readOutputTensors (final JniOutputBundle outputBundle)
- inline Pair< String, FloatTensor > readTensor (final JniOutputBundle outputBundle)
- inline boolean readOutputUserBufferTensors (final JniOutputBundle outputBundle, final Map< String, ? extends UserBufferTensor > outputMap)
- inline void readUserBufferTensor (final JniOutputBundle outputBundle, final UserBufferTensor outputTensor)
- inline List< ByteBuffer > writeInputTensors (final JniInputBundle bundle, final Map< String, NativeFloatTensor > tensorMap)
- inline ByteBuffer writeTensor (final JniInputBundle bundle, final String name, final NativeFloatTensor tensor)
- inline void writeUserBufferTensors (final JniInputBundle bundle, final Map< String, ? extends UserBufferTensor > tensorMap)
- inline void assertInputTensor (final String name, final Tensor tensor)
- inline void assertInputTensor (final String name, final UserBufferTensor tensor)
- inline void assertOutputTensor (final String name, final UserBufferTensor tensor)
- native long nativeInitFromBuffer (long nativeModelStreamHandle, ByteBuffer bundle, int bundleSize)
- native long nativeInitFromFile (String absolutePath, ByteBuffer bundleBuffer, int capacity)
- native JniOutputBundle nativeGetModelMetadata (long nativeHandle)
- native JniOutputBundle nativeForward (long nativeHandle, ByteBuffer bundle, int bundleSize, ByteBuffer[] byteBuffers)
- native JniOutputBundle nativeUserBufferForward (long nativeHandle, ByteBuffer bundle, int bundleSize)
- native void nativeRelease (long nativeHandle)
Private Members
-
Set<String> mOutputLayerNames¶
-
TensorAttributesMap mInputTensors¶
-
TensorAttributesMap mOutputTensors¶
-
long mNativeHandle
-
String mModelVersion¶
-
Runtime mTargetRuntime¶
-
boolean mIsDebugEnabled¶
Private Static Functions
- static inline Set< String > readOutputLayerNames (final JniOutputBundle modelMetadata)
- static inline void assertSelectedOutputLayer (final Set< String > outputLayerNames, final Set< String > selectedLayerNames)
- static inline JniInputBundle createInitBundle (final Runtime runtime, final Set< String > layerNames, final boolean isDebugEnabled, final PerformanceProfile performanceProfile, final ProfilingLevel profileLevel, final ExecutionPriorityHint executionPriorityHint, boolean isCpuFallbackEnabled, boolean unsignedPD, boolean useUserSuppliedBuffers, boolean isInitCacheEnabled, boolean isDlCacheAvailable, boolean cpuFxpMode, final String storageDirectory, final String dspCachePath, final Map< String, int[]> inputDimensions, boolean unconsumedTensorsOutput)
- static native boolean nativeIsRuntimeAvailable (int ordinal, int runtimeCheckOption)
Private Static Attributes
- static final HashMap< Runtime, Boolean > mRuntimeAvailability = new HashMap<>()