Skip to content

Conversation

@rajuptvs
Copy link

@rajuptvs rajuptvs commented Nov 1, 2025

Changed occurrences of Int to UInt to prevent deprecation warnings mentioned in #119
Please let me know if this is inline with the suggested changes.

Thanks!

Copy link
Collaborator

@ehsanmok ehsanmok left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Could you pixi run format to fix the formatting please?

@rajuptvs
Copy link
Author

rajuptvs commented Nov 1, 2025

Thanks a lot! Could you pixi run format to fix the formatting please?

yep, my bad! thank you.. fixed it

@rajuptvs
Copy link
Author

rajuptvs commented Nov 1, 2025

Also while going through the puzzles myself..
found few occurences where there wasn't a special init as Int of variables

fn process_sliding_window(
    output: LayoutTensor[mut=True, dtype, vector_layout],
    a: LayoutTensor[mut=False, dtype, vector_layout],
):
    thread_id = thread_idx.x

    # Each thread processes a sliding window of 3 elements
    window_sum = Scalar[dtype](0.0)

    # Sum elements in sliding window: [i-1, i, i+1]
    for offset in range(ITER):
        idx = thread_id + offset - 1
        if 0 <= idx < SIZE:
            value = rebind[Scalar[dtype]](a[idx])
            window_sum += value

    output[thread_id] = window_sum

Output

[Thread 0x7fffa57fa640 (LWP 1345974) exited]
/home/raju/personal/mojo-gpu-puzzles/problems/p09/p09.mojo:41:27: warning: deprecated implicit conversion from 'Int' to 'UInt'
        idx = thread_id + offset - 1
                          ^~~~~~
/home/raju/personal/mojo-gpu-puzzles/problems/p09/p09.mojo:1:1: note: '@implicit' constructor 'UInt.__init__' declared here
from memory import UnsafePointer

This particular case I have converted locally by type casting like below, but not in this commit

fn process_sliding_window(
    output: LayoutTensor[mut=True, dtype, vector_layout],
    a: LayoutTensor[mut=False, dtype, vector_layout],
):
    thread_id = thread_idx.x

    # Each thread processes a sliding window of 3 elements
    window_sum = Scalar[dtype](0.0)

    # Sum elements in sliding window: [i-1, i, i+1]
    for offset in range(ITER):
        idx = thread_id + UInt(offset) - 1
        if 0 <= idx < SIZE:
            value = rebind[Scalar[dtype]](a[idx])
            window_sum += value

    output[thread_id] = window_sum

so was wondering are there any pointers as to when is the deprecation warning getting triggered as such.

@ehsanmok
Copy link
Collaborator

ehsanmok commented Nov 3, 2025

Right! I think completely resolving it would require some manual type conversions. In the case above, it will be

    for offset in range(ITER):
        idx = thread_id + UInt(offset) - 1
        if 0 <= Int(idx) < SIZE:

Because, idx is UInt but SIZE is Int.

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