Python Forum
Does @ at sign used for tother than decorators?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Does @ at sign used for tother than decorators?
#1
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'],
)
buran write Oct-12-2023, 09:02 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
(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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Decorators @ annotation drcl 3 419 Feb-24-2024, 06:12 AM
Last Post: Gribouillis
  Need to sign JWT token with JWK key stucoder 1 1,695 Feb-21-2022, 09:04 AM
Last Post: stucoder
  i making a terminal sign up website thing Kenrichppython 1 1,713 Nov-04-2021, 03:57 AM
Last Post: bowlofred
  Variable Scopes Decorators oclmedyb 6 2,752 Jan-15-2021, 02:13 PM
Last Post: oclmedyb
  Style question on adherence to PEP 8 with whitespace near an "=" sign nilesh 6 3,965 Jan-12-2021, 11:11 PM
Last Post: snippsat
  Decorators and return statements JonEdward 2 1,911 Jul-24-2020, 05:02 PM
Last Post: JonEdward
  Syntax Error with = sign and more Kathleen57 3 2,666 May-03-2020, 03:52 AM
Last Post: buran
  How to print cache from Decorators with Memoization OlgaM 2 2,079 Jan-29-2020, 05:06 PM
Last Post: OlgaM
  Python decorators. dodiko1d 0 8,469 Oct-13-2019, 10:23 AM
Last Post: dodiko1d
  Handling pound sign (#) within custom URL chisox721 5 6,574 Apr-02-2019, 10:01 PM
Last Post: chisox721

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020