Skip to content

Conversation

@stever178
Copy link
Contributor

@stever178 stever178 commented May 7, 2025

pytest output:

=============================== test session starts ================================
platform linux -- Python 3.12.3, pytest-8.3.5, pluggy-1.5.0
rootdir: /home/lsj/projects/ntops
configfile: pyproject.toml
plugins: cov-6.1.1
collected 70 items

tests/test_abs.py ........                                                   [ 11%]
tests/test_add.py ........                                                   [ 22%]
tests/test_addmm.py ..                                                       [ 25%]
tests/test_bmm.py ..                                                         [ 28%]
tests/test_div.py ........                                                   [ 40%]
tests/test_exp.py ........                                                   [ 51%]
tests/test_gelu.py ........                                                  [ 62%]
tests/test_mm.py ..                                                          [ 65%]
tests/test_mul.py ........                                                   [ 77%]
tests/test_relu.py ........                                                  [ 88%]
tests/test_rsqrt.py ........                                                 [100%]
                                                                                    
========================== 70 passed in 80.04s (0:01:20) ===========================

@stever178 stever178 marked this pull request as ready for review May 7, 2025 13:56
Copy link
Collaborator

@voltjia voltjia left a comment

Choose a reason for hiding this comment

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

Please use Markdown syntax to denote a word or phrase as code in the commit messages:

  1. Add relu operator
  2. Remove the asterisk in the declaration of function relu in src/ntops/torch.py
  3. Add inplace parameter for relu

In src/ntops/kernels/relu.py, we don't actually need a replace parameter, because we can implement the inplace logic in src/ntops/torch.py:

def relu(input, inplace=False):
    if inplace:
        output = input
    else:
        output = torch.empty_like(input)

    kernel = ntops.kernels.relu.make(input.ndim)

    kernel(input, output)

    return output

Please change src/ntops/torch.py and tests/test_relu.py accordingly.

In addition, we use Ruff as our Python linter and code formatter. Please run the following before each commit:

ruff format
ruff check

@stever178 stever178 marked this pull request as draft May 8, 2025 12:27
@stever178 stever178 marked this pull request as ready for review May 8, 2025 12:58
@stever178 stever178 requested a review from voltjia May 8, 2025 13:42
Copy link
Collaborator

@voltjia voltjia left a comment

Choose a reason for hiding this comment

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

Nice work! There's just one last minor issue: In tests/test_relu.py, is replace a typo? If so, please change it to inplace.

@stever178 stever178 marked this pull request as draft May 9, 2025 12:41
@stever178 stever178 marked this pull request as ready for review May 9, 2025 13:56
@stever178 stever178 requested a review from voltjia May 9, 2025 14:25
@voltjia voltjia merged commit 0222cab into InfiniTensor:master May 10, 2025
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.

2 participants