Delegate which uses Hexagon SDK to delegate the processing to QC DSP. Note that we only support quantized models, since the DSP is efficient with quantized versions. So all op support is for quantized versions.
For more detailed usage and examples check the user guide.
Usage:
Add dependency on hexagon_delegate rule.
Code change example:
#include "tensorflow/lite/delegates/hexagon/hexagon_delegate.h"
// Assuming shared libraries are under "/data/local/tmp/"
// If files are packaged with native lib in android App then it
// will typically be equivalent to the path provided by
// "getContext().getApplicationInfo().nativeLibraryDir"
const char[] library_directory_path = "/data/local/tmp/";
TfLiteHexagonInitWithPath(library_directory_path); // Needed once at startup.
::tflite::TfLiteHexagonDelegateOptions params = {0};
// 'delegate_ptr' Need to outlive the interpreter. For example,
// If use case will need to resize input or anything that can trigger
// re-applying delegates then 'delegate_ptr' need to outlive the interpreter.
auto* delegate_ptr = ::tflite::TfLiteHexagonDelegateCreate(¶ms);
Interpreter::TfLiteDelegatePtr delegate(delegate_ptr,
[](TfLiteDelegate* delegate) {
::tflite::TfLiteHexagonDelegateDelete(delegate);
});
interpreter->ModifyGraphWithDelegate(delegate.get());
// IMPORTANT: AllocateTensors can be called only after ModifyGraphWithDelegate
TfLiteHexagonTearDown(); // Needed once at end of app/DSP usage.
Hexagon only supports ops that have inputs/outputs of <= 4 dimensions. The following operations have been implemented, with a few constraints that are verified in IsNodeSupportedByHexagon: