MIOpen icon indicating copy to clipboard operation
MIOpen copied to clipboard

The behavior of miopenConvolutionForwardBias

Open scarsty opened this issue 2 years ago • 4 comments

I have tested some cases and found the behavior of this function is:

y = (alpha + beta) * y + alpha * bias

This make me very confused. In cudnn, function "cudnnAddTensor" is used to add bias, and the behavior of that is easy to understand:

C = alpha * A + beta * C 

scarsty avatar Oct 02 '23 15:10 scarsty

Hello @scarsty the miopenConvolutionForwardBias performs the common Conv + Bias operation.

y = x * w + b 

where x is the input, w is the weights, b is bias with as many elements as there are output channels and * represents convolution. Recall that alpha and beta are restricted to 1 and 0 in MIOpen.

In light of the above, I am not sure I understand what you mean by the following:

y = (alpha + beta) * y + alpha * bias

JehandadKhan avatar Oct 12 '23 15:10 JehandadKhan

This function only perform adding bias, no conv. The inputs have only y and b, no x.

scarsty avatar Oct 12 '23 17:10 scarsty

@scarsty Do you still need assistance with this ticket? If not, please close the ticket. Thanks!

ppanchad-amd avatar Jun 25 '24 18:06 ppanchad-amd

@scarsty Do you still need assistance with this ticket? If not, please close the ticket. Thanks!

I want to hear the reason to design this function like this from the miopen team

scarsty avatar Jul 03 '24 09:07 scarsty

@scarsty Hi, the behavior of miopenConvolutionForwardBias is what you observed. As @JehandadKhan mentioned, when alpha = 1 and beta = 0, you have y = y + bias which satisfy the functions purpose:"Calculate element-wise scale and shift of a tensor via a bias tensor." https://rocm.docs.amd.com/projects/MIOpen/en/latest/doxygen/html/group__convolutions.html#ga8e445590bd57cd0038324943791a9b4a. If possible, can you provide more context about your question?

huanrwan-amd avatar Oct 16 '24 21:10 huanrwan-amd