Repository navigation
[Accuracy diff No.95] Fix accuracy diff for paddle.incubate.nn.functional.fused_rotary_position_embedding API #453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -478,13 +478,15 @@ def gen_paddle_output_and_output_grad(self, outputs): | |||||||||||
| if isinstance(outputs, paddle.Tensor): | ||||||||||||
| result_outputs.append(outputs) | ||||||||||||
| elif isinstance(outputs, list) and len(outputs) > 0 and isinstance(outputs[0], paddle.Tensor): | ||||||||||||
| result_outputs = outputs | ||||||||||||
| for output in outputs: | ||||||||||||
| if (output is not None) and (not isinstance(output, paddle.Tensor) or output.size != 0): | ||||||||||||
| result_outputs.append(output) | ||||||||||||
|
Comment on lines
+481
to
+483
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| elif isinstance(outputs, paddle.autograd.autograd.Hessian) or \ | ||||||||||||
| isinstance(outputs, paddle.autograd.autograd.Jacobian): | ||||||||||||
| result_outputs.append(outputs[:]) | ||||||||||||
| elif isinstance(outputs, tuple): | ||||||||||||
| for output in outputs: | ||||||||||||
| if isinstance(output, paddle.Tensor): | ||||||||||||
| if isinstance(output, paddle.Tensor) and output.size != 0: | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个是否会影响 0size 的测试? |
||||||||||||
| result_outputs.append(output) | ||||||||||||
| elif isinstance(output, list): | ||||||||||||
| for item in output: | ||||||||||||
|
|
@@ -500,6 +502,8 @@ def gen_paddle_output_and_output_grad(self, outputs): | |||||||||||
| isinstance(output[0], paddle.autograd.autograd.Jacobian)): | ||||||||||||
| for lazy_obj in output: | ||||||||||||
| result_outputs.append(lazy_obj[:]) | ||||||||||||
| elif output is None or output.size == 0: | ||||||||||||
| continue | ||||||||||||
| else: | ||||||||||||
| raise ValueError("outputs format not support") | ||||||||||||
| # elif isinstance(output, list) and len(output) > 0 and isinstance(output[0], paddle.Tensor): | ||||||||||||
|
|
@@ -510,6 +514,8 @@ def gen_paddle_output_and_output_grad(self, outputs): | |||||||||||
| result_outputs_grads = [] | ||||||||||||
| if len(self.outputs_grad_numpy) == 0: | ||||||||||||
| for output in result_outputs: | ||||||||||||
| if output is None or output.size == 0: | ||||||||||||
| continue | ||||||||||||
|
Comment on lines
+517
to
+518
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 此处应该是冗余的 |
||||||||||||
| dtype = str(output.dtype).split(".")[-1] | ||||||||||||
| if USE_CACHED_NUMPY: | ||||||||||||
| dtype = "float32" if dtype == "bfloat16" else dtype | ||||||||||||
|
|
@@ -522,6 +528,8 @@ def gen_paddle_output_and_output_grad(self, outputs): | |||||||||||
| numpy_tensor = (numpy.random.random(output.shape) - 0.5).astype(dtype) | ||||||||||||
| self.outputs_grad_numpy.append(numpy_tensor) | ||||||||||||
| for i, numpy_tensor in enumerate(self.outputs_grad_numpy): | ||||||||||||
| if numpy_tensor is None or numpy_tensor.size == 0: | ||||||||||||
| continue | ||||||||||||
|
Comment on lines
+531
to
+532
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同冗余 |
||||||||||||
| dtype = str(result_outputs[i].dtype).split(".")[-1] | ||||||||||||
| result_output_grad = paddle.to_tensor( | ||||||||||||
| numpy_tensor, | ||||||||||||
|
|
@@ -571,11 +579,15 @@ def gen_torch_output_and_output_grad(self, outputs): | |||||||||||
| elif isinstance(outputs, torch.Size): | ||||||||||||
| result_outputs.append(torch.tensor(outputs)) | ||||||||||||
| elif isinstance(outputs, list) and len(outputs) > 0 and isinstance(outputs[0], torch.Tensor): | ||||||||||||
| result_outputs = outputs | ||||||||||||
| for output in outputs: | ||||||||||||
| if output is not None: | ||||||||||||
| result_outputs.append(output) | ||||||||||||
|
Comment on lines
+582
to
+584
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| elif isinstance(outputs, tuple): | ||||||||||||
| for output in outputs: | ||||||||||||
| if isinstance(output, torch.Tensor): | ||||||||||||
| result_outputs.append(output) | ||||||||||||
| elif output is None: | ||||||||||||
| continue | ||||||||||||
| else: | ||||||||||||
| raise ValueError("outputs format not support") | ||||||||||||
| # elif isinstance(output, list) and len(output) > 0 and isinstance(output[0], torch.Tensor): | ||||||||||||
|
|
@@ -586,6 +598,8 @@ def gen_torch_output_and_output_grad(self, outputs): | |||||||||||
| result_outputs_grads = [] | ||||||||||||
| if len(self.outputs_grad_numpy) == 0: | ||||||||||||
| for output in result_outputs: | ||||||||||||
| if output is None: | ||||||||||||
| continue | ||||||||||||
| dtype = str(output.dtype).split(".")[-1] | ||||||||||||
| if USE_CACHED_NUMPY: | ||||||||||||
| dtype = "float32" if dtype == "bfloat16" else dtype | ||||||||||||
|
|
@@ -598,6 +612,8 @@ def gen_torch_output_and_output_grad(self, outputs): | |||||||||||
| numpy_tensor = (numpy.random.random(output.shape) - 0.5).astype(dtype) | ||||||||||||
| self.outputs_grad_numpy.append(numpy_tensor) | ||||||||||||
| for i, numpy_tensor in enumerate(self.outputs_grad_numpy): | ||||||||||||
| if numpy_tensor is None: | ||||||||||||
| continue | ||||||||||||
|
Comment on lines
+615
to
+616
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同冗余 |
||||||||||||
| dtype = str(result_outputs[i].dtype).split(".")[1] | ||||||||||||
| result_output_grad = torch.tensor( | ||||||||||||
| numpy_tensor, | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么需要检查 paddle_out.size == 0 呢?