CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[SOT][Faster Guard] support object_equal_stringified_guard
#72081
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
[SOT][Faster Guard] support object_equal_stringified_guard
#72081
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
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.
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
test/sot/test_faster_guard.py:206
- [nitpick] The function 'test_func' is redefined in the same scope, which may cause confusion in the test. Consider using a distinct name (e.g., 'test_func_redefined') for clarity.
def test_func():
f"{obj_free_var_name}() is not None and {{}} == {obj_free_var_name}()", | ||
paddle.framework.core.PyObjMatchGuard(self.get_py_value()), |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
paddle/fluid/pybind/sot/guards.h
Outdated
Py_INCREF(expected_); | ||
} | ||
|
||
~PyObjMatchGuard() override { Py_DECREF(expected_); } |
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.
好家伙,真就直接不 INCREF 存裸指针是吧,话说 weakref
本质上就是存不加引用计数的裸指针吗?
另外,如果是这样的话,使用的时候得检查下是否还存在,如果不存在的话记得报个错
paddle/fluid/pybind/sot/guards.h
Outdated
@@ -236,6 +236,20 @@ class NumPyArrayValueMatchGuard : public GuardBase { | |||
PyObject* expected_; | |||
}; | |||
|
|||
class PyObjMatchGuard : public GuardBase { |
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.
class PyObjMatchGuard : public GuardBase { | |
class WeakRefMatchGuard : public GuardBase { |
就叫这个吧,和 ValueMatchGuard
作区分
paddle/fluid/pybind/sot/guards.cc
Outdated
} | ||
|
||
#if PY_3_13_PLUS | ||
PyObject* referent = NULL; |
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.
referent
是啥,引用吗?应该是 reference
吧?一般直接写 ref 就可以吧
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.
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.
PR Category
Performance Optimization
PR Types
Performance
Description
NumpyDtypeMatchGuard
->NumPyDtypeMatchGuard
WeakRefMatchGuard
用于对自身进行弱引用,在 check 的时候检查自身是否为 None,并且于传入值相等