1 /* 2 * Copyright (c) Qualcomm Innovation Center, Inc. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8 9 #pragma once 10 11 #include <executorch/backends/qualcomm/qc_compiler_spec_generated.h> 12 #include <executorch/backends/qualcomm/runtime/backends/QnnContextCommon.h> 13 14 #include <memory> 15 #include <vector> 16 17 #include "HTP/QnnHtpContext.h" 18 19 namespace executorch { 20 namespace backends { 21 namespace qnn { 22 23 using namespace qnn_delegate; 24 25 class HtpContextCustomConfig { 26 public: HtpContextCustomConfig(const QnnContext * context,const QnnExecuTorchHtpBackendOptions * htp_options)27 explicit HtpContextCustomConfig( 28 const QnnContext* context, 29 const QnnExecuTorchHtpBackendOptions* htp_options) 30 : context_(context), htp_options_(htp_options) {} 31 32 std::vector<QnnContext_CustomConfig_t> CreateContextCustomConfig(); 33 34 private: AllocContextCustomConfig()35 QnnHtpContext_CustomConfig_t* AllocContextCustomConfig() { 36 htp_context_config_.emplace_back( 37 std::make_unique<QnnHtpContext_CustomConfig_t>()); 38 htp_context_config_.back()->option = QNN_HTP_CONTEXT_CONFIG_OPTION_UNKNOWN; 39 return htp_context_config_.back().get(); 40 } 41 42 [[maybe_unused]] const QnnContext* context_; 43 std::vector<std::unique_ptr<QnnHtpContext_CustomConfig_t>> 44 htp_context_config_; 45 [[maybe_unused]] const QnnExecuTorchHtpBackendOptions* htp_options_; 46 }; 47 48 } // namespace qnn 49 } // namespace backends 50 } // namespace executorch 51