cudnnBackendGetAttribute elementCount confusion

Hello! I’m fairly confused about the use of the elementCount parameter in the cudnnBackendGetAttribute function. Intuitively, I’d assume it’s used purely as a return value to store the total number of attributes for the descriptor. However, in the cudnn documentation it is marked as an input.

Is this just a typo in the docs, or can this value also be used as an input?

1 Like

Hi @brian223 ,
Have reported this to team, and waiting to hear from them.
Will confirm on teh same.

Thanks

Further to the above, I found a case where the elementCount is different depending on whether you set the requestedElementCount to zero or to another value. This feels like a bug.

i64 num_results = 0;
cudnnBackendGetAttribute(query, CUDNN_ATTR_ENGINEHEUR_RESULTS,
    CUDNN_TYPE_BACKEND_DESCRIPTOR, 0, &num_results, 0);

//...  initialize an array of results, called `query results`

i64 real_num_results = 0;
cudnnBackendGetAttribute(query, CUDNN_ATTR_ENGINEHEUR_RESULTS,
    CUDNN_TYPE_BACKEND_DESCRIPTOR, num_results, &real_num_results, query_results);

for a simple graph consisting of a single float32 matmul, this gives me 9 for num_results, but 3 for real_num_results.

Is there any update on this?

I’d assume that since you have to pass a pointer it can be considererd “input”, however looking at the overall state of the docs etc., it could also just be a typo (Looking at you CUDNN_ATTR_OPERATION_BN_FINALIZE_EXP_AVERATE_FACTOR_DESC)

However, I can’t see the problem here. ElementCount just tells you the number of elements a certain attribute of a certain descriptor has.
I use the elementCount to read exactly this. First I send (requestElements 0, int* elementCount, null) so elementCount equals the number of elements (i.e. the number of EngineConfigDescriptors from the HeuerDescriptor). Then I can prepare the array to read the EngineConfigDescriptors.
If it returns 0 then there are no elements.

Edit: To be fair CUDNN_ATTR_OPERATION_BN_FINALIZE_EXP_AVERATE_FACTOR_DESC is also written like this in the cuddn_graph.h file.