# Java Interface ## Classes - class QnnDelegate : public Delegate, AutoCloseable - - long getNativeHandle() - Get handle to the delegate. - void close() - override method Calls to Close() frees C-runtime resources TFLite. - public static int[] getVersion() - Get QNN Delegate API version. - void performanceVote() - Manual vote for performance. See HtpPerfCtrlStrategy option. - void performanceRelease() - Manual release the vote for performance. See HtpPerfCtrlStrategy option. - boolean isAvailable() - Check if the QnnDelegate is available on the platform. For checking backend capability only, please refer to checkCapability(). - static boolean checkCapability([Capability](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate10CapabilityE) cap) - Check if the input capability is supported by the platform. Note that it can be called prior to the construction of QnnDelegate class. - enum class Capability - Lists the supported runtime types of the current platform. - enumerator HTP\_RUNTIME\_QUANTIZED = 0 - HTP hardware accelerator with quantized parameters. - enumerator HTP\_RUNTIME\_FP16 = 1 - HTP hardware accelerator with both quantized and half-precision floating-point parameters. - enumerator GPU\_RUNTIME = 2 - GPU hardware accelerator. - enumerator DSP\_RUNTIME = 3 - DSP hardware accelerator. - enumerator INVALID = 99 - Invalid option. - QnnDelegate([Options](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7OptionsE) options) - QnnDelegate constructor. This creates QnnDelegate object by passing in the options, throws Exception if QnnDelegate is not available. - Throw - UnsupportedOperationException - class Options - final static class > > > - Options() > > - > > > > > > - enum class BackendType > > - The QNN backend used to delegate the model’s nodes. > Each backend has its own set of supported ops and tensor types. > > > > - enumerator UNDEFINED\_BACKEND = 0 > > - > > > > > > - enumerator GPU\_BACKEND = 1 > > - Backend for Adreno^TM^ GPU hardware accelerator. > > > > > > - enumerator HTP\_BACKEND = 2 > > - Backend for Hexagon HTP hardware accelerator. > > > > > > - enumerator DSP\_BACKEND = 3 > > - Backend for Hexagon DSP hardware accelerator. > > > > > > - enum class LogLevel > > - Logging level of the delegate and QNN backend. > > > > - enumerator LOG\_OFF = 0 > > - Disable delegate and QNN backend logging messages. > > > > > > - enumerator LOG\_LEVEL\_ERROR = 1 > > - > > > > > > - enumerator LOG\_LEVEL\_WARN = 2 > > - > > > > > > - enumerator LOG\_LEVEL\_INFO = 3 > > - > > > > > > - enumerator LOG\_LEVEL\_VERBOSE = 4 > > - > > > > > > - enumerator LOG\_LEVEL\_DEBUG = 5 > > - > > > > > > - enum class ProfilingOptions > > - Options to profile the QNN Delegate execution. > > > > - enumerator PROFILING\_OFF = 0 > > - > > > > > > - enumerator BASIC\_PROFILING = 1 > > - > > > > > > - enumerator DETAILED\_PROFILING = 2 > > - > > > > > > - enumerator LINTING\_PROFILING = 3 > > - > > > > > > - enum class GpuPrecision > > - Defines the optimization levels of the graph tensors that are not > input nor output tensors. This enum controls the trade-off between > performance and accuracy. > > > > - enumerator GPU\_PRECISION\_USER\_PROVIDED = 0 > > - > > > > > > - enumerator GPU\_PRECISION\_FP32 = 1 > > - > > > > > > - enumerator GPU\_PRECISION\_FP16 = 2 > > - > > > > > > - enumerator GPU\_PRECISION\_HYBRID = 3 > > - > > > > > > - enum class GpuPerformanceMode > > - Defines performance modes available for Gpu backend. > > > > - enumerator GPU\_PERFORMANCE\_DEFAULT = 0 > > - > > > > > > - enumerator GPU\_PERFORMANCE\_HIGH = 1 > > - > > > > > > - enumerator GPU\_PERFORMANCE\_NORMAL = 2 > > - > > > > > > - enumerator GPU\_PERFORMANCE\_LOW = 3 > > - > > > > > > - enum class HtpPerformanceMode > > - Defines performance modes available for HTP backend. > > > > - enumerator PERFORMANCE\_DEFAULT = 0 > > - > > > > > > - enumerator PERFORMANCE\_SUSTAINED\_HIGH\_PERFORMANCE = 1 > > - > > > > > > - enumerator PERFORMANCE\_BURST = 2 > > - > > > > > > - enumerator PERFORMANCE\_HIGH\_PERFORMANCE = 3 > > - > > > > > > - enumerator PERFORMANCE\_POWER\_SAVER = 4 > > - > > > > > > - enumerator PERFORMANCE\_LOW\_POWER\_SAVER = 5 > > - > > > > > > - enumerator PERFORMANCE\_HIGH\_POWER\_SAVER = 6 > > - > > > > > > - enumerator PERFORMANCE\_LOW\_BALANCE = 7 > > - > > > > > > - enumerator PERFORMANCE\_BALANCE = 8 > > - > > > > > > - enum class HtpPrecision > > - Defines the precision modes supported by the HTP backend. HTP\_PRECISION\_FP16 supports quantized networks, and also floating-point networks on certain SoCs. Default: HTP\_PRECISION\_FP16 > > > > - enumerator HTP\_PRECISION\_QUANTIZED = 0 > > - > > > > > > - enumerator HTP\_PRECISION\_FP16 = 1 > > - > > > > > > - enum class HtpUseConvHmx > > - Using short conv hmx might have better performance. > However, convolution having short depth and/or weights that are not symmetric could exhibit inaccurate results.(Default is HTP\_CONV\_HMX\_ON = 1) > > > > - enumerator HTP\_CONV\_HMX\_OFF = 0 > > - > > > > > > - enumerator HTP\_CONV\_HMX\_ON = 1 > > - > > > > > > - enum class HtpUseFoldRelu > > - Using fold relu might have better performance. > However, this optimization is correct when the quantization ranges of convolutions are equal or subset of > Relu operations. > > > > - enumerator HTP\_FOLD\_RELU\_OFF = 0 > > - > > > > > > - enumerator HTP\_FOLD\_RELU\_ON = 1 > > - > > > > > > - enum class HtpOptimizationStrategy > > - Defines the optimization strategy used by the HTP backend. > > > > - enumerator HTP\_OPTIMIZE\_FOR\_INFERENCE = 0 > > - > > > > > > - enumerator HTP\_OPTIMIZE\_FOR\_PREPARE = 1 > > - > > > > > > - enumerator HTP\_OPTIMIZE\_FOR\_INFERENCE\_O3 = 2 > > - > > > > > > - enum class DspPerformanceMode > > - Defines performance modes available for DSP backend. > > > > - enumerator PERFORMANCE\_DEFAULT = 0 > > - > > > > > > - enumerator PERFORMANCE\_SUSTAINED\_HIGH\_PERFORMANCE = 1 > > - > > > > > > - enumerator PERFORMANCE\_BURST = 2 > > - > > > > > > - enumerator PERFORMANCE\_HIGH\_PERFORMANCE = 3 > > - > > > > > > - enumerator PERFORMANCE\_POWER\_SAVER = 4 > > - > > > > > > - enumerator PERFORMANCE\_LOW\_POWER\_SAVER = 5 > > - > > > > > > - enumerator PERFORMANCE\_HIGH\_POWER\_SAVER = 6 > > - > > > > > > - enumerator PERFORMANCE\_LOW\_BALANCE = 7 > > - > > > > > > - enumerator PERFORMANCE\_BALANCE = 8 > > - > > > > > > - enum class HtpPerfCtrlStrategy > > - Defines HTP performance control strategy. > > > **Manual**: The performance mode is voted as the backend is initialized, and released > at the moment of the backend is destroyed. > > > Users can control the vote/release of the performance mode by instance methods > performanceVote() and performanceRelease(). > > > Note that this is the default strategy. > > > For example, users can vote before inferences, and release after all inference done. > > > QnnDelegate qnnDelegate = new QnnDelegate(htpOptions); > // initialize other stuff... > qnnDelegate.performanceVote(); > // invoke inferences... > qnnDelegate.performanceRelease(); > Copy to clipboard > > > **AUTO**: QNN Delegate vote before an inference, and release after an idle interval, > i.e.no more inference. > > > > - enumerator HTP\_PERF\_CTRL\_MANUAL = 0 > > - > > > > > > - enumerator HTP\_PERF\_CTRL\_AUTO = 1 > > - > > > > > > - enum class DspPerfCtrlStrategy > > - Defines DSP performance control strategy. Similar to HTP cases. > > > > - enumerator DSP\_PERF\_CTRL\_MANUAL = 0 > > - > > > > > > - enumerator DSP\_PERF\_CTRL\_AUTO = 1 > > - > > > > > > - enum class HtpPdSession > > - Defines pd sessions available for HTP backend. > > > > - enumerator HTP\_PD\_SESSION\_UNSIGNED = 0 > > - > > > > > > - enumerator HTP\_PD\_SESSION\_SIGNED = 1 > > - > > > > > > - enum class DspPdSession > > - Defines pd sessions available for DSP backend. > > > > - enumerator DSP\_PD\_SESSION\_UNSIGNED = 0 > > - > > > > > > - enumerator DSP\_PD\_SESSION\_SIGNED = 1 > > - > > > > > > - enumerator DSP\_PD\_SESSION\_ADAPTIVE = 2 > > - > > > > > > - class OpPackageInfo > > - static final > > > Class containing the information needed to register and use an op > package with QNN. > > > > - OpPackageInfo(String name, String path, String provider, String Target, HashMap<String, String> opsMap) > > - OpPackageInfo constructor. > > > > - Parameters > > - - **String name** – The name of the op package > - **String path** – The path on disk to the op package library > - **String provider** – The name of a function in the op package library which satisfies the QnnOpPackage\_InterfaceProvider\_t interface > - **String target** – The target which this op package library was compiled for > - **HashMap<String, String> opsMap** – Map of TFLite custom operator name to op type defined within an op package > > > > > > - int getBackendType() > > - Getter function to retrieve the integer that represents the BackendType. > > > > > > - String getLibraryPath() > > - Getter function to retrieve library path. > > > > > > - String getSkelLibraryDir() > > - Getter function to retrieve Skel library. > > > > > > - int getGpuPrecision() > > - Getter function to retrieve the integer that represents the GpuPrecision. > > > > > > - int getGpuPerformanceMode() > > - Getter function to retrieve the integer that represents the GpuPerformanceMode. > > > > > > - int getHtpPerformanceMode() > > - Getter function to retrieve the integer that represents the HtpPerformanceMode. > > > > > > - int getHtpPrecision() > > - Getter function to retrieve the integer that represents the HtpPrecision. > > > > > > - int getHtpUseConvHmx() > > - Getter function to retrieve the integer that represents the HtpUseConvHmx. > > > > > > - int getHtpUseFoldRelu() > > - Getter function to retrieve the integer that represents the HtpUseFoldRelu. > > > > > > - int getHtpPdSession() > > - Getter function to retrieve the integer that represents the HtpPdSession. > > > > > > - int getHtpOptimizationStrategy() > > - Getter function to retrieve the integer that represents the HtpOptimizationStrategy. > > > > > > - int getHtpPerfCtrlStrategy() > > - Getter function to retrieve the integer that represents the HtpPerfCtrlStrategy. > > > > > > - int getDspPerformanceMode() > > - Getter function to retrieve the integer that represents the DspPerformanceMode. > > > > > > - int getDspPdSession() > > - Getter function to retrieve the integer that represents the DspPdSession. > > > > > > - int getDspPerfCtrlStrategy() > > - Getter function to retrieve the integer that represents the DspPerfCtrlStrategy. > > > > > > - int getLogLevel() > > - Getter function to retrieve the integer that represents the LogLevel. > > > > > > - int getProfiling() > > - Getter function to retrieve the integer that represents the ProfilingOptions. > > > > > > - String getCacheDir() > > - Getter function to retrieve the cache directory. > > > > > > - String getModelToken() > > - Getter function to retrieve the model token. > > > > > > - int getOpPackageInfosLength() > > - Getter function to retrieve the number of OpPackageInfo. > > > > > > - public OpPackageInfo[] getOpPackageInfos() > > - Getter function to retrieve the OpPackageInfo array. > > > > > > - public int[] getSkipNodeIds() > > - Getter function to retrieve the arrays containing node ids to skip. > > > > > > - public int[] getSkipOps() > > - Getter function to retrieve the arrays containing node ops to skip. > > > > > > - void setBackendType([BackendType](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options11BackendTypeE) input) > > - The backend QNN library to open and execute the graph with. This is a > required argument and will error out if kUndefinedBackend is > supplied. > > > > > > - void setLibraryPath(String input) > > - Optional parameter to override the QNN backend library. > > > > > > - void setSkelLibraryDir(String input) > > - Optional parameter to directory of the QNN Skel library. Only useful > for backends which have a Skel library. > > > > > > - void setGpuOptions([GpuPrecision](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options12GpuPrecisionE) input) > > - Optional backend specific options for the GPU backend. Only used > when selecting kGpuBackend, else will be ignored. > > > Warning > > > setGpuOptions() is deprecated, and will be removed in the future release. > Instead, please use below individual setters for each options. > > > > > > - void setGpuPerformanceMode([GpuPerformanceMode](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options18GpuPerformanceModeE) mode) > > - Set GPU Performance mode. > > > > > > - void setGpuPrecision([GpuPrecision](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options12GpuPrecisionE) precision) > > - Set GPU Precision. > > > > > > - void setHtpOptions([HtpPerformanceMode](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options18HtpPerformanceModeE) mode, [HtpPrecision](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options12HtpPrecisionE) precision, [HtpPdSession](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options12HtpPdSessionE) pdSession, [HtpOptimizationStrategy](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options23HtpOptimizationStrategyE) optimizationStrategy) > > - Optional backend specific options for the HTP backend. Only used when > selecting HTP\_BACKEND, else will be ignored. > > > Warning > > > setHtpOptions() is deprecated, and will be removed in the future release. > Instead, please use below individual setters for each options. > > > > > > - void setHtpPerformanceMode([HtpPerformanceMode](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options18HtpPerformanceModeE) mode) > > - Set HTP Performance mode. > > > > > > - boolean enableHtpQuickResponse() > > - This option enhances the HTP response time in performance\_mode == burst. However, it requires more power wattage than the usual burst mode. > HTP quick response mode will be enabled if at least one delegate is in burst mode and enableHtpQuickResponse() is called. > Return value can be used to check if HTP quick response is enabled successfully. > > > > > > - void setHtpPrecision([HtpPrecision](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options12HtpPrecisionE) precision) > > - Set HTP Precision. > > > > > > - void setHtpPdSession([HtpPdSession](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options12HtpPdSessionE) pdSession) > > - Set HTP PdSession. > > > > > > - void setHtpOptimizationStrategy([HtpOptimizationStrategy](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options23HtpOptimizationStrategyE) optimizationStrategy) > > - Set HTP Optimization Strategy. > > > > > > - void setHtpPerfCtrlStrategy([HtpPerfCtrlStrategy](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options19HtpPerfCtrlStrategyE) perfCtrl) > > - Set HTP Performance control strategy. > > > > > > - void setDspOptions([DspPerformanceMode](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options18DspPerformanceModeE) mode, [DspPdSession](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options12DspPdSessionE) pdSession) > > - Optional backend specific options for the DSP backend. Only used when > selecting DSP\_BACKEND, else will be ignored. > > > Warning > > > setDspOptions() is deprecated, and will be removed in the future release. > Instead, please use below individual setters for each options. > > > > > > - void setDspPerformanceMode([DspPerformanceMode](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options18DspPerformanceModeE) mode) > > - Set DSP Performance mode. > > > > > > - void setDspPdSession([DspPdSession](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options12DspPdSessionE) pdSession) > > - Set DSP PdSession. > > > > > > - void setDspPerfCtrlStrategy([DspPerfCtrlStrategy](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options19DspPerfCtrlStrategyE) perfCtrl) > > - Set DSP Performance control strategy. > > > > > > - void setLogLevel([LogLevel](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options8LogLevelE) input) > > - Logging level of the delegate and the backend. Default is off. > > > > > > - void setProfiling([ProfilingOptions](https://docs.qualcomm.com/doc/80-63442-50/topic/java_interface.html#_CPPv4N11QnnDelegate7Options16ProfilingOptionsE) input) > > - Option to enable profiling with the delegate. Default is off. > > > > > > - public void setOpPackageOptions(OpPackageInfo[] info) > > - Optional structure to specify custom op packages for the backend. > > > > > > - void setCacheDir(String input) > > - Specifies the directory of a compiled model. Signals intent to either: > > > > > > > > > - Save the model if the file doesn’t exist, or > > - Restore model from the file. > > > > Model Cache specific options. Only used when setting > `setModelToken`, else will be ignored. > > > > > > - void setModelToken(String input) > > - The unique nul-terminated token string that acts as a ‘namespace’ for > all serialization entries. > Should be unique to a particular model (graph & constants). > > > Model Cache specific options. Only used when setting > `setCacheDir`, else will be ignored. > > > > > > - public void setSkipNodeIds(int[] ids) > > - Set nodes not to be delegated by their node ids. > Node ids can be obtained from the nodes’ location information in .tflite files. > > > > > > - public void setSkipOps(int[] ops) > > - Set ops not to be delegated by their built-in id(s). > Please refer to tensorflow/lite/builtin\_ops.h for the op built-in ids. > Note that we skip *ALL* same type of ops specified. > For example, if you skip SquaredDifference in your model, > all of the SquaredDifference ops in the model will not be delegated. > > > > > > - public byte[] getProfilingResult() > > - Get the profiling result, after profiling level is set. Note that the ownership of > the returned byte array is transferred to user. Empty result will be returned from > the second time on if this function is called consecutively. Last Published: Oct 10, 2025 [Previous Topic Qualcomm® AI Engine Direct Delegate Java Interface](https://docs.qualcomm.com/bundle/publicresource/80-63442-50/topics/TfLite-Delegate_api.md) [Next Topic External Delegate Interface](https://docs.qualcomm.com/bundle/publicresource/80-63442-50/topics/TfLite-Delegate_api.md)