Skip to content

Conversation

@Hzfengsy
Copy link
Member

Adds comprehensive Tile type support for block-level programming:

  • New pl.Tile[[shape], dtype] type annotation mirroring Tensor pattern
  • Block operations wrapper (load, store, add, mul, sqrt, sum, etc.)
  • Type resolver support for Tile with 2D shape validation
  • Updated tests to use modern @pl.program decorator pattern
  • Documentation updates for operator organization and syntax

Adds comprehensive Tile type support for block-level programming:
- New `pl.Tile[[shape], dtype]` type annotation mirroring Tensor pattern
- Block operations wrapper (load, store, add, mul, sqrt, sum, etc.)
- Type resolver support for Tile with 2D shape validation
- Updated tests to use modern @pl.program decorator pattern
- Documentation updates for operator organization and syntax
Copilot AI review requested due to automatic review settings January 31, 2026 06:54
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Hzfengsy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the PyPTO Language DSL by integrating a new Tile type for block-level programming. It provides a robust framework for defining and manipulating data blocks, complete with type annotations, a rich set of operations, and updated type resolution logic. These changes aim to simplify the expression of hardware-optimized programming patterns within the DSL, making it more powerful and user-friendly for low-level computations.

Highlights

  • New Tile Type: Introduced a comprehensive pl.Tile[[shape], dtype] type annotation for block-level programming, mirroring the existing Tensor pattern.
  • Block Operations: Added a wrapper for various block operations such as load, store, add, mul, sqrt, and sum, enabling type-safe DSL code for tile manipulations.
  • Type Resolver Enhancements: Updated the type resolver to support the new Tile type, including validation for 2D shapes, ensuring correct type inference and error handling.
  • Testing Modernization: Refactored existing memory reuse tests to utilize the modern @pl.program decorator pattern and the new pl.Tile type, improving test clarity and alignment with the DSL.
  • Documentation Updates: Revised documentation to include examples of the new high-level API for block operations and clarify operator organization and syntax.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces comprehensive support for a Tile type and block-level operations in the language DSL. The changes are well-structured, including updates to the language API, parser, and documentation. The refactoring of the test_basic_memory_reuse.py test to use the new @pl.program decorator is a significant improvement, making the tests more readable and modern. My review includes a couple of suggestions to improve documentation consistency and reduce code duplication in the new block_ops.py module.

Comment on lines +90 to +115
def add(lhs: Tile, rhs: Tile) -> Tile:
"""Element-wise addition of two tiles.

Args:
lhs: Left-hand side tile
rhs: Right-hand side tile

Returns:
Tile wrapping the add operation
"""
call_expr = _ir_ops.add(lhs.unwrap(), rhs.unwrap())
return Tile(expr=call_expr)


def sub(lhs: Tile, rhs: Tile) -> Tile:
"""Element-wise subtraction of two tiles.

Args:
lhs: Left-hand side tile
rhs: Right-hand side tile

Returns:
Tile wrapping the sub operation
"""
call_expr = _ir_ops.sub(lhs.unwrap(), rhs.unwrap())
return Tile(expr=call_expr)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There is a lot of repetitive code for creating the block operations. You can reduce this boilerplate by using helper functions for common patterns like unary and binary operations. This will improve maintainability.

For example, for binary operations like add, sub, mul, div, and maximum, you could use a helper like this:

from collections.abc import Callable

def _create_binary_op(op_func: Callable[[Expr, Expr], Expr], lhs: Tile, rhs: Tile) -> Tile:
    """Helper to create a binary operation on two tiles."""
    call_expr = op_func(lhs.unwrap(), rhs.unwrap())
    return Tile(expr=call_expr)

def add(lhs: Tile, rhs: Tile) -> Tile:
    """Element-wise addition of two tiles."""
    return _create_binary_op(_ir_ops.add, lhs, rhs)

def sub(lhs: Tile, rhs: Tile) -> Tile:
    """Element-wise subtraction of two tiles."""
    return _create_binary_op(_ir_ops.sub, lhs, rhs)

Similar helpers can be created for unary operations and operations with scalars.

Copy link
Contributor

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

Adds first-class Tile support to the PyPTO Language DSL, enabling type-annotated block/tile programming alongside existing Tensor patterns.

Changes:

  • Introduces pl.Tile[[shape], dtype] wrapper type and exports it from pypto.language.
  • Adds pl.op.block.* language-level wrappers for block/tile ops (load/store/elementwise/unary/reduction/matmul).
  • Extends the language type resolver to parse Tile annotations (subscript and legacy call forms), updates docs, and modernizes the BasicMemoryReuse tests to the @pl.program style.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/ut/ir/transforms/test_basic_memory_reuse.py Refactors memory reuse tests to the @pl.program DSL style and uses pl.Tile annotations + pl.op.block calls.
python/pypto/language/tile.py Adds the Tile language wrapper type (annotation + runtime wrapper).
python/pypto/language/parser/type_resolver.py Adds Tile type annotation parsing and rank validation (<=2 dims).
python/pypto/language/op/block_ops.py Adds language-level, type-safe wrappers around IR block_ops that return/accept Tile/Tensor wrappers.
python/pypto/language/op/init.py Exposes pl.op.block alongside pl.op.tensor.
python/pypto/language/init.py Re-exports Tile and documents block/tile usage in module docstring.
docs/dev/07-python_syntax.md Updates syntax docs and adds a Tile/block example section.
docs/dev/06-operator_organization.md Adds a high-level Language DSL example for block ops.

Hzfengsy and others added 3 commits January 31, 2026 15:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Hzfengsy Hzfengsy merged commit 57659c4 into hw-native-sys:main Jan 31, 2026
2 checks passed
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.

1 participant