Files
openpilot-evo/third_party/snpe/include/SnpeUdo/UdoImplGpu.h
T
Jason Wen acd46aa94b modeld: retain SNPE and thneed drive model support (#555)
* 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 commit 76b08e37cb8eb94266ad9f6fed80db227e7c3428.

* Reapply "long planner: allow throttle reflects usage (#33792)"

This reverts commit c75244ca4e9c48084b0205b7c871e1a4e0f4e693.

* Reapply "Fix low-speed allow_throttle behavior in long planner (#33894)"

This reverts commit b2b7d21b7b685a2785d1beede3d223f0bb954807.

* Reapply "Long planner get accel: new function args (#34288)"

This reverts commit 74dca2fccf4da59cc8ac62ba9c0ad10ba3fc264b.

* 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>
2025-01-10 18:34:06 -05:00

113 lines
3.8 KiB
C

//==============================================================================
//
// Copyright (c) 2019-2020 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
//
//==============================================================================
// Header to be used by a GPU UDO Implementation library
#ifndef SNPE_UDO_IMPL_GPU_H
#define SNPE_UDO_IMPL_GPU_H
#include "CL/cl.h"
#include "SnpeUdo/UdoBase.h"
/** @addtogroup c_plus_plus_apis C++
@{ */
/**
* This header defines version 0.0.0 of the GPU UDO Infrastructure.
* It defines the interpretation of the global and per-OpFactory infrastructure pointers
* as well as the interpretation of tensorData pointers.
*
* The per-Operation infrastructure pointer is defined to be null, and should not be used.
*
* The SnpeUdoTensorParam_t struct below provides the interpretation for
* the tensorData opaque pointer for SnpeUdoTensorParams representing inputs or outputs.
*
* The tensorData opaque pointer populated in SnpeUdoScalarParam_t structs should be interpreted
* as a host-readable data pointer.
*
*/
/**
* @brief Function to retrieve opencl program from Program Cache repository.
* @param programCache is opaque pointer to Program Cache repository provided by
* SNPE GPU UDO runtime.
* @param programName is name associated with opencl program for UDO.
* @param program is pointer to opencl program which will be populated with
* valid opencl program if found in Program Cache repository.
* @return SnpeUdo_ErrorType_t is error type returned. SNPE_UDO_NO_ERROR is returned
* on success.
*/
typedef SnpeUdo_ErrorType_t (*SnpeUdo_getProgram_t)
(void* programCache, const char* programName, cl_program* program);
/**
* @brief Function to store valid opencl program in Program Cache repository.
* @param programCache is opaque pointer to Program Cache repository provided by
* SNPE GPU UDO runtime.
* @param programName is name associated with opencl program for UDO.
* @param program is valid opencl program after program is built.
* @return SnpeUdo_ErrorType_t is error type returned. SNPE_UDO_NO_ERROR is returned
* on success.
* */
typedef SnpeUdo_ErrorType_t (*SnpeUdo_storeProgram_t)
(void* programCache, const char * programName, cl_program program);
/**
* @brief Global Infrastructure Definition for GPU UDO Implementations.
*/
typedef struct {
// Infrastructure definition version. This header is 0.0.0
SnpeUdo_Version_t gpuInfraVersion;
SnpeUdo_getProgram_t SnpeUdo_getProgram;
SnpeUdo_storeProgram_t SnpeUdo_storeProgram;
} SnpeUdo_GpuInfrastructure_t;
/**
* @brief Per OpFactory Infrastructure Definition for GPU UDO Implementations.
* @note This version of the infrastructure definition guarantees that the same
* Per OpFactory infrastructure pointer will be provided to all OpFactories
* in the same network.
*/
typedef struct
{
cl_context context;
cl_command_queue commandQueue;
void* programCache;
} SnpeUdo_GpuOpFactoryInfrastructure_t;
/**
* @brief Opaque tensorData definition for operation inputs and outputs.
*
* The following is a list of all SnpeUdoTensorLayout_t values supported by the
* GPU UDO implementation, and how the parameters of the struct should be
* interpreted in each case:
*
* SNPE_UDO_LAYOUT_NHWC:
* mem shall be single-element array, pointing to a cl buffer memory object.
* the dimensions of this object match the dimensions specified in the encompassing
* SnpeUdoTensorParam_t's currDimensions.
*
* memCount shall be 1.
*
* paddedRank and paddedDimensions are undefined and shall be ignored by the UDO
* implementation.
*
*/
typedef struct
{
cl_mem* mem;
uint32_t memCount;
uint32_t paddedRank;
uint32_t* paddedDimensions;
} SnpeUdo_GpuTensorData_t;
/** @} */ /* end_addtogroup c_plus_plus_apis C++ */
#endif // SNPE_UDO_IMPL_GPU_H