-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
fix bug in OpKernel register macro #3059
Conversation
@@ -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 { |
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.
Operator应该是不可比较的。operator==
应该改成 IsSameDevice
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.
这里比较的不是Operator,是OpKernelKey;目的是区分CPU和GPU对应着不同的OpKernel。
这里重载operator== 主要是当OpKernelKey作为unorder_map的key时,需要重载一个判断key是否相同的方法。
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.
这里会触发 GPUPlace(0) 与 GPUPlace(1) 对应不是一个OpKernel的bug
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.
是我看错了。不好意思。
能解释下这个bug的触发场景么,看起来之前编译就应该报错才对? |
@jacquesqiao REGISTER_OP_GPU_KERNEL/REGISTER_OP_CPU_KERNEL宏的展开分别在.cu 和 .cc里面,因此之前不会有冲突。 |
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.
LGTM!
No description provided.