Skip to content

Conversation

@gouzil
Copy link
Member

@gouzil gouzil commented Apr 5, 2025

PR Category

Performance Optimization

PR Types

Performance

Description

  • NumpyDtypeMatchGuard -> NumPyDtypeMatchGuard
  • 新增 WeakRefMatchGuard 用于对自身进行弱引用,在 check 的时候检查自身是否为 None,并且于传入值相等
@gouzil gouzil requested a review from Copilot April 5, 2025 15:46
@gouzil gouzil requested review from SigureMo and zrr1999 as code owners April 5, 2025 15:46
@paddle-bot
Copy link

paddle-bot bot commented Apr 5, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Apr 5, 2025
Copy link
Contributor

Copilot AI left a 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(): 
StringifiedExpression(
FasterStringifiedExpression(
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.

Py_INCREF(expected_);
}

~PyObjMatchGuard() override { Py_DECREF(expected_); }
Copy link
Member

Choose a reason for hiding this comment

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

好家伙,真就直接不 INCREF 存裸指针是吧,话说 weakref 本质上就是存不加引用计数的裸指针吗?

另外,如果是这样的话,使用的时候得检查下是否还存在,如果不存在的话记得报个错

PyObject* expected_;
};

class PyObjMatchGuard : public GuardBase {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class PyObjMatchGuard : public GuardBase {
class WeakRefMatchGuard : public GuardBase {

就叫这个吧,和 ValueMatchGuard 作区分

}

#if PY_3_13_PLUS
PyObject* referent = NULL;
Copy link
Member

@SigureMo SigureMo Apr 7, 2025

Choose a reason for hiding this comment

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

referent 是啥,引用吗?应该是 reference 吧?一般直接写 ref 就可以吧

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo merged commit 07202dc into PaddlePaddle:develop Apr 7, 2025
33 checks passed
@SigureMo SigureMo deleted the feat/add_PyObjMatchGuard branch April 7, 2025 09:57
YqGe585 pushed a commit to YqGe585/Paddle that referenced this pull request May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

2 participants