tilelang.language.print ======================= .. py:module:: tilelang.language.print .. autoapi-nested-parse:: This module provides macros and utilities for debugging TileLang (tl) programs. It includes functionality to print variables, print values in buffers, and conditionally execute debug prints. Functions --------- .. autoapisummary:: tilelang.language.print.print_var tilelang.language.print.print_var_with_condition tilelang.language.print.print_global_buffer_with_condition tilelang.language.print.print_shared_buffer_with_condition tilelang.language.print.print_fragment_buffer_with_condition tilelang.language.print.print_local_buffer_with_condition tilelang.language.print.print Module Contents --------------- .. py:function:: print_var(var, msg = '') Prints the value of a TIR primitive expression (PrimExpr) for debugging purposes. :param var: The variable or expression to be printed. :type var: tir.PrimExpr :returns: The TIR expression for the debug print operation. :rtype: tir.PrimExpr .. py:function:: print_var_with_condition(condition, var, msg = '') Conditionally prints a TIR primitive expression (PrimExpr) if a given condition is True. :param condition: A TIR expression representing the condition to check. :type condition: tir.PrimExpr :param var: The variable or expression to be printed. :type var: tir.PrimExpr :returns: The TIR expression for the debug print operation, if the condition is True. :rtype: tir.PrimExpr .. py:function:: print_global_buffer_with_condition(condition, buffer, elems, msg = '') Conditionally prints the values of a flattened TIR buffer if the condition is True. .. py:function:: print_shared_buffer_with_condition(condition, buffer, elems, msg = '') Conditionally prints the values of a flattened TIR buffer if the condition is True. :param condition: A TIR expression representing the condition to check. :type condition: tir.PrimExpr :param buffer: The buffer whose values need to be printed. :type buffer: tir.Buffer :param elems: The number of elements in the buffer to print. :type elems: int :returns: The TIR expression for the debug print operation. :rtype: tir.PrimExpr .. py:function:: print_fragment_buffer_with_condition(condition, buffer, elems, msg = '') Conditionally prints the values of a flattened TIR buffer if the condition is True. :param condition: A TIR expression representing the condition to check. :type condition: tir.PrimExpr :param buffer: The buffer whose values need to be printed. :type buffer: tir.Buffer :param elems: The number of elements in the buffer to print. :type elems: int :returns: The TIR expression for the debug print operation. :rtype: tir.PrimExpr .. py:function:: print_local_buffer_with_condition(condition, buffer, elems, msg = '') Conditionally prints the values of a flattened TIR buffer if the condition is True. :param condition: A TIR expression representing the condition to check. :type condition: tir.PrimExpr :param buffer: The buffer whose values need to be printed. :type buffer: tir.Buffer :param elems: The number of elements in the buffer to print. :type elems: int :returns: The TIR expression for the debug print operation. :rtype: tir.PrimExpr .. py:function:: print(obj, msg = '', warp_group_id = 0, warp_id = 0) A generic print function that handles both TIR buffers and primitive expressions. - If the input is a TIR buffer, it prints its values, but only on the first thread (tx=0, ty=0, tz=0). - If the input is a TIR primitive expression, it prints its value directly. :param obj: The object to print. It can be either a tir.Buffer or tir.PrimExpr. :type obj: Any :param msg: An optional message to include in the print statement. :type msg: str :param warp_group_id: The warp group id to print. :type warp_group_id: int :param warp_id: The warp id to print. :type warp_id: int :param print thread will be warp_group_id * warp_group_size + warp_id.: :returns: The TIR expression for the debug print operation. :rtype: tir.PrimExpr :raises ValueError: If the input object type is unsupported.