Add LeakyRelu MKLDNN support#18656
Conversation
123e958 to
d5aad2a
Compare
|
This PR is to fix #17654 |
test=develop
d5aad2a to
2d47bd7
Compare
| // input1: X | ||
| op->SetInput("X", Input("X")); | ||
| // input2: Out | ||
| op->SetInput("Out", Input("Out")); |
There was a problem hiding this comment.
It's because MKLDNN activation function grad functor expects to have input called "Out" to create hash key for caching. Without this change activation grad test crashed.
There was a problem hiding this comment.
create hash key for caching
Why should we add this input only for creating hash key, since this op doesn't need this input indeed?
There was a problem hiding this comment.
Well, I did it as it felt like the fastest way to get around this error but you are right, this Input unneccesary so I will change the way MKLDNN key is generated.
There was a problem hiding this comment.
Thanks very much! If we change the input, then many trained models before will fail after update the develop branch.
There was a problem hiding this comment.
@luotao1 Could you please explain why trained model will fail when we add additional input to grad op? This is just leaky relu grad op , so this grad op is not holding any params, so why extending inputs for grad op would cause failure? I'm asking because as described in #17960 I would like to extend all mkl-dnn grad ops to have X as input of grad ops as mkl-dnn backward implementations are requiring X to compute backward/grad.
There was a problem hiding this comment.
@jczaja @grygielski
Discussed with @phlrain, it's OK to add additional input to grad op as this PR does. But we could not addinput() in OpMaker().
There was a problem hiding this comment.
Ok, so my sollution is acceptable? Because during key generation we would have to add another cases to check if specific operator grad has only X input what causes additional problems when adding MKLDNN support for further activations.
|
Do you have any benchmark result for this mkldnn op on face model in #17654 |
|
Got it. I will check it tomorrow |
|
Thanks very much for your contribution.
|
|
Paddle/paddle/fluid/framework/ir/is_test_pass.cc Lines 27 to 35 in 067ed70 Do you need to update the op_list in is_test_pass?
|
|
I guess leaky_relu is already there |
But I don't see it. @grygielski @jczaja |
|
What about 3rd row, 2nd column in op_list you quoted in your last comment? |
|
Sorry, I miss finding it. |
LeakyRelu MKLDNN support along with unit tests have been added.