NVIDIA / cudnn-frontend

cudnn_frontend provides a c++ wrapper for the cudnn backend API and samples on how to use it
MIT License
423 stars 86 forks source link

Grouped Convolution with frontend API #114

Open jimgao1 opened 1 week ago

jimgao1 commented 1 week ago

While in cuDNN's cudnnConvolutionForward() there is the groupCount option for grouped convolutions, is there such an API available in the cuDNN frontend for the conv_fprop, conv_wgrad and conv_dgrad operations?

Anerudhan commented 4 days ago

Hi @jimgao1 ,

Thanks for your question.

A graph like

    int64_t group_count = 2;
    auto X = graph->tensor(fe::graph::Tensor_attributes()
                               .set_name("image")
                               .set_dim({n, c, h, w})
                               .set_stride({c * h * w, 1, c * w, c}));

    auto W = graph->tensor(fe::graph::Tensor_attributes()
                               .set_name("filter")
                               .set_dim({k, c/group_count, r, s})
                               .set_stride({c/group_count * r * s, 1, c/group_count * s, c/group_count}));

    auto conv_options =
        fe::graph::Conv_fprop_attributes().set_padding({0, 0}).set_stride({1, 1}).set_dilation({1, 1});
    auto Y = graph->conv_fprop(X, W, conv_options);

can be used to set the group count.

It is inferred based on the X and W sizes. Hope this helps

Thanks, Anerudhan