Skip to content

Commit c44b870

Browse files
Replacing use of deprecated ast.Num (#8698)
<!--- The core Triton is a small number of people, and we receive many PRs (thank you!). To help us review your code more quickly, **if you are a new contributor (less than 3 PRs merged) we ask that you complete the following tasks and include the filled-out checklist in your PR description.** Complete the following tasks before sending your PR, and replace `[ ]` with `[x]` to indicate you have done them. --> # New contributor declaration - [x] I am not making a trivial change, such as fixing a typo in a comment. - [x] I have written a PR description following these [rules](https://cbea.ms/git-commit/#why-not-how). - [x] I have run `pre-commit run --from-ref origin/main --to-ref HEAD`. - Select one of the following. - [ ] I have added tests. - `/test` for `lit` tests - `/unittest` for C++ tests - `/python/test` for end-to-end tests - [x] This PR does not need a test because `Existing tests are sufficient`. - Select one of the following. - [x] I have not added any `lit` tests. - [ ] The `lit` tests I have added follow these [best practices](https://mlir.llvm.org/getting_started/TestingGuide/#filecheck-best-practices), including the "tests should be minimal" section. (Usually running Python code and using the instructions it generates is not minimal.) Replacing use of deprecated `ast.Num` class with `ast.Constant`. This change is necessary to allow compatibility with Python 3.14, in which `ast.Num` was removed. Co-authored-by: Rich Coombs <richardc@graphcore.ai>
1 parent 6ac622c commit c44b870

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

python/triton/compiler/code_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,9 +1161,9 @@ def visit_For(self, node):
11611161
# visit iterator arguments
11621162
# note: only `range` iterator is supported now
11631163
# collect lower bound (lb), upper bound (ub), and step
1164-
lb = iter_args[0] if len(iter_args) > 1 else self.visit(ast.Num(0))
1164+
lb = iter_args[0] if len(iter_args) > 1 else self.visit(ast.Constant(0))
11651165
ub = iter_args[1] if len(iter_args) > 1 else self.visit(node.iter.args[0])
1166-
step = iter_args[2] if len(iter_args) > 2 else self.visit(ast.Num(1))
1166+
step = iter_args[2] if len(iter_args) > 2 else self.visit(ast.Constant(1))
11671167
else:
11681168
raise RuntimeError('Only `range` and `static_range` iterators are currently supported')
11691169
# handle negative constant step (not supported by scf.for in MLIR)

0 commit comments

Comments
 (0)