-
Notifications
You must be signed in to change notification settings - Fork 979
Expand file tree
/
Copy pathQnnExecuTorchBackend.h
More file actions
79 lines (65 loc) · 2.76 KB
/
QnnExecuTorchBackend.h
File metadata and controls
79 lines (65 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright (c) Qualcomm Innovation Center, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <executorch/backends/qualcomm/runtime/QnnBackendOptions.h>
#include <executorch/runtime/backend/interface.h>
#include <executorch/runtime/core/error.h>
#include <executorch/runtime/core/evalue.h>
#include <mutex>
#include <unordered_map>
namespace executorch {
namespace backends {
namespace qnn {
class QnnExecuTorchBackend final
: public ::executorch::runtime::BackendInterface {
public:
~QnnExecuTorchBackend(){};
executorch::runtime::Result<executorch::runtime::DelegateHandle*> init(
executorch::runtime::BackendInitContext& context,
executorch::runtime::FreeableBuffer* processed,
executorch::runtime::ArrayRef<executorch::runtime::CompileSpec>
compile_specs) const override;
executorch::runtime::Error execute(
ET_UNUSED executorch::runtime::BackendExecutionContext& context,
executorch::runtime::DelegateHandle* handle,
executorch::runtime::Span<executorch::runtime::EValue*> args)
const override;
ET_NODISCARD executorch::runtime::Error set_option(
executorch::runtime::BackendOptionContext& context,
const executorch::runtime::Span<executorch::runtime::BackendOption>&
backend_options) override;
executorch::runtime::Error get_option(
executorch::runtime::BackendOptionContext& context,
executorch::runtime::Span<executorch::runtime::BackendOption>&
backend_options) override;
void destroy(executorch::runtime::DelegateHandle* handle) const override;
bool is_available() const override;
private:
void add_cached_delegate(
const std::int64_t& signature,
executorch::runtime::DelegateHandle* handle) const;
void erase_cached_delegate(executorch::runtime::DelegateHandle* handle) const;
mutable std::mutex mutex_;
mutable std::mutex runtime_option_mutex_;
mutable std::unordered_map<int64_t, executorch::runtime::DelegateHandle*>
delegate_map_;
mutable std::unordered_map<executorch::runtime::DelegateHandle*, std::int64_t>
delegate_map_rev_;
RuntimeOption qnn_runtime_log_level_{false, 0};
RuntimeOption qnn_runtime_performance_mode_{false, 0};
RuntimeOption qnn_runtime_profile_level_{false, 0};
RuntimeOption qnn_runtime_lpai_fps_{false, 0};
RuntimeOption qnn_runtime_lpai_ftrt_ratio_{false, 0};
RuntimeOption qnn_runtime_lpai_client_perf_type_{false, 0};
RuntimeOption qnn_runtime_lpai_affinity_{false, 0};
RuntimeOption qnn_runtime_lpai_core_selection_{false, 0};
RuntimeOption qnn_runtime_heap_profiling_path_{false, {}};
};
} // namespace qnn
} // namespace backends
} // namespace executorch