mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 17:43:54 +08:00
* modeld: Retain pre-20hz drive model support * Method not available anymore on OP * some fixes * Revert "Long planner get accel: new function args (#34288)" * Revert "Fix low-speed allow_throttle behavior in long planner (#33894)" * Revert "long planner: allow throttle reflects usage (#33792)" * Revert "Gate acceleration on model gas press predictions (#33643)" * Reapply "Gate acceleration on model gas press predictions (#33643)" This reverts commit76b08e37cb. * Reapply "long planner: allow throttle reflects usage (#33792)" This reverts commitc75244ca4e. * Reapply "Fix low-speed allow_throttle behavior in long planner (#33894)" This reverts commitb2b7d21b7b. * Reapply "Long planner get accel: new function args (#34288)" This reverts commit74dca2fccf. * don't need * retain snpe * wrong * they're symlinks * remove * put back into VCS * add back * don't include built * Refactor model runner retrieval with caching support Added caching for active model runner type via `ModelRunnerTypeCache` to enhance performance and avoid redundant checks. Introduced a `force_check` flag to bypass the cache when necessary. Updated related code to handle cache clearing during onroad transitions. * Update model runner determination logic with caching fix Enhances `get_active_model_runner` to utilize caching more effectively by ensuring type consistency and updating cache only when necessary. Also updates `is_snpe_model` to pass the `started` state to the runner determination function, improving behavior for dynamic checks. * default to none * enable in next PR * more --------- Co-authored-by: DevTekVE <devtekve@gmail.com>
192 lines
5.4 KiB
C++
192 lines
5.4 KiB
C++
//=============================================================================
|
|
//
|
|
// Copyright (c) 2015-2020 Qualcomm Technologies, Inc.
|
|
// All Rights Reserved.
|
|
// Confidential and Proprietary - Qualcomm Technologies, Inc.
|
|
//
|
|
//=============================================================================
|
|
|
|
#ifndef ZEROTH_IDNC_CONTAINER_HPP
|
|
#define ZEROTH_IDNC_CONTAINER_HPP
|
|
|
|
#include <memory>
|
|
#include <stdint.h>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <set>
|
|
|
|
#include "DlSystem/ZdlExportDefine.hpp"
|
|
#include "DlSystem/String.hpp"
|
|
|
|
namespace zdl {
|
|
namespace DlContainer {
|
|
|
|
/** @addtogroup c_plus_plus_apis C++
|
|
@{ */
|
|
|
|
class IDlContainer;
|
|
class dlc_error;
|
|
|
|
/**
|
|
* The structure of a record in a DL container.
|
|
*/
|
|
struct ZDL_EXPORT DlcRecord
|
|
{
|
|
/// Name of the record.
|
|
std::string name;
|
|
/// Byte blob holding the data for the record.
|
|
std::vector<uint8_t> data;
|
|
|
|
DlcRecord();
|
|
DlcRecord( DlcRecord&& other )
|
|
: 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;
|
|
};
|
|
|
|
// The maximum length of any record name.
|
|
extern const uint32_t RECORD_NAME_MAX_SIZE;
|
|
// The maximum size of the record payload (bytes).
|
|
extern const uint32_t RECORD_DATA_MAX_SIZE;
|
|
// The maximum number of records in an archive at one time.
|
|
extern const uint32_t ARCHIVE_MAX_RECORDS;
|
|
|
|
/**
|
|
* Represents a container for a neural network model which can
|
|
* be used to load the model into the SNPE runtime.
|
|
*/
|
|
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
|
|
*/
|
|
static std::unique_ptr<IDlContainer>
|
|
open(const std::string &filename) noexcept;
|
|
|
|
/**
|
|
* Initializes a container from a container archive file.
|
|
*
|
|
* @param[in] filename Container archive file path.
|
|
*
|
|
* @return A pointer to the initialized container
|
|
*/
|
|
static std::unique_ptr<IDlContainer>
|
|
open(const zdl::DlSystem::String &filename) noexcept;
|
|
|
|
/**
|
|
* Initializes a container from a byte buffer.
|
|
*
|
|
* @param[in] buffer Byte buffer holding the contents of an archive
|
|
* file.
|
|
*
|
|
* @return A pointer to the initialized container
|
|
*/
|
|
static std::unique_ptr<IDlContainer>
|
|
open(const std::vector<uint8_t> &buffer) noexcept;
|
|
|
|
/**
|
|
* Initializes a container from a byte buffer.
|
|
*
|
|
* @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
|
|
*/
|
|
static std::unique_ptr<IDlContainer>
|
|
open(const uint8_t* buffer, const size_t size) noexcept;
|
|
|
|
|
|
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
|
|
|
|
/**
|
|
* Get the record catalog for a container.
|
|
*
|
|
* @param[out] catalog Buffer that will hold the record names on
|
|
* return.
|
|
*/
|
|
virtual void getCatalog(std::set<std::string> &catalog) const = 0;
|
|
|
|
/**
|
|
* Get the record catalog for a container.
|
|
*
|
|
* @param[out] catalog Buffer that will hold the record names on
|
|
* return.
|
|
*/
|
|
virtual void getCatalog(std::set<zdl::DlSystem::String> &catalog) const = 0;
|
|
|
|
/**
|
|
* 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
|
|
* will own the data in the record and is
|
|
* responsible for freeing it if needed.
|
|
*/
|
|
virtual void getRecord(const std::string &name, DlcRecord &record) const = 0;
|
|
|
|
/**
|
|
* 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
|
|
* will own the data in the record and is
|
|
* responsible for freeing it if needed.
|
|
*/
|
|
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() {}
|
|
};
|
|
|
|
} // ns DlContainer
|
|
} // ns zdl
|
|
|
|
|
|
#endif
|