Skip to content

Commit

Permalink
Fix up the doc build
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Dec 19, 2024
1 parent f465946 commit 90f4b88
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 31 deletions.
2 changes: 2 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@

# Reference not found from "<unknown>"? I'm not even sure where to look.
["py:class", r"ExpressionNode"],

["py:class", r"InameStr"],
]

autodoc_type_aliases = {
Expand Down
8 changes: 1 addition & 7 deletions doc/ref_kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,6 @@ Helper values

.. {{{
.. autoclass:: auto

.. autoclass:: UniqueName

.. autoclass:: Optional
Expand Down Expand Up @@ -693,11 +691,7 @@ The Kernel Object
Do not create :class:`LoopKernel` objects directly. Instead, refer to
:ref:`creating-kernels`.

.. autoclass:: LoopKernel

.. autoclass:: KernelState
:members:
:undoc-members:
.. automodule:: loopy.kernel

Implementation Details: The Base Array
--------------------------------------
Expand Down
23 changes: 16 additions & 7 deletions loopy/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
Sequence,
)

from immutables import Map
import immutables

from loopy.codegen.result import CodeGenerationResult
from loopy.library.reduction import ReductionOpFunction
Expand All @@ -44,8 +44,10 @@

from functools import reduce

import islpy # to help out Sphinx
import islpy as isl
from pytools import ProcessLogger, UniqueNameGenerator
import pytools # to help out Sphinx
from pytools import ProcessLogger
from pytools.persistent_dict import WriteOncePersistentDict

from loopy.diagnostic import LoopyError, warn
Expand Down Expand Up @@ -161,23 +163,24 @@ class CodeGenerationState:
# LoopKernel should not have a target, should use this instead
target: TargetBase

implemented_domain: isl.Set
implemented_domain: islpy.Set
"""
The entire implemented domain (as an :class:`islpy.Set`)
i.e. all constraints that have been enforced so far.
"""

implemented_predicates: frozenset[str | Expression]

# /!\ mutable
seen_dtypes: set[LoopyType]
seen_functions: set[SeenFunction]
seen_atomic_dtypes: set[LoopyType]

var_subst_map: Map[str, Expression]
var_subst_map: immutables.Map[str, Expression]
allow_complex: bool
callables_table: CallablesTable
is_entrypoint: bool
var_name_generator: UniqueNameGenerator
var_name_generator: pytools.UniqueNameGenerator
is_generating_device_code: bool

gen_program_name: str
Expand Down Expand Up @@ -328,6 +331,12 @@ def map_constant(self, expr):

@dataclass(frozen=True)
class PreambleInfo:
"""
.. autoattribute:: kernel
.. autoattribute:: seen_dtypes
.. autoattribute:: seen_functions
.. autoattribute:: seen_atomic_dtypes
"""
kernel: LoopKernel
seen_dtypes: set[LoopyType]
seen_functions: set[SeenFunction]
Expand Down Expand Up @@ -379,7 +388,7 @@ def generate_code_for_a_single_kernel(kernel, callables_table, target,
seen_dtypes=seen_dtypes,
seen_functions=seen_functions,
seen_atomic_dtypes=seen_atomic_dtypes,
var_subst_map=Map(),
var_subst_map=immutables.Map(),
allow_complex=allow_complex,
var_name_generator=kernel.get_var_name_generator(),
is_generating_device_code=False,
Expand Down Expand Up @@ -480,7 +489,7 @@ def diverge_callee_entrypoints(program):

new_callables[name] = clbl

return program.copy(callables_table=Map(new_callables))
return program.copy(callables_table=immutables.Map(new_callables))


@dataclass(frozen=True)
Expand Down
41 changes: 25 additions & 16 deletions loopy/kernel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
"""Kernel object."""
"""
.. currentmodule:: loopy
.. autoclass:: LoopKernel
.. autoclass:: KernelState
:members:
:undoc-members:
"""
from __future__ import annotations


Expand All @@ -23,7 +31,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

from collections import defaultdict
from dataclasses import dataclass, field, fields, replace
from enum import IntEnum
Expand All @@ -37,13 +44,13 @@
Iterator,
Mapping,
Sequence,
Tuple,
)
from warnings import warn

import numpy as np
from immutables import Map

import islpy # to help out Sphinx
import islpy as isl
from islpy import dim_type
from pymbolic import ArithmeticExpression
Expand All @@ -55,10 +62,10 @@
)
from pytools.tag import Tag, Taggable

import loopy.kernel.data # to help out Sphinx
from loopy.diagnostic import CannotBranchDomainTree, LoopyError, StaticValueFindingError
from loopy.kernel.data import (
ArrayArg,
Iname,
KernelArgument,
SubstitutionRule,
TemporaryVariable,
Expand All @@ -76,7 +83,7 @@


if TYPE_CHECKING:
from loopy.codegen import PreambleInfo
import loopy.codegen # to help out Sphinx
from loopy.kernel.function_interface import InKernelCallable


Expand All @@ -96,12 +103,9 @@ def _get_inames_from_domains(domains):

@dataclass(frozen=True)
class _BoundsRecord:
lower_bound_pw_aff: isl.PwAff
upper_bound_pw_aff: isl.PwAff
size: isl.PwAff


PreambleGenerator = Callable[["PreambleInfo"], Iterator[Tuple[int, str]]]
lower_bound_pw_aff: islpy.PwAff
upper_bound_pw_aff: islpy.PwAff
size: islpy.PwAff


@dataclass(frozen=True)
Expand Down Expand Up @@ -141,7 +145,7 @@ class LoopKernel(Taggable):
.. automethod:: tagged
.. automethod:: without_tags
"""
domains: Sequence[isl.BasicSet]
domains: Sequence[islpy.BasicSet]
"""Represents the :ref:`domain-tree`."""

instructions: Sequence[InstructionBase]
Expand All @@ -150,13 +154,13 @@ class LoopKernel(Taggable):
"""

args: Sequence[KernelArgument]
assumptions: isl.BasicSet
assumptions: islpy.BasicSet
"""
Must be a :class:`islpy.BasicSet` parameter domain.
"""

temporary_variables: Mapping[str, TemporaryVariable]
inames: Mapping[InameStr, Iname]
inames: Mapping[InameStr, loopy.kernel.data.Iname]
"""
An entry is guaranteed to be present for each iname.
"""
Expand All @@ -169,7 +173,11 @@ class LoopKernel(Taggable):
name: str = "loopy_kernel"

preambles: Sequence[tuple[int, str]] = ()
preamble_generators: Sequence[PreambleGenerator] = ()
preamble_generators: Sequence[
Callable[
[loopy.codegen.PreambleInfo],
Iterator[tuple[int, str]]]
] = ()
symbol_manglers: Sequence[
Callable[[LoopKernel, str], tuple[LoopyType, str] | None]] = ()
linearization: Sequence[ScheduleItem] | None = None
Expand Down Expand Up @@ -1360,7 +1368,8 @@ def get_copy_kwargs(self, **kwargs: Any) -> dict[str, Any]:
if "domains" in kwargs:
inames = kwargs.get("inames", self.inames)
domains = kwargs["domains"]
kwargs["inames"] = {name: inames.get(name, Iname(name, frozenset()))
kwargs["inames"] = {name: inames.get(name,
loopy.kernel.data.Iname(name, frozenset()))
for name in _get_inames_from_domains(domains)}

assert all(dom.get_ctx() == isl.DEFAULT_CONTEXT for dom in domains)
Expand Down
2 changes: 1 addition & 1 deletion loopy/kernel/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
if TYPE_CHECKING:
from loopy.codegen import VectorizationInfo
from loopy.kernel import LoopKernel
from loopy.kernel.data import ArrayArg, TemporaryVariable, auto
from loopy.kernel.data import ArrayArg, TemporaryVariable
from loopy.target import TargetBase

if getattr(sys, "_BUILDING_SPHINX_DOCS", False):
Expand Down
4 changes: 4 additions & 0 deletions loopy/typing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
.. autoclass:: Expression
.. autoclass:: ShapeType
.. autodata:: InameStr
.. currentmodule:: loopy
.. autoclass:: auto
"""

Expand Down

0 comments on commit 90f4b88

Please sign in to comment.