Skip to content

Commit

Permalink
Fix narrowing errors by replacing int by ssize_t
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb committed Apr 21, 2024
1 parent 0727538 commit 7785dc8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pytensor/tensor/elemwise_cgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def make_declare(loop_orders, dtypes, sub):
decl += f"""
npy_intp {var}_n{int(value)};
ssize_t {var}_stride{int(value)};
int {var}_jump{int(value)}_{int(j)};
ssize_t {var}_jump{int(value)}_{int(j)};
"""

else:
# if the dimension is broadcasted, we only need
# the jump (arbitrary length and stride = 0)
decl += f"""
int {var}_jump{value}_{int(j)};
ssize_t {var}_jump{value}_{int(j)};
"""

return decl
Expand Down Expand Up @@ -381,7 +381,7 @@ def get_loop_strides(loop_order, i):
)

declare_strides = f"""
int init_strides[{int(nvars)}][{int(nnested)}] = {{
ssize_t init_strides[{int(nvars)}][{int(nnested)}] = {{
{strides}
}};"""

Expand All @@ -397,7 +397,7 @@ def get_loop_strides(loop_order, i):
{ovar}_loops_rit = {ovar}_loops.rbegin();"""
for j in reversed(range(nnested)):
declare_strides += f"""
int {var}_stride_l{int(j)} = init_strides[{int(i)}][{ovar}_loops_rit->second];
ssize_t {var}_stride_l{int(j)} = init_strides[{int(i)}][{ovar}_loops_rit->second];
++{ovar}_loops_rit;
"""

Expand Down

0 comments on commit 7785dc8

Please sign in to comment.