Preparing for the efficientnet (#1255)
* snpe version 1.35.0.698 * fix files common for new snpe * efficient net with normal names * compiling with 1.32 works * actual snpe files * fix monitoring, delete unneeded * point the symlinks to the right places * err, modeld needs the CPU * benchmark for 50 its * put back old model for now Co-authored-by: Comma Device <device@comma.ai> Co-authored-by: Harald Schafer <harald.the.engineer@gmail.com> Co-authored-by: George Hotz <geohot@gmail.com>pull/1298/head
parent
5644b2875d
commit
6e5a2d404b
32 changed files with 1021 additions and 58 deletions
@ -1 +1 @@ |
||||
aarch64-android-clang3.8 |
||||
aarch64-android-clang6.0 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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 <cstddef> |
||||
#include <memory> |
||||
|
||||
#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
|
||||
|
@ -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 <vector> |
||||
#include <string> |
||||
#include <unordered_map> |
||||
|
||||
#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<uint8_t>& buff) noexcept; |
||||
void add(const char* name, std::vector<float>& 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<uint8_t>& getUserBuffer(const char* name) const; |
||||
const std::vector<uint8_t>& 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<std::string, std::vector<uint8_t>>& getUserBuffer() const; |
||||
explicit ApplicationBufferMap(); |
||||
~ApplicationBufferMap(); |
||||
explicit ApplicationBufferMap( |
||||
const std::unordered_map<std::string, std::vector<uint8_t>> buffer); |
||||
|
||||
private: |
||||
std::unordered_map<std::string, std::vector<uint8_t>> m_UserMap; |
||||
}; |
||||
|
||||
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ |
||||
} // namespace PSNPE
|
||||
} // namespace zdl
|
||||
|
||||
#endif // PSNPE_APPLICATIONBUFFERMAP_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 <cstdlib> |
||||
#include <unordered_map> |
||||
#include <functional> |
||||
#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<void(OutputAsyncCallbackParam)>; |
||||
using InputOutputAsyncCallbackFunc = std::function<void(InputOutputAsyncCallbackParam)>; |
||||
/**
|
||||
* @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
|
@ -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 <iostream> |
||||
#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<RuntimeConfig> m_runtimeConfigs; |
||||
|
||||
}; |
||||
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ |
||||
|
||||
} // namespace PSNPE
|
||||
} // namespace zdl
|
||||
#endif //PSNPE_RUNTIMECONFIGLIST_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 <vector> |
||||
#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<zdl::DlSystem::UserBufferMap> m_userBufferMaps; |
||||
|
||||
}; |
||||
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ |
||||
|
||||
} // namespace PSNPE
|
||||
} // namespace zdl
|
||||
#endif //PSNPE_USERBUFFERLIST_HPP
|
Binary file not shown.
Binary file not shown.
@ -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 |
||||
|
||||
|
@ -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 |
||||
|
||||
|
Loading…
Reference in new issue