Skip to content

[Hidet Script] Allow bind_tuple argument in mapping.on(...) and grid(...)#254

Merged
yaoyaoding merged 1 commit intohidet-org:mainfrom
yaoyaoding:return-tuple
May 29, 2023
Merged

[Hidet Script] Allow bind_tuple argument in mapping.on(...) and grid(...)#254
yaoyaoding merged 1 commit intohidet-org:mainfrom
yaoyaoding:return-tuple

Conversation

@yaoyaoding
Copy link
Copy Markdown
Member

See the following usage examples:

def test_bind_tuple():
    from hidet.lang import attrs
    from hidet.lang.mapping import spatial, repeat
    from hidet.lang import printf, grid

    with hidet.script_module() as script_module:

        @hidet.script
        def launch():
            attrs.func_kind = 'public'

            for w in grid(3, attrs='p'):
                for indices in repeat(2).spatial(3).on(w, bind_tuple=True):   
                    # indices is a tuple with a single integer 
                    printf("%d %d\n", w, indices[0])

            for w in grid(3, attrs='p'):     # i is an integer
                for i in repeat(2).spatial(3).on(w):
                    printf("%d %d\n", w, i)

            for indices in grid(3, bind_tuple=True):
                printf("%d\n", indices[0])

            for indices in grid([3]):
                printf("%d\n", indices[0])

            for i in grid(3):
                printf("%d\n", i)

    cm = script_module.build()
    cm()

@yaoyaoding yaoyaoding merged commit e2a7640 into hidet-org:main May 29, 2023
@yaoyaoding yaoyaoding deleted the return-tuple branch May 29, 2023 03:01
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