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");
111 std::array<ManagedOpaqueDescriptor, 10>
ops{};
128 m_operationGraph.handle = handle_;
134 m_operationGraph.numOps = numOps_;
135 for (
auto i = 0u; i < numOps_; i++) {
136 m_operationGraph.ops[i] = ops_[i]->get_desc();
137 m_operationGraph.opGraphTag += ops_[i]->getTag() +
'_';
147 if (m_operationGraph.numOps <= 0) {
150 CUDNN_STATUS_BAD_PARAM,
151 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: Check and Set the CUDNN_ATTR_OPERATIONGRAPH_OPS Count field");
152 return std::move(m_operationGraph);
154 if (m_operationGraph.ops[0] ==
nullptr) {
157 CUDNN_STATUS_BAD_PARAM,
158 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: Check and set CUDNN_ATTR_OPERATIONGRAPH_OPS field");
159 return std::move(m_operationGraph);
161 if (m_operationGraph.handle ==
nullptr) {
164 CUDNN_STATUS_BAD_PARAM,
165 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: Check and Set CUDNN_ATTR_OPERATIONGRAPH_HANDLE");
166 return std::move(m_operationGraph);
170 auto status = m_operationGraph.initialize_managed_backend_pointer(CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR);
171 if (
status != CUDNN_STATUS_SUCCESS) {
173 &m_operationGraph,
status,
"CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: cudnnCreate Failed");
174 return std::move(m_operationGraph);
177 std::array<cudnnBackendDescriptor_t, 10> ops_raw{
nullptr};
178 for (
auto i = 0u; i < m_operationGraph.numOps; i++) {
179 ops_raw[i] = m_operationGraph.ops[i]->get_backend_descriptor();
182 status = cudnnBackendSetAttribute(m_operationGraph.pointer->get_backend_descriptor(),
183 CUDNN_ATTR_OPERATIONGRAPH_OPS,
184 CUDNN_TYPE_BACKEND_DESCRIPTOR,
185 m_operationGraph.numOps,
187 if (
status != CUDNN_STATUS_SUCCESS) {
191 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: SetAttribute CUDNN_ATTR_OPERATIONGRAPH_OPS Failed");
192 return std::move(m_operationGraph);
194 status = cudnnBackendSetAttribute(m_operationGraph.pointer->get_backend_descriptor(),
195 CUDNN_ATTR_OPERATIONGRAPH_HANDLE,
198 &m_operationGraph.handle);
199 if (
status != CUDNN_STATUS_SUCCESS) {
203 "CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: SetAttribute CUDNN_ATTR_OPERATIONGRAPH_HANDLE Failed");
204 return std::move(m_operationGraph);
208 status = cudnnBackendFinalize(m_operationGraph.pointer->get_backend_descriptor());
209 if (
status != CUDNN_STATUS_SUCCESS) {
211 &m_operationGraph,
status,
"CUDNN_BACKEND_OPERATIONGRAPH_DESCRIPTOR: cudnnFinalize Failed");
212 return std::move(m_operationGraph);
215 return std::move(m_operationGraph);
uint64_t getOpCount() const
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