Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- master

env:
uv-version: "0.8.3"
uv-version: "0.9.0"

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v*'

env:
uv-version: "0.8.3"
uv-version: "0.9.0"

jobs:
pypi-publish:
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"returns >= 0.20,<0.26",
"returns >= 0.20,<0.27",
"cffi ~= 1.16",
"llvmlite == 0.44.*",
"llvmlite == 0.45.*",
"parsita == 2.*",
"typer == 0.15.*",
"typer == 0.19.*",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -67,7 +67,7 @@ fuzz = [
"hypofuzz == 24.*"
]
lint = [
"ruff == 0.6.*"
"ruff == 0.14.*"
]
docs = [
"mkdocs-material == 9.*"
Expand Down
4 changes: 2 additions & 2 deletions src/tensora/_stable_set.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

__all__ = ["StableSet", "StableFrozenSet"]
__all__ = ["StableFrozenSet", "StableSet"]

from typing import AbstractSet, Hashable, Iterator, MutableSet, TypeVar

Expand All @@ -10,7 +10,7 @@
class StableSet(MutableSet[Element]):
def __init__(self, *items: Element):
# Rely on stable dictionary
self._items = {item: None for item in items}
self._items = dict.fromkeys(items, None)

def __len__(self) -> int:
return len(self._items)
Expand Down
4 changes: 2 additions & 2 deletions src/tensora/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def tensora(
"Unmentioned tensors are be assumed to be all dense."
),
),
] = [], # noqa: B006; Typer does not support Sequence or tuple
] = [], # noqa: B006 Typer does not support Sequence or tuple
kernel_types: Annotated[
list[KernelType],
typer.Option(
"--type",
"-t",
help="The type of kernel that will be generated. Can be mentioned multiple times.",
),
] = [KernelType.compute], # noqa: B006; Typer does not support Sequence or tuple
] = [KernelType.compute], # noqa: B006 Typer does not support Sequence or tuple
language: Annotated[
Language,
typer.Option(
Expand Down
2 changes: 1 addition & 1 deletion src/tensora/codegen/_ir_to_c.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ["ir_to_c_statement", "ir_to_c_function_definition", "ir_to_c"]
__all__ = ["ir_to_c", "ir_to_c_function_definition", "ir_to_c_statement"]

from functools import singledispatch

Expand Down
6 changes: 3 additions & 3 deletions src/tensora/codegen/_type_to_llvm.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
__all__ = [
"llvm_integer_type",
"llvm_float_type",
"attribute_indexes",
"llvm_boolean_type",
"llvm_float_type",
"llvm_integer_type",
"llvm_mode_type",
"llvm_size_type",
"type_to_llvm",
"attribute_indexes",
]

from functools import singledispatch
Expand Down
4 changes: 2 additions & 2 deletions src/tensora/compile/_cffi_ownership.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
__all__ = [
"allocate_taco_structure",
"taco_structure_to_cffi",
"taco_type_header",
"take_ownership_of_arrays",
"take_ownership_of_tensor_members",
"take_ownership_of_tensor",
"taco_type_header",
"take_ownership_of_tensor_members",
"tensor_cdefs",
]

Expand Down
2 changes: 1 addition & 1 deletion src/tensora/compile/_porcelain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ["tensor_method", "evaluate", "evaluate_cffi", "evaluate_tensora"]
__all__ = ["evaluate", "evaluate_cffi", "evaluate_tensora", "tensor_method"]

from functools import lru_cache

Expand Down
2 changes: 1 addition & 1 deletion src/tensora/compile/_tensor_method.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__all__ = [
"TensorMethod",
"BackendCompiler",
"BroadcastTargetIndexError",
"TensorMethod",
]

from dataclasses import dataclass
Expand Down
12 changes: 6 additions & 6 deletions src/tensora/desugar/ast.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
__all__ = [
"Add",
"Assignment",
"Contract",
"Expression",
"Literal",
"Integer",
"Float",
"Tensor",
"Add",
"Integer",
"Literal",
"Multiply",
"Contract",
"Assignment",
"Tensor",
]

from dataclasses import dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/tensora/expression/_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ["MutatingAssignmentError", "InconsistentDimensionsError", "NameConflictError"]
__all__ = ["InconsistentDimensionsError", "MutatingAssignmentError", "NameConflictError"]

from dataclasses import dataclass

Expand Down
12 changes: 6 additions & 6 deletions src/tensora/expression/ast.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from __future__ import annotations

__all__ = [
"Add",
"Assignment",
"Expression",
"Literal",
"Integer",
"Float",
"Tensor",
"Add",
"Subtract",
"Integer",
"Literal",
"Multiply",
"Assignment",
"Subtract",
"Tensor",
]

from abc import abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion src/tensora/format/_format.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

__all__ = ["Mode", "Format"]
__all__ = ["Format", "Mode"]

from dataclasses import dataclass
from enum import Enum
Expand Down
2 changes: 1 addition & 1 deletion src/tensora/generate/_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ["generate_code", "Language"]
__all__ = ["Language", "generate_code"]

from enum import Enum

Expand Down
2 changes: 1 addition & 1 deletion src/tensora/ir/_peephole.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* redundant_assignment: a = a => {}
"""

__all__ = ["peephole_function_definition", "peephole_statement", "peephole"]
__all__ = ["peephole", "peephole_function_definition", "peephole_statement"]

from dataclasses import replace
from functools import singledispatch
Expand Down
46 changes: 23 additions & 23 deletions src/tensora/ir/ast.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
from __future__ import annotations

__all__ = [
"Statement",
"Expression",
"Add",
"And",
"ArrayAllocate",
"ArrayIndex",
"ArrayReallocate",
"Assignable",
"Variable",
"Assignment",
"AttributeAccess",
"ArrayIndex",
"IntegerLiteral",
"FloatLiteral",
"Block",
"BooleanLiteral",
"Add",
"Subtract",
"Multiply",
"BooleanToInteger",
"Branch",
"Declaration",
"DeclarationAssignment",
"Equal",
"NotEqual",
"Expression",
"FloatLiteral",
"FunctionDefinition",
"GreaterThan",
"GreaterThanOrEqual",
"IntegerLiteral",
"LessThan",
"LessThanOrEqual",
"And",
"Or",
"Loop",
"Max",
"Min",
"BooleanToInteger",
"ArrayAllocate",
"ArrayReallocate",
"Declaration",
"Assignment",
"DeclarationAssignment",
"Block",
"Branch",
"Loop",
"Return",
"FunctionDefinition",
"Module",
"Multiply",
"NotEqual",
"Or",
"Return",
"Statement",
"Subtract",
"Variable",
]

from dataclasses import dataclass
Expand Down
18 changes: 9 additions & 9 deletions src/tensora/ir/types.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
__all__ = [
"Type",
"Integer",
"integer",
"Array",
"FixedArray",
"Float",
"float",
"Tensor",
"tensor",
"Integer",
"Mode",
"mode",
"Pointer",
"Array",
"FixedArray",
"Tensor",
"Type",
"float",
"integer",
"mode",
"tensor",
]

from dataclasses import dataclass
Expand Down
4 changes: 1 addition & 3 deletions src/tensora/iteration_graph/_generate_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,7 @@ def to_ir_sum(self: SumNode, output: Output, kernel_type: KernelType):

if kernel_type.is_compute():
# No assembly is currently allowed downstream of a Sum node
next_output, next_output_declarations, next_output_cleanup = output.next_output(
None, kernel_type
)
next_output, next_output_declarations, _ = output.next_output(None, kernel_type)
source.append(next_output_declarations)

for term in self.terms:
Expand Down
12 changes: 6 additions & 6 deletions src/tensora/iteration_graph/_names.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from __future__ import annotations

__all__ = [
"dimension_name",
"pos_name",
"crd_name",
"vals_name",
"pos_capacity_name",
"crd_capacity_name",
"vals_capacity_name",
"crd_name",
"dimension_name",
"layer_pointer",
"pos_capacity_name",
"pos_name",
"previous_layer_pointer",
"sparse_end_name",
"vals_capacity_name",
"vals_name",
"value_from_crd",
]

Expand Down
4 changes: 2 additions & 2 deletions src/tensora/iteration_graph/_write_sparse_ir.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
__all__ = [
"write_sparse_initialization",
"write_crd_assembly",
"write_pos_assembly",
"write_pos_allocation",
"write_pos_assembly",
"write_sparse_initialization",
]

from ..format import Mode
Expand Down
2 changes: 1 addition & 1 deletion src/tensora/iteration_graph/identifiable_expression/ast.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ["Expression", "Literal", "Integer", "Float", "Tensor", "Add", "Multiply"]
__all__ = ["Add", "Expression", "Float", "Integer", "Literal", "Multiply", "Tensor"]

from dataclasses import dataclass

Expand Down
2 changes: 1 addition & 1 deletion src/tensora/iteration_graph/iteration_graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

__all__ = ["IterationGraph", "TerminalNode", "IterationNode", "SumNode"]
__all__ = ["IterationGraph", "IterationNode", "SumNode", "TerminalNode"]

from abc import abstractmethod
from dataclasses import dataclass, replace
Expand Down
4 changes: 2 additions & 2 deletions src/tensora/iteration_graph/outputs/_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def ravel_indexes(self, dimensions: list[Variable], indexes: list[Variable]):
return Add.join(list(reversed(terms)))

def name(self) -> Variable:
return Variable(f'bucket_{self.output.id}{"".join(f"_{x}" for x in self.layers)}')
return Variable(f"bucket_{self.output.id}{''.join(f'_{x}' for x in self.layers)}")

def loop_name(self) -> Variable:
return Variable(f'i_bucket_{self.output.id}{"".join(f"_{x}" for x in self.layers)}')
return Variable(f"i_bucket_{self.output.id}{''.join(f'_{x}' for x in self.layers)}")

def dimension_names(self):
return [dimension_name(self.output.indexes[layer]) for layer in self.layers]
4 changes: 2 additions & 2 deletions src/tensora/problem.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
__all__ = [
"Problem",
"make_problem",
"IncorrectDimensionsError",
"Problem",
"UndefinedReferenceError",
"UnusedFormatError",
"make_problem",
]

from dataclasses import dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/tensora/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def default_format_given_nnz(dimensions: Tuple[int, ...], nnz: int) -> Format:
# than the product of those dimensions.
needed_dense = 0
required_threshold = 1
for needed_dense, dimension in enumerate(dimensions): # noqa: B007; needed_dense is used
for needed_dense, dimension in enumerate(dimensions): # noqa: B007 needed_dense is used
required_threshold *= dimension
if nnz < required_threshold:
break
Expand Down
4 changes: 2 additions & 2 deletions tests/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ def test_binary_mismatched_dimensions():
a = Tensor.from_lol([3, 2, 5])
b = Tensor.from_lol([1, 2, 0, 4])

with pytest.raises(ValueError, match="Cannot apply operator +"):
with pytest.raises(ValueError, match="Cannot apply operator \\+"):
_ = a + b

with pytest.raises(ValueError, match="Cannot apply operator -"):
_ = a - b

with pytest.raises(ValueError, match="Cannot apply operator *"):
with pytest.raises(ValueError, match="Cannot apply operator \\*"):
_ = a * b


Expand Down
Loading