Skip to content

Lay foundation for namedisl + add set-likes and operations between them#5

Open
a-alveyblanc wants to merge 39 commits into
inducer:mainfrom
a-alveyblanc:initial-functionality
Open

Lay foundation for namedisl + add set-likes and operations between them#5
a-alveyblanc wants to merge 39 commits into
inducer:mainfrom
a-alveyblanc:initial-functionality

Conversation

@a-alveyblanc
Copy link
Copy Markdown
Contributor

  • Adds necessary pieces for named ISL object representation (base classes, types, utilities)
  • Adds representation for set-likes (Sets, Maps, BasicSets, BasicMaps)
  • Adds minimal set of operations between set-likes for use with loopy

Replaces #2

Comment thread namedisl/__init__.py Outdated
Comment thread namedisl/__init__.py Outdated
Comment thread namedisl/__init__.py Outdated
all_names += sorted(all_inp_names)
all_names += sorted(all_param_names)

name_to_dim: NameToDim = {}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Dict comprehension

Comment thread namedisl/__init__.py Outdated
return constantdict(name_to_dim), constantdict(dt_to_names)


def _align_obj(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Align wants a chunker!

Comment thread namedisl/__init__.py Outdated
_name_to_dim: NameToDim

# used to reconstruct ISL object
_dimtype_to_names: DimTypeToNames
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Make reconstruction (completely) generic.

Comment thread namedisl/__init__.py Outdated
@a-alveyblanc
Copy link
Copy Markdown
Contributor Author

Tests are finally passing. I think this is ready for (automated?) review. Foundation was handwritten, i.e. basic functionality in NamedIslObject and subclasses. Additional functionality was written by Codex as needed during development of inducer/loopy#970.

All commits can be squashed into a single commit.

@a-alveyblanc a-alveyblanc marked this pull request as ready for review May 21, 2026 19:33
Comment thread doc/ref.rst
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe keep the top-level .rsts to only module references?

Comment thread namedisl/set_like.py
return super().dim(dim_type)

@overload
def __and__(self: BasicMap, other: BasicMap | Map) -> BasicMap | Map: ...
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think unions on output will be un-ergonomic for user code.

Comment thread namedisl/set_like.py

@final
@dataclass(frozen=True, eq=False)
class BasicSet(_NamedIslSetLike):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
class BasicSet(_NamedIslSetLike):
class BasicSet(_NamedIslSetLike):
# NB: Internally stored as a Set, not BasicSet

Copy link
Copy Markdown

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.

Pull request overview

This PR establishes the core infrastructure for namedisl by introducing name-aware wrappers around islpy set/map objects and expression objects, along with initial operations, tests, and Sphinx documentation to make the project usable with downstream consumers (e.g. loopy).

Changes:

  • Add core metadata/alignment/reconstruction machinery for name-based dimension handling.
  • Introduce name-aware wrappers for set-likes (Set/Map + basic variants) and expression-likes (Aff/PwAff/QPolynomial/PwQPolynomial + multi-aff variants).
  • Add an initial pytest suite and expand Sphinx docs/reference pages.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pyproject.toml Adds ruff per-file ignores for exec usage (doc build/tests).
.gitignore Ignores .codex.
namedisl/core.py Implements metadata model, alignment, reconstruction, and name manipulation helpers.
namedisl/set_like.py Adds Set/Map wrappers and key set-like operations (union/intersection/subset/composition/etc.).
namedisl/expression_like.py Adds wrappers for isl expression objects with basic arithmetic ops + name alignment.
namedisl/init.py Exposes the new public API surface via make_* functions and wrapper classes.
namedisl/test/utils_for_tests.py Test helpers for generating randomized named sets/maps.
namedisl/test/test_namedisl.py Tests for metadata behavior (names, rename/move/add dims, reconstruction).
namedisl/test/test_set_like.py Tests for set/map operations, alignment, comparisons, and edge cases.
namedisl/test/test_expression_like.py Tests for expression wrapper construction and arithmetic behavior.
doc/index.rst Adds introductory project description and includes internal docs in the toctree.
doc/ref.rst Adds API reference entries for the new wrappers/functions.
doc/internals.rst Adds internal developer reference page for core helpers.
doc/conf.py Updates Sphinx configuration loading and autodoc settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread namedisl/core.py

new_name_to_dim, new_dimtype_to_names = self._metadata_from_chunk_names(
chunk_names,
has_inputs=True,
Comment thread namedisl/set_like.py
Comment on lines +397 to +399
def __eq__(self, other: object) -> bool:
if not isinstance(other, type(self)):
raise TypeError("Objects are not of the same type")
Comment thread namedisl/set_like.py
"""
if isinstance(names_to_eliminate, str):
names_to_eliminate = [names_to_eliminate]

Comment thread namedisl/set_like.py
if isinstance(names_to_project_out, str):
names_to_project_out = [names_to_project_out]

names_to_remove = set(names_to_project_out)
Comment thread pyproject.toml
]

[tool.ruff.lint.per-file-ignores]
"pytools/test/*.py" = ["S102"]
Comment thread doc/conf.py
Comment on lines +11 to 14
_conf_url = "https://tiker.net/sphinxconfig-v0.py"
with urlopen(_conf_url) as _inf:
exec(compile(_inf.read(), _conf_url, "exec"), globals())


# {{{ multi expression-likes (multiaff, pwmultiaff)

@dataclass(frozen=True, eq=False)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Multi{PwAff, Aff} are stored as isl.Sets internally. This incurs the cost of converting from isl.Multi* -> isl.Map -> isl.Set.

The only operation defined for the Multi objects is get_at, which returns nisl.PwAff, which incurs the cost of reconstruction + the ISL implementation of get_at.

This can be avoided if we just store all the parts in a constantdict[int, nisl.PwAff], and update NamedIslObject operations accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants