diff --git a/phonelibs/snpe/aarch64 b/phonelibs/snpe/aarch64 index 0ec9322111..baf4e9cb6e 120000 --- a/phonelibs/snpe/aarch64 +++ b/phonelibs/snpe/aarch64 @@ -1 +1 @@ -aarch64-android-clang3.8 \ No newline at end of file +aarch64-android-clang6.0 \ No newline at end of file diff --git a/phonelibs/snpe/aarch64-android-clang3.8/libSNPE.so b/phonelibs/snpe/aarch64-android-clang3.8/libSNPE.so deleted file mode 100644 index b2e5b0071b..0000000000 Binary files a/phonelibs/snpe/aarch64-android-clang3.8/libSNPE.so and /dev/null differ diff --git a/phonelibs/snpe/aarch64-android-clang3.8/libsnpe_dsp_skel.so b/phonelibs/snpe/aarch64-android-clang3.8/libsnpe_dsp_skel.so deleted file mode 100644 index f63f2fae70..0000000000 Binary files a/phonelibs/snpe/aarch64-android-clang3.8/libsnpe_dsp_skel.so and /dev/null differ diff --git a/phonelibs/snpe/aarch64-android-clang3.8/libsymphony-cpu.so b/phonelibs/snpe/aarch64-android-clang3.8/libsymphony-cpu.so deleted file mode 100755 index ca05458ea1..0000000000 Binary files a/phonelibs/snpe/aarch64-android-clang3.8/libsymphony-cpu.so and /dev/null differ diff --git a/phonelibs/snpe/aarch64-android-clang3.8/libsymphonypower.so b/phonelibs/snpe/aarch64-android-clang3.8/libsymphonypower.so deleted file mode 100755 index 30f676d728..0000000000 Binary files a/phonelibs/snpe/aarch64-android-clang3.8/libsymphonypower.so and /dev/null differ diff --git a/phonelibs/snpe/aarch64-android-clang6.0/libSNPE.so b/phonelibs/snpe/aarch64-android-clang6.0/libSNPE.so new file mode 100644 index 0000000000..f8338a6e34 Binary files /dev/null and b/phonelibs/snpe/aarch64-android-clang6.0/libSNPE.so differ diff --git a/phonelibs/snpe/aarch64-android-clang6.0/libc++_shared.so b/phonelibs/snpe/aarch64-android-clang6.0/libc++_shared.so new file mode 100644 index 0000000000..5b9a9cff61 Binary files /dev/null and b/phonelibs/snpe/aarch64-android-clang6.0/libc++_shared.so differ diff --git a/phonelibs/snpe/aarch64-android-clang6.0/libsnpe_adsp.so b/phonelibs/snpe/aarch64-android-clang6.0/libsnpe_adsp.so new file mode 100644 index 0000000000..98b8c2d8a6 Binary files /dev/null and b/phonelibs/snpe/aarch64-android-clang6.0/libsnpe_adsp.so differ diff --git a/phonelibs/snpe/aarch64-android-clang6.0/libsnpe_dsp_skel.so b/phonelibs/snpe/aarch64-android-clang6.0/libsnpe_dsp_skel.so new file mode 100644 index 0000000000..eecf45749f Binary files /dev/null and b/phonelibs/snpe/aarch64-android-clang6.0/libsnpe_dsp_skel.so differ diff --git a/phonelibs/snpe/aarch64-android-clang6.0/libsymphony-cpu.so b/phonelibs/snpe/aarch64-android-clang6.0/libsymphony-cpu.so new file mode 100755 index 0000000000..8dd26fb266 Binary files /dev/null and b/phonelibs/snpe/aarch64-android-clang6.0/libsymphony-cpu.so differ diff --git a/phonelibs/snpe/include/DiagLog/Options.hpp b/phonelibs/snpe/include/DiagLog/Options.hpp index ba0c82119b..ea247e953f 100644 --- a/phonelibs/snpe/include/DiagLog/Options.hpp +++ b/phonelibs/snpe/include/DiagLog/Options.hpp @@ -32,7 +32,8 @@ public: DiagLogMask(""), LogFileDirectory("diaglogs"), LogFileName("DiagLog"), - LogFileRotateCount(20) + LogFileRotateCount(20), + LogFileReplace(true) { // Solves the empty string problem with multiple std libs DiagLogMask.reserve(1); @@ -65,6 +66,13 @@ public: /// any existing log file that may exist. /// Default value is 20 uint32_t LogFileRotateCount; + + /// @brief + /// + /// If the log file already exists, control whether it will be replaced + /// (existing contents truncated), or appended. + /// Default value is true + bool LogFileReplace; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ diff --git a/phonelibs/snpe/include/DlContainer/IDlContainer.hpp b/phonelibs/snpe/include/DlContainer/IDlContainer.hpp index c4b465fd04..f2022ca9f5 100644 --- a/phonelibs/snpe/include/DlContainer/IDlContainer.hpp +++ b/phonelibs/snpe/include/DlContainer/IDlContainer.hpp @@ -1,6 +1,6 @@ //============================================================================= // -// Copyright (c) 2015 Qualcomm Technologies, Inc. +// Copyright (c) 2015,2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -43,7 +43,15 @@ struct ZDL_EXPORT DlcRecord : name(std::move(other.name)) , data(std::move(other.data)) {} - + DlcRecord(const std::string& new_name) + : name(new_name) + , data() + { + if(name.empty()) + { + name.reserve(1); + } + } DlcRecord(const DlcRecord&) = delete; }; @@ -63,9 +71,9 @@ class ZDL_EXPORT IDlContainer public: /** * Initializes a container from a container archive file. - * + * * @param[in] filename Container archive file path. - * + * * @return A pointer to the initialized container */ ZDL_EXPORT static std::unique_ptr @@ -83,10 +91,10 @@ public: /** * Initializes a container from a byte buffer. - * - * @param[in] buffer Byte buffer holding the contents of an archive + * + * @param[in] buffer Byte buffer holding the contents of an archive * file. - * + * * @return A pointer to the initialized container */ ZDL_EXPORT static std::unique_ptr @@ -94,12 +102,12 @@ public: /** * Initializes a container from a byte buffer. - * - * @param[in] buffer Byte buffer holding the contents of an archive + * + * @param[in] buffer Byte buffer holding the contents of an archive * file. * * @param[in] size Size of the byte buffer. - * + * * @return A pointer to the initialized container */ ZDL_EXPORT static std::unique_ptr @@ -110,8 +118,8 @@ public: /** * Get the record catalog for a container. - * - * @param[out] catalog Buffer that will hold the record names on + * + * @param[out] catalog Buffer that will hold the record names on * return. */ virtual void getCatalog(std::set &catalog) const = 0; @@ -126,7 +134,7 @@ public: /** * Get a record from a container by name. - * + * * @param[in] name Name of the record to fetch. * @param[out] record The passed in record will be populated with the * record data on return. Note that the caller @@ -146,6 +154,34 @@ public: */ virtual void getRecord(const zdl::DlSystem::String &name, DlcRecord &record) const = 0; + /** + * Save the container to an archive on disk. This function will save the + * container if the filename is different from the file that it was opened + * from, or if at least one record was modified since the container was + * opened. + * + * It will truncate any existing file at the target path. + * + * @param filename Container archive file path. + * + * @return indication of success/failure + */ + virtual bool save(const std::string &filename) = 0; + + /** + * Save the container to an archive on disk. This function will save the + * container if the filename is different from the file that it was opened + * from, or if at least one record was modified since the container was + * opened. + * + * It will truncate any existing file at the target path. + * + * @param filename Container archive file path. + * + * @return indication of success/failure + */ + virtual bool save (const zdl::DlSystem::String &filename) = 0; + virtual ~IDlContainer() {} }; diff --git a/phonelibs/snpe/include/DlSystem/DlEnums.hpp b/phonelibs/snpe/include/DlSystem/DlEnums.hpp index fde252ca7f..5b8b6b35fc 100644 --- a/phonelibs/snpe/include/DlSystem/DlEnums.hpp +++ b/phonelibs/snpe/include/DlSystem/DlEnums.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2014-2018 Qualcomm Technologies, Inc. +// Copyright (c) 2014-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -43,6 +43,12 @@ enum class Runtime_t /// Math: float 16bit GPU_FLOAT16 = 3, + /// Run the processing on Snapdragon AIX+HVX. + /// Data: 8bit fixed point Tensorflow style format + /// Math: 8bit fixed point Tensorflow style format + AIP_FIXED8_TF = 5, + AIP_FIXED_TF = AIP_FIXED8_TF, + /// Default legacy enum to retain backward compatibility. /// CPU = CPU_FLOAT32 CPU = CPU_FLOAT32, @@ -53,7 +59,23 @@ enum class Runtime_t /// Default legacy enum to retain backward compatibility. /// DSP = DSP_FIXED8_TF - DSP = DSP_FIXED8_TF + DSP = DSP_FIXED8_TF, + + /// Special value indicating the property is unset. + UNSET = -1 +}; + +/** + * Enumeration of runtime available check options. + */ +enum class RuntimeCheckOption_t +{ + /// Perform standard runtime available check + DEFAULT = 0, + /// Perform standard runtime available check + NORMAL_CHECK = 0, + /// Perform basic runtime available check, may be runtime specific + BASIC_CHECK = 1, }; /** @@ -68,17 +90,47 @@ enum class PerformanceProfile_t BALANCED = 0, /// Run in high performance mode - HIGH_PERFORMANCE, + HIGH_PERFORMANCE = 1, /// Run in a power sensitive mode, at the expense of performance. - POWER_SAVER, + POWER_SAVER = 2, /// Use system settings. SNPE makes no calls to any performance related APIs. - SYSTEM_SETTINGS, + SYSTEM_SETTINGS = 3, /// Run in sustained high performance mode - SUSTAINED_HIGH_PERFORMANCE + SUSTAINED_HIGH_PERFORMANCE = 4, + /// Run in burst mode + BURST = 5, + + /// Run in lower clock than POWER_SAVER, at the expense of performance. + LOW_POWER_SAVER = 6, + + /// Run in higher clock and provides better performance than POWER_SAVER. + HIGH_POWER_SAVER = 7, + + /// Run in lower balanced mode + LOW_BALANCED = 8, +}; + +/** + * Enumeration of various profilngLevels that can be requested. + */ +enum class ProfilingLevel_t +{ + /// No profiling. + /// Collects no runtime stats in the DiagLog + OFF = 0, + + /// Basic profiling + /// Collects some runtime stats in the DiagLog + BASIC = 1, + + /// Detailed profiling + /// Collects more runtime stats in the DiagLog + /// Performance may be impacted + DETAILED = 2 }; /** @@ -90,10 +142,10 @@ enum class ExecutionPriorityHint_t NORMAL = 0, /// Higher than normal priority - HIGH, + HIGH = 1, /// Lower priority - LOW + LOW = 2 }; @@ -110,34 +162,34 @@ enum class ImageEncoding_t /// The RGB format consists of 3 bytes per pixel: one byte for /// Red, one for Green, and one for Blue. The byte ordering is /// endian independent and is always in RGB byte order. - RGB, + RGB = 1, /// The ARGB32 format consists of 4 bytes per pixel: one byte for /// Red, one for Green, one for Blue, and one for the alpha channel. /// The alpha channel is ignored. The byte ordering depends on the /// underlying CPU. For little endian CPUs, the byte order is BGRA. /// For big endian CPUs, the byte order is ARGB. - ARGB32, + ARGB32 = 2, /// The RGBA format consists of 4 bytes per pixel: one byte for /// Red, one for Green, one for Blue, and one for the alpha channel. /// The alpha channel is ignored. The byte ordering is endian independent /// and is always in RGBA byte order. - RGBA, + RGBA = 3, /// The GRAYSCALE format is for 8-bit grayscale. - GRAYSCALE, + GRAYSCALE = 4, /// NV21 is the Android version of YUV. The Chrominance is down /// sampled and has a subsampling ratio of 4:2:0. Note that this /// image format has 3 channels, but the U and V channels /// are subsampled. For every four Y pixels there is one U and one V pixel. @newpage - NV21, + NV21 = 5, /// The BGR format consists of 3 bytes per pixel: one byte for /// Red, one for Green and one for Blue. The byte ordering is /// endian independent and is always BGR byte order. - BGR + BGR = 6 }; }} // namespaces end diff --git a/phonelibs/snpe/include/DlSystem/DlError.hpp b/phonelibs/snpe/include/DlSystem/DlError.hpp index 383403b541..a8b0b4ea75 100644 --- a/phonelibs/snpe/include/DlSystem/DlError.hpp +++ b/phonelibs/snpe/include/DlSystem/DlError.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2016-18 Qualcomm Technologies, Inc. +// Copyright (c) 2016-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -34,6 +34,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_CONFIG_WRONG_INPUT_NAME = 105, SNPE_CONFIG_INCORRECT_INPUT_DIMENSIONS = 106, SNPE_CONFIG_DIMENSIONS_MODIFICATION_NOT_SUPPORTED = 107, + SNPE_CONFIG_BOTH_OUTPUT_LAYER_TENSOR_NAMES_SET = 108, SNPE_CONFIG_NNCONFIG_ONLY_TENSOR_SUPPORTED = 120, SNPE_CONFIG_NNCONFIG_ONLY_USER_BUFFER_SUPPORTED = 121, @@ -56,8 +57,11 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_DLSYSTEM_BUFFER_MANAGER_MISSING = 214, SNPE_DLSYSTEM_RUNTIME_BUFFER_SOURCE_UNSUPPORTED = 215, SNPE_DLSYSTEM_BUFFER_CAST_FAILED = 216, + SNPE_DLSYSTEM_WRONG_TRANSITION_TYPE = 217, + SNPE_DLSYSTEM_LAYER_ALREADY_REGISTERED = 218, SNPE_DLSYSTEM_BUFFERENCODING_UNKNOWN = 240, + SNPE_DLSYSTEM_BUFFER_INVALID_PARAM = 241, // DlContainer errors SNPE_DLCONTAINER_MODEL_PARSING_FAILED = 300, @@ -95,6 +99,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_CPU_LAYER_PARAM_COMBINATION_INVALID = 603, SNPE_CPU_BUFFER_NOT_FOUND = 604, SNPE_CPU_NETWORK_NOT_SUPPORTED = 605, + SNPE_CPU_UDO_OPERATION_FAILED = 606, // CPU fixed-point runtime errors SNPE_CPU_FXP_LAYER_NOT_SUPPORTED = 700, @@ -119,7 +124,8 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_GPU_LAYER_PROXY_ERROR = 814, SNPE_GPU_BUFFER_IN_USE = 815, SNPE_GPU_BUFFER_MODIFICATION_ERROR = 816, - + SNPE_GPU_DATA_ARRANGEMENT_INVALID = 817, + SNPE_GPU_UDO_OPERATION_FAILED = 818, // DSP runtime errors SNPE_DSP_LAYER_NOT_SUPPORTED = 900, SNPE_DSP_LAYER_PARAM_NOT_SUPPORTED = 901, @@ -132,6 +138,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_DSP_RUNTIME_COMMUNICATION_ERROR = 908, SNPE_DSP_RUNTIME_INVALID_PARAM_ERROR = 909, SNPE_DSP_RUNTIME_SYSTEM_ERROR = 910, + SNPE_DSP_RUNTIME_CRASHED_ERROR = 911, // Model validataion errors SNPE_MODEL_VALIDATION_LAYER_NOT_SUPPORTED = 1000, @@ -143,6 +150,8 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_MODEL_VALIDATION_INVALID_CONSTRAINT = 1006, SNPE_MODEL_VALIDATION_MISSING_BUFFER = 1007, SNPE_MODEL_VALIDATION_BUFFER_REUSE_NOT_SUPPORTED = 1008, + SNPE_MODEL_VALIDATION_LAYER_COULD_NOT_BE_ASSIGNED = 1009, + SNPE_MODEL_VALIDATION_UDO_LAYER_FAILED = 1010, // UDL errors SNPE_UDL_LAYER_EMPTY_UDL_NETWORK = 1100, @@ -151,6 +160,9 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_UDL_LAYER_SETUP_FAILED = 1103, SNPE_UDL_EXECUTE_FAILED = 1104, SNPE_UDL_BUNDLE_INVALID = 1105, + SNPE_UDO_REGISTRATION_FAILED = 1106, + SNPE_UDO_GET_PACKAGE_FAILED = 1107, + SNPE_UDO_GET_IMPLEMENTATION_FAILED = 1108, // Dependent library errors SNPE_STD_LIBRARY_ERROR = 1200, @@ -161,6 +173,26 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { // Storage Errors SNPE_STORAGE_INVALID_KERNEL_REPO = 1300, + // AIP runtime errors + SNPE_AIP_LAYER_NOT_SUPPORTED = 1400, + SNPE_AIP_LAYER_PARAM_NOT_SUPPORTED = 1401, + SNPE_AIP_LAYER_PARAM_INVALID = 1402, + SNPE_AIP_LAYER_PARAM_COMBINATION_INVALID = 1403, + SNPE_AIP_STUB_NOT_PRESENT = 1404, + SNPE_AIP_LAYER_NAME_TRUNCATED = 1405, + SNPE_AIP_LAYER_INPUT_BUFFER_NAME_TRUNCATED = 1406, + SNPE_AIP_LAYER_OUTPUT_BUFFER_NAME_TRUNCATED = 1407, + SNPE_AIP_RUNTIME_COMMUNICATION_ERROR = 1408, + SNPE_AIP_RUNTIME_INVALID_PARAM_ERROR = 1409, + SNPE_AIP_RUNTIME_SYSTEM_ERROR = 1410, + SNPE_AIP_RUNTIME_TENSOR_MISSING = 1411, + SNPE_AIP_RUNTIME_TENSOR_SHAPE_MISMATCH = 1412, + SNPE_AIP_RUNTIME_BAD_AIX_RECORD = 1413, + + // DlCaching errors + SNPE_DLCACHING_INVALID_METADATA = 1500, + SNPE_DLCACHING_INVALID_INITBLOB = 1501 + }; @@ -187,6 +219,11 @@ ZDL_EXPORT ErrorCode getLastErrorCode(); */ ZDL_EXPORT const char* getLastErrorString(); +/** + * Returns the info string of the last error encountered. + */ +ZDL_EXPORT const char* getLastInfoString(); + /** * Returns the uint32_t representation of the error code enum. * diff --git a/phonelibs/snpe/include/DlSystem/DlOptional.hpp b/phonelibs/snpe/include/DlSystem/DlOptional.hpp index 2c41b6b689..35416b4267 100644 --- a/phonelibs/snpe/include/DlSystem/DlOptional.hpp +++ b/phonelibs/snpe/include/DlSystem/DlOptional.hpp @@ -35,10 +35,10 @@ template class ZDL_EXPORT Optional final { public: enum class LIFECYCLE { - NONE, - REFERENCE_OWNED, - POINTER_OWNED, - POINTER_NOT_OWNED + NONE = 0, + REFERENCE_OWNED = 1, + POINTER_OWNED = 2, + POINTER_NOT_OWNED = 3 }; struct ReferenceCount { diff --git a/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp b/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp index e80f6c134c..f893e0a237 100644 --- a/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp +++ b/phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2017 Qualcomm Technologies, Inc. +// Copyright (c) 2017-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -21,7 +21,6 @@ namespace zdl { namespace zdl { namespace DlSystem { - /** * @brief IBufferAttributes returns a buffer's dimension and alignment * requirements, along with info on its encoding type @@ -65,6 +64,15 @@ public: */ virtual const TensorShape getAlignments() const noexcept = 0; + /** + * @brief Gets the buffer encoding returned from the network responsible + * for generating this buffer. Depending on the encoding type, this will + * be an instance of an encoding type specific derived class. + * + * @return Derived user buffer encoding object. + */ + virtual zdl::DlSystem::UserBufferEncoding* getEncoding() const noexcept = 0; + virtual ~IBufferAttributes() {} }; diff --git a/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp b/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp index 70f6b33cbb..aefa0eda94 100644 --- a/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp +++ b/phonelibs/snpe/include/DlSystem/IUserBuffer.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2017-2018 Qualcomm Technologies, Inc. +// Copyright (c) 2017-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -11,6 +11,7 @@ #include "TensorShape.hpp" #include "ZdlExportDefine.hpp" +#include namespace zdl { namespace DlSystem { @@ -44,7 +45,10 @@ public: UNSIGNED8BIT = 2, /// Each element is presented by an 8-bit quantized value. - TF8 = 10 + TF8 = 10, + + /// Each element is presented by an 16-bit quantized value. + TF16 = 11 }; /** @@ -147,6 +151,7 @@ public: * An encoding type where each element is represented by tf8, which is an * 8-bit quantizd value, which has an exact representation of 0.0 */ + class ZDL_EXPORT UserBufferEncodingTf8 : public UserBufferEncodingUnsigned8Bit { public: UserBufferEncodingTf8() = delete; @@ -155,60 +160,72 @@ public: m_StepExactly0(stepFor0), m_QuantizedStepSize(stepSize) {}; - /** + +/** * @brief Sets the step value that represents 0 * * @param[in] stepExactly0 The step value that represents 0 * */ + void setStepExactly0(const unsigned char stepExactly0) { m_StepExactly0 = stepExactly0; } - /** + +/** * @brief Sets the float value that each step represents * * @param[in] quantizedStepSize The float value of each step size * */ + void setQuantizedStepSize(const float quantizedStepSize) { m_QuantizedStepSize = quantizedStepSize; } - /** + +/** * @brief Retrieves the step that represents 0.0 * * @return Step value */ + unsigned char getStepExactly0() const { return m_StepExactly0; } - /** + +/** * Calculates the minimum floating point value that * can be represented with this encoding. * * @return Minimum representable floating point value */ + float getMin() const { return m_QuantizedStepSize * (0 - m_StepExactly0); } - /** + +/** * Calculates the maximum floating point value that * can be represented with this encoding. * * @return Maximum representable floating point value */ + float getMax() const { return m_QuantizedStepSize * (255 - m_StepExactly0); } - /** + +/** * @brief Retrieves the step size * * @return Step size */ + float getQuantizedStepSize() const { return m_QuantizedStepSize; } @@ -219,6 +236,84 @@ private: float m_QuantizedStepSize; }; + + +class ZDL_EXPORT UserBufferEncodingTfN : public UserBufferEncoding { +public: + UserBufferEncodingTfN() = delete; + UserBufferEncodingTfN(uint64_t stepFor0, float stepSize, uint8_t bWidth=8): + UserBufferEncoding(getTypeFromWidth(bWidth)), + bitWidth(bWidth), + m_StepExactly0(stepFor0), + m_QuantizedStepSize(stepSize){}; + size_t getElementSize() const noexcept override; + /** + * @brief Sets the step value that represents 0 + * + * @param[in] stepExactly0 The step value that represents 0 + * + */ + void setStepExactly0(uint64_t stepExactly0) { + m_StepExactly0 = stepExactly0; + } + + /** + * @brief Sets the float value that each step represents + * + * @param[in] quantizedStepSize The float value of each step size + * + */ + void setQuantizedStepSize(const float quantizedStepSize) { + m_QuantizedStepSize = quantizedStepSize; + } + + /** + * @brief Retrieves the step that represents 0.0 + * + * @return Step value + */ + uint64_t getStepExactly0() const { + return m_StepExactly0; + } + + /** + * Calculates the minimum floating point value that + * can be represented with this encoding. + * + * @return Minimum representable floating point value + */ + float getMin() const { + return m_QuantizedStepSize * (0 - (double)m_StepExactly0); + } + + /** + * Calculates the maximum floating point value that + * can be represented with this encoding. + * + * @return Maximum representable floating point value + */ + float getMax() const{ + return m_QuantizedStepSize * (pow(2,bitWidth)-1 - (double)m_StepExactly0); + }; + + /** + * @brief Retrieves the step size + * + * @return Step size + */ + float getQuantizedStepSize() const { + return m_QuantizedStepSize; + } + + ElementType_t getTypeFromWidth(uint8_t width); + + uint8_t bitWidth; +private: + uint64_t m_StepExactly0; + float m_QuantizedStepSize; +}; + + /** * @brief UserBuffer contains a pointer and info on how to walk it and interpret its content. */ @@ -243,6 +338,24 @@ public: */ virtual size_t getSize() const = 0; + /** + * @brief Retrieves the size of the inference data in the buffer, in bytes. + * + * The inference results from a dynamic-sized model may not be exactly the same size + * as the UserBuffer provided to SNPE. This function can be used to get the amount + * of output inference data, which may be less or greater than the size of the UserBuffer. + * + * If the inference results fit in the UserBuffer, getOutputSize() would be less than + * or equal to getSize(). But if the inference results were more than the capacity of + * the provided UserBuffer, the results would be truncated to fit the UserBuffer. But, + * getOutputSize() would be greater than getSize(), which indicates a bigger buffer + * needs to be provided to SNPE to hold all of the inference results. + * + * @return Size required for the buffer to hold all inference results, which can be less + * or more than the size of the buffer, in bytes. + */ + virtual size_t getOutputSize() const = 0; + /** * @brief Changes the underlying memory that backs the UserBuffer. * diff --git a/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp b/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp index df452dc469..3f15f177e3 100644 --- a/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp +++ b/phonelibs/snpe/include/DlSystem/PlatformConfig.hpp @@ -10,6 +10,7 @@ #define _DL_SYSTEM_PLATFORM_CONFIG_HPP_ #include "DlSystem/ZdlExportDefine.hpp" +#include namespace zdl{ namespace DlSystem @@ -92,7 +93,8 @@ public: PlatformConfigInfo(){}; }; - PlatformConfig() : m_PlatformType(PlatformType_t::UNKNOWN) {}; + PlatformConfig() : m_PlatformType(PlatformType_t::UNKNOWN), + m_PlatformOptions("") {}; /** * @brief Retrieves the platform type @@ -156,9 +158,42 @@ public: return false; } + /** + * @brief Sets the platform options + * + * @param[in] options Options as a string in the form of "keyword:options" + * + * @return True if options are pass validation; otherwise false. If false, the options are not updated. + */ + bool setPlatformOptions(std::string options) { + std::string oldOptions = m_PlatformOptions; + m_PlatformOptions = options; + if (isOptionsValid()) { + return true; + } else { + m_PlatformOptions = oldOptions; + return false; + } + } + + /** + * @brief Indicates whther the plaform configuration is valid. + * + * @return True if the platform configuration is valid; false otherwise. + */ + bool isOptionsValid() const; + + /** + * @brief Gets the platform options + * + * @return Options as a string + */ + std::string getPlatformOptions() const { return m_PlatformOptions; } + private: PlatformType_t m_PlatformType; PlatformConfigInfo m_PlatformConfigInfo; + std::string m_PlatformOptions; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ diff --git a/phonelibs/snpe/include/DlSystem/RuntimeList.hpp b/phonelibs/snpe/include/DlSystem/RuntimeList.hpp new file mode 100644 index 0000000000..1088a5b31f --- /dev/null +++ b/phonelibs/snpe/include/DlSystem/RuntimeList.hpp @@ -0,0 +1,154 @@ +//============================================================================= +// +// Copyright (c) 2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================= + +#include "ZdlExportDefine.hpp" +#include "DlSystem/DlEnums.hpp" +#include "DlSystem/StringList.hpp" +#include +#include + +#ifndef DL_SYSTEM_RUNTIME_LIST_HPP +#define DL_SYSTEM_RUNTIME_LIST_HPP + +namespace DlSystem +{ + // Forward declaration of Runtime List implementation. + class RuntimeListImpl; +} + +namespace zdl +{ +namespace DlSystem +{ + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief . + * + * A class representing list of runtimes + */ +class ZDL_EXPORT RuntimeList final +{ +public: + + /** + * @brief . + * + * Creates a new runtime list + * + */ + RuntimeList(); + + /** + * @brief . + * + * copy constructor. + * @param[in] other object to copy. + */ + RuntimeList(const RuntimeList& other); + + /** + * @brief . + * + * constructor with single Runtime_t object + * @param[in] Runtime_t object + */ + RuntimeList(const zdl::DlSystem::Runtime_t& runtime); + + /** + * @brief . + * + * assignment operator. + */ + RuntimeList& operator=(const RuntimeList& other); + + /** + * @brief . + * + * subscript operator. + */ + Runtime_t& operator[](size_t index); + + /** + * @brief Adds runtime to the end of the runtime list + * order of precedence is former followed by latter entry + * + * @param[in] runtime to add + * + * Ruturns false If the runtime already exists + */ + bool add(const zdl::DlSystem::Runtime_t& runtime); + + /** + * @brief Removes the runtime from the list + * + * @param[in] runtime to be removed + * + * @note If the runtime is not found, nothing is done. + */ + void remove(const zdl::DlSystem::Runtime_t runtime) noexcept; + + /** + * @brief Returns the number of runtimes in the list + */ + size_t size() const noexcept; + + /** + * @brief Returns true if the list is empty + */ + bool empty() const noexcept; + + /** + * @brief . + * + * Removes all runtime from the list + */ + void clear() noexcept; + + /** + * @brief . + * + * Returns a StringList of names from the runtime list in + * order of precedence + */ + zdl::DlSystem::StringList getRuntimeListNames() const; + + /** + * @brief . + * + * @param[in] runtime string + * Returns a Runtime enum corresponding to the in param string + * + */ + static zdl::DlSystem::Runtime_t stringToRuntime(const char* runtimeStr); + + /** + * @brief . + * + * @param[in] runtime + * Returns a string corresponding to the in param runtime enum + * + */ + static const char* runtimeToString(const zdl::DlSystem::Runtime_t runtime); + + ~RuntimeList(); + +private: + void deepCopy(const RuntimeList &other); + std::unique_ptr<::DlSystem::RuntimeListImpl> m_RuntimeListImpl; +}; + +} // DlSystem namespace +} // zdl namespace + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +#endif // DL_SYSTEM_RUNTIME_LIST_HPP + diff --git a/phonelibs/snpe/include/SNPE/ApplicationBufferMap.hpp b/phonelibs/snpe/include/SNPE/ApplicationBufferMap.hpp new file mode 100644 index 0000000000..380a3e0e6e --- /dev/null +++ b/phonelibs/snpe/include/SNPE/ApplicationBufferMap.hpp @@ -0,0 +1,101 @@ +//============================================================================== +// +// Copyright (c) 2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== + +#ifndef PSNPE_APPLICATIONBUFFERMAP_HPP +#define PSNPE_APPLICATIONBUFFERMAP_HPP +#include +#include +#include + +#include "DlSystem/UserBufferMap.hpp" +#include "DlSystem/ZdlExportDefine.hpp" + +namespace zdl +{ +namespace PSNPE +{ +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief . + * + * A class representing the UserBufferMap of Input and Output asynchronous mode. + */ + +class ZDL_EXPORT ApplicationBufferMap final +{ + + public: + /** + * @brief Adds a name and the corresponding buffer + * to the map + * + * @param[in] name The name of the UserBuffer + * @param[in] buffer The vector of the uint8_t data + * + * @note If a UserBuffer with the same name already exists, the new + * UserBuffer pointer would be updated. + */ + void add(const char* name, std::vector& buff) noexcept; + void add(const char* name, std::vector& buff) noexcept; + /** + * @brief Removes a mapping of one UserBuffer and its name by its name + * + * @param[in] name The name of UserBuffer to be removed + * + * @note If no UserBuffer with the specified name is found, nothing + * is done. + */ + void remove(const char* name) noexcept; + + /** + * @brief Returns the number of UserBuffers in the map + */ + size_t size() const noexcept; + + /** + * @brief . + * + * Removes all UserBuffers from the map + */ + void clear() noexcept; + + /** + * @brief Returns the UserBuffer given its name. + * + * @param[in] name The name of the UserBuffer to get. + * + * @return nullptr if no UserBuffer with the specified name is + * found; otherwise, a valid pointer to the UserBuffer. + */ + const std::vector& getUserBuffer(const char* name) const; + const std::vector& operator[](const char* name) const; + /** + * @brief . + * + * Returns the names of all UserAsyncBufferMap + * + * @return A list of UserBuffer names. + */ + zdl::DlSystem::StringList getUserBufferNames() const; + const std::unordered_map>& getUserBuffer() const; + explicit ApplicationBufferMap(); + ~ApplicationBufferMap(); + explicit ApplicationBufferMap( + const std::unordered_map> buffer); + + private: + std::unordered_map> m_UserMap; +}; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ +} // namespace PSNPE +} // namespace zdl + +#endif // PSNPE_APPLICATIONBUFFERMAP_HPP diff --git a/phonelibs/snpe/include/SNPE/PSNPE.hpp b/phonelibs/snpe/include/SNPE/PSNPE.hpp new file mode 100644 index 0000000000..732b7aa4d3 --- /dev/null +++ b/phonelibs/snpe/include/SNPE/PSNPE.hpp @@ -0,0 +1,174 @@ +// ============================================================================= +// +// Copyright (c) 2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +// ============================================================================= + +#ifndef PSNPE_HPP +#define PSNPE_HPP + +#include +#include +#include +#include "SNPE/SNPE.hpp" +#include "DlSystem/UserBufferMap.hpp" +#include "DlContainer/IDlContainer.hpp" +#include "DlSystem/DlEnums.hpp" +#include "DlSystem/ZdlExportDefine.hpp" + +#include "UserBufferList.hpp" +#include "RuntimeConfigList.hpp" +#include "ApplicationBufferMap.hpp" + +namespace zdl +{ +namespace PSNPE +{ + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + *@ brief build snpe instance in serial or parallel + * + */ +enum ZDL_EXPORT BuildMode { + SERIAL = 0, + PARALLEL = 1 +}; +/** + * @brief Input and output transmission mode + */ +enum ZDL_EXPORT InputOutputTransmissionMode +{ + sync = 0, + outputAsync = 1, + inputOutputAsync = 2 +}; + +/** + * @brief A structure representing parameters of callback function of Async Output mode + */ +struct ZDL_EXPORT OutputAsyncCallbackParam +{ + size_t dataIndex; + bool executeStatus; + OutputAsyncCallbackParam(size_t _index,bool _status) + : dataIndex(_index),executeStatus(_status){}; +}; +/** + * @brief A structure representing parameters of callback function of Async Input/Output mode + */ +struct ZDL_EXPORT InputOutputAsyncCallbackParam +{ + size_t dataIndex; + const ApplicationBufferMap& outputMap; + bool executeStatus; + InputOutputAsyncCallbackParam(size_t _index, const ApplicationBufferMap& output_map,bool _status) + : dataIndex(_index) + , outputMap(output_map) + ,executeStatus(_status){ + + }; +}; +using OutputAsyncCallbackFunc = std::function; +using InputOutputAsyncCallbackFunc = std::function; +/** + * @brief . + * + * A structure BulkSNPE configuration + */ +struct ZDL_EXPORT BuildConfig final +{ + BuildMode buildMode = BuildMode::SERIAL; + zdl::DlContainer::IDlContainer* container; + zdl::DlSystem::StringList outputBufferNames; + RuntimeConfigList runtimeConfigList; + OutputAsyncCallbackFunc outputCallback; + InputOutputAsyncCallbackFunc inputOutputCallback; + InputOutputTransmissionMode inputOutputTransmissionMode = InputOutputTransmissionMode::sync; +}; +/** + * @brief . + * + * The class for executing SNPE instances in parallel. + */ +class ZDL_EXPORT PSNPE final +{ + public: + ~PSNPE(); + + explicit PSNPE() noexcept :m_TransmissionMode(InputOutputTransmissionMode::sync){}; + + /** + * @brief Build snpe instances. + * + */ + bool build(BuildConfig& buildConfig) noexcept; + + /** + * @brief Execute snpe instances in Async Output mode and Sync mode + * + * @param[in] inputBufferList A list of user buffers that contains the input data + * + * @param[in,out] outputBufferList A list of user buffers that will hold the output data + * + */ + bool execute(UserBufferList& inputBufferList, UserBufferList& outputBufferList) noexcept; + + /** + * @brief Execute snpe instances in Async Input/Output mode + * + * @param[in]inputMap A map of input buffers that contains input data. The names of buffers + * need to be matched with names retrived through getInputTensorNames() + * + * @param dataIndex Index of the input data + * + * @param isTF8buff Whether prefer to using 8 bit quantized element for inference + * + * @return True if executed successfully; flase, otherwise. + */ + bool executeInputOutputAsync(const ApplicationBufferMap& inputMap, size_t dataIndex, bool isTF8buff) noexcept; + /** + * @brief Returns the input layer names of the network. + * + * @return StringList which contains the input layer names + */ + const zdl::DlSystem::StringList getInputTensorNames() const noexcept; + + /** + * @brief Returns the output layer names of the network. + * + * @return StringList which contains the output layer names + */ + const zdl::DlSystem::StringList getOutputTensorNames() const noexcept; + + /** + * @brief Returns the input tensor dimensions of the network. + * + * @return TensorShape which contains the dimensions. + */ + const zdl::DlSystem::TensorShape getInputDimensions() const noexcept; + + /** + * @brief Returns attributes of buffers. + * + * @see zdl::SNPE + * + * @return BufferAttributes of input/output tensor named. + */ + const zdl::DlSystem::TensorShape getBufferAttributesDims(const char *name) const noexcept; + + private: + PSNPE(const PSNPE&) = delete; + PSNPE& operator=(const PSNPE&) = delete; + zdl::PSNPE::InputOutputTransmissionMode m_TransmissionMode; + +}; + +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ +} // namespace PSNPE +} // namespace zdl +#endif // PSNPE_HPP diff --git a/phonelibs/snpe/include/SNPE/RuntimeConfigList.hpp b/phonelibs/snpe/include/SNPE/RuntimeConfigList.hpp new file mode 100644 index 0000000000..ecd438b910 --- /dev/null +++ b/phonelibs/snpe/include/SNPE/RuntimeConfigList.hpp @@ -0,0 +1,88 @@ +//============================================================================== +// +// Copyright (c) 2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== +#ifndef PSNPE_RUNTIMECONFIGLIST_HPP +#define PSNPE_RUNTIMECONFIGLIST_HPP + +#include +#include "DlSystem/DlEnums.hpp" +#include "DlContainer/IDlContainer.hpp" +#include "DlSystem/ZdlExportDefine.hpp" +#include "DlSystem/RuntimeList.hpp" + +namespace zdl { +namespace PSNPE +{ + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief . + * + * The structure for configuring a BulkSNPE runtime + * + */ +struct ZDL_EXPORT RuntimeConfig final { + zdl::DlSystem::Runtime_t runtime; + zdl::DlSystem::RuntimeList runtimeList; + zdl::DlSystem::PerformanceProfile_t perfProfile; + bool enableCPUFallback; + RuntimeConfig(): runtime{zdl::DlSystem::Runtime_t::CPU_FLOAT32}, + perfProfile{zdl::DlSystem::PerformanceProfile_t::HIGH_PERFORMANCE}, + enableCPUFallback{false} + {} + RuntimeConfig(const RuntimeConfig& other) + { + runtime = other.runtime; + runtimeList = other.runtimeList; + perfProfile = other.perfProfile; + enableCPUFallback = other.enableCPUFallback; + } + + RuntimeConfig& operator=(const RuntimeConfig &other) + { + this->runtimeList = other.runtimeList; + this->runtime = other.runtime; + this->perfProfile = other.perfProfile; + this->enableCPUFallback = other.enableCPUFallback; + return *this; + } + + ~RuntimeConfig() {} + +}; + +/** +* @brief . +* +* The class for creating a RuntimeConfig container. +* +*/ +class ZDL_EXPORT RuntimeConfigList final +{ +public: + RuntimeConfigList(); + RuntimeConfigList(const size_t size); + void push_back(const RuntimeConfig &runtimeConfig); + RuntimeConfig& operator[](const size_t index); + RuntimeConfigList& operator =(const RuntimeConfigList &other); + size_t size() const noexcept; + size_t capacity() const noexcept; + void clear() noexcept; + ~RuntimeConfigList() = default; + +private: + void swap(const RuntimeConfigList &other); + std::vector m_runtimeConfigs; + +}; +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +} // namespace PSNPE +} // namespace zdl +#endif //PSNPE_RUNTIMECONFIGLIST_HPP diff --git a/phonelibs/snpe/include/SNPE/SNPE.hpp b/phonelibs/snpe/include/SNPE/SNPE.hpp index ba84265b96..e0821b90b1 100644 --- a/phonelibs/snpe/include/SNPE/SNPE.hpp +++ b/phonelibs/snpe/include/SNPE/SNPE.hpp @@ -83,6 +83,14 @@ public: zdl::DlSystem::Optional getOutputTensorNames() const noexcept; + /** + * @brief Gets the name of output tensor from the input layer name + * + * @return Output tensor name. + */ + zdl::DlSystem::StringList + getOutputTensorNamesByLayerName(const char *name) const noexcept; + /** * @brief Processes the input data and returns the output * diff --git a/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp b/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp index 13e80e8c1a..f314d88bcf 100644 --- a/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp +++ b/phonelibs/snpe/include/SNPE/SNPEBuilder.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2017 Qualcomm Technologies, Inc. +// Copyright (c) 2017-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -15,6 +15,7 @@ #include "DlSystem/DlOptional.hpp" #include "DlSystem/TensorShapeMap.hpp" #include "DlSystem/PlatformConfig.hpp" +#include "DlSystem/RuntimeList.hpp" namespace zdl { namespace DlContainer @@ -55,6 +56,9 @@ public: ~SNPEBuilder(); /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. Please use + * setRuntimeProcessorOrder() + * * @brief Sets the runtime processor. * * @param[in] targetRuntimeProcessor The target runtime. @@ -74,6 +78,17 @@ public: SNPEBuilder& setPerformanceProfile( zdl::DlSystem::PerformanceProfile_t performanceProfile); + /** + * @brief Sets the profiling level. Default profiling level for + * SNPEBuilder is off. Off and basic only applies to DSP runtime. + * + * @param[in] profilingLevel The target profiling level. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setProfilingLevel( + zdl::DlSystem::ProfilingLevel_t profilingLevel); + /** * @brief Sets a preference for execution priority. * @@ -104,6 +119,20 @@ public: SNPEBuilder& setOutputLayers( const zdl::DlSystem::StringList& outputLayerNames); + /** + * @brief Sets the output tensor names. + * + * @param[in] outputTensorNames List of tensor names to + * output. An empty list will + * result in producing output for the final + * output tensor of the model. + * The list will be copied. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setOutputTensors( + const zdl::DlSystem::StringList& outputTensorNames); + /** * @brief Passes in a User-defined layer. * @@ -144,6 +173,9 @@ public: bool debugMode); /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. Please use + * setRuntimeProcessorOrder() + * * @brief Sets the mode of CPU fallback functionality. * * @param[in] mode This flag enables/disables the functionality @@ -185,6 +217,22 @@ public: */ SNPEBuilder& setInputDimensions(const zdl::DlSystem::TensorShapeMap& inputDimensionsMap); + /** + * @brief Sets the mode of init caching functionality. + * + * @param[in] mode This flag enables/disables the functionality of init caching. + * When init caching functionality is enabled, a set of init caches + * will be created during network building/initialization process + * and will be added 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. + * In disable mode, no init caches will be added to DLC container. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setInitCacheMode( + bool cacheMode); + /** * @brief Returns an instance of SNPE based on the current parameters. * @@ -202,6 +250,31 @@ public: */ SNPEBuilder& setPlatformConfig(const zdl::DlSystem::PlatformConfig& platformConfig); + /** + * @brief Sets network's runtime order of precedence. Example: + * CPU_FLOAT32, GPU_FLOAT16, AIP_FIXED8_TF + * Note:- setRuntimeProcessor() or setCPUFallbackMode() will be silently ignored when + * setRuntimeProcessorOrder() is invoked + * + * @param[in] runtimeList The list of runtime in order of precedence + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setRuntimeProcessorOrder(const zdl::DlSystem::RuntimeList& runtimeList); + + /** + * @brief Sets the unconsumed tensors as output + * + * @param[in] setOutput This enables unconsumed tensors (i.e) + * outputs which are not inputs to any + * layer (basically dead ends) to be marked + * for output + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setUnconsumedTensorsAsOutputs( + bool setOutput); + }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ diff --git a/phonelibs/snpe/include/SNPE/SNPEFactory.hpp b/phonelibs/snpe/include/SNPE/SNPEFactory.hpp index bb9921afe1..7bef45d877 100644 --- a/phonelibs/snpe/include/SNPE/SNPEFactory.hpp +++ b/phonelibs/snpe/include/SNPE/SNPEFactory.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2015-2016 Qualcomm Technologies, Inc. +// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -42,19 +42,35 @@ class ZDL_EXPORT SNPEFactory public: /** - * Indicates whether the supplied runtime is available on the + * Indicates whether the supplied runtime is available on the * current platform. - * + * * @param[in] runtime The target runtime to check. - * - * @return True if the supplied runtime is available; false, + * + * @param[in] option Extent to perform runtime available check. + * + * @return True if the supplied runtime is available; false, * otherwise. */ static bool isRuntimeAvailable(zdl::DlSystem::Runtime_t runtime); + /** + * Indicates whether the supplied runtime is available on the + * current platform. + * + * @param[in] runtime The target runtime to check. + * + * @param[in] option Extent to perform runtime available check. + * + * @return True if the supplied runtime is available; false, + * otherwise. + */ + static bool isRuntimeAvailable(zdl::DlSystem::Runtime_t runtime, + zdl::DlSystem::RuntimeCheckOption_t option); + /** * Gets a reference to the tensor factory. - * + * * @return A reference to the tensor factory. */ static zdl::DlSystem::ITensorFactory& getTensorFactory(); @@ -87,6 +103,17 @@ public: */ static bool setSNPEStorageLocation(const char* storagePath); + /** + * @brief Register a user-defined op package with SNPE. + * + * @param[in] regLibraryPath Path to the registration library + * that allows clients to register a set of operations that are + * part of the package, and share op info with SNPE + * + * @return True if successful, False otherwise. + */ + static bool addOpPackage( const std::string& regLibraryPath ); + /** * Indicates whether the OpenGL and OpenCL interoperability is supported * on GPU platform. diff --git a/phonelibs/snpe/include/SNPE/UserBufferList.hpp b/phonelibs/snpe/include/SNPE/UserBufferList.hpp new file mode 100644 index 0000000000..a660bca0f6 --- /dev/null +++ b/phonelibs/snpe/include/SNPE/UserBufferList.hpp @@ -0,0 +1,49 @@ +//============================================================================== +// +// Copyright (c) 2019 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================== +#ifndef PSNPE_USERBUFFERLIST_HPP +#define PSNPE_USERBUFFERLIST_HPP + +#include +#include "DlSystem/UserBufferMap.hpp" +#include "DlSystem/ZdlExportDefine.hpp" + +namespace zdl { +namespace PSNPE +{ + +/** @addtogroup c_plus_plus_apis C++ +@{ */ +/** +* @brief . +* +* The class for creating a UserBufferMap container. +* +*/ +class ZDL_EXPORT UserBufferList final +{ +public: + UserBufferList(); + UserBufferList(const size_t size); + void push_back(const zdl::DlSystem::UserBufferMap &userBufferMap); + zdl::DlSystem::UserBufferMap& operator[](const size_t index); + UserBufferList& operator =(const UserBufferList &other); + size_t size() const noexcept; + size_t capacity() const noexcept; + void clear() noexcept; + ~UserBufferList() = default; + +private: + void swap(const UserBufferList &other); + std::vector m_userBufferMaps; + +}; +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +} // namespace PSNPE +} // namespace zdl +#endif //PSNPE_USERBUFFERLIST_HPP diff --git a/phonelibs/snpe/x86_64-linux-clang/libSNPE.so b/phonelibs/snpe/x86_64-linux-clang/libSNPE.so index cc1de85075..8247103179 100644 Binary files a/phonelibs/snpe/x86_64-linux-clang/libSNPE.so and b/phonelibs/snpe/x86_64-linux-clang/libSNPE.so differ diff --git a/phonelibs/snpe/x86_64-linux-clang/libsymphony-cpu.so b/phonelibs/snpe/x86_64-linux-clang/libsymphony-cpu.so index 70d6f146a3..03ebe979a5 100755 Binary files a/phonelibs/snpe/x86_64-linux-clang/libsymphony-cpu.so and b/phonelibs/snpe/x86_64-linux-clang/libsymphony-cpu.so differ diff --git a/release/files_common b/release/files_common index a1a225d67e..20fe7a2f7f 100644 --- a/release/files_common +++ b/release/files_common @@ -405,7 +405,7 @@ phonelibs/libyuv/include/** phonelibs/libyuv/lib/** phonelibs/snpe/include/** -phonelibs/snpe/aarch64-android-clang3.8/** +phonelibs/snpe/aarch64** phonelibs/fastcv/aarch64/** diff --git a/selfdrive/modeld/dmonitoringmodeld b/selfdrive/modeld/dmonitoringmodeld index 710e0e595b..a7aa664a2a 100755 --- a/selfdrive/modeld/dmonitoringmodeld +++ b/selfdrive/modeld/dmonitoringmodeld @@ -1,5 +1,5 @@ #!/bin/sh -export LD_LIBRARY_PATH="/data/pythonpath/phonelibs/snpe/aarch64-android-clang3.8:$HOME/openpilot/phonelibs/snpe/x86_64-linux-clang:$LD_LIBRARY_PATH" -export ADSP_LIBRARY_PATH="/data/pythonpath/phonelibs/snpe/aarch64-android-clang3.8/" +export LD_LIBRARY_PATH="/data/pythonpath/phonelibs/snpe/aarch64:$HOME/openpilot/phonelibs/snpe/x86_64-linux-clang:$LD_LIBRARY_PATH" +export ADSP_LIBRARY_PATH="/data/pythonpath/phonelibs/snpe/aarch64/" exec ./_dmonitoringmodeld diff --git a/selfdrive/modeld/modeld b/selfdrive/modeld/modeld index bbe7006afc..9de1569dec 100755 --- a/selfdrive/modeld/modeld +++ b/selfdrive/modeld/modeld @@ -1,4 +1,4 @@ #!/bin/sh -export LD_LIBRARY_PATH="/data/pythonpath/phonelibs/snpe/aarch64-android-clang3.8/:$HOME/openpilot/phonelibs/snpe/x86_64-linux-clang:$LD_LIBRARY_PATH" +export LD_LIBRARY_PATH="/data/pythonpath/phonelibs/snpe/aarch64/:$HOME/openpilot/phonelibs/snpe/x86_64-linux-clang:$LD_LIBRARY_PATH" exec ./_modeld diff --git a/selfdrive/modeld/test/snpe_benchmark/benchmark.cc b/selfdrive/modeld/test/snpe_benchmark/benchmark.cc index cc61e96ff5..0e8f4faf49 100644 --- a/selfdrive/modeld/test/snpe_benchmark/benchmark.cc +++ b/selfdrive/modeld/test/snpe_benchmark/benchmark.cc @@ -83,7 +83,7 @@ void test(char *filename) { struct timespec start, end; cout << "**** starting benchmark ****" << endl; - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 50; i++) { clock_gettime(CLOCK_MONOTONIC, &start); assert(snpe->execute(inputTensorMap, outputTensorMap)); clock_gettime(CLOCK_MONOTONIC, &end);