cudnn_backend_base.h
ostream
cudnn.h
cudnn_frontend_utils.h
cudnn_frontend_Logging.h
cudnn.h
ostream
cudnn_backend_base.h
cudnn_frontend_VariantPack.h
cudnn_frontend_Engine.h
cudnn_frontend_EngineConfig.h
cudnn_frontend_MatMulDesc.h
cudnn_frontend_Heuristics.h
cudnn_frontend_PointWiseDesc.h
cudnn_frontend_get_plan.h
cudnn_frontend_Errata.h
cudnn_frontend_Logging.h
cudnn_frontend_Tensor.h
cudnn_frontend_EngineConfigGenerator.h
cudnn_frontend_ExecutionPlanCache.h
cudnn_frontend_Operation.h
cudnn_frontend_Reorder_Tensor.h
cudnn_frontend_ExecutionPlan.h
cudnn_frontend_ConvDesc.h
cudnn_frontend_OperationGraph.h
cudnn_frontend.h
cudnn_frontend_find_plan.h
cudnn_frontend_ReductionDesc.h
cudnn_frontend_utils.h
cudnn_backend_base.h
cudnn_frontend::OpaqueBackendPointer
cudnn_frontend::BackendDescriptor
cudnn_frontend

    /*
    *Copyright(c)2021,NVIDIACORPORATION.Allrightsreserved.
    *
    *Permissionisherebygranted,freeofcharge,toanypersonobtaininga
    *copyofthissoftwareandassociateddocumentationfiles(the"Software"),
    *todealintheSoftwarewithoutrestriction,includingwithoutlimitation
    *therightstouse,copy,modify,merge,publish,distribute,sublicense,
    *and/orsellcopiesoftheSoftware,andtopermitpersonstowhomthe
    *Softwareisfurnishedtodoso,subjecttothefollowingconditions:
    *
    *Theabovecopyrightnoticeandthispermissionnoticeshallbeincludedin
    *allcopiesorsubstantialportionsoftheSoftware.
    *
    *THESOFTWAREISPROVIDED"ASIS",WITHOUTWARRANTYOFANYKIND,EXPRESSOR
    *IMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOFMERCHANTABILITY,
    *FITNESSFORAPARTICULARPURPOSEANDNONINFRINGEMENT.INNOEVENTSHALL
    *THEAUTHORSORCOPYRIGHTHOLDERSBELIABLEFORANYCLAIM,DAMAGESOROTHER
    *LIABILITY,WHETHERINANACTIONOFCONTRACT,TORTOROTHERWISE,ARISING
    *FROM,OUTOFORINCONNECTIONWITHTHESOFTWAREORTHEUSEOROTHER
    *DEALINGSINTHESOFTWARE.
    */

    #pragmaonce

    #include<ostream>

    #include<cudnn.h>

    namespacecudnn_frontend{

    classOpaqueBackendPointer{
    cudnnBackendDescriptor_tm_desc=nullptr;
    cudnnStatus_tstatus=CUDNN_STATUS_SUCCESS;

    public:
    OpaqueBackendPointer(constOpaqueBackendPointer&)=delete;
    OpaqueBackendPointer&
    operator=(constOpaqueBackendPointer&)=delete;
    OpaqueBackendPointer(OpaqueBackendPointer&&)=default;

    OpaqueBackendPointer(cudnnBackendDescriptorType_ttype){status=cudnnBackendCreateDescriptor(type,&m_desc);}
    ~OpaqueBackendPointer(){cudnnBackendDestroyDescriptor(m_desc);};
    cudnnBackendDescriptor_tconst&
    get_backend_descriptor()const{
    returnm_desc;
    }
    cudnnStatus_t
    get_status()const{
    returnstatus;
    }
    bool
    is_good()const{
    returnstatus==CUDNN_STATUS_SUCCESS;
    }
    };

    usingManagedOpaqueDescriptor=std::shared_ptr<OpaqueBackendPointer>;

    staticManagedOpaqueDescriptor
    make_shared_backend_pointer(cudnnBackendDescriptorType_ttype){
    returnstd::make_shared<OpaqueBackendPointer>(type);
    }

    classBackendDescriptor{
    public:
    virtualstd::string
    describe()const=0;

    cudnnBackendDescriptor_t
    get_raw_desc()const{
    returnpointer->get_backend_descriptor();
    }

    cudnnStatus_t
    get_status()const{
    returnstatus;
    }

    void
    set_status(cudnnStatus_tconststatus_)const{
    status=status_;
    }

    void
    set_error(constchar*message)const{
    err_msg=message;
    }

    constchar*
    get_error()const{
    returnerr_msg.c_str();
    }

    ManagedOpaqueDescriptor
    get_desc()const{
    returnpointer;
    }

    cudnnStatus_t
    initialize_managed_backend_pointer(cudnnBackendDescriptorType_ttype){
    pointer=make_shared_backend_pointer(type);
    returnpointer->get_status();
    }

    protected:
    BackendDescriptor(ManagedOpaqueDescriptorpointer_,cudnnStatus_tstatus_,std::stringerr_msg_)
    :pointer(pointer_),status(status_),err_msg(err_msg_){}
    BackendDescriptor()=default;

    ManagedOpaqueDescriptorpointer;

    mutablecudnnStatus_tstatus=CUDNN_STATUS_SUCCESS;
    mutablestd::stringerr_msg;
    };
    }