CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[SOT][Faster Guard] support NumpyDtypeMatchGuard
#71900
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 NumpyDtypeMatchGuard
#71900
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.
Pull Request Overview
This PR adds support for NumpyDtypeMatchGuard to check the consistency of numpy dtypes, enhancing performance guard validation.
- Added unit tests for NumpyDtypeMatchGuard in the test suite.
- Updated guard creation in the stringified guard generation to use FasterStringifiedExpression for performance improvements.
Reviewed Changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/sot/test_faster_guard.py | Added tests for checking numpy dtype consistency via NumpyDtypeMatchGuard |
python/paddle/jit/sot/opcode_translator/executor/variables/basic.py | Replaced StringifiedExpression with FasterStringifiedExpression when constructing dtype and value guards to support the performance optimization |
Files not reviewed (3)
- paddle/fluid/pybind/jit.cc: Language not supported
- paddle/fluid/pybind/sot/guards.cc: Language not supported
- paddle/fluid/pybind/sot/guards.h: Language not supported
Comments suppressed due to low confidence (2)
test/sot/test_faster_guard.py:137
- Consider adding additional test cases for non-numpy inputs or invalid types to further ensure that NumpyDtypeMatchGuard correctly rejects unsupported types.
self.assertTrue(guard_numpy_dtype.check(np.int32()))
python/paddle/jit/sot/opcode_translator/executor/variables/basic.py:1334
- Ensure that FasterStringifiedExpression provides equivalent behavior to the previous StringifiedExpression in the context of constructing dtype guards. If there are any subtle differences, update the related code or tests accordingly.
dtype_guard = FasterStringifiedExpression(
self.assertTrue(guard_numpy_dtype.check(np.array(1, dtype=np.int32))) | ||
self.assertTrue(guard_numpy_dtype.check(np.int32())) | ||
self.assertFalse(guard_numpy_dtype.check(np.array(1, dtype=np.int64))) | ||
self.assertFalse(guard_numpy_dtype.check(np.float32())) |
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.
测一下 np.bool_
呢?
@@ -137,6 +137,7 @@ def test_numpy_dtype_match_guard(self): | |||
self.assertTrue(guard_numpy_dtype.check(np.int32())) | |||
self.assertFalse(guard_numpy_dtype.check(np.array(1, dtype=np.int64))) | |||
self.assertFalse(guard_numpy_dtype.check(np.float32())) | |||
self.assertFalse(guard_numpy_dtype.check(np.bool_())) |
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.
别 assertFalse
呀,换一个 guard 实例,测个 assertTrue
的
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.
Pull Request Overview
This PR adds performance optimizations for the SOT guard system by introducing support for NumpyDtypeMatchGuard, which checks that two numpy dtypes are equivalent.
- Added tests in test/sot/test_faster_guard.py to verify NumpyDtypeMatchGuard behavior
- Updated guard initialization in python/paddle/jit/sot/opcode_translator/executor/variables/basic.py to use FasterStringifiedExpression with NumpyDtypeMatchGuard and ValueMatchGuard consistently
Reviewed Changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/sot/test_faster_guard.py | Adds tests to validate the behavior of NumpyDtypeMatchGuard with various numpy types. |
python/paddle/jit/sot/opcode_translator/executor/variables/basic.py | Modifies the stringified guard construction to use FasterStringifiedExpression along with the new NumpyDtypeMatchGuard. |
Files not reviewed (3)
- paddle/fluid/pybind/jit.cc: Language not supported
- paddle/fluid/pybind/sot/guards.cc: Language not supported
- paddle/fluid/pybind/sot/guards.h: Language not supported
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.
* [SOT][Faster Guard] support `NumpyDtypeMatchGuard` * fix review * fix review and test build * test build * fix build error * use pyobj * add todo
* [SOT][Faster Guard] support `NumpyDtypeMatchGuard` * fix review * fix review and test build * test build * fix build error * use pyobj * add todo
PR Category
Performance Optimization
PR Types
Performance
Description
NumpyDtypeMatchGuard
支持,用于检查两个 numpy dtype 是否一致