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

fix bug in OpKernel register macro #3059

Merged
merged 2 commits into from
Jul 27, 2017

Conversation

QiJune
Copy link
Member

@QiJune QiJune commented Jul 25, 2017

No description provided.

@QiJune QiJune requested a review from reyoung July 25, 2017 16:03
@QiJune QiJune requested a review from jacquesqiao July 26, 2017 06:03
@@ -199,7 +199,9 @@ class OperatorWithKernel : public OperatorBase {
place_ = dev_ctx.GetPlace();
}

bool operator==(const OpKernelKey& o) const { return place_ == o.place_; }
bool operator==(const OpKernelKey& o) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Operator应该是不可比较的。operator==应该改成 IsSameDevice

Copy link
Member Author

Choose a reason for hiding this comment

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

这里比较的不是Operator,是OpKernelKey;目的是区分CPU和GPU对应着不同的OpKernel。
这里重载operator== 主要是当OpKernelKey作为unorder_map的key时,需要重载一个判断key是否相同的方法。

Copy link
Member Author

Choose a reason for hiding this comment

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

这里会触发 GPUPlace(0) 与 GPUPlace(1) 对应不是一个OpKernel的bug

Copy link
Collaborator

Choose a reason for hiding this comment

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

是我看错了。不好意思。

@jacquesqiao
Copy link
Member

能解释下这个bug的触发场景么,看起来之前编译就应该报错才对?

@QiJune
Copy link
Member Author

QiJune commented Jul 27, 2017

@jacquesqiao REGISTER_OP_GPU_KERNEL/REGISTER_OP_CPU_KERNEL宏的展开分别在.cu 和 .cc里面,因此之前不会有冲突。

Copy link
Member

@jacquesqiao jacquesqiao left a comment

Choose a reason for hiding this comment

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

LGTM!

@QiJune QiJune merged commit f96e215 into PaddlePaddle:develop Jul 27, 2017
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.

3 participants