cudnn_frontend_Reorder_Tensor.h
algorithm
array
functional
memory
sstream
iostream
utility
cudnn_frontend_Tensor.h
cudnn_frontend_ConvDesc.h
cudnn_frontend.h
functional
cudnn.h
string
cudnn_frontend_Logging.h
cudnn_frontend_Tensor.h
exception
fstream
ostream
cudnn_frontend_Reorder_Tensor.h
vector
cudnn_frontend_ConvDesc.h
cudnn_backend.h
utility
array
sstream
iostream
algorithm
cstring
cudnn_frontend_utils.h
memory
cudnn_backend_base.h
cudnn_frontend_get_plan.h
cudnn_frontend_EngineConfigGenerator.h
cudnn_frontend_Reorder_Tensor.h
cudnn_frontend.h
cudnn_frontend_find_plan.h
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<algorithm>
    #include<array>
    #include<functional>
    #include<memory>
    #include<sstream>
    #include<iostream>
    #include<utility>

    #include"cudnn_frontend_Tensor.h"
    #include"cudnn_frontend_ConvDesc.h"

    namespacecudnn_frontend{

    staticcudnnStatus_t
    cudnnReorderFilterAndBiasInt8x32(cudnnHandle_thandle,
    constTensor_v8&tensor,
    constConvDesc_v8&conv_desc,
    void*dev_filter_ptr,void*reordered_filter_ptr,
    void*dev_bias_ptr,void*reordered_bias_ptr){

    autocudnn_status=CUDNN_STATUS_SUCCESS;

    if(dev_filter_ptr&&reordered_filter_ptr==nullptr){
    returnCUDNN_STATUS_BAD_PARAM;
    }
    if(dev_bias_ptr&&reordered_bias_ptr==nullptr){
    returnCUDNN_STATUS_BAD_PARAM;
    }

    cudnnFilterDescriptor_tfilterDesc=nullptr;

    cudnn_status=cudnnCreateFilterDescriptor(&filterDesc);
    if(cudnn_status!=CUDNN_STATUS_SUCCESS){returncudnn_status;}

    autoconv_dims=conv_desc.getDimensionCount();
    autotensor_dims=tensor.getDimensionCount();
    autonon_shape_dims=tensor_dims-conv_dims;

    if(non_shape_dims!=2&&non_shape_dims!=3){
    returnCUDNN_STATUS_BAD_PARAM;
    }

    if(conv_dims!=2&&conv_dims!=3){
    returnCUDNN_STATUS_BAD_PARAM;
    }

    intfilter_dims_[5]={1,1,1,1,1};
    int64_tconst*filter_dims=tensor.getDimArray();
    filter_dims_[0]=static_cast<int>(filter_dims[0]);//n
    filter_dims_[1]=static_cast<int>((non_shape_dims==2)?filter_dims[1]:filter_dims[2])*32;//c
    filter_dims_[2]=static_cast<int>((non_shape_dims==2)?filter_dims[2]:filter_dims[3]);//d/h
    filter_dims_[3]=static_cast<int>((non_shape_dims==2)?filter_dims[3]:filter_dims[4]);//h/w
    if(conv_dims==3){
    filter_dims_[4]=static_cast<int>((non_shape_dims==2)?filter_dims[4]:filter_dims[5]);//w
    }

    cudnn_status=cudnnSetFilterNdDescriptor(filterDesc,CUDNN_DATA_INT8x32,CUDNN_TENSOR_NCHW_VECT_C,conv_dims+2,filter_dims_);

    if(cudnn_status!=CUDNN_STATUS_SUCCESS){returncudnn_status;}

    intreorderBias=(dev_bias_ptr!=nullptr);

    cudnn_status=cudnnReorderFilterAndBias(handle,
    filterDesc,CUDNN_DEFAULT_REORDER,dev_filter_ptr,reordered_filter_ptr,reorderBias,dev_bias_ptr,reordered_bias_ptr);

    cudnnDestroyFilterDescriptor(filterDesc);
    returncudnn_status;
    }
    }