gemini-code-assist[bot] commented on code in PR #19822:
URL: https://github.com/apache/tvm/pull/19822#discussion_r3431063548
##########
python/tvm/relax/frontend/nn/extern.py:
##########
@@ -306,13 +308,13 @@ def get_includes(tvm_pkg: list[str] | None = None) ->
list[Path]:
includes : List[pathlib.Path]
The list of include paths.
"""
- tvm_home = SourceModule.tvm_home()
results = [
- tvm_home / "include",
- tvm_home / "3rdparty/tvm-ffi/include",
- tvm_home / "3rdparty/tvm-ffi/3rdparty/dlpack/include",
+ Path(libinfo.find_include_path()),
+ Path(tvm_ffi.libinfo.find_include_path()),
+ Path(tvm_ffi.libinfo.find_dlpack_include_path()),
]
if tvm_pkg:
+ tvm_home = SourceModule.tvm_home()
for relative in tvm_pkg:
results.append(tvm_home / "3rdparty" / relative)
for path in results:
Review Comment:

The include paths resolved from `libinfo` and `tvm_ffi.libinfo` can
sometimes overlap or be identical depending on the environment setup (e.g., in
monolithic or developer builds). To prevent redundant compiler `-I` flags and
duplicate assertion checks, we should deduplicate the list of paths while
preserving their search order. Using `dict.fromkeys` is an efficient and
order-preserving way to achieve this in Python 3.7+.
```suggestion
results = [
Path(libinfo.find_include_path()),
Path(tvm_ffi.libinfo.find_include_path()),
Path(tvm_ffi.libinfo.find_dlpack_include_path()),
]
if tvm_pkg:
tvm_home = SourceModule.tvm_home()
for relative in tvm_pkg:
results.append(tvm_home / "3rdparty" / relative)
results = list(dict.fromkeys(results))
for path in results:
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]