28 #include <cudnn_backend.h> 53 ss <<
"CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR :";
71 for (
auto i = 0u; i < count; ++i) {
74 if (engConfig->is_good() ==
false) {
77 engConfig->get_status(),
78 "CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR: CUDNN_BACKEND_ENGINECFG_DESCRIPTOR cudnnCreate Failed");
83 std::vector<cudnnBackendDescriptor_t> heuristic_results_;
88 status = cudnnBackendGetAttribute(
pointer->get_backend_descriptor(),
89 CUDNN_ATTR_ENGINEHEUR_RESULTS,
90 CUDNN_TYPE_BACKEND_DESCRIPTOR,
93 heuristic_results_.data());
94 if (status != CUDNN_STATUS_SUCCESS) {
96 this, status,
"CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR: GetAttribute CUDNN_ATTR_ENGINEHEUR_RESULTS Failed");
106 status = cudnnBackendGetAttribute(
pointer->get_backend_descriptor(),
107 CUDNN_ATTR_ENGINEHEUR_RESULTS,
108 CUDNN_TYPE_BACKEND_DESCRIPTOR,
112 if (status != CUDNN_STATUS_SUCCESS) {
116 "CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR: GetAttribute CUDNN_ATTR_ENGINEHEUR_RESULTS Count Failed");
128 cudnnBackendHeurMode_t
mode = CUDNN_HEUR_MODE_INSTANT;
146 m_heuristics.opGraph = opGraph_.get_desc();
147 m_heuristics.opGraphTag = opGraph_.getTag();
153 m_heuristics.mode = mode_;
162 if (m_heuristics.opGraph ==
nullptr) {
164 CUDNN_STATUS_BAD_PARAM,
165 "CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR: Check and Set the " 166 "CUDNN_ATTR_ENGINEHEUR_OPERATION_GRAPH field for heuristic");
167 return std::move(m_heuristics);
171 auto status = m_heuristics.initialize_managed_backend_pointer(CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR);
172 if (
status != CUDNN_STATUS_SUCCESS) {
174 &m_heuristics,
status,
"CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR: cudnnCreate Failed");
175 return std::move(m_heuristics);
178 status = cudnnBackendSetAttribute(m_heuristics.pointer->get_backend_descriptor(),
179 CUDNN_ATTR_ENGINEHEUR_OPERATION_GRAPH,
180 CUDNN_TYPE_BACKEND_DESCRIPTOR,
182 &(m_heuristics.opGraph->get_backend_descriptor()));
183 if (
status != CUDNN_STATUS_SUCCESS) {
187 "CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR: SetAttribute CUDNN_ATTR_ENGINEHEUR_OPERATION_GRAPH Failed");
188 return std::move(m_heuristics);
190 status = cudnnBackendSetAttribute(m_heuristics.pointer->get_backend_descriptor(),
191 CUDNN_ATTR_ENGINEHEUR_MODE,
192 CUDNN_TYPE_HEUR_MODE,
195 if (
status != CUDNN_STATUS_SUCCESS) {
199 "CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR: SetAttribute CUDNN_ATTR_ENGINEHEUR_MODE Failed");
200 return std::move(m_heuristics);
204 status = cudnnBackendFinalize(m_heuristics.pointer->get_backend_descriptor());
205 if (
status != CUDNN_STATUS_SUCCESS) {
207 &m_heuristics,
status,
"CUDNN_BACKEND_ENGINEHEUR_DESCRIPTOR: cudnn Finalize failed");
208 return std::move(m_heuristics);
211 getLogger() <<
"[cudnn_frontend] " << m_heuristics << std::endl;
212 return std::move(m_heuristics);
226 template<std::
size_t SIZE>
230 std::function<
bool(cudnnBackendDescriptor_t)> filter_fn) {
235 for (
auto mode : modes) {
237 .setOperationGraph(opGraph)
241 auto& engine_config = heuristics.getEngineConfig(heuristics.getEngineConfigCount());
245 return filtered_configs;
auto setHeurMode(cudnnBackendHeurMode_t mode_) -> EngineHeuristicsBuilder_v8 &
Set cudnnHandle for the operations.
ConditionalStreamer & getLogger()
static void set_error_and_throw_exception(BackendDescriptor const *desc, cudnnStatus_t status, const char *message)
friend class EngineHeuristicsBuilder_v8
EngineHeuristics_v8 && build()
auto getEngineConfig(int64_t count=1) -> std::vector< ManagedOpaqueDescriptor > &
Query the total count of the engines for the Operation Set.
static auto filter(Predicate pred, executionPlans_t &plans) -> executionPlans_t
static ManagedOpaqueDescriptor make_shared_backend_pointer(cudnnBackendDescriptorType_t type)
auto setOperationGraph(OperationGraph_v8 &opGraph_) -> EngineHeuristicsBuilder_v8 &
Set operationGraph for the engine (opGraph is not destroyed)
cudnnBackendHeurMode_t mode
ManagedOpaqueDescriptor opGraph
std::string opGraphTag
storage of heuristic results
auto getEngineConfigCount(void) const -> int64_t
Query the total count of the engine config for the Operation Set.
~EngineHeuristics_v8()=default
EngineConfigList get_heuristics_list(std::array< cudnnBackendHeurMode_t, SIZE > modes, OperationGraph_v8 &opGraph, std::function< bool(cudnnBackendDescriptor_t)> filter_fn)
std::shared_ptr< OpaqueBackendPointer > ManagedOpaqueDescriptor
EngineHeuristics_v8()=default
EngineHeuristics_v8 & operator=(EngineHeuristics_v8 &&from)=default
std::vector< ManagedOpaqueDescriptor > m_heuristic_results
EngineHeuristics_v8 m_heuristics
std::vector< ManagedOpaqueDescriptor > EngineConfigList
std::string describe() const override
Return a string describing the backend Descriptor.
cudnnStatus_t status
Shared pointer of the OpaqueBackendPointer.
ManagedOpaqueDescriptor pointer