33 #include <cudnn_backend.h> 57 ss <<
"CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR :";
77 int64_t global_count = -1;
78 auto status = cudnnBackendGetAttribute(
pointer->get_backend_descriptor(),
79 CUDNN_ATTR_OPERATIONGRAPH_ENGINE_GLOBAL_COUNT,
84 if (
status != CUDNN_STATUS_SUCCESS) {
87 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: GetAttribute " 88 "CUDNN_ATTR_OPERATIONGRAPH_ENGINE_GLOBAL_COUNT Failed");
106 std::array<ManagedOpaqueDescriptor, 10>
ops{};
123 m_operationGraph.handle = handle_;
129 m_operationGraph.numOps = numOps_;
130 for (
auto i = 0u; i < numOps_; i++) {
131 m_operationGraph.ops[i] = ops_[i]->get_desc();
132 m_operationGraph.opGraphTag += ops_[i]->getTag() +
'_';
142 if (m_operationGraph.numOps <= 0) {
145 CUDNN_STATUS_BAD_PARAM,
146 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: Check and Set the CUDNN_ATTR_OPERATIONGRAPH_OPS Count field");
147 return std::move(m_operationGraph);
149 if (m_operationGraph.ops[0] ==
nullptr) {
152 CUDNN_STATUS_BAD_PARAM,
153 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: Check and set CUDNN_ATTR_OPERATIONGRAPH_OPS field");
154 return std::move(m_operationGraph);
156 if (m_operationGraph.handle ==
nullptr) {
159 CUDNN_STATUS_BAD_PARAM,
160 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: Check and Set CUDNN_ATTR_OPERATIONGRAPH_HANDLE");
161 return std::move(m_operationGraph);
165 auto status = m_operationGraph.initialize_managed_backend_pointer(CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR);
166 if (
status != CUDNN_STATUS_SUCCESS) {
168 &m_operationGraph,
status,
"CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: cudnnCreate Failed");
169 return std::move(m_operationGraph);
172 std::array<cudnnBackendDescriptor_t, 10> ops_raw{
nullptr};
173 for (
auto i = 0u; i < m_operationGraph.numOps; i++) {
174 ops_raw[i] = m_operationGraph.ops[i]->get_backend_descriptor();
177 status = cudnnBackendSetAttribute(m_operationGraph.pointer->get_backend_descriptor(),
178 CUDNN_ATTR_OPERATIONGRAPH_OPS,
179 CUDNN_TYPE_BACKEND_DESCRIPTOR,
180 m_operationGraph.numOps,
182 if (
status != CUDNN_STATUS_SUCCESS) {
186 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: SetAttribute CUDNN_ATTR_OPERATIONGRAPH_OPS Failed");
187 return std::move(m_operationGraph);
189 status = cudnnBackendSetAttribute(m_operationGraph.pointer->get_backend_descriptor(),
190 CUDNN_ATTR_OPERATIONGRAPH_HANDLE,
193 &m_operationGraph.handle);
194 if (
status != CUDNN_STATUS_SUCCESS) {
198 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: SetAttribute CUDNN_ATTR_OPERATIONGRAPH_HANDLE Failed");
199 return std::move(m_operationGraph);
203 status = cudnnBackendFinalize(m_operationGraph.pointer->get_backend_descriptor());
204 if (
status != CUDNN_STATUS_SUCCESS) {
206 &m_operationGraph,
status,
"CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: cudnnFinalize Failed");
207 return std::move(m_operationGraph);
210 return std::move(m_operationGraph);
static void set_error_and_throw_exception(BackendDescriptor const *desc, cudnnStatus_t status, const char *message)
auto setHandle(cudnnHandle_t handle_) -> OperationGraphBuilder_v8 &
Set cudnnHandle for the operations.
auto setOperationGraph(int64_t numOps_, Operation_v8 const **ops_) -> OperationGraphBuilder_v8 &
Set numoperations and the operations.
ManagedOpaqueDescriptor get_desc() const
Returns a copy of underlying managed descriptor.
auto getEngineCount(void) const -> int64_t
Query the total count of the engines for the Operation Set.
friend class OperationGraphBuilder_v8
OperationGraph_v8 m_operationGraph
cudnnStatus_t get_status() const
Current status of the descriptor.
std::string const & getTag() const
std::string describe() const override
Return a string describing the backend Descriptor.
OperationGraph_v8()=default
const char * get_error() const
Diagonistic error message if any.
~OperationGraph_v8()=default
OperationGraph_v8(OperationGraph_v8 &&from)
OperationGraph_v8 && build()
OperationGraph_v8 & operator=(OperationGraph_v8 const &)=delete
std::array< ManagedOpaqueDescriptor, 10 > ops
cudnnStatus_t status
Shared pointer of the OpaqueBackendPointer.
ManagedOpaqueDescriptor pointer