Skip to content

Commit

Permalink
- Added basic changes for elementwise_add_grad bf16
Browse files Browse the repository at this point in the history
lint

- fix to UT

- removed uneeded error margin redefining
  • Loading branch information
jczaja committed Feb 5, 2021
1 parent aab3a30 commit 3619ae2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ REGISTER_OP_KERNEL(
ops::EltwiseMKLDNNKernel<uint8_t, dnnl::algorithm::binary_add>)

REGISTER_OP_KERNEL(elementwise_add_grad, MKLDNN, ::paddle::platform::CPUPlace,
ops::EltwiseAddMKLDNNGradKernel<paddle::platform::bfloat16>,
ops::EltwiseAddMKLDNNGradKernel<float>)
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ def setUp(self):
self.axis = -1

self.generate_data()
self.x_bf16 = convert_float_to_uint16(self.x)
self.y_bf16 = convert_float_to_uint16(self.y)

self.inputs = {
'X': convert_float_to_uint16(self.x),
'Y': convert_float_to_uint16(self.y)
'X': self.x_bf16,
'Y': self.y_bf16
}
self.attrs = {'axis': self.axis, 'use_mkldnn': self.use_mkldnn}
self.outputs = {'Out': convert_float_to_uint16(self.out)}
Expand All @@ -45,14 +48,27 @@ def generate_data(self):
def test_check_output(self):
self.check_output_with_place(core.CPUPlace())

# elementwise_add grad is just passing upper gradients to either X or Y or both
def test_check_grad_normal(self):
pass
self.check_grad(["X", "Y"],
"Out",
check_dygraph=False,
user_defined_grads=[self.x_bf16, self.x_bf16],
user_defined_grad_outputs=[self.x_bf16])

def test_check_grad_ingore_x(self):
pass
self.check_grad(["Y"],
"Out",
check_dygraph=False,
user_defined_grads=[self.y_bf16],
user_defined_grad_outputs=[self.y_bf16])

def test_check_grad_ingore_y(self):
pass
self.check_grad(["X"],
"Out",
check_dygraph=False,
user_defined_grads=[self.x_bf16],
user_defined_grad_outputs=[self.x_bf16])


if __name__ == '__main__':
Expand Down

0 comments on commit 3619ae2

Please sign in to comment.