Skip to content
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

[Rocm] fix test of random_crop_op & logsumexp #32824

Merged
merged 7 commits into from
May 19, 2021

Conversation

Ray2020BD
Copy link
Contributor

@Ray2020BD Ray2020BD commented May 10, 2021

PR types

Bug fixes

PR changes

OPs

Describe

[Rocm] fix test_random_crop_op ( under release-compile )
[Rocm] fix test_logsumexp
image
image

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@Ray2020BD Ray2020BD changed the title [Rocm] fix test of random_crop_op [Rocm] fix test of random_crop_op & simple_rnn_op May 13, 2021
@@ -69,6 +70,7 @@ HOSTDEVICE inline void StridedMemcpy(const T* x, const size_t* x_dims, T* out,
"expected to be 1, but got %ld. Please check input "
"value.",
i, rank, out_stride);
#endif
Copy link
Contributor

@qili93 qili93 May 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看了下你的分析文档,但当前这个修复方式不能满足OP要,我们OP修复的原则是

  • 不可以因为这两段代码会挂就不检查x_stride和out_stride,而是需要找到能工作的代码替换这两段代码,或者修复PADDLE_ENFORCE的逻辑使其能够工作

我们修复OP的目的不是为了单测可以通过,而是保证功能的正确性,当前的diff只是简单跳过了x_stride和out_stride的检查,不符合我们OP修复的目的。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,已修改。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个直接printf不符合paddle msg的标准,请参考这个文档写关于paddle的error msg
https://github.com/PaddlePaddle/Paddle/wiki/Paddle-Error-Message-Writing-Specification

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已删除

@Ray2020BD Ray2020BD changed the title [Rocm] fix test of random_crop_op & simple_rnn_op [Rocm] fix test of random_crop_op & simple_rnn_op & logsumexp May 17, 2021
@@ -69,6 +70,7 @@ HOSTDEVICE inline void StridedMemcpy(const T* x, const size_t* x_dims, T* out,
"expected to be 1, but got %ld. Please check input "
"value.",
i, rank, out_stride);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个直接printf不符合paddle msg的标准,请参考这个文档写关于paddle的error msg
https://github.com/PaddlePaddle/Paddle/wiki/Paddle-Error-Message-Writing-Specification

haozech
haozech previously approved these changes May 18, 2021
Copy link
Contributor

@haozech haozech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

dy = np.ones(1, dtype=self.dtype)
x = self.inputs['X']
y = self.outputs['Out']
return dy * np.exp(x - y)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里能解释一下为什么get_numeric_gradient得到的结果在ROCm上无法对齐,需要定义user_defined_grads呢?CUDA上为什么可以直接使用get_numeric_gradient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logsumexp这个op本身运算出来的analytic_grads是没问题的,有问题的是numeric_grads(cuda下该计算没问题),所以干脆自己计算numeric_grads

) else np.float64
self.sequence_length = None if fluid.core.is_compiled_with_rocm(
) else np.array(
[12, 11, 10, 9, 8], dtype=np.int32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MIOPEN不支持sequence_length的话,SimpleRNN的API也同样需要修改,对于sequence_length非空的输入需要抛出正确的error msg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simpleRNN的修改以及该单测的修改从本pr中删除,将和其他rnn单测修改统一放到其他的pr中。

if self.is_bidirec:
for i in range(0, len(flat_w), 4):
flat_w[i + 1], flat_w[i + 2] = flat_w[i + 2], flat_w[i + 1]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里能解释一下为什么需要对flat_w的数据做交换吗?是miopenSetRNNDescriptor_V2 里面的 miopenRNNbidirection 和 cudnnSetRNNDescriptor_v6 的 CUDNN_BIDIRECTIONAL 的行为不一致?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

miopen相关api的实现中,layout并没有和cuda相关pai对齐,需要手动调节。

@Ray2020BD Ray2020BD changed the title [Rocm] fix test of random_crop_op & simple_rnn_op & logsumexp [Rocm] fix test of random_crop_op & logsumexp May 18, 2021
Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for op benchmark ci

Copy link
Contributor

@qili93 qili93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qili93 qili93 merged commit aa4a56f into PaddlePaddle:develop May 19, 2021
@Ray2020BD Ray2020BD deleted the rocm_fix_random_crop branch May 19, 2021 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants