Add Python API for Resizer (rsz)#9693
Add Python API for Resizer (rsz)#9693rohithsiddi wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a Python API for the Resizer (rsz) tool, which is a great step towards unifying the scripting interface across OpenROAD tools. The changes are well-structured, including build system updates, SWIG bindings, a Pythonic wrapper, tests, and documentation.
My review focuses on correctness and memory safety. I've found a few areas in the SWIG interface file (Resizer-py.i) where using smart pointers (std::unique_ptr) would improve exception safety and prevent potential memory leaks. These are detailed in the specific comments.
Overall, this is a solid contribution that significantly improves the usability of the Resizer from Python-based flows.
Note: Security Review is unavailable for this PR.
|
clang-tidy review says "All clean, LGTM! 👍" |
|
We should have a python API for rsz. This PR however tries to impose an interface the mirrors tcl which is not desirable. In Python we intend to expose an object-oriented API rather than a command oriented API. Please look at other modules for examples. |
|
Thanks for the feedback — understood. I’ll pivot the architecture to follow the object-oriented Python API pattern used in the other modules instead of the Tcl-like command wrappers. I'll study the preferred modules to align with your exact design patterns and push an updated structure to this branch shortly. |
- Add rsz_py SWIG module (Resizer-py.i) and wire into build/Main.cc - Add rsz_aux.py Python wrapper with unit conversions and docstrings - Add helpers.py and gcd_resize.py test mirroring gcd_resize.tcl - All RSZ commands exposed: dont_use, buffer_ports, repair_design, repair_timing, reporting, eliminate_dead_logic, etc. Signed-off-by: rohithsiddi <rohithsiddi7@gmail.com>
Signed-off-by: rohithsiddi <rohithsiddi7@gmail.com>
Signed-off-by: rohithsiddi <rohithsiddi7@gmail.com>
3bc3a95 to
3f83a1f
Compare
|
@maliberty I've addressed the review comments. Summary of the changes below. What I updated
Validation
|
| %include <std_string.i> | ||
| %include <std_vector.i> | ||
|
|
||
| %ignore rsz::Resizer::Resizer; |
There was a problem hiding this comment.
Why are there so many %ignore ?
There was a problem hiding this comment.
The higher %ignore count in Resizer-py.i compared to GRT/CTS is because
Resizer.hh is deeply integrated with OpenSTA internals:
- ~21 methods return/take STA collection types (NetSeq*, PinSet*, vector)
that have no Python SWIG typemaps — these are either ignored or replaced with
%extend wrappers (e.g. findFloatingNetsCount(), string-based repairSetup). - ~5 methods use output-by-reference params (Delay&, Slew&, map<Pin*, float>&)
not cleanly expressible in Python. - Internal/GUI hooks (postReadLiberty, setDebugGraphics, lib_data_) follow
the same pattern as GRT's init/initGui/setRenderer ignores.
GlobalRouter gets away with only 5 %ignores because its API mostly uses
odb::db* types already registered by the odb SWIG module.
Summary
Adds a Python API for the Resizer (rsz) tool so that flows can use
rsz_auxand therszmodule instead of Tcl for buffer_ports, repair_design, repair_timing, and related commands.Motivation
The Resizer had no Python bindings; Python flows had to call Tcl commands via
evalTclString. This change brings rsz in line with other tools (e.g. grt, cts, drt, pdn) that expose a Python API.Changes
rsz_pySWIG module insrc/rsz/src/CMakeLists.txtusingResizer-py.i; linked insrc/CMakeLists.txt;rszadded to Python module load list insrc/Main.cc.Resizer-py.iexposes snake_case wrappers for Resizer commands (opaque STA types; no Tcl-specific code).src/rsz/test/rsz_aux.pywith full command coverage, docstrings, and correct unit conversions (microns↔metres, ns↔seconds, percent↔fraction).helpers.pyandgcd_resize.pymirroring the existing Tcl test; run via CTest asrsz.gcd_resize.py.src/rsz/README.md.Testing
ctest -R "rsz.gcd_resize.py"— passctest -R "rsz"— all RSZ tests (Tcl + Python) pass