Python Forum
Does @ at sign used for tother than decorators? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Does @ at sign used for tother than decorators? (/thread-40911.html)



Does @ at sign used for tother than decorators? - ggpython000 - Oct-12-2023

I have simple example for decorator usage which is straightforward to understand:
def print_fcn_name(func):
        def wrapper():
            print("Something is happening before the function is called.")
            func()
            print("Something is happening after the function is called.")
        return wrapper


@print_fcn_name
def f1():
    print("this is f1...")

f1()
But I am seeing what seems usage other than decorator, for example, following statement I just can not get it:
Do I see it is calling previously defined decorator function called triton.autotune?
@triton.autotune(
    configs=[
        <data definitions1>
    ] if torch.version.hip is None else [
        <data definitions2>
    ],
    key=['M', 'N', 'K'],
)



RE: Does @ at sign used for tother than decorators? - buran - Oct-12-2023

(Oct-12-2023, 08:57 AM)ggpython000 Wrote: Do I see it is calling previously defined decorator function called triton.autotune?
Did you check the docs?

It's a decorator with arguments and the decorated function is somewhere down in the code you look at (i.e. you didn't show that part here)

In the example in the docs the function kernel() is decorated with 2 decorators - @triton.autotune and @triton.jit